Very neat.
One drawback is that the "scores" list carries incomplete data (after the loop finishes, you will not be able to distinguish frames in the list).
So I didn't vote for "best practices", but voted for "clever"
Hi! Thanks for your feedback! Actualy I'm not really surprised. I spent a lot of effort on this kata. But every time there was an edge case which ruined my another attempt. May be the test cases should be improved to invalidate solutions such as mine.
Very neat.
One drawback is that the "scores" list carries incomplete data (after the loop finishes, you will not be able to distinguish frames in the list).
So I didn't vote for "best practices", but voted for "clever"
This is definitely the best solution I've seen for finding the unknown out of several possible ones.
This comment is hidden because it contains spoiler information about the solution
Liked your way of mixing characters with ints.
duplicate issue below
A plus sign before (possibly negative)
rand.nextInt()
doesn't make it positive. At least not in Java.Thanks, sorry for the delay.
Thank you.
Perfect. Not used any Math.pow() and the number of divisions is minimized
Input:
ORD, K^G, Q^E, DAD, T^B, A^L, B<F, S^I, AKA, AIA, JMJ, PFG, MGM
Output:
BEAHJFOKLTS
It's not even of length 20.
This comment is hidden because it contains spoiler information about the solution
Hi! Thanks for your feedback! Actualy I'm not really surprised. I spent a lot of effort on this kata. But every time there was an edge case which ruined my another attempt. May be the test cases should be improved to invalidate solutions such as mine.
Hi. Unfortunately, your solution is incomplete. Consider this input:
{88, 90, 89, 87}
.Your program cannot find a solution, while it exists, e.g.:
{88, 78, 77, 76, 86, 96, 95, 94, 93, 92, 91, 90, 80, 81, 82, 83, 84, 85, 75, 65, 66, 67, 68, 69, 79, 89, 99, 98, 97, 87}
.Moreover, on this input:
{88, 91, 89, 83}
it returns a path of length 34:
{88, 87, 86, 85, 84, 74, 73, 72, 71, 81, 91, 90, 80, 70, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 79, 89, 99, 98, 97, 96, 95, 94, 93, 83}
,while there is a path of length 32:
{88, 78, 77, 76, 75, 74, 73, 72, 82, 92, 91, 81, 71, 61, 62, 63, 64, 65, 66, 67, 68, 69, 79, 89, 99, 98, 97, 87, 86, 85, 84, 83}
.Hi. Unfortunately, your solution is incomplete. Consider this input:
{30, 1, 28, 0}
.Your program cannot find a solution, while it exists, e.g.:
{30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 29, 19, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 28, 27, 26, 25, 24, 23, 22, 21, 20, 10, 0}
.Moreover, on this input:
{56, 30, 21, 41}
it returns a path of length 15:
{56, 55, 54, 53, 52, 51, 50, 40, 30, 31, 21, 22, 32, 42, 41}
,while there is a path of length 13:
{56, 55, 54, 53, 52, 51, 50, 40, 30, 20, 21, 31, 41}
.Hi. Unfortunately, your solution is incomplete. Consider this input:
{88, 29, 98, 58}
.Your program cannot find a solution, while it exists, e.g.:
{88, 78, 68, 67, 57, 47, 48, 49, 39, 29, 28, 38, 37, 36, 46, 56, 66, 76, 77, 87, 97, 98, 99, 89, 79, 69, 59, 58}
.Moreover, on this input:
{4, 19, 21, 6}
it returns a path of length 39:
{4, 3, 13, 12, 11, 10, 20, 30, 40, 41, 42, 43, 44, 45, 46, 36, 37, 27, 28, 29, 19, 18, 17, 16, 26, 25, 35, 34, 33, 32, 31, 21, 22, 23, 24, 14, 15, 5, 6}
,while there is a path of length 35:
{4, 3, 2, 1, 0, 10, 20, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 29, 19, 18, 28, 27, 26, 25, 24, 23, 22, 21, 11, 12, 13, 14, 15, 5, 6}
.Loading more items...