Problem «Even indices»
StatementGiven a list of numbers, find and print all the list elements with an even index number. (i.e.
Problem «Even elements»
StatementGiven a list of numbers, find and print all elements that are an even number. In this case use a for-loop that iterates over the list, and not over its indices! That is, don't use
Problem «Greater than previous»
StatementGiven a list of numbers, find and print all the elements that are greater than the previous element.
Problem «Neighbors of the same sign»
StatementGiven a list of numbers, find and print the first adjacent elements which have the same sign. If there is no such pair, leave the output blank.
Problem «Greater than neighbours»
StatementGiven a list of numbers, determine and print the quantity of elements that are greater than both of their neighbors.
The first and the last items of the list shouldn't be considered because they don't have two neighbors.
Problem «The largest element»
StatementGiven a list of numbers. Determine the element in the list with the largest value. Print the value of the largest element and then the index number. If the highest element is not unique, print the index of the first instance.
Problem «The number of distinct elements»
StatementGiven a list of numbers with all of its elements sorted in ascending order, determine and print the quantity of distinct elements in it.
Problem «Swap neighbours»
StatementGiven a list of numbers, swap adjacent items in pairs (
A, etc.). Print the resulting list. If a list has an odd number of elements, leave the last element in place.
Problem «Swap min and max»
StatementGiven a list of unique numbers, swap the minimal and maximal elements of this list. Print the resulting list.
Problem «The number of pairs of equal»
StatementGiven a list of numbers, count how many element pairs have the same value (are equal). Any two elements that are equal to each other should be counted exactly once.
Problem «Unique elements»
StatementGiven a list of numbers, find and print the elements that appear in the list only once. The elements must be printed in the order in which they occur in the original list.
StatementIn chess it is known that it is possible to place 8 queens on an 8×8 chess board such that none of them can attack another. Given a placement of 8 queens on the board, determine if there is a pair of queens that can attach each other on the next move. Print the word
NOif no queen can attack another, otherwise print
YES. The input consists of eight coordinate pairs, one pair per line, with each pair giving the position of a queen on a standard chess board with rows and columns numbered starting at 1.
Problem «The bowling alley»
StatementIn bowling, the player starts wtih 10 pins at the far end of a lane. The object is to knock all the pins down. For this exercise, the number of pins and balls will vary. Given the number of pins N and then the number of balls K to be rolled, followed by K pairs of numbers (one for each ball rolled), determine which pins remain standing after all the balls have been rolled. The balls are numbered from 1 to N (inclusive) for this situation. The subsequent number pairs, one for each K represent the start to stop (inclusive) positions of the pins that were knocked down with each role. Print a sequence of N characters, where
"I"represents a pin left standing and
"."represents a pin knocked down.