From 3555f2afe06cf290e77585836502cfb70544d5f0 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 16 Dec 2020 12:36:55 -0500 Subject: Solve day 16 part 1 in C --- 2020/day16.pl | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 2020/day16.pl (limited to '2020/day16.pl') diff --git a/2020/day16.pl b/2020/day16.pl deleted file mode 100644 index 8ebe521..0000000 --- a/2020/day16.pl +++ /dev/null @@ -1,30 +0,0 @@ -use strict; -use warnings; - -my (%rules, @ticket, @nearby); -while (<>) { - chomp; - if (/([^:]+): (\d+)-(\d+) or (\d+)-(\d+)/) { - $rules{$1} = [$2, $3, $4, $5]; - } elsif (/your ticket:/) { - <>; - chomp; - @ticket = split ','; - } elsif (/^[\d,]+$/) { - my @fields = split ','; - push @nearby, \@fields; - } -} - -my $error = 0; -foreach my $t (@nearby) { - foreach my $f (@$t) { - my $valid = 0; - foreach my $r (values %rules) { - $valid = 1 if $f >= $$r[0] && $f <= $$r[1]; - $valid = 1 if $f >= $$r[2] && $f <= $$r[3]; - } - $error += $f unless $valid; - } -} -print "$error\n"; -- cgit 1.4.1 '>summary refs log tree commit diff
path: root/git (unfollow)
Commit message (Expand)Author
2014-02-20diffstat: do not rely on uninitialized dataJason A. Donenfeld
2014-02-05gen-version.sh: check if git is available before trying to call itFabien C
2014-01-23simple-authentication: styleJason A. Donenfeld
2014-01-22makefile: use LUA_PKGCONFIG to set Lua implementationNatanael Copa
2014-01-20tests: only do lua tests if lua is compiled-inJason A. Donenfeld
2014-01-20cgit: add --version argument for printing infoJason A. Donenfeld
2014-01-19cache: use sendfile() instead of a pair of read() + write()Sebastian Andrzej Siewior
2014-01-19README: document pkg-config for luajitJason A. Donenfeld
2014-01-17makefile: bump versionJason A. Donenfeld
2014-01-17mailmap: source before lighttpdJason A. Donenfeld
2014-01-17ui-shared: do not allow negative minutesJason A. Donenfeld
2014-01-17auth: document tweakables in lua scriptJason A. Donenfeld
2014-01-17repolist: make owner clickable to searchJason A. Donenfeld
2014-01-17ui-shared: move about tab all the way to the leftJason A. Donenfeld
2014-01-17filter: don't forget to reap the auth filterJason A. Donenfeld
2014-01-17cgit.c: free tmp variableJason A. Donenfeld
2014-01-17Switch to exclusively using global ctxLukas Fleischer
2014-01-16auth: have cgit calculate login addressJason A. Donenfeld
2014-01-16auth: lua string comparisons are time invariantJason A. Donenfeld
2014-01-16authentication: use hidden form instead of refererJason A. Donenfeld
2014-01-16auth: add basic authentication filter frameworkJason A. Donenfeld
2014-01-16t0111: Additions and fixesLukas Fleischer
2014-01-16parsing.c: Remove leading space from committerLukas Fleischer