Created
May 22, 2023 18:02
-
-
Save hoc081098/0df1663ce5785fbb14f5252ddaac8a21 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun main() { | |
var delta = -1 | |
val m = 3 | |
val offsets: List<Int> = (0..10).scan(0) { acc, _ -> | |
(acc + delta).also { | |
if (it == -m || it == m) { | |
delta = -delta | |
} | |
} | |
} | |
offsets.forEach {v -> | |
println((-m..m).map { if (v == it) "*" else " " }.joinToString("_")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment