13
\$\begingroup\$

In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds for two different teams, determine which team won the game.

Take four integers g1, b1, g2, b2 as input, and output two distinct values for whether the first team or the second team inputted won. Input format is flexible, but input order must allow it to be obvious which team is first. For example, g1, g2, b1, b2 would be allowed, but b1, g2, g1, b2 would not.

Test Cases

Test cases will use true for the first team winning and false for the second team winning. Input is in the format (g1,b1),(g2,b2).

(1,0),(0,1)        true
(2,0),(0,11)       true
(10,8),(11,1)      true
(0,0),(1,0)        false
(100,100),(117,0)  false
(7,7),(5,12)       true
(2,0),(0,13)       false

As an example, for input (10,8),(11,1), team 1 scored 10 goals and 8 behinds, for a total of \$10*6+8*1=68\$ points, while team 2 scored \$11*6+1*1=67\$ points, so team 1 wins.

No input will be a draw - your program's behavior on draw input does not matter.

\$\endgroup\$
7
  • \$\begingroup\$ Could we extend for Gaelic football and hurling? \$\endgroup\$ – TRiG Sep 27 '19 at 10:23
  • \$\begingroup\$ @TRiG make your own question! \$\endgroup\$ – Stephen Sep 27 '19 at 11:07
  • \$\begingroup\$ I'll try to think of something that isn't too close. \$\endgroup\$ – TRiG Sep 27 '19 at 11:23
  • 2
    \$\begingroup\$ @TRiG, GAA would be identical, just using base-3 instead of base-6. \$\endgroup\$ – Shaggy Sep 27 '19 at 11:35
  • \$\begingroup\$ Yeah @Shaggy, which is why I couldn't just copy this question to make an equivalent GAA one. Something similar. Maybe including International Rules Football. \$\endgroup\$ – TRiG Sep 27 '19 at 12:15

35 Answers 35

1
2
1
\$\begingroup\$

MathGolf, 7 6 bytes

I am quite impressed that MathGolf has 8 block-starting builtins!

2É6*+>

TIO

Explanation

2      Constant 2
 É     Start code block of length 3
  6*   Take one input * 6 (with implicit input)
    +  Take another input and add them
     > Take Greater than of the two constants in the stack
There is an implicit output.
\$\endgroup\$
1
\$\begingroup\$

Whitespace, 101 bytes

(Lots of whitespace)

Try it online!

readable version:

lstl        call readint
sssttsl     push 6
tssl        mult
lstl        call readint
tsss        add
lstl        call readint
sssttsl     push 6
tssl        mult
lstl        call readint
tsss        add
tsst        sub
sssl        push 0
slt         swap
lttsl       jn otherteam
ssstl       push 1
lsssl       otherteam:
tlst        printi
lll         end

lssl        readint:
sssl        push 0
sls         dup
tltt        readi
ttt         retrieve
ltl         ret
\$\endgroup\$
1
\$\begingroup\$

R, 28 bytes

function(a,b,c,d)a*6+b>c*6+d

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Pyth, 12 bytes

qhQeo+*6hNeN

Try it online!

Pretty simple but Im happy with it. Takes (g1,b1),(g2,b2), returns True or False

How it works

qhQeo+*6hNeN
qhQ          - The first input is equal to..
   eo        - The last input of a sorted list (implicitly the input)
     +*6hNeN - With the key 6 * first (hN) + last (eN)
\$\endgroup\$
1
\$\begingroup\$

GolfScript, 11 bytes

Puts the code block into a function.

{6*+@@6*+>}

Try it online!

\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.