Anonymous user
Abelian sandpile model: Difference between revisions
m
→{{header|Pascal}}: added link to python abelian (64)
(added pascal) |
m (→{{header|Pascal}}: added link to python abelian (64)) |
||
Line 770:
{{works with|Free Pascal}}
The main optimization was to spread the sand immediatly.<pre>mul := val DIV 4;//not only := val -4 </pre> so that only (sand mod 4) stays in place.runtime for abelian(1e6) down to 1min 20 secs from 9 min<BR>
Memorizing the used colums of the rows has little effect when choosing the right size of the grid.
[http://rosettacode.org/wiki/Abelian_sandpile_model#Python Python] shows 64 too.
<lang pascal>
program Abelian2;
Line 942 ⟶ 943:
procedure OneTurn(count:NativeUint);
begin
Writeln(' Test
MaxVal := count;
InitGrid(Grid,count);
Line 962 ⟶ 963:
{{out}}
<pre>
Test
010
101
010
columns 3 checksum 4 ?=? 4
Test
00100
02120
Line 974 ⟶ 975:
00100
columns 5 checksum 16 ?=? 16
Test
00121000
02222200
Line 984 ⟶ 985:
00000000
columns 8 checksum 64 ?=? 64
Test
0000000001111111000000000
0000000130233320310000000
Line 1,011 ⟶ 1,012:
0000000001111111000000000
columns 25 checksum 1000 ?=? 1000
Test
--shortened
columns 77 checksum 10000 ?=? 10000
Test
columns 241 checksum 100000 ?=? 100000
real 0m0,815s
</pre>
=={{header|Perl}}==
<lang Perl>#!/usr/bin/perl
|