Skip to content

Instantly share code, notes, and snippets.

@krikit
Created September 18, 2015 13:14
Show Gist options
  • Save krikit/151c6bb6609db47965da to your computer and use it in GitHub Desktop.
Save krikit/151c6bb6609db47965da to your computer and use it in GitHub Desktop.
import java.io.{File, PrintWriter}
object PowerLevels extends App {
def log9000(bang: Int): Int = {
(for (k <- 0 to (9000 / bang)) yield {
Math.log10(9000 - bang * k)
}).sum.ceil.toInt
}
val numBang = List(0) ++ (1 to 8999).map(log9000(_))
def answer(d: Int): String = {
if (d < 4) "..."
else {
val bang = (numBang.zipWithIndex.filter { x: (Int, Int) =>
x._1 >= d
}).size + 1
"IT'S OVER 9000" + ("!" * bang)
}
}
// main
val lines = io.Source.fromFile("C-small-practice.in").getLines()
val out = new PrintWriter(new File("C-small-practice.out" ))
for (i <- 1 to lines.next.toInt) {
out.println(s"Case #${i}: ${answer(lines.next.toInt)}")
}
out.close
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment