https://kotlinlang.org logo
Title
a

adam-mcneilly

12/01/2017, 5:21 PM
Also related to AoC earlier - does Kotlin have any circular linked list data type or would I just use any Java implementation that I've previously had? My instincts tell me no since most Kotlin collections are based upon the Java ones.
k

karelpeeters

12/01/2017, 5:51 PM
I just appended the first element to the end of the list and used
zipWithNext
on it.
Ugly but elegant 😛.
But no, I don't think this exists in the Kotlin stdlib.
a

adam-mcneilly

12/01/2017, 6:01 PM
LOOOOL I DID THIS TOO. It's not so helpful for the second part, though.
k

karelpeeters

12/01/2017, 6:01 PM
What second part?
s

stkent

12/01/2017, 6:02 PM
reminder that there's also
windowed
now
also not that helpful for part ii though
a

adam-mcneilly

12/01/2017, 6:03 PM
There's two parts to every AoC problem.
k

karelpeeters

12/01/2017, 6:04 PM
I only noticed the "sum of matching digits one" and got my golden star, what's the other one?
@stkent
zipWithNext
is also new in
1.2
.
👏 1
a

adam-mcneilly

12/01/2017, 6:05 PM
It's the same idea, but it's a circular list that wraps all the way around, so you might need to go beyond the "first" digit so it's not enough to just append it again.
That explains why I never heard of it.
k

karelpeeters

12/01/2017, 6:06 PM
I'll check it out later. You can emulate circular lists with
list[index % list.size]
if that helps.
a

adam-mcneilly

12/01/2017, 6:06 PM
That's what I've been told. I need to sit down and try that.