Skip to main content
added 1730 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 44 bytes

lambda a,b:[b-61<~a<a>b/22*b-3for b in-~b,b]

Try it online!

An improved validity check by TFeld saves 3 bytes. The main idea is to branch on "overtime" b>21 with b/22*b which effectively sets below-21 scores to zero, whereas I'd branched on a>19 with the longer max(19,a).


Python 2, 43 bytes

lambda a,b:a>>99|cmp(2+max(19,a)%30-a/29,b)

Try it online!

Outputs:

ended: 0
going: -1
invalid: 1

Assumes that the inputs are not below \$-2^{99}\$.

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 43 bytes

lambda a,b:a>>99|cmp(2+max(19,a)%30-a/29,b)

Try it online!

Outputs:

ended: 0
going: -1
invalid: 1

Assumes that the inputs are not below \$-2^{99}\$.

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 44 bytes

lambda a,b:[b-61<~a<a>b/22*b-3for b in-~b,b]

Try it online!

An improved validity check by TFeld saves 3 bytes. The main idea is to branch on "overtime" b>21 with b/22*b which effectively sets below-21 scores to zero, whereas I'd branched on a>19 with the longer max(19,a).


Python 2, 43 bytes

lambda a,b:a>>99|cmp(2+max(19,a)%30-a/29,b)

Try it online!

Outputs:

ended: 0
going: -1
invalid: 1

Assumes that the inputs are not below \$-2^{99}\$.

deleted 406 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 4443 bytes

lambda a,b:a<0 or cmpa>>99|cmp(b,2+max(19,a)%30-a/29,b)

Try it online!Try it online!

Outputs:

ended: 0
going: -1
invalid: 1 (including True)

Assumes that the inputs are not below \$-2^{99}\$.

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 44 bytes

lambda a,b:a<0 or cmp(b,2+max(19,a)%30-a/29)

Try it online!

Outputs:

ended: 0
going: -1
invalid: 1 (including True)

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 43 bytes

lambda a,b:a>>99|cmp(2+max(19,a)%30-a/29,b)

Try it online!

Outputs:

ended: 0
going: -1
invalid: 1

Assumes that the inputs are not below \$-2^{99}\$.

deleted 406 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 44 bytes

lambda a,b:0!=a/30ora<0 or cmp(b,2+max(19,a)%30-a/29)

[Try it online!][TIO-jtqhdtff]

