SHARE
TWEET

Untitled

a guest Oct 13th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Lambda;
  2.  
  3. class NiuNiu {
  4.     static public function check_NiuPoint(value:Array<UInt>):Array<UInt> {
  5.         var res = [];
  6.  
  7.         var bk = value.slice(0, value.length);
  8.         var seat = [];
  9.         var noseat = [];
  10.  
  11.         for (i in 0...3) {
  12.             for (j in i + 1...bk.length - 1) {
  13.                 if ((bk[i] + bk[j] + bk[j + 1]) % 10 == 0) {
  14.                     seat = [i, j, j + 1];
  15.                     break;
  16.                 }
  17.             }
  18.         }
  19.         if (seat.length == 3) {
  20.             for (i in 0...bk.length) {
  21.                 if (seat.indexOf(i) == -1) {
  22.                     noseat.push(i);
  23.                 }
  24.             }
  25.  
  26.             var num = (bk[noseat[0]] + bk[noseat[1]]) % 10;
  27.  
  28.             res.push(num);
  29.         } else {
  30.             res.push(-1); // 无牛
  31.         }
  32.         return res;
  33.     }
  34.  
  35.     static public function test() {
  36.         var arr = [2, 1, 7, 4, 5];
  37.         var x = check_NiuPoint(arr);
  38.         trace(x);
  39.         var arr = [2, 1, 7, 4, 6];
  40.         var x = check_NiuPoint(arr);
  41.         trace(x);
  42.     }
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top