ใครเป็นผู้ชนะ Game of Bar Dice


24

ท้าทาย

Bar Dice เป็นเกมง่ายๆที่เล่นใน Bar with Dice (ชื่อนี้) คุณหมุนลูกเต๋าหกเหลี่ยม 5 ลูกและพยายามทำให้มือดีที่สุด

การให้คะแนนขึ้นอยู่กับการรวบรวมจำนวนลูกเต๋าที่มากที่สุดด้วยตัวเลขเดียวกัน แต่ละมือต้องมี "เอซ" อย่างน้อยหนึ่งครั้งหรืออย่างใดอย่างหนึ่งเพื่อให้เป็นมือที่ถูกต้อง Aces ทำหน้าที่เป็น "wilds" และสามารถจับคู่กับหลักอื่น ๆ ได้ ความแข็งแรงของมือผู้เล่นขึ้นอยู่กับจำนวนของตัวเลขและค่าของตัวเลขเหล่านั้น ยกตัวอย่างเช่นมือ (นับจำนวนไวลด์) ที่มีสี่ 3 นั้นดีกว่ามือที่มีสาม 5 แต่ไม่ดีกว่ามือที่มีห้า 2
นำมาจากบทความ Wikipedia

ซึ่งหมายความว่ามืออันดับสูงสุดทำจากทั้งหมด 6 ของและ 1 และอันดับต่ำสุดคือมือใด ๆ ที่ไม่มี 1

ความท้าทายของคุณคือการจับสองมือและคืนผู้เล่นคนใดที่ชนะหรือหากพวกเขาผูกไว้

อินพุต

สองรายการที่ไม่เรียงลำดับของตัวเลข 5 หมายเลขตั้งแต่ 1 ถึง 6 แต่ละรายการแสดงถึงมือของผู้เล่น รูปแบบอินพุตมีความยืดหยุ่น

เอาท์พุต

มีสามค่าที่แตกต่างกัน แต่สอดคล้องกันคงที่ (ไม่อนุญาตให้ใช้ช่วง) เพื่อบ่งชี้ว่าผู้เล่น 1 หรือผู้เล่น 2 ชนะหรือเป็นเสมอ โปรดระบุคำตอบของคุณว่าคุณใช้ค่าอะไร ตัวอย่างเช่นคุณสามารถกลับมาได้-1ถ้า P1 ชนะ0ถ้ามันเสมอกันและ1ถ้า P2 ชนะ

กฎระเบียบ

  • อินพุตจะถูกต้องเสมอ
  • จะใช้คะแนนดีที่สุดเท่าที่เป็นไปได้ในแต่ละมือเพื่อตัดสินผู้ชนะ ไม่มี tie-breakers เช่น[1,4,4,3,3]จะผูก[1,4,4,2,2]แทนการใช้ 3's และ 2's เป็น tie-breaker
  • เอาต์พุตต้องเป็นหนึ่งใน 3 ค่าที่เลือกทุกครั้ง เพียงทำแผนที่จำนวนลบทั้งหมดถึงP1 Winsไม่ได้รับอนุญาตและจะต้องทำให้เป็นมาตรฐาน
  • มือที่ไม่ถูกต้องเช่นมือที่ไม่มีของ 1 แพ้ให้กับมือที่ถูกต้องทั้งหมด แต่ผูกมือที่ไม่ถูกต้องอื่น ๆ ทั้งหมด เช่นความสัมพันธ์[2,2,2,2,2][3,3,3,3,3]
  • ไพ่[1,1,1,1,1]นับเป็นเซตที่ถูกต้องของ 6 เพื่อการจัดอันดับ
  • นี่คือสั้นที่สุดนับจำนวนชัยชนะ

ตัวอย่าง

#You guys are pretty good at finding edge-cases that break things. Good job!
Input:  [2,1,5,6,6], [6,2,6,6,6]
Output: P1 Wins

Input:  [2,4,5,6,6], [6,2,6,6,6]
Output: Tie

Input:  [1,2,3,4,5], [5,4,3,2,1]
Output: Tie

