My results in thread
# advent-of-code
k
My results in thread
Lost some time in part 2 due to forgetting that
reduce
exists, and instead using a fold. Not using
fold(data.first, data.drop(1)
, no that wouldn't have been good enough. I went with
Copy code
List<Int>?>(null){ acc, n ->
		if(acc == null)
			return@fold n
		acc.zip(n){a,b->
			if(a == 2)
				b
			else
				a
		}
	}!!
I first forgot the
return@fold
which is why the the
!!
. I should have listen to the compiler instead of getting that NPE getting shoved in my face
full code
reading the result wasn't easy too
All by all I ended 18/38 which is pretty nice Might be able to get on the leaderboard by the end of the month
👍 2
k
Isn't that fold just
find
?
k
It finds the first non 2 value for each cell. But AFAIK there isn’t a stdlib function to do the transposing first
k
Ah right you're basically doing
find
over the entire grid at once, makes sense.
k
Yep