Skip to content

Instantly share code, notes, and snippets.

@kotarot
Last active October 15, 2015 07:07
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 kotarot/aed26b6aa9b0ad1748f9 to your computer and use it in GitHub Desktop.
Save kotarot/aed26b6aa9b0ad1748f9 to your computer and use it in GitHub Desktop.
For my blog article "Fewest moves vs God's number" http://www.terabo.net/blog/fmc-vs-gods-number/
#!/usr/bin/env python
"""
This scripts counts number of nodes
in 3x3x3 search tree (2)
http://www.terabo.net/blog/fmc-vs-gods-number/
"""
ALL_POS = 43252003274489856000
print 'All possible positions: {0:,d}'.format(ALL_POS)
print '----'
MAX_N = 20
nums = [1 for _ in range(0, MAX_N + 1)]
# Calculation part
for i in range(1, MAX_N + 1):
nums[i] = nums[i-1] + 18 * (15**(i-1))
# Printing part
for i in range(1, MAX_N + 1):
print "{0:2d}: {1:,d} (+{2:,d})".format(i, nums[i], nums[i] - nums[i-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment