Abbreviations, automatic: Difference between revisions
→{{header|Kotlin}}: Changed code so that lines are now printed as soon as they're processed
(Added Kotlin) |
(→{{header|Kotlin}}: Changed code so that lines are now printed as soon as they're processed) |
||
Line 156:
fun main(args: Array<String>) {
val lines = File("days_of_week.txt").readLines()
for ((i, line) in lines.withIndex()) {
if (line.trim().isEmpty()) {
continue
}
Line 165 ⟶ 164:
if (days.size != 7) throw RuntimeException("There aren't 7 days in line ${i + 1}")
if (days.distinct().size < 7) { // implies some days have the same name
continue
}
Line 171 ⟶ 170:
while (true) {
if (days.map { it.take(len) }.distinct().size == 7) {
break
}
len++
}
}
}</lang>
|