This commit is contained in:
Xavier Morel
2018-08-31 15:22:46 +02:00
parent 58c8d007f3
commit 0760dc9acb
3 changed files with 1151 additions and 0 deletions

View File

@@ -9,3 +9,6 @@ Codingame Challenge using the excellent Codingame-Scala-Kit : https://github.com
* Symlinks `build.sbt`, `src/main/scala/com` and `project` should be referring the appropriate paths in `codingame-scala-kit-forked`
* Running `./enhanceCoK` should continuously build a file `target/CoK.scala` that you can sync with Codingame using a web-browser plugin.
# TODO
* Monkey Patch / extend / update `com.truelaurel.math.geometry.Pos` with local changes (see backup)

1128
backup_CoK.scala Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
package cok.math.geometry
import com.truelaurel.math.geometry.{Direction, N, S, W, E}
// TODO Add those changes to truelaurel code.
case class Pos(x: Int, y:Int) {
def neighborsIn(direction: Direction): Iterator[Pos] = direction match {
case N (y - 1).to(0).iterator.map(y2 Pos(x, y2))
case S (y + 1).to(500).iterator.map(y2 Pos(x, y2))
case W (x - 1).to(0).iterator.map(x2 Pos(x2, y))
case E (x + 1).to(500).iterator.map(x2 Pos(x2, y))
}
def distanceManhattan(pos: Pos): Int =
Math.abs(x - pos.x) + Math.abs(y - pos.y)
}
object Direction {
val cardinals = Seq(N, W, S, E)
}