adventofcode/2020/5/hello-world.pas

39 lines
629 B
ObjectPascal
Raw Normal View History

2022-12-01 21:02:00 +01:00
PROGRAM Hello;
VAR
filein : text;
mychar : char;
highest, column, row, pass : integer;
BEGIN
highest := 0;
column := 0;
row := 0;
assign(filein, 'input');
reset(filein);
repeat begin
read(filein, mychar);
case mychar of
'F': row := row shl 1;
'B': row := (row shl 1) or 1;
'L': column := column shl 1;
'R': column := (column shl 1) or 1;
otherwise begin
pass := row * 8 + column;
if pass > highest then
highest := pass;
row := 0;
column := 0;
end
end;
end;
until eof(filein);
close(filein);
writeln('Largest boarding pass found is ', highest);
END.