This is a more complicated version of this puzzle. The premise is the same but a few rules differ in a few key places, making for a more complex problem.
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 specify whether I choose a shirt with highest (h) or lowest (l) remaining durability.
Take in an arbitrarily long sequence of four indicators (eg. bh bh bl wl bl wh wl bh...) 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 print out the remaining shirts’ durabilities.
Number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, and a sequence of shirt selections of arbitrary length at least long enough for one color of shirt to run out (can be considered infinitely long). The selection can be represented by a character pair (eg. bh, bl, wh, wl), or a single character (eg. b, B, w, W). Your choice, as long as there are four distinct inputs of 1 or 2 characters.
Status of each remaining shirt, sorted by durability. All shirts will be of one color.
The following test cases represent the amount of input the program should need to process before halting. The input is arbitrarily long otherwise.
1 1 1 1 bh 1 1 3 1 10 wh bh 10 10 9 1 5 2 10 wh wh bh wl wl wl bh 10 10 9 8 8 2 5 1 10 bh wh wh wl bl 10 10 9 9 9 1 5 6 5 wl wh bl wl wh bl wl wh bl wl wl bl wl wl wl bl wl wl wl wl bl 4 3 2 1 1 1 1 10 bl wh wh wh wh wh wh wh wh wh wh wh wh 10 #note the processing would stop occurring after the first bl and everything else should be ignored.
- This is code-golf, so shortest answer in bytes wins.
- Default I/O rules apply