This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Point = (Int, Int) | |
case class StateVars(pathLength: Int, seen: Set[Point], starts: Set[Point]) | |
// lab is 2-dimension array either of enterable cell (true) or obsticle (false) | |
def solve(start: Point, end: Point, lab: Vector[Vector[Boolean]]): Int = { | |
State[StateVars, Boolean] { case StateVars(pathLength, seen, expandFrom) => | |
val nextArea = expandFrom.flatMap { case (x, y) => | |
Set((x - 1, y), (x + 1, y), (x, y + 1), (x, y - 1)).filterNot(seen).filter { | |
case (nx, ny) => nx >= 0 && nx < lab.size && ny >=0 && ny < lab(0).size && lab(nx)(ny) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.{ApplicativeError, ~>} | |
import cats.tagless.FunctorK | |
object NotImplemented { | |
private def notImplemented[F[_]](implicit F: ApplicativeError[F, _ >: NotImplementedError]): F ~> F = | |
new (F ~> F){ | |
override def apply[A](fa: F[A]): F[A] = F.raiseError(new NotImplementedError()) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import magnolia._ | |
import scala.language.experimental.macros | |
case class TypeArguments[T](names: Vector[String]) { | |
override def toString: String = names.mkString("__") | |
} | |
object Bug { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
amixer -c 1 sset Mic toggle | grep '\[off\]' && notify-send "❌ MIC switched OFF ❌" || notify-send "🎤 MIC switched ON 🎤" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.scala | |
import io.prometheus.client.{Collector, Counter, Gauge, SimpleCollector} | |
import shapeless.{HNil, LabelledGeneric} | |
import shapeless._ | |
import shapeless.labelled.FieldType | |
import scala.annotation.implicitNotFound | |
package object prometheus { |