Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Langtons-ant/Seed7/langtons-ant.seed7
Normal file
30
Task/Langtons-ant/Seed7/langtons-ant.seed7
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const type: direction is new enum UP, RIGHT, DOWN, LEFT end enum;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
const integer: width is 75;
|
||||
const integer: height is 52;
|
||||
var array array boolean: m is height times width times FALSE;
|
||||
var direction: dir is UP;
|
||||
var integer: x is width div 2;
|
||||
var integer: y is height div 2;
|
||||
begin
|
||||
while x in {1 .. width} and y in {1 .. height} do
|
||||
dir := direction conv ((ord(dir) + 2 * ord(m[y][x]) - 1) mod 4);
|
||||
m[y][x] := not m[y][x];
|
||||
case dir of
|
||||
when {UP}: decr(y);
|
||||
when {RIGHT}: decr(x);
|
||||
when {DOWN}: incr(y);
|
||||
when {LEFT}: incr(x);
|
||||
end case;
|
||||
end while;
|
||||
for key x range m do
|
||||
for y range 1 to width do
|
||||
write(".#"[succ(ord(m[x][y]))]);
|
||||
end for;
|
||||
writeln;
|
||||
end for;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue