I hereby claim:
- I am stsatlantis on github.
- I am stsatlantis (https://keybase.io/stsatlantis) on keybase.
- I have a public key ASCCQrfKvYjs38lLVT053MrbUhAJCyTsDhr6ahsBiRt6aAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| { | |
| "user":"szeretemacsokit", | |
| "sessionId":"8416525d747a48efa744f0c3ce753d76", | |
| "game":{ | |
| "id":5426, | |
| "name": "League of Legends" | |
| }, | |
| "event":{ | |
| "name":"assist", | |
| "data":{ |
| package util | |
| import eu.timepit.refined.api.RefType | |
| import io.circe.Encoder | |
| import io.circe.refined.refinedEncoder | |
| import shapeless._ | |
| import shapeless.ops.hlist.Mapper | |
| import shapeless.tag.@@ | |
| trait Sensitive |
| import shapeless.HList | |
| trait ParentEncoder[-T] { | |
| type Repr <: HList | |
| def to(t: T): Repr | |
| } | |
| object ParentEncoder { |
| import io.circe.Encoder | |
| import io.circe.refined.refinedEncoder | |
| import shapeless._ | |
| import shapeless.ops.coproduct.{ Mapper => CoproductMapper } | |
| import shapeless.ops.hlist.{ Mapper => HListMapper } | |
| import shapeless.tag.@@ | |
| trait Sensitive | |
| object Sensitive { |
| object filterPoly extends Poly1 { | |
| implicit def filterNotEqualValues[A <: Symbol, B]: Case.Aux[(A, (B, B)), List[String]] = | |
| at[(A, (B, B))] { case (k, (v1, v2)) => if (v1 == v2) List.empty[String] else List(k.name) } | |
| } | |
| object foldListPoly extends Poly2 { | |
| implicit def foldToList[T](implicit st: filterPoly.Case.Aux[T, List[String]]): Case.Aux[T, List[String], List[String]] = | |
| at[T, List[String]] { (t, acc) => st(t) ::: acc } | |
| } | |
| def checkCorruptChecksum(_source: List[List[Int]]) = { | |
| _source.map( | |
| _.map(x => (x, x)) | |
| .reduceLeft((x, y) => (x._1 min y._1, x._2 max y._2) | |
| ) | |
| ).map { case (a, b) => b - a } | |
| .sum | |
| } | |
| def advancedCheckCorruptChecksum(_source: List[List[Int]]) = { |
| def simpleCaptcha(_source: String) = { | |
| (_source + _source.head).map(_.asDigit).sliding(2).collect { case Seq(a, b) if a == b => a }.sum | |
| } | |
| def advancedCaptcha(_source: String) = { | |
| val size = _source.length / 2 | |
| val (firstHalf, lastHalf) = _source.map(_.asDigit).splitAt(size) | |
| firstHalf.zip(lastHalf).collect { case (e1, e2) if e1 == e2 => e1 }.sum * 2 | |
| } |
| trait Devideable { | |
| def isDevidable(i: Int, d: Int, s: String) = if(i % d == 0) Some(s) else None | |
| } | |
| trait SzogletesDevidable extends Devideable { | |
| abstract override def isDevidable(i: Int, d: Int, s: String): Option[String] = super.isDevidable(i, d, s"[$s]") | |
| } | |
| trait KerekDevidable extends Devideable { | |
| abstract override def isDevidable(i: Int, d: Int, s: String): Option[String] = super.isDevidable(i, d, s"($s)") |
| def countSumOfTwoRepresentations2(n: Int, l: Int, r: Int): Int = { | |
| if(l > n/2) 0 else math.min(n/2 - l, r - n/2) + (if(n%2 == 1) 0 else 1) | |
| } |