Skip to main content
added 109 characters in body
Source Link
digEmAll
  • 5k
  • 14
  • 22

R, 4135 bytes

function(v)rank(c(6,0,5,1:4*0,1:3)[v][scan()])[1]

Try it online!Try it online!

  • -6 Bytes thanks to @JayCe suggestion to switch to full program instead of function

The functionprogram returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(6,0,5,1:4*0,1:3)[v]          # extract the score of each card in v;v (got from scan());
                                     # cards in v are used as indexes in the cards rank 
                                     # vector, which is based on briscola scores vector 
                                     # c(11,0,10,0,0,0,0,2,3,4) but divided by 2 and rounded 
                                     # to integer preserving the original order

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value

R, 41 bytes

function(v)rank(c(6,0,5,1:4*0,1:3)[v])[1]

Try it online!

The function returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(6,0,5,1:4*0,1:3)[v]          # extract the score of each card in v;
                                     # cards in v are used as indexes in the cards rank 
                                     # vector, which is based on briscola scores vector 
                                     # c(11,0,10,0,0,0,0,2,3,4) but divided by 2 and rounded 
                                     # to integer preserving the original order

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value

R, 35 bytes

rank(c(6,0,5,1:4*0,1:3)[scan()])[1]

Try it online!

  • -6 Bytes thanks to @JayCe suggestion to switch to full program instead of function

The program returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(6,0,5,1:4*0,1:3)[v]          # extract the score of each card in v (got from scan());
                                     # cards in v are used as indexes in the cards rank 
                                     # vector, which is based on briscola scores vector 
                                     # c(11,0,10,0,0,0,0,2,3,4) but divided by 2 and rounded 
                                     # to integer preserving the original order

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value
added 120 characters in body
Source Link
digEmAll
  • 5k
  • 14
  • 22

R, 41 bytes

function(v)rank(c(6,0,5,1:4*0,1:3)[v])[1]

Try it online!

The function returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(6,0,5,1:4*0,1:3)[v]          # extract the score of each card in v;
                                     # cards in v are used as indexes in the briscolacards rank 
                                     # vector, which is based on briscola scores vector 
                                     # c(11,0,10,0,0,0,0,2,3,4) but divided by 2 and rounded 
                                     # (dividedto byinteger 2preserving andthe roundedoriginal up)order

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value

R, 41 bytes

function(v)rank(c(6,0,5,1:4*0,1:3)[v])[1]

Try it online!

The function returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(6,0,5,1:4*0,1:3)[v]          # extract the score of each card in v;
                                     # cards in v are used as indexes in the briscola  
                                     # scores vector c(11,0,10,0,0,0,0,2,3,4) 
                                     # (divided by 2 and rounded up)

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value

R, 41 bytes

function(v)rank(c(6,0,5,1:4*0,1:3)[v])[1]

Try it online!

The function returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(6,0,5,1:4*0,1:3)[v]          # extract the score of each card in v;
                                     # cards in v are used as indexes in the cards rank 
                                     # vector, which is based on briscola scores vector 
                                     # c(11,0,10,0,0,0,0,2,3,4) but divided by 2 and rounded 
                                     # to integer preserving the original order

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value
deleted 2 characters in body
Source Link
digEmAll
  • 5k
  • 14
  • 22

R, 4341 bytes

function(v)rank(c(116,0,105,1:4*0,21:43)[v])[1]

Try it online!Try it online!

The function returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(116,0,105,1:4*0,21:43)[v]          # extract the score of each card in v;
                                     # cards in v are used as indexes in the briscola  
                                     # scores vector c(11,0,10,0,0,0,0,2,3,4)
  
rank                                     # (divided by 2 and rounded up)

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value

R, 43 bytes

function(v)rank(c(11,0,10,1:4*0,2:4)[v])[1]

Try it online!

The function returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(11,0,10,1:4*0,2:4)[v]        # extract the score of each card in v;
                                     # cards in v are used as indexes in the  
                                     # scores vector c(11,0,10,0,0,0,0,2,3,4)
 
rank(                        )[1]    # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value

R, 41 bytes

function(v)rank(c(6,0,5,1:4*0,1:3)[v])[1]

Try it online!

The function returns 2 for 'greater than', 1 for 'less than', 1.5 for 'equal'

Explanation :

      c(6,0,5,1:4*0,1:3)[v]          # extract the score of each card in v;
                                     # cards in v are used as indexes in the briscola  
                                     # scores vector c(11,0,10,0,0,0,0,2,3,4) 
                                     # (divided by 2 and rounded up)

rank(                      )[1]      # rank returns : c(1,  2)   if v[1] < v[2]
                                     #                c(2,  1)   if v[1] > v[2]
                                     #                c(1.5,1.5) if v[1] == v[2]
                                     # and we select the first value
deleted 484 characters in body
Source Link
digEmAll
  • 5k
  • 14
  • 22
Loading
deleted 484 characters in body
Source Link
digEmAll
  • 5k
  • 14
  • 22
Loading
edited body
Source Link
digEmAll
  • 5k
  • 14
  • 22
Loading
Source Link
digEmAll
  • 5k
  • 14
  • 22
Loading