6 kyu

Magnitude

9 of 347g964
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • HaoticEvil Avatar

    Nice kata. Not actually hard, but very interesting:)

  • vmbot Avatar

    Ouch that was fun, but I'd be totally lost if I couldn't do return inputVar or the prints to console lol. I badly overestimate my algorithm skills.

  • akar-0 Avatar

    I think there's still an issue in Python, how should we handle that input: ['polar', 39, 39, 36, 26, 18, 15, 29, 27, 33, 39, 39, 18, 16, 47, 24, 47, 27] ? Texts expect correct, however it contains an odd number of integers, and description does not say how we are supposed to form complex numbers in those conditions (and I can't figure out of the expected result is calculated, through my code gives correct answers when number of integers is even). Edit: Well, actually I got it: one must add to the sum the square of the remaining integer. However for me this is out of the description.

    • g964 Avatar

      Until now nobody complained:-) If there is an odd numbers of integers, consider that the last one z is z = a = a+O*i or z = r = (r, 0) = r(cos0+isin0), no?

    • akar-0 Avatar

      I think this should be at least stated in the description (or, at least, there should be an example of this type in the basic tests; it seems those minoritary unexpected cases are juste like traps added to make codes fail artificially). Missing data is not obviously 0, it is missing data. Maybe I'm psychorigid, do what you think is right :)

    • natan Avatar

      Lists in cartesian or polar form will always contain at least three elements and an even number of complex numbers.

      seems to contradict

      '(cart 1 2 3 4 5 6) or ['cart', 1, 2, 3, 4, 5, 6]includes the three complex numbers 1+2i, 3+4i, 5+6i

      which has three complex numbers which is not even

      but it probably wants to say that there will always an odd number of elements, so there is either a contradiction or a typo'd and false promise

      there's also 'polara in there, so there are three tags in total

      aside from that I don't like the language specific bits (very noisy) but whatever.

      edit: it's also leaking what is presumably an idiom in lisp, into other languages. too late to do anything about that, obviously.

    • g964 Avatar

      I simplified the description and changed the Python random tests so the input length is always odd (tag included). If you agree (no, I don't think you are psychorigid:-) I will change the tests in other languages.

    • akar-0 Avatar

      It's ok for me, thanks ;)

      Issue marked resolved by akar-0 4 years ago
  • imjasonmiller Avatar

    I've forked the Rust translation in order to update it to Rust 1.49 and updated rand::Rng::gen_range to its new signature that takes a std::ops::Range.

  • krishp Avatar

    Shouldn't the length of the array always be odd? In my code, if I take out the snippet that says: if len(arr) % 2 != 1: return (False,-1,1)

    I get a list index out of range error. I am also failing all the test cases that do not meet this criteria for some reason.

    • g964 Avatar

      Python? Fixed. I tried your solution (which is rather long:-), submitted it by error (!) and it passes.

      Issue marked resolved by g964 6 years ago
  • krishp Avatar

    Hey there, I am not quite understanding how the 52 is being calculated. Can someone explain that to me? sqr_modulus(['cart', 3, 4]) -> (True , 25, 52)

  • Unnamed Avatar

    Heterogeneous lists of objects in a statically typed language (List<object>), input checking, valid input still is a heterogeneous list, randomly mixed tasks (complex numbers and sorting digits, rly?), returning a tuple as a List, dependent values in the result (False => -1, 1), magic number (-1), probably done previously in other katas. The only thing left is to add "warning: don't do this in production" to the description...

  • Blind4Basics Avatar

    Hi,

    What's the point of the third output? Maybe you could remove that part? (I don't see the point of it, in the current context)

    • g964 Avatar

      See above:-)

    • Blind4Basics Avatar

      well, maybe that's not a good idea, don't you think? :/

      Question marked resolved by Blind4Basics 6 years ago
    • g964 Avatar

      My aim in this kata was to show in two small exercises how to:

      • validate an input of elements of different types
      • do some work in a list or an array ("complex numbers" is only a pretext)

      These two tasks were not enough hence the last: manipulate digits of an integer. Of course it's not for super power users:-)

  • Ranald Avatar

    Interesting like all your katas that I have tried, g964. In my opinion (for what it is worth), it is a good programming exercise. Aesthetically, it is regrettable that the "third part" - greatest number - has little connection to complex numbers, but I can see why it is there. Would it be appropriate to hint, in the description, that Racket 'match' might be useful?