← March 2025 questions

MARCH 2025 / INTERMEDIATE / LEVEL 1 · QUESTION 3

Level 1 · Question 3

Archived question

Try the question in your own editor, then check your output below.

THE QUESTION

Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.

Create a function that takes a string  and returns the number of words in that string (a ‘word’ is
defined by any character separated by ‘punctuation’)
punctuation = [' ', ',', '.', '!', '?', '-']
Input:
string1 = "AH-pateu apateu, apateu apateu, apateu apateu, ugh, ahah
ahah!"

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Use the corresponding input from the question. For lists, brackets and commas are optional for numeric answers; text lists may also be entered one item per line.

Reveal worked answer

Your output

10

Split on the specified punctuation and count non-empty words.

Reveal supplied answer

From the supplied Intermediate answer key. Outputs are reproduced as provided.

Expected output

10

Source: GIC 2025 Intermediate Questions and the supplied Intermediate answer key, March 2025 archive.