5 kyu

Typing series #5 --> the insert key and moving cursor

Description
Loading description...
Strings
Algorithms
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    Description is contradicting test cases. Please align.

    abcd[ins 0]wxyz[ins 0]pqrs -> pqrs
    

    Test cases expect pqrswxyz, description expects pqrs.

    This part is not correct in description:

    [ins n]...text...[ins n]
    
    ins goes back to insertion mode and continue typing.
    
    • B1ts Avatar

      I got confused by this too. It appears that [ins number] would force insertion mode on, but that's not true... It's still a toggle.

    • goldenratio161 Avatar

      sorry i didn't address this sooner, but yes, [ins] and [ins n] are toggles. it's like if you physically type the string out and press [ins] on your keyboard; it behaves as a toggle.

      Issue marked resolved by goldenratio161 8 months ago
    • dfhwze Avatar

      Is this then correctly phrased in the description?

      [ins n]...text...[ins n]
      
      ins goes back to insertion mode and continue typing.
      
    • dfhwze Avatar

      yes, all good now

  • dfhwze Avatar

    from examples:

    abcd[ins 0]wxyz[ins 0]pqrs -> pqrs
    

    yet, from tests:

    abcd[ins 0]wxyz[ins 0]pqrs[ins]
    'pqrs' should equal 'pqrswxyz'
    

    so what is the specification for an [ins n] after another [ins n] ??

  • saudiGuy Avatar

    Almost 10 months now.. someone should approve this amazing kata..

  • Fbasham Avatar

    As pointed out below, the cursor goes out of bounds in some of the tests.

    See the following examples from the random tests:

    • wlruxwqg[ins 0]xvlg[ins 9]yzjbpqj[ins 8]urtbr[22][ins -20]p[-17]fqajg,
    • tn[ins 0][ins -3]xd[ins -4]nce[2][-7]pzvd[10]uti[1]cqmvn
    • jufwuzcwbp[ins 3]ntyd[-6]wyltfby[ins -17]hn[4][ins 0]fh[ins -21]egpdanjvgxwg
    • Fbasham Avatar

      Duplicate issue. Looks like Voile and I posted near the same time and I didn't see his issue before raising this one. Closing.

      Issue marked resolved by Fbasham 2 years ago
  • Voile Avatar

    The description needs to specify how cursor indexing is handled when it's negative. Currently it just says "negative numbers can appear and you're expected to handle them", it doesn't tell how.

    (-len(s)-1 <= n < len(s))

    n = len(s) is a possible input: it sends the cursor to the end of the buffer.

    Also, as mentioned below, random tests generate invalid input, such as:

    xsahl[ins 0]oitzrleai[-15]qdkgexvo[-8]qr
    
    'oitzrqqrgexvo' should equal 'oitzrledqrexvoq'
    

    There are less than 15 characters when [-15] happens.

    • goldenratio161 Avatar

      Hi, sorry about the miscommunication. I have given a (hopefully clear) example in the description and have added more tests containing the edge case. To approve this, I have to close this issue, but please raise it again if the issue is still there.

      Issue marked resolved by goldenratio161 2 years ago
  • Fbasham Avatar

    I'm passing about 2/3 of the tests and I'm a bit confused. I think you need to add addtional examples (with a breakdown) and sample tests for something like the following:

    wlruxwqg[ins 0]xvlg[ins 9]yzjbpqj[ins 8]urtbr[22][ins -20]p[-17]fqajg

    It's unclear to me how the answer is (based on the tests): xfqajgvlgxwqgurtbrpqjp

    It appears the cursor goes out of bounds, unless I'm misunderstanding the description?

    Edit:

    Another one: tn[ins 0][ins -3]xd[ins -4]nce[2][-7]pzvd[10]uti[1]cqmvn

    The cursor goes out of bounds here sometimes.