Ad
  • Default User Avatar
  • Default User Avatar

    Loved this one.

  • Default User Avatar

    Worst kata I've seen in my whole life.

  • Default User Avatar

    Yes. Copying the input instead fixed it. Never had this problem before so I had no idea it was even a thing. I've noticed some Katas mention mutating inputs in their description, but never actually knew why. Thanks!

  • Default User Avatar

    C# - Clearly something going on with random tests. Logged input and output and this is what I got:

    Input:
    4500, 733, 4976, 9018, 8542, 4520, 9616, 5532, 4302, 6802, 1606, 1265, 9465, 2552, 7297, 2718, 2495, 2752, 3031, 9920, 6172, 5303, 385, 1202, 9738, 2355, 8739, 6243, 1340, 8043, 8160, 9237, 5294, 4386, 9016, 7802, 9730, 3961, 932, 4706, 5700, 2688, 629, 8813, 7524, 1255, 8957, 7794, 6844, 1672, 1215, 7540, 8370, 5425, 2237, 9196, 353, 3780, 9280, 6192, 5781, 3378, 4198, 6258, 8641, 2369, 5971, 5084, 3536, 9495, 2988, 8533, 1826, 8325, 4226, 3490, 4680, 1572, 3677, 8488, 3398, 951, 9399, 9667, 6833, 625, 872, 9868, 2155, 9819, 7455, 5955, 4681, 4739, 8925, 2327, 8489, 4370, 177, 5161, 5284, 3878, 4263, 7349, 8683, 2682, 5720, 51, 1204, 8747, 4521, 8781, 108, 797, 2800, 4835, 3979, 4530, 9425, 8022, 1502, 6102, 2935, 3716, 2045, 7032, 3857, 7087, 1905, 5000, 316, 1400, 8516, 3210, 9520, 6687, 2055, 990, 4156, 4905, 826, 8670, 3408, 8673, 5853, 3890, 1944, 4096, 8347, 3964, 4945, 3664, 9181, 948, 552, 5309, 1656, 8824, 8632, 652, 9299, 3752, 4211, 7386, 1591, 7586, 3280, 8147, 1929, 3546, 5274, 3123, 681, 7432, 9526, 8412, 3372, 1185, 9967, 5148

    Output:
    9967, 51, 9920, 108, 9868, 177, 9819, 316, 9738, 353, 9730, 385, 9667, 552, 9616, 625, 9526, 629, 9520, 652, 9495, 681, 9465, 733, 9425, 797, 9399, 826, 9299, 872, 9280, 932, 9237, 948, 9196, 951, 9181, 990, 9018, 1185, 9016, 1202, 8957, 1204, 8925, 1215, 8824, 1255, 8813, 1265, 8781, 1340, 8747, 1400, 8739, 1502, 8683, 1572, 8673, 1591, 8670, 1606, 8641, 1656, 8632, 1672, 8542, 1826, 8533, 1905, 8516, 1929, 8489, 1944, 8488, 2045, 8412, 2055, 8370, 2155, 8347, 2237, 8325, 2327, 8160, 2355, 8147, 2369, 8043, 2495, 8022, 2552, 7802, 2682, 7794, 2688, 7586, 2718, 7540, 2752, 7524, 2800, 7455, 2935, 7432, 2988, 7386, 3031, 7349, 3123, 7297, 3210, 7087, 3280, 7032, 3372, 6844, 3378, 6833, 3398, 6802, 3408, 6687, 3490, 6258, 3536, 6243, 3546, 6192, 3664, 6172, 3677, 6102, 3716, 5971, 3752, 5955, 3780, 5853, 3857, 5781, 3878, 5720, 3890, 5700, 3961, 5532, 3964, 5425, 3979, 5309, 4096, 5303, 4156, 5294, 4198, 5284, 4211, 5274, 4226, 5161, 4263, 5148, 4302, 5084, 4370, 5000, 4386, 4976, 4500, 4945, 4520, 4905, 4521, 4835, 4530, 4739, 4680, 4706, 4681

    Test Failed
    Expected is <System.Collections.Generic.List1[System.Int32]> with 0 elements, actual is <System.Collections.Generic.List1[System.Int32]> with 180 elements
    Values differ at index [0]
    Extra: < 9967, 51, 9920... >

    Here's from another run:

    Input:
    6868, 9021, 9720, 5672, 453, 9297, 4984, 8283, 7854, 1996, 4810, 3808, 1036, 2525, 754, 954, 9980, 9765, 1142, 7592, 2801, 9072, 1476, 1608, 566, 3553, 8919, 5430, 7829, 1537, 1930, 8905, 2368, 7596, 504, 3427, 2058, 867, 1216, 110, 9336, 2438, 6224, 4730, 3405, 3154, 1217, 5266, 9963, 3463, 4663, 4818, 9328, 4734, 7795, 7550, 8117, 5112, 6899, 383, 9553, 459, 6323, 72, 5904, 1446, 3439, 2027, 7327, 2671, 7927, 8904, 9926, 7487, 3465, 6639, 5252, 6878, 7160, 404, 7708, 170, 7866, 8073, 7266, 4093, 3039, 2867, 2708, 5877, 171, 6945, 3967, 838, 556, 8882, 6114, 6158, 8825, 1965, 9715, 9190, 7939, 7298, 5535, 5759, 4891, 1847, 1275, 1162, 2304, 1245, 7952, 6501, 2675, 9389, 2592, 8250, 2805, 1817, 8406, 577, 9318, 1456, 2505, 988, 4942, 9093, 6936, 4582, 530, 8052, 5200, 688, 8517, 2230, 574, 2543, 1513, 9201, 1198, 1598, 1552, 3578, 8926, 8992, 7465, 8162, 1167, 6295, 7864, 3359, 7013, 3559, 9143, 9871, 6489, 4798, 4553, 822, 5798, 4910, 6692, 637, 3210, 3192, 2757, 5818, 4158, 7165, 2023, 5712, 1298

    Input Count: 173

    Output:
    9980, 72, 9963, 110, 9926, 170, 9871, 171, 9765, 383, 9720, 404, 9715, 453, 9553, 459, 9389, 504, 9336, 530, 9328, 556, 9318, 566, 9297, 574, 9201, 577, 9190, 637, 9143, 688, 9093, 754, 9072, 822, 9021, 838, 8992, 867, 8926, 954, 8919, 988, 8905, 1036, 8904, 1142, 8882, 1162, 8825, 1167, 8517, 1198, 8406, 1216, 8283, 1217, 8250, 1245, 8162, 1275, 8117, 1298, 8073, 1446, 8052, 1456, 7952, 1476, 7939, 1513, 7927, 1537, 7866, 1552, 7864, 1598, 7854, 1608, 7829, 1817, 7795, 1847, 7708, 1930, 7596, 1965, 7592, 1996, 7550, 2023, 7487, 2027, 7465, 2058, 7327, 2230, 7298, 2304, 7266, 2368, 7165, 2438, 7160, 2505, 7013, 2525, 6945, 2543, 6936, 2592, 6899, 2671, 6878, 2675, 6868, 2708, 6692, 2757, 6639, 2801, 6501, 2805, 6489, 2867, 6323, 3039, 6295, 3154, 6224, 3192, 6158, 3210, 6114, 3359, 5904, 3405, 5877, 3427, 5818, 3439, 5798, 3463, 5759, 3465, 5712, 3553, 5672, 3559, 5535, 3578, 5430, 3808, 5266, 3967, 5252, 4093, 5200, 4158, 5112, 4553, 4984, 4582, 4942, 4663, 4910, 4730, 4891, 4734, 4818, 4798, 4810

    Output Count: 173

    Test Failed
    Expected is <System.Collections.Generic.List1[System.Int32]> with 1 elements, actual is <System.Collections.Generic.List1[System.Int32]> with 173 elements
    Values differ at index [0]
    Expected: 4810
    But was: 9980

    Sample tests look like this and is working fine:

    Input: 15, 11, 10, 7, 12

    Output: 15, 7, 12, 10, 11

    Input: 91, 75, 86, 14, 82

    Output: 91, 14, 86, 75, 82

    Input: 84, 79, 76, 61, 78

    Output: 84, 61, 79, 76, 78

    Input: 52, 77, 72, 44, 74, 76, 40

    Output: 77, 40, 76, 44, 74, 52, 72

    Input: 1, 6, 9, 4, 3, 7, 8, 2

    Output: 9, 1, 8, 2, 7, 3, 6, 4

    Input: 78, 79, 52, 87, 16, 74, 31, 63, 80

    Output: 87, 16, 80, 31, 79, 52, 78, 63, 74

    So what's up?

  • Default User Avatar

    Is this even possible using C#?

  • Default User Avatar

    Wow. After completing this and seeing the other solutions I can confidently say that I was overthinking this one. It was fun tho. Great kata!

  • Default User Avatar

    I don't remember what was going on, but I finished it right after posting this :P

    Edit: I still don't understand how 10 is a peak in that random test. Didn't touch the input at all, only read values.

  • Default User Avatar

    Random Test in C#

    Testing for 7, 2, 12, 11, 16, 3, 14, 10, -2, 2, 14, 14, -4, -2, 13, 1, -2:
    Values differ at index [3]
    Expected: 10
    But was: 14

    Here's my printed lists:
    pos: 2, 4, 6
    peaks: 12, 16, 14

    How is 10 a peak, but 14 isn't?

  • Default User Avatar

    Came back to this one after a month.
    Tried to print the inputs this time and this is what I've got:

    // This is what it looks like for every test except random
    Number: 1
    Array: -32
    Array: 12
    Array: 8
    Array: -10
    Array: -2
    Array: 4

    It prints the target number and the numbers in the array. As expected.

    // This is for the random test
    Number: -862
    Number: -862
    Array: -862

    Seems like it's giving two target numbers and an array containing only one number.

  • Default User Avatar

    This one was fun. Thanks for the kata :)

  • Default User Avatar

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

  • Default User Avatar

    Didn't expect to see Buckethead here :)

  • Default User Avatar

    Apparently C# doesn't support Tail Recursion. Only workaround I found was this thing called Trampolining, which effectively is a loop.
    I don't think this can be solved using recursion (I think it times out due to huge stacks) in C#, which kinda defeats the purpose of this kata.

    If someone knows a way to do this using recursion in C#, could you please point me in the right direction?
    Thanks.

  • Default User Avatar

    Aha

  • Loading more items...