[TIO-jtqhdtff]: https://tio.run/##jZbNbuNGEITvfgrmZBmRsKyeH84s4EOA3UOAIMdcHB/o2FIE2LLhGEH26R2qq8aUmATIpY2mNfU1yanivHx7@/35YO/b61/fH8enu/uxG9d3n/vvrsdPoX9@7X57elndre37p/GvFep6vNqMn6xevV@8vO4Pb93ln@Pj/r57ONw/3H@@1MXtquvXneHqo4ed94apDyd9WXehP@kr@3PK/tC9PI7fFpzuZJ1z@3MubMFdzmEzZ39w0glhc/wJ6rxkMz2FM41uc/zF4l5tcS8n/w/9@b3G6ffx5Fmgd2R/ZPDixS8//PTjl@ubm37d366nCq/mNXiNXpPX7HXwWrxWrtJirgaXg@tBAVABlAA1QBFQxahiRxWsWc1r8Bq9Jq/Z6@C1eK1c1fOPNLgcXA8KgAqgBKgBioAqRhWfxHwG8xnMZzCfwXwG8xnMZzCfwTiDcQbjDMYZjDMYZzDOYJzBOINxBuMMxhmC04PTg9OD04PTg9OD0wPpgfRAeiA9kB5ID6QH0gPpgfRAeiA9Ojc6Nzo3Ojc6Nzo3khvJjeRGciO5kdxIbiQ3khvJjeRGcpMTkxOTE5MTkxMTiYnERGIiMZGYSEwkJhITiYnERGIiMTsrOys7Kzsrk5XJymRlsjJZmaxMViYrk5XJymRlsganDE4ZnDKQMpAykDKQMpAykDKQMpAykDKQMpAykFJcv7h@oX6hfqF@oX6hfqF@oX6hfqF@oX6hfqF@deVK5UrlSuVK5UrlSuVK5UrlSuVK5UrlqgRQrEC5AgULlCxQtEDZAoULlC5QvED5AgUMWsK0lGgx0XKiBUVLihYVLStaWLS0aHGhvIAsD3keMj3kesj2kO8h40POh6wPeR9yL2RfyL@QgSEHQxaGPAyZGHIxZEPIh5ARISdCVoS8CJkRciPkJshOkJ8gQ0GOgiwFeQqyBOQJyBSQKyBbQL6AdjW0raF9DW1saGdD2xLal9DGhHYmtKugbQXtK9M@sH7uPaJb3mPuPbNNvc29h3hQH@beUz2qj3PvMZ/Up7n33M/q89z7h2BQP8y9fxmK@vLRB7@fqr4e@9uLi68/f/nKT7u@qO1zhtNoV9Iq/pRMig45vNmx2aZt87Y92/Zq26S99vY62@tqr@Ufj335WJePbflYFrfN291dn5wyt6upLg55H0evPx7eVjv/wXY6hk5/j8c/Pwi1o9Ll@anzXxf44/1YsHveH3b/g9Dtt93NdOG2Ozy/ncj81zFxoXRc8Toedg@rTZoOZf1Vd7x8N18e/eISwpt7/xs "Python 2 – Try It Online"R8iJkRsiNkJsgO0F@ggwFOQqyFOQpyBKQJyBTQK6AbAH5AtrV0LaG9jW0saGdDW1LaF9CGxPamdCugrYVtK9M@8D6qfeIbnmPqffMNvU29R7iQX2Yek/1qD5Ovcd8Up@m3nM/q89T7x@Cor5MvX8ZBvXDex/8ear6euxvLi4@//LpMz/t@qK2zxlOo11Jq/hTMik65PBmx2abts3b9mzbq22T9rO3n7P9XO1n@cdrn7/W@Wubv5bZY/Nxt1cnx8zN4lBnh7z3o9fv96@Lrd@weXo53n48/vlBqB2VLs9Pnf@6wF/v@4Lt026//R@Ebrfprg8Xbrr90@uJzH8dE2dKxxUv4357v1inw6GsX3bHy7fT5dEvziF8uLe/AQ "Python 2 – Try It Online"Try it online!

Outputs:

ended: 0
going: -1
invalid: 1 (including True)

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 44 bytes

lambda a,b:0!=a/30or cmp(b,2+max(19,a)-a/29)

[Try it online!][TIO-jtqhdtff]

[TIO-jtqhdtff]: https://tio.run/##jZbNbuNGEITvfgrmZBmRsKyeH84s4EOA3UOAIMdcHB/o2FIE2LLhGEH26R2qq8aUmATIpY2mNfU1yanivHx7@/35YO/b61/fH8enu/uxG9d3n/vvrsdPoX9@7X57elndre37p/GvFep6vNqMn6xevV@8vO4Pb93ln@Pj/r57ONw/3H@@1MXtquvXneHqo4ed94apDyd9WXehP@kr@3PK/tC9PI7fFpzuZJ1z@3MubMFdzmEzZ39w0glhc/wJ6rxkMz2FM41uc/zF4l5tcS8n/w/9@b3G6ffx5Fmgd2R/ZPDixS8//PTjl@ubm37d366nCq/mNXiNXpPX7HXwWrxWrtJirgaXg@tBAVABlAA1QBFQxahiRxWsWc1r8Bq9Jq/Z6@C1eK1c1fOPNLgcXA8KgAqgBKgBioAqRhWfxHwG8xnMZzCfwXwG8xnMZzCfwTiDcQbjDMYZjDMYZzDOYJzBOINxBuMMxhmC04PTg9OD04PTg9OD0wPpgfRAeiA9kB5ID6QH0gPpgfRAeiA9Ojc6Nzo3Ojc6Nzo3khvJjeRGciO5kdxIbiQ3khvJjeRGcpMTkxOTE5MTkxMTiYnERGIiMZGYSEwkJhITiYnERGIiMTsrOys7Kzsrk5XJymRlsjJZmaxMViYrk5XJymRlsganDE4ZnDKQMpAykDKQMpAykDKQMpAykDKQMpAykFJcv7h@oX6hfqF@oX6hfqF@oX6hfqF@oX6hfqF@deVK5UrlSuVK5UrlSuVK5UrlSuVK5UrlqgRQrEC5AgULlCxQtEDZAoULlC5QvED5AgUMWsK0lGgx0XKiBUVLihYVLStaWLS0aHGhvIAsD3keMj3kesj2kO8h40POh6wPeR9yL2RfyL@QgSEHQxaGPAyZGHIxZEPIh5ARISdCVoS8CJkRciPkJshOkJ8gQ0GOgiwFeQqyBOQJyBSQKyBbQL6AdjW0raF9DW1saGdD2xLal9DGhHYmtKugbQXtK9M@sH7uPaJb3mPuPbNNvc29h3hQH@beUz2qj3PvMZ/Up7n33M/q89z7h2BQP8y9fxmK@vLRB7@fqr4e@9uLi68/f/nKT7u@qO1zhtNoV9Iq/pRMig45vNmx2aZt87Y92/Zq26S99vY62@tqr@Ufj335WJePbflYFrfN291dn5wyt6upLg55H0evPx7eVjv/wXY6hk5/j8c/Pwi1o9Ll@anzXxf44/1YsHveH3b/g9Dtt93NdOG2Ozy/ncj81zFxoXRc8Toedg@rTZoOZf1Vd7x8N18e/eISwpt7/xs "Python 2 – Try It Online"R8iJkRsiNkJsgO0F@ggwFOQqyFOQpyBKQJyBTQK6AbAH5AtrV0LaG9jW0saGdDW1LaF9CGxPamdCugrYVtK9M@8D6qfeIbnmPqffMNvU29R7iQX2Yek/1qD5Ovcd8Up@m3nM/q89T7x@Cor5MvX8ZBvXDex/8ear6euxvLi4@//LpMz/t@qK2zxlOo11Jq/hTMik65PBmx2abts3b9mzbq22T9rO3n7P9XO1n@cdrn7/W@Wubv5bZY/Nxt1cnx8zN4lBnh7z3o9fv96@Lrd@weXo53n48/vlBqB2VLs9Pnf@6wF/v@4Lt026//R@Ebrfprg8Xbrr90@uJzH8dE2dKxxUv4357v1inw6GsX3bHy7fT5dEvziF8uLe/AQ "Python 2 – Try It Online"

Outputs:

ended: 0
going: -1
invalid: 1 (including True)

Python 2, 47 bytes

lambda a,b:[61>60-a>b<3+max(19,a)for b in-~b,b]

Try it online!

Outputs a list of two Booleans. Thanks to TFeld for writing a test suite in their answer that made it easy to check my solution.

ended: [False, True]
going: [True, True]
invalid: [False, False]

The key insight is that a valid score ends the game exactly if increasing the higher value b makes the score invalid. So, we just code up the validity condition, and check it for (a,b+1) in addition to (a,b) to see if the game has ended.

Validity is checked via three conditions that are chained together:

  • b<3+max(19,a): Checks that the higher score b isn't past winning, with either b<=21 or b<=a+2 (win by two)
  • 60-a>b: Equivalent to a+b<=59, ensuring the score isn't above (29,30)
  • 61>60-a: Equivalent to a>=0, ensures the lower score is non-negative

Python 2, 44 bytes

lambda a,b:a<0 or cmp(b,2+max(19,a)%30-a/29)

Try it online!

Outputs:

ended: 0
going: -1
invalid: 1 (including True)
added 418 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652
Loading
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652
Loading