Input:  [1,5,5,3,2], [5,4,1,6,6]
Output: P2 Wins

Input:  [3,2,2,2,1], [4,1,3,6,6]
Output: P1 Wins

Input:  [1,1,1,1,1], [6,1,1,6,6]
Output: Tie

Input:  [1,3,3,4,4], [1,2,2,5,5]
Output: P2 Wins

Input:  [1,3,3,5,5], [1,3,3,2,2]
Output: P1 Wins

Input:  [1,3,3,3,4], [1,1,3,3,3]
Output: P2 Wins

Input:  [2,2,2,6,1], [5,3,3,1,2]
Output: P1 Wins

Input:  [5,5,5,1,5], [1,1,1,1,1]
Output: P2 Wins

Input:  [1,1,1,1,1], [1,1,5,1,1]
Output: P1 Wins

คำตอบ:


10

เยลลี่ , 17 14 ไบต์

ċⱮ6Ḣ©+$®aĖUṀ)M

ลองออนไลน์!

ลิงก์ monadic ที่รับรายการของทั้งสองรายการเป็นอาร์กิวเมนต์และส่งคืน[1]สำหรับผู้เล่น 1 ชนะ[2]สำหรับผู้เล่น 2 ชนะและ[1, 2]เสมอกัน ลิงก์ TIO จะแสดงสิ่งนี้ขึ้นมาเพื่อแสดง

ขอบคุณ @JonathanAllan สำหรับการบันทึก 3 ไบต์!

คำอธิบาย

            )   | For each input list (e.g. of one list 1,1,3,3,4)
ċⱮ6             | - Count each of 1..6 (e.g. 2,0,2,1,0,0)
      $         | - Following as a monad:
   Ḣ            |   - Head (number of 1s)
    ©︎           |   - Copy to register
     +          |   - Add (e.g. 2,4,3,0,0)
       ®a       | - Register logical and with this
         Ė      | - Enumerate (e.g. [1,2],[2,4],[3,3],[4,0],[5,0])
          U     | - Reverse each (e.g. [2,1],[4,2],[3,3],[0,4],[0,5])
            Ṁ   | - Max (e.g. 4,2)
              M | Index/indices of maximal score

1
คุณสามารถแทนที่IṠด้วยMและเอาท์พุทรายการผู้ชนะ
Jonathan Allan

@JanathanAllan จุดดี! ขอบคุณ
Nick Kennedy

1
15 ไบต์โดยใช้การลงทะเบียน
Jonathan Allan

1
ฉันคิดว่าตอนนี้อาจซ้ำซ้อนเช่นกันเนื่องจากรายการเรียงลำดับเหมือนกับจำนวนเต็ม
Jonathan Allan

1
นี่เป็นวิธีที่น่ารัก ทำได้ดี.
Jonah

9

R , 115 96 ไบต์

-6 ไบต์ขอบคุณ Giuseppe

-6 ไบต์ขอบคุณ Aaron Hayman

-2 ไบต์ขอบคุณที่ Arnauld ตามรูปแบบการออกของเขาในคำตอบ JavaScript

function(i,j)(f(i)-f(j))/0
f=function(x,s=tabulate(x,6),l=s[1]+s[-1]*!!s[1])max(l)*6+order(l)[5]

ลองออนไลน์!

ส่งคืนInfสำหรับ P1 NaNสำหรับการผูก-Infสำหรับ P2

ใช้ฟังก์ชันตัวช่วยfซึ่งคำนวณคะแนนสำหรับแต่ละมือ คะแนนถูกกำหนดไว้ดังนี้: อนุญาตให้dเป็นตัวเลขที่ซ้ำกันมากที่สุดและnจำนวนครั้งที่มีการทำซ้ำ ดังนั้นคะแนนคือ6*n+dถ้ามีอย่างน้อยหนึ่งเอซและ0ถ้าไม่มีเอซ จากนั้นเราเพียงแค่ต้องค้นหาผู้เล่นที่มีคะแนนสูงสุด

