Skip to content

Instantly share code, notes, and snippets.

@benetis
Last active December 22, 2017 12:35
Show Gist options
  • Save benetis/c428b14a9b54e6782b16058d67801358 to your computer and use it in GitHub Desktop.
Save benetis/c428b14a9b54e6782b16058d67801358 to your computer and use it in GitHub Desktop.
Christmas golf
val b = """ [___]
/:' \
|:: |
\::. /
\::./
'=' """
val r = ".--._"
val s = " " ++ r ++ "\n _(_"
val f = r.reverse ++ "\n _)_"
val m = r ++ r.reverse ++ "\n _Y_"
def light(n: Int, c: Int): Seq[Seq[String]] = {
def r(u: String): Seq[String] = u.split("\n") ++ b.split("\n")
c match {
case c if c == n => Seq(r(s)) ++ light(n, c-1)
case c if c == 0 => Seq(r(f))
case _ => Seq(r(m)) ++ light(n, c-1)
}
}
val n = 4
val res = light(n, n)
res.foreach(println)
for(i <- 0 to 7) {
for(k <- 0 to n) {
print(res(k)(i))
}
print("\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment