## Mispelling

View as PDF

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 th character from an input string.

#### Input Specification

The first line of input contains a single integer which is the number of datasets that follow.

Each dataset consists of a single line of input containing , a space, and a string made up of uppercase letters and spaces only. 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 .

#### 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

• commented on Jan. 16, 2022, 9:47 a.m. edit 2

Can someone tell me why I failed the last two test cases or something I failed to account for?

Edit: I saw the bottom comment and am now suffering crippling depression

• commented on Jan. 19, 2022, 7:51 p.m.

i think its the whitespace issue

• commented on Jan. 6, 2022, 12: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.

• commented on Jan. 6, 2022, 12: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

• commented on Jan. 7, 2022, 2: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

• commented on Aug. 17, 2021, 1:59 a.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Aug. 17, 2021, 10:43 a.m.

Welcome to DMOJ! First I would like to say not to paste your entire code into the comments as people who solved this question can view all submissions. As for your code -

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.

• commented on July 27, 2021, 12:49 p.m.

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

• commented on July 27, 2021, 2:21 p.m.

What if the string started with spaces?

• commented on Jan. 19, 2022, 1: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"?

• commented on Jan. 19, 2022, 3:17 p.m.

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

• commented on Jan. 19, 2022, 9:09 p.m.

Oh right. ok thanks

• commented on July 27, 2021, 8:27 p.m.

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

• commented on Jan. 3, 2021, 10:03 a.m. edit 2

Good challenge. I only need over 60 submissions.

• commented on Oct. 20, 2020, 5: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?

• commented on Feb. 5, 2021, 4:08 p.m.

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

• commented on Oct. 20, 2020, 8:07 p.m.

Did you consider if the string has spaces in it?

• commented on Oct. 20, 2020, 9:05 p.m.

Massive brain.