Ungolfed:

f = function(x) {
  s = tabulate(x, 6)         # number of occurrences of each integer
  l = s[1] + s[-1] * !!s[1]  # add the number of wild aces to all values; set to 0 if s[1] == 0
  max(l) * 6 +               # highest number of repetitions (apart from aces)
    order(l)[5]              # most repeated integer (take largest in case of tie)
}
function(i, j){
  sign(f(i) - f(j))
}

คุณสามารถใช้order(l)[5]แทนmax.col(t(l),"l")รับโซลูชัน 96 ไบต์: ลองออนไลน์!
Aaron Hayman

@AaronHayman ดีมากขอบคุณ!
Robin Ryder

6

JavaScript (ES6),  97  90 ไบต์

(a)(b)จะเข้าเป็น ส่งคืน+Infinityสำหรับ P1 -Infinityสำหรับ P2 หรือNaNเสมอ

a=>b=>((g=(x,m)=>x>6?m*/1/.test(a):g(-~x,a.map(k=>n+=k<2|k==x,n=x/6)|m>n?m:n))()-g(a=b))/0

ลองออนไลน์!

แสดงความคิดเห็น

a => b => (                 // a[] = dice of P1; b[] = dice of P2
  ( g = (                   // g is a recursive function taking:
      x,                    //   x = dice value to test; initially, it is either undefined
                            //       or set to a non-numeric value
      m                     //   m = maximum score so far, initially undefined
    ) =>                    //
      x > 6 ?               // if x is greater than 6:
        m * /1/.test(a)     //   return m, or 0 if a[] does not contain any 1 
      :                     // else:
        g(                  //   do a recursive call:
          -~x,              //     increment x (or set it to 1 if it's non-numeric)
          a.map(k =>        //     for each dice value k in a[]:
            n +=            //       add 1 to n if:
              k < 2 |       //         k is equal to 1
              k == x,       //         or k is equal to x
            n = x / 6       //       start with n = x / 6
          ) |               //     end of map()
          m > n ?           //     if m is defined and greater than n:
            m               //       pass m unchanged
          :                 //     else:
            n               //       update m to n
        )                   //   end of recursive call
  )()                       // first call to g, using a[]
  - g(a = b)                // subtract the result of a 2nd call, using b[]
) / 0                       // divide by 0 to force one of the 3 consistent output values

6

05AB1E , 16 15 ไบต์

-1 ไบต์ขอบคุณ JonathanAllan

εWΘ*6L¢ć+°ƶà}ZQ

ลองออนไลน์!

ส่งคืน [1, 0] สำหรับการชนะ P1, [1, 1] สำหรับความสัมพันธ์, [0, 1] สำหรับการชนะ P2

แทนที่จะใช้คำสั่งทำพจนานุกรมใน 2-tuple (จำนวนลูกเต๋า, ค่าลูกเต๋า) ซึ่งคำนวณคะแนนเป็น 10 ** ลูกเต๋านับ * ค่าลูกเต๋า มือที่ไม่มี 1 คะแนน 5.

ε           }           # map each hand to its computed score
 WΘ                     # minimum == 1 (1 if the hand contains a 1, 0 otherwise)
   *                    # multiply (sets hands without 1 to [0, 0, 0, 0, 0])
    6L                  # range [1..6]
      ¢                 # count occurences of each in the hand
       ć                # head extract (stack is now [2-count, ..., 6-count], 1-count)
        +               # add the 1-count to all the other counts
         °              # 10**x
          ƶ             # multiply each element by its 1-based index
           à            # take the maximum

Z                       # maximum
 Q                      # equality test (vectorizes)

1
โอ้ .. ฉันชอบć+(ตอนนี้ที่ฉันเห็นมันฉันไม่อยากจะเชื่อเลยว่าฉันไม่ได้คิดถึงมัน .. )! นั่นเป็นมากดีกว่าสิ่งที่ผมพยายาม .. °ผมไม่ได้มีความคิดที่คล้ายกันด้วย :) ยกเว้นว่าฉันอยู่ที่ 20 ไบต์แล้วและยังคงต้องแก้ไขปัญหาสำหรับกรณีทดสอบ[[1,1,1,1,1],] [6,1,1,6,6]].. ขอบคุณที่ช่วยฉันประหยัดเวลาดังนั้นฉันจึงสามารถใส่ถังขยะ .. ; p
Kevin Cruijssen

