I hereby claim:
- I am takayahilton on github.
- I am timhilton (https://keybase.io/timhilton) on keybase.
- I have a public key ASBOYffC5sx09TTR77hul4ehuTOU_1ZSVsfoLpYz5rZfJgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import cats.implicits._ | |
import cats.data._ | |
List("a", "b", "b", "c", "b").traverse(s => State((map: Map[String, Int]) => map.get(s) match { | |
case Some(i) => (map.updated(s, i + 1), s + s"${i + 1}") | |
case None => (map.updated(s, 0), s) | |
})).run(Map.empty).value._2 //List("a", "b", "b1", "c", "b2") |
import scala.jdk.CollectionConverters; | |
import java.util.List; | |
public class Hoge { | |
public void hoge() { | |
scala.collection.immutable.List<Integer> sList = scala.collection.immutable.List.empty(); | |
List<Integer> list = CollectionConverters.seqAsJavaListConverter(sList).asJava(); | |
} | |
} |
trait Fuge { | |
type A = String | |
} |
def dfs(li:List[Int] ,k:Int,sum:Int = 0):Boolean = li match{ | |
case _ if sum == k => true | |
case Nil => false | |
case x::xs => dfs(xs,k,sum) || dfs(xs,k,sum+x) | |
} |
{- | |
同じ大きさの5枚の正方形の板を一列に並べ | |
赤色,緑色,青色のペンキを用いて,隣り合う正方形どうしが異なる色となるように, | |
この掲示板を塗り分ける。ただし,塗り分ける際には,3色のペンキをすべて使わなければならないわけではなく,2色のペンキだけで塗り | |
分けることがあってもよいものとする。 | |
すべての塗り方を列挙してください。 | |
また、その場合の組み合わせが何通りあるかもカウントしてください。 | |
-} |
case class Fraction(numer:Int,denom:Int){ | |
import scala.annotation._ | |
@tailrec | |
private def gcd(a:Int,b:Int):Int= b match{ | |
case 0 => a | |
case _ => gcd(b,a%b) | |
} | |
def toAnswer:Int = { |