Skip to content

Instantly share code, notes, and snippets.

@guersam
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guersam/ab8ca328a80b3255a283 to your computer and use it in GitHub Desktop.
Save guersam/ab8ca328a80b3255a283 to your computer and use it in GitHub Desktop.
맥소날드
#!/usr/bin/env python
import itertools
NR_OF_MARIOS = 4
def mario_test(n):
marios = range(NR_OF_MARIOS)
all_cases = [p for p in itertools.product(marios, repeat = n)]
def succeed_at_last(case):
init = set(case[:-1])
return case[-1] not in init and len(init) == NR_OF_MARIOS - 1
successful_cases = filter(succeed_at_last, all_cases)
nr_all = len(all_cases)
nr_success = len(successful_cases)
print "%2d: %10d / %10d (%s)" % (n, nr_success, nr_all, nr_success / float(nr_all))
for i in range(4, 13):
mario_test(i)
4: 24 / 256 (0.09375)
5: 144 / 1024 (0.140625)
6: 600 / 4096 (0.146484375)
7: 2160 / 16384 (0.1318359375)
8: 7224 / 65536 (0.110229492188)
9: 23184 / 262144 (0.0884399414062)
10: 72600 / 1048576 (0.0692367553711)
11: 223920 / 4194304 (0.0533866882324)
12: 684024 / 16777216 (0.0407710075378)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment