Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.io.Source
- import scala.collection.mutable
- object Application extends App {
- val fileReader = Source.fromFile("src/main/input/puzzle1")
- val lines = fileReader.getLines.toList
- // Lag et brett som er strippet for unødvendige whitespaces
- // Lag en verdi-matrise ut i fra denne
- // Lag en nabo-matrise ut i fra denne
- fileReader.close()
- val size_string = lines.slice(1, 2)(0).toString
- val puzzle = lines.slice(2, lines.length)
- var character_matrix:List[List[Char]] = List[List[Char]]()
- for(line <- puzzle) {
- var row:List[Char] = List[Char]()
- for(char <- line) {
- if(char != " ") {
- row = row :+ char
- }
- }
- character_matrix +:= row
- }
- var value_matrix:List[List[Char]] = List[List[Char]]()
- for(y <- 0 until character_matrix.length by 2) {
- var row:List[Char] = List[Char]()
- for(x <- 0 until character_matrix(0).length by 4) {
- val current = character_matrix(y)(x)
- row = row :+ current
- }
- value_matrix +:= row
- }
- var value_matrix_2 = List[List[List[Int]]]()
- for(y <- 0 until value_matrix.length) {
- val row:List[List[Int]] = List[List[Int]]()
- for(x <- 0 until value_matrix(y).length) {
- if(value_matrix(y)(x) == "_") {
- val l:List[Int] = List(1, 2, 3, 4)
- row(0) = l
- }
- }
- }
- value_matrix_2.foreach(println)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement