Asked by meeee
Write a program to cheer for your favourite team at the sports carnival. Since I don't play any real world sports, my program would work like this:
Cheer: gryffindor
Give me a g, g!
Give me a r, r!
Give me a y, y!
Give me a f, f!
Give me a f, f!
Give me a i, i!
Give me a n, n!
Give me a d, d!
Give me a o, o!
Give me a r, r!
What does it spell?
GRYFFINDOR
ā
Here's another example of how your program should work:
Cheer: hello
Give me a h, h!
Give me a e, e!
Give me a l, l!
Give me a l, l!
Give me a o, o!
What does it spell?
HELLO
All Answers 1
Answered by
GPT-5 mini
AI
Here are two simple implementations (Python and Node.js). They prompt with "Cheer: ", skip spaces, print a "Give me a ..." line for each character, then print the uppercase spelled word.
Python (3):
```
s = input("Cheer: ").strip()
for ch in s:
if ch.isspace():
continue
c = ch.lower()
print(f"Give me a {c}, {c}!")
print("What does it spell?")
print(s.replace(" ", "").upper())
```
Node.js (run with node):
```
const readline = require('readline');
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question('Cheer: ', (s) => {
for (const ch of s) {
if (/\s/.test(ch)) continue;
const c = ch.toLowerCase();
console.log(`Give me a ${c}, ${c}!`);
}
console.log('What does it spell?');
console.log(s.replace(/\s+/g, '').toUpperCase());
rl.close();
});
```
Examples
- Input: "gryffindor" produces the exact output in your example.
- Input: "hello" produces the second example.
If you want different handling (keep original case in the "Give me..." lines, treat punctuation specially, or use "an" before vowels), tell me and I'll adjust.
Python (3):
```
s = input("Cheer: ").strip()
for ch in s:
if ch.isspace():
continue
c = ch.lower()
print(f"Give me a {c}, {c}!")
print("What does it spell?")
print(s.replace(" ", "").upper())
```
Node.js (run with node):
```
const readline = require('readline');
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question('Cheer: ', (s) => {
for (const ch of s) {
if (/\s/.test(ch)) continue;
const c = ch.toLowerCase();
console.log(`Give me a ${c}, ${c}!`);
}
console.log('What does it spell?');
console.log(s.replace(/\s+/g, '').toUpperCase());
rl.close();
});
```
Examples
- Input: "gryffindor" produces the exact output in your example.
- Input: "hello" produces the second example.
If you want different handling (keep original case in the "Give me..." lines, treat punctuation specially, or use "an" before vowels), tell me and I'll adjust.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.