1
@KevinCruijssen ใช่มันน่าทึ่งć+มาก ความคิดเริ่มต้นของฉันเริ่มต้นด้วยæʒW}ʒ1KËแต่สิ่งนี้ถูกฆ่าโดย[1,1,1,1,1]ปัญหา
Grimmy

1
ใช่วิธีการของฉันเป็นไปตามแนวของε1¢©Āy{γéθ¬sg®+°P}`.Sแต่คน[1,1,1,1,1]เมาที่เช่นกัน คำตอบทั้งหมดของคุณมีการทำงานร่วมกันที่ดีกับWΘ*, 6L¢, และć+ °ƶโดยเฉพาะอย่างยิ่งตัวอาคารWćƶแสดงความแข็งแกร่งของพวกเขาที่นี่
Kevin Cruijssen

Wไม่จำเป็นต้องใช้จริงเป็นเช่นเดียวไบต์นับเป็น6L¢¬Ā* WΘ*6L¢
Grimmy

อืมจุดดี :) ความคิดWโดยไม่ต้องเต้นและ*แสดงให้เห็นแล้วว่ามันมีความแข็งแกร่ง แต่¬ถ้าไม่มีการเต้นแล้ว*ก็เหมือนกัน ความจริงที่ว่ามันไม่ได้ป็อปก็คือความแข็งแกร่งที่ฉันบอกเป็นนัยถึงการประหยัดไบต์ ćƶแต่มันเป็นเรื่องจริงส่วนใหญ่
Kevin Cruijssen

6

Python 2 , 85 81 80 ไบต์

lambda p:cmp(*[max((h.count(i)+h.count(i>1),i)*(1in h)for i in[6]+h)for h in p])

ลองออนไลน์!

ส่งคืน1สำหรับ P1 0สำหรับเสมอและ-1สำหรับ P2

-1 ไบต์ต้องขอบคุณปลาหมึก


1
ช่องว่างระหว่าง1และinสามารถไปได้
Reinstate Monica

@squid ขอบคุณ :)
TFeld

4

Perl 6 , 60 49 ไบต์

&[cmp]o*.map:{.{1}&&max (.{2..6}X+.{1})Z ^5}o&bag

ลองออนไลน์!

ผลตอบแทนMore, Same, LessสำหรับP1 Wins,TieP2 Wins ,

คำอธิบาย

       *.map:  # Map input lists
                                             &bag  # Convert to Bag
             {                             }o  # Pass to block
              .{1}&&  # Return 0 if no 1s
                    max  # Maximum of
                         .{2..6}  # number of 2s,3s,4s,5s,6s
                                X+.{1}  # plus number of 1s
                        (             )Z     # zipped with
                                         ^5  # secondary key 0,1,2,3,4
&[cmp]o  # Compare mapped values

4

แบบสอบถาม T-SQL ขนาด 148 ไบต์

การใช้ตัวแปรตารางเป็นอินพุต

p: ผู้เล่น

v: ความคุ้มค่าสำหรับการม้วน

DECLARE @ table(p int,v int)
INSERT @ values(1,5),(1,5),(1,5),(1,5),(1,5)
INSERT @ values(2,4),(2,3),(2,3),(2,1),(2,4)

SELECT sign(min(u)+max(u))FROM(SELECT(p*2-3)*(s+sum(sign(s)-1/v))*(s/5*5+v+30)u
FROM(SELECT*,sum(1/v)over(partition by p)s FROM @)c GROUP BY v,s,p)x

ลองออนไลน์

Player 1 wins returns -1
Tie returns 0 
Player 2 wins returns 1


2

PowerShell , 112 126 123 121 ไบต์

(a)(b)จะเข้าเป็น ผลตอบแทน-1สำหรับการชนะ P1 1สำหรับ P2 หรือ0เสมอ

$args|%{$d=$($_-ne1|group|sort c*,n*|%{$m=$_};(7*(($o=($_-eq1).Count)+$m.Count)+$m.Name+6*!$m)[!$o])-$d}
[math]::Sign($d)

ลองออนไลน์!

กรณีทดสอบ @( @(1,1,5,1,1), @(1,1,1,1,1), 1)เพิ่ม

คลี่:

$args|%{
    $score=$(                                            # powershell creates a new scope inside expression $(...)
        $_-ne1|group|sort count,name|%{$max=$_}          # $max is an element with the widest group and the maximum digit except 1
        $ones=($_-eq1).Count                             # number of 1s in a player's hand
        $scoreRaw=7*($ones+$max.Count)+$max.Name+6*!$max # where $max.Name is digit of the widest group
        $scoreRaw[!$ones]                                # output $scoreRaw if the array contains 1, otherwise output $null 
    )                                                    # powershell deletes all variables created inside the scope on exit
    $diff=$score-$diff
}
[math]::Sign($diff)                                     # output the score difference

2

ภาษา Wolfram (Mathematica) , 78 75 74 ไบต์

-1 ไบต์โดย Greg Martin

Order@@(#~FreeQ~1||Last@Sort[Reverse/@Tally@Flatten[#/. 1->Range@6]]&)/@#&

ลองออนไลน์!

เอาท์พุต -1 เมื่อผู้เล่น 1 ชนะ 1 เมื่อผู้เล่น 2 ชนะและ 0 สำหรับการเสมอ

                                    Helper function to score a list:
FreeQ[#,1] ||                       If there are 0 1s, score is True
Last@Sort[                          Otherwise, take the largest element of
    Reverse/@Tally@                 the {frequency, number} pairs in the flat list
       Flatten[ #/. 1->Range@6]     where each 1 is replaced by {1,2,3,4,5,6}.
]&                              e.g. {1,3,3,5,5} -> {1,2,3,4,5,6,3,3,5,5} -> {3,5}

Order @@ (...) /@ #&                Apply this function to both lists,
                                    then find the ordering of the result.

คุณสามารถบันทึกหนึ่งไบต์โดยการแทนที่ด้วยFreeQ[#,1] #~FreeQ~1
Greg Martin

2

Java 8, 244 240 236 215 199 ไบต์

a->b->{int c[][]=new int[2][7],m[]=new int[2],p,i=5;for(;i-->0;c[1][b[i]]++)c[0][a[i]]++;for(i=14;i-->4;)m[p=i%2]=Math.max(m[p],c[p][1]>0?i/2+9*(c[p][i/2]+c[p][1]):0);return Long.compare(m[0],m[1]);}

-4 ไบต์ขอบคุณที่@someone
-21 ไบต์ขอบคุณที่@Neil
-16 ไบต์ขอบคุณ@ceilingcat @ceilingcat

ส่งคืน1ถ้า P1 ชนะ; -1ถ้า P2 ชนะ;0ถ้ามันเป็นเน็คไท

ลองออนไลน์

คำอธิบาย:

a->b->{                        // Method with 2 integer-array parameters & integer return
  int c[][]=new int[2][7],     //  Create a count-array for each value of both players,
                               //  initially filled with 0s
      m[]=new int[2],          //  The maximum per player, initially 0
      p,                       //  Temp-value for the player
  i=5;for(;i-->0;              //  Loop `i` in the range (5, 0]:
    c[1]                       //   For player 2:
        [b[i]                  //    Get the value of the `i`'th die,
             ]++)              //    and increase that score-count by 1
    c[0][a[i]]++;              //   Do the same for player 1
  for(i=14;i-->4;)             //  Then loop `i` in the range (14, 4]:
    m[p=i%2]=                  //   Set the score of a player to:
                               //   (even `i` = player 1; odd `i` = player 2)
      Math.max(                //    The max between:
        m[p],                  //     The current value,
                               //     And the value we calculate as follows:
        c[p][1]>0?             //     If this player rolled at least one 1:
          i/2                  //      Use the current value `i` integer-divided by 2
          +9*                  //      With 9 times the following added:
             (c[p][i/2]        //       The amount of dice for value `i//2`
              +c[p][1])        //       Add the amount of dice for value 1
        :                      //     Else (no 1s were rolled):
         0);                   //      Use 0
  return Long.compare(m[0],m[1]);}
                               //  Finally compare the maximum scores of the players,
                               //  resulting in -1 if a<b; 0 if a==b; 1 if a>b

