Skip to main content
added 87 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirtsa shirt with the highest durability of that color to ensure even loss of durabilitywear and tear among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately. Note that the program must not consume any more input than is required before halting.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output

None. The program must simply halt when the last shirt of either color is thrown away.

Test cases

1 1 1 1 b

1 999 1 999 b

1 999 1 999 w w w w w w w w b

2 999 1 999 b w w w b

2 999 2 999 b w w w b w b w w w b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default input rules apply for the first four arguments. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character or byte at a time, of theoretically infinite length, such as STDIN or some other stream.

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirts with the highest durability of that color to ensure even loss of durability among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output

None. The program must simply halt when the last shirt of either color is thrown away.

Test cases

1 1 1 1 b

1 999 1 999 b

1 999 1 999 w w w w w w w w b

2 999 1 999 b w w w b

2 999 2 999 b w w w b w b w w w b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default input rules apply for the first four arguments. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character or byte at a time, of theoretically infinite length, such as STDIN or some other stream.

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose a shirt with the highest durability of that color to ensure even wear and tear among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately. Note that the program must not consume any more input than is required before halting.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output

None. The program must simply halt when the last shirt of either color is thrown away.

Test cases

1 1 1 1 b

1 999 1 999 b

1 999 1 999 w w w w w w w w b

2 999 1 999 b w w w b

2 999 2 999 b w w w b w b w w w b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default input rules apply for the first four arguments. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character or byte at a time, of theoretically infinite length, such as STDIN or some other stream.
deleted 34 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirts with the highest durability of that color to ensure even loss of durability among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output

None. The program must simply halt when the last shirt of either color is thrown away.

Test cases

1 1 1 1 b

1 999 1 999 b

1 999 1 999 w w w w w w w w b

2 999 1 999 b w w w b

2 999 2 999 b w w w b w b w w w b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default Loopholes are forbidden.
  • Default input rules apply for the first four arguments. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character or byte at a time, of theoretically infinite length, such as STDIN or some other stream.

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirts with the highest durability of that color to ensure even loss of durability among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output

None. The program must simply halt when the last shirt of either color is thrown away.

Test cases

1 1 1 1 b

1 999 1 999 b

1 999 1 999 w w w w w w w w b

2 999 1 999 b w w w b

2 999 2 999 b w w w b w b w w w b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default Loopholes are forbidden.
  • Default input rules apply for the first four arguments. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character at a time, of theoretically infinite length, such as STDIN or some other stream.

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirts with the highest durability of that color to ensure even loss of durability among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output

None. The program must simply halt when the last shirt of either color is thrown away.

Test cases

1 1 1 1 b

1 999 1 999 b

1 999 1 999 w w w w w w w w b

2 999 1 999 b w w w b

2 999 2 999 b w w w b w b w w w b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default input rules apply for the first four arguments. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character or byte at a time, of theoretically infinite length, such as STDIN or some other stream.
deleted 43 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both shirtscolors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirts with the highest durability of that color to ensure even loss of durability among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately, printing out which shirt I ran out of first.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output:

None. The character representing whichprogram must simply halt when the last shirt ran out firstof either color is thrown away.

Test cases

1 1 1 1 b
b

1 999 1 999 b
b

1 999 1 999 w w w w w w w w b
b

2 999 1 999 b w w w b
b

2 999 2 999 b w w w b w b w w w b
b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w
w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default Loopholes are forbidden.
  • Default I/Oinput rules apply for the first four arguments and for the resulting output. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character at a time, of theoretically infinite length, such as STDIN or some other stream.

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts. Both shirts have a non-zero durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirts with the highest durability of that color to ensure even loss of durability among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately, printing out which shirt I ran out of first.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output:

The character representing which shirt ran out first.

Test cases

1 1 1 1 b
b

1 999 1 999 b
b

1 999 1 999 w w w w w w w w b
b

2 999 1 999 b w w w b
b

2 999 2 999 b w w w b w b w w w b
b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w
w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default Loopholes are forbidden.
  • Default I/O rules apply for the first four arguments and for the resulting output. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character at a time, of theoretically infinite length, such as STDIN or some other stream.

This puzzle is based on this Math.SE post.

Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.

Every day, I pick out a clean shirt to wear, and it becomes dirty. Once I run out of all clean black shirts or all clean white shirts, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.

When picking which shirt to wear of a particular color, I always choose one of the shirts with the highest durability of that color to ensure even loss of durability among shirts.

Challenge:

Take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing my choice of shirt to wear on that day. Continue execution until either my last black shirt or my last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately.

Inputs:

Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and an arbitrary number of two single characters, your choice (eg. b and w)

Output

None. The program must simply halt when the last shirt of either color is thrown away.

Test cases

1 1 1 1 b

1 999 1 999 b

1 999 1 999 w w w w w w w w b

2 999 1 999 b w w w b

2 999 2 999 b w w w b w b w w w b

5 3 6 1 w w w w w b b b b b b b b b b b b b b w

General rules:

  • This is , so shortest answer in bytes wins.
  • Default Loopholes are forbidden.
  • Default input rules apply for the first four arguments. For the arbitrarily long input sequence after the first four arguments, input must come from a source which can provide input one character at a time, of theoretically infinite length, such as STDIN or some other stream.
added 136 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3
Loading
added 61 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3
Loading
added 61 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3
Loading
added 78 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3
Loading
added 83 characters in body
Source Link
Ed Marty
  • 299
  • 1
  • 3
Loading
Source Link
Ed Marty
  • 299
  • 1
  • 3
Loading