GENIUS Olympiad Coding Samples
GENIUS Olympiad Coding Samples
4
20, 20, 23
20, 20, 20
20, 21, 22
13, 14, 30
•
•
Isosceles
Equilateral
Scalene
Not a Triangle
Sample Question 2
Difficulty: Easy
Problem Background
Adding up numbers is very easy, unless you add a twist. If two numbers are the same, sum their sums!
Problem Description
Your program will be given two numbers. If they are not equal, return their sum. If they are equal,
return double their sum.
Sample Input
received from the standard input channel, will contain a
positive integer representing the number of test cases. Each test case will include a single line
consisting of two non-negative integers separated by spaces.
5
1 3
2 2
3 2
13 13
125 9
Sample Output
For each test case, your program must output the value calculated according to the rules described
above.
4
8
5
52
134
Sample Question 3
Difficulty: Easy
Problem Background
Recycling is very beneficial to the environment. It helps conserve limited natural resources, reduces
waste that is sent to landfills, and so much more. In order to encourage people to participate in
recycling programs, many local governments offer rebate programs, where you can earn money by
bringing aluminum cans, glass bottles, and qualifying plastic items to a recycling center.
Problem Description
The local government has hired Lockheed Martin to set up a new recycling rebate system. To make it
easier for recycling center employees to determine the total rebate for a customer, recyclable items
are separated and weighed, rather than individually counted.
On average:
Based on these weights, customers are then paid for each item they brought in to be recycled:
Sample Input
received from the standard input channel, will contain a
positive integer representing the number of test cases. Each test case will include a line containing
three non-negative integers separated by spaces, each representing (respectively):
o
o
o
o
o
2
2
[[Alice,Bob],[15,16],[aliceInsta,BobIsCool1],[@wonderland,@bobbyBoy],[1234567890,
4078675309],[[email protected],[email protected]]]
Alice
Bob
2
[[Joe,Eve],[32,45],[AverageJoe,DropperOfEves],[@shoeless,@eve123],[8374629401,384
9502837],[[email protected],[email protected]]]
Eve
Joe
Name: Alice
Age: 15
Instagram: aliceInsta
Twitter: @wonderland
Phone: 1234567890
Email: [email protected]
Name: Bob
Age: 16
Instagram: BobIsCool1
Twitter: @bobbyBoy
Phone: 4078675309
Email: [email protected]
Name: Eve
Age: 45
Instagram: DropperOfEves
Twitter: @eve123
Phone: 3849502837
Email: [email protected]
Name: Joe
Age: 32
Instagram: AverageJoe
Twitter: @shoeless
Phone: 8374629401
Email: [email protected]
Sample Question 5
Difficulty: Medium
Problem Background
Despite its numerous qualities and names, constructing the triangle is relatively simple. The triangle
consists of a series of rows, in which each row is used to create the next. The first row, row 0, consists
of a single number 1. Each subsequent row adds an additional number, creating a pyramid shape,
where each number is the sum of the two above it (blank values from outside the triangle are
considered to be 0). As a result, row 1 consists of two numbers, 1 and 1, since there are no other
numbers to add together. Row 2 is the first row to contain a number greater than 1, with the numbers
1, 2, and 1; the center cell is the value of both cells from the previous row added together.
While its construction is simple, the numbers in the triangle grow in magnitude very quickly and can
become unmanageable if building a triangle by hand. Even computers can begin to run into problems
after too many rows!
Problem Description
Your team must write a program that ca
Triangle. Remember that row 0 contains only the number 1; the image above shows the numbers
number; this is one of many patterns that may help you solve this problem!) Also keep in mind that the
3
3
4
7
Sample Output
For each test case, your program must output
Triangle. Each test case must be printed on a separate line.
3
6
35
Sample Question 6
Difficulty: Medium
Problem Background
Problem Description
Your program will be provided with a list of numbers, and must
determine if the list contains a triplet. A triplet is a number
that appears exactly three times within the list (not necessarily in a row). A number that appears only
t count, nor one that appears four times.
Sample Input
received from the standard input channel, will contain a
positive integer representing the number of test cases. Each test case will include a line containing
several positive integers separated by spaces.
4
1 2 3 4 5 1 7 8 1 6
11 34 56 11 12 94 67
22 33 44 22 99 22 32
98 1 34 5 98 3 89 5
Sample Output
For each test case, your program must
one
separate line.
TRUE
FALSE
TRUE
FALSE
Sample Question 7
Difficulty: Hard
Problem Background
Problem Description
Your goal is to write an application that reads an input representing a chessboard and outputs
whether the player set to move is in checkmate. The player to move can be deduced by determining
which player is in check - if neither player is in check, no checkmate exists.
While chess is a well-known game, it rules are somewhat complicated, and so the ones relevant to
this problem are reiterated below. If you are familiar with the game already, you can skip most of the
rest of this description; however, make sure to take note of which letters are used to represent which
pieces.
There are six different kinds of pieces in chess, all of which move in different ways. In this problem,
they will be represented on the chessboard with upper or lowercase letters, as shown later in this
section. The overall goal of the game is to force your opponent into a situation where their king is in
The six types of pieces and their rules of movement are as follows:
• P or p - Pawn
o Can only move onto the space directly in front of it, with three relevant exceptions,
explained below
o A pawn cannot move forward if the space in front of it is occupied by another piece (of
either color)
o If an opposing piece is in either space diagonally ahead of a pawn, the pawn may move
onto that space to capture that piece
o A pawn in its starting position (second row
two spaces forward, if both spaces are unoccupied
• R or r - Rook
Sample Question 7 - Continued
The king
Neither player may make any move that puts their own king in check (or allows their king to remain in
check). If a player in check is unable to make any move to protect their king, that causes a
Sample Input
received from the standard input channel, will contain a positive
integer representing the number of test cases. Each test case will include 8 lines representing the
layout of a chessboard during a game of chess. Pieces are represented with uppercase or lowercase
letters as shown above; uppercase letters represent white pieces, and lowercase letters
Sample Question 7 - continued
t the
3
..k.....
.PQP....
........
........
........
........
........
..R....K
........
k.......
........
........
......Q.
.....bnr
......PP
.......K
......k.
........
..rr....
.b......
........
........
........
..RKR...
Sample Output
For each test case, if a checkmate exists, your program must print a line containing the word
. If no checkmate exists (neither player is in check, or the player
in check is able to move), print NO CHECKMATE instead.
CHECKMATE WHITE
NO CHECKMATE
CHECKMATE BLACK
Sample Question 8
Difficulty: Hard
Problem Background
enemy has cameras positioned throughout the building with a 360° field of view; if your spy is caught
on camera, the mission will fail! Fortunately, there are a number of walls blocking the view of the
cameras that your spy can hide behind. You need to be able to determine if your spies will be seen
based on the position of the cameras, spies, and the walls in the room.
Problem Description
Your mission, should you choose to accept it, is to determine if there is a clear line of sight from a
camera at a given set of (𝑥, 𝑦) coordinates to a spy located at a different set of coordinates. Several
walls will be positioned throughout the room; if a wall intersects a line drawn between the camera and
the spy, the spy is hidden and avoids detection. You must write a program that checks if the spy is
successfully hidden and reports if he has been detected or not.
they were continued infinitely in both directions. Remember that a (non-vertical) line can be defined
using the equation
𝑦 = 𝑎𝑥 + 𝑐
(If 𝑥2 − 𝑥1 = 0, then 𝑎 is undefined, and the line is vertical.) Once you know 𝑎, you can calculate 𝑐 using
it and the (𝑥, 𝑦) coordinates of one of the points on the line:
𝑐 = 𝑦 − 𝑎𝑥
of their
line equations. You can then use both equations to calculate the (𝑥, 𝑦) point at which the lines would
intersect. If this point is within the bounds of the points you already knew about, then the wall is
Sample Input
received from the standard input channel, will contain a
positive integer representing the number of test cases. Each test case will include the following lines
of input:
• A line containing five integers separated by spaces, representing the following information, in
order:
o The X-coordinate of the spy within the current room
o The Y-coordinate of the spy within the current room
o The X-coordinate of the camera within the current room
o The Y-coordinate of the camera within the current room
o The number of walls in the current room, W
• W lines containing four integers separated by spaces, each line representing information about
a wall within the room:
o The X-coordinate of the start of the wall
o The Y-coordinate of the start of the wall
o The X-coordinate of the end of the wall
2 o The Y-coordinate of the end of the wall
2 2 6 4 1
2 5 5 5
2 2 6 4 2
4 1 4 5 Sample Output
For each test case, your program must output a single line
YES
NO
Sample Question 9
o
o
•
o
•
Sample Question 9 - Continued
•
•
•
o
o
o
o
•
o
o
o
o
2
2
a * b + c
2 ^ 2 ^ 3
3
( a - b ) * c / d + e / f
( ( a + b ) - ( c - d ) ^ x ) + q * w
A + B * C - D
a b * c +
2 2 3 ^ ^
a b - c * d / e f / +
a b + c d - x ^ - q w * +
A B C * + D -