Abelian sandpile model: Difference between revisions
→{{header|11l}}: Write PPM
Alextretyak (talk | contribs) (Added 11l) |
Alextretyak (talk | contribs) (→{{header|11l}}: Write PPM) |
||
Line 37:
print(row.map(c -> ‘#3’.format(c)).join(‘’))
F simulate(&grid)
L
V changed = 0B
L(arr) grid▼
L.break
simulate(&grid)
print("\nAfter:")
L(row) grid
print(row.map(c -> ‘#3’.format(c)).join(‘’))
grid = [[0] * 65] * 65
grid[32][32] = 64 * 64
simulate(&grid)
V ppm = File(‘sand_pile.ppm’, ‘w’)
ppm.write_bytes(("P6\n#. #.\n255\n".format(grid.len, grid.len)).encode())
V colors = [[Byte(0), 0, 0],
[Byte(255), 0, 0],
[Byte(0), 255, 0],
[Byte(0), 0, 255]]
L(c) row
ppm.write_bytes(colors[c])</lang>
{{out}}
|