Ask HN: You're in an empty room. How do you generate a random number? 27 points by TallboyOne on Sept 12, 2012 | hide | past | web | favorite | 46 comments The only thing you're wearing is 1 undergarment. The room has no windows, doors or any objects inside it.How do you generate the "most random" number you can using only what you can in your means.

 One standard trick that hasn't been mentioned: if you're e.g. looking at the ends of thrown undergarments, or at another random source that's guaranteed to produce uncorrelated output bits but is not guaranteed to produce a 0 with probability exactly 50% (e.g. an unbalanced undergarment), the following algorithm will yield uncorrelated outputs bits that are guaranteed to be 0 with probability exactly 50%:- generate two bits- if they are the same, discard both and start over- if they are 0 1, return 0- they are 1 0, return 1Also, once you have generated some entropy using the above method, you can generate a much longer random-looking number using a (pseudo-)random number generator. You could use another of von Neumann's tricks, the middle-square method (http://en.wikipedia.org/wiki/Pseudorandom_number_generator#E...), if you're decent at arithmetic (and hey, any errors can be written off as a deliberate attempt to increase entropy); if you're really paranoid, you may want to try doing RC4, although I recommend smuggling in a pen for that.That said, are you trying to solve some problem, or..?
 Take off your undergarment throw it by one wall. Assuming the room has 4 walls this is your marker for wall "0". The rest of the walls going counter-clockwise will be walls "1", "2" and "3".Close your eyes and spin in the room until you lose your orientation then stop and open your eyes. Record the number of the wall you are facing in your head.Repeat spin and remember next new number.Repeat spin and remember next new number.Repeat, repeat, repeat until you have reached the maximum amount of numbers you can remember sequentially. You will have a sequence like 2,1,3,0,2.Take your numbers, concatenate them sequentially, and translate from base 4 (ex. 21302) to base 10 (ex. 626)
 This assumes that the number of times one can rotate before losing one's orientation is random. Presumably it is not only regular, but you might even get better as you practiced. Both of these would conspire to produce substantial autocorrelation in the generated series.
 Number of rotations will probably be clustered. (degrees rotated mod 360)/4, not so much.
 To generate a number between 0 and k:0) remove undergarment (I'm assuming a bra because it's simplest, but the same principle applies to other varieties) 1) scratch your arm until you bleed 2) mark one cup of the bra with blood (both inside and outside) 3) stand against a wall 4) set i <- 0, n <- 0 5) throw bra up into the air, spinning it in the plane parallel to the floor 6) observe which cup is closer to the wall (if unclear, goto 5) 7) set x <- 0 if clean, 1 if bloody 8) if i >= floor(log2(k)), goto 11 9) set n <- n + (2i)*x 10) set i <- i + 1, goto 5 11) if n > k, goto 4 12) your number is n.
 That's easy. I just say to myself, "Think of a random number between 1 and X.", and then I do. I see magicians do this all the time.If it's hot out, I remove the undergarment.
 I thought of 7X/18
 Remove clothes. Begin urinating whilst dancing to Born this Way by Lady Gaga (music in your head). At completion of flow, see which number the splatters on the floor most resemble.
 What about people who spin in circles and think everything looks like a 0? It isn't completely random if someone is biased towards a number, especially when the picture is uncertain. A possibly better approach would be to count the number of 'splatters' (or whatever), and mod by some smaller number (i.e., 16).
 Good point. I should probably also let people choose their own tune for extra randomness.
 Divide room along one diagonal by urinating a rough line if bladder is full, or else cut your finger with your teeth and set the line that way. Similarly mark one side 'A' and the other side 'B.'Remove undergarments and crumple into ball in both hands. Stand in what appears to be the center of the room. Select an unfamiliar song and spin around singing it with eyes closed until you can no longer remember any lyrics, at which point stop and use both hands to toss up the balled-up garment.Open your eyes and search for the garment.If the garment lands so that the 'front' appears to face up, append zero to the left of the number, else append one.If garment lands in side A, flip all bits, and if garment lands in side B, flip only the bits of position equal to 1 mod c, (rightmost position called 0 for this purpose) where c is the value of the sub string of your current number generated from every third digit (positions 2, 5, and so on).Repeat until the desired range is reached by the number of digits.The method assumes that you have an incredible penchant for mental math.
 Assuming you wear light or silky undergarments and there is no constant air flow/current in the room:1. Take off your undergarment. No one else is there, you don't need it anymore.2. Tear apart your undergarment into as many small pieces as you can. Use your teeth if necessary. Let them dry to prevent clumping later. Make it an odd number to prevent you biasing the results, later.3. Stand up straight. Place your feet together. Cup undergarment fragments in your hands at chest level.4. Extend your arms, still cupping the fragments. Keep the center of your cupped hands on your plane of symmetry (in line with point at which your feet meet).5. Drop fragments.6. A. If more fragments land on the right side of the plane of symmetry, write 1.6. B. If more fragments land on the left side of the plane of symmetry, write 0.7. Repeat as many times as necessary for the number of random bits required.Upside: you can do this in the dark (problem did not mention if a light source was readily available or not).`` -- e.w.t.``
 Sit down. Pluck as many hair follicles from your body as you can. Arrange the follicles radially around your body. Remove undergarment and sit down on top of it. Choose one follicle, deliberately is fine, move this follicle closer to the undergarment than the other follicles. Stand up and with eyes closed turn as as many rotations as you can without stepping off the undergarment. Sit down. With your smallest finger, push forward from the undergarment outward along the floor. Count the number of follicles between the one closest to the undergarment and the one you pushed outward from the circle. This is your random number, its range is between zero and the total number of follicles you plucked.
 Remove undergarment. Pick at its fabric until a loose thread emerges. Pull the thread out as far as you can.Then, wrap the thread around your roundest finger or other body part as many times as it will go. It should be possible to tell what quadrant was reached by the end of the thread. E.g., if it ended up closest to the top of your chosen body part, that's 00, the right side is 01, the bottom is 10, and the left side is 11.That's two bits of reasonably-good entropy per thread. Repeat until your underwear is gone or you have the desired number of digits.Another idea: spit on the wall and count the number of heartbeats it takes for the spit to run down to the floor.
 1. de-thread the undergarment2. lay out the threads3. define distances between them to either be "big" or "small". proportion them better so that all the "big" distances are roughly the same size as each other, and do so for the smaller distances as well so there's no confusion as to which is big, and which is small.4. assign a "1" to the "big" distances, and a "0" to the "small" distances, similar to how a barcode works.5. you now have a binary number which contains as many bits as there are spaces between the individual threads (quite large!).you can generate 2^n-1 random numbers in this fashion, where n is the number of threads in the undergarment.
 Easy. The question is ambiguous and everyone else here isn't being particularly creative, yet.Is the empty room inside e.g: a space station or a rocket? Am I a robot or an alien? Does the undergarment contain any wearable electronics with an antenna?So let's say I'm an alien with an ability to detect the state of my antenna in my undergarment. I'll just occasionally check the level of a very high frequency electromagnetic wave in the antenna and occasionally write down the last significant digit of the output. no problem. ;)
 I don't really think it's creative to say "i'm an alien" and then solve the problem with some made up ability. Not to hate on your idea, it's just a bit disingenuous.
 This is an ill formed problem.If all you need to do is pick one random number, just pick one: 0 or 1. That will be to any level of proof just as random as any natural method one could devise for a single number.If instead the question is about generating a series of digits, and making an argument about the randomness of thosee digits, that is a completely different problem, and one that needs more specification about how much random data is needed and what context against which that randomness will be evaluated.
 - Put the undergarment somewhere in the room- Divide the room in two: one half that contains the undergarment and the other half- Go in the middle of the room- Close your eyes and spin for a while. Then, count one if you are facing the part of the room that contains the undergarment and 0 otherwise- Reiterate previous step as many times as necessary to build an integer (by binary writing).Was this an interview question?
 Use all 8 directions (4 walls and 4 corners). Number them from 0 to 7 or 1 to 8. Pull out one hair with the root. Use that root as an arrow. Throw the hair and watch till it lands on the ground. Use the number that the root is pointing to. Repeat. For a better effect try to blow at the hair while in air so it spins more.
 There is no 'random number'. Perhaps you mean 'a series of (uniformly/normally distributed?) random numbers between 0 and k'?For a normally distributed series of numbers make a jump and report the length (in milimeters). You will produce a series normally distributed around your average jumping length.
 Realize that you are in the Sims and some sick bastard user is trying to kill you. Look deeply within yourself and realize that what assigns your next task is partially the rand function.Use it to generate a number. Try to say it in English and fail because you only speak Simanese.
 And now a method, which doesn't involve removing your underwear.If your room is large enough choose a random path from one wall to another. Take small steps by placing one foot directly in front of the other. Count the number of steps mod a small number.
 Take off your one undergarment. Use your finger as a pen and your fecal matter as ink. Draw an x-y coordinate plane on the ground. Now throw your undergarment in the air and note which direction the elastic (or top) part is facing. Once again re-ink your pen and note this angle (from 0 to 360 degrees). Do this as many times as you feel will satisfy randomness. Take the sum of the angles and divide by the number of times you did the experiment (theoretically once should be enough).To expand on the range do this another set of times, except this time take the sum (no average) and use this as the exponent.Congratulations, you have successfully generated a random number using only your finger, fecal matter, and a little bit of math.Now sit in this room of solitude until you die or are released from Guantanamo Bay.
 I can't believe nobody has noticed that there's no light in this room. How the hell are you going to see where the walls are, or where your undergarment is falling if you throw it through the air?
 One can't be sure if there is air, gravity (or how much), or a singularity sitting right outside the room. We don't know if it is filled with solely oxygen at 100000000000000000000000000000000000000000000000psi.
 It shouldn't take to much skill with knot-tying to make a rather useful die out of the undies. Mark faces with embedded, bitten-off fingernails or bodily fluids. Roll to heart's content.
 Walk around the room, counting up from 0, until you cannot walk anymore. Convert that number to binary, and take the middle X bits, where X is the required level of entropy.
 Take off your undergarment and count the number of pubes.
 ...And mod by the number of hairs you have on your hand.
 place finger nail marks down the wall at your own random intervals, step back from the wall and spit a massive bunch of saliva onto the wall. Spin around in a circle until you are dizzy and bang your head against the wall. While dazzed count the number of nail marks the the saliva has dribbled down past and dont recount if you think you might have it wrong. That is your random number.
 You could just spray some spit on the wall and count the big blobs.
 take the button of my boxers and flip it as a coin to produce a random binary string. break it down into even chunks of the appropriate length and convert to decimal. OR inspect the threads of the undergarment cloth like they did in "Wanted", except encode each type of thread as a number instead of a character
 I'd just take my shoe off, throw it up in the air while spinning it, and use the wall it ends up pointing to.
 Shit in your hands and throw it on the ceiling. Now you got a whole fuggin fractal, duh....
 Easy: bite tongue, spit blood on wall, and read out numbers like a rorschach test.
 Even easier solution, splooge on the wall.
 I'm more worried about how the hell I got in this windowless and doorless room.
 Quantum Teleportation.
 Add to that no light, you won't be able to see anything.
 Consider the spin of any electron in the room. Do not measure it.
 Choose 4. It will be random every time.
 Or 9, 9, 9, 9, 9, and 9.
 Dilbert reference:

Applications are open for YC Summer 2020

Search: