Last active
August 6, 2021 20:24
-
-
Save Eladkay/9ee28661b90d7cc14f6c990713c377dd to your computer and use it in GitHub Desktop.
I needed it, so I made it. It takes two sets of lines and merges them alternatingly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.* | |
fun main() { | |
val scanner = Scanner(System.`in`) | |
var last = "" | |
val lines1 = mutableListOf<String>() | |
do { | |
last = scanner.nextLine() | |
lines1.add(last) | |
} while (last != "$") | |
println("Size: ${lines1.size}") | |
val lines2 = mutableListOf<String>() | |
do { | |
last = scanner.nextLine() | |
lines2.add(last) | |
} while (last != "$") | |
println(lines1.mapIndexed { i, s -> "$s\n${if(lines2.size <= i) "" else lines2[i]}" }.filterNot { "$" in it }.joinToString("\n")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment