importjava.io.Fileimportjava.lang.Exceptionconstvalfilepath="day5.txt"funmain(){valseats=File(filepath).readLines().map{line->line.map{ch->if(chin"BR")"1"else"0"}.joinToString("").toInt(2)}valmin=seats.minOrNull()?:throwException("Min not found")valmax=seats.maxOrNull()?:throwException("Max not found")valyourSeat=IntRange(min,max).firstOrNull{it!inseats}?:throwException("Seat not found")println("Highest seat number: $max\nYour seat number: $yourSeat")}
I was curious to know if Python would let you execute a lambda immediately by wrapping it with parens and giving it the input, such as (lambda)(input) and ... sure enough you can. As such, I present this monstrosity in 1 line:
Python in 2 lines
And a much more legible Kotlin
I was curious to know if Python would let you execute a lambda immediately by wrapping it with parens and giving it the input, such as
(lambda)(input)and ... sure enough you can. As such, I present this monstrosity in 1 line: