6 kyu

Smallest Permutation

888 of 1,552coder334
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • gotfede Avatar

    11588 should equal 1001588

    just tell me why, something wrong in this kata

  • kira__ Avatar

    No enough explanation

  • trashy_incel Avatar

    C translation (author gone)

  • Ferenandios Avatar

    Great kata

  • Ferenandios Avatar

    n = -482072 answer = -874220

    Why is incorrect answer?

  • dogma-n Avatar

    cool kata. good test cases.

  • JohanWiltink Avatar
  • aland97 Avatar
  • Danilin Aleksander Avatar
  • Mxrcon Avatar

    good and basic, nice work! you should add non number validation

  • Blind4Basics Avatar

    warning, there are currently only 1/3 if the random tests that aren't expecting None. The probability if valid inputs should be much higher than invalid inputs.

    Seems you didn't see that one. It's ""worse"" now that you removed the floats: half of the random tests are invalid inputs. => Update the tests to something like:

        ...
        a=random.randint(0,10)
        if a:
          #valid process
        else:
          # negative number
    

    cheers

  • JohanWiltink Avatar

    Basically, the task here is to sort ( ascending ) a valid value. That means any input for which an order is defined over the elements of the value ( which could be digits of a number, characters of a string, elements of a list, &c ) will work. There is no reason to complicate the task with negative floats and other insanity, other than making it look like something it is not.

    It also means any ranking over 8 means you didn't understand the task, and it's a duplicate of a duplicate of a duplicate.

    I'm not sure the kata is worth saving. If @failure learned a few useful things, it's all good and the decent thing to do next is unpublish the kata.

    that's a little harsh

    are you saying this is 8 kyu?

    cuz it's not

    if you haven't got anything good to say or any real feedback then dont say it

    let's put it this way:

    do you have any REAL feedback other than 'it's a duplicate of a duplicate of a duplicate' which you have given no proof of and that i doubt you really have

    also i really doubt you read everything in here because i removed floats and made the task only integers actually i doubt you even read the description

    Apparently, you're under the impression you're at your grandmother's dining room table, she has spent hours in the kitchen to cook you a fabulous dinner and you don't like it. That would be the moment to not say anything, as my mother taught me. But you are not at your granny's dining room table, this is CodeWars. If you publish a kata, you are inviting criticism ( of it, not of you. and that's the last I'll say about personal attacks ).

    Yes, I am saying this is an 8 kyu kata, because it is. The task is sorting an algebraic datatype. In this case, that algebraic datatype is a number composed of digits, but as I mentioned, it could have been a string composed of characters or a generic polymorphic list composed of arbitrary elements ( for which an order is defined ). The particular encoding has no bearing on the essence of the task, decoding and encoding a number as a list of digits does not raise the difficulty above 8, and sorting a list has been done, which makes this a duplicate. I did not give specific examples of previous "sort my list" kata, but if you think I could not, you did not yet encounter a lot of kata I have some across.

  • hobovsky Avatar

    I would suggest changing the requirement of returning None to some sentinel integer value, for example -1. Otherwise you risk problems with description when kata gets translated to other languages and translators will create frankensteinous monstrosities like "return None in Pyton, -1 in C, Nothing in Haskell" and you will get overwhelmed by description merge conflicts.

  • hobovsky Avatar

    Is your kata meant to be solvable by iteration from 0 to n checking if the number satisfies the condition of being minimal, and having the same digits? If not, you should take special care of generating some pessimistic input. There are already two digits rearrangement kata (Next bigger number with the same digits and Next smaller number with the same digits) with tests randomized in a way that iterative solutions are able to pass after sufficient (and not that high) amount of resubmits.

  • Blind4Basics Avatar

    Hi again,

    I didn't pay enough attention before, sorry, but you need to mix the two types of random cases: use one single batch of random tests and you generate randomly a good or wrong random input. Otherwise, your tests aren't really random (the expected output for the first batch is know upfront, for instance). Use something like this:

        # define your random generators of inputs here:
        def randFloat(): ...
        def randNeg():
        def randValid(): ...
        
        gens = (randFloat,randNeg) + (randValid,)*10     # *10 to get more valid inputs than invalid inputs
        from random import choice
        
        for _ in range(200):
            v = choice(gens)()
            # assert stuff one way or the other here
    

    note: might be good to have 2 different kinds of valid generators, the second one inserting zeroes in the input, to make sure this is properly tested (after all, that's the main point of the kata)

  • Blind4Basics Avatar

    why provide the input as a string? if that's the type of input, you really should test for stuff like '0000' and '000123' too.

    So imo, you should rather go for integers as inputs (which would make much more sense considering the context of the task)

  • Blind4Basics Avatar

    hi,

    nice enough, but:

    • this is incorrect: minPermutation('0') => '' It should be '0'
    • you should make the description language agnostic as much as possible, hence avoid to show the function name (which will vary from one language to another) and just show the mapping input/output. And preferably use "..." which are working in most languages for strings while '...' doesn't.
    • function identifier in python should be in snake_case, hence min_permutation

    cheers