Ad
  • Custom User Avatar

    Exponentiation is right-associative.

    [4,3,6] == 4 ^ 3 ^ 6 == 4 ^ (3 ^ 6) == 4 ^ 729 == 7975054838978857957869783595079038148815929134873574372267239147002092943367488761318118323875971614518937350748146290561474995443284105875630084237401365691741820338695355818455664737390057540900825684807418526691288993393970109201605650784885019821709886980841347925777256289930194351608431522864880360956238794237301100891415162717067858756153598763756850431348717233286605102660510814000306243542621599170963477008725517984745855647744
    
  • Custom User Avatar

    I am sure this has probably been brought up before... but You CAN do the calculation with a calculator... it's not an unreasonably large number. The numerical value of this argument: ([4, 3, 6] comes out to 68719476736. That expected result should be 6. Why is this Kata's expected ouput wrong?
    " ([4, 3, 6], 4)) .

  • Custom User Avatar

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

  • Custom User Avatar

    Are these not nested lists?

    You're reading the code of tests wrong. What you see there is a list of test cases, where each test case is a tuple of (input_list, expected). If you read tests further, you see:

    for test_input, test_output in test_data:
        test.assert_equals(last_digit(test_input), test_output)
    

    You can see that the call looks like: last_digit(test_input), where test_input is a single, flat list. One list from the whole test set, one by one.

  • Custom User Avatar

    In the kata description it says this: E. g., with the input [3, 4, 2], your code should return 1 because 3 ^ (4 ^ 2) = 3 ^ 16 = 43046721.

    that looks like a list to me! It did not mention anything about arguments being in the form of both lists or lists within tuples ! why was this information left out?

  • Custom User Avatar

    The above picture you posted is not at all nested lists. More like tuples that have lists in them.

  • Custom User Avatar

    No matter what I do to handle this (I used a recursive function to "flatten" the list), but no matter waht I do, I cannot get ([0,0,0],0) to return the expected 0. It always returns a 1.

  • Custom User Avatar

    Are these not nested lists? The arements have arrays within the lists! lists within lists.

    test_data = [
            ([], 1),
            ([0, 0], 1),
            ([0, 0, 0], 0),
            ([1, 2], 1),
            ([3, 4, 5], 1),
            ([4, 3, 6], 4),
            ([7, 6, 21], 1),
            ([12, 30, 21], 6),
            ([2, 2, 2, 0], 4),
            ([937640, 767456, 981242], 0),
            ([123232, 694022, 140249], 6),
            ([499942, 898102, 846073], 6)
    
  • Custom User Avatar

    What do you mean, "arguments that hare nested lists"? There should be no nested lists anywhere. Why do you think that you are given nested lists as inputs?

  • Custom User Avatar

    My comment on this kata is that the description is a little mis-leading! Nowhere in the description does it mention that testing will include arguments that hare nested lists! Therefore my current solution gets errors. Does this solution require recursion?

  • Custom User Avatar

    See this fork with an explanation.

  • Custom User Avatar

    This brevity amazes me... it seems like the most efficient solution (though perhaps not as readable) but I do have one question that puzzles me. How does this regular expression determine if the length of s is even or odd? How does it know that it only needs to add a "_" character if the last pair character pairing in the string is solitary?