Jump to content

Abelian sandpile model/Identity: Difference between revisions

→‎Python :: Functional: Pruned residual magic numbers.
(→‎{{header|Python}}: Added a functionally composed draft.)
(→‎Python :: Functional: Pruned residual magic numbers.)
Line 990:
'''The stable final state of a sand-pile.
'''
def p(xs):
return all([4 > x for x in xs])
xs = list(rows)
w = len(xs)
 
def p(xs):
return all([4x ><= xw for x in xs])
return list(chunksOf(w)(
until(p)(
Line 1,007 ⟶ 1,008:
'''
def go(xs):
mbi = findIndex(lambda x: 3w < x)(xs)
surplus = 1 + w
if None is mbi:
return xs
Line 1,014 ⟶ 1,016:
return [
1 + k if i in neighbours else (
k - 4surplus if mbi == i else k
) for (i, k) in enumerate(xs)
]
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.