Ad
  • Custom User Avatar

    This solution is missing the 5th traversal as brendanvos already pointed out. Otherwise, if you would scale up this task to numbers bigger than 13, e.g. equal_to_24(55, 26, 30, 5) would say impossible, however 26-((55+5)/30) = 24.

    For anyone wondering, you would need to add

    elif round(z(c, x(y(d, b), a)), 5) == 24:
        return f"{c} {op[z]} (({d} {op[y]} {b}) {op[x]} {a})"
    

    to the solve24 function.

  • Custom User Avatar

    It is necessary, for example equal_to_24(55, 26, 30, 5) would give with his solution a "It's not possible!", however 26-((55+5)/30) = 24.

  • Custom User Avatar

    Can someone explain to me why the 5th traversal isn't necessary here?
    It would look like x(a,y(z(c,d),b))

  • Custom User Avatar

    Hi Chrono - thank you very much. I understood the problem and you are right. appreciate your help.

  • Custom User Avatar

    Well, the error you see is because you're returning a single number instead of 4 when there is a possible solution.

    this one can return 53 - (28 + (21 / 21)), your answer is: 24

    You should return '53 - (28 + (21 / 21))', not '24'

  • Custom User Avatar

    Hi Chrono - thanks for the reply. sorry for posting multiple - it was not showing me when i first posted and i re-posted. i will make sure i dont do that.
    Below is my calling code to solve the problem:
    def equal_to_24(a,b,c,d):
    print(f"input is {a},{b},{c},{d}")
    if call24(a,b,c,d) is True:
    return '24'
    else:
    return "It's not possible!"

    i am printing the input and i see input displayed for all cases until the last step where it throws STDERR. I am showing last 2 cases output along with error at the end. hope this helps.

    Test Passed
    Log
    input is 4,3,1,6
    this one can return 6/(1-(3/4)), your answer is: 24
    input is 4,3,1,6
    Test Passed
    Log
    input is 1,1,1,1
    Test Passed
    Log
    input is 13,13,13,13
    Test Passed
    Log

    --------20 Random Test--------

    input is 21,28,21,53

    Test for: a=21,b=28,c=21,d=53 Example solution: "53-(28+(21/21))"
    STDERR
    Traceback (most recent call last):
    File "main.py", line 83, in
    A,B,C,D = filter(lambda x: len(x), re.split("[^\d.]+", useran))
    ValueError: not enough values to unpack (expected 4, got 1)

    I tested just for the last random case alone and i see its working
    Log
    input is 21,28,21,53
    this one can return 53 - (28 + (21 / 21)), your answer is: 24
    input is 21,28,21,53
    Test Passed

  • Custom User Avatar

    Print the input so we can check if it is a kata problem, and please, don't open multiple post about the same. Read this too.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Can you fix this issue. All cases are passed but i see this STDERR while running random test cases.

    Traceback (most recent call last):
    File "main.py", line 83, in
    A,B,C,D = filter(lambda x: len(x), re.split("[^\d.]+", useran))
    ValueError: not enough values to unpack (expected 4, got 1)

  • Custom User Avatar

    to the author. can i get some help. i am getting issue with running random test case. all cases are fine but i see this error.

    Traceback (most recent call last):
    File "main.py", line 83, in
    A,B,C,D = filter(lambda x: len(x), re.split("[^\d.]+", useran))
    ValueError: not enough values to unpack (expected 4, got 1)

  • Custom User Avatar

    i am getting issue with running random test case. all cases are fine but i see this error

    Traceback (most recent call last):
    File "main.py", line 83, in
    A,B,C,D = filter(lambda x: len(x), re.split("[^\d.]+", useran))
    ValueError: not enough values to unpack (expected 4, got 1)

  • Custom User Avatar

    spent a lot of time on this. then realized my mistake . if this helps others -
    dont try to add number and reversenumber in the same iteration to the list or set.
    and no need to construct full set of size 65.

  • Custom User Avatar

    Actually I just re-checked the wiki, it seems that the katas do give you a set amount of score (which you can see at the bottom of the page I linked above) based on the kata difficulty "as well as an internal score that counts toward your next rank" (this part I don't really get), my bad/

  • Custom User Avatar

    Thanks Nekai. that helps.

  • Loading more items...