Ad
  • Custom User Avatar

    Hi! have the same problem. Got this on calculation First\Last Decile: i got First Decile = -74.4682544, should equal = -74.4682543999999, and Last = 587.1, should equal = 587.1000000000001.

    Maybe i dont understand but difference between mine and expected value less then 10**-10:

    abs(-74.4682544-(-74.4682543999999)) -> 9.947598300641403e-14 < 10**-10; 
    abs(587.1 - 587.1000000000001) -> 1.1368683772161603e-13 < 10**-10
    

    do you submit this kata?

  • Custom User Avatar

    Great kata, thanks.

  • Custom User Avatar

    1)Noone will anser me but i dont understand why when i test in jupyter lab StatisticalSummary(data).boxplot() with data = list(range(1, 33)) + list(range(12, 21)) + list(range(12, 21)) + list(range(12, 21)) + [16] + ['a']
    i got [('Sample', 12.75, 16.0, 20.0)] (the same as in the "Worked example # => [("Sample", 12.75, 16, 20)]")
    but when copy-pass to test here i got ('Sample', None) Σ(っ °Д °;)っ

    UPD: problem was in plot=BOXPLOT, in cata its defined not as string as i do - so its work now but with errors in calculation

    2)and also why in "Worked example":
    d1 = range(1, 33) + range(12, 21) + range(12, 21) + range(12, 21) + [16]
    d2 = [d - 2 for d in d1[:len(data)//2]] + [d + 2 for d in d1[len(data)//2:]] #we call for var "data" but not define it (or i think we use previously defined "data" in 1st example ???

    data = [("A", n) for n in d1] + [("B", n) for n in d2]
    i expect "data" to be smt like this: [(A, 1),(A, 2), (A, 3)...(B, 1), (B,2)...] but not this:
    Data: [('A', [1, 2, ...), , ('B', [-1, 0, 1,] (got it from incorrect tests) (╬▔皿▔)╯

    So ... i thinks there is some confusing examples or i just dont understend smt(((
    UPD1: not just Lower\Upper Outlier boundary but !!Smallest value!!

  • Custom User Avatar

    This Enigma machine is a real nightmare! :-D

    Here is my thoughts to understand how the reflector works, especially when changing the start position.

    Easy part : the initial mapping, with string given as

    STR = A Y B R C U D H E Q F S G L I P J X K N M O T Z V W

    this gives the following input/output pairs:

    IN = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    OUT = Y R U H Q S L D Q X N G O K M I E B F Z C W V J A T

    In start position A, A is wired to Y, B is wired to R and so on... Now in start position N, what happens?
    Whole input alphabet is shifted so that A becomes N. First I would think "N is wired to Y", "O is wired to R"... following this logic, "well, easy, just shift by 13..."
    spoler: that does not work at all:

    IN = N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
    OUT = Y R U H Q S L D Q X N G O K M I E B F Z C W V J A T

    the 4 first columns are good, we are safe. N>Y, O>R, P>U, Q>H ... but R>Q is not good, and the whole logic of "pairs of letters" blows out.

    Other way of thinking (and IMHO this is the good one): it's the "length" of the wire which remains the same when shifting. Left part of image found in https://brej.org/enigma/Image10.gif made me realize this... The reflector wiring has to be seen as a kind of "comb", meaning the "distance between wire input and output" remains the same.
    "Wire length" from A to Y (first pair) is 24 ; A (letter 1 of alphabet) + 24 = letter 25 in alphabet = Y)

    Hence...

    INPUT = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    OUTPUT = Y R U H Q S L D Q X N G O K M I E B F Z C W V J A T
    LENGTH =24 16 18 04 12 13 05 04 07 14 03 05 02 03 02 07 12 16 13 06 18 01 01 14 24 06

    Length is computed as "input + Length = output" in terms of letters (A + 24 letters = Y)

    Then if the input is shifted by 1, the output changes based on the same difference in letters from input to output.

    INPUT = B C D E F G H I J K L M N O P Q R S T U V W X Y Z A
    OUTPUT = Z S V I R T M E Q Y O H P L N J F C G A D X W K B U
    LENGTH =24 16 18 04 12 13 05 04 07 14 03 05 02 03 02 07 12 16 13 06 18 01 01 14 24 06

    Pairs still are pairs (A<=>U, B<=>Z, C<=>S and so on...)

    if the shift is 13 (A to N) as in the example:

    INPUT = N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
    OUTPUT = L E H U D F Y Q C K A T B X Z V R O S M P J I W N G
    LENGTH =24 16 18 04 12 13 05 04 07 14 03 05 02 03 02 07 12 16 13 06 18 01 01 14 24 06

    Pairs still are pairs (A<=>X, B<=>Z, C<=>V and so on...)

    That should help those who did not know how the reflector worked (as I do/did!)

  • Custom User Avatar

    Two information which may help other codewarriors, which are missing (or I could not deduce it from the kata details) from the details of this kata (for those who, like me, did not know how the Enigma machine works):

    1- The "Dot" letter has an influence on the notch. As a matter of fact, the dot letter leads to an offset between the notch and the visible position in the window.
    Example:
    If notch is "Q" and dot letter is "A", then the notch causes rotation when "Q" is displayed in the window. No change, Dot is in initial position.

    If notch is "Q" and dot letter is "Z", then the notch causes rotation when "P" is displayed in the window, because Z has an offset of 25 towards A (0 position) => Q + offset of 25 gives "P".

    If notch is "Q" and dot letter is "M", then the notch causes rotation when "C" is displayed in the window, because M has an offset of 12 towards A (0 position) => Q + offset of 12 gives "C".

    2- When kata says "While in the actual usage of the original Enigma Machine, punctuation was encoded as words transmitted in the stream, in your code any input character that is not in the range A-Z should be returned unchanged and should not affect the internal state of the machine.", the "A-Z" is to be case-sensitive understood.

    That is "A-Z" will be ciphered and crypted, punctuation will leaves the machine status as is (no rotation, no ciphering) ... but range "a-z" will ALSO remains untouched.

  • Custom User Avatar

    Hi! Really helpfull, thank you!

    Another piece of information which was missing (or I could not deduce it from the kata details): the "Dot" letter has an influence on the notch. As a matter of fact, the dot letter leads to an offset between the notch and the visible position in the window.

    If notch is "Q" and dot letter is "A", then the notch causes rotation when "Q" is diplayed in the window.
    If notch is "Q" and dot letter is "Z", then the notch causes rotation when "P" is diplayed in the window, because Z has an offset of 25 towards A (0 position) => Q + offset of 25 gives "P".
    If notch is "Q" and dot letter is "M", then the notch causes rotation when "C" is diplayed in the window, because N has an offset of 12 towards A (0 position) => Q + offset of 12 gives "C"

  • Custom User Avatar

    Great kata to understand some reverse engineering with object oriented programming, thanks.

  • Custom User Avatar

    missing useful imports.

    import codewars_test as test
    from solution import how_many_moves
    
  • Custom User Avatar

    wrong in this case. all elements are identical except one. there aren't a lot of swaps going on. what are you talking about.

  • Custom User Avatar

    @MMMAAANNN's comment was VERY helpful!

    but why is part #1 available in 100 languages, and part 2 / 3 / 4 available in Python only? :-(

    I cannot check my solution in C# for this part #2.

  • Custom User Avatar

    What does the n != do

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks for the suggestion. The current rank will stay.

  • Custom User Avatar

    all languages edited

  • Custom User Avatar

    5q so high for this kata, i think 6q should be correct

  • Loading more items...