SRL Archive - Help and Support

Python help


Simtoon

2012-02-22 07:36:02

Question 8
Pythons and Shells and Stars, Oh My!
Who's up for playing Mariokart? If you don't know, Mariokart is Nintendo's cartoon racing game. Apart from letting you drive around like a lunatic, the game has certain items you can pick up to help you, or to hurt your opponents.
In this question, we want to figure out what items certain characters have picked up – either stars, which make you invincible, or shells, which let you shoot people to make them crash.
Your program should ask the user for input. There will be no punctuation, but there may be capitals.
• If the sentence has the word star in it, your program should print out INVINCIBLLLLE!
• If the sentence has the word shell in it, your program should print out CRASH!
• If there are multiple shells and stars in a sentence, one shell will cancel out one star. Your program should print the correct output for whatever is left over.
• If there are no items, or they've all cancelled each other out, your program should print Just drive.
Here's an example of how your program should work:
Enter: Toad drove around with a shell and a star but another shell hit him
CRASH!
There are two shells and one star, so there is one shell left over and the car will crash.
The words can be hiding in the sentence. For example:
Enter: When Peach came first a ROAR went up in the crowd
INVINCIBLLLLE!
This is because star exists in the sentence using the last two letters of first, then the word a and then the first letter of the word roar. Hidden words will always have their letters in the correct order, they can just be parts of other words and have spaces in between them, but no other characters.

An example of where you should just drive is as follows:
Enter: Mario has a kart and a shell and a shell and a star and a star
Just drive.
since the two stars and shells cancel, and there are no extra items left over.
Hint
The string count() method makes this question a lot easier!






Please dont move this to public i dont want the teacher searching this and finding it thanks

I'm not sure on how to find the hidden words

Er1k

2012-02-22 07:42:27

trim spaces and regex?