Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CraicOverflow89/ece2fc083f39d2c63889156628ecd317 to your computer and use it in GitHub Desktop.
Save CraicOverflow89/ece2fc083f39d2c63889156628ecd317 to your computer and use it in GitHub Desktop.
AOC1B
fun main(args: Array<String>)
{
// Fetch Input
val input = input()
// Iterate Chars
var total = 0
var n = 0
do
{
var pos = n + input.length / 2
if(pos > input.length - 1) pos = pos - input.length
if(input[pos] == input[n]) total += Integer.parseInt(input[n].toString())
}
while(++ n < input.length)
// Render Result
println(total)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment