-
-
Save alexgreenbank/8f9f60abcd4fa6a140cb076264112f7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my $max_seat = undef; | |
| my $min_seat = undef; | |
| my %exist=(); | |
| while( my $line = <STDIN> ) { | |
| chomp( $line ); | |
| $line =~ tr/BRFL/1100/; | |
| my $ans = oct( "0b".$line ); | |
| $exist{$ans}=1; | |
| $min_seat=$ans if( !defined( $min_seat ) || $ans < $min_seat ); | |
| $max_seat=$ans if( !defined( $max_seat ) || $ans > $max_seat ); | |
| } | |
| print "Max: $max_seat\n"; | |
| my $ct=$min_seat+1; | |
| while( $ct < $max_seat ) { | |
| if( exists( $exist{$ct-1} ) && !exists( $exist{$ct} ) && exists( $exist{$ct+1} ) ) { | |
| print "SEAT: $ct\n"; | |
| } | |
| $ct++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment