Ad
  • Custom User Avatar

    Looking at this kata but haven't tried it yet. That said, the parser would know how many parameters the function needs when it sees its name. Thereby knowing how many expressions to parse to be able give it the parameters it needs. Keeping in mind that an expression would continue to parse as long as it possibly can and still being a valid expression. Thus the parser would parse two subsequent expressions (resolving "2 + 5" and "3" respectively) and give them to the function, evaluate it, and continue on.

    It will not stop at just the "2", because "2 + 5" is a valid expression; it will however stop there, because "2 + 5 3" is not a valid expression (as per the grammar).

    I hope that makes sense.

  • Custom User Avatar

    issue 6 years old, author incactive, 322 warriors solved it, translated to other 2 languages, I am presuming, based on these fact, that description is ok. I am closing this issue, as it is stopping kata with 88% rate from further progress in beta process. If anyone disagree, please do suggestion or fork with better description.

  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    No good reason to change specs and invalidate solutions on an ancient kata.

  • Custom User Avatar

    Appreciated!

  • Custom User Avatar

    I've fixed the Rust translation, sample tests should now correctly use Options in the assertions. A reset of the trainer might be necessary to see the changes if you've already started training on them, however I wouldn't bother since the actual test suite is not affected by this issue.

  • Custom User Avatar

    This is very odd, since the approved translation has correct sample tests. Not sure how these (outdated) sample tests show up when entering the trainer. I'll look into it.

  • Custom User Avatar

    Rust sample tests do not compile. A few test cases do not compare to an Option<usize> as they should, and the case for None expects -1.

  • Custom User Avatar

    I would imagine this goes against the original idea of the kata, and additionally, this would invalidate a lot of solutions. It's a major change for a kata years old. This could be incorporated into a separate kata that expands on the idea of a PaginationHelper.

  • Custom User Avatar

    How should the expression 5 + abc 2 + 5 3, where abc is a function with two parameters, be evaluated?
    This expression is permissible by the grammar, however the language spec lists + as a higher priority than functions. Intuitively, I'd want to just evaluate the function first, but that seems to go against what is explicitly stated, unless I'm misunderstanding how priority works.

    Edit: To anyone else wondering about how the priority properly works, function calls are the highest priority. Then, the operations in the table follow accordingly. Function assignment is the lowest priority.

  • Custom User Avatar

    Not a problem, I'm glad I could help :D

  • Custom User Avatar

    There's an issue with the Rust version of this kata. According to the problem description, "if you are given an array with multiple answers, return the lowest correct index".
    This is not true in the Rust translation. Here is an example where it breaks:

    [5789, 7078, 659, -8368, -1095, 360, 5335, 4182, 8784, 3830, 2452, -4398, 4410, 4608, -7401, 3961, -7297, -5611, 7955, 9161, 1562, 1952, 9472, -1753, 5727, -8722, -8811, -9806, -9466, -3573, 6676, 7551, -2884, -7086, 8519, 9270, -2223, -5293, 8054, -4715, 85, -4782, 1494, 831, -2437, -2135, -6001, 3968, 9474, 6190, 7201, -6982, -1150, 469, 1806, 1725, -7172, 5396, 238, -7497, 5832, -1861, -5153, -7039, 2128, 2939, -1313, 3239, -9301, 1996, 5304, -9884, -138, -1445, -6853, 8668, 3299, 1154, -2733, 2285, -3715, 5695, -9500, 3303, -2737, -8601, -5807, -984, 8727, -8406, 7191, 3376, -1435, -2765, -5389, 3566, 3852, 4488, 6611, -4183, 4237, -8503, -4649, 4124, -7322, -1897, 793, -1746, 1349, -4642, 708, -5744, 7057, 7476, 7184, -8886, -6100, -4159, -9482, 1360, 8613, 7757, 5915, -2201, -694, 9151, -54, -6794, 1895, -1122, -4630, 798, -7008, -8878, -9491, -5909, 7831, -9401, 3313, 1427, -8889, 6521, -4197, -8411, -2145, -6102, -2512, -9066, -9214, -8084, 2972, -5576, -5121, -4287, -7635, -4836, 6, 790, -1418, 5979, -922, 7362, -2533, -3569, -4611, 438, -1707, 4295, -2770, -2566, 8889, -4414, -170, 589, -5493, -6894, 2989, 2506, 6505, 1112, -2640, -4028, -3474, -4150, 432, 5009, -5154, 3296, -2099, 6939, -7892, -6705, 2397, -1236, -7946, 8157, -9251, -8327, 4076, 4189, -2035, -2599, 5079, -6689, 4122, -4986, 2211, -6599, -4882, 3159, -6876, 1198, -5061, 6341, 19, 7800, 4074, -3371, -1198, 9149, 9930, -155, 7428, -8635, -8210, -7346, -8099, 4497, -9643, -7382, -9787, 7954, -761, -9015, -9516, -7925, 1910, -843, -72390]
    

    This random test expected an answer of Some(202) which IS a valid answer, but my code returned Some(199), which is ALSO a valid answer and has the lower index.

    This happens when the kata tries to generate a random test with a guaranteed answer but doesn't check that its answer is the lowest valid answer, instead just assuming it's the only answer. This is easy to fix -- just replace dotest(&arr, Some(i)) with dotest(&arr, reference_solution(&arr)) (and probably do a slight refactor to get rid of the extraneous else block). I have a proposed fix here: https://www.codewars.com/kumite/649c7f7f0b00c8003ea81022?sel=649c7f7f0b00c8003ea81022

  • Custom User Avatar

    Fixes a bug where the random test will sometimes have the incorrect expected response. The test where it inserts values to create a guaranteed midpoint does not check that it's the earliest midpoint possible.

  • Custom User Avatar

    It seemed to me after a bit of looking at the documentation that Arrays.stream(a) will return an IntStream of an array of ints, and that IntStream.of(a) doesn't support returning an IntStream from an array, but instead a list of parameters that you give it. Unless I'm misunderstanding the ellipsis in the documentation.

    Arrays.stream(int[] array): https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#stream-int:A-

    IntStream.of(int... values):https://docs.oracle.com/javase/8/docs/api/java/util/stream/IntStream.html#of-int...-

    Looking at the solution now, I think that I am misunderstanding it. There doesn't seem to be anything there that says it works with an array of ints. My guess is no, it doesn't matter, unless it's something really finicky with how Java compiles.

  • Loading more items...