Mispelling

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 16M

Problem type

Misspelling is an art form that students seem to excel at. Write a program that removes the nth character from an input string.

Input Specification

The first line of input contains a single integer N (1 \le N \le 1\,000) which is the number of datasets that follow.

Each dataset consists of a single line of input containing M, a space, and a string made up of uppercase letters and spaces only. M will be less than or equal to the length of the string. The length of the string is guaranteed to be less than or equal to 80.

Output Specification

For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, and the misspelled string. The misspelled string is the input string with the indicated character deleted.

Sample Input

4
4 MISSPELL
1 PROGRAMMING
7 CONTEST
3 BALLOON

Sample Output

1 MISPELL
2 ROGRAMMING
3 CONTES
4 BALOON

Comments


  • 0
    pythonprogramming100  commented on Feb. 22, 2023, 8:54 p.m.

    good problem


  • 0
    jerrycui07  commented on June 13, 2022, 11:33 p.m. edited

    This might be an error some of that has occurred to some of you. I used a dictionary to store the input, with the string being the key, and the character to skip as the value. However, if you receive the same string twice as input, then the original value will get overwritten. I think the 10th test case is doing something like this.

    Edit: This was not the reason I got an error for my program. But it is something you should keep in mind.


  • -3
    rmichailov  commented on Jan. 6, 2022, 5:09 p.m.

    Can someone look at my work? When I test it out it works, but it still says that the 10th test is failing.


    • 2
      Spitfire720  commented on Jan. 6, 2022, 5:58 p.m. edit 6

      Consider if your string is entirely spaces. Your code will fail because it removes all the spaces instead of just the nth character.

      Also, your slicing is flawed. For a test case like:

      30 AEIOUAEIOUAEIOUAEIOUAEIOUAEIOU

      Your code will not work correctly.

      Also, you can print your output as you receive input, because DMOJ is cool like that


      • 0
        rmichailov  commented on Jan. 7, 2022, 7:53 p.m. edited

        I made the changes but it still says that the last test is failing

        Edit: I finished the problem, but before I did I worked out that the last test is a long string ending with the digits 1-0. Even though the directions said that it was a string with uppercase letters and spaces only. Hope this helps


  • 0
    x_Sunnybr0G_x  commented on July 27, 2021, 4:49 p.m.

    Can someone see what is wrong with my code? I tried accounting for spaces but it is still wrong.


    • 3
      Badmode  commented on July 27, 2021, 6:21 p.m.

      What if the string started with spaces?


      • -2
        Code  commented on Jan. 19, 2022, 6:35 p.m.

        Wait, this might be why I still can't finish it. If the string started with spaces, you would have to print the spaces out along with it? For example if the input was "4" and " abcdef," would the output be " abcef"?


        • 2
          Spitfire720  commented on Jan. 19, 2022, 8:17 p.m.

          No, it would be " abdef", since c would be the 4th character in the string


          • -1
            Code  commented on Jan. 20, 2022, 2:09 a.m.

            Oh right. ok thanks


      • -4
        x_Sunnybr0G_x  commented on July 28, 2021, 12:27 a.m.

        Been workin through it and now it gives an error. So confused


  • 5
    dev405  commented on Jan. 3, 2021, 3:03 p.m. edit 2

    Good challenge. I only need over 60 submissions.


    • -2
      John  commented on April 4, 2022, 5:42 p.m.

      And I thought 17 was painful...


  • -2
    PerfectlyInternal  commented on Oct. 20, 2020, 9:46 p.m.

    I've tested my code and it seems to work just fine, but I keep failing tests 9 and 10, why is this? I tried handling cases where M is 0 and it didn't change. Is M negative in some cases?


    • 0
      kresteodymium  commented on Feb. 5, 2021, 9:08 p.m.

      I faced the same issue but @charliezhao06's comment opened my eyes lol


    • 12
      charliezhao06  commented on Oct. 21, 2020, 12:07 a.m.

      Did you consider if the string has spaces in it?


      • 24
        ross_cleary  commented on Oct. 21, 2020, 1:05 a.m.

        Massive brain.