Skip to content

Instantly share code, notes, and snippets.

@sadger
sadger / Day08.kt
Last active December 8, 2022 15:09
Advent of Code 2022 - Day 08 - Kotlin
class Day08(private val input : String) {
private fun <E> List<List<E>>.transpose(defaultValue: E) = List(maxOf{it.size}) { i -> this.map { it.getOrElse(i){defaultValue} } }
fun solveVisible(trees : List<List<Int>>, unify : (Pair<Int, Int>) -> Pair<Int, Int>) = trees.mapIndexed {row, ints ->
ints.mapIndexed { idx, treeSize ->
val compare = ints.subList(0, idx) //Other trees between it and the edge
unify(row to idx) to (compare.isEmpty() || compare.max() < treeSize)
}.filter { it.second }.map { it.first }}.flatten()
fun solveBeauty(trees : List<List<Int>>, unify : (Pair<Int, Int>) -> Pair<Int, Int>) = trees.mapIndexed {row, ints ->
--[[ Copyright (c) 2020 William "sadger" Gatens
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
--[[ Copyright (c) 2020 William "sadger" Gatens
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
#! /bin/bash
sxhkd &
bspc monitor DP-3 -d 1 2 3 4 5 6 7 8 9 10
bspc monitor DP-2 -d 1 2 3 4 5 6 7 8 9 10
bspc config border_width 4
bspc config window_gap 30
cmake \
-D WITH_MOVIES:BOOL=OFF \
-D LUA_INCLUDE_DIR=/usr/include/lua5.1 \
-D LUA_LIBRARY=/usr/lib/liblua5.1.so \
-DWITH_LUAJIT=OFF \
-D CMAKE_BUILD_TYPE=DEBUG \
-D CMAKE_INSTALL_PREFIX=/usr/share/ \
-D SDL_LIBRARY:PATH=/usr/lib64/libSDL2.so \
-D SDL_INCLUDE_DIR=/usr/include/SDL2 \
.
total 1016
drwxr-xr-x 2 root root 4096 Jan 15 18:35 .
drwxr-xr-x 6 root root 4096 Jan 15 18:11 ..
lrwxrwxrwx 1 root root 11 Jan 13 14:09 libglx.so -> libglx.xorg
lrwxrwxrwx 1 root root 16 Jan 15 18:11 libglx.so.1 -> libglx.so.343.36
lrwxrwxrwx 1 root root 56 Jan 15 18:11 libglx.so.325.15 -> /usr/lib/nvidia/xorg/modules/extensions/libglx.so.325.15
lrwxrwxrwx 1 root root 56 Jan 15 18:11 libglx.so.331.20 -> /usr/lib/nvidia/xorg/modules/extensions/libglx.so.331.20
lrwxrwxrwx 1 root root 56 Jan 15 18:11 libglx.so.340.24 -> /usr/lib/nvidia/xorg/modules/extensions/libglx.so.340.24
lrwxrwxrwx 1 root root 56 Jan 15 18:11 libglx.so.340.32 -> /usr/lib/nvidia/xorg/modules/extensions/libglx.so.340.32
lrwxrwxrwx 1 root root 56 Jan 15 18:11 libglx.so.343.36 -> /usr/lib/nvidia/xorg/modules/extensions/libglx.so.343.36
[ 20.812]
X.Org X Server 1.18.0
Release Date: 2015-11-09
[ 20.812] X Protocol Version 11, Revision 0
[ 20.812] Build Operating System: Linux 4.2.5-1-ARCH x86_64
[ 20.812] Current Operating System: Linux william-pc 4.3.3-2-ARCH #1 SMP PREEMPT Wed Dec 23 20:09:18 CET 2015 x86_64
[ 20.812] Kernel command line: BOOT_IMAGE=../vmlinuz-linux root=/dev/mapper/SadgerVolume-rootVol cryptdevice=/dev/sdc2:lvm ro initrd=../initramfs-linux.img
[ 20.812] Build Date: 08 January 2016 05:56:16PM
[ 20.812]
[ 20.812] Current version of pixman: 0.32.8
lib32-libdrm 2.4.66-1
lib32-mesa 11.1.1-1
lib32-mesa-libgl 11.1.1-1
lib32-mesa-vdpau 11.1.1-1
libdrm 2.4.66-1
mesa 11.1.1-1
mesa-demos 8.3.0-1
mesa-libgl 11.1.1-1
mesa-vdpau 11.1.1-1
[ 24.102]
X.Org X Server 1.18.0
Release Date: 2015-11-09
[ 24.102] X Protocol Version 11, Revision 0
[ 24.102] Build Operating System: Linux 4.2.5-1-ARCH x86_64
[ 24.102] Current Operating System: Linux william-pc 4.3.3-2-ARCH #1 SMP PREEMPT Wed Dec 23 20:09:18 CET 2015 x86_64
[ 24.102] Kernel command line: BOOT_IMAGE=../vmlinuz-linux root=/dev/mapper/SadgerVolume-rootVol cryptdevice=/dev/sdc2:lvm ro initrd=../initramfs-linux.img
[ 24.102] Build Date: 08 January 2016 05:56:16PM
[ 24.102]
[ 24.102] Current version of pixman: 0.32.8
[ 29.775]
X.Org X Server 1.18.0
Release Date: 2015-11-09
[ 29.775] X Protocol Version 11, Revision 0
[ 29.775] Build Operating System: Linux 4.2.3-1-ARCH x86_64
[ 29.776] Current Operating System: Linux william-pc 4.3.3-2-ARCH #1 SMP PREEMPT Wed Dec 23 20:09:18 CET 2015 x86_64
[ 29.776] Kernel command line: BOOT_IMAGE=../vmlinuz-linux root=/dev/mapper/SadgerVolume-rootVol cryptdevice=/dev/sdc2:lvm ro initrd=../initramfs-linux.img
[ 29.776] Build Date: 18 November 2015 08:07:09AM
[ 29.776]
[ 29.776] Current version of pixman: 0.32.8