Skip to content

Instantly share code, notes, and snippets.

@daclouds
Created August 15, 2014 07:32
Show Gist options
  • Save daclouds/8910b64cf3623da1af36 to your computer and use it in GitHub Desktop.
Save daclouds/8910b64cf3623da1af36 to your computer and use it in GitHub Desktop.
object sudoku extends App {
def check(input: Array[Int]): Boolean = {
Range(1, 10).toSet[Int] == input.map(_.toInt).toSet
}
def process(lineIn: Iterator[String])(lineOut: String => Unit) = {
var amountCases: Int = lineIn.next().toInt
var sizeOfSquare: Int = lineIn.next().toInt
for (i <- 1 to amountCases) {
var length = sizeOfSquare * sizeOfSquare
var board = Array.ofDim[Int](length, length);
for (j <- 0 to length - 1) {
var abc = lineIn.next().split(" ").map(_.toInt).toArray
println(abc.toSeq)
board +: abc
}
for (a <- board) {
println(a.toSeq)
}
}
}
val writer = new java.io.PrintWriter("d.large.out")
try {
process(io.Source.fromFile("input.txt").getLines)(writer.println)
} finally {
writer.flush(); writer.close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment