Advertisement
Stormtalons

Untitled

Dec 16th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 2.77 KB | None | 0 0
  1. import java.util.Scanner
  2.  
  3. object Main extends App
  4. {
  5.     case class Foo(me: Int, nums: Array[Int], com: String)
  6.     {
  7.         val poss = new Array[Boolean](nums.length)
  8.         for (i <- 0 until poss.length)
  9.             poss(i) = true
  10.  
  11.         def disqualify(index: Array[Int]) = index.foreach(i =>
  12.         {
  13.             poss(i) = false
  14.             foos.foreach(f => if (f.nums(i) == nums(i) && f.me != me) f.disqualify_internal(i))
  15.         })
  16.  
  17.         def disqualify_internal(index: Int) = poss(index) = false
  18.         def disp =
  19.         {
  20.             print(s"Set ${if (me < 10) me + " " else me}:   ")
  21.             println(poss.zipWithIndex.map((f: (Boolean, Int)) => if (f._1) nums(f._2) else " ").mkString("  ") + "\t" + com)
  22.         }
  23.     }
  24.  
  25.     val foos = Array(
  26.         Foo(0,  "2321386104303845".toCharArray.map(_.toString.toInt), "0 correct"),
  27.         Foo(1,  "5616185650518293".toCharArray.map(_.toString.toInt), "2 correct"),
  28.         Foo(2,  "3847439647293047".toCharArray.map(_.toString.toInt), "1 correct"),
  29.         Foo(3,  "5855462940810587".toCharArray.map(_.toString.toInt), "3 correct"),
  30.         Foo(4,  "9742855507068353".toCharArray.map(_.toString.toInt), "3 correct"),
  31.         Foo(5,  "4296849643607543".toCharArray.map(_.toString.toInt), "3 correct"),
  32.         Foo(6,  "3174248439465858".toCharArray.map(_.toString.toInt), "1 correct"),
  33.         Foo(7,  "4513559094146117".toCharArray.map(_.toString.toInt), "2 correct"),
  34.         Foo(8,  "7890971548908067".toCharArray.map(_.toString.toInt), "3 correct"),
  35.         Foo(9,  "8157356344118483".toCharArray.map(_.toString.toInt), "1 correct"),
  36.         Foo(10, "2615250744386899".toCharArray.map(_.toString.toInt), "2 correct"),
  37.         Foo(11, "8690095851526254".toCharArray.map(_.toString.toInt), "3 correct"),
  38.         Foo(12, "6375711915077050".toCharArray.map(_.toString.toInt), "1 correct"),
  39.         Foo(13, "6913859173121360".toCharArray.map(_.toString.toInt), "1 correct"),
  40.         Foo(14, "6442889055042768".toCharArray.map(_.toString.toInt), "2 correct"),
  41.         Foo(15, "2326509471271448".toCharArray.map(_.toString.toInt), "2 correct"),
  42.         Foo(16, "5251583379644322".toCharArray.map(_.toString.toInt), "2 correct"),
  43.         Foo(17, "1748270476758276".toCharArray.map(_.toString.toInt), "3 correct"),
  44.         Foo(18, "4895722652190306".toCharArray.map(_.toString.toInt), "1 correct"),
  45.         Foo(19, "3041631117224635".toCharArray.map(_.toString.toInt), "3 correct"),
  46.         Foo(20, "1841236454324589".toCharArray.map(_.toString.toInt), "3 correct"),
  47.         Foo(21, "2659862637316867".toCharArray.map(_.toString.toInt), "2 correct")
  48.     )
  49.  
  50.     val in = new Scanner(System.in)
  51.     while (true)
  52.     {
  53.         println("          0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15")
  54.         foos.foreach(f => f.disp)
  55.         println("Eliminate something:")
  56.         val s = in.nextLine
  57.         val tar = s.split(" ")(0).toInt
  58.         val toRemove = s.split(" ")(1)
  59.         foos(tar).disqualify(if (toRemove.equals("all")) (0 to 15).toArray else toRemove.split(",").map(_.toInt))
  60.         println("\n\n")
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement