alexpgp: (Default)
[personal profile] alexpgp
It turns out that some of the Farkel-related numbers I've been seeing take account of the rules of the game, which apparently confer special meaning to dice showing one or five. So I'm not at all sure such numbers are of much help.

And then it struck me: brute-forcing the six dice problem should not be all that hard.

Step 1. Log into my Raspberry Pi web server, open emacs and write a perl program to produce every possible roll of 6 dice.
for ($d1 = 1; $d1 <= 6; $d1++) {
  for ($d2 = 1; $d2 <= 6; $d2++) {
    for ($d3 = 1; $d3 <= 6; $d3++) {
      for ($d4 = 1; $d4 <= 6; $d4++) {
        for ($d5 = 1; $d5 <= 6; $d5++) {
          for ($d6 = 1; $d6 <= 6; $d6++) {
            my @roll = sort ($d1, $d2, $d3, $d4, $d5, $d6);
            print(@roll, "\n");
          }
        }
      }
    }
  }
}
Yes, I know: far from elegant. But it gets the job done. I run this program from the command line and I direct its output to allrolls.txt.

Step 2. Run the Linux command line
sort allrolls.txt | uniq -c > uniquerolls.txt
What this command line does is sort the allrolls.txt file and creates an output file (uniquerolls.txt)where duplicate lines are replaced with a single line that's prefaced by the number of duplicates found in the input file, e.g.:
      1 111111
      6 111112
      6 111113
      6 111114
      6 111115
      6 111116
     15 111122
     30 111123
     30 111124
     30 111125
     30 111126
     ...
If I count the number of lines in the file uniquerolls.txt, it turns out there are only 462 different combinations of 1, 2, 3, 4, 5 and 6 possible with 6 dice, though some (112456, which can occur 360 different ways) are more probable than others (111111, which can occur in exactly one way).

Progress, surely, but Morpheus calls.

Date: 2014-01-11 01:15 pm (UTC)
From: [identity profile] nibot.livejournal.com
As you mentioned in your prior post, we can calculate the number of times some combination (like 111126) will occur by dividing the number of permutations of the whole list of digits by the product of the numbers of permutations of each group of indistinguishable things.

i.e. the number of ways to get a combination like 111126 is 6!/(4! 1! 1!) = 6*5 = 30.

The number of ways to get a combination like 112456 is 6!/(2!1!1!1!1!) = 6*5*4*3 = 360.

And the number of ways to get 111111 is 6!/6! = 1.
Edited Date: 2014-01-11 01:15 pm (UTC)

Profile

alexpgp: (Default)
alexpgp

January 2018

S M T W T F S
  1 2 3456
7 8910111213
14 15 16 17181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 28th, 2026 03:57 pm
Powered by Dreamwidth Studios