Foundations
These problems don’t require any data structure or complicated algorithm. They help get used to the submission system and the various forms of input. As mentioned in the introduction, within each category, problems are listed from easiest to not so easy, in my opinion.
Sequence
These problems can be solved without any if-statements or loops.
You may need to use abs
, min
or max
to avoid if-statements.
-
Hello World! (1 LOC): See the Input and Output section for details.
-
Simple Addition (1 LOC): See the Input and Output section for details.
-
Solving for Carrots (1 LOC): See the Input and Output section for details.
-
Faktor (2 LOC): A little arithmetic tongue-in-cheek problem about the academic obsession with bibliometrics. The problem description explains the necessary concepts.
-
Planina (1 LOC): Compute the number of points on a grid, after n iterations of a given procedure to create points. Once the formula has been derived, the code is trivial, using the power operator
**
.
Selection
These problems can be solved with if-statements alone. No loops required.
-
Quadrant Selection (6 LOC): Given the x and y coordinates of a point, print in which quadrant it is.
-
Moscow Dream (5 LOC): Check that four integers satisfy some conditions.
-
Wizard of Odds (5 LOC): Check that two integers satisfy a condition.
-
Judging Moose (7 LOC): Describe the antlers of a moose.
-
Eating Out (3 LOC): Check if people in a restaurant, each choosing a certain number of dishes, may end up not choosing the same dish. Easy to code, but requires some thinking to get the formula.
Iteration
These problems require a for- or while-loop because either the input contains multiple lines, or the problem itself requires a loop.
-
R2 (3 LOC): Given the average of two integers and one of them, find the other one. The input has two integers per line, until the end of the file.
-
A Different Problem (4 LOC): See the Input and Output section for details. Doesn’t require if-statements.
-
Left Beehind (11 LOC): See the Input and Output section for details.
-
Thanos (7 LOC): Simulate the growth of a population and find out in which year the resources aren’t enough. A nice simple problem that uses a for-loop to process all test cases, and a while-loop to solve each test case.
-
Tarifa (6 LOC): Given the allowance on a data plan and the past monthly consumption, how much data is available this month? Unused data carries forward.
Floats
These problems involve floating-point numbers, some of
which can be tricky due to precision and rounding issues.
You may need the math
library for some of the problems.
-
A Real Challenge (3 LOC): Given the area of a square pasture, how long is the fence? No if-statements or loops.
-
Pizza Crust (2 LOC): What percentage of a pizza has cheese, knowing the width of the crust? No if-statements or loops.
-
Euler’s Number (6 LOC): Approximate Euler’s number through a series of factorials. This problem doesn’t require mathematical knowledge: just translate the given formula to code.
-
Roaming Romans (5 LOC): Convert English miles to Roman paces. No loops. Requires some care because Python rounds floats to the nearest even integer, not necessarily up.
-
Herman (4 LOC): What is the area of a circle in normal and in Manhattan/taxi geometry? Draw on grid paper to see the latter. No if-statements or loops.
Strings
Almost every problem requires printing a string as part of the output,
but these problems require some string processing: comparing strings,
matching substrings with the in
operator,
calculating the length with the len
function, formatting the output, etc.
-
IsItHalloween.com (2 LOC): Check if the input is one of two dates. No loops required.
-
Avion (7 LOC): Report which given strings have a particular substring.
-
Cryptographer’s Conundrum (4 LOC): Given a string, count how many letters must be replaced to obtain another string.
-
Help a PhD candidate out! (3 LOC): See the Input and Output section for details.
-
Drinking Song (12 LOC): Print out the ‘99 bottles of beer’ song for any drink and number of bottles. The text varies when there’s one or no bottle left.