26
0
Problem
Starting from n=2
dice:
- Roll
n
dice, with each number 1 to 6 equally likely on each die. - Check if their sum equals the most probable sum for
n
dice, that is3.5*n
.- If they're equal, terminate.
- Otherwise, print
n
, and repeat from the start withn+2
dice
Your code doesn't have to do this procedure exactly, but should give random output probabilistically equivalent to it, based on our definition of randomness.
Your program should output all of the numbers on their own line; for example, if the program got up to 8 dice and rolled the most probable number with 8 dice, the output would be:
2
4
6
Example Run
On 2 dice, 7
is the most probable sum. Let's say the numbers rolled were 2
and 3
. Then, you would print 2
.
On 4 dice, 14
is the most probable sum. Let's say the numbers rolled were 3
, 4
, 2
, and 5
. Then, the sum is 14
, so the program would terminate here.
The final output in this case is "2"
.
Rules
- code-golf so shortest solution in bytes wins
- Standard Loopholes Apply
- The meta definition of randomness applies
- You may use functions as well as programs
This answer, as it stands, is very unclear. Is there input, or is it meant to generate the output from no input as a loop? Is there any randomness? I don't seem to see any randomness involved. – HyperNeutrino – 2017-06-13T01:59:25.447
By the way, welcome to PPCG! :) – HyperNeutrino – 2017-06-13T01:59:49.557
Thank you, Sorry I am very new to this. What would make it more clear? There is no input, you are supposed to start with one die and work your way up as high as you can. – zoecarver – 2017-06-13T02:01:40.347
@pudility So if I understand correctly, I am supposed to keep outputting
2, 4, 6, 8, ...
an roll that many dice each time until I hit the most probable number for that iteration? – HyperNeutrino – 2017-06-13T02:03:02.683Yes, that is correct. – zoecarver – 2017-06-13T02:03:43.863
5
Thank you for taking the time to edit your challenge based on our feedback! For the record, we have a place where you can post challenges to work out some of the details before posting: the sandbox.
– FryAmTheEggman – 2017-06-13T02:12:06.927I think I understand the challenge instructions now, though it took me some time to digest. Would it be OK to simplify things and just say to try even numbers of nice? – xnor – 2017-06-13T02:16:55.683
I think that it would be easier just to leave it how it is now. If you think that it is really important, I can change it. But I think that it makes more sense how it is currently written. Thank you for the suggestion though. – zoecarver – 2017-06-13T02:36:54.690
@pudility I'll give a try at a general cleanup edit, and you see what you think. – xnor – 2017-06-13T02:50:58.773
@pudility I made some edits. Feel free to change things back. I tried to avoid changing any rules, but I do want to suggest allowing a freer output format. In particular, the default is to allow functions as well as programs, which may output (say as a list) rather than print. See this advice on things to avoid.
– xnor – 2017-06-13T03:03:23.027I added
you may use functions as well as programs
– zoecarver – 2017-06-13T03:07:51.277The probability of getting the most probable number with
– Leaky Nun – 2017-06-13T04:07:07.6732n
dice isA063419
(n)/(6^(2n))
.I have asked here if some of the current answers that follow a slightly different approach are valid.
– None – 2017-06-13T15:34:30.783Please do not accept answers when there are shorter answers in too. – Erik the Outgolfer – 2017-06-21T11:43:22.333