Beta

Chalkboard math mistake (simple version)

Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • Unnamed Avatar

    This solution failed at a random test with

    old: -6/9+-3=1/8/7/619/168
    new: -6+9+-3=1/8/7/619/168
    

    If precise calculations are required, there should be corresponding fixed tests.

    • davilla Avatar

      Interesting. The kata was originally written with precise calculations in mind, but I wonder if it would make more sense to just avoid testing cases like this.

  • Unnamed Avatar

    A fixed test with implicit multiplication of two parenthesized expressions should be added. Some of the published solutions don't handle this case correctly.

  • Awesome A.D. Avatar

    So, I'm sure you're supposed to come up with something super clever, but so far I'm bruteforcing it with a O(N) solution (strictly speaking O(9*N) in worst case). Surely this can't be intended? I'm solving the very large tests with this. Also, my dumb little bruteforce method came up with something interesting:

    In:  -86(6/-1/4-31)556/-13(2(-6×0×4×11)187)=25/-230--15(-(0/28/3×25/7))×-3/-32
    Out: -86(6/-1/4-31)556/-13(2(-6×0×4×11)187)=25//230--15(-(0/28/3×25/7))×-3/-32  # '-' -> '/'
                                                  ^
    

    I think according to your rules, this is not a valid solution (although mathematically correct: 0 = 0). In any case, I got an error Unable to parse result. Your parser doesn't like integer division? Is this intended?

    • davilla Avatar

      Interesting, yes. No, it doesn't like. That's not a basic operation. I've never seen it on a blackboard, is another way to say it.

      As to brute force, I'm OK with one kata to do that, but see below investigating other ideas.

    • Awesome A.D. Avatar

      Ok. I've modified solution to avoid // and **. I pass all tests, but when attempting to submit, it tells me There was an issue submitting your final solution. This is the first time I've encountered this error on CW, any hints what's going on?

      EDIT: Now the submit button is gone entirely and I'm stuck in an "attempt" loop.

      EDIT 2: Did some research, apparently you can't submit to a kata in draft status? But others did? I'm confused.

    • davilla Avatar

      I must have unpublished it while you were still working on it. I've published again if that helps, but I'll have to revise some of the descrpition.

    • davilla Avatar

      I didn't call these out explicitly, but in the description I've touched on other operations.

      Issue marked resolved by davilla 4 years ago
    • Awesome A.D. Avatar

      Thanks. That fixed it. Now give me back the hour I spent googling this issue! :) I rated this at 5 kyu simply because it's brute forcable. I'm sure if there were some safeguards in place to make bruteforce unviable that would raise this problem to at least a 3 kyu. I can't think of any unfortunately.

      By the way, feel free to mark this issue as resolved, as CW for some reason won't allow me to do it myself. Edit: Ok, that was because you marked it as resolved while I was still typing my comment. You have a terrible tendency to interrupt me during my work :) Like a real life race condition.

    • davilla Avatar

      Derp, sorry. I think I make too many edits. Commented below that I'm OK with brute force on this one. But that wasn't the goal, so when I iterate on the idea, that will be the first priority.

    • Awesome A.D. Avatar

      Sure, but keep in mind that anyone who solves this can see your solution that would potentially solve your more complex kata.

    • davilla Avatar

      But I can substitute a different solution, no? If anyone is bold enough to do so, I think it would be for the better.

    • mauro-1 Avatar

      EDIT 2: Did some research, apparently you can't submit to a kata in draft status?

      Yes, and half of kata in beta becomes draft (or retired) while I'm solving it. :(

      For example: Glider velocity:

      • attempt -> all tests passed -> green submit button
      • some minor edits (less than 10 seconds)
      • attempt -> all test passed but kata in draft and no submit
    • Kacarott Avatar

      To be fair I think that was one of the mods who reverted it back to draft, not davilla (could be wrong though)

    • hobovsky Avatar

      To be fair I think that was one of the mods who reverted it back to draft, not davilla (could be wrong though)

      It does not seem so, there's no related entry in mod audit logs.

    • Kacarott Avatar

      It was Blind4Basics. Based on what he said anyway its quite possible i misunderstood the context.

      ok... I unpublished it ,then, so you have time to get it right before the downvotes start to rain on it... ;o

      That was in the discourse of the kata

  • dolamroth Avatar

    The last sample test is broken (commented):

        incorrect = '-(-7×9+4×-491)-4+34-47--7×39=(3+10-4--17-44×3)×-38+-17+153-3+68-267-1845'
        # result = solution.fix_equation(incorrect)
        preloaded.validate(None, incorrect, hint=16)
    
  • Kacarott Avatar

    Submitted a solution. I assume that is not the intended method of solving. Feel free to break it, and i'll have a go at solving it for real.

    • dolamroth Avatar

      Lol, I solved it in almost the same way as you did.

    • davilla Avatar

      Wow no, I was trying to make it computationally complex, clearly not enough. And I thought the fractions would kill that approach, apparently not. But I'd be happy to leave this one be if you have a suggestion for a way to accomplish as much, for a new kata. Maybe just lift the restrictions on digits, and allow any integer to substitute for another?

    • Kacarott Avatar

      This comment has been hidden.

    • davilla Avatar

      I'm not keen on artificial restrictions. I was actually thinking of making a version that was solvable in that way. Little did I know...

    • dolamroth Avatar

      You may simply add floats as terms to your task.

    • davilla Avatar

      OK at some point I'll revisit this in a new kata. I've resolved to keep this one as is.

  • Kacarott Avatar
    AttributeError: module 'solution' has no attribute 'Expression'
    

    Got this in the random tests, is this my error?