Yes, unfortunately this exercise does not have a simple version to then increase the difficulty of the tests.
It will be like one of those exercises (already present on the platform) where the user is encouraged to search for a solution by Googling.
The only thing we can do is write a detailed introduction explaining the rules clearly. Then it’s all downhill from there, hopefully.
I don’t think it’s such a difficult exercise to consider Hard. It’s just a matter of recursively applying rules to sort an array at the end of the day.
My secret dream is that someone, after discovering this little problem/game, will be encouraged to contribute to research, perhaps by improving an existing algorithm or creating a new one, or even just by learning more about it through study.
For many novice users, this will certainly be a door to a new topic, it will be up to them to decide whether to open it or not.
The Wikipedia article doesn’t define “tricks” well. I’m trying to implement a solution but (1) my card out if off by 1/2 in 3 cases and (2) I’m not sure what counts as a trick.
Yeah, the Square Root exercise outlines a few possible approaches and then references Wikipedia. I think that’s fine as long as we’re not biasing folks towards one particular approach in case it might not be appropriate for a given track. Practice exercises are ideally solvable multiple ways.
I’d cover the rules and maybe provide a short example game to show how the rules are applied to come up with the final result.
If you tell me which ones you can’t find, I’ll try to check them myself. Maybe I was wrong, or maybe the website was wrong.
The first two tests are definitely correct because I tried them physically with the cards.
A ‘trick’ is a round. When a round ends, the player collects the cards and places them at the bottom of their deck.
Example with small decks :
starting decks:
PLAYER A: "--K--J---"
PLAYER B: "----K----"
pile at the end of the trick:
top → "-J--K--K----" ← bottom
new decks:
PLAYER A: "---|----K--K--J-"
PLAYER B: "---"
pile at the end of the trick:
top → "------" ← bottom
Enough war happening around the world, that it does have a mental picture of something terrible, and in reality for some, even real memories.
We have people on the platform that may be doing this to get away from a little bit of daily stress. We are trying to name things in a way that might not instantly trigger anxiety to people, unnecessarily.
But yeah. Lots of maintainer input, not a ton of explicit “please do proceed” but what I’m reading as a bunch of implicit “sounds good” feedback.
+1 to using Camicia (even if the rules don’t actually match Camicia). We can use the instructions to lay out what rules to follow and the tests to validate the details.
+cc @ErikSchierboom and/or @iHiD : should we have an explicit approval from one of you before proceeding?
Really great introduction. Instructions could probably do with a bit of refinement but generally fine. We can work on that on a PR. Maybe use actual numbers instead of dashes? I found that a bit confusing.
I’ve not looked at the tests, but you’re probably all better positioned than me to agree those. So I’m a . Thanks!
Here is another on the addition of this exercise, with the name Camica (same reasoning as @mk-mxp gave), especially as we do have students in active warzones.
Feel free to make the PR. I definitely have some comments for improvement, but would love to see this added to the JS (and TS) track, and perhaps also Kotlin and Ruby.
I found the problem.
In the first two tests you reported (ignoring the third one, which was already wrong by 1)
they end in the same way.
The last round of the game ends with a trick consisting only of "-".
In your code, you are not counting this possibility as a trick (if at least one payment card has been played, then it works correctly).
Furthermore, in this case, the game does not end as soon as his deck is empty, but at the first play to which he cannot respond, as the player owes only 1 card to his opponent according to the rules.
For example: "----" and "----" would count as 8 cards and 1 trick. (B wins) "----" and "---" would count as 7 cards and 1 trick. (A wins) "---" and "----" would count as 6 cards and 1 trick. (B wins)
Anyway, I wrote to the professor who manages the website with the records. He told me that there is probably an error in the counting of the last card in his website’s Python code.
The errors I found are:
Michael Kleber (before 1999) (5791 → 5790 cards)
Truman Collins (2006) (6914 → 6913 cards)
Reed Nessler (20-09-2013) (7259 → 7258 cards)
William Rucklidge (17-01-2014) (7269 → 7268 cards)
Philip Anderson (03-02-2014) (7323 → 7322 cards)
William Rucklidge (05-03-2014) (7960 → 7959 cards)
I worked on it all day but couldn’t find the problem in the code.
Would anyone like to take a look?
Maybe I’m just being stupid, I don’t know where or what to look for anymore, haha.
I reconsidered, the algorithm always works regardless of the size of the string used.
If desired, other small tests can be added to test only the cards and their behaviour in a single trick.
For example, by testing with 5/10 cards and with 100 or more.
Let’s go for the elegant shirt then!
(Fun fact: Camicia means this in Italian. )
Let me know what you think and how to proceed. Always at your disposal
I’ll try to find time later today to look at the code again. I didn’t realize it counts as a “trick” when there was no face card. We should make sure the instructions are very clear about what counts as a trick.
Put up a PR on the problem spec repo! We can word smith on the PR. For instance, I’d like to completely remove the “Beat you neighbor” from the exercise.
When messages like this come in via e-mail it shows nothing of what kind of link it is. Can we give context to links? Not a complaint to you, @FraSanga just it happens enough that I have to go to the browser to figure it out, and this happened to be “the straw”, as it were.