From 2ecc5db82d92d7a6fffbe7f8c1f318583a80ea24 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 8 Dec 2022 13:01:41 -0500 Subject: Solve day 8 part 1 --- 2022/day08.awk | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 2022/day08.awk (limited to '2022') diff --git a/2022/day08.awk b/2022/day08.awk new file mode 100644 index 0000000..35505e4 --- /dev/null +++ b/2022/day08.awk @@ -0,0 +1,39 @@ +function visible(x, y) { + if (x == 1 || x == right) return 1; + if (y == 1 || y == bottom) return 1; + for (xx = x-1; xx >= 1; --xx) { + if (m[xx,y] >= m[x,y]) break; + } + if (!xx) return 1; + for (xx = x+1; xx <= right; ++xx) { + if (m[xx,y] >= m[x,y]) break; + } + if (xx > right) return 1; + for (yy = y-1; yy >= 1; --yy) { + if (m[x,yy] >= m[x,y]) break; + } + if (!yy) return 1; + for (yy = y+1; yy <= bottom; ++yy) { + if (m[x,yy] >= m[x,y]) break; + } + if (yy > bottom) return 1; + return 0; +} +BEGIN { + FS = ""; +} +{ + for (x = 1; x <= NF; ++x) { + m[x,NR] = $x; + } + right = NF; + bottom = NR; +} +END { + for (x = 1; x <= right; ++x) { + for (y = 1; y <= bottom; ++y) { + if (visible(x, y)) vis++; + } + } + print vis; +} -- cgit 1.4.1 www/git.causal.agency/cgit/tests/valgrind?id=a9163f8ca3f589e3a3eaaeee339df4c55c6907ff'>tree commit diff
path: root/www/git.causal.agency/cgit/tests/valgrind (unfollow)
Commit message (Expand)Author
2021-02-09Add volume control bindings to cwmJune McEnroe
2021-02-09Use w3m to open other URLsJune McEnroe
2021-02-09Disable mouse mode in xtermJune McEnroe
2021-02-09Add pbcopy, pbpaste, open dispatch scriptsJune McEnroe
2021-02-09Use flags for pbd client behaviourJune McEnroe
2021-02-08Add macOS-like copy and paste to xtermJune McEnroe
2021-02-08Only update clock script every minuteJune McEnroe
2021-02-08Use 4M- for window resizing in cwmJune McEnroe
2021-02-08Tweak trackpad scaling, mouse accelerationJune McEnroe
2021-02-08Use xsel in up and add it do install.shJune McEnroe
2021-02-07Swap root window coloursJune McEnroe
2021-02-07Add -X flag to install X stuff on OpenBSDJune McEnroe
2021-02-07Adjust brightness by smaller incrementsJune McEnroe
2021-02-07Fix cwm window cycling, move big by defaultJune McEnroe
2021-02-07Use class names for Foreground, Background, BorderColorJune McEnroe
2021-02-07Add simple battery status and clock to xsessionJune McEnroe
2021-02-07Set cursor theme and sizeJune McEnroe
2021-02-07Use scrot for up -s if no screencaptureJune McEnroe
2021-02-07Enable mouse acceleration in XJune McEnroe
2021-02-07Set colours for Xt and cwmJune McEnroe
2021-02-07Set urgency on bell in xtermJune McEnroe
2021-02-07Add bindings for brightness controlJune McEnroe
2021-02-07Set X key repeat rateJune McEnroe
2021-02-07Bump font size to 12June McEnroe
2021-02-07Fully configure and rebind cwmJune McEnroe
2021-02-07Add BintiJune McEnroe
2021-02-07Finish configuring xtermJune McEnroe
2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe
2021-02-06Set root window to black on purple snowJune McEnroe
2021-02-06Add xmodmap configurationJune McEnroe
2021-02-06Add initial OpenBSD X configurationJune McEnroe
2021-02-06Add xterm output to schemeJune McEnroe