5 kyu

Joyful Transpiler

Description
Loading description...
Puzzles
Restricted
  • Please sign in or sign up to leave a comment.
  • el-f Avatar

    if you think you are cheating, you are not.

    my solution begs to differ ;)

  • LanXnHn Avatar

    My 9 characters solution time out, too lazy to work out another approach...

  • Voile Avatar

    This comment has been hidden.

  • mauro-1 Avatar

    I have a "solution" with 12 unique chars, but 10???

    • Kacarott Avatar

      I was stuck at 11 for a while. I think theres really only one approach that is small enough. It might be worth making the bounds ever so slightly larger?

    • potzko Avatar

      I tried to find more solutions and found a few more in the counts of 11,12 and 13, I increased the char limitation to thirteen to allow for them as well

  • Kacarott Avatar

    I've finally got a working solution that I'll submit once its out of draft again, but the nature of the kata made it a real pain to debug some of the tests. I strongly suggest that on a failed test, the input should be printed for user convenience.

    • potzko Avatar

      I can add it but im cuirius as to why not just print from within the function for debug purpose?

    • Kacarott Avatar

      Well because my function is a big jumbled esoteric mess because it needs to have at most 10 chars. So adding a print means adding it in my original code elsewhere, recompiling, recopying it over, then wait for tests to run again.

    • potzko Avatar

      ah good point, ill add it and republish after voile clarifies what they meant in their comment

      Suggestion marked resolved by potzko 2 years ago
  • Kacarott Avatar

    your code should contain no more then 10 unique characters

    Yet in the full tests I am getting errors that "this code had 10 unique chars in it"

    • potzko Avatar

      when I rewrote the count chars function I accidentally removed one finger, oops, solved

      Issue marked resolved by potzko 2 years ago
  • Voile Avatar

    At least in sample tests: Tests run the transpiled code returned by user function with something like exec(a:=joy(code1), names), which is an incorrect usage: Variables in Python are defined and looked up at local scope, not global scope, unless nonlocal or global keywords are used.

    • potzko Avatar

      im unsure what you mean here, mind elaborating? the way I read it is:
      exec(a:=joy(code1), names)
      so, a = the code I got from the function as a string
      and names is the "global scope" of the function I run after it is finished
      so if the code is 'q = 5' or an equivilant code, then names['q'] == 5 is True

    • potzko Avatar
      Issue marked resolved by potzko 2 years ago
  • Blind4Basics Avatar

    separated of the below problem:

    please reduce the noise in the sample tests:

    def count_chars(text):
        if (a := len({i for i in text})) > 10:
            test.fail(f'does not spark joy\nthis code had {a} uniqe chars in it')
            return False
        test.assert_equals(True,True)
        return True
    
    • the returned value is never used in the sample tests => remove the return statements
    • why the 2 separated assertions!??
    • just store the length and assert using test.expect (with the appropriate error message)
    • typo: uniqe
    • len(set(text)) is more readable
  • Blind4Basics Avatar

    Hi,

    You need to give the actual specs of the inputs. With the current description, the task could go from 8 kyu to far beyond 1kyu.

    Cheers

    • Blind4Basics Avatar

      I have no idea what you're up to, but now that I see the sample tests, I'm not sure my issue is the right one... There is still an issue for sure, but I don't know exactly what it is yet. I guess the task isn't properly described/hinted.

    • dfhwze Avatar

      The "puzzle" tag is not enough to justify this lack of examples. If the sample tests give you more info about what to expect, I feel more examples should be given in the description. For now, it seems a simple 'eval' should do the trick..

    • Blind4Basics Avatar

      the sample tests rather lost me, actually. It's not about missing examples, it's more about the task is on a different level/of a different kind that what the description suggests at first sight.

    • potzko Avatar

      for this kata the only specs I need to give for the input is that it is valid python code, and that the length is reasonable, I estimated the difficulty at rank 3

      I know what im asking and why it looks hard/impossible however I stand by my estimate and I remind you that this is a puzzle

      I will add more examples

      Issue marked resolved by potzko 2 years ago
    • dfhwze Avatar

      So you are asking us to pass your specific test cases, not to have 'any' python code reduced to 10 (now 13) chars?

    • potzko Avatar

      no, your solution should be able to pass for any single string of python code, and in N iterations N strings of python code (maintain state) however I only have some test cases as testing all features of python would be unrealistic

    • dfhwze Avatar

      This comment has been hidden.

    • potzko Avatar

      yes, although not exactly everything is allowed, you are guaranteed the source code is valid