Why is this code for Spy Life challenge coming back as a fail? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Why is this code for Spy Life challenge coming back as a fail?

I wrote this code for the Spy Life challenge. For the first 2 visible tests, my output and expected output are the same, but they are marked as failures. I made a test file on my own and entered the same values the test did, and I get the expected output and no compiler errors. Any idea why the challenge says its incorrect? Yes, I know there are other ways to solve this challenge, but I want to know why this isn't working. https://code.sololearn.com/c1fXx3YmU4xk/?ref=app

13th Dec 2020, 10:37 PM
Jessica Brezzo
Jessica Brezzo - avatar
4 Réponses
+ 2
I cant remember what was needed for the spy life...but I far as I can see from your code, your trying to remove all none alphabet and upper-case characters (apart for the '
#x27; in line 33) Your reverse routine is slightly incorrect:- ...... ....... string reversed; for (unsigned int i = 0; i < phrase.size(); i++) { reversed += phrase[phrase.size() - 1 - i]; } return reversed; }
13th Dec 2020, 11:36 PM
rodwynnejones
rodwynnejones - avatar
+ 1
Looks like that fixed it, though my version was returning the correct words. Any idea why my was returning the correct words but failing the challenge?
14th Dec 2020, 12:36 AM
Jessica Brezzo
Jessica Brezzo - avatar
+ 1
Jessica Brezzo they use random words, numbers and characters in the test and all test are hidden from everyone including mods. The developers are the only ones who know exactly what the test are.
14th Dec 2020, 1:04 AM
BroFar
BroFar - avatar
+ 1
BroFar It was doing this is the tests that were revealed (the first two tests). The output and expected output were exactly the same, but marked as incorrect. The earlier suggestion outputs the exact same thing as my original code, but is marked correct.
14th Dec 2020, 1:08 AM
Jessica Brezzo
Jessica Brezzo - avatar