Advertisement
Guest User

Untitled

a guest
Feb 13th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.59 KB | None | 0 0
  1. val layer = Seq(1, 0, 0, 0, 1,
  2.             1, 0, 0, 0, 1,
  3.             1, 0, 0, 0, 1,
  4.             1, 0, 0, 0, 1,
  5.             1, 0, 0, 0, 1,
  6.             1, 0, 0, 0, 1,
  7.             1, 0, 0, 0, 1)
  8. val width = 5
  9. val layerArray: Seq[Seq[Int]] = layer.grouped(width).toSeq
  10. val height = layerArray.size
  11. layerArray(height - 1)(width - 1)
  12. (for {
  13.   j <- 0 until Math.ceil(height / 2).toInt
  14.   h <- 0 until height
  15.   i <- 0 until Math.ceil(width / 2).toInt
  16.   w <- 0 until width
  17. } yield layerArray(j)(w) == layerArray(height - 1 - j)(w) &&
  18. layerArray(h)(i) == layerArray(h)(width - 1 - i)).forall(identity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement