Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val sample1 = "4;2 1 1 1;9;3 3;6;2 2|2;2;2 1;5;1 3;1 1 1;3 1;1 4;5;1"
- val sample2 = "1;1 1 3;1 1 5;2 2 5;1 1 2 8;2 7 1;6 9 1;1 5 9 1;1 5 8;6 7;3 5|2;3 1 1;2 4;5;3 5;2 5;4;1;2;3;2;6;9;10;11;10;9;6;1 1;3"
- val sample3 = "3;5;3;2 1 2;1 1 4;1 2 1 5;1 1 7;1 7;5;3;1 1;1 1;2|2;1 1;1 2;1 1;1 2;4 2;4;1 8;3 6 1;9;3 4;1 3;1"
- fun main() {
- val nonogram = sample1
- val (rows, columns) = nonogram.split("|").map { part ->
- part.split(";").map { lineInfo -> lineInfo.split(" ").map { token -> token.toInt() } }
- }
- println("$rows")
- println("$columns")
- val height = rows.size
- val width = columns.size
- /**
- * 0 = we don't know
- * 1 = black cell
- * -1 = white cell
- */
- val field = List(height) { MutableList(width) { 0 } }
- print(field)
- while (field.any { row -> 0 in row }) {
- var improved = false
- for (i in field.indices) {
- val result = process(rows[i], field[i])
- // TODO: put result to field
- }
- for (j in field[0].indices) {
- val result = process(columns[j], field.map { row -> row[j] })
- // TODO: put result to field
- }
- if (!improved) break
- }
- }
- fun process(info: List<Int>, fieldLine: List<Int>) {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement