Ad
  • Custom User Avatar

    Hi, so my code has passed 5 tests, and is failing in 'Rotor malfunction' saying that the string is out of index but I don't know how since I put a conditional to avoid that. I can't try that test since it doesn't mentions the rotors, can someone help me with this? Like, I'm trying to see what I can fix but it doesn't gives me very much information

  • Custom User Avatar

    Hi all. Are the tests for the Python version working correctly? I've finished my solution, and it passed the first tests, but when I attempt, most of the tests failed, and when I checked them it didn't made any sense to me. For example, one of the test says the following:
    "-----magic_music_box(['CREDIBLE', 'DREAMER', 'JOURNEY', 'CONSISTENT']): ['CREDIBLE', 'CONSISTENT', 'DREAMER'] should equal [] ".
    In the list of words to evaluate, comes 4 words, and my solution returns 'CREDIBLE', 'CONSISTENT', 'DREAMER', and according to the test it should return an empty array.
    I've checked the instructions several times, and I don't find any sense to this, the word 'CREDIBLE' contains 'RE', the word 'CONSISTENT' contains 'SI', and 'DREAMER' contains 'RE' again but in a different word so it's valid according to the instructions. Why does the test says it should return an empty array? am I missing something? And this happens in a lot of the tests, only 9 passed and 241 failed, but as I mentioned before, I've quickly checked some of them and they don't do sense to me. Please help me

  • Custom User Avatar

    Same here, I took my notebook and wrote the numbers, the fractions, tried to find a pattern but nothing. I'm not quite following the explanation, this is a problem that most likely would be solved in lets say 10-15 lines maybe, but man I can't even find the logic. If someone can explain it I would appreciate it a lot.

  • Custom User Avatar

    I know that the input is set only to str and int, therefore the '!=' will do fine here. But, I think that for scalability reasons it would be better to do the comparison strictly with ints, e.g. 'if type(x) == int: ... ' this way if for some reason in the future the list contains other things like booleans, dicts, tuples, or an inside list, it will still work. Great solution btw, it was my first thought also!

  • Custom User Avatar

    You can search for 'Inline IF statement' or list comprehension. Basically when creating a variable you can put in that same line an IF logic to see what you will assign. For example "Size = 'small' if x < 10 else 'large'" Here depending on x the variable will be 'small' or 'large' in one line instead of having 4 lines.

  • Custom User Avatar

    men... first I wrote a working code of like 40 lines, then I managed to reduce it by half, and it turns out I only needed 3 lines... thanks for opening my eyes

  • Custom User Avatar

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