Skip to content

Instantly share code, notes, and snippets.

@thanhbv
thanhbv / d8bug.scala
Last active December 8, 2023 19:08
Advent of Code 2023 day 8 bug
// Guide to run:
// + Install scala-cli: https://scala-cli.virtuslab.org/install
// + Run: scala-cli test d8bug.scala
// Guide to dev: https://scala-cli.virtuslab.org/docs/cookbooks/ide/vscode
//> using scala 3.3.1
//> using dep org.scalameta::munit::1.0.0-M10
// With input like bellow, we can NOT use LCM to solve part2
val input = """LLR
@thanhbv
thanhbv / d7.scala
Last active December 8, 2023 04:49
Advent of Code 2023 day 7 scala
// Dev using scala-cli and vscode https://scala-cli.virtuslab.org/docs/cookbooks/ide/vscode
//> using scala 3.3.1
import Hand.*, Kind.*
import scala.math.Ordering
enum Kind:
case HighCard, OnePair, TwoPair, ThreeOfAKind, FullHouse, FourOfAKind, FiveOfAKind
object Hand:
@thanhbv
thanhbv / a
Created September 21, 2013 10:43
test
bc
@thanhbv
thanhbv / CbFutureAsScala.scala
Created September 21, 2013 10:40
implicit convert spymemcache (>= 2.10.0) OperationFuture to scala.concurrent.Future
package sd.cb
import net.spy.memcached.internal.{OperationCompletionListener, OperationFuture}
import scala.concurrent.{Future, Promise}
/**
* @see http://stackoverflow.com/questions/11529145/how-do-i-wrap-a-java-util-concurrent-future-in-an-akka-future?rq=1
* http://stackoverflow.com/questions/17215421/scala-concurrent-future-wrapper-for-java-util-concurrent-future
*/
object CbFutureAsScala{
@thanhbv
thanhbv / CbFutureAsScala.scala
Created September 21, 2013 10:39
implicit convert spymemcache (>= 2.10.0) OperationFuture to scala.concurrent.Future
package sd.cb
import net.spy.memcached.internal.{OperationCompletionListener, OperationFuture}
import scala.concurrent.{Future, Promise}
/**
* @see http://stackoverflow.com/questions/11529145/how-do-i-wrap-a-java-util-concurrent-future-in-an-akka-future?rq=1
* http://stackoverflow.com/questions/17215421/scala-concurrent-future-wrapper-for-java-util-concurrent-future
*/
object CbFutureAsScala{