Skip to content

Instantly share code, notes, and snippets.

@theodoreLee
Last active August 29, 2015 14:20
Show Gist options
  • Save theodoreLee/f51644eeebb9e26f64c0 to your computer and use it in GitHub Desktop.
Save theodoreLee/f51644eeebb9e26f64c0 to your computer and use it in GitHub Desktop.
import java.io.FileOutputStream
import scala.io.Source
object Omino {
val INPUT = "D-large-practice.in"
val OUTPUT = INPUT.takeWhile(_ != '.') + ".out"
def main(args: Array[String]): Unit = {
val itr = Source.fromFile(INPUT).getLines()
val sets = itr.next().toInt
val writer = new FileOutputStream(OUTPUT)
// val writer = Console.out
try {
Console.withOut(writer) {
for (set <- 1 to sets) {
val Array(x, r, c) = itr.next().split(' ').map(_.toInt)
val ret = if(solve(x, r min c, r max c)) "GABRIEL" else "RICHARD"
println(s"Case #${set}: ${ret}")
}
}
} finally {
writer.flush()
writer.close()
}
}
def solve(x: Int, s: Int, l: Int): Boolean = (x, s, l) match {
case _ if ((s * l) % x) != 0 => false
case (3, 1, _) => false
case (4, _, _) if s <= 2 => false
case (5, _, _) if (s <= 2) || (s, l) == (3, 5) => false
case (6, _, _) if s <= 3 => false
case _ if x >= 7 => false
case _ => true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment