Blog
adamcrussell adamcrussell
Latest posts 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 , Lines ):- read_line_codes ( Stream , Line ), ( Line == end_of_file -> Lines = [] ; Lines = [ Line | Rest ],…
Dec 13, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ),…
Dec 11, 2025 Prolog. Developed and tested with GNU Prolog 1.5.0. :- dynamic ([ connected / 2 , memoized_paths / 2 ]). check_and_read ( 10 , [] , _ ):- !. check_and_read ( Char , [ Char | Chars ], Stream ):- get_code ( Stream , NextChar ), check_and_read ( NextChar , Chars , Stream ). read_data ( Stream , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ),…
Dec 11, 2025 Prolog. Developed and tested with GNU Prolog 1.5.0. check_and_read ( 10 , [] , _ ):- !. check_and_read ( Char , [ Char | Chars ], Stream ):- get_code ( Stream , NextChar ), check_and_read ( NextChar , Chars , Stream ). read_data ( Stream , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code ( Stream , Char ), check_and_read ( Char , Chars ,…
Dec 11, 2025
Prolog. Developed and tested with GNU Prolog 1.5.0. check_and_read ( 10 , [] , _ ):- !. check_and_read ( Char , [ Char | Chars ], Stream ):- get_code ( Stream , NextChar ), check_and_read ( NextChar , Chars , Stream ). read_data ( Stream , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code ( Stream , Char ), check_and_read ( Char , Chars ,…
Dec 11, 2025 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 ; %seen = (); my @y_coordinates = sort { $a <=> $b } grep { ! $seen { $_ } ++ } map { $_ -> [ 1 ] } @input ; my %coordinates_x ;…
Dec 10, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 10, 2025 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 ). read_data ( Stream , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L…
Dec 9, 2025 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 ). read_data ( Stream , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L…
Dec 9, 2025 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 } - 1 )[ 0 ]); my $splits = advance( $beam [ 0 ], $beam [ 1 ], \ @grid ); $count = 1 + $splits ; say…
Dec 8, 2025 Perl. Developed and tested with Perl 5.40.0. use v5 .40 ; my @grid ; open DATA, q/data/ ; while ( <DATA> ){ chomp ; push @grid , [ split // , $_ ]; } close (DATA); my $line = shift @grid ; my @beams = ([ 0 , ( grep { $line -> [ $_ ] eq q/S/ } 0 .. @ { $line } - 1 )[ 0 ]]); my $splits = 0 ; { $line = shift @grid ; my ( $s , $b ) = advance( \ @beams , $line ); $splits += $s ; @beams = @ { $b }; redo…
Dec 8, 2025 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 , $_ ; push @grid , [ @fields ]; } close (DATA); my @operations = map { m/([\+\*])/ ; $1 } @ { pop @grid }; my @columns ;…
Dec 7, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 6, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 5, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 5, 2025 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 } - 1 ){ if ( $row -> [ $j ] eq q/@/ ){ push @accessible , [ $i , $j ] if is_accessible( $i , $j , \ @grid ); } } } push…
Dec 4, 2025
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 = 0 ; for my $i ( 0 .. @grid - 1 ){ my $row = $grid [ $i ]; for my $j ( 0 .. @ { $row } - 1 ){ if ( $row -> [ $j ] eq q/@/ ){ $forklift_accessible += is_accessible( $i , $j , \ @grid ); } } } say $forklift_accessible ; sub…
Dec 4, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 3, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 3, 2025 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 ). read_data ( Stream , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+…
Dec 2, 2025 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 ). read_data ( Stream , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+…
Dec 2, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 1, 2025 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 , []):- at_end_of_stream ( Stream ). read_data ( Stream , [ X | L ]):- \+ at_end_of_stream ( Stream ), get_code (…
Dec 1, 2025 We're together for 7 years now! Thank you!
Jul 20, 2025 See http://www.rabbitfarm.com/cgi-bin/blosxom/prolog/2025/06/29 \documentclass { article } \usepackage { color } \definecolor { linkcolor }{ rgb }{ 0, 0, 0.7 } \usepackage { amsmath } \usepackage [backref, raiselinks, pdfhighlight=/O, pagebackref, hyperfigures, breaklinks, colorlinks, pdfpagemode=UseNone, pdfstartview=FitBH, linkcolor= { linkcolor } , anchorcolor= { linkcolor } , citecolor= {…
Jul 1, 2025
← Prev ✦ Random Next → Visit ↗ Feed Kagi ↗