Skip to content

Instantly share code, notes, and snippets.

View rmartinsdepaula's full-sized avatar

Renan Reis Martins de Paula rmartinsdepaula

  • PayPal/Zettle
  • Stockholm
View GitHub Profile
@rmartinsdepaula
rmartinsdepaula / GridTraveler.scala
Created February 26, 2023 20:11
Return the cache so it is not needed to use mutable map (horrible)
object GridTraveler extends App {
def gridTraveler(r: Int, c: Int, cache: collection.mutable.Map[(Int, Int), Long]): Long = {
cache.get((r, c)) match {
case Some(n) => return n
case None =>
}
cache.get((c, r)) match {
case Some(n) => return n