ในวงมานานกว่า P, คุณสามารถแทนที่ด้วย...*(c[p][1]>0?1:0) c[p][1]>0?...:0ฉันสามารถโพสต์ลิงก์ TIO เนื่องจากมันยาวเกินไปและฉันไม่ต้องการย่อให้สั้นลง เวอร์ชันที่ไม่ได้ปรับแต่งมีวงเล็บที่ไม่สมดุลอยู่ตรงนั้น
สรรพนามของฉันคือ monicareinstate

@someone อาแน่นอนขอบคุณ ฉันเพิ่มการc[p][1]>0?ตรวจสอบในภายหลังว่าเป็นการแก้ไขข้อผิดพลาด แต่เห็นได้ชัดโดยไม่ต้องคิดมาก ขอบคุณสำหรับ -4 :)
Kevin Cruijssen

ทำไม*(i<2?6:i)? คุณเพียงแค่ทำซ้ำความพยายามและi=6 i=1นี่เป็นเพียง*i(และหยุดการวนซ้ำเมื่อคุณถึง 2)
Neil

นอกจากนี้9เลขอาถรรพ์ใดก็ได้ระหว่าง5และประมาณ32ใช่ไหม? ถ้าคุณใช้8แล้วแทนคุณสามารถใช้(int)Math.pow(8,(...)*i) i<<3*(...)
Neil

