3 kyu

N-Parasitic Numbers Ending in N

195 of 972LesRamer
Description
Loading description...
Algorithms
Mathematics
Puzzles
  • Please sign in or sign up to leave a comment.
  • jediflamaster Avatar

    This is too easy to be 3 kyu, knock it down to 4 or make just multiplying with carry not viable.

  • Sir Umbra Avatar

    I worked out a mathmatical expression. It only fails in some octal cases (8,6) (8,7).

    I have no idea why it isn't working and I already asked a question a week ago.

    Could you show the expected results? Because if I had the results, maybe I could see my mistake as no one aswered my first question.

  • Sir Umbra Avatar

    This comment has been hidden.

  • snowshovel Avatar

    I hope we soon get a node.js version that handles BigInt, I just modified my old code to use BigInt and now it won't work.

  • akar-0 Avatar
  • akar-0 Avatar
  • akar-0 Avatar
  • Twilight_Sun Avatar

    This comment has been hidden.

  • und3f Avatar

    This comment has been hidden.

  • MobulaKuhlii Avatar

    This comment has been hidden.

  • mirrorcall96 Avatar

    in javascript you can't use BigInt because the testing use old js code please fix the testing code sir

  • augustjdl Avatar

    To be a 3 kyu kata, it really should be opened up to any base 3 to 36...

  • mauro-1 Avatar

    This comment has been hidden.

  • Toemmsche Avatar

    This comment has been hidden.

  • artur-szpot Avatar

    It was a fun challenge, what with having to convert a prepared Python3 code into Python2 and fighting to optimize it enough to squeeze through the tests in the time alloted. As usual, seeing the 5-line solution afterwards is hilarious, but it was satisfying to get my way :)

  • guriyeller Avatar

    This comment has been hidden.

  • Tivian Avatar

    I think you should update test cases (at least those for C#) for base 10, because for n = 5 correct answer is 142857 not 102040816326530612244897959183673469387755, because 5 is special case and period of 5 / 49 isn't the smallest parasite number possible. For n = 5 correct answer is period of 1 / 7.

  • Woody Woodburn Avatar

    This comment has been hidden.

  • KenuR Avatar

    Getting an error with the test library.

    Fixture.cs(7,20): error CS0246: The type or namespace name 'Result' could not be found (are you missing a using directive or an assembly reference?) Fixture.cs(8,20): error CS0246: The type or namespace name 'Result' could not be found (are you missing a using directive or an assembly reference?)

  • Taybola Avatar

    Hello. I'm agree with user Kastalien There are an errors in this kata. For case with lastDigit = 2 and base = 8 exist more smaller integer 52 ( in octal: 2 * 25 = 52 ) than in kata solution (1042) And for case lastDigit = 5 and base = 10 solution is 5 * 142857 = 714285, wich is much smaller then 102040816326530612244897959183673469387755 I didn't encounter issues with base 16. May be due to structure of random tests.

  • BobaFett Avatar

    Hello,

    I'm getting error with testcase digit: 3, numberBase 16 on C#.

    My answer is 1057262010144124151298821193. But it is not expected result in this test.

    Could you share what expected result should be for this case, so I can debug my code?

  • MP7373 Avatar

    I'm getting what I think is a bug in the Javascript version where string.charAt() is not working in the test cases (or possibly a single test case I can't tell).

    I've even tried guarding and only calling string.charAt(variable) if (typeof(variable) === 'string')

    I'm not sure what's up or if i'm missing something obvious.

    UPDATE:

    I changed all of my string.charAt(x) to string.substring(x, x +1) and i'm still getting the same error. then I tried:

    function calculateSpecial(lastDigit, base) { return 1 }

    I got the same bug so the Javascript test cases need to be fixed.

  • Ysrael Avatar

    No era tan complicado después de todo. Hay que tener cuidado en representar bien las cifras de acuerdo a la base.

  • iv2101 Avatar

    nice kata, but feels more like 5kyu to me.

  • cyril-lemaire Avatar

    Miss random test cases (why not open the bases range? 2=>16 should be fair enough)

  • Voile Avatar

    Some hairy readings for mathematical aware people to get a grasp of this problem:

    http://math.blogoverflow.com/2014/06/11/when-do-n-and-2n-have-the-same-decimal-digits/

  • hufftheweevil Avatar

    Are the tests supposed to end if you get two wrong? At the moment, my solution works for base 8 up to n=5, then fails on 7 and 8. But then it just quits and doesn't test anything else. Is this supposed to happen? If so, that's rather annoying because I would like to see what other tests I am able to pass, that might help me figure out what's wrong with my algorithm.

  • __TomFoolery__ Avatar

    (0)_(0) grrrrrr

  • user6619196 Avatar

    fun kata. I would suggest maybe giving another example (with radix > 10) to demonstrate that expected answers should be represented in the given radix (i.e. some hex output will contain a,b,c,d,e,f etc).

  • adloky Avatar

    Maybe tests has error, but true:

    2 (base 8) => 25 5 (base 10) => 142857 7 (base 16) => 1024E6A17 9 (base 16) => 13B

    I comment my code for emumerate k (by wiki)

  • Kastalien Avatar

    This comment has been hidden.

  • nimou Avatar

    Well, I'm not sure if by "brute force" you meant the wikipedia method, but it worked pretty well :p

    Nice kata

  • Yoshyn Avatar

    I got a solution that make pass the 'run exemples' and also the exemple i found over wikipedia. However, it fail on the attempt (Some fail and one forever loop). I can't figure out why.

    Is it possible to add more exemple (with other base & value) or a least for most of the tests that fail when submitting, give the expected?

  • openmind Avatar

    In the test case, the method is calcSpecial, but when you submit, it needs to be calc_special

  • lechevalier Avatar

    Nice, but you should precise the definition used here isn't the same one as the one in the link you give.

    From your link (wikipedia):

    An n-parasitic number (in base 10) is a positive natural number which can be multiplied by n by moving the rightmost digit of its decimal representation to the front.

    It quite differs with your definition:

    Parasitic numbers get their name from this one simple property -- when they are multiplied by their trailing-digit, the product has all of the same digits in exactly the same order with one exception -- the trailing digit has moved from the rightmost position of the multiplicand to the leftmost position in the product.

  • Absurdated Avatar

    Nice kata, with a number of different ways to solve. Thanks.

  • LesRamer Avatar

    This was a fun kata for me to author and I hope it is as fun for you to solve. It involves some number awareness.

    I solved the puzzle a completely different way in java than I did in c#. I also know of a third, completely different way to solve the puzzle.

    I'm really looking forward to solutions from you clever folks out there. Happy puzzling!