Professional Documents
Culture Documents
Coding Challenge - Examples
Coding Challenge - Examples
Rainbow (Easy)
Mary is 5 years old and is learning the colors of the rainbow. Write a program that takes the
digit N as an input and displays (in any way - prints, draws) the first Ns as colors of the
rainbow. A little hint - don't forget that there are 7 colors of the rainbow! Try to make a beautiful
rainbow, the judges love it!
3 RОY
22 wrong input
Caterpillar (Hard)
The caterpillar decided to climb the tree because the leaves at the top of the tree are the most
delicious. All day long it crawls up and climbs 5 meters. At night the caterpillar sleeps and
crawls down 3 meters. You need to write a program that helps the caterpillar determine how
many days it will take to crawl to the top of the tree.
The input is the height of the tree. The output is the number of days it will take the caterpillar
to reach the top of the tree.
Example:
4 1
5 1
8 3
A decimal integer number is given. You need to write a program that looks for the difference
in two numbers. The first number is equal to the sum of digits of the original number in even
places. The second number is equal to the sum of digits in odd places.
Example:
123456 3
1111 0
0 0
Imagine that you are in the future and even the bathtub is controlled by voice commands. Only
it has two commands - to pour 7 liters of water, to drain 5 liters of water. The bathtub's capacity
is 200 liters.
The input of the program is the amount of water to be poured into the bathtub, the output - 2
numbers, how many times you need to drain and how much to pour. Important! In the future
everyone is very careful to save natural resources in general and water in particular, so it is
necessary to use as little water as possible!
12 66
73 14 5
1 34
Consider all natural numbers whose entry in the decimal notation is a palindrome (the entry
does not start with zero). For example, numbers 121 and 1331 are palindromes, and number
123 is not. For a given natural number N determine the next natural number (that is, the
smallest number that exceeds N ) that is a palindrome. The program receives as input one
natural numberr N. The program should output the smallest natural number that is greater
than N and is a palindrome
Example:
123 131
667667 667766
432 434
Three triangle side lengths are given as input. You need to write a program that determines
whether a triangle with these sides exists, and if so, specify the classes to which it belongs
(equilateral, isosceles, obtuse-angled, acute-angled, right-angled triangle)
Example:
7 15 7 doesn’t exist