Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @jddingemanse,validated by @Rafarafa,@cedricdd and @Remi.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @jddingemanse,validated by @Rafarafa,@cedricdd and @Remi.
If you have any issues, feel free to ping them.
Great puzzle! Thank you in particular for including six testcases with only one PUT action, before testcases that require several actions.
A COMBINE action can be used to merge two runs into one longer valid run. Order the rowids from the two rows numerically. The new run gets the lowest rowid (rowid1), the other rowid (rowid2) becomes unused.
In case of a split, the new run with the highest numerical tile values gets a new rowid (highest rowid that existed + 1)
I suggest either
replacing: “the other rowid (rowid2) becomes unused”
with “the other rowid (rowid2) becomes unused (but still cannot be attributed to new runs).”;
or at least
replacing: “highest rowid that existed + 1”
with: “highest rowid that ever existed + 1”
(in consistence with testcase 16)
Thanks, glad you like the puzzle. Your suggestions are good, I changed it into
...the other rowid (rowid2) becomes unused (and cannot be attributed to new runs).
and
...(highest rowid that ever existed + 1)...
I have to try it, maybe soon.
A very interesting yet quite challenging puzzle. I encountered a failure on validator 15, despite passing all the test cases.
Overall, the test cases are well-designed and very helpful for solving the problem. However, I would suggest adding one additional test case to verify the uniqueness of the set — ensuring that the “put” action is disallowed.
After failing validator 15, I revisited the problem description and fixed it. But while the requirement is clearly stated, it’s easy to overlook amidst the many other conditions. Adding such a test would help prevent this oversight.
I am glad you liked it (or at least, that is how I interpret ‘interesting’) . I am surprised at your case (passing all tests, but failing validator 15). I assume you talk about ‘validator 15’, which is supposed to be a twin of ‘Combine priority’. For that test/validator pair, the only difference is that the order of rows in the input is different. It are literally identical rows, only in a different order. So, it is also difficult to grasp the issue that caused the error in your case (and to judge whether it is another edge case that needs to be tested).
Can you explain what you mean with ‘verifying the uniqueness of the set’, and disallowing the put action in that regard? Do you mean a case of having 5B 5G 5Y
, and the option to put 5B
but that this is not allowed because 5B
is already in there?
Yes, I like it!
I passed all the pre-submit tests but failed validator 15 after submission. Since the validator inputs aren’t visible to users (to prevent hardcoded solutions), I couldn’t immediately see what was wrong with my program.
I revisited the problem, re-read the rules, and realized I had missed the uniqueness condition: each tile (number + color) can appear only twice. This meant that if I already had 5B, 5G, and 5Y, adding another 5B should be disallowed.
Without this rule, I was passing all tests but failing validator 15. You can see in my solution where I added an “if” condition to handle this case. After that change, I passed validator 15 and completed the puzzle successfully.
I think this are two different issues. The fact that each tile can only appear twice, is something from the game Rummikub (there are simply two of all tiles available in the game). This feature is never tested, since the input gives you the tiles to work with, and all these tiles are supposed to be available (there will never be a third of one tile).
The part of uniqueness (not a second 5B in a set) is due to the part of the rules through the definition of a set: " tiles all of a unique color". There is in fact a test dedicated to this: test ‘choose the run’ (paired with validator 6, where you get a 10B which cannot go into the set due to the uniqueness requirement.
I sent you by private message the validator input, in case you are interested to double check where your code went wrong. It still surprises me that it would be this uniqueness, since that validator is practically identical to its test case twin. I expect it had more to do with the order of actions that apparently became different due to a different order of the rows (that’s the only difference between the test and validator), and that your if-solution somehow solved this.
Anyway, glad that you were able to find a solution; it’s always frustrating when only a validator fails.
And, now you’re well prepared for Rummikub 2 .
Thank you for a unique and challenging puzzle!
Like @rugby, I had a failure on validator 15 (all other validators and test cases passed), and I came here looking for advice. Based on your post from Oct 11th, Validator 15 is like test case 15 ‘Combine priority’, but the order of the rows has been changed.
I think I’ll try scrambling the order of the rows in test case 15 and see if I can force different behavior out of my solution. Hopefully the bug will present itself.
Glad you liked it! I sent you the IN and OUT of validator 15 by PM. For others having a problem with validator 15 only, I think below custom test is identical, and hopefully helps with debugging:
IN
6B
7
1 5B 5R 5Y
2 5Y 6Y 7Y
3 8G 9G 10G
4 8Y 9Y 10Y
5 5G 6G 7G
6 2B 3B 4B
7 5B 5G 5R
Expected OUT:
COMBINE 2 4
TAKE 5Y 2
PUT 5Y 7
TAKE 5B 7
PUT 5B 6
PUT 6B 6
1 5B 5R 5Y
2 6Y 7Y 8Y 9Y 10Y
3 8G 9G 10G
5 5G 6G 7G
6 2B 3B 4B 5B 6B
7 5G 5R 5Y