Skip to content

Instantly share code, notes, and snippets.

@philihp
Last active August 29, 2015 14:01
Show Gist options
  • Save philihp/276c356ed2bc2d4e7020 to your computer and use it in GitHub Desktop.
Save philihp/276c356ed2bc2d4e7020 to your computer and use it in GitHub Desktop.

Revisions

  1. philihp revised this gist May 7, 2014. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions fourkind.py
    Original file line number Diff line number Diff line change
    @@ -8,12 +8,9 @@
    for n in xrange(1,100000000):
    i = random.randint(0,99999999)
    s = "{0:0>8}".format(i);
    a = {}
    a = {"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0}
    for c in list(s):
    if c in a.keys():
    a[c]+=1;
    else:
    a[c]=1;
    a[c]+=1;
    if 4 in a.values():
    good+=1;
    if n % 100000 == 0:
  2. philihp revised this gist May 7, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions fourkind.py
    Original file line number Diff line number Diff line change
    @@ -14,8 +14,8 @@
    a[c]+=1;
    else:
    a[c]=1;
    if 4 in a.values():
    good+=1;
    if 4 in a.values():
    good+=1;
    if n % 100000 == 0:
    ratio = good/float(n)
    print "%%%.8f = %d / %d"%(ratio*100,good,n)
  3. philihp revised this gist May 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fourkind.py
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,4 @@
    good+=1;
    if n % 100000 == 0:
    ratio = good/float(n)
    print "%.4f = %d / %d"%(ratio,good,n)
    print "%%%.8f = %d / %d"%(ratio*100,good,n)
  4. philihp revised this gist May 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fourkind.py
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    a[c]+=1;
    else:
    a[c]=1;
    if max(a.values()) >= 4:
    if 4 in a.values():
    good+=1;
    if n % 100000 == 0:
    ratio = good/float(n)
  5. philihp created this gist May 7, 2014.
    21 changes: 21 additions & 0 deletions fourkind.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/usr/bin/python

    import random

    total = 0;
    good = 0;

    for n in xrange(1,100000000):
    i = random.randint(0,99999999)
    s = "{0:0>8}".format(i);
    a = {}
    for c in list(s):
    if c in a.keys():
    a[c]+=1;
    else:
    a[c]=1;
    if max(a.values()) >= 4:
    good+=1;
    if n % 100000 == 0:
    ratio = good/float(n)
    print "%.4f = %d / %d"%(ratio,good,n)