summary refs log tree commit diff homepage
path: root/2021/day02.pl
blob: 30dc1d12ac0e0eb53f6bcef52c43a7a75f229b57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use strict;
use warnings;
my ($depth, $pos) = (0, 0);
my ($depth2, $pos2, $aim) = (0, 0, 0);
while (<>) {
	if (/forward (\d+)/) {
		$pos += $1;
		$pos2 += $1;
		$depth2 += $aim * $1;
	} elsif (/down (\d+)/) {
		$depth += $1;
		$aim += $1;
	} elsif (/up (\d+)/) {
		$depth -= $1;
		$aim -= $1;
	}
}
print $depth * $pos, "\n";
print $depth2 * $pos2, "\n";
follow=1'>Reuse CGColorSpace and CGDataProvider in gfcocoaJune McEnroe 2018-02-04Mark mac target phonyJune McEnroe 2018-02-04Set up Makefile for gfxx-cocoa or gfxx-fbJune McEnroe 2018-02-04Avoid doing excessive work in gfxxJune McEnroe 2018-02-04Handle window resizing in gfcocoaJune McEnroe 2018-02-04Set cinoptionsJune McEnroe 2018-02-04Tweak colorscheme moreJune McEnroe 2018-02-04Color MatchParen DarkYellowJune McEnroe 2018-02-04Add palette sampling to gfxxJune McEnroe 2018-02-04Add 4-bit RGB to gfxxJune McEnroe 2018-02-04Add Quit menu item to gfcocoaJune McEnroe 2018-02-04Switch back to sane Objective-C styleJune McEnroe 2018-02-04Quit gfcocoa when window closesJune McEnroe 2018-02-03Apparently this is how people write Objective-CJune McEnroe