Abelian sandpile model/Identity: Difference between revisions

Content deleted Content added
Hout (talk | contribs)
→‎{{header|Python}}: Added a functionally composed draft.
Hout (talk | contribs)
→‎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)
]