6 kyu

Odder than the rest

139 of 315JohanWiltink
Description
Loading description...
Puzzles
Algorithms
Recursion
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    Puzzling to figure out and rewarding kata.

  • Mitsunee Avatar

    Literally cannot understand any sentence of this kata's description. Really wish this site was actually codewars and not puzzles for people who studied mathematics at university...

  • Ahmedrt6 Avatar

    Something doesn't look right with this kata
    I wish I can understand it 😂

  • saudiGuy Avatar
  • barrent Avatar

    That is a great kata!

  • JohanWiltink Avatar

    LC translation.

    Uses a custom numEncoding NegaBinaryScott, which uses base -2 but is otherwise equal to BinaryScott. All negative, zero and positive integral numbers can be encoded, and the encoding is unique if the invariant holds. There is no -0.

  • ah2023 Avatar

    This kata contains what we love:

    • recursion
    • a very special n
    • positive/negative asymmetry
    • TheChildOfProphecy Avatar

      can someone explein the description and what should i do at this Kata(What is the task) i dosent understand this description

    • Yushi.py Avatar

      Yeah, this sucks, I'm sorry.

      It's a really nice idea, but made extremelly annoying by the tests and unclear description.

      Now I may leave, knowing that this has added nothing to my knowledge and I'll never get back this time, thanks :).

    • edgardpetre Avatar

      This kata was extremely frustrating, but whith all its traps (including the somehow bad english), I think it is close to what you may encounter in your life as a programmer in a big company. So it the end of the day, t was a good experience.

    • zdreagin Avatar

      I found the description for this Kata to be a little tough to make sense of, and after reading the comments I see that I'm not alone. I have re-worded the description slightly so that (at least for me) it makes more sense. Whether or not the author decides to use my description, I hope that it will at least be helpful for others. I also hope that this does not come off as a harsh critique of the Kata, as it was enjoyable to solve. My suggested description is below.

      Integrals numbers (i.e. integers) can be even or odd.

      For a given number, n, even numbers satisfy the equation n = 2m, while odd numbers satisfy the equation n = 2m + 1, where m is also an integral number. Now, some odd numbers can be more odd than others. An odd number's oddness can be determined using the above definition recursively, where a number is more odd if m is also odd. Even numbers are, of course, the least odd.

      Task

      Given a finite list of integral (not necessarily positive) numbers, determine which number is odder than the rest. If there is no single such number, return Nothing, null or the appropriate empty value for the given language.

    • dfhwze Avatar

      After reading all comments and having solved this kata, I would have to agree with the kata author that ALL information required to solving this kata is in the first paragraph of the description.

      Even numbers satisfy n = 2m ( with m also integral ) and we will ( completely arbitrarily ) think of odd numbers as n = 2m + 1.
      Now, some odd numbers can be more odd than others: when for some n, m is more odd than for another's. Recursively. :]
      Even numbers are just not odd.
      
    • bouchert Avatar

      Codewars needs a better range of options than just Very, Somewhat, and None. At a minimum, the addition of "this is infinitely dissatisfying; the mere existence of this Kata has made my life worse".

    • akar-0 Avatar

      This comment has been hidden.

    • BRMonte Avatar

      The intro text is badly written and the premiss not clear.

    • user9396321 Avatar

      Look, I'm sorry, but this description's a mangled mess. I know you're trying to be clever but cleverness is the enemy of education.

    • RealKenshiro Avatar

      Great and original Puzzle Kata. Thanks @JohanWiltink!

    • JorgeVS Avatar

      Great kata. Listen to this while finding a solution.

      Real life coding challenges are defined whith less clear requirements most of the time.

      It is even possible to extend this by thinking that 18 is odder than 24.

    • Investrum Avatar

      Why 0 is odd?

    • etnl Avatar

      The description is hard to understand, am I missing something?

    • eb110 Avatar

      The kata has surprisingly low "joy" percentage - two hints - analyse "-1" very very deeply and why author of the kata mentioned about recursion.

    • nomennescio Avatar

      According to the Factor tests, a single 0 is expected to give 0 as the oddest number, whereas according to the definition, 0 is even, is not odd, so certainly cannot be odder than the rest, as only odd numbers can be odder. In my opinion therefore 'null/Nothing/false' should be the expected answer, not 0.

    • nomennescio Avatar

      Your description really doesn't make sense:

      Suppose we have two odd numbers, n1 and n2, such that n1=2m1+1 and n2=2m2+1. So far so good. When exactly is one "more odd" than the other?

      "Now, some odd numbers can be more odd than others: when for some n, m is more odd than for another's"

      Mathematically speaking, if you say "for some n", you fix n. If you have two numbers, n is not fixed, but different. The sentence therefore doesn't make any sense. What's left is to try to infer what exactly is meant by looking at some examples. Unfortunately, in the language of my choice I only see very little examples.

      If you want to improve the description, at least write it down mathematically sound.

    • G_kuldeep Avatar

      Super fun..gem of kata :)

    • Konstantin Modin Avatar

      Well, it is pretty clear what happens with positive integers, but when it comes with negative .... -1 is more odder then -31. Why? I we count to 0, -31 has 5 "points" and -1 has 1 "point".

      -97 is more odder then 71. why? -97 has 1 "point", and 71 has 3 "points".

      So we can think that all negative numbers are more odder then positive.... No. 3 is odder then -3.

      -65 is more odder then -95. Why?

    • B1ts Avatar

      I think this one deserves the 'puzzle' tag. If the chaos in discourse isn't enough, the ambiguity of description is calling for it :>

      I realise it looks simple when you understand it, but getting to that point isn't clear-cut, and the hint gives more questions than answers :D

    • JohnHolz Avatar

      why 39 is odder than 31? 39 - 39,19,9,4 -31 - 31,15,7,3,1

    • sethkal7 Avatar

      It would be helpful to have more samples, especially input consisting of arrays of different sizes.

    • bcaixl Avatar

      Sorry, I don't even understand the subject.So Sad! QAQ

    • user8436785 Avatar

      Apparently you missed a notification -- Ruby translation EDIT: Also CoffeeScript translation

    • Chrono79 Avatar

      Maybe it's just me, but why should [0] return 0?

      Even numbers are just not odd.

      If there is no single such number, no number is odder than the rest; return Nothing, null, None, nil or a similar empty value.

    • user8436785 Avatar
    • docgunthrop Avatar

      Having recently started with publishing JS katas using chai for testing, I recommend wrapping each individual test case in an it function. This way subsequent tests continue running even after the first failed test. If you keep track of failed tests with a counter that terminates any further test runs once a failure threshold value has been reached, it can allow users to get a better understanding of why their code failed by examining more than one test at a time.

      This is a general suggestion, not specific to this particular kata.

    • docgunthrop Avatar

      The Description should include the test constraints so users can plan how to write their solution. This kata appears to require some level of performance, but does not indicate how performant a solution needs to be.

    • phildinius Avatar

      This would really benefit from some more useful examples in the description that illustrate how to compare two numbers whose 'm' is odd through a few recursions -- especially since the tests don't display so it's hard to see what's failing with your code.