2 kyu

The position of a digital string in a infinite digital string

335 of 1,179myjinxin2015
Description
Loading description...
Algorithms
Puzzles
  • Please sign in or sign up to leave a comment.
  • PhoenixS2 Avatar

    The kata is great but I'm having a hard time solving it, can anyone point me in the right direction?

  • Little Turtle Avatar

    Excellent kata!

    I have a small remark. The description is not precise.

    There is a infinite string. You can imagine it's a combination of numbers from 1 to n, like this:

    It is not just a combination. It is the infinite sequence of digits defined as the concatenation of the sequence of strings representing the consecutive numbers from 1 to infinity.

  • Noha1981 Avatar

    Good Morning!

    Can anyone please explain the main problem? If I would find an index of a subsequence in a string I would use indexOf in C#. At the second case he said that I can create my own string if I can´t find this subsequence...Okay, the subsequence I searchd is at the first position, cause I created a string on my own. Seems I don´t understand the problem...

    Greetings Noha

  • poop123 Avatar

    brainstroming. lol.

  • divinebeam Avatar

    Someone please kindly tell me what article should I read to help me solve this kata.Thank you all. Onegai, Sensei

  • user3038216 Avatar

    Really nice kata, I really underestimated it and thought people are joking about edge cases, but they are not joking and I spend few days having fun solving it, this is the most brainstorming kata I've ever solved, thank you!

  • rrabmig Avatar

    This comment has been hidden.

  • llctrautmann Avatar

    This comment has been hidden.

  • narsonos Avatar

    Incredible kata. It took me so long to find the solution. At first, there was an attempt to cover all the corner cases, which was huge. But then...

  • Obaskly Avatar

    Execution Timed Out (12000 ms) :/

  • dschrempf Avatar

    I really enjoyed this kata in the beginning, but with all these corner cases, it became a bit of a hazzle. Nice idea though, thank you!

  • WYXkk Avatar

    The idea is simple but there are so many corner cases to consider. Thanks to the given samples covering nearly all corner cases, or I wouldn't be able to solve this.

  • smolen Avatar

    Every time i see @myjinxin2015 kata i know i will have a hard time to solve it, in the other hand i enjoy it alot.

  • dfhwze Avatar

    One of the most interesting kata's. A very simple problem, yet so tricky to get right.

  • Luksonaッ Avatar

    Shouldn't it be "The position of a digital string in a(n) infinite digital string" ?

  • mmib Avatar

    This comment has been hidden.

  • TheRoboManTAS Avatar

    I was pressing attempt multiple times to make sure my code isnt making any very rare mistakes, and I think I found a mistake in the c# translation author's solution. It thinks that the index of 4949 should be 18685 when its actually two less (18683) This is really rare and you can easily pass the random tests but i thought id mention it.

  • ShreckYe Avatar

    I have thought of a quicker algorithm but there are so many cases to consider and they are realy cumbersome! I can never think of all of them without the test cases. This is basically test-driven programming.

  • achambily Avatar

    The hardest kata I've ever solved... It took 3 weeks with several hours a day. Each time I discovered a new case, it destroyed my previous work...

  • zLuki Avatar

    This comment has been hidden.

  • kuchaguangjie Avatar

    This comment has been hidden.

  • Alfabetix Avatar

    This comment has been hidden.

  • Davo36 Avatar

    This comment has been hidden.

  • Toemmsche Avatar

    Great kata! Getting the correct approach to solve it analytically didn't take that long but considering all the edge cases is pretty tedious. I don't even know if I managed to cover all of them.

  • DunetsNM Avatar

    Came up with a technique to solve it analytically. It simple to explain informally but there are soooooo many subtleties :)

  • AyushBk Avatar

    Lots of runtime errors.

  • aaronallen8455 Avatar

    I think there's a bug with the random tests in Haskell. The expected value and actual value that it gives seem to be flipped.

  • KChallenge Avatar

    Wonderful Kata! I managed to implement a correct algorithm but ... it takes way much more than 16 seconds to execute! Just as an example, this test "555899959741198" must give a result of "1686722738828503" ... that's a huge number, just only to iterate. I have to figure out something to make it super efficient, otherwise I will never manage to stay within the 16 seconds! Thanks for this Kata ... I hope I will manage to make it.

  • vaiil Avatar

    The task is formulated so easy, but I've spend about 5 hours to solve it. myjinxin2015, you've made excellent kata. Thank you!

  • vaiil Avatar

    The task is formulated so easy, but I've spent about 5 hours to solve it. myjinxin2015, you've made excellent kata. Thank you!

  • suarezali75 Avatar

    myjinxin2015 great job. Very, very challenging and particular. Took me very long to solve it but was absolutely worth it.

  • KKOKU Avatar

    This comment has been hidden.

  • s1y1 Avatar

    This comment has been hidden.

  • COLONELBIHI Avatar

    This comment has been hidden.

  • user9277937 Avatar

    This comment has been hidden.

  • Unihedron Avatar

    This comment has been hidden.

  • Daniel Ray Avatar

    This comment has been hidden.

  • Daniel Ray Avatar

    I think there's a typo in the kata description.

    it says:

     findPosition("454") == 76
     because "123456789101112131415...44454647".indexOf("454")=76
                                        ^^^
    

    It should be 79 instead of 76.

  • gjenkins Avatar

    This comment has been hidden.

  • myjinxin2015 Avatar

    @Voile Why you changed the expected value of testcase "040" to -1?

    "...400401..."

  • Blind4Basics Avatar

    Java translation!

    • I increased the number of random tests to 2*200, since I discovered with my python solution could fail on some particular edge cases
    • I added 5 fixed tests in the test cases, according to fails of some validated solutions discovered in this fork
    • changed the === to == in the description (I thought it was more common to the different languages than ===. Good?)

    Please, review!

  • Voile Avatar

    This comment has been hidden.

  • cyril-lemaire Avatar

    This comment has been hidden.

  • docgunthrop Avatar

    Thanks for another excellent kata, @myjinxin2015, and props for the outstanding work on the test cases - it's very robust and accounts for all types of edge cases. 👍👍

  • Voile Avatar

    (Trivia: It took me around 30 minutes to finish the kata. I guess that'd make it a 2kyu? ;-))

  • Voile Avatar

    Approved

  • myjinxin2015 Avatar

    This comment has been hidden.