Skip to content

Instantly share code, notes, and snippets.

@7yl4r
Created May 16, 2015 19:58
Show Gist options
  • Save 7yl4r/b4cf4c76ee6b1b6f6510 to your computer and use it in GitHub Desktop.
Save 7yl4r/b4cf4c76ee6b1b6f6510 to your computer and use it in GitHub Desktop.
CA Perfect Hash function?
input = "0 1 0" # example input bits
neighborhood_w = len(input) # 3
possible_states = 2^len(input)
# rule = neighbor-count mapped to indexes of original input [0,1,0], thus f(0) = input[0], etc
# edges do not wrap, padded w/ 0s
neighbor_count = "1 1 1"
hash = 1 1 1
# more pairs:
101, 121, 101
100, 110, 110
001, 011, 011
110, 221, 001
000, 001, 010, 011, 100, 101, 110, 111
000, 011, 111, 122, 110, 121, 211, 232
000, 011, 111, 100, 110, 101, 011, 0?0
^------------------------^ ^----indexOutOfBounds
collision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment