All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
More randomness! (Posted on 2003-06-30) Difficulty: 3 of 5
Suppose you have a function (or a magic ball) that is capable of producing a totally random integer between 1 and 5 (inclusive).

Using this, how would you generate a random number (also an integer) between 1 and 7 (inclusive)? (Note that the for the number to be random, all integers between 1 and 7 must have an equal chance of being generated)

Assume that using your 1-5 generator is pretty time-consuming, so you want to minimize the number of times you are going to use it.

See The Solution Submitted by levik    
Rating: 4.4286 (7 votes)

Comments: ( You must be logged in to post comments.)
  Subject Author Date
re: A binary solutionS2003-10-31 00:22:11
SolutionA binary solutionFederico Kereki2003-07-14 15:49:01
Another look at optimalityfriedlinguini2003-07-01 06:55:26
re(5): solutionfriedlinguini2003-07-01 05:56:59
Questionre(4): solutionCharlie2003-07-01 05:38:24
re(3): solutionfriedlinguini2003-07-01 05:17:58
re(2): solutionCharlie2003-06-30 15:14:41
re: solutionGamer2003-06-30 13:26:10
re(2): Quick and Dirty Solutionfriedlinguini2003-06-30 09:12:31
SolutionOptimal Solutionfriedlinguini2003-06-30 09:04:07
SolutionsolutionCharlie2003-06-30 08:52:22
re: Quick and Dirty SolutionCharlie2003-06-30 08:50:42
re: Possible Solutionfriedlinguini2003-06-30 08:05:55
Some ThoughtsPossible Solutionderek2003-06-30 07:52:56
impossible?Travis Taylor2003-06-30 06:59:30
SolutionQuick and Dirty Solutionfriedlinguini2003-06-30 06:56:18
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information