Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tymurray on github.
  • I am tymurray (https://keybase.io/tymurray) on keybase.
  • I have a public key ASBkf6gTApAmTz8CzdXBfwBEAwqA54o3A8VU-ajDlzhbEAo

To claim this, I am signing this object:

@tymurray
tymurray / fizzBuzz.scala
Last active August 29, 2015 14:25
Generic approach to fizz buzz, guarantee order
def fb(i: Int, d: Map[Int, String]) = Option(d.toSeq.sortBy(_._1).filter(i % _._1 == 0).toMap.values.mkString)
.filter(_.nonEmpty).getOrElse(i)
(1 to 100).foreach(i => println(fb(i, Map(5 -> "buzz", 3 -> "fizz"))))