1
ฉันลงเอยด้วยการa->b->{int c[][]=new int[2][7],m[]=new int[2],s,p,i=5;for(;i-->0;c[1][b[i]]++)c[0][a[i]]++;for(i=7;i-->2;)for(p=2;p-->0;m[p]=s>m[p]?s:m[p])s=c[p][1]>0?i+9*(c[p][i]+(i>1?c[p][1]:0)):0;return Long.compare(m[0],m[1]);}ที่ดูเหมือนจะผ่านทุกกรณีการทดสอบของคุณ ...
Neil

1

เยลลี่ , 27 ไบต์

’o5Rṗ5¤ṢŒr$€UẎṀ1e⁸¤×µ€_/Ṡo/

ลองออนไลน์!

1 สำหรับ P1, -1 สำหรับ P2, 0 สำหรับเสมอกัน

คำอธิบาย

’o5Rṗ5¤ṢŒr$€UẎṀ1e⁸¤×µ€_/Ṡo/  Main link
                    µ€       For each list
’                            Decrement each value (so 1s become falsy)
 o                           Vectorized logical or (this replaces previous 1s (now 0s) with the test values)
  5Rṗ5¤                      1..5 cartesian-power 5 (1,1,1,1,1; 1,1,1,1,2; 1,1,1,1,3; ...)
          $€                 For each test list
       ṢŒr                   Sort and run-length encode (gives [digit, #digit])
            U                Reverse each list (gives [#digit, digit])
             Ẏ               Tighten by one (gives a list containing each possible hand for each possible wildcard)
              Ṁ              Take the maximum
               1e⁸¤×         Multiply the list values by (whether or not the original contained a 1) - becomes [0, 0] if not
                      _/Ṡ    Take the sign of the difference between the #digits and the digits
                         o/  If the number of digits differs, then 1/-1 is returned; otherwise, check the value of the digit (could still be 0)

1

Sledgehammer 0.4 , 27 bytes

⢱⢙⢂⠠⡾⢃⠐⢈⠸⣞⠴⠻⠎⡥⡳⡐⢒⠘⢛⣩⡓⣮⡕⡠⣢⣡⠿

บีบอัดลงในฟังก์ชันภาษา Wolfram นี้:

Order @@ (FreeQ[#1, 1] || Last[Sort[Reverse[Tally[Flatten[#1 /. 1 -> Range[6]]], 2]]] & ) /@ #1 & 

ซึ่งจะออกมาเป็นเหมือนกับฉันคำตอบ Mathematica


1

ถ่าน , 48 45 ไบต์

UMθ⮌E⁷№ι∨λ¹UMθ׬¬⊟ι⁺⊟ιιUMθ⟦⌈ι±⌕ι⌈ι⟧I⁻⌕θ⌈θ⌕θ⌊θ

ลองออนไลน์! การเชื่อมโยงคือการใช้รหัสเวอร์ชันอย่างละเอียด รับอินพุตเป็นอาร์เรย์ของอาร์เรย์และเอาต์พุต-1หากผู้เล่น 1 ชนะ0สำหรับเสมอและ1หากผู้เล่น 2 ชนะ คำอธิบาย:

UMθ⮌E⁷№ι∨λ¹

แทนที่แต่ละมือด้วยจำนวนครั้งที่ค่า6..1ปรากฏในมือ รายการถูกย้อนกลับเนื่องจากก) ทำให้ง่ายต่อการค้นหาค่าสูงสุดด้วยจำนวนสูงสุดและ b) ทำให้ง่ายต่อการลบจำนวนของ1s จำนวนของ1s เป็นสองเท่าเพราะจะต้องลบออกสองครั้งหนึ่งครั้งเพื่อตรวจสอบว่ามันไม่ใช่ศูนย์และอีกครั้งเพื่อเพิ่มลงในจำนวนอื่น ๆ

UMθ׬¬⊟ι⁺⊟ιι

เพิ่มจำนวนของ1s เข้ากับจำนวน6..2แต่ตั้งค่าจำนวนทั้งหมดเป็นศูนย์หากจำนวนของ1s เป็นศูนย์

UMθ⟦⌈ι±⌕ι⌈ι⟧

สำหรับแต่ละมือให้หาจำนวนสูงสุดและมูลค่าสูงสุดด้วยจำนวนนั้น (อันที่จริงเราพบค่าลบ6ตามที่นักกอล์ฟ)

I⁻⌕θ⌈θ⌕θ⌊θ

กำหนดมือที่ชนะโดยการลบตำแหน่งของมือที่ชนะและมือที่แพ้ (หากมือถูกผูกไว้มือแรกคือทั้งชนะและแพ้ดังนั้นผลลัพธ์จึง0เป็นที่ต้องการ)


1

C (gcc) / 32 บิต, 117 ไบต์

t;m;s(int*r){int c[6]={};for(m=0;t=*r++;m=t>m?t:m)c[--t]+=5,t=t?c[t]+t:5;t=*c?*c+m:0;}f(a,b){t=s(a)-s(b);t=(t>0)-!t;}

ลองออนไลน์!

ใช้อาร์เรย์จำนวนเต็มสองชุดที่สิ้นสุดด้วยศูนย์ ผลตอบแทน1, 0, -1สำหรับP1 Wins, ,P2 WinsTie


1
@Veskah ตกลงได้รับการแก้ไข
nwellnhof


1

Perl 5 -MList::Util=max -pl , 80 ไบต์

sub t{$t=pop;$_=max map$_ x$t=~s/$_//g,2..6;/./;$t&&$_.$t*($&||6)}$_=t($_)<=>t<>

ลองออนไลน์!

การป้อนข้อมูล:

ผู้เล่นแต่ละคนในบรรทัดแยกกันไม่มีช่องว่าง

เอาท์พุท:

1 สายหนึ่งชนะ

0 ผูก

-1 ชนะสองเส้น


1
เปลี่ยนตามการอธิบายกฎของเกมของคุณ
Xcali
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.