Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Comments on Probability of rolling all 6 dice faces [FINALIZED]

Post

Probability of rolling all 6 dice faces [FINALIZED]

+1
−0

Now posted: Probability of rolling all 6 dice faces


The probability of rolling every number from 1 to 6 with $N$ six-sided dice.

Input

  • A positive integer $N$.
  • Your code must work for inputs up to and including 10, but may crash, error, or give incorrect output for larger inputs.

Output

  • A probability, $0 \le p \le 1$
  • This is the probability of seeing every number from 1 to 6 at least once after rolling $N$ six-sided dice simultaneously.
  • For inputs up to and including 10, your output is valid if rounding it to 6 decimal places results in the output shown in the test cases.

Note that this means that if you find an incorrect algorithm that happens to give the correct result when rounded to 6 decimal places for inputs from 1 to 10, that is still a valid entry.

Test cases

  • Test cases are in the format input : output.
1 : 0
2 : 0
3 : 0
4 : 0
5 : 0
6 : 0.015432
7 : 0.054012
8 : 0.114026
9 : 0.189043
10 : 0.271812

Scoring

This is a code golf challenge. Your score is the number of bytes in your code.

Explanations are optional, but I'm more likely to upvote answers that have one.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Why 29? (3 comments)
Why 29?
manassehkatz‭ wrote 10 months ago

Why go all the way to 29 decimal places? A 64-bit floating point is on the order of 16 decimal places, and that's way more than the required 6 digits. I actually don't see any point in showing the test cases with more than 7 digits - i.e., just go one beyond the requirement.

trichoplax‭ wrote 10 months ago · edited 10 months ago

Thanks for the feedback. Good point.

I just copied and pasted what I'd worked out (which was 30 significant figures, which happens to be 29 decimal places in this case). I'd worked it out with arbitrary precision to make sure I wasn't introducing errors into the test cases, but now that I've only required 6 digits you're right the rest are redundant. I suppose listing beyond 10 inputs when only the first 10 are required is also redundant.

If anyone suggests more decimal places, I've got the redundant ones to make it easy to include more. The same goes for the number of inputs - if someone points out a reason that 10 inputs is too few I can add as many more as needed from the 100 test cases.

Once I'm settled on the final figures for required number of inputs and required number of decimal places, I'll trim the test cases down to one more digit than required, as you suggest, and only the number of inputs required.

trichoplax‭ wrote 10 months ago

I apologise. I just realised this comment thread is not on my other dice draft, which has 100 test cases to 29 decimal places, so my previous response made no sense.

Once I have calculated the test cases for this draft, I will apply the same approach to both challenges - only showing as many inputs in the test cases as are required, and only showing as many decimal places as are appropriate.

I'm still considering whether 1 or 2 additional decimal places make sense for cases where the final digit would be rounded up.