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
class Ord[T](val lessThan: (T, T) => Boolean) | |
class Compare[T](x: T)(implicit ord: Ord[T]) { | |
def < (that: T) = ord.lessThan(x, that) | |
def > (that: T) = ord.lessThan(that, x) | |
} | |
implicit def anyToCompare[T: Ord](x: T) = new Compare(x) | |
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
val tiles = Map[Char, Int]( | |
'a' -> 1, | |
'b' -> 3, | |
'c' -> 3, | |
'd' -> 2 | |
// etc. | |
) | |
def main(args: Array[String]) { | |
var out = Vector[String]() |
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 ijeuler | |
/* Disclaimer: this code is a bit crappy since I wrote it ages ago | |
and it was written very quickly based on an even crappier poker hand | |
evaluator I wrote even longer ago in VBA | |
*/ | |
object P054 extends App { | |
object Rank extends Enumeration { |
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
def multiPartition[T, C[X] <: Traversable[X]](xs: C[T])(fs: T => Boolean *)(implicit cbf: CanBuildFrom[C[_],T,C[_]]) = { | |
val builders = Vector.fill(fs.length)(cbf()) | |
for (e <- xs) { | |
val i = fs.indexWhere(f => f(e)) | |
if (i >= 0) builders(i) += e | |
} | |
builders.map(_.result) | |
} |