Dec 13 2025
adamcrussell
Prolog. Developed and tested with GNU Prolog 1.5.0.:- dynamic(shape/2). read_line_codes(Stream, Codes):- get_code(Stream, C), ( C == -1 -> Codes = end_of_file ; C == 10 ->Codes = [] ; read_line_codes(Stream, Cs), Codes = [C|Cs] ). read_all_lines(Stream,...
Dec 11 2025
adamcrussell
Prolog. Developed and tested with GNU Prolog 1.5.0.:-dynamic([connected/2, memoized_paths/3]). check_and_read(10, [] ,_):- !. check_and_read(Char, [Char|Chars], Stream):- get_code(Stream, NextChar), check_and_read(NextChar, Chars, Stream). read_data(Stream, []):-...
Dec 10 2025
adamcrussell
Perl. Developed and tested with Perl 5.40.0.use v5.40; my @input; open DATA, q/data/; while(<DATA>){ chomp; push @input, [split /,/, $_]; } close(DATA); my %seen; my @x_coordinates = sort { $a <=> $b } grep { !$seen{$_}++ } map { $_->[0] } @input;...
Dec 09 2025
adamcrussell
Prolog. Developed and tested with GNU Prolog 1.5.0 and SWI-Prolog 9.2.9.:-dynamic(connected/2). check_and_read(10, [] ,_):- !. check_and_read(end_of_file, [], _):- !. check_and_read(Char, [Char|Chars], Stream):- get_code(Stream, NextChar), check_and_read(NextChar, Chars, Stream)....
Dec 08 2025
adamcrussell
Perl. Developed and tested with Perl 5.40.0.use v5.40; no warnings q/recursion/; my @grid; open DATA, q/data/; while(<DATA>){ chomp; push @grid, [split //, $_]; } close(DATA); my $count = 1; my $line = shift @grid; my @beam = (1, (grep {$line->[$_] eq q/S/} 0 .. @{$line} -...
Dec 07 2025
adamcrussell
Perl. Developed and tested with Perl 5.40.0.use v5.40; my @grid; open DATA, q/data/; while(<DATA>){ chop; push @grid, $_; } close(DATA); my $format = build_unpack_format(@grid); @grid = (); open DATA, q/data/; while(<DATA>){ chop; my @fields = unpack $format, $_;...
Dec 06 2025
adamcrussell
Prolog. Developed and tested with GNU Prolog 1.5.0.check_and_read(10, [] ,_):- !. check_and_read(end_of_file, [], _):- !. check_and_read(Char, [Char|Chars], Stream):- get_code(Stream, NextChar), check_and_read(NextChar, Chars, Stream). read_data(Stream, []):-...
Dec 05 2025
adamcrussell
Prolog. Developed and tested with SWI-Prolog 9.2.9.check_and_read(10, [] ,_):- !. check_and_read(end_of_file, [], _):- !. check_and_read(Char, [Char|Chars], Stream):- get_code(Stream, NextChar), check_and_read(NextChar, Chars, Stream). read_data(Stream, []):-...
Dec 04 2025
adamcrussell
Perl. Developed and tested with Perl 5.42.0.use v5.42; my @grid; open DATA, q/data/; while(<DATA>){ chomp; push @grid, [split //, $_]; } my @forklift_accessible; { my @accessible = (); for my $i (0 .. @grid - 1){ my $row = $grid[$i]; for my $j (0 .. @{$row}...
Dec 03 2025
adamcrussell
Prolog. Developed and tested with GNU Prolog 1.5.0.check_and_read(10, [] ,_):- !. check_and_read(end_of_file, [], _):- !. check_and_read(Char, [Char|Chars], Stream):- get_code(Stream, NextChar), check_and_read(NextChar, Chars, Stream). read_data(Stream, []):-...
Dec 02 2025
adamcrussell
Prolog. Developed and tested with GNU Prolog 1.5.0.check_and_read(10, [] ,_):- !. check_and_read(44, [] ,_):- !. check_and_read(end_of_file, [], _):- !. check_and_read(Char, [Char|Chars], Stream):- get_code(Stream, NextChar), check_and_read(NextChar, Chars, Stream)....
Dec 01 2025
adamcrussell
Prolog. Developed and tested with GNU Prolog 1.5.0.check_and_read(10, [] ,_):- !. check_and_read(end_of_file, [], _):- !. check_and_read(Char, [Char|Chars], Stream):- get_code(Stream, NextChar), check_and_read(NextChar, Chars, Stream). read_data(Stream, []):-...