Skip to content

Instantly share code, notes, and snippets.

@jargnar
Last active December 11, 2017 11:00
Show Gist options
  • Save jargnar/ed146912c9b6875171c945c8db4307a2 to your computer and use it in GitHub Desktop.
Save jargnar/ed146912c9b6875171c945c8db4307a2 to your computer and use it in GitHub Desktop.
ASCII Art from Codingame
/*
MIT License
Copyright 2017 Suhas SG <jargnar@gmail.com>
*/
import scala.util._
object Solution extends App {
val l = readInt
val h = readInt
val t = readLine
val rows = for (_ <- 0 until h) yield readLine
val alphabets = "abcdefghijklmnopqrstuvwxyz"
val positions = for (letter <- t) yield {
val pos = alphabets.indexOf(letter.toLower)
if (pos == -1) 26 else pos
}
for (row <- rows) {
for (pos <- positions) {
for (i <- 0 to l-1) {
print(row(pos*l + i))
}
}
println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment