Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
So, that's it! Thanks, now totally explained.
In all of the initial tests Hands are created, tested once and then freed. That let me to the assumption that it would always be that way. My mistake. Thanks again.
yes, but what is the issue here ? you modify
tracker
yourself, so you mutate the state of yourHand
object. then at the next call with the same object, of course the mutations will persist. take a look at how the random tests work, all of the hands are built beforehand and are played against each other at random, it is very likely that one hand get used multiple times, hence why the changes persistThanks, but that result would be expected - buildTracker() should indeed set values into the tracker field.
Let's use your test approach, but before any calls to buildTracker:
Output includes:
it seems to be your own code that modifies the
tracker
field though, I slightly modified your test incompare()
:the assertion fails.
This comment is hidden because it contains spoiler information about the solution
This code does not really confirm anything because we do not know how your real code, the one which breaks things, looks like.
This comment is hidden because it contains spoiler information about the solution
Seems not fixed to me. I was given the test:
"JC 6H JS JD JH", "JC 7H JS JD JH"
Both hands contain 4 Jacks. For this to be possible, there would have to be at least two decks of cards in use. To be fair, the description does not specify whether a single deck of cards is used, but I think most people would assume that's the case.
I agree, the correct solution for 96682790625023136 is { 9668279062523136, 11, 0 }
Tested with large random integers, this seems to be about 100 times the speed of some solutions here - those using strings and brute force.
Thanks for the feedback. I was running your code to test it... maybe I made a mistake and forgot to compile and it was somebody else's code :) I'll check again when I've got a moment.
Are you sure? b7 to a8 return 4.
If begin OR end position is a corner point (A1,A8,H1,H8) AND BOTH row and col are 1 step, we've a minimum of 4 moves.
This covers the moves A1-->B2; B2-->A1; H1-->G2; G2-->H1; A8-->B7; B7-->A8; H8-->G7; G7-->H8
For all other 1-1 moves, you will not fall in the second IF case and it returns 2 moves.
I play with the ASCII value: 'a' = 65, 'b' = 66... 'h' = 72; '1' = 49, '2' = 50,... '9' = 57
It doesn't matter if we move from a to b or b to a as ABS(66-65) == ABS(65-66) == 1; same for the digits.
Despite passing tests here, this solution is flawed. I'll fix it when I get a moment.
Try testing all possible moves - you will find it fails on 8 of them.
If you test it with all possible moves, you will find it fails 8 of them, returning 2 when it should be 4.
Loading more items...