I don't know how to forbid eval in codewars and when I was proposed this question, it wasn't required for the main part (constructing all the equations)
I'll add in a line saying no reordering of elements
You have a good point. 1,2,3,0,2,3 with 100 should be either 2 or 3 because 123 + 0 - 23 = 100 and 123 - 0 - 23 = 100 but I'm jaded because 123 - 023 does technically equal 100. We could restrict it to only 1-9 but that also feels dirty.
I think everyone's going to figure out that they need to compose a string of arithmetic to produce this and if they can write a method that takes the string and parses it out, that's what I meant by not using eval. My solution doesn't use eval.
Have you guys gotten this running in Python yet? I'm able to get the provided tests done but I believe I'm running into some floating point rounding issues. Can you guys confirm that you were able to get the python solutions working?
Agreed. I think it was just something I did to explicitly show what i was returning while we could've just left it to the implicit None returned. Also, couldn't these be turned into lambda functions for even more concise coding.
I didn't give a maximum length. I figure a moderate amount of input. I had a random number generator that did like 5-10 numbers.
I went ahead and made it quit out if it gets a leading 0 so [1,2,3,0,2,3] will only return 2:
123 + 0 - 23
and123 - 0 - 23
I think everyone's going to figure out that they need to compose a string of arithmetic to produce this and if they can write a method that takes the string and parses it out, that's what I meant by not using eval. My solution doesn't use eval.
I love how this is scalable to other denominations. Well done!
I really like this solution. Very concise and readable.
This comment is hidden because it contains spoiler information about the solution
Have you guys gotten this running in Python yet? I'm able to get the provided tests done but I believe I'm running into some floating point rounding issues. Can you guys confirm that you were able to get the python solutions working?
Looks good to me. Thanks for adding another example too; I think that will help show what you intend.
description needs to be cleaned up a bit.
Awesome solution! I really like how you avoided nested loops with this solution.
Agreed. I think it was just something I did to explicitly show what i was returning while we could've just left it to the implicit None returned. Also, couldn't these be turned into lambda functions for even more concise coding.
well played sir.
Good catch. I was wondering why this kata was not accepted by more people and I assume that was a cause of major frustration. Thanks for finding it.
This comment is hidden because it contains spoiler information about the solution
Loading more items...