MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / format_ruleset

Function format_ruleset

cellular_automata/one_dimensional.py:18–27  ·  view source on GitHub ↗

>>> format_ruleset(11100) [0, 0, 0, 1, 1, 1, 0, 0] >>> format_ruleset(0) [0, 0, 0, 0, 0, 0, 0, 0] >>> format_ruleset(11111111) [1, 1, 1, 1, 1, 1, 1, 1]

(ruleset: int)

Source from the content-addressed store, hash-verified

16
17
18def format_ruleset(ruleset: int) -> list[int]:
19 """
20 >>> format_ruleset(11100)
21 [0, 0, 0, 1, 1, 1, 0, 0]
22 >>> format_ruleset(0)
23 [0, 0, 0, 0, 0, 0, 0, 0]
24 >>> format_ruleset(11111111)
25 [1, 1, 1, 1, 1, 1, 1, 1]
26 """
27 return [int(c) for c in f"{ruleset:08}"[:8]]
28
29
30def new_generation(cells: list[list[int]], rule: list[int], time: int) -> list[int]:

Callers 1

one_dimensional.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected