Playing Pickomino












6












$begingroup$


In the game Pickomino, there are several tiles lying in the middle of the table, each with a different positive integer on them. Each turn, the players roll dices in a certain way and get a score, which is a nonnegative integer.



Now the player takes the tile with the highest number that is still lower or equal to their score, removing the tile from the middle and adding it to their stack. If this is not possible because all numbers in the middle are higher than the player's score, the player loses the topmost tile from their stack (which was added latest), which is returned to the middle. If the player has no tiles left, nothing happens.



The challenge



Simulate a player playing the game against themselves. You get a list of the tiles in the middle and a list of the scores that the player got. Return a list of the tiles of the player after all turns have been evaluated.



Challenge rules




  • You can assume that the list with the tiles is ordered and doesn't contain any integer twice.

  • You can take both lists of input in any order you want

  • The output has to keep the order of the tiles on the stack, but you can decide whether the list is sorted from top to bottom or from bottom to top.


General rules




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Adding an explanation for you answer is recommended.


Example



(taken from the 6th testcase)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]


First score is 22, so take the highest tile in the middle <= 22, which is 22 itself.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [22, 22, 23, 21, 24, 0, 22]


Next score is 22, so take the highest tile in the middle <= 22. Because 22 is already taken, the player has to take 21.



Middle: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 21]
Remaining scores: [22, 23, 21, 24, 0, 22]


Next score is 22, but all numbers <= 22 are already taken. Therefore, the player loses the topmost tile on the stack (21), which is returned into the middle.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [23, 21, 24, 0, 22]


Next scores are 23, 21 and 24, so the player takes these tiles from the middle.



Middle: [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21, 24]
Remaining scores: [0, 22]


The player busts and scores zero. Therefore, the tile with the number 24 (topmost on the stack) is returned into the middle.



Middle: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21]
Remaining scores: [22]


The last score is 22, but all tiles <= 22 are already taken, so the player loses the topmost tile on the stack (21).



Middle: [21, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Final Stack and Output: [22, 23]


Test cases



(with the topmost tile last in the output list)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [26, 30, 21]
Output: [26, 30, 21]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [35, 35, 36, 36]
Output: [35, 34, 36, 33]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23]
Output: [23]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores:
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23, 0]
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]
Output: [22, 23]

Tiles: [1, 5, 9, 13, 17, 21, 26]
Scores: [6, 10, 23, 23, 23, 1, 0, 15]
Output: [5, 9, 21, 17, 13, 1]

Tiles:
Scores: [4, 6, 1, 6]
Output:




Sandbox










share|improve this question









$endgroup$












  • $begingroup$
    If the middle pile is empty does that count as all it's members being higher than the score? I mean logically it does but I just want to be clear.
    $endgroup$
    – TRITICIMAGVS
    5 hours ago










  • $begingroup$
    Can we assume there are no tiles with a value of zero in the middle?
    $endgroup$
    – Embodiment of Ignorance
    5 hours ago










  • $begingroup$
    @EmbodimentofIgnorance It says "positive integer", so yes.
    $endgroup$
    – Ørjan Johansen
    5 hours ago










  • $begingroup$
    Since the tiles are unique, would it be acceptable to take them as a bitmask?
    $endgroup$
    – Arnauld
    4 hours ago


















6












$begingroup$


In the game Pickomino, there are several tiles lying in the middle of the table, each with a different positive integer on them. Each turn, the players roll dices in a certain way and get a score, which is a nonnegative integer.



Now the player takes the tile with the highest number that is still lower or equal to their score, removing the tile from the middle and adding it to their stack. If this is not possible because all numbers in the middle are higher than the player's score, the player loses the topmost tile from their stack (which was added latest), which is returned to the middle. If the player has no tiles left, nothing happens.



The challenge



Simulate a player playing the game against themselves. You get a list of the tiles in the middle and a list of the scores that the player got. Return a list of the tiles of the player after all turns have been evaluated.



Challenge rules




  • You can assume that the list with the tiles is ordered and doesn't contain any integer twice.

  • You can take both lists of input in any order you want

  • The output has to keep the order of the tiles on the stack, but you can decide whether the list is sorted from top to bottom or from bottom to top.


General rules




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Adding an explanation for you answer is recommended.


Example



(taken from the 6th testcase)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]


First score is 22, so take the highest tile in the middle <= 22, which is 22 itself.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [22, 22, 23, 21, 24, 0, 22]


Next score is 22, so take the highest tile in the middle <= 22. Because 22 is already taken, the player has to take 21.



Middle: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 21]
Remaining scores: [22, 23, 21, 24, 0, 22]


Next score is 22, but all numbers <= 22 are already taken. Therefore, the player loses the topmost tile on the stack (21), which is returned into the middle.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [23, 21, 24, 0, 22]


Next scores are 23, 21 and 24, so the player takes these tiles from the middle.



Middle: [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21, 24]
Remaining scores: [0, 22]


The player busts and scores zero. Therefore, the tile with the number 24 (topmost on the stack) is returned into the middle.



Middle: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21]
Remaining scores: [22]


The last score is 22, but all tiles <= 22 are already taken, so the player loses the topmost tile on the stack (21).



Middle: [21, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Final Stack and Output: [22, 23]


Test cases



(with the topmost tile last in the output list)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [26, 30, 21]
Output: [26, 30, 21]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [35, 35, 36, 36]
Output: [35, 34, 36, 33]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23]
Output: [23]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores:
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23, 0]
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]
Output: [22, 23]

Tiles: [1, 5, 9, 13, 17, 21, 26]
Scores: [6, 10, 23, 23, 23, 1, 0, 15]
Output: [5, 9, 21, 17, 13, 1]

Tiles:
Scores: [4, 6, 1, 6]
Output:




Sandbox










share|improve this question









$endgroup$












  • $begingroup$
    If the middle pile is empty does that count as all it's members being higher than the score? I mean logically it does but I just want to be clear.
    $endgroup$
    – TRITICIMAGVS
    5 hours ago










  • $begingroup$
    Can we assume there are no tiles with a value of zero in the middle?
    $endgroup$
    – Embodiment of Ignorance
    5 hours ago










  • $begingroup$
    @EmbodimentofIgnorance It says "positive integer", so yes.
    $endgroup$
    – Ørjan Johansen
    5 hours ago










  • $begingroup$
    Since the tiles are unique, would it be acceptable to take them as a bitmask?
    $endgroup$
    – Arnauld
    4 hours ago
















6












6








6





$begingroup$


In the game Pickomino, there are several tiles lying in the middle of the table, each with a different positive integer on them. Each turn, the players roll dices in a certain way and get a score, which is a nonnegative integer.



Now the player takes the tile with the highest number that is still lower or equal to their score, removing the tile from the middle and adding it to their stack. If this is not possible because all numbers in the middle are higher than the player's score, the player loses the topmost tile from their stack (which was added latest), which is returned to the middle. If the player has no tiles left, nothing happens.



The challenge



Simulate a player playing the game against themselves. You get a list of the tiles in the middle and a list of the scores that the player got. Return a list of the tiles of the player after all turns have been evaluated.



Challenge rules




  • You can assume that the list with the tiles is ordered and doesn't contain any integer twice.

  • You can take both lists of input in any order you want

  • The output has to keep the order of the tiles on the stack, but you can decide whether the list is sorted from top to bottom or from bottom to top.


General rules




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Adding an explanation for you answer is recommended.


Example



(taken from the 6th testcase)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]


First score is 22, so take the highest tile in the middle <= 22, which is 22 itself.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [22, 22, 23, 21, 24, 0, 22]


Next score is 22, so take the highest tile in the middle <= 22. Because 22 is already taken, the player has to take 21.



Middle: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 21]
Remaining scores: [22, 23, 21, 24, 0, 22]


Next score is 22, but all numbers <= 22 are already taken. Therefore, the player loses the topmost tile on the stack (21), which is returned into the middle.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [23, 21, 24, 0, 22]


Next scores are 23, 21 and 24, so the player takes these tiles from the middle.



Middle: [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21, 24]
Remaining scores: [0, 22]


The player busts and scores zero. Therefore, the tile with the number 24 (topmost on the stack) is returned into the middle.



Middle: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21]
Remaining scores: [22]


The last score is 22, but all tiles <= 22 are already taken, so the player loses the topmost tile on the stack (21).



Middle: [21, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Final Stack and Output: [22, 23]


Test cases



(with the topmost tile last in the output list)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [26, 30, 21]
Output: [26, 30, 21]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [35, 35, 36, 36]
Output: [35, 34, 36, 33]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23]
Output: [23]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores:
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23, 0]
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]
Output: [22, 23]

Tiles: [1, 5, 9, 13, 17, 21, 26]
Scores: [6, 10, 23, 23, 23, 1, 0, 15]
Output: [5, 9, 21, 17, 13, 1]

Tiles:
Scores: [4, 6, 1, 6]
Output:




Sandbox










share|improve this question









$endgroup$




In the game Pickomino, there are several tiles lying in the middle of the table, each with a different positive integer on them. Each turn, the players roll dices in a certain way and get a score, which is a nonnegative integer.



Now the player takes the tile with the highest number that is still lower or equal to their score, removing the tile from the middle and adding it to their stack. If this is not possible because all numbers in the middle are higher than the player's score, the player loses the topmost tile from their stack (which was added latest), which is returned to the middle. If the player has no tiles left, nothing happens.



The challenge



Simulate a player playing the game against themselves. You get a list of the tiles in the middle and a list of the scores that the player got. Return a list of the tiles of the player after all turns have been evaluated.



Challenge rules




  • You can assume that the list with the tiles is ordered and doesn't contain any integer twice.

  • You can take both lists of input in any order you want

  • The output has to keep the order of the tiles on the stack, but you can decide whether the list is sorted from top to bottom or from bottom to top.


General rules




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Adding an explanation for you answer is recommended.


Example



(taken from the 6th testcase)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]


First score is 22, so take the highest tile in the middle <= 22, which is 22 itself.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [22, 22, 23, 21, 24, 0, 22]


Next score is 22, so take the highest tile in the middle <= 22. Because 22 is already taken, the player has to take 21.



Middle: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 21]
Remaining scores: [22, 23, 21, 24, 0, 22]


Next score is 22, but all numbers <= 22 are already taken. Therefore, the player loses the topmost tile on the stack (21), which is returned into the middle.



Middle: [21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22]
Remaining scores: [23, 21, 24, 0, 22]


Next scores are 23, 21 and 24, so the player takes these tiles from the middle.



Middle: [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21, 24]
Remaining scores: [0, 22]


The player busts and scores zero. Therefore, the tile with the number 24 (topmost on the stack) is returned into the middle.



Middle: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Stack: [22, 23, 21]
Remaining scores: [22]


The last score is 22, but all tiles <= 22 are already taken, so the player loses the topmost tile on the stack (21).



Middle: [21, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Final Stack and Output: [22, 23]


Test cases



(with the topmost tile last in the output list)



Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [26, 30, 21]
Output: [26, 30, 21]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [35, 35, 36, 36]
Output: [35, 34, 36, 33]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23]
Output: [23]

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores:
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 17, 23, 19, 23, 0]
Output:

Tiles: [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]
Scores: [22, 22, 22, 23, 21, 24, 0, 22]
Output: [22, 23]

Tiles: [1, 5, 9, 13, 17, 21, 26]
Scores: [6, 10, 23, 23, 23, 1, 0, 15]
Output: [5, 9, 21, 17, 13, 1]

Tiles:
Scores: [4, 6, 1, 6]
Output:




Sandbox







code-golf game






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 6 hours ago









Black Owl KaiBlack Owl Kai

6409




6409












  • $begingroup$
    If the middle pile is empty does that count as all it's members being higher than the score? I mean logically it does but I just want to be clear.
    $endgroup$
    – TRITICIMAGVS
    5 hours ago










  • $begingroup$
    Can we assume there are no tiles with a value of zero in the middle?
    $endgroup$
    – Embodiment of Ignorance
    5 hours ago










  • $begingroup$
    @EmbodimentofIgnorance It says "positive integer", so yes.
    $endgroup$
    – Ørjan Johansen
    5 hours ago










  • $begingroup$
    Since the tiles are unique, would it be acceptable to take them as a bitmask?
    $endgroup$
    – Arnauld
    4 hours ago




















  • $begingroup$
    If the middle pile is empty does that count as all it's members being higher than the score? I mean logically it does but I just want to be clear.
    $endgroup$
    – TRITICIMAGVS
    5 hours ago










  • $begingroup$
    Can we assume there are no tiles with a value of zero in the middle?
    $endgroup$
    – Embodiment of Ignorance
    5 hours ago










  • $begingroup$
    @EmbodimentofIgnorance It says "positive integer", so yes.
    $endgroup$
    – Ørjan Johansen
    5 hours ago










  • $begingroup$
    Since the tiles are unique, would it be acceptable to take them as a bitmask?
    $endgroup$
    – Arnauld
    4 hours ago


















$begingroup$
If the middle pile is empty does that count as all it's members being higher than the score? I mean logically it does but I just want to be clear.
$endgroup$
– TRITICIMAGVS
5 hours ago




$begingroup$
If the middle pile is empty does that count as all it's members being higher than the score? I mean logically it does but I just want to be clear.
$endgroup$
– TRITICIMAGVS
5 hours ago












$begingroup$
Can we assume there are no tiles with a value of zero in the middle?
$endgroup$
– Embodiment of Ignorance
5 hours ago




$begingroup$
Can we assume there are no tiles with a value of zero in the middle?
$endgroup$
– Embodiment of Ignorance
5 hours ago












$begingroup$
@EmbodimentofIgnorance It says "positive integer", so yes.
$endgroup$
– Ørjan Johansen
5 hours ago




$begingroup$
@EmbodimentofIgnorance It says "positive integer", so yes.
$endgroup$
– Ørjan Johansen
5 hours ago












$begingroup$
Since the tiles are unique, would it be acceptable to take them as a bitmask?
$endgroup$
– Arnauld
4 hours ago






$begingroup$
Since the tiles are unique, would it be acceptable to take them as a bitmask?
$endgroup$
– Arnauld
4 hours ago












6 Answers
6






active

oldest

votes


















1












$begingroup$


Haskell, 119 111 104 103 bytes



1 byte saved thanks to Ørjan Johansen





(#)=span.(<)
(a%(b:c))d|(g,e:h)<-b#d=(e:a)%c$g++h|g:h<-a,(i,j)<-g#d=h%c$i++g:j|1>0=a%c$d
(a%b)c=a
(%)


Try it online!



Assumes the tiles are sorted in descending order.



Not much fancy going on here. The first argument is the players pile, the second their scores and the third is the pile in the middle.






share|improve this answer











$endgroup$









  • 1




    $begingroup$
    This cannot be right because sort is ascending. The TIO test case never hits that branch, though. I strongly recommend testing all cases every time when iterating like this.
    $endgroup$
    – Ørjan Johansen
    5 hours ago












  • $begingroup$
    @ØrjanJohansen Thanks! Fixed now. At least I don't have to import any longer!
    $endgroup$
    – TRITICIMAGVS
    4 hours ago










  • $begingroup$
    Save a byte with (#)=span.(<).
    $endgroup$
    – Ørjan Johansen
    4 hours ago










  • $begingroup$
    @ØrjanJohansen Change made. Funny thing is I tried that earlier and thought that it added a byte.
    $endgroup$
    – TRITICIMAGVS
    4 hours ago



















0












$begingroup$

Japt, 24 bytes



Oof! That didn't work out as well as I thought it would!



Takes input in reverse order.



®=Va§Z)Ì?NpVjZ:VpNo)n



Try it






share|improve this answer









$endgroup$





















    0












    $begingroup$


    Charcoal, 35 bytes



    Fη«≔⌈Φ講κιι¿ι«≔Φθ⁻κιθ⊞υι»¿υ⊞θ⊟υ»Iυ


    Try it online! Link is to verbose version of code. Explanation:



    Fη«


    Loop over the scores.



    ≔⌈Φ講κιι


    Look for the highest available tile.



    ¿ι«


    If it exists then...



    ≔Φθ⁻κιθ


    ... remove the tile from the middle...



    ⊞υι


    ... and add it to the stack.



    »¿υ


    Otherwise, if the stack is not empty...



    ⊞θ⊟υ


    Remove the latest tile from the stack and return it to the middle.



    »Iυ


    Print the resulting stack from oldest to newest.






    share|improve this answer









    $endgroup$





















      0












      $begingroup$


      Perl 6, 89 bytes





      {my@x;@^a;@^b>>.&{@x=|@x,|(keys(@a∖@x).grep($_>=*).sort(-*)[0]//(try ~@x.pop&&()))};@x}


      Try it online!



      I think there's a few more bytes to be golfed off this...






      share|improve this answer









      $endgroup$





















        0












        $begingroup$

        JavaScript (ES6),  100 98  94 bytes



        Takes input as (tiles)(scores). The tiles can be passed in any order.





        t=>s=>s.map(x=>m[(g=_=>m[x]?x:g(x--))()?r.push(x)&&x:r.pop()]^=1,t.map(x=>m[x]=1,m=[r=]))&&r


        Try it online!



        Commented



        t => s =>                 // t = tiles; s = scores
        s.map(x => // for each score x in s:
        m[ // update the 'middle':
        (g = _ => // g = recursive function which decrements x until
        m[x] ? x : g(x--) // m[x] is set and returns the final value
        )() ? // if x is not equal to 0 after that:
        r.push(x) && x // push x in the stack r and yield x
        : // else:
        r.pop() // pop the last value from the stack
        ] ^= 1, // toggle the corresponding flag in m
        t.map(x => // initialization of the 'middle': for each value x in t:
        m[x] = 1, // set m[x]
        m = [r = ] // the stack r is stored as the first entry of m,
        // which ensures that g will always stop when x = 0
        ) // end of initialization
        ) && r // end of main loop; return r





        share|improve this answer











        $endgroup$





















          0












          $begingroup$


          C# (Visual C# Interactive Compiler), 159 158 bytes





          Called as f(tiles)(scores)



          n=>m=>{var s=new Stack<int>();m.Add(0);foreach(var k in n){var a=m.Except(s).Where(x=>x<=k).Max();if(a<1)m.Add(s.Count<1?0:s.Pop());else s.Push(a);}return s;}


          Try it online!



          //Function taking in a list and returning
          //another function that takes in another list and returns a stack
          n=>m=>{
          //Initialize the stack
          var s=new Stack<int>();
          //Add a zero to the tiles, to ensure no empty collection exceptions
          //when we try to filter it later and getting the biggest element
          m.Add(0);
          //Iterate through our scores
          foreach(var k in n){
          //Create a variable called a, which we will use later
          var a=
          //Get all the elements in the middle that haven't appeared in our stack
          m.Except(s).
          //And throw away all elements that are bigger than our current score
          Where(x=>x<=k).
          //And get the biggest element there, and that is now the value of a
          //Without the m.Add(0), we would get an exception here
          Max();
          //Self-explanatory, if a is less than 1 aka if a equals 0
          //Checks if all elements in the middle are bigger than our score
          //Except for our self added 0, of course
          if(a<1)
          //Add 0 to the middle if the stack is empty
          //Remember, zeros don't affect the list
          m.Add(s.Count<1?0:
          //Else pop the stack and add that to the middle
          s.Pop());
          //If a isn't 0, add a to the stack
          else s.Push(a);}
          //Afterwards, return the stack
          return s;}





          share|improve this answer











          $endgroup$













            Your Answer





            StackExchange.ifUsing("editor", function () {
            return StackExchange.using("mathjaxEditing", function () {
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
            });
            });
            }, "mathjax-editing");

            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "200"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f179588%2fplaying-pickomino%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            6 Answers
            6






            active

            oldest

            votes








            6 Answers
            6






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1












            $begingroup$


            Haskell, 119 111 104 103 bytes



            1 byte saved thanks to Ørjan Johansen





            (#)=span.(<)
            (a%(b:c))d|(g,e:h)<-b#d=(e:a)%c$g++h|g:h<-a,(i,j)<-g#d=h%c$i++g:j|1>0=a%c$d
            (a%b)c=a
            (%)


            Try it online!



            Assumes the tiles are sorted in descending order.



            Not much fancy going on here. The first argument is the players pile, the second their scores and the third is the pile in the middle.






            share|improve this answer











            $endgroup$









            • 1




              $begingroup$
              This cannot be right because sort is ascending. The TIO test case never hits that branch, though. I strongly recommend testing all cases every time when iterating like this.
              $endgroup$
              – Ørjan Johansen
              5 hours ago












            • $begingroup$
              @ØrjanJohansen Thanks! Fixed now. At least I don't have to import any longer!
              $endgroup$
              – TRITICIMAGVS
              4 hours ago










            • $begingroup$
              Save a byte with (#)=span.(<).
              $endgroup$
              – Ørjan Johansen
              4 hours ago










            • $begingroup$
              @ØrjanJohansen Change made. Funny thing is I tried that earlier and thought that it added a byte.
              $endgroup$
              – TRITICIMAGVS
              4 hours ago
















            1












            $begingroup$


            Haskell, 119 111 104 103 bytes



            1 byte saved thanks to Ørjan Johansen





            (#)=span.(<)
            (a%(b:c))d|(g,e:h)<-b#d=(e:a)%c$g++h|g:h<-a,(i,j)<-g#d=h%c$i++g:j|1>0=a%c$d
            (a%b)c=a
            (%)


            Try it online!



            Assumes the tiles are sorted in descending order.



            Not much fancy going on here. The first argument is the players pile, the second their scores and the third is the pile in the middle.






            share|improve this answer











            $endgroup$









            • 1




              $begingroup$
              This cannot be right because sort is ascending. The TIO test case never hits that branch, though. I strongly recommend testing all cases every time when iterating like this.
              $endgroup$
              – Ørjan Johansen
              5 hours ago












            • $begingroup$
              @ØrjanJohansen Thanks! Fixed now. At least I don't have to import any longer!
              $endgroup$
              – TRITICIMAGVS
              4 hours ago










            • $begingroup$
              Save a byte with (#)=span.(<).
              $endgroup$
              – Ørjan Johansen
              4 hours ago










            • $begingroup$
              @ØrjanJohansen Change made. Funny thing is I tried that earlier and thought that it added a byte.
              $endgroup$
              – TRITICIMAGVS
              4 hours ago














            1












            1








            1





            $begingroup$


            Haskell, 119 111 104 103 bytes



            1 byte saved thanks to Ørjan Johansen





            (#)=span.(<)
            (a%(b:c))d|(g,e:h)<-b#d=(e:a)%c$g++h|g:h<-a,(i,j)<-g#d=h%c$i++g:j|1>0=a%c$d
            (a%b)c=a
            (%)


            Try it online!



            Assumes the tiles are sorted in descending order.



            Not much fancy going on here. The first argument is the players pile, the second their scores and the third is the pile in the middle.






            share|improve this answer











            $endgroup$




            Haskell, 119 111 104 103 bytes



            1 byte saved thanks to Ørjan Johansen





            (#)=span.(<)
            (a%(b:c))d|(g,e:h)<-b#d=(e:a)%c$g++h|g:h<-a,(i,j)<-g#d=h%c$i++g:j|1>0=a%c$d
            (a%b)c=a
            (%)


            Try it online!



            Assumes the tiles are sorted in descending order.



            Not much fancy going on here. The first argument is the players pile, the second their scores and the third is the pile in the middle.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 4 hours ago

























            answered 5 hours ago









            TRITICIMAGVSTRITICIMAGVS

            34.5k10157369




            34.5k10157369








            • 1




              $begingroup$
              This cannot be right because sort is ascending. The TIO test case never hits that branch, though. I strongly recommend testing all cases every time when iterating like this.
              $endgroup$
              – Ørjan Johansen
              5 hours ago












            • $begingroup$
              @ØrjanJohansen Thanks! Fixed now. At least I don't have to import any longer!
              $endgroup$
              – TRITICIMAGVS
              4 hours ago










            • $begingroup$
              Save a byte with (#)=span.(<).
              $endgroup$
              – Ørjan Johansen
              4 hours ago










            • $begingroup$
              @ØrjanJohansen Change made. Funny thing is I tried that earlier and thought that it added a byte.
              $endgroup$
              – TRITICIMAGVS
              4 hours ago














            • 1




              $begingroup$
              This cannot be right because sort is ascending. The TIO test case never hits that branch, though. I strongly recommend testing all cases every time when iterating like this.
              $endgroup$
              – Ørjan Johansen
              5 hours ago












            • $begingroup$
              @ØrjanJohansen Thanks! Fixed now. At least I don't have to import any longer!
              $endgroup$
              – TRITICIMAGVS
              4 hours ago










            • $begingroup$
              Save a byte with (#)=span.(<).
              $endgroup$
              – Ørjan Johansen
              4 hours ago










            • $begingroup$
              @ØrjanJohansen Change made. Funny thing is I tried that earlier and thought that it added a byte.
              $endgroup$
              – TRITICIMAGVS
              4 hours ago








            1




            1




            $begingroup$
            This cannot be right because sort is ascending. The TIO test case never hits that branch, though. I strongly recommend testing all cases every time when iterating like this.
            $endgroup$
            – Ørjan Johansen
            5 hours ago






            $begingroup$
            This cannot be right because sort is ascending. The TIO test case never hits that branch, though. I strongly recommend testing all cases every time when iterating like this.
            $endgroup$
            – Ørjan Johansen
            5 hours ago














            $begingroup$
            @ØrjanJohansen Thanks! Fixed now. At least I don't have to import any longer!
            $endgroup$
            – TRITICIMAGVS
            4 hours ago




            $begingroup$
            @ØrjanJohansen Thanks! Fixed now. At least I don't have to import any longer!
            $endgroup$
            – TRITICIMAGVS
            4 hours ago












            $begingroup$
            Save a byte with (#)=span.(<).
            $endgroup$
            – Ørjan Johansen
            4 hours ago




            $begingroup$
            Save a byte with (#)=span.(<).
            $endgroup$
            – Ørjan Johansen
            4 hours ago












            $begingroup$
            @ØrjanJohansen Change made. Funny thing is I tried that earlier and thought that it added a byte.
            $endgroup$
            – TRITICIMAGVS
            4 hours ago




            $begingroup$
            @ØrjanJohansen Change made. Funny thing is I tried that earlier and thought that it added a byte.
            $endgroup$
            – TRITICIMAGVS
            4 hours ago











            0












            $begingroup$

            Japt, 24 bytes



            Oof! That didn't work out as well as I thought it would!



            Takes input in reverse order.



            ®=Va§Z)Ì?NpVjZ:VpNo)n



            Try it






            share|improve this answer









            $endgroup$


















              0












              $begingroup$

              Japt, 24 bytes



              Oof! That didn't work out as well as I thought it would!



              Takes input in reverse order.



              ®=Va§Z)Ì?NpVjZ:VpNo)n



              Try it






              share|improve this answer









              $endgroup$
















                0












                0








                0





                $begingroup$

                Japt, 24 bytes



                Oof! That didn't work out as well as I thought it would!



                Takes input in reverse order.



                ®=Va§Z)Ì?NpVjZ:VpNo)n



                Try it






                share|improve this answer









                $endgroup$



                Japt, 24 bytes



                Oof! That didn't work out as well as I thought it would!



                Takes input in reverse order.



                ®=Va§Z)Ì?NpVjZ:VpNo)n



                Try it







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 4 hours ago









                ShaggyShaggy

                19.7k21667




                19.7k21667























                    0












                    $begingroup$


                    Charcoal, 35 bytes



                    Fη«≔⌈Φ講κιι¿ι«≔Φθ⁻κιθ⊞υι»¿υ⊞θ⊟υ»Iυ


                    Try it online! Link is to verbose version of code. Explanation:



                    Fη«


                    Loop over the scores.



                    ≔⌈Φ講κιι


                    Look for the highest available tile.



                    ¿ι«


                    If it exists then...



                    ≔Φθ⁻κιθ


                    ... remove the tile from the middle...



                    ⊞υι


                    ... and add it to the stack.



                    »¿υ


                    Otherwise, if the stack is not empty...



                    ⊞θ⊟υ


                    Remove the latest tile from the stack and return it to the middle.



                    »Iυ


                    Print the resulting stack from oldest to newest.






                    share|improve this answer









                    $endgroup$


















                      0












                      $begingroup$


                      Charcoal, 35 bytes



                      Fη«≔⌈Φ講κιι¿ι«≔Φθ⁻κιθ⊞υι»¿υ⊞θ⊟υ»Iυ


                      Try it online! Link is to verbose version of code. Explanation:



                      Fη«


                      Loop over the scores.



                      ≔⌈Φ講κιι


                      Look for the highest available tile.



                      ¿ι«


                      If it exists then...



                      ≔Φθ⁻κιθ


                      ... remove the tile from the middle...



                      ⊞υι


                      ... and add it to the stack.



                      »¿υ


                      Otherwise, if the stack is not empty...



                      ⊞θ⊟υ


                      Remove the latest tile from the stack and return it to the middle.



                      »Iυ


                      Print the resulting stack from oldest to newest.






                      share|improve this answer









                      $endgroup$
















                        0












                        0








                        0





                        $begingroup$


                        Charcoal, 35 bytes



                        Fη«≔⌈Φ講κιι¿ι«≔Φθ⁻κιθ⊞υι»¿υ⊞θ⊟υ»Iυ


                        Try it online! Link is to verbose version of code. Explanation:



                        Fη«


                        Loop over the scores.



                        ≔⌈Φ講κιι


                        Look for the highest available tile.



                        ¿ι«


                        If it exists then...



                        ≔Φθ⁻κιθ


                        ... remove the tile from the middle...



                        ⊞υι


                        ... and add it to the stack.



                        »¿υ


                        Otherwise, if the stack is not empty...



                        ⊞θ⊟υ


                        Remove the latest tile from the stack and return it to the middle.



                        »Iυ


                        Print the resulting stack from oldest to newest.






                        share|improve this answer









                        $endgroup$




                        Charcoal, 35 bytes



                        Fη«≔⌈Φ講κιι¿ι«≔Φθ⁻κιθ⊞υι»¿υ⊞θ⊟υ»Iυ


                        Try it online! Link is to verbose version of code. Explanation:



                        Fη«


                        Loop over the scores.



                        ≔⌈Φ講κιι


                        Look for the highest available tile.



                        ¿ι«


                        If it exists then...



                        ≔Φθ⁻κιθ


                        ... remove the tile from the middle...



                        ⊞υι


                        ... and add it to the stack.



                        »¿υ


                        Otherwise, if the stack is not empty...



                        ⊞θ⊟υ


                        Remove the latest tile from the stack and return it to the middle.



                        »Iυ


                        Print the resulting stack from oldest to newest.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 3 hours ago









                        NeilNeil

                        80.4k744178




                        80.4k744178























                            0












                            $begingroup$


                            Perl 6, 89 bytes





                            {my@x;@^a;@^b>>.&{@x=|@x,|(keys(@a∖@x).grep($_>=*).sort(-*)[0]//(try ~@x.pop&&()))};@x}


                            Try it online!



                            I think there's a few more bytes to be golfed off this...






                            share|improve this answer









                            $endgroup$


















                              0












                              $begingroup$


                              Perl 6, 89 bytes





                              {my@x;@^a;@^b>>.&{@x=|@x,|(keys(@a∖@x).grep($_>=*).sort(-*)[0]//(try ~@x.pop&&()))};@x}


                              Try it online!



                              I think there's a few more bytes to be golfed off this...






                              share|improve this answer









                              $endgroup$
















                                0












                                0








                                0





                                $begingroup$


                                Perl 6, 89 bytes





                                {my@x;@^a;@^b>>.&{@x=|@x,|(keys(@a∖@x).grep($_>=*).sort(-*)[0]//(try ~@x.pop&&()))};@x}


                                Try it online!



                                I think there's a few more bytes to be golfed off this...






                                share|improve this answer









                                $endgroup$




                                Perl 6, 89 bytes





                                {my@x;@^a;@^b>>.&{@x=|@x,|(keys(@a∖@x).grep($_>=*).sort(-*)[0]//(try ~@x.pop&&()))};@x}


                                Try it online!



                                I think there's a few more bytes to be golfed off this...







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 3 hours ago









                                Jo KingJo King

                                22.2k251115




                                22.2k251115























                                    0












                                    $begingroup$

                                    JavaScript (ES6),  100 98  94 bytes



                                    Takes input as (tiles)(scores). The tiles can be passed in any order.





                                    t=>s=>s.map(x=>m[(g=_=>m[x]?x:g(x--))()?r.push(x)&&x:r.pop()]^=1,t.map(x=>m[x]=1,m=[r=]))&&r


                                    Try it online!



                                    Commented



                                    t => s =>                 // t = tiles; s = scores
                                    s.map(x => // for each score x in s:
                                    m[ // update the 'middle':
                                    (g = _ => // g = recursive function which decrements x until
                                    m[x] ? x : g(x--) // m[x] is set and returns the final value
                                    )() ? // if x is not equal to 0 after that:
                                    r.push(x) && x // push x in the stack r and yield x
                                    : // else:
                                    r.pop() // pop the last value from the stack
                                    ] ^= 1, // toggle the corresponding flag in m
                                    t.map(x => // initialization of the 'middle': for each value x in t:
                                    m[x] = 1, // set m[x]
                                    m = [r = ] // the stack r is stored as the first entry of m,
                                    // which ensures that g will always stop when x = 0
                                    ) // end of initialization
                                    ) && r // end of main loop; return r





                                    share|improve this answer











                                    $endgroup$


















                                      0












                                      $begingroup$

                                      JavaScript (ES6),  100 98  94 bytes



                                      Takes input as (tiles)(scores). The tiles can be passed in any order.





                                      t=>s=>s.map(x=>m[(g=_=>m[x]?x:g(x--))()?r.push(x)&&x:r.pop()]^=1,t.map(x=>m[x]=1,m=[r=]))&&r


                                      Try it online!



                                      Commented



                                      t => s =>                 // t = tiles; s = scores
                                      s.map(x => // for each score x in s:
                                      m[ // update the 'middle':
                                      (g = _ => // g = recursive function which decrements x until
                                      m[x] ? x : g(x--) // m[x] is set and returns the final value
                                      )() ? // if x is not equal to 0 after that:
                                      r.push(x) && x // push x in the stack r and yield x
                                      : // else:
                                      r.pop() // pop the last value from the stack
                                      ] ^= 1, // toggle the corresponding flag in m
                                      t.map(x => // initialization of the 'middle': for each value x in t:
                                      m[x] = 1, // set m[x]
                                      m = [r = ] // the stack r is stored as the first entry of m,
                                      // which ensures that g will always stop when x = 0
                                      ) // end of initialization
                                      ) && r // end of main loop; return r





                                      share|improve this answer











                                      $endgroup$
















                                        0












                                        0








                                        0





                                        $begingroup$

                                        JavaScript (ES6),  100 98  94 bytes



                                        Takes input as (tiles)(scores). The tiles can be passed in any order.





                                        t=>s=>s.map(x=>m[(g=_=>m[x]?x:g(x--))()?r.push(x)&&x:r.pop()]^=1,t.map(x=>m[x]=1,m=[r=]))&&r


                                        Try it online!



                                        Commented



                                        t => s =>                 // t = tiles; s = scores
                                        s.map(x => // for each score x in s:
                                        m[ // update the 'middle':
                                        (g = _ => // g = recursive function which decrements x until
                                        m[x] ? x : g(x--) // m[x] is set and returns the final value
                                        )() ? // if x is not equal to 0 after that:
                                        r.push(x) && x // push x in the stack r and yield x
                                        : // else:
                                        r.pop() // pop the last value from the stack
                                        ] ^= 1, // toggle the corresponding flag in m
                                        t.map(x => // initialization of the 'middle': for each value x in t:
                                        m[x] = 1, // set m[x]
                                        m = [r = ] // the stack r is stored as the first entry of m,
                                        // which ensures that g will always stop when x = 0
                                        ) // end of initialization
                                        ) && r // end of main loop; return r





                                        share|improve this answer











                                        $endgroup$



                                        JavaScript (ES6),  100 98  94 bytes



                                        Takes input as (tiles)(scores). The tiles can be passed in any order.





                                        t=>s=>s.map(x=>m[(g=_=>m[x]?x:g(x--))()?r.push(x)&&x:r.pop()]^=1,t.map(x=>m[x]=1,m=[r=]))&&r


                                        Try it online!



                                        Commented



                                        t => s =>                 // t = tiles; s = scores
                                        s.map(x => // for each score x in s:
                                        m[ // update the 'middle':
                                        (g = _ => // g = recursive function which decrements x until
                                        m[x] ? x : g(x--) // m[x] is set and returns the final value
                                        )() ? // if x is not equal to 0 after that:
                                        r.push(x) && x // push x in the stack r and yield x
                                        : // else:
                                        r.pop() // pop the last value from the stack
                                        ] ^= 1, // toggle the corresponding flag in m
                                        t.map(x => // initialization of the 'middle': for each value x in t:
                                        m[x] = 1, // set m[x]
                                        m = [r = ] // the stack r is stored as the first entry of m,
                                        // which ensures that g will always stop when x = 0
                                        ) // end of initialization
                                        ) && r // end of main loop; return r






                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited 2 hours ago

























                                        answered 4 hours ago









                                        ArnauldArnauld

                                        75.6k692317




                                        75.6k692317























                                            0












                                            $begingroup$


                                            C# (Visual C# Interactive Compiler), 159 158 bytes





                                            Called as f(tiles)(scores)



                                            n=>m=>{var s=new Stack<int>();m.Add(0);foreach(var k in n){var a=m.Except(s).Where(x=>x<=k).Max();if(a<1)m.Add(s.Count<1?0:s.Pop());else s.Push(a);}return s;}


                                            Try it online!



                                            //Function taking in a list and returning
                                            //another function that takes in another list and returns a stack
                                            n=>m=>{
                                            //Initialize the stack
                                            var s=new Stack<int>();
                                            //Add a zero to the tiles, to ensure no empty collection exceptions
                                            //when we try to filter it later and getting the biggest element
                                            m.Add(0);
                                            //Iterate through our scores
                                            foreach(var k in n){
                                            //Create a variable called a, which we will use later
                                            var a=
                                            //Get all the elements in the middle that haven't appeared in our stack
                                            m.Except(s).
                                            //And throw away all elements that are bigger than our current score
                                            Where(x=>x<=k).
                                            //And get the biggest element there, and that is now the value of a
                                            //Without the m.Add(0), we would get an exception here
                                            Max();
                                            //Self-explanatory, if a is less than 1 aka if a equals 0
                                            //Checks if all elements in the middle are bigger than our score
                                            //Except for our self added 0, of course
                                            if(a<1)
                                            //Add 0 to the middle if the stack is empty
                                            //Remember, zeros don't affect the list
                                            m.Add(s.Count<1?0:
                                            //Else pop the stack and add that to the middle
                                            s.Pop());
                                            //If a isn't 0, add a to the stack
                                            else s.Push(a);}
                                            //Afterwards, return the stack
                                            return s;}





                                            share|improve this answer











                                            $endgroup$


















                                              0












                                              $begingroup$


                                              C# (Visual C# Interactive Compiler), 159 158 bytes





                                              Called as f(tiles)(scores)



                                              n=>m=>{var s=new Stack<int>();m.Add(0);foreach(var k in n){var a=m.Except(s).Where(x=>x<=k).Max();if(a<1)m.Add(s.Count<1?0:s.Pop());else s.Push(a);}return s;}


                                              Try it online!



                                              //Function taking in a list and returning
                                              //another function that takes in another list and returns a stack
                                              n=>m=>{
                                              //Initialize the stack
                                              var s=new Stack<int>();
                                              //Add a zero to the tiles, to ensure no empty collection exceptions
                                              //when we try to filter it later and getting the biggest element
                                              m.Add(0);
                                              //Iterate through our scores
                                              foreach(var k in n){
                                              //Create a variable called a, which we will use later
                                              var a=
                                              //Get all the elements in the middle that haven't appeared in our stack
                                              m.Except(s).
                                              //And throw away all elements that are bigger than our current score
                                              Where(x=>x<=k).
                                              //And get the biggest element there, and that is now the value of a
                                              //Without the m.Add(0), we would get an exception here
                                              Max();
                                              //Self-explanatory, if a is less than 1 aka if a equals 0
                                              //Checks if all elements in the middle are bigger than our score
                                              //Except for our self added 0, of course
                                              if(a<1)
                                              //Add 0 to the middle if the stack is empty
                                              //Remember, zeros don't affect the list
                                              m.Add(s.Count<1?0:
                                              //Else pop the stack and add that to the middle
                                              s.Pop());
                                              //If a isn't 0, add a to the stack
                                              else s.Push(a);}
                                              //Afterwards, return the stack
                                              return s;}





                                              share|improve this answer











                                              $endgroup$
















                                                0












                                                0








                                                0





                                                $begingroup$


                                                C# (Visual C# Interactive Compiler), 159 158 bytes





                                                Called as f(tiles)(scores)



                                                n=>m=>{var s=new Stack<int>();m.Add(0);foreach(var k in n){var a=m.Except(s).Where(x=>x<=k).Max();if(a<1)m.Add(s.Count<1?0:s.Pop());else s.Push(a);}return s;}


                                                Try it online!



                                                //Function taking in a list and returning
                                                //another function that takes in another list and returns a stack
                                                n=>m=>{
                                                //Initialize the stack
                                                var s=new Stack<int>();
                                                //Add a zero to the tiles, to ensure no empty collection exceptions
                                                //when we try to filter it later and getting the biggest element
                                                m.Add(0);
                                                //Iterate through our scores
                                                foreach(var k in n){
                                                //Create a variable called a, which we will use later
                                                var a=
                                                //Get all the elements in the middle that haven't appeared in our stack
                                                m.Except(s).
                                                //And throw away all elements that are bigger than our current score
                                                Where(x=>x<=k).
                                                //And get the biggest element there, and that is now the value of a
                                                //Without the m.Add(0), we would get an exception here
                                                Max();
                                                //Self-explanatory, if a is less than 1 aka if a equals 0
                                                //Checks if all elements in the middle are bigger than our score
                                                //Except for our self added 0, of course
                                                if(a<1)
                                                //Add 0 to the middle if the stack is empty
                                                //Remember, zeros don't affect the list
                                                m.Add(s.Count<1?0:
                                                //Else pop the stack and add that to the middle
                                                s.Pop());
                                                //If a isn't 0, add a to the stack
                                                else s.Push(a);}
                                                //Afterwards, return the stack
                                                return s;}





                                                share|improve this answer











                                                $endgroup$




                                                C# (Visual C# Interactive Compiler), 159 158 bytes





                                                Called as f(tiles)(scores)



                                                n=>m=>{var s=new Stack<int>();m.Add(0);foreach(var k in n){var a=m.Except(s).Where(x=>x<=k).Max();if(a<1)m.Add(s.Count<1?0:s.Pop());else s.Push(a);}return s;}


                                                Try it online!



                                                //Function taking in a list and returning
                                                //another function that takes in another list and returns a stack
                                                n=>m=>{
                                                //Initialize the stack
                                                var s=new Stack<int>();
                                                //Add a zero to the tiles, to ensure no empty collection exceptions
                                                //when we try to filter it later and getting the biggest element
                                                m.Add(0);
                                                //Iterate through our scores
                                                foreach(var k in n){
                                                //Create a variable called a, which we will use later
                                                var a=
                                                //Get all the elements in the middle that haven't appeared in our stack
                                                m.Except(s).
                                                //And throw away all elements that are bigger than our current score
                                                Where(x=>x<=k).
                                                //And get the biggest element there, and that is now the value of a
                                                //Without the m.Add(0), we would get an exception here
                                                Max();
                                                //Self-explanatory, if a is less than 1 aka if a equals 0
                                                //Checks if all elements in the middle are bigger than our score
                                                //Except for our self added 0, of course
                                                if(a<1)
                                                //Add 0 to the middle if the stack is empty
                                                //Remember, zeros don't affect the list
                                                m.Add(s.Count<1?0:
                                                //Else pop the stack and add that to the middle
                                                s.Pop());
                                                //If a isn't 0, add a to the stack
                                                else s.Push(a);}
                                                //Afterwards, return the stack
                                                return s;}






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 1 hour ago

























                                                answered 5 hours ago









                                                Embodiment of IgnoranceEmbodiment of Ignorance

                                                846118




                                                846118






























                                                    draft saved

                                                    draft discarded




















































                                                    If this is an answer to a challenge…




                                                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                      Explanations of your answer make it more interesting to read and are very much encouraged.


                                                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                    More generally…




                                                    • …Please make sure to answer the question and provide sufficient detail.


                                                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f179588%2fplaying-pickomino%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    Polycentropodidae

                                                    Magento 2 Error message: Invalid state change requested

                                                    Paulmy