Skip to content

Commit

Permalink
First Start 🌟
Browse files Browse the repository at this point in the history
  • Loading branch information
lasecun committed Dec 1, 2023
1 parent c136f67 commit b2519fe
Show file tree
Hide file tree
Showing 3 changed files with 1,027 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/Day01.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
fun main() {

fun getNumber(result: String): Int{
if (result.length == 1) {
return Integer.parseInt(result + result)
} else if (result.length == 2) {
return Integer.parseInt(result)
} else {
val first = result.first().toString()
val last = result.last().toString()
return Integer.parseInt(first + last)
}
}

fun part1(input: List<String>): Int {
return input.size
var total = 0
input.forEach { row ->
val result = row.filter { it.isDigit() }
total += getNumber(result)
}
println("TOTAL --> $total")
return total
}

fun part2(input: List<String>): Int {
return input.size
}



// test if implementation meets criteria from the description, like:
val testInput = readInput("Day01_test")
check(part1(testInput) == 1)
check(part1(testInput) == 142)

val input = readInput("Day01")
part1(input).println()
Expand Down
Loading

0 comments on commit b2519fe

Please sign in to comment.