├── .gitignore ├── README.md ├── lessons ├── 00_introduction.html ├── 10_inout.html ├── 140_sets.html ├── 150_dicts.html ├── 15_formatted_output.html ├── 20_ifelse.html ├── 300_js.html ├── 30_int_and_float.html ├── 40_for.html ├── 50_str.html ├── 60_while.html ├── 70_lists.html ├── 80_functions.html ├── 90_2d_arrays.html ├── __init__.py └── steps │ ├── __init__.py │ ├── for_loop_range.py │ ├── functions.py │ ├── if_then_else_conditions.py │ ├── integer_float_numbers.py │ ├── lists.py │ ├── print_input_numbers.py │ ├── strings_str.py │ ├── two_dimensional_lists_arrays.py │ └── while_loop.py └── problems ├── 2d_arrays ├── 2d_max.txt ├── chessboard.txt ├── diagonals.txt ├── matrix_multiply.txt ├── scale_matrix.txt ├── secondary_diagonal.txt ├── snowflake.txt └── swap_columns.txt ├── aplusb_wrong.py ├── aplusbplusc.txt ├── aplusbplusc_solution.py ├── apples.txt ├── area_of_right_triangle.txt ├── desks.txt ├── dicts ├── accent_test.txt ├── bank_accounts.txt ├── countries_and_cities.txt ├── english_latin_dict.txt ├── frequency_analysis.txt ├── genealogy_ancestors_and_descendants.txt ├── genealogy_descendants_count.txt ├── genealogy_lca.txt ├── genealogy_level_count.txt ├── most_frequent_word.txt ├── occurency_index.txt ├── permissions.txt ├── sales.txt ├── synonym_dictionary.txt ├── usa_elections.txt └── usa_elections_2.txt ├── electronic_watch.txt ├── for ├── factorial.txt ├── how_many_zeroes.txt ├── ladder.txt ├── lost_card.txt ├── series_1.txt ├── series_2.txt ├── series_3.txt ├── sum_of_cubes.txt ├── sum_of_factorials.txt ├── sum_of_n_numbers.txt └── sum_of_ten_numbers.txt ├── functions ├── capitalize.txt ├── fibonacci_rec.txt ├── length_of_segment.txt ├── negative_power.txt ├── power_rec.txt └── reverse_rec.txt ├── hello_harry.txt ├── ifelse ├── bishop_move.txt ├── chess_board.txt ├── chocolate.txt ├── jacob_the_swimmer.txt ├── king_move.txt ├── knight_move.txt ├── leap_year.txt ├── minimum.txt ├── minimum3.txt ├── num_equal.txt ├── queen_move.txt ├── rook_move.txt └── signum.txt ├── int_and_float ├── compound_interest.txt ├── digit_after_separator.txt ├── fractional_part.txt ├── last_digit.txt ├── motor_rally.txt ├── percents.txt ├── purchase_price.txt ├── russian_round.txt ├── sum_of_digits.txt ├── tens_digit.txt ├── watch_1.txt ├── watch_2.txt └── watch_3.txt ├── lists ├── even_elements.txt ├── even_indices.txt ├── increasing_neighbours.txt ├── insert_element.txt ├── kegelbahn.txt ├── maximal_element.txt ├── more_than_neighbours.txt ├── num_distinct.txt ├── num_equal_pairs.txt ├── queens.txt ├── remove_element.txt ├── same_sign_neighbours.txt ├── sherenga.txt ├── swap_min_and_max.txt ├── swap_neighbours.txt └── unique_elements.txt ├── next_and_previous.txt ├── rect_triangle_square.txt ├── sets ├── cubes.txt ├── guess_number.txt ├── guess_number_2.txt ├── number_of_coincidental.txt ├── number_of_unique.txt ├── number_of_words.txt ├── occurs_before.txt ├── polyglotes.txt ├── sets_intersection.txt └── strikes.txt ├── str ├── delete_char.txt ├── delete_chunk.txt ├── delete_every_third_char.txt ├── first_and_last_occurences.txt ├── num_words.txt ├── replace_in_chunk.txt ├── replace_substring.txt ├── reverse_chunk.txt ├── second_occurence.txt ├── slices.txt ├── swap_two_words.txt └── two_halves.txt └── while ├── bank_percents.txt ├── is_fibonacci.txt ├── kth_fibonacci.txt ├── list_of_squares.txt ├── minimal_divisor.txt ├── powers_of_two.txt ├── running.txt ├── seq_avg.txt ├── seq_increasing_neighbours.txt ├── seq_index_of_max.txt ├── seq_len.txt ├── seq_max.txt ├── seq_max_chunk_of_repetitions.txt ├── seq_num_even.txt ├── seq_num_maximal.txt ├── seq_second_max.txt ├── seq_sum.txt └── std_dev.txt /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Foreword 2 | --- 3 | 4 | This is the content of the website https://snakify.org/. Please, suggest corrections wherever you see grammar mistakes, bad wording, unclear sentences and such. I’ll sync the website based on corrections here. Thanks! 5 | 6 | Authors: Denis Kirienko, Vitaly Pavlenko, Alexander Garkusha 7 | 8 | License 9 | --- 10 | 11 | This content is licensed under the Creative Commons Attribution Non-Commercial Share-alike License (http://creativecommons.org/licenses/by-nc-sa/4.0/), which means you may share and adapt this material for non-commercial uses as long as you attribute its original source, and retain these same licensing terms. 12 | -------------------------------------------------------------------------------- /lessons/10_inout.html: -------------------------------------------------------------------------------- 1 | {% section "How to read and write in Python" %} 2 | 3 |

4 | Every program is eventually a data processor, so we should know how to input and output data within it. There exists a function, print(), to output data from any Python program. 5 | To use it, pass a comma separated list of arguments 6 | that you want to print to the print() function. 7 | Let's see an example. Press "run" and then "next" to see how the program 8 | is being executed line by line: 9 | 10 | {% program %} 11 | print(5 + 10) 12 | print(3 * 7, (17 - 2) * 8) 13 | print(2 ** 16) # two stars are used for exponentiation (2 to the power of 16) 14 | print(37 / 3) # single forward slash is a division 15 | print(37 // 3) # double forward slash is an integer division 16 | # it returns only the quotient of the division (i.e. no remainder) 17 | print(37 % 3) # percent sign is a modulus operator 18 | # it gives the remainder of the left value divided by the right value 19 | {% endprogram %} 20 |

21 | 22 |

23 | To input data into a program, we use input(). This function reads a single line of text, as a String. 24 |

25 | 26 |

27 | Here's a program that reads the user's name and greets them: 28 | {% program %} 29 | print('What is your name?') 30 | name = input() # read a single line and store it in the variable "name" 31 | print('Hi ' + name + '!') 32 | {% inputdata %} 33 | John 34 | {% endinputdata %} 35 | {% endprogram %} 36 |

37 | 38 | {% endsection %} 39 | 40 | 41 | 42 | {% section "Sum of numbers and strings" %} 43 | 44 |

45 | Let's try to write a program that inputs two numbers and prints their sum. We read the two numbers 46 | and store them in the variables a and b using the assignment operator =. 47 | On the left side of an assignment operator we put the name of the variable. The name could be a string of latin characters (A-Z, a-z, 0-9, _) 48 | but must start with a letter in the range A-Z or a-z. 49 | On the right side of an assignment operator we put any expression that Python can evaluate. 50 | The name starts pointing to the result of the evaluation. 51 | Read this example, run it and look at the output: 52 | {% program %} 53 | a = input() 54 | b = input() 55 | s = a + b 56 | print(s) 57 | {% inputdata %} 58 | 5 59 | 7 60 | {% endinputdata %} 61 | {% endprogram %} 62 |

63 | 64 |

65 | After running the example we can see that it prints 57. As we were taught in school, 66 | 5 + 7 gives 12. So, the program is wrong, and it's important to understand why. 67 | The thing is, in the third line s = a + b Python has "summed" two strings, rather than two numbers. 68 | The sum of two strings in Python works as follows: they are just glued one after another. It's also sometimes 69 | called "string concatenation". 70 |

71 | 72 |

73 | Do you see in the variable inspector, on the right hand side, that the values bound to variables a and b 74 | are wrapped in quotes? That means that the values there are string, not numbers. Strings and numbers 75 | are represented in Python differently. 76 |

77 | 78 |

79 | All the values in Python are called "objects". Every object has a certain type. The number 2 corresponds to an object "number 2" of type "int" 80 | (i.e., an integer number). The string 'hello' corresponds to an object "string 'hello'" of type "str". 81 | Every floating-point number is represented as an object of type "float". The type 82 | of an object specifies what kind of operations may be applied to it. 83 | For instance, if the two variables "first" and "second" are pointing to the objects of type int, Python can multiply them. However, if they are pointing to the objects of type str, Python can't do that: 84 | {% program %} 85 | first = 5 86 | second = 7 87 | print(first * second) 88 | 89 | # you can use single or double quotes to define a string 90 | first = '5' 91 | second = "7" 92 | print(first * second) 93 | {% endprogram %} 94 |

95 | 96 |

97 | To cast (convert) the string of digits into an integer number, we can use the function int(). For example, int('23') gives an int object with value 23. 98 |

99 | 100 |

101 | Given the information above, we can now fix the incorrect output and output the sum of the two numbers correctly: 102 | {% program %} 103 | a = int(input()) 104 | b = int(input()) 105 | s = a + b 106 | print(s) 107 | {% inputdata %} 108 | 5 109 | 7 110 | {% endinputdata %} 111 | {% endprogram %} 112 |

113 | 114 | {% endsection %} 115 | -------------------------------------------------------------------------------- /lessons/15_formatted_output.html: -------------------------------------------------------------------------------- 1 | {% section "How to read and write in Python" %} 2 | 3 |

4 | Every program is eventually a data processor, so we should know how to input data 5 | into it and how to output them. There's a function print() to output data from Python program. 6 | To use it, fill in its parentheses with a comma-separated list of the values 7 | that you want to print. Let's see an example. Press "run" and then "next" to see how the program 8 | is being executed line by line: 9 | 10 | {% program %} 11 | print(5 + 10) 12 | print(3 * 7, (17 - 2) * 8) 13 | print(2 ** 16) # two stars are used for exponentiation 14 | print(37 / 3) # single forward slash is a division 15 | print(37 // 3) # double forward slash is an integer division 16 | print(37 % 3) # percent sign is a modulus operator 17 | # it gives the remainder of the left value divided by the right value 18 | {% endprogram %} 19 |

20 | 21 |

22 | Use the function input() to input data into the program. This function reads a single text line as a string. 23 |

24 | 25 |

26 | Here's a program that reads the user's name and greets him: 27 | {% program %} 28 | print('What is your name?') 29 | name = input() # read a single line and store it in the variable "name" 30 | print('Hi ' + name + '!') 31 | {% inputdata %} 32 | John 33 | {% endinputdata %} 34 | {% endprogram %} 35 |

36 | 37 | {% endsection %} 38 | 39 | 40 | 41 | {% section "Sum of numbers and strings" %} 42 | 43 |

44 | Let's try to write a program that inputs two numbers and prints their sum. We read the two numbers 45 | and store them in the variables a and b using the assignment operator =. 46 | On the left side of an assignment operator we put the name of the variable. The name could be a string of latin characters. 47 | On the right side of an assignment operator we put any expression that Python can evaluate. 48 | The name starts pointing to the result of the evaluation. 49 | Read this example, run it and look at its output: 50 | {% program %} 51 | a = input() 52 | b = input() 53 | s = a + b 54 | print(s) 55 | {% inputdata %} 56 | 5 57 | 7 58 | {% endinputdata %} 59 | {% endprogram %} 60 |

61 | 62 |

63 | After running the example we can see that it prints 57. As we were taught in school, 64 | 5 + 7 gives 12. So, the program is wrong, and it's important to understand why. 65 | The thing is, in the third line s = a + b Python has "summed" two strings, rather than two numbers. 66 | The sum of two strings in Python works as follows: they are just glued one after another. It's also sometimes 67 | called "string concatenation". 68 |

69 | 70 |

71 | Do you see in the right side that the values bound to variables a and b 72 | are wrapped in quotes? That means that the values there are string, not numbers. Strings and values 73 | are represented in Python differently. 74 |

75 | 76 |

77 | All the values in Python are called "objects". Every object has a certain type. The number 2 corresponds to an object "number 2" of type "int" 78 | (i.e., an integer number). The string 'hello' corresponds to an object "string 'hello'" of type "str". 79 | Every floating-point number is represented as an object of type "float". The type 80 | of an object specifies what kind of operations may be applied to it. 81 | For instance, if the two variables "first" and "second" are pointing to the objects of type int, Python can multiply them. However, if they are pointing to the objects of type str, Python can't do that: 82 | {% program %} 83 | first = 5 84 | second = 7 85 | print(first * second) 86 | 87 | # you can use single or double quotes to define a string 88 | first = '5' 89 | second = "7" 90 | print(first * second) 91 | {% endprogram %} 92 |

93 | 94 |

95 | To cast the string of digits into an integer number, we can use the function int(). Eg., int('23') gives an int object 23. 96 |

97 | 98 |

99 | Given the information above, we can now fix our wrong program to sum the two numbers: 100 | {% program %} 101 | a = int(input()) 102 | b = int(input()) 103 | s = a + b 104 | print(s) 105 | {% inputdata %} 106 | 5 107 | 7 108 | {% endinputdata %} 109 | {% endprogram %} 110 |

111 | 112 | {% endsection %} -------------------------------------------------------------------------------- /lessons/300_js.html: -------------------------------------------------------------------------------- 1 | {% section "JavaScript" %} 2 |

Our site now supports JavaScript. 3 | The code editor now has an indicator in the top right corner showing which language you are using: Python or JavaScript 4 | You can change language by pressing corresponding button on the top panel. 5 | Currently this feature is only present in problems and on some other pages including this one.

6 | 7 |

In your code you can use all features of JavaScript that you are used to, but for the sake of convenience we added two functions that you need to use to read input and write output. 8 | They are called input() and print. They work as simplified variants of Python 3 functions.

9 | 10 |

Here is a little example. This program reads string from input and prints it with preceding "Simon says: ". 11 | Try it out:

12 | 13 | {#

#} 14 | {##} 15 | {% jsprogram %} 16 | // First, we create a variable and read string from input 17 | var string = input(); // 18 | 19 | // Then we print the concatination of "Simon says: " and our variable using + operator 20 | print("Simon says: " + string); 21 | {% inputdata %} 22 | jump 23 | {% endinputdata %} 24 | {% endjsprogram %} 25 | 26 |

And here is a program that sums three numbers from input:

27 | 28 | {% jsprogram %} 29 | var a = parseInt(input()); 30 | var b = parseInt(input()); 31 | var c = parseInt(input()); 32 | print(a + b + c); 33 | {% inputdata %} 34 | 1 35 | 3 36 | 6 37 | {% endinputdata %} 38 | {% endjsprogram %} 39 | 40 |

Of course you can define functions in your programs. Here is that previous example but with function:

41 | 42 | {% jsprogram %} 43 | function sum3(a, b, c) { 44 | return a + b + c; 45 | } 46 | 47 | var a = parseInt(input()); 48 | var b = parseInt(input()); 49 | var c = parseInt(input()); 50 | print(sum3(a, b, c)); 51 | {% inputdata %} 52 | 1 53 | 3 54 | 6 55 | {% endinputdata %} 56 | {% endjsprogram %} 57 | 58 |

You can solve any problem from the huge set on our site using JavaScript. For example, you can start from 59 | "Apple sharing" or "Sign function".

60 | 61 | {% endsection %} -------------------------------------------------------------------------------- /lessons/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vpavlenko/content/0e8bab83f6a74a341e582dc6fe60779213d03399/lessons/__init__.py -------------------------------------------------------------------------------- /lessons/steps/__init__.py: -------------------------------------------------------------------------------- 1 | from . import print_input_numbers 2 | from . import if_then_else_conditions 3 | from . import integer_float_numbers 4 | from . import for_loop_range 5 | from . import strings_str 6 | from . import while_loop 7 | from . import lists 8 | from . import functions 9 | from . import two_dimensional_lists_arrays 10 | -------------------------------------------------------------------------------- /problems/2d_arrays/2d_max.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Maximum 3 | 4 | Statement: 5 |

Given two integers representing the rows and columns \( \left ( m \times n \right ) \), and subsequent \( m \) rows of \( n \) elements, find the index position of the maximum element and print two numbers representing the index \( \left ( i \times j \right ) \) or the row number and the column number. If there exist multiple such elements in different rows, print the one with smaller row number. If there multiple such elements occur on the same row, output the smallest column number. 6 | 7 | 8 | Test: 9 | 3 4 10 | 0 3 2 4 11 | 2 3 5 5 12 | 5 1 2 3 13 | 14 | Answer: 15 | 1 2 16 | 17 | 18 | Test: 19 | 1 1 20 | 1 21 | 22 | 23 | Answer: 24 | 0 0 25 | 26 | 27 | Test: 28 | 3 5 29 | 1 2 3 4 5 30 | 6 7 8 9 10 31 | 11 12 13 14 15 32 | 33 | Answer: 34 | 2 4 35 | 36 | 37 | Test: 38 | 6 1 39 | 1 40 | 2 41 | 3 42 | 2 43 | 1 44 | 2 45 | 46 | 47 | Answer: 48 | 2 0 49 | 50 | 51 | Test: 52 | 1 6 53 | 1 2 3 3 2 1 54 | 55 | Answer: 56 | 0 2 57 | 58 | 59 | Test: 60 | 3 5 61 | 1 4 5 2 7 62 | 3 4 8 0 8 63 | 8 8 8 8 8 64 | 65 | Answer: 66 | 1 2 67 | 68 | 69 | Test: 70 | 2 2 71 | -3 -2 72 | -2 -1 73 | 74 | Answer: 75 | 1 1 76 | 77 | 78 | Test: 79 | 2 2 80 | -1000000003 -1000000002 81 | -1000000002 -1000000001 82 | 83 | Answer: 84 | 1 1 85 | 86 | -------------------------------------------------------------------------------- /problems/2d_arrays/chessboard.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Chess board 3 | 4 | Statement: 5 |

Given two numbers \( n \) and \( m \). Create a two-dimensional array of size \( \left ( n \times m \right ) \) and populate it with the characters "." and "*" in a checkerboard pattern. The top left corner should have the character "." . 6 | 7 | Test: 8 | 3 4 9 | 10 | Answer: 11 | . * . * 12 | * . * . 13 | . * . * 14 | 15 | 16 | Test: 17 | 6 8 18 | 19 | Answer: 20 | . * . * . * . * 21 | * . * . * . * . 22 | . * . * . * . * 23 | * . * . * . * . 24 | . * . * . * . * 25 | * . * . * . * . 26 | 27 | 28 | Test: 29 | 8 3 30 | 31 | Answer: 32 | . * . 33 | * . * 34 | . * . 35 | * . * 36 | . * . 37 | * . * 38 | . * . 39 | * . * 40 | 41 | 42 | Test: 43 | 7 5 44 | 45 | Answer: 46 | . * . * . 47 | * . * . * 48 | . * . * . 49 | * . * . * 50 | . * . * . 51 | * . * . * 52 | . * . * . 53 | 54 | 55 | Test: 56 | 1 6 57 | 58 | Answer: 59 | . * . * . * 60 | 61 | 62 | Test: 63 | 8 1 64 | 65 | Answer: 66 | . 67 | * 68 | . 69 | * 70 | . 71 | * 72 | . 73 | * 74 | 75 | 76 | Test: 77 | 1 1 78 | 79 | Answer: 80 | . -------------------------------------------------------------------------------- /problems/2d_arrays/diagonals.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The diagonal parallel to the main 3 | 4 | Statement: 5 |

Given an integer \( n \), produce a two-dimensional array of size \( \left ( n \times n \right ) \) and complete it according to the following rules, and print with a single space between characters: 6 |

11 | 12 |

Print the elements of the resulting array. 13 | 14 | Test: 15 | 5 16 | 17 | Answer: 18 | 0 1 2 3 4 19 | 1 0 1 2 3 20 | 2 1 0 1 2 21 | 3 2 1 0 1 22 | 4 3 2 1 0 23 | 24 | 25 | Test: 26 | 6 27 | 28 | Answer: 29 | 0 1 2 3 4 5 30 | 1 0 1 2 3 4 31 | 2 1 0 1 2 3 32 | 3 2 1 0 1 2 33 | 4 3 2 1 0 1 34 | 5 4 3 2 1 0 35 | 36 | 37 | Test: 38 | 7 39 | 40 | Answer: 41 | 0 1 2 3 4 5 6 42 | 1 0 1 2 3 4 5 43 | 2 1 0 1 2 3 4 44 | 3 2 1 0 1 2 3 45 | 4 3 2 1 0 1 2 46 | 5 4 3 2 1 0 1 47 | 6 5 4 3 2 1 0 48 | 49 | 50 | Test: 51 | 4 52 | 53 | Answer: 54 | 0 1 2 3 55 | 1 0 1 2 56 | 2 1 0 1 57 | 3 2 1 0 58 | 59 | 60 | Test: 61 | 3 62 | 63 | Answer: 64 | 0 1 2 65 | 1 0 1 66 | 2 1 0 67 | 68 | 69 | Test: 70 | 2 71 | 72 | Answer: 73 | 0 1 74 | 1 0 75 | 76 | 77 | Test: 78 | 1 79 | 80 | Answer: 81 | 0 -------------------------------------------------------------------------------- /problems/2d_arrays/matrix_multiply.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Multiply two matrices 3 | 4 | Statement: 5 |

Given three positive integers \( m \), \( n \) and \( r \), 6 | \( m \) lines of \( n \) elements, giving an \( m \times n \) matrix \( A \), and 7 | \( n \) lines of \( r \) elements, giving an \( n \times r \) matrix \( B \), 8 | form the product matrix \( A B \), which is the \( m \times r \) matrix 9 | whose \( (i,k) \) entry is the sum 10 | 11 | $$ A[i][1] * B[1][k] + \cdots + A[i][n] * B[n][k] $$ 12 | 13 | and print the result. 14 | 15 | 16 | Test: 17 | 3 4 2 18 | 0 1 2 3 19 | 4 5 6 7 20 | 8 9 10 11 21 | 2 3 22 | 0 4 23 | 5 -1 24 | 1 1 25 | 26 | Answer: 27 | 13 5 28 | 45 33 29 | 77 61 30 | 31 | 32 | Test: 33 | 2 2 2 34 | 1 2 35 | 3 4 36 | 5 4 37 | 3 2 38 | 39 | Answer: 40 | 11 8 41 | 27 20 42 | 43 | 44 | Test: 45 | 1 1 1 46 | 5 47 | 7 48 | 49 | Answer: 50 | 35 51 | 52 | 53 | Test: 54 | 4 3 1 55 | 1 2 3 56 | 4 5 6 57 | 7 8 9 58 | 10 11 12 59 | 1 60 | 2 61 | 3 62 | 63 | Answer: 64 | 14 65 | 32 66 | 50 67 | 68 68 | -------------------------------------------------------------------------------- /problems/2d_arrays/scale_matrix.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Scale a matrix 3 | 4 | Statement: 5 |

Given two positive integers \( m \) and \( n \), 6 | \( m \) lines of \( n \) elements, giving an \( m \times n \) matrix \( A \), 7 | followed by one integer \( c \), 8 | multiply every entry of the matrix by \( c \) and print the result. 9 | 10 | Test: 11 | 3 4 12 | 11 12 13 14 13 | 21 22 23 24 14 | 31 32 33 34 15 | 2 16 | 17 | Answer: 18 | 22 24 26 28 19 | 42 44 46 48 20 | 62 64 66 68 21 | 22 | 23 | Test: 24 | 2 2 25 | 1 2 26 | 3 4 27 | 0 28 | 29 | Answer: 30 | 0 0 31 | 0 0 32 | 33 | 34 | Test: 35 | 10 1 36 | 1 37 | 2 38 | 3 39 | 4 40 | 5 41 | 6 42 | 7 43 | 8 44 | 9 45 | 10 46 | -1 47 | 48 | Answer: 49 | -1 50 | -2 51 | -3 52 | -4 53 | -5 54 | -6 55 | -7 56 | -8 57 | -9 58 | -10 59 | 60 | 61 | Test: 62 | 4 3 63 | 1 2 3 64 | 4 5 6 65 | 7 8 9 66 | 10 11 12 67 | 1 68 | 69 | Answer: 70 | 1 2 3 71 | 4 5 6 72 | 7 8 9 73 | 10 11 12 74 | 75 | 76 | Test: 77 | 1 1 78 | 9 79 | 9 80 | 81 | Answer: 82 | 81 83 | -------------------------------------------------------------------------------- /problems/2d_arrays/secondary_diagonal.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Side diagonal 3 | 4 | Statement: 5 |

Given an integer \( n \), create a two-dimensional array of size \( \left ( n \times n \right ) \) and populate it as follows, with spaces between each character: 6 |

11 | 12 |

Print the elements of the resulting array. 13 | 14 | Test: 15 | 4 16 | 17 | Answer: 18 | 0 0 0 1 19 | 0 0 1 2 20 | 0 1 2 2 21 | 1 2 2 2 22 | 23 | 24 | Test: 25 | 1 26 | 27 | Answer: 28 | 1 29 | 30 | 31 | Test: 32 | 2 33 | 34 | Answer: 35 | 0 1 36 | 1 2 37 | 38 | 39 | Test: 40 | 3 41 | 42 | Answer: 43 | 0 0 1 44 | 0 1 2 45 | 1 2 2 46 | 47 | 48 | Test: 49 | 5 50 | 51 | Answer: 52 | 0 0 0 0 1 53 | 0 0 0 1 2 54 | 0 0 1 2 2 55 | 0 1 2 2 2 56 | 1 2 2 2 2 57 | 58 | 59 | Test: 60 | 6 61 | 62 | Answer: 63 | 0 0 0 0 0 1 64 | 0 0 0 0 1 2 65 | 0 0 0 1 2 2 66 | 0 0 1 2 2 2 67 | 0 1 2 2 2 2 68 | 1 2 2 2 2 2 69 | 70 | 71 | Test: 72 | 7 73 | 74 | Answer: 75 | 0 0 0 0 0 0 1 76 | 0 0 0 0 0 1 2 77 | 0 0 0 0 1 2 2 78 | 0 0 0 1 2 2 2 79 | 0 0 1 2 2 2 2 80 | 0 1 2 2 2 2 2 81 | 1 2 2 2 2 2 2 82 | 83 | 84 | Test: 85 | 8 86 | 87 | Answer: 88 | 0 0 0 0 0 0 0 1 89 | 0 0 0 0 0 0 1 2 90 | 0 0 0 0 0 1 2 2 91 | 0 0 0 0 1 2 2 2 92 | 0 0 0 1 2 2 2 2 93 | 0 0 1 2 2 2 2 2 94 | 0 1 2 2 2 2 2 2 95 | 1 2 2 2 2 2 2 2 -------------------------------------------------------------------------------- /problems/2d_arrays/snowflake.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Snowflake 3 | 4 | Statement: 5 |

Given an odd number integer \( n \), produce a two-dimensional array of size \( \left ( n \times n \right ) \). Fill each element with a single character string of "." . Then fill the middle row, the middle column and the diagnals with the single character string of "*" (an image of a snow flake). Print the array elements in \( \left ( n \times n \right ) \) rows and columns and separate the characters with a single space. 6 | 7 | Test: 8 | 5 9 | 10 | Answer: 11 | * . * . * 12 | . * * * . 13 | * * * * * 14 | . * * * . 15 | * . * . * 16 | 17 | 18 | Test: 19 | 7 20 | 21 | Answer: 22 | * . . * . . * 23 | . * . * . * . 24 | . . * * * . . 25 | * * * * * * * 26 | . . * * * . . 27 | . * . * . * . 28 | * . . * . . * 29 | 30 | 31 | Test: 32 | 9 33 | 34 | Answer: 35 | * . . . * . . . * 36 | . * . . * . . * . 37 | . . * . * . * . . 38 | . . . * * * . . . 39 | * * * * * * * * * 40 | . . . * * * . . . 41 | . . * . * . * . . 42 | . * . . * . . * . 43 | * . . . * . . . * 44 | 45 | 46 | Test: 47 | 11 48 | 49 | Answer: 50 | * . . . . * . . . . * 51 | . * . . . * . . . * . 52 | . . * . . * . . * . . 53 | . . . * . * . * . . . 54 | . . . . * * * . . . . 55 | * * * * * * * * * * * 56 | . . . . * * * . . . . 57 | . . . * . * . * . . . 58 | . . * . . * . . * . . 59 | . * . . . * . . . * . 60 | * . . . . * . . . . * 61 | 62 | 63 | Test: 64 | 3 65 | 66 | Answer: 67 | * * * 68 | * * * 69 | * * * 70 | 71 | 72 | Test: 73 | 1 74 | 75 | Answer: 76 | * -------------------------------------------------------------------------------- /problems/2d_arrays/swap_columns.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Swap the columns 3 | 4 | Statement: 5 |

Given two positive integers \( m \) and \( n \), 6 | \( m \) lines of \( n \) elements, giving an \( m \times n \) matrix \( A \), 7 | followed by two non-negative integers \( i \) and \( j \) less than \( n \), 8 | swap columns \( i \) and \( j \) of \( A \) and print the result. 9 | 10 |

Write a function swap_columns(a, i, j) and call it to exchange the columns. 11 | 12 | Test: 13 | 3 4 14 | 11 12 13 14 15 | 21 22 23 24 16 | 31 32 33 34 17 | 0 1 18 | 19 | Answer: 20 | 12 11 13 14 21 | 22 21 23 24 22 | 32 31 33 34 23 | 24 | 25 | Test: 26 | 2 2 27 | 1 2 28 | 3 4 29 | 0 1 30 | 31 | Answer: 32 | 2 1 33 | 4 3 34 | 35 | 36 | Test: 37 | 10 1 38 | 1 39 | 2 40 | 3 41 | 4 42 | 5 43 | 6 44 | 7 45 | 8 46 | 9 47 | 10 48 | 0 0 49 | 50 | Answer: 51 | 1 52 | 2 53 | 3 54 | 4 55 | 5 56 | 6 57 | 7 58 | 8 59 | 9 60 | 10 61 | 62 | 63 | Test: 64 | 4 3 65 | 1 2 3 66 | 4 5 6 67 | 7 8 9 68 | 10 11 12 69 | 1 2 70 | 71 | Answer: 72 | 1 3 2 73 | 4 6 5 74 | 7 9 8 75 | 10 12 11 76 | 77 | 78 | Test: 79 | 1 5 80 | 1 2 3 4 5 81 | 1 4 82 | 83 | Answer: 84 | 1 5 3 4 2 85 | 86 | 87 | Test: 88 | 1 1 89 | 179 90 | 0 0 91 | 92 | Answer: 93 | 179 94 | 95 | 96 | Test: 97 | 4 6 98 | 11 12 13 14 15 16 99 | 21 22 23 24 25 26 100 | 31 32 33 34 35 36 101 | 41 42 43 44 45 46 102 | 0 5 103 | 104 | Answer: 105 | 16 12 13 14 15 11 106 | 26 22 23 24 25 21 107 | 36 32 33 34 35 31 108 | 46 42 43 44 45 41 109 | 110 | 111 | Test: 112 | 4 6 113 | 11 12 13 14 15 16 114 | 21 22 23 24 25 26 115 | 31 32 33 34 35 36 116 | 41 42 43 44 45 46 117 | 5 0 118 | 119 | Answer: 120 | 16 12 13 14 15 11 121 | 26 22 23 24 25 21 122 | 36 32 33 34 35 31 123 | 46 42 43 44 45 41 124 | 125 | 126 | Test: 127 | 4 6 128 | 11 12 13 14 15 16 129 | 21 22 23 24 25 26 130 | 31 32 33 34 35 36 131 | 41 42 43 44 45 46 132 | 4 5 133 | 134 | Answer: 135 | 11 12 13 14 16 15 136 | 21 22 23 24 26 25 137 | 31 32 33 34 36 35 138 | 41 42 43 44 46 45 139 | 140 | 141 | Test: 142 | 4 6 143 | 11 12 13 14 15 16 144 | 21 22 23 24 25 26 145 | 31 32 33 34 35 36 146 | 41 42 43 44 45 46 147 | 1 4 148 | 149 | Answer: 150 | 11 15 13 14 12 16 151 | 21 25 23 24 22 26 152 | 31 35 33 34 32 36 153 | 41 45 43 44 42 46 154 | 155 | 156 | Test: 157 | 4 6 158 | 11 12 13 14 15 16 159 | 21 22 23 24 25 26 160 | 31 32 33 34 35 36 161 | 41 42 43 44 45 46 162 | 3 3 163 | 164 | Answer: 165 | 11 12 13 14 15 16 166 | 21 22 23 24 25 26 167 | 31 32 33 34 35 36 168 | 41 42 43 44 45 46 169 | -------------------------------------------------------------------------------- /problems/aplusb_wrong.py: -------------------------------------------------------------------------------- 1 | a = input() 2 | b = input() 3 | c = input() 4 | s = a + b + c 5 | print(s) 6 | -------------------------------------------------------------------------------- /problems/aplusbplusc.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Sum of three numbers 3 | 4 | Statement: 5 | Write a program that takes three numbers and prints their sum. 6 | Every number is given on a separate line. 7 | 8 | Test: 9 | 2 10 | 3 11 | 6 12 | 13 | Answer: 14 | 11 15 | 16 | Test: 17 | 0 18 | 20 19 | 300 20 | 21 | Answer: 22 | 320 23 | 24 | Test: 25 | -5 26 | 180 27 | -17 28 | 29 | Answer: 30 | 158 31 | -------------------------------------------------------------------------------- /problems/aplusbplusc_solution.py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | b = int(input()) 3 | c = int(input()) 4 | s = a + b + c 5 | print(s) -------------------------------------------------------------------------------- /problems/apples.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Apple sharing 3 | 4 | Statement: 5 | N students take K apples and distribute them among each other evenly. The remaining (the undivisible) part remains in the basket. How many apples will each single student get? How many apples will remain in the basket? 6 |

7 | The program reads the numbers N and K. It should print the two answers for the questions above. 8 | 9 | Test: 10 | 6 11 | 50 12 | 13 | Answer: 14 | 8 15 | 2 16 | 17 | Test: 18 | 1 19 | 10 20 | 21 | Answer: 22 | 10 23 | 0 24 | 25 | Test: 26 | 5 27 | 25 28 | 29 | Answer: 30 | 5 31 | 0 32 | 33 | Test: 34 | 4 35 | 2 36 | 37 | Answer: 38 | 0 39 | 2 40 | -------------------------------------------------------------------------------- /problems/area_of_right_triangle.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Area of right-angled triangle 3 | 4 | Statement: 5 | Write a program that reads the length of the base and the height of a right-angled triangle and prints the area. 6 | Every number is given on a separate line. 7 | 8 | Test: 9 | 3 10 | 5 11 | 12 | Answer: 13 | 7.5 14 | 15 | Test: 16 | 10 17 | 2 18 | 19 | Answer: 20 | 10.0 21 | 22 | Test: 23 | 179 24 | 1534 25 | 26 | Answer: 27 | 137293.0 28 | 29 | Test: 30 | 1543 31 | 57 32 | 33 | Answer: 34 | 43975.5 35 | -------------------------------------------------------------------------------- /problems/desks.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | School desks 3 | 4 | Statement: 5 | A school decided to replace the desks in three classrooms. 6 | Each desk sits two students. Given the number of students in each class, print the smallest possible 7 | number of desks that can be purchased. 8 |

9 | The program should read three integers: the number of students in each of the three classes, a, b and c respectively. 10 | 11 |

In the first test there are three groups. The first group has 20 students and thus needs 10 desks. 12 | The second group has 21 students, so they can get by with no fewer than 11 desks. 11 desks is also enough 13 | for the third group of 22 students. So we need 32 desks in total. 14 | 15 | Test: 16 | 20 17 | 21 18 | 22 19 | 20 | Answer: 21 | 32 22 | 23 | Test: 24 | 1 25 | 1 26 | 1 27 | 28 | Answer: 29 | 3 30 | 31 | Test: 32 | 26 33 | 20 34 | 16 35 | 36 | Answer: 37 | 31 38 | 39 | Test: 40 | 25 41 | 21 42 | 23 43 | 44 | Answer: 45 | 36 46 | 47 | Test: 48 | 17 49 | 19 50 | 18 51 | 52 | Answer: 53 | 28 54 | -------------------------------------------------------------------------------- /problems/dicts/accent_test.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Контрольная по ударениям 3 | 4 | Statement: 5 |

Учительница задала Пете домашнее задание — в заданном тексте расставить ударения в словах, 6 | после чего поручила Васе проверить это домашнее задание. Вася очень плохо знаком с данной темой, 7 | поэтому он нашел словарь, в котором указано, как ставятся ударения в словах. К сожалению, 8 | в этом словаре присутствуют не все слова. Вася решил, что в словах, которых нет в словаре, 9 | он будет считать, что Петя поставил ударения правильно, если в этом слове Петей поставлено ровно одно ударение.

10 | 11 |

Оказалось, что в некоторых словах ударение может быть поставлено больше, чем одним способом. 12 | Вася решил, что в этом случае если то, как Петя поставил ударение, соответствует одному из приведенных 13 | в словаре вариантов, он будет засчитывать это как правильную расстановку ударения, а если не соответствует, то как ошибку.

14 | 15 |

Вам дан словарь, которым пользовался Вася и домашнее задание, сданное Петей. Ваша задача — определить количество ошибок, 16 | которое в этом задании насчитает Вася.

17 | 18 |

19 | Вводится сначала число N — количество слов в словаре. 20 |

21 | Далее идет N строк со словами из словаря. Каждое слово состоит не более чем из 30 символов. Все 22 | слова состоят из маленьких и заглавных латинских букв. В каждом слове заглавная ровно одна буква — 23 | та, на которую попадает ударение. Слова в словаре расположены в алфавитном порядке. Если есть 24 | несколько возможностей расстановки ударения в одном и том же слове, то эти варианты в словаре идут в 25 | произвольном порядке. 26 |

27 | Далее идет упражнение, выполненное Петей. Упражнение представляет собой строку текста, суммарным 28 | объемом не более 300000 символов. Строка состоит из слов, которые разделяются между собой ровно 29 | одним пробелом. Длина каждого слова не превышает 30 символов. Все слова состоят из маленьких и 30 | заглавных латинских букв (заглавными обозначены те буквы, над которыми Петя поставил ударение). Петя 31 | мог по ошибке в каком-то слове поставить более одного ударения или не поставить ударения вовсе. 32 |

33 | 34 |

35 | Выведите количество ошибок в Петином тексте, которые найдет Вася. 36 |

37 | 38 |

39 | Примечания к примерам тестов 40 |

41 | 1. В слове cannot, согласно словарю возможно два варианта расстановки ударения. Эти варианты в 42 | словаре могут быть перечислены в любом порядке (т.е. как сначала cAnnot, а потом cannOt, так и 43 | наоборот). 44 | Две ошибки, совершенные Петей — это слова be (ударение вообще не поставлено) и fouNd (ударение 45 | поставлено неверно). Слово thE отсутствует в словаре, но поскольку в нем Петя поставил ровно одно 46 | ударение, признается верным. 47 |

48 | 2. Неверно расставлены ударения во всех словах, кроме The (оно отсутствует в словаре, в нем 49 | поставлено ровно одно ударение). В остальных словах либо ударные все буквы (в слове PAGE), либо не 50 | поставлено ни одного ударения. 51 |

52 | 53 | Test: 54 | 4 55 | cAnnot 56 | cannOt 57 | fOund 58 | pAge 59 | thE pAge cAnnot be found 60 | 61 | Answer: 62 | 2 63 | 64 | 65 | Test: 66 | 4 67 | cAnnot 68 | cannOt 69 | fOund 70 | pAge 71 | The PAGE cannot be found 72 | 73 | Answer: 74 | 4 75 | 76 | 77 | Test: 78 | 1 79 | M 80 | M 81 | 82 | Answer: 83 | 0 84 | 85 | 86 | Test: 87 | 2 88 | Xu 89 | xU 90 | NJ xu xU xu 91 | 92 | Answer: 93 | 3 94 | 95 | 96 | Test: 97 | 5 98 | gSn 99 | gsN 100 | qY 101 | rkZ 102 | rKz 103 | qy dr DH y Y qy rKz 104 | 105 | Answer: 106 | 5 107 | 108 | 109 | Test: 110 | 5 111 | nPa 112 | Oc 113 | oC 114 | pT 115 | zjU 116 | Qp Gt oC oG l oc oc 117 | 118 | Answer: 119 | 3 120 | 121 | 122 | Test: 123 | 5 124 | aZqz 125 | Azqz 126 | lyAi 127 | lYai 128 | zN 129 | xfm Zn frs lyai azqz 130 | 131 | Answer: 132 | 5 133 | 134 | 135 | Test: 136 | 10 137 | chN 138 | lXp 139 | Lxp 140 | lxP 141 | qXe 142 | Qxe 143 | qxE 144 | uDb 145 | udB 146 | vezV 147 | chn jkn bz j UDb Qxe udb qxE szk Lxp udb chn qXe cx 148 | 149 | Answer: 150 | 10 151 | 152 | 153 | Test: 154 | 10 155 | De 156 | iKq 157 | ikQ 158 | lL 159 | Mea 160 | meA 161 | uDb 162 | X 163 | zA 164 | Za 165 | IKq H mea qc ln Udb udb lL jr pE X ul Yc ikQ dE dE 166 | 167 | Answer: 168 | 10 169 | 170 | -------------------------------------------------------------------------------- /problems/dicts/bank_accounts.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Банковские счета 3 | 4 | Statement: 5 |

Некоторый банк хочет внедрить систему управления счетами клиентов, поддерживающую 6 | следующие операции:

7 | 8 |
    9 |
  1. Пополнение счета клиента. 10 |
  2. Снятие денег со счета. 11 |
  3. Запрос остатка средств на счете. 12 |
  4. Перевод денег между счетами клиентов. 13 |
  5. Начисление процентов всем клиентам. 14 |
15 | 16 |

Вам необходимо реализовать такую систему. Клиенты банка идентифицируются именами (уникальная строка, не содержащая 17 | пробелов). Первоначально у банка нет ни одного клиента. Как только для клиента проводится операция пололнения, 18 | снятия или перевода денег, ему заводится счет с нулевым балансом. Все дальнейшие операции проводятся только 19 | с этим счетом. Сумма на счету может быть как положительной, так и отрицательной, при этом всегда является целым числом.

20 | 21 |

22 | Входной файл содержит последовательность операций. Возможны следующие операции: 23 |

24 | DEPOSIT name sum - зачислить сумму sum на счет клиента name. Если у клиента нет счета, то счет 25 | создается. 26 |

27 | WITHDRAW name sum - снять сумму sum со счета клиента name. Если у клиента нет счета, то счет 28 | создается. 29 |

30 | BALANCE name - узнать остаток средств на счету клиента name. 31 |

32 | TRANSFER name1 name2 sum - перевести сумму sum со счета клиента name1 на счет клиента name2. Если у 33 | какого-либо клиента нет счета, то ему создается счет. 34 |

35 | INCOME p - начислить всем клиентам, у которых открыты счета, p% от суммы счета. Проценты начисляются 36 | только клиентам с положительным остатком на счету, если у клиента остаток отрицательный, то его счет 37 | не меняется. После начисления процентов сумма на счету остается целой, то есть начисляется только 38 | целое число денежных единиц. Дробная часть начисленных процентов отбрасывается. 39 |

40 | 41 |

42 | Для каждого запроса BALANCE программа должна вывести остаток на счету данного клиента. Если же у 43 | клиента с запрашиваемым именем не открыт счет в банке, выведите ERROR. 44 |

45 | 46 | Test: 47 | DEPOSIT Ivanov 100 48 | INCOME 5 49 | BALANCE Ivanov 50 | TRANSFER Ivanov Petrov 50 51 | WITHDRAW Petrov 100 52 | BALANCE Petrov 53 | BALANCE Sidorov 54 | 55 | Answer: 56 | 105 57 | -50 58 | ERROR 59 | 60 | 61 | Test: 62 | BALANCE Ivanov 63 | BALANCE Petrov 64 | DEPOSIT Ivanov 100 65 | BALANCE Ivanov 66 | BALANCE Petrov 67 | DEPOSIT Petrov 150 68 | BALANCE Petrov 69 | DEPOSIT Ivanov 10 70 | DEPOSIT Petrov 15 71 | BALANCE Ivanov 72 | BALANCE Petrov 73 | DEPOSIT Ivanov 46 74 | BALANCE Ivanov 75 | BALANCE Petrov 76 | DEPOSIT Petrov 14 77 | BALANCE Ivanov 78 | BALANCE Petrov 79 | 80 | Answer: 81 | ERROR 82 | ERROR 83 | 100 84 | ERROR 85 | 150 86 | 110 87 | 165 88 | 156 89 | 165 90 | 156 91 | 179 92 | 93 | 94 | Test: 95 | BALANCE a 96 | BALANCE b 97 | DEPOSIT a 100 98 | BALANCE a 99 | BALANCE b 100 | WITHDRAW a 20 101 | BALANCE a 102 | BALANCE b 103 | WITHDRAW b 78 104 | BALANCE a 105 | BALANCE b 106 | WITHDRAW a 784 107 | BALANCE a 108 | BALANCE b 109 | DEPOSIT b 849 110 | BALANCE a 111 | BALANCE b 112 | 113 | Answer: 114 | ERROR 115 | ERROR 116 | 100 117 | ERROR 118 | 80 119 | ERROR 120 | 80 121 | -78 122 | -704 123 | -78 124 | -704 125 | 771 126 | 127 | -------------------------------------------------------------------------------- /problems/dicts/countries_and_cities.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Countries and cities 3 | 4 | Statement: 5 |

Given a list of countries and cities of each country. Then given the names of the cities. For each city 6 | specify the country in which it is located.

7 | 8 | Test: 9 | 2 10 | USA Boston Pittsburgh Washington Seattle 11 | UK London Edinburgh Cardiff Belfast 12 | 3 13 | Cardiff 14 | Seattle 15 | London 16 | 17 | Answer: 18 | UK 19 | USA 20 | UK 21 | 22 | 23 | Test: 24 | 2 25 | Russia Moscow Petersburg Novgorod Kaluga 26 | Ukraine Kiev Donetsk Odessa 27 | 3 28 | Odessa 29 | Moscow 30 | Novgorod 31 | 32 | Answer: 33 | Ukraine 34 | Russia 35 | Russia 36 | 37 | 38 | Test: 39 | 5 40 | A B 41 | C D 42 | E F 43 | G H 44 | I J 45 | 5 46 | J 47 | H 48 | F 49 | D 50 | B 51 | 52 | Answer: 53 | I 54 | G 55 | E 56 | C 57 | A 58 | 59 | 60 | Test: 61 | 5 62 | A B 63 | C D E 64 | F G H I 65 | J K L M N 66 | O P Q R S T 67 | 15 68 | T 69 | S 70 | N 71 | R 72 | M 73 | I 74 | Q 75 | L 76 | H 77 | E 78 | P 79 | K 80 | G 81 | D 82 | B 83 | 84 | Answer: 85 | O 86 | O 87 | J 88 | O 89 | J 90 | F 91 | O 92 | J 93 | F 94 | C 95 | O 96 | J 97 | F 98 | C 99 | A 100 | -------------------------------------------------------------------------------- /problems/dicts/english_latin_dict.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | English-Latin dictionary 3 | 4 | Statement: 5 |

One day, going through old books in the attic, a student Bob found English-Latin dictionary. 6 | By that time he spoke English fluently, and his dream was to learn Latin. 7 | So finding the dictionary was just in time.

8 | 9 |

Unfortunately, full-fledged language studying process requires also another type of dictionary: 10 | Latin-English. For lack of a better way he decided to make a second dictionary using the first one.

11 | 12 |

As you know, the dictionary consists of words, each of which contains multiple translations. 13 | For each Latin word that appears anywhere in the dictionary, Bob has to find all its translations 14 | (that is, all English words, for which our Latin word is among its translations), 15 | and take them and only them as the translations of this Latin word.

16 | 17 |

Help him to create a Latin-English.

18 | 19 |

20 | The first line contains a single integer N — the number of English words in the dictionary. 21 | Followed by N dictionary entries. 22 | Each entry is contained on a separate line, which contains first the English word, then a hyphen surrounded by spaces and then comma-separated list with the translations of this English word in Latin. 23 | All the words consist only of lowercase English letters. 24 | The translations are sorted in lexicographical order. 25 | The order of English words in the dictionary is also lexicographic. 26 |

27 |

28 | Print the corresponding Latin-English dictionary in the same format. 29 | In particular, the first word line should be the lexicographically minimal translation of the Latin word, then second in that order, etc. Inside the line the English words should be sorted also lexicographically. 30 |

31 | 32 | Test: 33 | 3 34 | apple - malum, pomum, popula 35 | fruit - baca, bacca, popum 36 | punishment - malum, multa 37 | 38 | Answer: 39 | 7 40 | baca - fruit 41 | bacca - fruit 42 | malum - apple, punishment 43 | multa - punishment 44 | pomum - apple 45 | popula - apple 46 | popum - fruit 47 | 48 | 49 | Test: 50 | 1 51 | school - schola 52 | 53 | Answer: 54 | 1 55 | schola - school 56 | 57 | 58 | Test: 59 | 3 60 | greet - empfangen, willkommen 61 | silicon - silicon 62 | welcome - willkommen 63 | 64 | Answer: 65 | 3 66 | empfangen - greet 67 | silicon - silicon 68 | willkommen - greet, welcome 69 | 70 | 71 | Test: 72 | 2 73 | mef - mqax, xkr 74 | wemu - mqax 75 | 76 | Answer: 77 | 2 78 | mqax - mef, wemu 79 | xkr - mef 80 | 81 | 82 | Test: 83 | 3 84 | gfk - whao 85 | icfx - nil, whao 86 | utzs - brh 87 | 88 | Answer: 89 | 3 90 | brh - utzs 91 | nil - icfx 92 | whao - gfk, icfx 93 | 94 | 95 | Test: 96 | 5 97 | casy - moxd, oosz, pfh, wfp 98 | cgsy - pfh 99 | dlx - fma, lyq 100 | vja - fma, lyq, moxd, oosz, pfh, wfp, xrwv 101 | zfq - fma, lyq, tnqq, xrwv 102 | 103 | Answer: 104 | 8 105 | fma - dlx, vja, zfq 106 | lyq - dlx, vja, zfq 107 | moxd - casy, vja 108 | oosz - casy, vja 109 | pfh - casy, cgsy, vja 110 | tnqq - zfq 111 | wfp - casy, vja 112 | xrwv - vja, zfq 113 | 114 | 115 | Test: 116 | 6 117 | drxpeycnkp - fgoezltv, fgqedltc, fgqezltc, fsqezltc, tgqehltc 118 | oaxpeycnkp - fgqedltc, pgqezltu, tgqehltc 119 | yaxpefcnkr - fgqedltc, fgqezljc, fgqezlqc, fgqezltc, tgqehltc 120 | yaxpeycnkp - fgqedltc, fgqezlqc, fsqezltc 121 | yaxpeycnks - fgqedltc, fsqezltc, pgqezltu 122 | yaxteyckp - fgqedltc, fgqezljc, fgqezlqc, fsqezltc, pgqezltu 123 | 124 | Answer: 125 | 8 126 | fgoezltv - drxpeycnkp 127 | fgqedltc - drxpeycnkp, oaxpeycnkp, yaxpefcnkr, yaxpeycnkp, yaxpeycnks, yaxteyckp 128 | fgqezljc - yaxpefcnkr, yaxteyckp 129 | fgqezlqc - yaxpefcnkr, yaxpeycnkp, yaxteyckp 130 | fgqezltc - drxpeycnkp, yaxpefcnkr 131 | fsqezltc - drxpeycnkp, yaxpeycnkp, yaxpeycnks, yaxteyckp 132 | pgqezltu - oaxpeycnkp, yaxpeycnks, yaxteyckp 133 | tgqehltc - drxpeycnkp, oaxpeycnkp, yaxpefcnkr 134 | 135 | 136 | Test: 137 | 5 138 | fnpa - kbyip 139 | kbyip - kbyip, ojawe, ysye 140 | ojawe - fnpa, kbyip 141 | uyjge - kbyip 142 | ysye - ojawe 143 | 144 | Answer: 145 | 4 146 | fnpa - ojawe 147 | kbyip - fnpa, kbyip, ojawe, uyjge 148 | ojawe - kbyip, ysye 149 | ysye - kbyip 150 | 151 | 152 | Test: 153 | 6 154 | ddf - ngyj, nrbb, nrkh, wryj 155 | deds - ngyj, nrbb, nrkh, nryj, wryj 156 | dpds - ngyj, nrkh, nryj 157 | dudm - ngyj, nrkh, nrni, nryj, wryj 158 | duds - ngyj, nrbb, nrkh, nryj 159 | dujs - ngyj, nrbb, nrkh, wryj 160 | 161 | Answer: 162 | 6 163 | ngyj - ddf, deds, dpds, dudm, duds, dujs 164 | nrbb - ddf, deds, duds, dujs 165 | nrkh - ddf, deds, dpds, dudm, duds, dujs 166 | nrni - dudm 167 | nryj - deds, dpds, dudm, duds 168 | wryj - ddf, deds, dudm, dujs 169 | 170 | 171 | Test: 172 | 6 173 | cdb - cdb, crke, meqb, pyk, uel 174 | crke - cdb, crke, meqb, pyk, uel 175 | fvl - crke, meqb 176 | meqb - cdb 177 | pyk - crke, meqb, uel 178 | uel - cdb, crke, fvl 179 | 180 | Answer: 181 | 6 182 | cdb - cdb, crke, meqb, uel 183 | crke - cdb, crke, fvl, pyk, uel 184 | fvl - uel 185 | meqb - cdb, crke, fvl, pyk 186 | pyk - cdb, crke 187 | uel - cdb, crke, pyk 188 | 189 | -------------------------------------------------------------------------------- /problems/dicts/frequency_analysis.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Frequency analysis 3 | 4 | Statement: 5 |

Given a number \( n \), followed by \( n \) lines of text, 6 | print all words encountered in the text, one per line. 7 | The words should be sorted in descending order according to their number of occurrences in the text, 8 | and all words with the same frequency should be printed in lexicographical order.

9 | 10 |

Hint. After you create a dictionary of the words and their frequencies, 11 | you would like to sort it according to the frequencies. This can be achieved if you create a list 12 | whose elements are tuples of two elements: the frequency of occurrence of a word 13 | and the word itself. For example, [(2, 'hi'), (1, 'what'), (3, 'is')]. 14 | Then the standard list sort will sort a list of tuples, with 15 | the tuples compared by the first element, and if these are equal, 16 | by the second element. This is nearly what is required in the problem.

17 | 18 | Test: 19 | 9 20 | hi 21 | hi 22 | what is your name 23 | my name is bond 24 | james bond 25 | my name is damme 26 | van damme 27 | claude van damme 28 | jean claude van damme 29 | 30 | Answer: 31 | damme 32 | is 33 | name 34 | van 35 | bond 36 | claude 37 | hi 38 | my 39 | james 40 | jean 41 | what 42 | your 43 | 44 | 45 | 46 | Test: 47 | 1 48 | ai ai ai ai ai ai ai ai ai ai 49 | 50 | Answer: 51 | ai 52 | 53 | 54 | Test: 55 | 2 56 | iovjxotfvt h h iovjxotfvt h iovjxotfvt iovjxotfvt h 57 | h iovjxotfvt 58 | 59 | Answer: 60 | h 61 | iovjxotfvt 62 | 63 | 64 | Test: 65 | 4 66 | eqlbahbovv pzpumhz mlcgtbbnfr 67 | axsjbontg emojwajtfi 68 | basdu nzyh wpyirkmz xxkmrr blnlqwcpur eqlbahbovv nzyh mlcgtbbnfr 69 | mlcgtbbnfr axsjbontg mlcgtbbnfr mlcgtbbnfr mlcgtbbnfr blnlqwcpur mlcgtbbnfr 70 | 71 | Answer: 72 | mlcgtbbnfr 73 | axsjbontg 74 | blnlqwcpur 75 | eqlbahbovv 76 | nzyh 77 | basdu 78 | emojwajtfi 79 | pzpumhz 80 | wpyirkmz 81 | xxkmrr 82 | 83 | 84 | Test: 85 | 14 86 | That thou hast her it is not all my grief, 87 | And yet it may be said I loved her dearly, 88 | That she hath thee is of my wailing chief, 89 | A loss in love that touches me more nearly. 90 | Loving offenders thus I will excuse ye, 91 | Thou dost love her, because thou know'st I love her, 92 | And for my sake even so doth she abuse me, 93 | Suff'ring my friend for my sake to approve her. 94 | If I lose thee, my loss is my love's gain, 95 | And losing her, my friend hath found that loss, 96 | Both find each other, and I lose both twain, 97 | And both for my sake lay on me this cross, 98 | But here's the joy, my friend and I are one, 99 | Sweet flattery, then she loves but me alone. 100 | 101 | Answer: 102 | my 103 | I 104 | And 105 | for 106 | friend 107 | her, 108 | is 109 | love 110 | me 111 | sake 112 | she 113 | That 114 | and 115 | both 116 | hath 117 | her 118 | it 119 | lose 120 | loss 121 | that 122 | thou 123 | A 124 | Both 125 | But 126 | If 127 | Loving 128 | Suff'ring 129 | Sweet 130 | Thou 131 | abuse 132 | all 133 | alone. 134 | approve 135 | are 136 | be 137 | because 138 | but 139 | chief, 140 | cross, 141 | dearly, 142 | dost 143 | doth 144 | each 145 | even 146 | excuse 147 | find 148 | flattery, 149 | found 150 | gain, 151 | grief, 152 | hast 153 | her. 154 | here's 155 | in 156 | joy, 157 | know'st 158 | lay 159 | losing 160 | loss, 161 | love's 162 | loved 163 | loves 164 | may 165 | me, 166 | more 167 | nearly. 168 | not 169 | of 170 | offenders 171 | on 172 | one, 173 | other, 174 | said 175 | so 176 | the 177 | thee 178 | thee, 179 | then 180 | this 181 | thus 182 | to 183 | touches 184 | twain, 185 | wailing 186 | will 187 | ye, 188 | yet 189 | -------------------------------------------------------------------------------- /problems/dicts/genealogy_descendants_count.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Родословная: число потомков 3 | 4 | Statement: 5 |

Для каждого элемента дерева определите число всех его потомков (не считая его самого).

6 | 7 |

8 | Формат выходных данных совпадает с 9 | задачей. 10 |

11 | Выведите список всех элементов в лексикографическом 12 | порядке, для каждого элемента выводите количество всех его потомков. 13 |

14 | 15 | Test: 16 | 9 17 | Alexei Peter_I 18 | Anna Peter_I 19 | Elizabeth Peter_I 20 | Peter_II Alexei 21 | Peter_III Anna 22 | Paul_I Peter_III 23 | Alexander_I Paul_I 24 | Nicholaus_I Paul_I 25 | 26 | Answer: 27 | Alexander_I 0 28 | Alexei 1 29 | Anna 4 30 | Elizabeth 0 31 | Nicholaus_I 0 32 | Paul_I 2 33 | Peter_I 8 34 | Peter_II 0 35 | Peter_III 3 36 | 37 | 38 | Test: 39 | 10 40 | AICHNG ZLNYXGO 41 | BDLHBJZWY BELAFXWA 42 | COXUC WVWNNC 43 | ELPPUINHJ BELAFXWA 44 | HIOSZOHQWG AICHNG 45 | UVRRAVHX BDLHBJZWY 46 | WVWNNC ELPPUINHJ 47 | YKYWCJBAX BDLHBJZWY 48 | ZLNYXGO BDLHBJZWY 49 | 50 | Answer: 51 | AICHNG 1 52 | BDLHBJZWY 5 53 | BELAFXWA 9 54 | COXUC 0 55 | ELPPUINHJ 2 56 | HIOSZOHQWG 0 57 | UVRRAVHX 0 58 | WVWNNC 1 59 | YKYWCJBAX 0 60 | ZLNYXGO 2 61 | 62 | 63 | Test: 64 | 10 65 | ATGRVELXU VAFBFFU 66 | AXOLTFYBEU IELUG 67 | GJSBSGD PSLUWDJML 68 | NOVHFU ZGTKHDLCUG 69 | PSLUWDJML ATGRVELXU 70 | UTOEGJE VQJTQ 71 | VAFBFFU AXOLTFYBEU 72 | VQJTQ NOVHFU 73 | ZGTKHDLCUG GJSBSGD 74 | 75 | Answer: 76 | ATGRVELXU 6 77 | AXOLTFYBEU 8 78 | GJSBSGD 4 79 | IELUG 9 80 | NOVHFU 2 81 | PSLUWDJML 5 82 | UTOEGJE 0 83 | VAFBFFU 7 84 | VQJTQ 1 85 | ZGTKHDLCUG 3 86 | 87 | 88 | Test: 89 | 10 90 | BVBSQST YYKHZ 91 | DLPJBFWD BVBSQST 92 | LWHPUKU MMDVH 93 | MMDVH AGHTYJZKGG 94 | NMOGF QKZQHV 95 | QKZQHV YYKHZ 96 | TXIGBES MMDVH 97 | YGQSXD QKZQHV 98 | YYKHZ AGHTYJZKGG 99 | 100 | Answer: 101 | AGHTYJZKGG 9 102 | BVBSQST 1 103 | DLPJBFWD 0 104 | LWHPUKU 0 105 | MMDVH 2 106 | NMOGF 0 107 | QKZQHV 2 108 | TXIGBES 0 109 | YGQSXD 0 110 | YYKHZ 5 111 | 112 | -------------------------------------------------------------------------------- /problems/dicts/genealogy_lca.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Родословная: LCA 3 | 4 | Statement: 5 |

В генеалогическом древе определите для двух элементов их наименьшего общего 6 | предка (Lowest Common Ancestor). Наименьшим общим предком элементов A и B является такой элемент C, 7 | что С является предком A, C является предком B, при этом глубина C является наибольшей 8 | из возможных. При этом элемент считается своим собственным предком. 9 |

10 |

11 | Формат входных данных аналогичен 12 | предыдущей задаче 13 |

14 | 15 |

16 | Для каждого запроса выведите наименьшего общего предка данных элементов. 17 |

18 | 19 | 20 | Test: 21 | 9 22 | Alexei Peter_I 23 | Anna Peter_I 24 | Elizabeth Peter_I 25 | Peter_II Alexei 26 | Peter_III Anna 27 | Paul_I Peter_III 28 | Alexander_I Paul_I 29 | Nicholaus_I Paul_I 30 | 3 31 | Alexander_I Nicholaus_I 32 | Peter_II Paul_I 33 | Alexander_I Anna 34 | 35 | Answer: 36 | Paul_I 37 | Peter_I 38 | Anna 39 | 40 | 41 | Test: 42 | 10 43 | ABVQKLSZG UNORTZGDM 44 | ALOPAEPIX VYNYXUEQ 45 | DBPNBMCQ IDZTWEVFC 46 | HHYVM NQXCK 47 | IDZTWEVFC ABVQKLSZG 48 | NQXCK VYNYXUEQ 49 | SXIVZSOLAH HHYVM 50 | UNORTZGDM ALOPAEPIX 51 | UYPMDVMONF NQXCK 52 | 100 53 | ABVQKLSZG ABVQKLSZG 54 | ABVQKLSZG ALOPAEPIX 55 | ABVQKLSZG DBPNBMCQ 56 | ABVQKLSZG HHYVM 57 | ABVQKLSZG IDZTWEVFC 58 | ABVQKLSZG NQXCK 59 | ABVQKLSZG SXIVZSOLAH 60 | ABVQKLSZG UNORTZGDM 61 | ABVQKLSZG UYPMDVMONF 62 | ABVQKLSZG VYNYXUEQ 63 | ALOPAEPIX ABVQKLSZG 64 | ALOPAEPIX ALOPAEPIX 65 | ALOPAEPIX DBPNBMCQ 66 | ALOPAEPIX HHYVM 67 | ALOPAEPIX IDZTWEVFC 68 | ALOPAEPIX NQXCK 69 | ALOPAEPIX SXIVZSOLAH 70 | ALOPAEPIX UNORTZGDM 71 | ALOPAEPIX UYPMDVMONF 72 | ALOPAEPIX VYNYXUEQ 73 | DBPNBMCQ ABVQKLSZG 74 | DBPNBMCQ ALOPAEPIX 75 | DBPNBMCQ DBPNBMCQ 76 | DBPNBMCQ HHYVM 77 | DBPNBMCQ IDZTWEVFC 78 | DBPNBMCQ NQXCK 79 | DBPNBMCQ SXIVZSOLAH 80 | DBPNBMCQ UNORTZGDM 81 | DBPNBMCQ UYPMDVMONF 82 | DBPNBMCQ VYNYXUEQ 83 | HHYVM ABVQKLSZG 84 | HHYVM ALOPAEPIX 85 | HHYVM DBPNBMCQ 86 | HHYVM HHYVM 87 | HHYVM IDZTWEVFC 88 | HHYVM NQXCK 89 | HHYVM SXIVZSOLAH 90 | HHYVM UNORTZGDM 91 | HHYVM UYPMDVMONF 92 | HHYVM VYNYXUEQ 93 | IDZTWEVFC ABVQKLSZG 94 | IDZTWEVFC ALOPAEPIX 95 | IDZTWEVFC DBPNBMCQ 96 | IDZTWEVFC HHYVM 97 | IDZTWEVFC IDZTWEVFC 98 | IDZTWEVFC NQXCK 99 | IDZTWEVFC SXIVZSOLAH 100 | IDZTWEVFC UNORTZGDM 101 | IDZTWEVFC UYPMDVMONF 102 | IDZTWEVFC VYNYXUEQ 103 | NQXCK ABVQKLSZG 104 | NQXCK ALOPAEPIX 105 | NQXCK DBPNBMCQ 106 | NQXCK HHYVM 107 | NQXCK IDZTWEVFC 108 | NQXCK NQXCK 109 | NQXCK SXIVZSOLAH 110 | NQXCK UNORTZGDM 111 | NQXCK UYPMDVMONF 112 | NQXCK VYNYXUEQ 113 | SXIVZSOLAH ABVQKLSZG 114 | SXIVZSOLAH ALOPAEPIX 115 | SXIVZSOLAH DBPNBMCQ 116 | SXIVZSOLAH HHYVM 117 | SXIVZSOLAH IDZTWEVFC 118 | SXIVZSOLAH NQXCK 119 | SXIVZSOLAH SXIVZSOLAH 120 | SXIVZSOLAH UNORTZGDM 121 | SXIVZSOLAH UYPMDVMONF 122 | SXIVZSOLAH VYNYXUEQ 123 | UNORTZGDM ABVQKLSZG 124 | UNORTZGDM ALOPAEPIX 125 | UNORTZGDM DBPNBMCQ 126 | UNORTZGDM HHYVM 127 | UNORTZGDM IDZTWEVFC 128 | UNORTZGDM NQXCK 129 | UNORTZGDM SXIVZSOLAH 130 | UNORTZGDM UNORTZGDM 131 | UNORTZGDM UYPMDVMONF 132 | UNORTZGDM VYNYXUEQ 133 | UYPMDVMONF ABVQKLSZG 134 | UYPMDVMONF ALOPAEPIX 135 | UYPMDVMONF DBPNBMCQ 136 | UYPMDVMONF HHYVM 137 | UYPMDVMONF IDZTWEVFC 138 | UYPMDVMONF NQXCK 139 | UYPMDVMONF SXIVZSOLAH 140 | UYPMDVMONF UNORTZGDM 141 | UYPMDVMONF UYPMDVMONF 142 | UYPMDVMONF VYNYXUEQ 143 | VYNYXUEQ ABVQKLSZG 144 | VYNYXUEQ ALOPAEPIX 145 | VYNYXUEQ DBPNBMCQ 146 | VYNYXUEQ HHYVM 147 | VYNYXUEQ IDZTWEVFC 148 | VYNYXUEQ NQXCK 149 | VYNYXUEQ SXIVZSOLAH 150 | VYNYXUEQ UNORTZGDM 151 | VYNYXUEQ UYPMDVMONF 152 | VYNYXUEQ VYNYXUEQ 153 | 154 | Answer: 155 | ABVQKLSZG 156 | ALOPAEPIX 157 | ABVQKLSZG 158 | VYNYXUEQ 159 | ABVQKLSZG 160 | VYNYXUEQ 161 | VYNYXUEQ 162 | UNORTZGDM 163 | VYNYXUEQ 164 | VYNYXUEQ 165 | ALOPAEPIX 166 | ALOPAEPIX 167 | ALOPAEPIX 168 | VYNYXUEQ 169 | ALOPAEPIX 170 | VYNYXUEQ 171 | VYNYXUEQ 172 | ALOPAEPIX 173 | VYNYXUEQ 174 | VYNYXUEQ 175 | ABVQKLSZG 176 | ALOPAEPIX 177 | DBPNBMCQ 178 | VYNYXUEQ 179 | IDZTWEVFC 180 | VYNYXUEQ 181 | VYNYXUEQ 182 | UNORTZGDM 183 | VYNYXUEQ 184 | VYNYXUEQ 185 | VYNYXUEQ 186 | VYNYXUEQ 187 | VYNYXUEQ 188 | HHYVM 189 | VYNYXUEQ 190 | NQXCK 191 | HHYVM 192 | VYNYXUEQ 193 | NQXCK 194 | VYNYXUEQ 195 | ABVQKLSZG 196 | ALOPAEPIX 197 | IDZTWEVFC 198 | VYNYXUEQ 199 | IDZTWEVFC 200 | VYNYXUEQ 201 | VYNYXUEQ 202 | UNORTZGDM 203 | VYNYXUEQ 204 | VYNYXUEQ 205 | VYNYXUEQ 206 | VYNYXUEQ 207 | VYNYXUEQ 208 | NQXCK 209 | VYNYXUEQ 210 | NQXCK 211 | NQXCK 212 | VYNYXUEQ 213 | NQXCK 214 | VYNYXUEQ 215 | VYNYXUEQ 216 | VYNYXUEQ 217 | VYNYXUEQ 218 | HHYVM 219 | VYNYXUEQ 220 | NQXCK 221 | SXIVZSOLAH 222 | VYNYXUEQ 223 | NQXCK 224 | VYNYXUEQ 225 | UNORTZGDM 226 | ALOPAEPIX 227 | UNORTZGDM 228 | VYNYXUEQ 229 | UNORTZGDM 230 | VYNYXUEQ 231 | VYNYXUEQ 232 | UNORTZGDM 233 | VYNYXUEQ 234 | VYNYXUEQ 235 | VYNYXUEQ 236 | VYNYXUEQ 237 | VYNYXUEQ 238 | NQXCK 239 | VYNYXUEQ 240 | NQXCK 241 | NQXCK 242 | VYNYXUEQ 243 | UYPMDVMONF 244 | VYNYXUEQ 245 | VYNYXUEQ 246 | VYNYXUEQ 247 | VYNYXUEQ 248 | VYNYXUEQ 249 | VYNYXUEQ 250 | VYNYXUEQ 251 | VYNYXUEQ 252 | VYNYXUEQ 253 | VYNYXUEQ 254 | VYNYXUEQ 255 | -------------------------------------------------------------------------------- /problems/dicts/genealogy_level_count.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Родословная: подсчет уровней 3 | 4 | Statement: 5 |

В генеалогическом древе у каждого человека, кроме родоначальника, есть ровно один родитель.

6 |

Каждом элементу дерева сопоставляется целое неотрицательное число, называемое высотой. 7 | У родоначальника высота равна 0, у любого другого элемента высота на 1 больше, чем у его родителя.

8 | 9 |

Вам дано генеалогическое древо, определите высоту всех его элементов.

10 | 11 |

12 | Программа получает на вход число элементов в генеалогическом древе N. 13 | Далее следует N−1 строка, задающие родителя для каждого элемента древа, кроме родоначальника. 14 | Каждая строка имеет вид имя_потомка имя_родителя. 15 |

16 | 17 |

18 | Программа должна вывести список всех элементов древа в лексикографическом порядке. 19 | После вывода имени каждого элемента необходимо вывести его высоту. 20 |

21 | 22 |

23 | Примечание 24 |

25 | Эта задача имеет решение сложности O(n), но вам достаточно написать решение сложности O(n2) (не считая сложности обращения к элементам словаря). 26 |

27 | 28 | Test: 29 | 9 30 | Alexei Peter_I 31 | Anna Peter_I 32 | Elizabeth Peter_I 33 | Peter_II Alexei 34 | Peter_III Anna 35 | Paul_I Peter_III 36 | Alexander_I Paul_I 37 | Nicholaus_I Paul_I 38 | 39 | Answer: 40 | Alexander_I 4 41 | Alexei 1 42 | Anna 1 43 | Elizabeth 1 44 | Nicholaus_I 4 45 | Paul_I 3 46 | Peter_I 0 47 | Peter_II 2 48 | Peter_III 2 49 | 50 | 51 | Test: 52 | 10 53 | AQHFYP MKFXCLZBT 54 | AYKOTYQ QIUKGHWCDC 55 | IWCGKHMFM WPLHJL 56 | MJVAURUDN QIUKGHWCDC 57 | MKFXCLZBT IWCGKHMFM 58 | PUTRIPYHNQ UQNGAXNP 59 | QIUKGHWCDC WPLHJL 60 | UQNGAXNP WPLHJL 61 | YURTPJNR QIUKGHWCDC 62 | 63 | Answer: 64 | AQHFYP 3 65 | AYKOTYQ 2 66 | IWCGKHMFM 1 67 | MJVAURUDN 2 68 | MKFXCLZBT 2 69 | PUTRIPYHNQ 2 70 | QIUKGHWCDC 1 71 | UQNGAXNP 1 72 | WPLHJL 0 73 | YURTPJNR 2 74 | 75 | 76 | Test: 77 | 10 78 | BFNRMLH CSZMPFXBZ 79 | CSZMPFXBZ IHWBQDJ 80 | FMVQTU FUXATQUGIG 81 | FUXATQUGIG IRVAVMQKN 82 | GNVIZ IQGIGUJZ 83 | IHWBQDJ LACXYFQHSQ 84 | IQGIGUJZ JMUPNYRQD 85 | IRVAVMQKN GNVIZ 86 | JMUPNYRQD BFNRMLH 87 | 88 | Answer: 89 | BFNRMLH 3 90 | CSZMPFXBZ 2 91 | FMVQTU 9 92 | FUXATQUGIG 8 93 | GNVIZ 6 94 | IHWBQDJ 1 95 | IQGIGUJZ 5 96 | IRVAVMQKN 7 97 | JMUPNYRQD 4 98 | LACXYFQHSQ 0 99 | 100 | 101 | Test: 102 | 10 103 | AQYAGCP REWAA 104 | ESWQWYTYC UBRMC 105 | IAMIHKG REWAA 106 | ICEWDHDNA XETAFXX 107 | PYDGXBFCOE XETAFXX 108 | REWAA UBRMC 109 | UCODPEEGM ESWQWYTYC 110 | VZHDSSNZ UCODPEEGM 111 | XETAFXX ESWQWYTYC 112 | 113 | Answer: 114 | AQYAGCP 2 115 | ESWQWYTYC 1 116 | IAMIHKG 2 117 | ICEWDHDNA 3 118 | PYDGXBFCOE 3 119 | REWAA 1 120 | UBRMC 0 121 | UCODPEEGM 2 122 | VZHDSSNZ 3 123 | XETAFXX 2 124 | 125 | -------------------------------------------------------------------------------- /problems/dicts/most_frequent_word.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The most frequent word 3 | 4 | Statement: 5 |

Given the text: the first line contains the number of lines, then given the lines of words. 6 | Print the word in the text that occurs most often. 7 | If there are many such words, print the one that is less in the alphabetical 8 | order.

9 | 10 | Test: 11 | 1 12 | apple orange banana banana orange 13 | 14 | Answer: 15 | banana 16 | 17 | 18 | Test: 19 | 3 20 | q w e r t y u i o p 21 | a s d f g h j k l 22 | z x c v b n m 23 | 24 | Answer: 25 | a 26 | 27 | Test: 28 | 3 29 | vqcg vqcg vqcg vqcg vqcg vqcg vqcg 30 | vqcg vqcg 31 | vqcg 32 | 33 | Answer: 34 | vqcg 35 | 36 | 37 | Test: 38 | 2 39 | taia ikm ikm ikm taia taia taia 40 | ikm ikm ikm 41 | 42 | Answer: 43 | ikm 44 | 45 | 46 | Test: 47 | 1 48 | zc gdwbsv uwsz j bqz cytzpsdpl q zczwrq e zvnisf cytzpsdpl gdwbsv cytzpsdpl e bqz bqz zczwrq gdwbsv gdwbsv e 49 | 50 | Answer: 51 | gdwbsv 52 | 53 | 54 | Test: 55 | 3 56 | iawkvxlhqwjm rwcahhaesy kbfahrmup huq w rzllq pq ufszcjb 57 | wmjdbhcwhxzlhlf 58 | jeeyfhbsauapwnpmskgh rzllq rzllq wmjdbhcwhxzlhlf rzllq rzllq jeeyfhbsauapwnpmskgh wmjdbhcwhxzlhlf rzllq jeeyfhbsauapwnpmskgh jeeyfhbsauapwnpmskgh 59 | 60 | Answer: 61 | rzllq 62 | 63 | 64 | Test: 65 | 1 66 | enagtgufzhnmyzkf kaphgquvoanw tkvj sylaejugfsv vuszbsdsv kmyyed rnhcdrpx b ejqa vykiu fjmdqlgxmameddhiytv yy owmldhdcjnoi durqhg ftjnehww aq ou tqxlcnxdpnmo ssdhbcdzzp twjdcvcojgtj 67 | 68 | Answer: 69 | aq 70 | 71 | 72 | Test: 73 | 10 74 | Death there mirth way the noisy merit. Piqued shy spring nor six though mutual living ask extent. Replying of dashwood advanced ladyship smallest disposal or. Attempt offices own improve now see. Called person are around county talked her esteem. Those fully these way nay thing seems. 75 | At distant inhabit amongst by. Appetite welcomed interest the goodness boy not. Estimable education for disposing pronounce her. John size good gay plan sent old roof own. Inquietude saw understood his friendship frequently yet. Nature his marked ham wished. 76 | Marianne or husbands if at stronger ye. Considered is as middletons uncommonly. Promotion perfectly ye consisted so. His chatty dining for effect ladies active. Equally journey wishing not several behaved chapter she two sir. Deficient procuring favourite extensive you two. Yet diminution she impossible understood age. 77 | So if on advanced addition absolute received replying throwing he. Delighted consisted newspaper of unfeeling as neglected so. Tell size come hard mrs and four fond are. Of in commanded earnestly resources it. At quitting in strictly up wandered of relation answered felicity. Side need at in what dear ever upon if. Same down want joy neat ask pain help she. Alone three stuff use law walls fat asked. Near do that he help. 78 | Betrayed cheerful declared end and. Questions we additions is extremely incommode. Next half add call them eat face. Age lived smile six defer bed their few. Had admitting concluded too behaviour him she. Of death to or to being other. 79 | Consulted he eagerness unfeeling deficient existence of. Calling nothing end fertile for venture way boy. Esteem spirit temper too say adieus who direct esteem. It esteems luckily mr or picture placing drawing no. Apartments frequently or motionless on reasonable projecting expression. Way mrs end gave tall walk fact bed. 80 | Offered say visited elderly and. Waited period are played family man formed. He ye body or made on pain part meet. You one delay nor begin our folly abode. By disposed replying mr me unpacked no. As moonlight of my resolving unwilling. 81 | Folly words widow one downs few age every seven. If miss part by fact he park just shew. Discovered had get considered projection who favourable. Necessary up knowledge it tolerably. Unwilling departure education is be dashwoods or an. Use off agreeable law unwilling sir deficient curiosity instantly. Easy mind life fact with see has bore ten. Parish any chatty can elinor direct for former. Up as meant widow equal an share least. 82 | With my them if up many. Lain week nay she them her she. Extremity so attending objection as engrossed gentleman something. Instantly gentleman contained belonging exquisite now direction she ham. West room at sent if year. Numerous indulged distance old law you. Total state as merit court green decay he. Steepest sex bachelor the may delicate its yourself. As he instantly on discovery concluded to. Open draw far pure miss felt say yet few sigh. 83 | Out too the been like hard off. Improve enquire welcome own beloved matters her. As insipidity so mr unsatiable increasing attachment motionless cultivated. Addition mr husbands unpacked occasion he oh. Is unsatiable if projecting boisterous insensible. It recommend be resolving pretended middleton. 84 | 85 | Answer: 86 | or 87 | 88 | 89 | -------------------------------------------------------------------------------- /problems/dicts/occurency_index.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Number of occurrences 3 | 4 | Statement: 5 |

The text is given in a single line. 6 | For each word of the text count the number of its occurrences before it.

7 | 8 |

A word is a sequence of non-whitespace characters. 9 | Two consecutive words are separated by one or more spaces. 10 | Punctiation marks are a part of a word, by this definition. 11 |

12 | 13 | Test: 14 | one two one tho three 15 | 16 | Answer: 17 | 0 0 1 0 0 18 | 19 | 20 | Test: 21 | She sells sea shells on the sea shore; The shells that she sells are sea shells I'm sure. So if she sells sea shells on the sea shore, I'm sure that the shells are sea shore shells. 22 | 23 | Answer: 24 | 0 0 0 0 0 0 1 0 0 1 0 0 1 0 2 2 0 0 0 0 1 2 3 3 1 1 4 0 1 0 1 2 4 1 5 0 0 25 | 26 | 27 | Test: 28 | aba aba; aba @?" 29 | 30 | Answer: 31 | 0 0 1 0 32 | 33 | 34 | Test: 35 | AA aa Aa aA 36 | 37 | Answer: 38 | 0 0 0 0 39 | 40 | 41 | Test: 42 | a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 43 | 44 | Answer: 45 | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 46 | 47 | 48 | Test: 49 | a b a c a b a d a b a c a b a 50 | 51 | Answer: 52 | 0 0 1 0 2 1 3 0 4 2 5 1 6 3 7 53 | 54 | 55 | Test: 56 | dsgsdf ' sdfg gdf ghgh sdfg sdh ghhfgjgj sdfg fhdh dfh dfh dfh 57 | 58 | Answer: 59 | 0 0 0 0 0 1 0 0 2 0 0 1 2 60 | 61 | 62 | Test: 63 | word 64 | 65 | Answer: 66 | 0 67 | 68 | 69 | Test: 70 | Lady of luck come out of your hiden course bless your light upon me as the light of the moon shines above and in the light of luck will be blessed i, when the moon is next to be full 71 | 72 | Answer: 73 | 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 2 1 0 0 0 0 0 2 2 3 1 0 0 0 0 0 3 1 0 0 0 1 0 74 | 75 | 76 | Test: 77 | As I prick this candle, I prick at thee Broken hearts unhappy be May you part another day Soon to go your separate ways 78 | 79 | Answer: 80 | 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 81 | 82 | 83 | Test: 84 | you will not solve this test. This @problem@ is unsolvable. 85 | 86 | Answer: 87 | 0 0 0 0 0 0 0 0 0 0 88 | 89 | 90 | Test: 91 | dfs bfs dejkstra bubble sort floid kmp z-function kormen bfs dejkstra bubble sort qsort merge sort heap sort genetic algorythm 92 | 93 | Answer: 94 | 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 2 0 3 0 0 95 | -------------------------------------------------------------------------------- /problems/dicts/permissions.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Access rights 3 | 4 | Statement: 5 |

The virus attacked the filesystem of the supercomputer and broke 6 | the control of access rights to the files. For each file 7 | there is a known set of operations which may be applied to it:

8 | 9 | 14 | 15 |

16 | The first line contains the number N — the number of files contained in the filesystem. 17 | The following N lines contain the file names and allowed operations with them, separated by spaces. 18 | 19 | The next line contains an integer M — the number of operations to the files. 20 | In the last M lines specify the operations that are requested for files. 21 | One file can be requested many times. 22 |

23 | 24 |

You need to recover the control over the access rights to the files. 25 | For each request your program should return OK 26 | if the requested operation is valid or 27 | Access denied if the operation is invalid.

28 | 29 | 30 | Test: 31 | 4 32 | helloworld.exe R X 33 | pinglog W R 34 | nya R 35 | goodluck X W R 36 | 5 37 | read nya 38 | write helloworld.exe 39 | execute nya 40 | read pinglog 41 | write pinglog 42 | 43 | Answer: 44 | OK 45 | Access denied 46 | Access denied 47 | OK 48 | OK 49 | 50 | 51 | Test: 52 | 1 53 | abacaba X 54 | 3 55 | read abacaba 56 | write abacaba 57 | execute abacaba 58 | 59 | Answer: 60 | Access denied 61 | Access denied 62 | OK 63 | 64 | 65 | Test: 66 | 1 67 | tmp_909925047 W X R 68 | 7 69 | execute tmp_909925047 70 | read tmp_909925047 71 | write tmp_909925047 72 | read tmp_909925047 73 | execute tmp_909925047 74 | execute tmp_909925047 75 | read tmp_909925047 76 | 77 | Answer: 78 | OK 79 | OK 80 | OK 81 | OK 82 | OK 83 | OK 84 | OK 85 | 86 | 87 | Test: 88 | 5 89 | tmp_1017722015 W 90 | tmp_897110090 X W R 91 | tmp_651548400 W X 92 | tmp_422551574 X R W 93 | tmp_477658548 W 94 | 1 95 | write tmp_897110090 96 | 97 | Answer: 98 | OK 99 | 100 | 101 | Test: 102 | 2 103 | tmp_584361681 R X 104 | tmp_70361076 X 105 | 3 106 | read tmp_70361076 107 | write tmp_70361076 108 | write tmp_70361076 109 | 110 | Answer: 111 | Access denied 112 | Access denied 113 | Access denied 114 | 115 | 116 | Test: 117 | 4 118 | tmp_796487715 X R W 119 | tmp_31144126 X R 120 | tmp_967334538 R 121 | tmp_264755563 R W 122 | 3 123 | read tmp_264755563 124 | execute tmp_796487715 125 | execute tmp_796487715 126 | 127 | Answer: 128 | OK 129 | OK 130 | OK 131 | 132 | -------------------------------------------------------------------------------- /problems/dicts/sales.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Продажи 3 | 4 | Statement: 5 |

Дана база данных о продажах некоторого интернет-магазина. 6 | Каждая строка входного файла представляет собой запись вида 7 | Покупатель товар количество, где 8 | Покупатель — имя покупателя (строка без пробелов), 9 | товар — название товара (строка без пробелов), 10 | количество — количество приобретенных единиц 11 | товара.

12 | 13 |

Создайте список всех покупателей, а для каждого покупателя 14 | подсчитайте количество приобретенных им единиц каждого вида товаров. 15 | Список покупателей, а также список товаров для каждого покупателя нужно выводить 16 | в лексикографическом порядке.

17 | 18 | Test: 19 | Ivanov paper 10 20 | Petrov pens 5 21 | Ivanov marker 3 22 | Ivanov paper 7 23 | Petrov envelope 20 24 | Ivanov envelope 5 25 | 26 | Answer: 27 | Ivanov: 28 | envelope 5 29 | marker 3 30 | paper 17 31 | Petrov: 32 | envelope 20 33 | pens 5 34 | 35 | 36 | Test: 37 | Ivanov aaa 1 38 | Petrov aaa 2 39 | Sidorov aaa 3 40 | Ivanov aaa 6 41 | Petrov aaa 7 42 | Sidorov aaa 8 43 | Ivanov bbb 3 44 | Petrov bbb 7 45 | Sidorov aaa 345 46 | Ivanov ccc 45 47 | Petrov ddd 34 48 | Ziborov eee 234 49 | Ivanov aaa 45 50 | 51 | Answer: 52 | Ivanov: 53 | aaa 52 54 | bbb 3 55 | ccc 45 56 | Petrov: 57 | aaa 9 58 | bbb 7 59 | ddd 34 60 | Sidorov: 61 | aaa 356 62 | Ziborov: 63 | eee 234 64 | 65 | 66 | Test: 67 | TKSNUU FKXYPUGQ 855146 68 | TKSNUU FKXYPUGQ 930060 69 | TKSNUU FKXYPUGQ 886973 70 | TKSNUU FKXYPUGQ 59344 71 | TKSNUU FKXYPUGQ 296343 72 | TKSNUU FKXYPUGQ 193166 73 | TKSNUU FKXYPUGQ 211696 74 | TKSNUU FKXYPUGQ 821064 75 | TKSNUU FKXYPUGQ 672846 76 | TKSNUU FKXYPUGQ 820341 77 | TKSNUU FKXYPUGQ 350693 78 | TKSNUU FKXYPUGQ 469538 79 | TKSNUU FKXYPUGQ 849069 80 | TKSNUU FKXYPUGQ 502007 81 | TKSNUU FKXYPUGQ 961595 82 | TKSNUU FKXYPUGQ 747271 83 | TKSNUU FKXYPUGQ 863648 84 | TKSNUU FKXYPUGQ 952069 85 | TKSNUU FKXYPUGQ 286019 86 | TKSNUU FKXYPUGQ 364841 87 | TKSNUU FKXYPUGQ 455930 88 | TKSNUU FKXYPUGQ 100486 89 | TKSNUU FKXYPUGQ 335026 90 | TKSNUU FKXYPUGQ 197672 91 | TKSNUU FKXYPUGQ 217640 92 | TKSNUU FKXYPUGQ 612549 93 | TKSNUU FKXYPUGQ 622501 94 | TKSNUU FKXYPUGQ 96554 95 | TKSNUU FKXYPUGQ 327166 96 | TKSNUU FKXYPUGQ 425399 97 | TKSNUU FKXYPUGQ 362309 98 | TKSNUU FKXYPUGQ 78477 99 | TKSNUU FKXYPUGQ 258916 100 | TKSNUU FKXYPUGQ 297923 101 | TKSNUU FKXYPUGQ 8891 102 | TKSNUU FKXYPUGQ 13639 103 | TKSNUU FKXYPUGQ 77308 104 | TKSNUU FKXYPUGQ 707620 105 | TKSNUU FKXYPUGQ 68205 106 | TKSNUU FKXYPUGQ 256702 107 | TKSNUU FKXYPUGQ 668334 108 | TKSNUU FKXYPUGQ 968673 109 | TKSNUU FKXYPUGQ 138125 110 | TKSNUU FKXYPUGQ 222904 111 | TKSNUU FKXYPUGQ 214091 112 | TKSNUU FKXYPUGQ 500231 113 | TKSNUU FKXYPUGQ 19611 114 | TKSNUU FKXYPUGQ 491343 115 | TKSNUU FKXYPUGQ 404307 116 | TKSNUU FKXYPUGQ 68367 117 | TKSNUU FKXYPUGQ 287107 118 | TKSNUU FKXYPUGQ 794935 119 | TKSNUU FKXYPUGQ 254217 120 | TKSNUU FKXYPUGQ 206370 121 | TKSNUU FKXYPUGQ 202761 122 | TKSNUU FKXYPUGQ 929017 123 | TKSNUU FKXYPUGQ 843359 124 | TKSNUU FKXYPUGQ 955269 125 | TKSNUU FKXYPUGQ 134139 126 | TKSNUU FKXYPUGQ 946168 127 | TKSNUU FKXYPUGQ 967781 128 | TKSNUU FKXYPUGQ 856474 129 | TKSNUU FKXYPUGQ 465070 130 | TKSNUU FKXYPUGQ 580526 131 | TKSNUU FKXYPUGQ 172109 132 | TKSNUU FKXYPUGQ 191703 133 | TKSNUU FKXYPUGQ 207916 134 | TKSNUU FKXYPUGQ 512264 135 | TKSNUU FKXYPUGQ 533081 136 | TKSNUU FKXYPUGQ 577208 137 | TKSNUU FKXYPUGQ 831389 138 | TKSNUU FKXYPUGQ 439158 139 | TKSNUU FKXYPUGQ 565633 140 | TKSNUU FKXYPUGQ 452643 141 | TKSNUU FKXYPUGQ 164426 142 | TKSNUU FKXYPUGQ 540743 143 | TKSNUU FKXYPUGQ 880704 144 | TKSNUU FKXYPUGQ 868529 145 | TKSNUU FKXYPUGQ 240742 146 | TKSNUU FKXYPUGQ 868865 147 | TKSNUU FKXYPUGQ 910442 148 | TKSNUU FKXYPUGQ 146737 149 | TKSNUU FKXYPUGQ 820984 150 | TKSNUU FKXYPUGQ 660948 151 | TKSNUU FKXYPUGQ 957975 152 | TKSNUU FKXYPUGQ 135847 153 | TKSNUU FKXYPUGQ 401865 154 | TKSNUU FKXYPUGQ 982859 155 | TKSNUU FKXYPUGQ 748454 156 | TKSNUU FKXYPUGQ 354734 157 | TKSNUU FKXYPUGQ 525638 158 | TKSNUU FKXYPUGQ 119140 159 | TKSNUU FKXYPUGQ 484816 160 | TKSNUU FKXYPUGQ 616539 161 | TKSNUU FKXYPUGQ 682553 162 | TKSNUU FKXYPUGQ 841541 163 | TKSNUU FKXYPUGQ 713063 164 | TKSNUU FKXYPUGQ 433453 165 | TKSNUU FKXYPUGQ 465340 166 | TKSNUU FKXYPUGQ 985635 167 | 168 | Answer: 169 | TKSNUU: 170 | FKXYPUGQ 49769497 171 | 172 | -------------------------------------------------------------------------------- /problems/dicts/synonym_dictionary.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Dictionary of synonyms 3 | 4 | Statement: 5 |

You are given a dictionary consisting of word pairs. Every word is a synonym the other word in its pair. 6 | All the words in the dictionary are different.

7 | 8 |

After the dictionary there's one more word given. Find a synonym for him.

9 | 10 | Test: 11 | 3 12 | Hello Hi 13 | Bye Goodbye 14 | List Array 15 | Goodbye 16 | 17 | Answer: 18 | Bye 19 | 20 | 21 | Test: 22 | 1 23 | beep Car 24 | Car 25 | 26 | Answer: 27 | beep 28 | 29 | 30 | Test: 31 | 1 32 | 1234 4321 33 | 1234 34 | 35 | Answer: 36 | 4321 37 | 38 | 39 | Test: 40 | 10 41 | a 1 42 | b 2 43 | c 3 44 | d 4 45 | e 5 46 | f 6 47 | g 7 48 | h 8 49 | i 9 50 | j 10 51 | e 52 | 53 | Answer: 54 | 5 55 | 56 | 57 | Test: 58 | 10 59 | a 1 60 | b 2 61 | c 3 62 | d 4 63 | e 5 64 | f 6 65 | g 7 66 | h 8 67 | i 9 68 | j 10 69 | 5 70 | 71 | Answer: 72 | e 73 | 74 | 75 | Test: 76 | 10 77 | 95UUSA4P3K 140YAZQF1W2 78 | JIGCEL82Y3BXJ 277WMID9GFAWGC 79 | X36U1924TQ GUDPNJ60NR3A 80 | TR7JOPXQ0JK64CM O6BJSY7MHMAI8S 81 | 17HZOQO20CDQ1UG VVIPAVTVY202R 82 | 8T1A0XRRKKXEV 7L2UKWCJ917G1Q 83 | WLPOJYRN0G3MC 5QWJPM4FG58 84 | Z8TN35IQAF GXUPQY7I3AJCX3 85 | 5F382242HD25Q 3IV9JL29DNP64 86 | KZWNAOSV8H8APVF LDAIALO4YMXE7 87 | WLPOJYRN0G3MC 88 | 89 | Answer: 90 | 5QWJPM4FG58 91 | 92 | -------------------------------------------------------------------------------- /problems/dicts/usa_elections.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Elections in the USA 3 | 4 | Statement: 5 |

As you know, the president of USA is elected not by direct vote, but through a two-step voting. 6 | First elections are held in each state and determine the winner of elections in that state. 7 | Thereafter, the state election is going: in this election, every state has a certain 8 | the number of votes — the number of electors from that state. In practice, all the electors 9 | from the state of voted in accordance with the results of the vote within a state.

10 | 11 |

The first line contains the number of records. After that, each entry contains the name of the candidate and the number of votes they got in one of the states. 12 | Count the total results of the elections: sum the number of votes for each candidate. 13 | Print candidates in the alphabetical order.

14 | 15 | Test: 16 | 5 17 | McCain 10 18 | McCain 5 19 | Obama 9 20 | Obama 8 21 | McCain 1 22 | 23 | Answer: 24 | McCain 16 25 | Obama 17 26 | 27 | Test: 28 | 13 29 | McCain 10 30 | McCain 3 31 | Obama 19 32 | Obama 2 33 | McCain 7 34 | McCain 2 35 | Obama 6 36 | Obama 10 37 | McCain 11 38 | McCain 5 39 | Obama 3 40 | Obama 12 41 | McCain 13 42 | 43 | Answer: 44 | McCain 51 45 | Obama 52 46 | 47 | 48 | Test: 49 | 1 50 | Obama 1 51 | 52 | Answer: 53 | Obama 1 54 | 55 | 56 | Test: 57 | 7 58 | ivan 2 59 | gena 1 60 | sergey 100000 61 | ivan 1 62 | ivan 1 63 | ivan 0 64 | gena 100 65 | 66 | Answer: 67 | gena 101 68 | ivan 4 69 | sergey 100000 70 | 71 | Test: 72 | 61 73 | Obama 1 74 | Obama 1 75 | Obama 1 76 | Obama 1 77 | Obama 1 78 | Obama 1 79 | Obama 1 80 | Obama 1 81 | Obama 1 82 | Obama 1 83 | Obama 1 84 | Obama 1 85 | Obama 1 86 | Obama 1 87 | Obama 1 88 | Obama 1 89 | Obama 1 90 | Obama 1 91 | Obama 1 92 | Obama 1 93 | Obama 1 94 | Obama 1 95 | Obama 1 96 | Obama 1 97 | Obama 1 98 | Obama 1 99 | Obama 1 100 | Obama 1 101 | Obama 1 102 | Obama 1 103 | Obama 1 104 | Obama 1 105 | Obama 1 106 | Obama 1 107 | Obama 1 108 | Obama 1 109 | Obama 1 110 | Obama 1 111 | Obama 1 112 | Obama 1 113 | Obama 1 114 | Obama 1 115 | Obama 1 116 | Obama 1 117 | Obama 1 118 | Obama 1 119 | Obama 1 120 | Obama 1 121 | Obama 1 122 | Obama 1 123 | Obama 1 124 | Obama 1 125 | Obama 1 126 | Obama 1 127 | Obama 1 128 | Obama 1 129 | Obama 1 130 | Obama 1 131 | Obama 1 132 | Obama 1 133 | McCain 59 134 | 135 | Answer: 136 | McCain 59 137 | Obama 60 138 | -------------------------------------------------------------------------------- /problems/dicts/usa_elections_2.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Выборы в США - 2 3 | 4 | Statement: 5 |

Как известно, в США президент выбирается не прямым голосованием, а путем двухуровневого голосования. Сначала проводятся выборы в каждом штате и определяется победитель выборов в данном штате. Затем проводятся государственные выборы: на этих выборах каждый штат имеет определенное число голосов — число выборщиков от этого штата. На практике, все выборщики от штата голосуют в соответствии с результами голосования внутри штата, то есть на заключительной стадии выборов в голосовании участвуют штаты, имеющие различное число голосов.

6 | 7 |

На этот раз вам известно число выборщиков от каждого штата США и 8 | результаты голосования каждого гражданина США (а также в каком штате 9 | проживает данный гражданин).

10 | 11 |

Вам необходимо подвести результаты голосования: сначала определить результаты 12 | голосования в каждом штате и определить, за какого из кандидатов отданы 13 | голоса выборщиков данного штата. Далее необходимо подвести результаты голосования выборщиков по всем штатам.

14 | 15 | Test: 16 | 2 17 | Florida 25 18 | Pennsylvania 23 19 | Florida Gore 20 | Pennsylvania Gore 21 | Florida Bush 22 | Pennsylvania Gore 23 | Pennsylvania Bush 24 | Florida Gore 25 | Pennsylvania Gore 26 | Florida Bush 27 | Pennsylvania Gore 28 | Florida Bush 29 | Pennsylvania Gore 30 | 31 | Answer: 32 | Bush 25 33 | Gore 23 34 | 35 | 36 | Test: 37 | 3 38 | Florida 5 39 | Pennsylvania 4 40 | Alaska 3 41 | Florida Gore 42 | Pennsylvania Obama 43 | Pennsylvania Clinton 44 | Alaska Bush 45 | 46 | Answer: 47 | Gore 5 48 | Clinton 4 49 | Bush 3 50 | Obama 0 51 | 52 | -------------------------------------------------------------------------------- /problems/electronic_watch.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Digital clock 3 | 4 | Statement: 5 | Given the integer N - the number of minutes that is passed since midnight - how many hours and minutes are displayed on the 24h digital clock? 6 |

7 | The program should print two numbers: the number of hours (between 0 and 23) and the number of minutes 8 | (between 0 and 59). 9 |

10 | For example, if N = 150, then 150 minutes have passed since midnight - i.e. now is 2:30 am. So the 11 | program should print 2 30. 12 | 13 | 14 | Test: 15 | 150 16 | 17 | Answer: 18 | 2 30 19 | 20 | Test: 21 | 180 22 | 23 | Answer: 24 | 3 0 25 | 26 | Test: 27 | 444 28 | 29 | Answer: 30 | 7 24 31 | 32 | Test: 33 | 1111 34 | 35 | Answer: 36 | 18 31 37 | 38 | Test: 39 | 1439 40 | 41 | Answer: 42 | 23 59 43 | -------------------------------------------------------------------------------- /problems/for/factorial.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Factorial 3 | 4 | Statement: 5 | In mathematics, the factorial of an integer \(n\), denoted by \(n!\) is the following product: 6 | $$n! = 1 \times 2 \times \ldots \times n$$ 7 | 8 |

9 | For the given integer \(n\) calculate the value \(n!\). Don't use math module in this exercise. 10 | 11 | 12 | 13 | Test: 14 | 4 15 | 16 | Answer: 17 | 24 18 | 19 | 20 | 21 | 22 | Test: 23 | 1 24 | 25 | Answer: 26 | 1 27 | 28 | 29 | Test: 30 | 2 31 | 32 | Answer: 33 | 2 34 | 35 | 36 | Test: 37 | 3 38 | 39 | Answer: 40 | 6 41 | 42 | 43 | 44 | Test: 45 | 5 46 | 47 | Answer: 48 | 120 49 | 50 | 51 | Test: 52 | 6 53 | 54 | Answer: 55 | 720 56 | 57 | 58 | Test: 59 | 7 60 | 61 | Answer: 62 | 5040 63 | 64 | 65 | Test: 66 | 8 67 | 68 | Answer: 69 | 40320 70 | 71 | 72 | Test: 73 | 9 74 | 75 | Answer: 76 | 362880 77 | 78 | 79 | Test: 80 | 10 81 | 82 | Answer: 83 | 3628800 84 | 85 | 86 | Test: 87 | 11 88 | 89 | Answer: 90 | 39916800 91 | 92 | 93 | Test: 94 | 12 95 | 96 | 97 | Answer: 98 | 479001600 99 | -------------------------------------------------------------------------------- /problems/for/how_many_zeroes.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of zeros 3 | 4 | Statement: 5 | Given N numbers: the first number in the input is N, after that N integers are given. Count the number of zeros among the given integers and print it. 6 | 7 |

8 | You need to count the number of numbers that are equal to zero, not the number of zero digits. 9 | 10 | 11 | Test: 12 | 5 13 | 0 14 | 700 15 | 0 16 | 200 17 | 2 18 | 19 | Answer: 20 | 2 21 | 22 | 23 | Test: 24 | 7 25 | 1 26 | 2 27 | 3 28 | 4 29 | 5 30 | 6 31 | 7 32 | 33 | Answer: 34 | 0 35 | 36 | 37 | Test: 38 | 6 39 | 0 40 | 0 41 | 0 42 | 0 43 | 0 44 | 0 45 | 46 | Answer: 47 | 6 48 | 49 | 50 | Test: 51 | 1 52 | 0 53 | 54 | Answer: 55 | 1 56 | 57 | 58 | Test: 59 | 1 60 | 1 61 | 62 | Answer: 63 | 0 64 | 65 | 66 | Test: 67 | 3 68 | 0 69 | 1 70 | 2 71 | 72 | Answer: 73 | 1 74 | 75 | 76 | Test: 77 | 3 78 | 1 79 | 2 80 | 0 81 | 82 | Answer: 83 | 1 84 | 85 | Test: 86 | 10 87 | 0 88 | 4 89 | 1 90 | -7 91 | 0 92 | 4 93 | 5 94 | 1 95 | 0 96 | 0 97 | 98 | Answer: 99 | 4 100 | -------------------------------------------------------------------------------- /problems/for/ladder.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Ladder 3 | 4 | Statement: 5 | For given integer n ≤ 9 print a ladder of n steps. The k-th step consists of the integers from 1 to k without spaces between them. 6 |

7 | To do that, you can use the sep and end arguments for the function print(). 8 | 9 | Test: 10 | 3 11 | 12 | Answer: 13 | 1 14 | 12 15 | 123 16 | 17 | 18 | Test: 19 | 4 20 | 21 | Answer: 22 | 1 23 | 12 24 | 123 25 | 1234 26 | 27 | 28 | Test: 29 | 2 30 | 31 | Answer: 32 | 1 33 | 12 34 | 35 | 36 | Test: 37 | 5 38 | 39 | Answer: 40 | 1 41 | 12 42 | 123 43 | 1234 44 | 12345 45 | 46 | 47 | Test: 48 | 1 49 | 50 | Answer: 51 | 1 52 | 53 | 54 | Test: 55 | 7 56 | 57 | Answer: 58 | 1 59 | 12 60 | 123 61 | 1234 62 | 12345 63 | 123456 64 | 1234567 65 | 66 | 67 | Test: 68 | 8 69 | 70 | Answer: 71 | 1 72 | 12 73 | 123 74 | 1234 75 | 12345 76 | 123456 77 | 1234567 78 | 12345678 79 | 80 | 81 | Test: 82 | 9 83 | 84 | Answer: 85 | 1 86 | 12 87 | 123 88 | 1234 89 | 12345 90 | 123456 91 | 1234567 92 | 12345678 93 | 123456789 94 | 95 | 96 | Test: 97 | 6 98 | 99 | Answer: 100 | 1 101 | 12 102 | 123 103 | 1234 104 | 12345 105 | 123456 -------------------------------------------------------------------------------- /problems/for/lost_card.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Lost card 3 | 4 | Statement: 5 | There was a set of cards with numbers from 1 to N. One of the card is now lost. Determine the number on that lost card given the numbers for the remaining cards. 6 | 7 |

8 | Given a number N, followed by N − 1 integers - representing the numbers on the remaining cards (distinct integers in the range from 1 to N). Find and print the number on the lost card. 9 | 10 | 11 | Test: 12 | 5 13 | 1 14 | 2 15 | 3 16 | 4 17 | 18 | 19 | Answer: 20 | 5 21 | 22 | 23 | Test: 24 | 5 25 | 3 26 | 5 27 | 2 28 | 1 29 | 30 | 31 | Answer: 32 | 4 33 | 34 | 35 | Test: 36 | 4 37 | 3 38 | 2 39 | 4 40 | 41 | Answer: 42 | 1 43 | 44 | 45 | Test: 46 | 3 47 | 1 48 | 2 49 | 50 | Answer: 51 | 3 52 | 53 | 54 | Test: 55 | 3 56 | 3 57 | 2 58 | 59 | Answer: 60 | 1 61 | 62 | 63 | Test: 64 | 3 65 | 3 66 | 1 67 | 68 | Answer: 69 | 2 70 | 71 | 72 | Test: 73 | 1 74 | 75 | Answer: 76 | 1 77 | 78 | Test: 79 | 10 80 | 4 81 | 1 82 | 7 83 | 8 84 | 3 85 | 5 86 | 9 87 | 10 88 | 6 89 | 90 | Answer: 91 | 2 92 | -------------------------------------------------------------------------------- /problems/for/series_1.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Series - 1 3 | 4 | Statement: 5 | Given two integers A and B (A ≤ B). Print all numbers from A to B inclusively. 6 | 7 | 8 | Test: 9 | 1 10 | 10 11 | 12 | Answer: 13 | 1 2 3 4 5 6 7 8 9 10 14 | 15 | 16 | Test: 17 | -3 18 | 14 19 | 20 | Answer: 21 | -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 22 | 23 | 24 | Test: 25 | 0 26 | 0 27 | 28 | Answer: 29 | 0 30 | 31 | 32 | Test: 33 | 20 34 | 20 35 | 36 | Answer: 37 | 20 38 | -------------------------------------------------------------------------------- /problems/for/series_2.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Series - 2 3 | 4 | Statement: 5 | Given two integers A and B. Print all numbers from A to B inclusively, in ascending order, if A < B, or 6 | in descending order, if A ≥ B. 7 | 8 | 9 | Test: 10 | 1 11 | 10 12 | 13 | Answer: 14 | 1 2 3 4 5 6 7 8 9 10 15 | 16 | 17 | Test: 18 | 10 19 | 1 20 | 21 | Answer: 22 | 10 9 8 7 6 5 4 3 2 1 23 | 24 | 25 | Test: 26 | 179 27 | 179 28 | 29 | Answer: 30 | 179 31 | 32 | 33 | Test: 34 | -14 35 | 7 36 | 37 | Answer: 38 | -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 39 | 40 | 41 | Test: 42 | 12 43 | -5 44 | 45 | Answer: 46 | 12 11 10 9 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 47 | 48 | 49 | Test: 50 | -3 51 | -7 52 | 53 | Answer: 54 | -3 -4 -5 -6 -7 55 | -------------------------------------------------------------------------------- /problems/for/series_3.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Ряд - 3 3 | 4 | Statement: 5 | Даны два целых числа A и В, \(A>B\). Выведите все нечётные числа от A до B включительно, в порядке убывания. В этой задаче нельзя использовать инструкцию if. 6 | 7 | 8 | Test: 9 | 7 10 | 1 11 | 12 | Answer: 13 | 7 5 3 1 14 | 15 | 16 | Test: 17 | 10 18 | 1 19 | 20 | Answer: 21 | 9 7 5 3 1 22 | 23 | 24 | Test: 25 | 200 26 | 186 27 | 28 | Answer: 29 | 199 197 195 193 191 189 187 30 | 31 | 32 | Test: 33 | -18 34 | -29 35 | 36 | Answer: 37 | -19 -21 -23 -25 -27 -29 38 | 39 | 40 | Test: 41 | 6 42 | 5 43 | 44 | Answer: 45 | 5 46 | 47 | 48 | Test: 49 | 1001 50 | 1000 51 | 52 | Answer: 53 | 1001 54 | -------------------------------------------------------------------------------- /problems/for/sum_of_cubes.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Sum of cubes 3 | 4 | 5 | Statement: 6 | For the given integer N calculate the following sum: 7 | 8 | $$ 1^3 + 2^3 + \ldots + N^3 $$ 9 | 10 | 11 | Test: 12 | 3 13 | 14 | Answer: 15 | 36 16 | 17 | 18 | 19 | Test: 20 | 1 21 | 22 | Answer: 23 | 1 24 | 25 | 26 | Test: 27 | 2 28 | 29 | Answer: 30 | 9 31 | 32 | 33 | 34 | 35 | Test: 36 | 4 37 | 38 | Answer: 39 | 100 40 | 41 | 42 | Test: 43 | 5 44 | 45 | Answer: 46 | 225 47 | 48 | 49 | Test: 50 | 6 51 | 52 | Answer: 53 | 441 54 | 55 | 56 | Test: 57 | 7 58 | 59 | Answer: 60 | 784 61 | 62 | 63 | Test: 64 | 8 65 | 66 | Answer: 67 | 1296 68 | 69 | 70 | Test: 71 | 9 72 | 73 | Answer: 74 | 2025 75 | 76 | 77 | Test: 78 | 20 79 | 80 | Answer: 81 | 44100 82 | 83 | 84 | Test: 85 | 30 86 | 87 | Answer: 88 | 216225 -------------------------------------------------------------------------------- /problems/for/sum_of_factorials.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Adding factorials 3 | 4 | 5 | Statement: 6 |

Given an integer \(n\), print the sum \(1!+2!+3!+...+n!\). 7 | 8 |

9 | This problem has a solution with only one loop, so try to discover it. And don't use the math library :) 10 | 11 | 12 | Test: 13 | 1 14 | 15 | Answer: 16 | 1 17 | 18 | 19 | Test: 20 | 2 21 | 22 | Answer: 23 | 3 24 | 25 | 26 | Test: 27 | 3 28 | 29 | Answer: 30 | 9 31 | 32 | 33 | Test: 34 | 4 35 | 36 | Answer: 37 | 33 38 | 39 | 40 | Test: 41 | 5 42 | 43 | Answer: 44 | 153 45 | 46 | 47 | Test: 48 | 6 49 | 50 | Answer: 51 | 873 52 | 53 | 54 | Test: 55 | 7 56 | 57 | Answer: 58 | 5913 59 | 60 | 61 | Test: 62 | 8 63 | 64 | Answer: 65 | 46233 66 | 67 | 68 | Test: 69 | 9 70 | 71 | Answer: 72 | 409113 73 | 74 | 75 | Test: 76 | 10 77 | 78 | Answer: 79 | 4037913 80 | -------------------------------------------------------------------------------- /problems/for/sum_of_n_numbers.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Sum of N numbers 3 | 4 | Statement: 5 | N numbers are given in the input. Read them and print their sum. 6 |

7 | The first line of input contains the integer N, which is the number of integers to follow. 8 | Each of the next N lines contains one integer. Print the sum of these N integers. 9 | 10 | 11 | Test: 12 | 10 13 | 1 14 | 2 15 | 1 16 | 1 17 | 1 18 | 1 19 | 3 20 | 1 21 | 1 22 | 1 23 | 24 | Answer: 25 | 13 26 | 27 | 28 | Test: 29 | 10 30 | 1 31 | 2 32 | 3 33 | 4 34 | 5 35 | 6 36 | 7 37 | 8 38 | 9 39 | 10 40 | 41 | 42 | Answer: 43 | 55 44 | 45 | 46 | Test: 47 | 10 48 | 8 49 | 4 50 | 5 51 | 3 52 | 9 53 | 2 54 | 3 55 | 4 56 | 5 57 | 1 58 | 59 | 60 | Answer: 61 | 44 62 | 63 | 64 | Test: 65 | 10 66 | 758 67 | 483 68 | 893 69 | 393 70 | 293 71 | 292 72 | 292 73 | 485 74 | 828 75 | 182 76 | 77 | 78 | Answer: 79 | 4899 80 | 81 | 82 | Test: 83 | 10 84 | -1 85 | -2 86 | -3 87 | -4 88 | -5 89 | -6 90 | -7 91 | -8 92 | -9 93 | 0 94 | 95 | 96 | Answer: 97 | -45 98 | 99 | 100 | Test: 101 | 10 102 | 0 103 | 0 104 | 0 105 | 0 106 | 0 107 | 0 108 | 0 109 | 0 110 | 0 111 | 0 112 | 113 | 114 | 115 | Answer: 116 | 0 117 | 118 | 119 | Test: 120 | 1 121 | 891 122 | 123 | Answer: 124 | 891 125 | 126 | 127 | Test: 128 | 2 129 | 235 130 | 56 131 | 132 | 133 | Answer: 134 | 291 135 | 136 | 137 | Test: 138 | 0 139 | 140 | Answer: 141 | 0 142 | 143 | 144 | Test: 145 | 3 146 | 1 147 | 2 148 | 3 149 | 150 | Answer: 151 | 6 152 | 153 | 154 | Test: 155 | 4 156 | 4 157 | 4 158 | 4 159 | 4 160 | 161 | Answer: 162 | 16 163 | -------------------------------------------------------------------------------- /problems/for/sum_of_ten_numbers.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Sum of ten numbers 3 | 4 | Statement: 5 | 10 numbers are given in the input. Read them and print their sum. Use as few variables as you can. 6 | 7 | Test: 8 | 0 9 | 1 10 | 2 11 | 3 12 | 4 13 | 5 14 | 6 15 | 7 16 | 8 17 | 9 18 | 19 | Answer: 20 | 45 21 | 22 | 23 | Test: 24 | 1 25 | 1 26 | 1 27 | 1 28 | 1 29 | 1 30 | 1 31 | 1 32 | 1 33 | 1 34 | 35 | 36 | Answer: 37 | 10 38 | 39 | 40 | Test: 41 | 1 42 | 2 43 | 3 44 | 4 45 | 5 46 | 6 47 | 7 48 | 8 49 | 9 50 | 10 51 | 52 | 53 | Answer: 54 | 55 55 | 56 | 57 | Test: 58 | 8 59 | 4 60 | 5 61 | 3 62 | 9 63 | 2 64 | 3 65 | 4 66 | 5 67 | 1 68 | 69 | 70 | Answer: 71 | 44 72 | 73 | 74 | Test: 75 | 758 76 | 483 77 | 893 78 | 393 79 | 293 80 | 292 81 | 292 82 | 485 83 | 828 84 | 182 85 | 86 | 87 | Answer: 88 | 4899 89 | 90 | 91 | Test: 92 | -1 93 | -2 94 | -3 95 | -4 96 | -5 97 | -6 98 | -7 99 | -8 100 | -9 101 | 0 102 | 103 | 104 | Answer: 105 | -45 106 | 107 | 108 | Test: 109 | 0 110 | 0 111 | 0 112 | 0 113 | 0 114 | 0 115 | 0 116 | 0 117 | 0 118 | 0 119 | 120 | 121 | 122 | Answer: 123 | 0 124 | -------------------------------------------------------------------------------- /problems/functions/capitalize.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Uppercase 3 | 4 | Statement: 5 |

Write a function capitalize(lower_case_word) that takes the lower case word and returns the word with the first letter capitalized. Eg., print(capitalize('word')) should print the word Word. 6 | 7 |

Then, given a line of lowercase ASCII words (text separated by a single space), print it with the first letter of each word capitalized using the your own function capitalize(). 8 | 9 |

In Python there is a function ord(character), which returns character code in the ASCII chart, and the function chr(code), which returns the character itself from the ASCII code. For example, ord('a') == 97, chr(97) == 'a'. 10 | 11 | Test: 12 | harry potter 13 | 14 | Answer: 15 | Harry Potter 16 | 17 | 18 | Test: 19 | procrastination 20 | 21 | Answer: 22 | Procrastination 23 | 24 | 25 | Test: 26 | we danced the mamushka at waterloo 27 | 28 | Answer: 29 | We Danced The Mamushka At Waterloo 30 | 31 | Test: 32 | de noche todos los gatos son pardos 33 | 34 | Answer: 35 | De Noche Todos Los Gatos Son Pardos 36 | 37 | Test: 38 | all i see turns to brown 39 | 40 | Answer: 41 | All I See Turns To Brown -------------------------------------------------------------------------------- /problems/functions/fibonacci_rec.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Fibonacci numbers 3 | 4 | Statement: 5 | Given a non-negative integer \( n \), print the \( n \)th Fibonacci number. Do this by writing a function fib(n) which takes the non-negative integer \( n \) and returns the \( n \)th Fibonacci number. 6 | 7 |

Don't use loops, use the flair of recursion instead. 8 | However, you should think about why the recursive method is much slower than using loops. 9 | 10 | 11 | Test: 12 | 6 13 | 14 | Answer: 15 | 8 16 | 17 | 18 | Test: 19 | 1 20 | 21 | Answer: 22 | 1 23 | 24 | 25 | Test: 26 | 2 27 | 28 | Answer: 29 | 1 30 | 31 | 32 | Test: 33 | 3 34 | 35 | Answer: 36 | 2 37 | 38 | 39 | Test: 40 | 4 41 | 42 | Answer: 43 | 3 44 | 45 | 46 | Test: 47 | 5 48 | 49 | Answer: 50 | 5 51 | 52 | 53 | Test: 54 | 7 55 | 56 | Answer: 57 | 13 58 | 59 | 60 | Test: 61 | 8 62 | 63 | Answer: 64 | 21 65 | -------------------------------------------------------------------------------- /problems/functions/length_of_segment.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The length of the segment 3 | 4 | Statement: 5 | Given four real numbers representing cartesian coordinates: \( \left ( x_{1}, y_{1} \right ), \left ( x_{2}, y_{2} \right ) \). Write a function distance(x1, y1, x2, y2) to compute the distance between the points \( \left ( x_{1}, y_{1} \right ) \) and \( \left ( x_{2}, y_{2} \right ) \). Read four real numbers and print the resulting distance calculated by the function. 6 | 7 |

The formula for distance between two points can be found at Wolfram. 8 | 9 | Test: 10 | 0 11 | 0 12 | 1 13 | 1 14 | 15 | Answer: 16 | 1.41421 17 | 18 | 19 | Test: 20 | 0 21 | 0 22 | 1 23 | 0 24 | 25 | Answer: 26 | 1 27 | 28 | 29 | Test: 30 | 3 31 | -2 32 | -1 33 | 7 34 | 35 | Answer: 36 | 9.84886 37 | 38 | 39 | Test: 40 | 0.1 41 | 0.1 42 | 0.2 43 | 0.2 44 | 45 | Answer: 46 | 0.141421 47 | 48 | 49 | Test: 50 | -1 51 | -1 52 | -3 53 | -5 54 | 55 | Answer: 56 | 4.47214 57 | 58 | -------------------------------------------------------------------------------- /problems/functions/negative_power.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Negative exponent 3 | 4 | Statement: 5 |

Given a positive real number \( a \) and integer \( n \). 6 | 7 |

Compute \( a^{n} \). Write a function power(a, n) to calculate the results using the function and print the result of the expression. 8 | 9 |

Don't use the same function from the standard library. 10 | 11 | Test: 12 | 2 13 | -3 14 | 15 | Answer: 16 | 0.125 17 | 18 | 19 | Test: 20 | 2 21 | 1 22 | 23 | Answer: 24 | 2 25 | 26 | 27 | Test: 28 | 2 29 | 2 30 | 31 | Answer: 32 | 4 33 | 34 | 35 | Test: 36 | 2 37 | 3 38 | 39 | Answer: 40 | 8 41 | 42 | 43 | Test: 44 | 2 45 | 4 46 | 47 | Answer: 48 | 16 49 | 50 | 51 | Test: 52 | 2 53 | 9 54 | 55 | Answer: 56 | 512 57 | 58 | 59 | Test: 60 | 2 61 | 10 62 | 63 | Answer: 64 | 1024 65 | 66 | 67 | Test: 68 | 2 69 | 15 70 | 71 | Answer: 72 | 32768 73 | 74 | 75 | Test: 76 | 2 77 | 0 78 | 79 | Answer: 80 | 1 81 | 82 | 83 | Test: 84 | 3 85 | 1 86 | 87 | Answer: 88 | 3 89 | 90 | 91 | Test: 92 | 3 93 | 2 94 | 95 | Answer: 96 | 9 97 | 98 | 99 | Test: 100 | 3 101 | 3 102 | 103 | Answer: 104 | 27 105 | 106 | 107 | Test: 108 | 3 109 | 10 110 | 111 | Answer: 112 | 59049 113 | 114 | 115 | Test: 116 | 3 117 | 0 118 | 119 | Answer: 120 | 1 121 | 122 | 123 | Test: 124 | 1.1414 125 | 2 126 | 127 | Answer: 128 | 1.30279 129 | 130 | 131 | Test: 132 | 1.5 133 | 10 134 | 135 | Answer: 136 | 57.665 137 | 138 | 139 | Test: 140 | 1 141 | -1 142 | 143 | Answer: 144 | 1 145 | 146 | 147 | Test: 148 | 2 149 | -1 150 | 151 | Answer: 152 | 0.5 153 | 154 | 155 | Test: 156 | 2 157 | -2 158 | 159 | Answer: 160 | 0.25 161 | 162 | 163 | Test: 164 | 2 165 | -3 166 | 167 | Answer: 168 | 0.125 169 | 170 | 171 | Test: 172 | 2 173 | -4 174 | 175 | Answer: 176 | 0.0625 177 | 178 | 179 | Test: 180 | 2 181 | -8 182 | 183 | Answer: 184 | 0.00390625 185 | 186 | 187 | Test: 188 | 2 189 | -9 190 | 191 | Answer: 192 | 0.00195312 193 | 194 | 195 | Test: 196 | 2 197 | -10 198 | 199 | Answer: 200 | 0.000976562 201 | 202 | 203 | Test: 204 | 2 205 | -15 206 | 207 | Answer: 208 | 3.05176e-05 209 | 210 | 211 | Test: 212 | 3 213 | -1 214 | 215 | Answer: 216 | 0.333333 217 | 218 | 219 | Test: 220 | 3 221 | -2 222 | 223 | Answer: 224 | 0.111111 225 | 226 | 227 | Test: 228 | 3 229 | -3 230 | 231 | Answer: 232 | 0.037037 233 | 234 | 235 | Test: 236 | 3 237 | -4 238 | 239 | Answer: 240 | 0.0123457 241 | 242 | 243 | Test: 244 | 3 245 | -5 246 | 247 | Answer: 248 | 0.00411523 249 | 250 | 251 | Test: 252 | 3 253 | -10 254 | 255 | Answer: 256 | 1.69351e-05 257 | 258 | 259 | Test: 260 | 3 261 | -6 262 | 263 | Answer: 264 | 0.00137174 265 | 266 | 267 | Test: 268 | 1.1414 269 | -2 270 | 271 | Answer: 272 | 0.767581 273 | 274 | 275 | Test: 276 | 1.5 277 | -10 278 | 279 | Answer: 280 | 0.0173415 281 | -------------------------------------------------------------------------------- /problems/functions/power_rec.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Exponentiation 3 | 4 | Statement: 5 |

Given a positive real number \( a \) and a non-negative integer \( n \). Calculate \( a^{n} \) without using loops, ** operator or the built in function math.pow(). Instead, use recursion and the relation \( a^{n} = a \cdot a^{n-1} \). Print the result. 6 | 7 |

Form the function power(a, n). 8 | 9 | Test: 10 | 2 11 | 3 12 | 13 | Answer: 14 | 8 15 | 16 | 17 | Test: 18 | 2 19 | 2 20 | 21 | Answer: 22 | 4 23 | 24 | 25 | Test: 26 | 2 27 | 1 28 | 29 | Answer: 30 | 2 31 | 32 | 33 | Test: 34 | 2 35 | 4 36 | 37 | Answer: 38 | 16 39 | 40 | 41 | Test: 42 | 2 43 | 5 44 | 45 | Answer: 46 | 32 47 | 48 | 49 | Test: 50 | 2 51 | 6 52 | 53 | Answer: 54 | 64 55 | 56 | 57 | Test: 58 | 2 59 | 7 60 | 61 | Answer: 62 | 128 63 | 64 | 65 | Test: 66 | 2 67 | 8 68 | 69 | Answer: 70 | 256 71 | 72 | 73 | Test: 74 | 2 75 | 9 76 | 77 | Answer: 78 | 512 79 | 80 | 81 | Test: 82 | 2 83 | 10 84 | 85 | Answer: 86 | 1024 87 | 88 | 89 | Test: 90 | 2 91 | 15 92 | 93 | Answer: 94 | 32768 95 | 96 | 97 | Test: 98 | 2 99 | 0 100 | 101 | Answer: 102 | 1 103 | 104 | 105 | Test: 106 | 3 107 | 1 108 | 109 | Answer: 110 | 3 111 | 112 | 113 | Test: 114 | 3 115 | 2 116 | 117 | Answer: 118 | 9 119 | 120 | 121 | Test: 122 | 3 123 | 3 124 | 125 | Answer: 126 | 27 127 | 128 | 129 | Test: 130 | 3 131 | 4 132 | 133 | Answer: 134 | 81 135 | 136 | 137 | Test: 138 | 3 139 | 5 140 | 141 | Answer: 142 | 243 143 | 144 | 145 | Test: 146 | 3 147 | 10 148 | 149 | Answer: 150 | 59049 151 | 152 | 153 | Test: 154 | 3 155 | 0 156 | 157 | Answer: 158 | 1 159 | 160 | 161 | Test: 162 | 1.1414 163 | 2 164 | 165 | Answer: 166 | 1.30279 167 | 168 | 169 | Test: 170 | 1.5 171 | 10 172 | 173 | Answer: 174 | 57.665 175 | -------------------------------------------------------------------------------- /problems/functions/reverse_rec.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Reverse the sequence 3 | 4 | Statement: 5 | Given a sequence of integers that end with a \( 0 \). Print the sequence in reverse order. 6 | 7 |

Don't use lists or other data structures. Use the force of recursion instead. 8 | 9 | 10 | Test: 11 | 1 12 | 2 13 | 3 14 | 0 15 | 16 | Answer: 17 | 0 18 | 3 19 | 2 20 | 1 21 | 22 | 23 | Test: 24 | 8 25 | 7 26 | 2 27 | 3 28 | 1 29 | 4 30 | 5 31 | 0 32 | 33 | Answer: 34 | 0 35 | 5 36 | 4 37 | 1 38 | 3 39 | 2 40 | 7 41 | 8 42 | 43 | 44 | Test: 45 | 1 46 | 0 47 | 48 | Answer: 49 | 0 50 | 1 51 | 52 | 53 | Test: 54 | 0 55 | 56 | Answer: 57 | 0 58 | 59 | 60 | Test: 61 | 1 62 | 2 63 | 3 64 | 4 65 | 5 66 | 6 67 | 7 68 | 8 69 | 9 70 | 0 71 | 72 | Answer: 73 | 0 74 | 9 75 | 8 76 | 7 77 | 6 78 | 5 79 | 4 80 | 3 81 | 2 82 | 1 83 | 84 | 85 | -------------------------------------------------------------------------------- /problems/hello_harry.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Hello, Harry! 3 | 4 | Statement: 5 | Write a program that greets the user by printing the word "Hello", a comma, the name of the user and an exclamation mark after it. 6 | See the examples below. 7 |

8 | Warning. Your program's output should strictly match the desired one, character by character. 9 | There shouldn't be any space between the name and the exclamation mark. You can use + operator to 10 | concatenate two strings. See the lesson for details. 11 | 12 | Test: 13 | Harry 14 | 15 | Answer: 16 | Hello, Harry! 17 | 18 | Test: 19 | Mr. Potter 20 | 21 | Answer: 22 | Hello, Mr. Potter! 23 | 24 | Test: 25 | Lord Voldemort 26 | 27 | Answer: 28 | Hello, Lord Voldemort! 29 | -------------------------------------------------------------------------------- /problems/ifelse/bishop_move.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Bishop moves 3 | 4 | Statement: 5 | In chess, the bishop moves diagonally, any number of squares. Given two different squares of the chessboard, determine whether a bishop can go from the first to the second in one move. 6 | 7 |

8 | The program receives as input four numbers from 1 to 8, specifying the column and row numbers of the starting square and the column and row numbers of the ending square. 9 | The program should output YES if a Bishop can go from the first square to the second in one move, or NO otherwise. 10 | 11 |

12 | 13 | Test: 14 | 4 15 | 4 16 | 5 17 | 5 18 | 19 | Answer: 20 | YES 21 | 22 | 23 | Test: 24 | 4 25 | 4 26 | 5 27 | 4 28 | 29 | Answer: 30 | NO 31 | 32 | 33 | Test: 34 | 4 35 | 4 36 | 5 37 | 3 38 | 39 | Answer: 40 | YES 41 | 42 | 43 | Test: 44 | 4 45 | 4 46 | 4 47 | 5 48 | 49 | Answer: 50 | NO 51 | 52 | 53 | Test: 54 | 4 55 | 4 56 | 3 57 | 5 58 | 59 | Answer: 60 | YES 61 | 62 | 63 | Test: 64 | 4 65 | 4 66 | 4 67 | 3 68 | 69 | Answer: 70 | NO 71 | 72 | 73 | Test: 74 | 4 75 | 4 76 | 3 77 | 4 78 | 79 | Answer: 80 | NO 81 | 82 | 83 | Test: 84 | 4 85 | 4 86 | 3 87 | 3 88 | 89 | Answer: 90 | YES 91 | 92 | 93 | Test: 94 | 1 95 | 1 96 | 1 97 | 8 98 | 99 | Answer: 100 | NO 101 | 102 | 103 | Test: 104 | 1 105 | 1 106 | 8 107 | 8 108 | 109 | Answer: 110 | YES 111 | 112 | 113 | Test: 114 | 1 115 | 1 116 | 8 117 | 1 118 | 119 | Answer: 120 | NO 121 | 122 | 123 | Test: 124 | 1 125 | 8 126 | 8 127 | 8 128 | 129 | Answer: 130 | NO 131 | 132 | 133 | Test: 134 | 1 135 | 8 136 | 8 137 | 1 138 | 139 | Answer: 140 | YES 141 | 142 | 143 | Test: 144 | 1 145 | 8 146 | 1 147 | 1 148 | 149 | Answer: 150 | NO 151 | 152 | 153 | Test: 154 | 8 155 | 8 156 | 8 157 | 1 158 | 159 | Answer: 160 | NO 161 | 162 | 163 | Test: 164 | 8 165 | 8 166 | 1 167 | 1 168 | 169 | Answer: 170 | YES 171 | 172 | 173 | Test: 174 | 8 175 | 8 176 | 1 177 | 8 178 | 179 | Answer: 180 | NO 181 | 182 | 183 | Test: 184 | 8 185 | 1 186 | 1 187 | 1 188 | 189 | Answer: 190 | NO 191 | 192 | 193 | Test: 194 | 8 195 | 1 196 | 1 197 | 8 198 | 199 | Answer: 200 | YES 201 | 202 | 203 | Test: 204 | 8 205 | 1 206 | 8 207 | 8 208 | 209 | Answer: 210 | NO 211 | 212 | 213 | Test: 214 | 1 215 | 1 216 | 1 217 | 2 218 | 219 | Answer: 220 | NO 221 | 222 | 223 | Test: 224 | 1 225 | 1 226 | 2 227 | 2 228 | 229 | Answer: 230 | YES 231 | 232 | 233 | Test: 234 | 1 235 | 1 236 | 2 237 | 1 238 | 239 | Answer: 240 | NO 241 | 242 | 243 | Test: 244 | 4 245 | 4 246 | 6 247 | 6 248 | 249 | Answer: 250 | YES 251 | 252 | 253 | Test: 254 | 4 255 | 4 256 | 2 257 | 2 258 | 259 | Answer: 260 | YES 261 | 262 | 263 | Test: 264 | 4 265 | 4 266 | 6 267 | 2 268 | 269 | Answer: 270 | YES 271 | 272 | 273 | Test: 274 | 4 275 | 4 276 | 2 277 | 6 278 | 279 | Answer: 280 | YES 281 | 282 | 283 | Test: 284 | 4 285 | 4 286 | 2 287 | 7 288 | 289 | Answer: 290 | NO 291 | 292 | 293 | Test: 294 | 4 295 | 4 296 | 4 297 | 6 298 | 299 | Answer: 300 | NO 301 | 302 | 303 | Test: 304 | 4 305 | 4 306 | 2 307 | 4 308 | 309 | Answer: 310 | NO 311 | 312 | 313 | Test: 314 | 7 315 | 4 316 | 2 317 | 5 318 | 319 | Answer: 320 | NO 321 | 322 | 323 | Test: 324 | 7 325 | 5 326 | 1 327 | 1 328 | 329 | Answer: 330 | NO 331 | 332 | 333 | -------------------------------------------------------------------------------- /problems/ifelse/chess_board.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Chess board - same color 3 | 4 | Statement: 5 | Given two cells of a chessboard. If they are painted in one color, print the word YES, and if in a different color - NO. 6 | 7 |

8 | The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. 9 | 10 |

11 | 12 | Test: 13 | 1 14 | 1 15 | 2 16 | 6 17 | 18 | Answer: 19 | YES 20 | 21 | Test: 22 | 2 23 | 2 24 | 2 25 | 5 26 | 27 | Answer: 28 | NO 29 | 30 | Test: 31 | 2 32 | 2 33 | 2 34 | 4 35 | 36 | Answer: 37 | YES 38 | 39 | Test: 40 | 2 41 | 3 42 | 3 43 | 2 44 | 45 | Answer: 46 | YES 47 | 48 | Test: 49 | 2 50 | 3 51 | 7 52 | 8 53 | 54 | Answer: 55 | YES 56 | 57 | Test: 58 | 2 59 | 3 60 | 8 61 | 8 62 | 63 | Answer: 64 | NO 65 | 66 | Test: 67 | 5 68 | 7 69 | 5 70 | 7 71 | 72 | Answer: 73 | YES 74 | 75 | Test: 76 | 2 77 | 6 78 | 3 79 | 1 80 | 81 | Answer: 82 | YES 83 | 84 | Test: 85 | 2 86 | 3 87 | 4 88 | 5 89 | 90 | Answer: 91 | YES 92 | 93 | Test: 94 | 7 95 | 2 96 | 2 97 | 3 98 | 99 | Answer: 100 | YES 101 | 102 | Test: 103 | 1 104 | 6 105 | 7 106 | 2 107 | 108 | Answer: 109 | YES 110 | -------------------------------------------------------------------------------- /problems/ifelse/chocolate.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Chocolate bar 3 | 4 | Statement: 5 | Chocolate bar has the form of a rectangle divided into \(n \times m\) portions. Chocolate bar can be split into 6 | two rectangular parts by breaking it along a selected straight line on its pattern. Determine whether it is possible to split it so that one of the parts will have 7 | exactly k squares. 8 | 9 |

10 | The program reads three integers: n, m, and k. It should print YES or NO. 11 | 12 | Test: 13 | 4 14 | 2 15 | 6 16 | 17 | Answer: 18 | YES 19 | 20 | 21 | Test: 22 | 2 23 | 10 24 | 7 25 | 26 | Answer: 27 | NO 28 | 29 | 30 | Test: 31 | 5 32 | 7 33 | 1 34 | 35 | Answer: 36 | NO 37 | 38 | 39 | Test: 40 | 7 41 | 4 42 | 21 43 | 44 | Answer: 45 | YES 46 | 47 | 48 | Test: 49 | 5 50 | 12 51 | 100 52 | 53 | Answer: 54 | NO 55 | 56 | 57 | Test: 58 | 6 59 | 6 60 | 6 61 | 62 | Answer: 63 | YES 64 | 65 | 66 | Test: 67 | 6 68 | 6 69 | 35 70 | 71 | Answer: 72 | NO 73 | 74 | 75 | Test: 76 | 6 77 | 6 78 | 37 79 | 80 | Answer: 81 | NO 82 | 83 | 84 | Test: 85 | 7 86 | 1 87 | 99 88 | 89 | Answer: 90 | NO 91 | 92 | 93 | Test: 94 | 300 95 | 100 96 | 3000 97 | 98 | Answer: 99 | YES 100 | 101 | 102 | Test: 103 | 256 104 | 124 105 | 4069 106 | 107 | Answer: 108 | NO 109 | 110 | 111 | Test: 112 | 348 113 | 41 114 | 6183 115 | 116 | Answer: 117 | NO 118 | 119 | 120 | Test: 121 | 387 122 | 13 123 | 2709 124 | 125 | Answer: 126 | YES 127 | 128 | 129 | Test: 130 | 13 131 | 387 132 | 2709 133 | 134 | Answer: 135 | YES 136 | 137 | 138 | Test: 139 | 1 140 | 1 141 | 2 142 | 143 | Answer: 144 | NO 145 | 146 | 147 | -------------------------------------------------------------------------------- /problems/ifelse/jacob_the_swimmer.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Яша плавает в бассейне 3 | 4 | Statement: 5 | Яша плавал в бассейне размером N × M метров и устал. В этот момент он обнаружил, что находится на расстоянии x метров от одного из длинных бортиков (не обязательно от ближайшего) и y метров от одного из коротких бортиков. Какое минимальное расстояние должен проплыть Яша, чтобы выбраться из бассейна на бортик? 6 | 7 | Программа получает на вход числа N, M, x, y. Программа должна вывести число метров, которое нужно проплыть Яше до бортика. 8 | 9 | Test: 10 | 23 11 | 52 12 | 8 13 | 43 14 | 15 | Answer: 16 | 8 17 | 18 | 19 | Test: 20 | 18 21 | 90 22 | 3 23 | 63 24 | 25 | Answer: 26 | 3 27 | 28 | 29 | Test: 30 | 96 31 | 1 32 | 0 33 | 83 34 | 35 | Answer: 36 | 0 37 | 38 | 39 | Test: 40 | 78 41 | 29 42 | 1 43 | 10 44 | 45 | Answer: 46 | 1 47 | 48 | 49 | Test: 50 | 49 51 | 31 52 | 14 53 | 32 54 | 55 | Answer: 56 | 14 57 | 58 | 59 | Test: 60 | 53 61 | 3 62 | 2 63 | 0 64 | 65 | Answer: 66 | 0 67 | 68 | 69 | Test: 70 | 73 71 | 63 72 | 51 73 | 8 74 | 75 | Answer: 76 | 8 77 | 78 | 79 | Test: 80 | 57 81 | 7 82 | 3 83 | 0 84 | 85 | Answer: 86 | 0 87 | 88 | 89 | Test: 90 | 54 91 | 22 92 | 15 93 | 6 94 | 95 | Answer: 96 | 6 97 | 98 | 99 | Test: 100 | 50 101 | 42 102 | 17 103 | 29 104 | 105 | Answer: 106 | 17 107 | 108 | 109 | Test: 110 | 43 111 | 33 112 | 6 113 | 30 114 | 115 | Answer: 116 | 6 117 | 118 | 119 | Test: 120 | 65 121 | 30 122 | 13 123 | 12 124 | 125 | Answer: 126 | 12 127 | 128 | 129 | Test: 130 | 11 131 | 47 132 | 1 133 | 20 134 | 135 | Answer: 136 | 1 137 | 138 | 139 | Test: 140 | 5 141 | 98 142 | 2 143 | 81 144 | 145 | Answer: 146 | 2 147 | 148 | 149 | Test: 150 | 34 151 | 39 152 | 3 153 | 7 154 | 155 | Answer: 156 | 3 157 | 158 | 159 | Test: 160 | 45 161 | 48 162 | 17 163 | 11 164 | 165 | Answer: 166 | 11 167 | 168 | 169 | Test: 170 | 78 171 | 48 172 | 0 173 | 4 174 | 175 | Answer: 176 | 0 177 | 178 | 179 | Test: 180 | 90 181 | 72 182 | 9 183 | 35 184 | 185 | Answer: 186 | 9 187 | 188 | 189 | Test: 190 | 16 191 | 100 192 | 7 193 | 11 194 | 195 | Answer: 196 | 7 197 | 198 | 199 | Test: 200 | 38 201 | 31 202 | 2 203 | 4 204 | 205 | Answer: 206 | 2 207 | 208 | 209 | Test: 210 | 96 211 | 45 212 | 41 213 | 22 214 | 215 | Answer: 216 | 4 217 | 218 | 219 | Test: 220 | 3 221 | 56 222 | 0 223 | 37 224 | 225 | Answer: 226 | 0 227 | 228 | 229 | Test: 230 | 28 231 | 25 232 | 17 233 | 28 234 | 235 | Answer: 236 | 0 237 | 238 | 239 | Test: 240 | 6 241 | 97 242 | 6 243 | 95 244 | 245 | Answer: 246 | 0 247 | 248 | 249 | Test: 250 | 88 251 | 18 252 | 7 253 | 70 254 | 255 | Answer: 256 | 7 257 | 258 | 259 | Test: 260 | 25 261 | 57 262 | 0 263 | 20 264 | 265 | Answer: 266 | 0 267 | 268 | 269 | Test: 270 | 97 271 | 38 272 | 6 273 | 38 274 | 275 | Answer: 276 | 6 277 | 278 | 279 | Test: 280 | 98 281 | 77 282 | 31 283 | 80 284 | 285 | Answer: 286 | 18 287 | 288 | 289 | Test: 290 | 41 291 | 84 292 | 4 293 | 73 294 | 295 | Answer: 296 | 4 297 | 298 | 299 | Test: 300 | 46 301 | 90 302 | 28 303 | 77 304 | 305 | Answer: 306 | 13 307 | 308 | 309 | Test: 310 | 5 311 | 94 312 | 1 313 | 36 314 | 315 | Answer: 316 | 1 317 | 318 | 319 | Test: 320 | 66 321 | 45 322 | 35 323 | 47 324 | 325 | Answer: 326 | 10 327 | 328 | 329 | Test: 330 | 60 331 | 98 332 | 39 333 | 27 334 | 335 | Answer: 336 | 21 337 | 338 | 339 | Test: 340 | 67 341 | 22 342 | 7 343 | 54 344 | 345 | Answer: 346 | 7 347 | 348 | 349 | Test: 350 | 6 351 | 38 352 | 1 353 | 16 354 | 355 | Answer: 356 | 1 357 | 358 | 359 | Test: 360 | 72 361 | 19 362 | 9 363 | 42 364 | 365 | Answer: 366 | 9 367 | 368 | 369 | Test: 370 | 79 371 | 78 372 | 49 373 | 79 374 | 375 | Answer: 376 | 0 377 | 378 | 379 | Test: 380 | 71 381 | 26 382 | 21 383 | 42 384 | 385 | Answer: 386 | 5 387 | 388 | 389 | Test: 390 | 5 391 | 87 392 | 3 393 | 38 394 | 395 | Answer: 396 | 2 397 | 398 | 399 | Test: 400 | 31 401 | 79 402 | 0 403 | 74 404 | 405 | Answer: 406 | 0 407 | 408 | 409 | 410 | 411 | -------------------------------------------------------------------------------- /problems/ifelse/king_move.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | King move 3 | 4 | Statement: 5 | Chess king moves horizontally, vertically or diagonally to any adjacent cell. Given two different cells of the chessboard, determine whether a king can go from the first cell to the second in one move. 6 | 7 |

8 | The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. 9 | The program should output YES if a king can go from the first cell to the second in one move, or NO otherwise. 10 | 11 |

12 | 13 | Test: 14 | 4 15 | 4 16 | 5 17 | 5 18 | 19 | Answer: 20 | YES 21 | 22 | 23 | Test: 24 | 4 25 | 4 26 | 5 27 | 4 28 | 29 | 30 | Answer: 31 | YES 32 | 33 | 34 | Test: 35 | 4 36 | 4 37 | 5 38 | 3 39 | 40 | Answer: 41 | YES 42 | 43 | 44 | Test: 45 | 4 46 | 4 47 | 4 48 | 5 49 | 50 | Answer: 51 | YES 52 | 53 | 54 | Test: 55 | 4 56 | 4 57 | 3 58 | 5 59 | 60 | Answer: 61 | YES 62 | 63 | 64 | Test: 65 | 4 66 | 4 67 | 4 68 | 3 69 | 70 | Answer: 71 | YES 72 | 73 | 74 | Test: 75 | 4 76 | 4 77 | 3 78 | 4 79 | 80 | Answer: 81 | YES 82 | 83 | 84 | Test: 85 | 4 86 | 4 87 | 3 88 | 3 89 | 90 | Answer: 91 | YES 92 | 93 | 94 | Test: 95 | 1 96 | 1 97 | 1 98 | 8 99 | 100 | Answer: 101 | NO 102 | 103 | 104 | Test: 105 | 1 106 | 1 107 | 8 108 | 8 109 | 110 | Answer: 111 | NO 112 | 113 | 114 | Test: 115 | 1 116 | 1 117 | 8 118 | 1 119 | 120 | Answer: 121 | NO 122 | 123 | 124 | Test: 125 | 1 126 | 8 127 | 8 128 | 8 129 | 130 | Answer: 131 | NO 132 | 133 | 134 | Test: 135 | 1 136 | 8 137 | 8 138 | 1 139 | 140 | Answer: 141 | NO 142 | 143 | 144 | Test: 145 | 1 146 | 8 147 | 1 148 | 1 149 | 150 | Answer: 151 | NO 152 | 153 | 154 | Test: 155 | 8 156 | 8 157 | 8 158 | 1 159 | 160 | Answer: 161 | NO 162 | 163 | 164 | Test: 165 | 8 166 | 8 167 | 1 168 | 1 169 | 170 | Answer: 171 | NO 172 | 173 | 174 | Test: 175 | 8 176 | 8 177 | 1 178 | 8 179 | 180 | Answer: 181 | NO 182 | 183 | 184 | Test: 185 | 8 186 | 1 187 | 1 188 | 1 189 | 190 | Answer: 191 | NO 192 | 193 | 194 | Test: 195 | 8 196 | 1 197 | 1 198 | 8 199 | 200 | Answer: 201 | NO 202 | 203 | 204 | Test: 205 | 8 206 | 1 207 | 8 208 | 8 209 | 210 | Answer: 211 | NO 212 | 213 | 214 | Test: 215 | 1 216 | 1 217 | 1 218 | 2 219 | 220 | Answer: 221 | YES 222 | 223 | 224 | Test: 225 | 1 226 | 1 227 | 2 228 | 2 229 | 230 | Answer: 231 | YES 232 | 233 | 234 | Test: 235 | 1 236 | 1 237 | 2 238 | 1 239 | 240 | Answer: 241 | YES 242 | 243 | 244 | Test: 245 | 4 246 | 4 247 | 6 248 | 6 249 | 250 | Answer: 251 | NO 252 | 253 | 254 | Test: 255 | 4 256 | 4 257 | 2 258 | 2 259 | 260 | Answer: 261 | NO 262 | 263 | 264 | Test: 265 | 4 266 | 4 267 | 6 268 | 2 269 | 270 | Answer: 271 | NO 272 | 273 | 274 | Test: 275 | 4 276 | 4 277 | 2 278 | 6 279 | 280 | Answer: 281 | NO 282 | 283 | 284 | Test: 285 | 4 286 | 4 287 | 2 288 | 7 289 | 290 | Answer: 291 | NO 292 | 293 | 294 | Test: 295 | 4 296 | 4 297 | 4 298 | 6 299 | 300 | Answer: 301 | NO 302 | 303 | 304 | Test: 305 | 4 306 | 4 307 | 2 308 | 4 309 | 310 | Answer: 311 | NO 312 | 313 | 314 | Test: 315 | 4 316 | 4 317 | 5 318 | 6 319 | 320 | Answer: 321 | NO 322 | 323 | 324 | Test: 325 | 1 326 | 7 327 | 1 328 | 8 329 | 330 | Answer: 331 | YES 332 | 333 | 334 | Test: 335 | 4 336 | 3 337 | 2 338 | 2 339 | 340 | 341 | Answer: 342 | NO 343 | 344 | -------------------------------------------------------------------------------- /problems/ifelse/knight_move.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Knight move 3 | 4 | Statement: 5 | Chess knight moves like the letter L. It can move two cells horizontally and one cell vertically, or two cells vertically and one cells horizontally. Given two different cells of the chessboard, determine whether a knight can go from the first cell to the second in one move. 6 | 7 |

8 | The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. 9 | The program should output YES if a knight can go from the first cell to the second in one move, or NO otherwise. 10 | 11 |

12 | 13 | Test: 14 | 1 15 | 1 16 | 1 17 | 4 18 | 19 | Answer: 20 | NO 21 | 22 | 23 | Test: 24 | 1 25 | 1 26 | 8 27 | 8 28 | 29 | Answer: 30 | NO 31 | 32 | 33 | Test: 34 | 2 35 | 4 36 | 3 37 | 2 38 | 39 | Answer: 40 | YES 41 | 42 | 43 | Test: 44 | 5 45 | 2 46 | 4 47 | 4 48 | 49 | Answer: 50 | YES 51 | 52 | 53 | Test: 54 | 2 55 | 8 56 | 3 57 | 7 58 | 59 | Answer: 60 | NO 61 | 62 | 63 | Test: 64 | 2 65 | 8 66 | 3 67 | 5 68 | 69 | Answer: 70 | NO 71 | 72 | 73 | Test: 74 | 5 75 | 5 76 | 3 77 | 7 78 | 79 | Answer: 80 | NO 81 | 82 | 83 | Test: 84 | 2 85 | 4 86 | 2 87 | 5 88 | 89 | Answer: 90 | NO 91 | 92 | 93 | Test: 94 | 4 95 | 7 96 | 6 97 | 6 98 | 99 | Answer: 100 | YES 101 | 102 | 103 | Test: 104 | 4 105 | 5 106 | 2 107 | 4 108 | 109 | Answer: 110 | YES 111 | 112 | 113 | Test: 114 | 2 115 | 3 116 | 3 117 | 2 118 | 119 | Answer: 120 | NO 121 | 122 | 123 | Test: 124 | 5 125 | 1 126 | 4 127 | 3 128 | 129 | Answer: 130 | YES 131 | 132 | 133 | Test: 134 | 6 135 | 2 136 | 8 137 | 3 138 | 139 | Answer: 140 | YES 141 | 142 | 143 | -------------------------------------------------------------------------------- /problems/ifelse/leap_year.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Leap year 3 | 4 | Statement: 5 |

6 | Given the year number. You need to check if this year is a leap year. If it is, print 7 | LEAP, otherwise print COMMON. 8 | 9 |

10 | The rules in Gregorian calendar are as follows: 11 |

15 | 16 |

17 | Warning. The words LEAP and COMMON should be printed all caps. 18 | 19 | 20 | Test: 21 | 2012 22 | 23 | Answer: 24 | LEAP 25 | 26 | Test: 27 | 2011 28 | 29 | Answer: 30 | COMMON 31 | 32 | Test: 33 | 1492 34 | 35 | Answer: 36 | LEAP 37 | 38 | Test: 39 | 1861 40 | 41 | Answer: 42 | COMMON 43 | 44 | Test: 45 | 1600 46 | 47 | Answer: 48 | LEAP 49 | 50 | Test: 51 | 1700 52 | 53 | Answer: 54 | COMMON 55 | 56 | Test: 57 | 1800 58 | 59 | Answer: 60 | COMMON 61 | 62 | Test: 63 | 1900 64 | 65 | Answer: 66 | COMMON 67 | 68 | Test: 69 | 2000 70 | 71 | Answer: 72 | LEAP 73 | -------------------------------------------------------------------------------- /problems/ifelse/minimum.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Minimum of two numbers 3 | 4 | Statement: 5 | Given two integers, print the smaller value. 6 | 7 | Test: 8 | 3 9 | 7 10 | 11 | Answer: 12 | 3 13 | 14 | Test: 15 | 2 16 | 2 17 | 18 | Answer: 19 | 2 20 | 21 | Test: 22 | 15 23 | -8 24 | 25 | Answer: 26 | -8 27 | 28 | Test: 29 | -15 30 | -8 31 | 32 | Answer: 33 | -15 34 | -------------------------------------------------------------------------------- /problems/ifelse/minimum3.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Minimum of three numbers 3 | 4 | Statement: 5 | Given three integers, print the smallest value. 6 | 7 | Test: 8 | 5 9 | 3 10 | 7 11 | 12 | Answer: 13 | 3 14 | 15 | Test: 16 | 10 17 | 30 18 | 4 19 | 20 | Answer: 21 | 4 22 | 23 | Test: 24 | -5 25 | -3 26 | -3 27 | 28 | Answer: 29 | -5 30 | 31 | Test: 32 | 1 33 | 10 34 | 20 35 | 36 | Answer: 37 | 1 38 | 39 | Test: 40 | 74 41 | 32 42 | 11 43 | 44 | Answer: 45 | 11 46 | 47 | Test: 48 | 50 49 | 80 50 | 25 51 | 52 | Answer: 53 | 25 54 | -------------------------------------------------------------------------------- /problems/ifelse/num_equal.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Equal numbers 3 | 4 | Statement: 5 | Given three integers, determine how many of them are equal to each other. The program must print one of these numbers: 3 (if all are the same), 2 (if two of them are equal to each other and the third is different) or 0 (if all numbers are different). 6 | 7 | Test: 8 | 10 9 | 5 10 | 10 11 | 12 | Answer: 13 | 2 14 | 15 | Test: 16 | 17 17 | 17 18 | -9 19 | 20 | Answer: 21 | 2 22 | 23 | Test: 24 | 4 25 | -82 26 | -82 27 | 28 | Answer: 29 | 2 30 | 31 | Test: 32 | 5 33 | 2 34 | 4 35 | 36 | Answer: 37 | 0 38 | 39 | Test: 40 | -149 41 | -146 42 | -142 43 | 44 | Answer: 45 | 0 46 | 47 | Test: 48 | 666 49 | 666 50 | 666 51 | 52 | Answer: 53 | 3 54 | -------------------------------------------------------------------------------- /problems/ifelse/queen_move.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Queen move 3 | 4 | Statement: 5 | Chess queen moves horizontally, vertically or diagonally to any number of cells. Given two different cells of the chessboard, determine whether a queen can go from the first cell to the second in one move. 6 | 7 |

8 | The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. 9 | The program should output YES if a queen can go from the first cell to the second in one move, or NO otherwise. 10 | 11 |

12 | 13 | Test: 14 | 1 15 | 1 16 | 2 17 | 2 18 | 19 | Answer: 20 | YES 21 | 22 | 23 | Test: 24 | 1 25 | 1 26 | 2 27 | 3 28 | 29 | Answer: 30 | NO 31 | 32 | 33 | Test: 34 | 5 35 | 6 36 | 3 37 | 3 38 | 39 | Answer: 40 | NO 41 | 42 | 43 | Test: 44 | 3 45 | 3 46 | 1 47 | 1 48 | 49 | Answer: 50 | YES 51 | 52 | 53 | Test: 54 | 6 55 | 5 56 | 2 57 | 5 58 | 59 | Answer: 60 | YES 61 | 62 | 63 | Test: 64 | 7 65 | 6 66 | 5 67 | 2 68 | 69 | Answer: 70 | NO 71 | 72 | 73 | Test: 74 | 2 75 | 7 76 | 6 77 | 7 78 | 79 | Answer: 80 | YES 81 | 82 | 83 | Test: 84 | 2 85 | 7 86 | 4 87 | 6 88 | 89 | Answer: 90 | NO 91 | 92 | 93 | Test: 94 | 7 95 | 4 96 | 2 97 | 5 98 | 99 | Answer: 100 | NO 101 | 102 | 103 | Test: 104 | 7 105 | 5 106 | 1 107 | 1 108 | 109 | Answer: 110 | NO 111 | 112 | 113 | Test: 114 | 2 115 | 4 116 | 5 117 | 7 118 | 119 | Answer: 120 | YES 121 | 122 | 123 | Test: 124 | 3 125 | 5 126 | 7 127 | 1 128 | 129 | Answer: 130 | YES 131 | 132 | 133 | Test: 134 | 5 135 | 2 136 | 5 137 | 8 138 | 139 | Answer: 140 | YES 141 | 142 | Test: 143 | 1 144 | 2 145 | 3 146 | 1 147 | 148 | Answer: 149 | NO 150 | 151 | Test: 152 | 2 153 | 1 154 | 1 155 | 3 156 | 157 | Answer: 158 | NO 159 | -------------------------------------------------------------------------------- /problems/ifelse/rook_move.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Rook move 3 | 4 | Statement: 5 | Chess rook moves horizontally or vertically. Given two different cells of the chessboard, determine whether a rook can go from the first cell to the second in one move. 6 | 7 |

8 | The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. 9 | The program should output YES if a rook can go from the first cell to the second in one move, or NO otherwise. 10 | 11 |

12 | 13 | Test: 14 | 4 15 | 4 16 | 5 17 | 5 18 | 19 | Answer: 20 | NO 21 | 22 | 23 | Test: 24 | 4 25 | 4 26 | 5 27 | 4 28 | 29 | 30 | Answer: 31 | YES 32 | 33 | 34 | Test: 35 | 4 36 | 4 37 | 5 38 | 3 39 | 40 | Answer: 41 | NO 42 | 43 | 44 | Test: 45 | 4 46 | 4 47 | 4 48 | 5 49 | 50 | Answer: 51 | YES 52 | 53 | 54 | Test: 55 | 4 56 | 4 57 | 3 58 | 5 59 | 60 | Answer: 61 | NO 62 | 63 | 64 | Test: 65 | 4 66 | 4 67 | 4 68 | 3 69 | 70 | Answer: 71 | YES 72 | 73 | 74 | Test: 75 | 4 76 | 4 77 | 3 78 | 4 79 | 80 | Answer: 81 | YES 82 | 83 | 84 | Test: 85 | 4 86 | 4 87 | 3 88 | 3 89 | 90 | Answer: 91 | NO 92 | 93 | 94 | Test: 95 | 1 96 | 1 97 | 1 98 | 8 99 | 100 | Answer: 101 | YES 102 | 103 | 104 | Test: 105 | 1 106 | 1 107 | 8 108 | 8 109 | 110 | Answer: 111 | NO 112 | 113 | 114 | Test: 115 | 1 116 | 1 117 | 8 118 | 1 119 | 120 | Answer: 121 | YES 122 | 123 | 124 | Test: 125 | 1 126 | 8 127 | 8 128 | 8 129 | 130 | Answer: 131 | YES 132 | 133 | 134 | Test: 135 | 1 136 | 8 137 | 8 138 | 1 139 | 140 | Answer: 141 | NO 142 | 143 | 144 | Test: 145 | 1 146 | 8 147 | 1 148 | 1 149 | 150 | Answer: 151 | YES 152 | 153 | 154 | Test: 155 | 8 156 | 8 157 | 8 158 | 1 159 | 160 | Answer: 161 | YES 162 | 163 | 164 | Test: 165 | 8 166 | 8 167 | 1 168 | 1 169 | 170 | Answer: 171 | NO 172 | 173 | 174 | Test: 175 | 8 176 | 8 177 | 1 178 | 8 179 | 180 | Answer: 181 | YES 182 | 183 | 184 | Test: 185 | 8 186 | 1 187 | 1 188 | 1 189 | 190 | Answer: 191 | YES 192 | 193 | 194 | Test: 195 | 8 196 | 1 197 | 1 198 | 8 199 | 200 | Answer: 201 | NO 202 | 203 | 204 | Test: 205 | 8 206 | 1 207 | 8 208 | 8 209 | 210 | Answer: 211 | YES 212 | 213 | 214 | Test: 215 | 1 216 | 1 217 | 1 218 | 2 219 | 220 | Answer: 221 | YES 222 | 223 | 224 | Test: 225 | 1 226 | 1 227 | 2 228 | 2 229 | 230 | Answer: 231 | NO 232 | 233 | 234 | Test: 235 | 1 236 | 1 237 | 2 238 | 1 239 | 240 | Answer: 241 | YES 242 | 243 | 244 | Test: 245 | 4 246 | 4 247 | 6 248 | 6 249 | 250 | Answer: 251 | NO 252 | 253 | 254 | Test: 255 | 4 256 | 4 257 | 2 258 | 2 259 | 260 | Answer: 261 | NO 262 | 263 | 264 | Test: 265 | 4 266 | 4 267 | 6 268 | 2 269 | 270 | Answer: 271 | NO 272 | 273 | 274 | Test: 275 | 4 276 | 4 277 | 2 278 | 6 279 | 280 | Answer: 281 | NO 282 | 283 | 284 | Test: 285 | 4 286 | 4 287 | 2 288 | 7 289 | 290 | Answer: 291 | NO 292 | 293 | 294 | Test: 295 | 4 296 | 4 297 | 4 298 | 6 299 | 300 | Answer: 301 | YES 302 | 303 | 304 | Test: 305 | 4 306 | 4 307 | 2 308 | 4 309 | 310 | Answer: 311 | YES 312 | 313 | -------------------------------------------------------------------------------- /problems/ifelse/signum.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Sign function 3 | 4 | Statement: 5 | 6 |

7 | For the given integer X print 1 if it's positive, -1 if it's negative, or 0 8 | if it's equal to zero. 9 | 10 |

11 | Try to use the cascade if-elif-else for it. 12 | 13 | Test: 14 | 179 15 | 16 | Answer: 17 | 1 18 | 19 | Test: 20 | -42 21 | 22 | Answer: 23 | -1 24 | 25 | Test: 26 | 0 27 | 28 | Answer: 29 | 0 30 | 31 | Test: 32 | 17 33 | 34 | Answer: 35 | 1 36 | 37 | Test: 38 | -100 39 | 40 | Answer: 41 | -1 42 | -------------------------------------------------------------------------------- /problems/int_and_float/compound_interest.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Сложные проценты 3 | 4 | Statement: 5 | Процентная ставка по вкладу составляет P процентов годовых, которые прибавляются к сумме вклада через год. Вклад составляет X рублей Y копеек. Определите размер вклада через K лет. 6 | 7 |

8 | Программа получает на вход целые числа P, X, Y, K и должна вывести два числа: величину вклада через год в рублях и копейках. Дробное число копеек по истечение года отбрасывается. Перерасчет суммы вклада (с отбрасыванием дробных частей копеек) происходит ежегодно. 9 | 10 | Test: 11 | 12 12 | 179 13 | 0 14 | 5 15 | 16 | Answer: 17 | 315 43 18 | 19 | 20 | Test: 21 | 13 22 | 179 23 | 0 24 | 100 25 | 26 | Answer: 27 | 36360285 50 28 | 29 | 30 | Test: 31 | 1 32 | 1 33 | 0 34 | 1000 35 | 36 | Answer: 37 | 11881 92 38 | 39 | 40 | Test: 41 | 100 42 | 1 43 | 0 44 | 10 45 | 46 | Answer: 47 | 1024 0 48 | 49 | 50 | Test: 51 | 100 52 | 0 53 | 1 54 | 30 55 | 56 | Answer: 57 | 10737418 24 58 | 59 | 60 | Test: 61 | 17 62 | 94 63 | 41 64 | 27 65 | 66 | Answer: 67 | 6544 33 68 | 69 | 70 | Test: 71 | 23 72 | 19382 73 | 23 74 | 5 75 | 76 | Answer: 77 | 54566 88 78 | 79 | 80 | Test: 81 | 17 82 | 35 83 | 87 84 | 14 85 | 86 | Answer: 87 | 322 88 88 | 89 | 90 | Test: 91 | 1 92 | 1 93 | 99 94 | 1 95 | 96 | Answer: 97 | 2 0 98 | -------------------------------------------------------------------------------- /problems/int_and_float/digit_after_separator.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | First digit after decimal point 3 | 4 | Statement: 5 | Given a positive real number, print its first digit to the right of the decimal point. 6 | 7 | Test: 8 | 1.79 9 | 10 | Answer: 11 | 7 12 | 13 | 14 | Test: 15 | 10.34 16 | 17 | Answer: 18 | 3 19 | 20 | 21 | Test: 22 | 0.001 23 | 24 | Answer: 25 | 0 26 | 27 | 28 | Test: 29 | 179 30 | 31 | Answer: 32 | 0 33 | 34 | 35 | Test: 36 | 19.99 37 | 38 | Answer: 39 | 9 40 | 41 | 42 | Test: 43 | 179.12 44 | 45 | Answer: 46 | 1 47 | 48 | 49 | Test: 50 | 5.29 51 | 52 | Answer: 53 | 2 54 | 55 | 56 | Test: 57 | 0.31 58 | 59 | Answer: 60 | 3 61 | 62 | 63 | Test: 64 | 12.45 65 | 66 | Answer: 67 | 4 68 | 69 | 70 | Test: 71 | 18.58 72 | 73 | Answer: 74 | 5 75 | 76 | 77 | Test: 78 | 0.83 79 | 80 | Answer: 81 | 8 82 | 83 | 84 | Test: 85 | 999.99 86 | 87 | Answer: 88 | 9 89 | 90 | 91 | Test: 92 | 146.67 93 | 94 | Answer: 95 | 6 96 | 97 | 98 | Test: 99 | 1293.73 100 | 101 | Answer: 102 | 7 103 | 104 | 105 | Test: 106 | 0.09999 107 | 108 | Answer: 109 | 0 110 | 111 | 112 | Test: 113 | 312.19999 114 | 115 | Answer: 116 | 1 117 | 118 | 119 | Test: 120 | 901.29999 121 | 122 | Answer: 123 | 2 124 | 125 | 126 | Test: 127 | 3.39999 128 | 129 | Answer: 130 | 3 131 | 132 | 133 | Test: 134 | 2371.49999 135 | 136 | Answer: 137 | 4 138 | 139 | 140 | Test: 141 | 290.59999 142 | 143 | Answer: 144 | 5 145 | 146 | 147 | Test: 148 | 90291.69999 149 | 150 | Answer: 151 | 6 152 | 153 | 154 | Test: 155 | 412.79999 156 | 157 | Answer: 158 | 7 159 | 160 | 161 | Test: 162 | 1.89999 163 | 164 | Answer: 165 | 8 166 | 167 | 168 | Test: 169 | 0.999999 170 | 171 | Answer: 172 | 9 173 | -------------------------------------------------------------------------------- /problems/int_and_float/fractional_part.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Fractional part 3 | 4 | Statement: 5 | Given a positive real number, print its fractional part. 6 | 7 | 8 | Test: 9 | 17.9 10 | 11 | Answer: 12 | 0.9 13 | 14 | 15 | Test: 16 | 10.34 17 | 18 | Answer: 19 | 0.34 20 | 21 | 22 | Test: 23 | 0.001 24 | 25 | Answer: 26 | 0.001 27 | 28 | 29 | Test: 30 | 179 31 | 32 | Answer: 33 | 0 34 | 35 | 36 | Test: 37 | 19.99 38 | 39 | Answer: 40 | 0.99 41 | 42 | 43 | -------------------------------------------------------------------------------- /problems/int_and_float/last_digit.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Last digit of integer 3 | 4 | Statement: 5 | Given an integer number, print its last digit. 6 | 7 | 8 | Test: 9 | 179 10 | 11 | Answer: 12 | 9 13 | 14 | 15 | Test: 16 | 40 17 | 18 | Answer: 19 | 0 20 | 21 | 22 | Test: 23 | 101 24 | 25 | Answer: 26 | 1 27 | 28 | 29 | Test: 30 | 222 31 | 32 | Answer: 33 | 2 34 | 35 | 36 | Test: 37 | 1923 38 | 39 | Answer: 40 | 3 41 | 42 | 43 | Test: 44 | 74 45 | 46 | Answer: 47 | 4 48 | 49 | 50 | Test: 51 | 505 52 | 53 | Answer: 54 | 5 55 | 56 | 57 | Test: 58 | 996 59 | 60 | Answer: 61 | 6 62 | 63 | 64 | Test: 65 | 3487 66 | 67 | Answer: 68 | 7 69 | 70 | 71 | Test: 72 | 308 73 | 74 | Answer: 75 | 8 76 | 77 | 78 | Test: 79 | 1 80 | 81 | Answer: 82 | 1 83 | 84 | 85 | Test: 86 | 2 87 | 88 | Answer: 89 | 2 90 | 91 | 92 | Test: 93 | 3 94 | 95 | Answer: 96 | 3 97 | 98 | 99 | Test: 100 | 4 101 | 102 | Answer: 103 | 4 104 | 105 | 106 | Test: 107 | 5 108 | 109 | Answer: 110 | 5 111 | 112 | 113 | Test: 114 | 6 115 | 116 | Answer: 117 | 6 118 | 119 | 120 | Test: 121 | 7 122 | 123 | Answer: 124 | 7 125 | 126 | 127 | Test: 128 | 9 129 | 130 | Answer: 131 | 9 132 | 133 | 134 | Test: 135 | 10 136 | 137 | Answer: 138 | 0 139 | 140 | 141 | -------------------------------------------------------------------------------- /problems/int_and_float/motor_rally.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Car route 3 | 4 | Statement: 5 | A car can cover distance of N kilometers per day. How many days will it take 6 | to cover a route of length M kilometers? 7 | 8 | The program gets two numbers: N and M. 9 | 10 | Test: 11 | 700 12 | 750 13 | 14 | Answer: 15 | 2 16 | 17 | 18 | Test: 19 | 700 20 | 2100 21 | 22 | Answer: 23 | 3 24 | 25 | 26 | Test: 27 | 10 28 | 15 29 | 30 | Answer: 31 | 2 32 | 33 | 34 | Test: 35 | 10 36 | 16 37 | 38 | Answer: 39 | 2 40 | 41 | 42 | Test: 43 | 10 44 | 19 45 | 46 | Answer: 47 | 2 48 | 49 | 50 | Test: 51 | 10 52 | 70 53 | 54 | Answer: 55 | 7 56 | 57 | 58 | Test: 59 | 10 60 | 81 61 | 62 | Answer: 63 | 9 64 | 65 | 66 | Test: 67 | 10 68 | 1000 69 | 70 | Answer: 71 | 100 72 | 73 | 74 | Test: 75 | 10 76 | 1001 77 | 78 | Answer: 79 | 101 80 | 81 | 82 | Test: 83 | 10 84 | 999 85 | 86 | Answer: 87 | 100 88 | 89 | 90 | Test: 91 | 10 92 | 1 93 | 94 | Answer: 95 | 1 96 | 97 | 98 | Test: 99 | 10 100 | 9 101 | 102 | Answer: 103 | 1 104 | 105 | 106 | Test: 107 | 483 108 | 9382 109 | 110 | Answer: 111 | 20 112 | 113 | 114 | Test: 115 | 123 116 | 234234 117 | 118 | Answer: 119 | 1905 120 | 121 | -------------------------------------------------------------------------------- /problems/int_and_float/percents.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Проценты 3 | 4 | Statement: 5 | Процентная ставка по вкладу составляет P процентов годовых, которые прибавляются к сумме вклада. Вклад составляет X рублей Y копеек. Определите размер вклада через год. 6 | 7 |

8 | Программа получает на вход целые числа P, X, Y и должна вывести два числа: величину вклада через год в рублях и копейках. Дробная часть копеек отбрасывается. 9 | 10 | Test: 11 | 12 12 | 179 13 | 0 14 | 15 | Answer: 16 | 200 48 17 | 18 | 19 | Test: 20 | 13 21 | 179 22 | 0 23 | 24 | Answer: 25 | 202 27 26 | 27 | 28 | Test: 29 | 10 30 | 100 31 | 0 32 | 33 | Answer: 34 | 110 0 35 | 36 | 37 | Test: 38 | 100 39 | 100 40 | 0 41 | 42 | Answer: 43 | 200 0 44 | 45 | 46 | Test: 47 | 100 48 | 17 49 | 34 50 | 51 | Answer: 52 | 34 68 53 | 54 | 55 | Test: 56 | 17 57 | 94 58 | 41 59 | 60 | Answer: 61 | 110 45 62 | 63 | 64 | Test: 65 | 23 66 | 19382 67 | 23 68 | 69 | Answer: 70 | 23840 14 71 | 72 | 73 | Test: 74 | 17 75 | 35 76 | 87 77 | 78 | Answer: 79 | 41 96 80 | 81 | 82 | Test: 83 | 1 84 | 1 85 | 99 86 | 87 | Answer: 88 | 2 0 89 | -------------------------------------------------------------------------------- /problems/int_and_float/purchase_price.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Total cost 3 | 4 | Statement: 5 | A cupcake costs A dollars and B cents. Determine, how many dollars and cents should one pay for N cupcakes. 6 | 7 | A program gets three numbers: A, B, N. It should print two numbers: total cost in dollars and cents. 8 | 9 | Test: 10 | 2 11 | 50 12 | 4 13 | 14 | Answer: 15 | 10 0 16 | 17 | 18 | Test: 19 | 10 20 | 15 21 | 2 22 | 23 | Answer: 24 | 20 30 25 | 26 | 27 | Test: 28 | 3000 29 | 99 30 | 3000 31 | 32 | Answer: 33 | 9002970 0 34 | 35 | 36 | Test: 37 | 2029 38 | 34 39 | 1848 40 | 41 | Answer: 42 | 3750220 32 43 | 44 | 45 | Test: 46 | 1886 47 | 73 48 | 295 49 | 50 | Answer: 51 | 556585 35 52 | 53 | 54 | Test: 55 | 1069 56 | 40 57 | 1967 58 | 59 | Answer: 60 | 2103509 80 61 | 62 | 63 | Test: 64 | 905 65 | 79 66 | 496 67 | 68 | Answer: 69 | 449271 84 70 | 71 | 72 | Test: 73 | 1967 74 | 91 75 | 926 76 | 77 | Answer: 78 | 1822284 66 79 | 80 | 81 | Test: 82 | 2255 83 | 76 84 | 1090 85 | 86 | Answer: 87 | 2458778 40 88 | 89 | 90 | Test: 91 | 2435 92 | 6 93 | 1965 94 | 95 | Answer: 96 | 4784892 90 97 | 98 | -------------------------------------------------------------------------------- /problems/int_and_float/russian_round.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Округление по российским правилам 3 | 4 | Statement: 5 | По российский правилам числа округляются до ближайшего целого числа, 6 | а если дробная часть числа равна 0.5, то число округляется вверх. 7 | 8 |

Дано неотрицательное число x, округлите его по этим правилам. 9 | Обратите внимание, что функция round не годится для этой задачи! 10 | 11 | Test: 12 | 2.3 13 | 14 | Answer: 15 | 2 16 | 17 | 18 | Test: 19 | 2.5 20 | 21 | Answer: 22 | 3 23 | 24 | 25 | Test: 26 | 2.7 27 | 28 | Answer: 29 | 3 30 | 31 | 32 | Test: 33 | 3.0 34 | 35 | Answer: 36 | 3 37 | 38 | 39 | Test: 40 | 3.1 41 | 42 | Answer: 43 | 3 44 | 45 | 46 | Test: 47 | 3.4999 48 | 49 | Answer: 50 | 3 51 | 52 | 53 | Test: 54 | 3.5 55 | 56 | Answer: 57 | 4 58 | 59 | 60 | Test: 61 | 3.5001 62 | 63 | Answer: 64 | 4 65 | 66 | 67 | Test: 68 | 3.9999 69 | 70 | Answer: 71 | 4 72 | 73 | -------------------------------------------------------------------------------- /problems/int_and_float/sum_of_digits.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Sum of digits 3 | 4 | Statement: 5 | Given a three-digit number. Find the sum of its digits. 6 | 7 | 8 | Test: 9 | 179 10 | 11 | Answer: 12 | 17 13 | 14 | 15 | Test: 16 | 829 17 | 18 | Answer: 19 | 19 20 | 21 | 22 | Test: 23 | 204 24 | 25 | Answer: 26 | 6 27 | 28 | 29 | Test: 30 | 100 31 | 32 | Answer: 33 | 1 34 | 35 | 36 | Test: 37 | 999 38 | 39 | Answer: 40 | 27 41 | 42 | 43 | Test: 44 | 483 45 | 46 | Answer: 47 | 15 48 | 49 | -------------------------------------------------------------------------------- /problems/int_and_float/tens_digit.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Tens digit 3 | 4 | Statement: 5 | Given an integer. Print its tens digit. 6 | 7 | Test: 8 | 73 9 | 10 | Answer: 11 | 7 12 | 13 | Test: 14 | 1234 15 | 16 | Answer: 17 | 3 18 | 19 | 20 | Test: 21 | 10 22 | 23 | Answer: 24 | 1 25 | 26 | 27 | Test: 28 | 29 29 | 30 | Answer: 31 | 2 32 | 33 | 34 | Test: 35 | 37 36 | 37 | Answer: 38 | 3 39 | 40 | 41 | Test: 42 | 48 43 | 44 | Answer: 45 | 4 46 | 47 | 48 | Test: 49 | 50 50 | 51 | Answer: 52 | 5 53 | 54 | 55 | Test: 56 | 67 57 | 58 | Answer: 59 | 6 60 | 61 | 62 | Test: 63 | 81 64 | 65 | Answer: 66 | 8 67 | 68 | 69 | Test: 70 | 99 71 | 72 | Answer: 73 | 9 74 | 75 | 76 | Test: 77 | 179 78 | 79 | Answer: 80 | 7 81 | 82 | 83 | Test: 84 | 100 85 | 86 | Answer: 87 | 0 88 | 89 | 90 | Test: 91 | 999 92 | 93 | Answer: 94 | 9 95 | 96 | 97 | Test: 98 | 854345 99 | 100 | Answer: 101 | 4 102 | 103 | 104 | Test: 105 | 1000000 106 | 107 | Answer: 108 | 0 109 | 110 | 111 | Test: 112 | 9999 113 | 114 | Answer: 115 | 9 116 | 117 | 118 | Test: 119 | 9 120 | 121 | Answer: 122 | 0 123 | 124 | 125 | Test: 126 | 1 127 | 128 | Answer: 129 | 0 130 | 131 | 132 | Test: 133 | 0 134 | 135 | Answer: 136 | 0 137 | -------------------------------------------------------------------------------- /problems/int_and_float/watch_1.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Clock face - 1 3 | 4 | Statement: 5 | H hours, M minutes and S seconds are passed since the midnight (0 ≤ H < 12, 0 ≤ M < 60, 0 ≤ S < 60). Determine the angle (in degrees) of the hour hand on the clock face right now. 6 | 7 | 8 | Test: 9 | 1 10 | 2 11 | 6 12 | 13 | Answer: 14 | 31.05 15 | 16 | 17 | Test: 18 | 1 19 | 0 20 | 0 21 | 22 | Answer: 23 | 30 24 | 25 | 26 | Test: 27 | 0 28 | 1 29 | 0 30 | 31 | Answer: 32 | 0.5 33 | 34 | 35 | Test: 36 | 0 37 | 2 38 | 0 39 | 40 | Answer: 41 | 1 42 | 43 | 44 | Test: 45 | 0 46 | 2 47 | 1 48 | 49 | Answer: 50 | 1.00833 51 | 52 | 53 | Test: 54 | 0 55 | 0 56 | 1 57 | 58 | Answer: 59 | 0.00833333 60 | 61 | 62 | Test: 63 | 11 64 | 59 65 | 59 66 | 67 | Answer: 68 | 359.992 69 | 70 | 71 | Test: 72 | 7 73 | 18 74 | 49 75 | 76 | Answer: 77 | 219.408 78 | 79 | 80 | Test: 81 | 4 82 | 54 83 | 55 84 | 85 | Answer: 86 | 147.458 87 | 88 | 89 | Test: 90 | 9 91 | 9 92 | 37 93 | 94 | Answer: 95 | 274.808 96 | 97 | 98 | -------------------------------------------------------------------------------- /problems/int_and_float/watch_2.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Clock face - 2 3 | 4 | Statement: 5 | Hour hand turned by α degrees since the midnight. Determine the angle by which minute hand 6 | turned since the start of the current hour. Input and output in this problems are floating-point numbers. 7 | 8 | Test: 9 | 190 10 | 11 | Answer: 12 | 120 13 | 14 | 15 | Test: 16 | 0 17 | 18 | Answer: 19 | 0 20 | 21 | 22 | Test: 23 | 5 24 | 25 | Answer: 26 | 60 27 | 28 | 29 | Test: 30 | 10 31 | 32 | Answer: 33 | 120 34 | 35 | 36 | Test: 37 | 15 38 | 39 | Answer: 40 | 180 41 | 42 | 43 | Test: 44 | 20 45 | 46 | Answer: 47 | 240 48 | 49 | 50 | Test: 51 | 25 52 | 53 | Answer: 54 | 300 55 | 56 | 57 | Test: 58 | 29 59 | 60 | Answer: 61 | 348 62 | 63 | 64 | Test: 65 | 30 66 | 67 | Answer: 68 | 0 69 | 70 | 71 | Test: 72 | 31 73 | 74 | Answer: 75 | 12 76 | 77 | 78 | Test: 79 | 40 80 | 81 | Answer: 82 | 120 83 | 84 | 85 | Test: 86 | 59 87 | 88 | Answer: 89 | 348 90 | 91 | 92 | Test: 93 | 60 94 | 95 | Answer: 96 | 0 97 | 98 | 99 | Test: 100 | 61 101 | 102 | Answer: 103 | 12 104 | 105 | 106 | Test: 107 | 70 108 | 109 | Answer: 110 | 120 111 | 112 | 113 | Test: 114 | 89 115 | 116 | Answer: 117 | 348 118 | 119 | 120 | Test: 121 | 90 122 | 123 | Answer: 124 | 0 125 | 126 | 127 | Test: 128 | 95 129 | 130 | Answer: 131 | 60 132 | 133 | 134 | Test: 135 | 179 136 | 137 | Answer: 138 | 348 139 | 140 | 141 | Test: 142 | 190 143 | 144 | Answer: 145 | 120 146 | 147 | 148 | Test: 149 | 192 150 | 151 | Answer: 152 | 144 153 | 154 | 155 | Test: 156 | 300 157 | 158 | Answer: 159 | 0 160 | 161 | 162 | Test: 163 | 359 164 | 165 | Answer: 166 | 348 167 | 168 | 169 | Test: 170 | 1 171 | 172 | Answer: 173 | 12 174 | 175 | 176 | Test: 177 | 132 178 | 179 | Answer: 180 | 144 181 | 182 | 183 | Test: 184 | 0.5 185 | 186 | Answer: 187 | 6 188 | 189 | 190 | Test: 191 | 0.0001 192 | 193 | Answer: 194 | 0.0012 195 | 196 | 197 | Test: 198 | 73.2938 199 | 200 | Answer: 201 | 159.526 202 | 203 | 204 | Test: 205 | 119.994 206 | 207 | Answer: 208 | 359.928 209 | 210 | 211 | Test: 212 | 120.005 213 | 214 | Answer: 215 | 0.06 216 | 217 | 218 | Test: 219 | 231.3452 220 | 221 | Answer: 222 | 256.142 223 | 224 | 225 | -------------------------------------------------------------------------------- /problems/int_and_float/watch_3.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Часы - 3 3 | 4 | Statement: 5 | С начала суток часовая стрелка повернулась на угол в α градусов. Определите сколько полных часов, минут и секунд прошло с начала суток, то есть решите задачу, обратную задаче «Часы - 1». Запишите ответ в три переменные и выведите их на экран. 6 | 7 | Test: 8 | 31.05 9 | 10 | Answer: 11 | 1 2 6 12 | 13 | 14 | Test: 15 | 30 16 | 17 | Answer: 18 | 1 0 0 19 | 20 | 21 | Test: 22 | 0.5 23 | 24 | Answer: 25 | 0 1 0 26 | 27 | 28 | Test: 29 | 1 30 | 31 | Answer: 32 | 0 2 0 33 | 34 | 35 | Test: 36 | 1.00833 37 | 38 | Answer: 39 | 0 2 0 40 | 41 | 42 | Test: 43 | 0.00833333 44 | 45 | Answer: 46 | 0 0 0 47 | 48 | 49 | Test: 50 | 389.992 51 | 52 | Answer: 53 | 12 59 59 54 | 55 | 56 | Test: 57 | 219.408 58 | 59 | Answer: 60 | 7 18 48 61 | 62 | 63 | Test: 64 | 147.46 65 | 66 | Answer: 67 | 4 54 55 68 | 69 | 70 | Test: 71 | 274.81 72 | 73 | Answer: 74 | 9 9 37 75 | 76 | 77 | -------------------------------------------------------------------------------- /problems/lists/even_elements.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Even elements 3 | 4 | Statement: 5 | Given a list of numbers, find and print all elements that are an even number. 6 | 7 | In this case use a for-loop that iterates over the list, 8 | and not over its indices! That is, don't use range() 9 | 10 | Test: 11 | 1 2 2 3 3 3 4 12 | 13 | Answer: 14 | 2 2 4 15 | 16 | 17 | Test: 18 | 1 2 3 4 5 19 | 20 | Answer: 21 | 2 4 22 | 23 | 24 | Test: 25 | 2 4 6 8 26 | 27 | Answer: 28 | 2 4 6 8 29 | 30 | 31 | Test: 32 | 1 1 1 1 1 1 2 33 | 34 | Answer: 35 | 2 36 | 37 | 38 | Test: 39 | 44 -51 32 -60 -7 -67 62 91 26 -14 40 | 41 | Answer: 42 | 44 32 -60 62 26 -14 43 | 44 | 45 | Test: 46 | 32 -95 -78 -15 -71 -73 -83 53 -91 -82 -71 -52 -60 -18 12 8 98 -92 -83 7 47 | 48 | Answer: 49 | 32 -78 -82 -52 -60 -18 12 8 98 -92 50 | 51 | 52 | Test: 53 | 39 55 -88 56 -39 -92 -30 54 15 94 27 -87 -85 -53 -44 -87 33 38 -22 56 54 | 55 | Answer: 56 | -88 56 -92 -30 54 94 -44 38 -22 56 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /problems/lists/even_indices.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Even indices 3 | 4 | Statement: 5 | Given a list of numbers, find and print all the list elements with an even index number. 6 | (i.e. A[0], A[2], A[4], ...). 7 | 8 | Test: 9 | 1 2 3 4 5 10 | 11 | Answer: 12 | 1 3 5 13 | 14 | 15 | Test: 16 | 4 5 3 4 2 3 17 | 18 | Answer: 19 | 4 3 2 20 | 21 | 22 | Test: 23 | 9 4 5 2 3 24 | 25 | Answer: 26 | 9 5 3 27 | 28 | 29 | Test: 30 | 6 31 | 32 | Answer: 33 | 6 34 | 35 | 36 | Test: 37 | 7 8 38 | 39 | Answer: 40 | 7 41 | 42 | 43 | Test: 44 | 1 2 3 45 | 46 | Answer: 47 | 1 3 48 | 49 | 50 | Test: 51 | 90 45 3 43 52 | 53 | Answer: 54 | 90 3 55 | 56 | 57 | Test: 58 | 40 64 -80 -98 -68 56 85 87 -68 -78 59 | 60 | Answer: 61 | 40 -80 -68 85 -68 62 | 63 | 64 | Test: 65 | -1 -11 -40 3 -47 -37 -18 -100 6 -29 14 -1 -89 -20 -36 7 5 78 -5 85 66 | 67 | Answer: 68 | -1 -40 -47 -18 6 14 -89 -36 5 -5 69 | -------------------------------------------------------------------------------- /problems/lists/increasing_neighbours.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Greater than previous 3 | 4 | Statement: 5 | Given a list of numbers, find and print all the elements that are greater than the previous element. 6 | 7 | Test: 8 | 1 5 2 4 3 9 | 10 | Answer: 11 | 5 4 12 | 13 | 14 | Test: 15 | 1 2 3 4 5 16 | 17 | Answer: 18 | 2 3 4 5 19 | 20 | 21 | Test: 22 | 5 4 3 2 1 23 | 24 | Answer: 25 | 26 | 27 | 28 | Test: 29 | 1 5 1 5 1 30 | 31 | Answer: 32 | 5 5 33 | 34 | 35 | Test: 36 | 5 1 5 1 5 37 | 38 | Answer: 39 | 5 5 40 | 41 | 42 | Test: 43 | 5 5 5 5 5 44 | 45 | Answer: 46 | 47 | 48 | 49 | Test: 50 | 1 1 1 5 1 51 | 52 | Answer: 53 | 5 54 | 55 | 56 | Test: 57 | 345354 58 | 59 | Answer: 60 | 61 | 62 | 63 | Test: 64 | 1 465 65 | 66 | Answer: 67 | 465 68 | 69 | 70 | Test: 71 | 4 -54643 72 | 73 | Answer: 74 | 75 | 76 | 77 | Test: 78 | 2147483647 0 1 2 3 79 | 80 | Answer: 81 | 1 2 3 82 | 83 | 84 | Test: 85 | 1 2 3 4 -2147483648 86 | 87 | Answer: 88 | 2 3 4 89 | 90 | 91 | Test: 92 | -9 29 -100 64 26 73 -96 28 -92 11 -14 -86 -54 -67 93 | 94 | Answer: 95 | 29 64 73 28 11 -54 96 | 97 | 98 | -------------------------------------------------------------------------------- /problems/lists/insert_element.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Вставить элемент 3 | 4 | Statement: 5 | Дан список целых чисел, число k и значение C. 6 | Необходимо вставить в список на позицию с индексом k элемент, 7 | равный C, сдвинув все элементы, имевшие индекс не менее k, вправо. 8 | 9 |

Посколько при этом количество элементов в списке увеличивается, 10 | после считывания списка в его конец нужно будет добавить новый элемент, 11 | используя метод append. 12 | 13 |

Вставку необходимо осуществлять уже в считанном списке, 14 | не делая этого при выводе и не создавая дополнительного списка. 15 | 16 | Test: 17 | 7 6 5 4 3 2 1 18 | 2 0 19 | 20 | Answer: 21 | 7 6 0 5 4 3 2 1 22 | 23 | 24 | Test: 25 | 4 6 2 4 3 5 12 24 3 5 26 | 4 22 27 | 28 | Answer: 29 | 4 6 2 4 22 3 5 12 24 3 5 30 | 31 | 32 | Test: 33 | 4 6 2 4 3 5 12 24 3 5 34 | 0 2 35 | 36 | Answer: 37 | 2 4 6 2 4 3 5 12 24 3 5 38 | 39 | 40 | Test: 41 | 4 6 2 4 3 5 12 24 3 5 42 | 8 22 43 | 44 | Answer: 45 | 4 6 2 4 3 5 12 24 22 3 5 46 | 47 | 48 | Test: 49 | 4 6 2 4 3 5 12 24 3 5 50 | 9 1 51 | 52 | Answer: 53 | 4 6 2 4 3 5 12 24 3 1 5 54 | 55 | 56 | Test: 57 | 1 2 58 | 0 3 59 | 60 | Answer: 61 | 3 1 2 62 | 63 | 64 | Test: 65 | 1 2 66 | 1 3 67 | 68 | Answer: 69 | 1 3 2 70 | 71 | 72 | Test: 73 | 4 6 2 4 3 5 12 24 3 5 74 | 1 22 75 | 76 | Answer: 77 | 4 22 6 2 4 3 5 12 24 3 5 78 | 79 | 80 | Test: 81 | 1 3 5 7 9 11 13 15 17 19 82 | 10 179 83 | 84 | Answer: 85 | 1 3 5 7 9 11 13 15 17 19 179 -------------------------------------------------------------------------------- /problems/lists/kegelbahn.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The bowling alley 3 | 4 | Statement: 5 | In 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. 6 | 7 | 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. 8 | 9 | Test: 10 | 10 3 11 | 8 10 12 | 2 5 13 | 3 6 14 | 15 | Answer: 16 | I.....I... 17 | 18 | 19 | Test: 20 | 5 2 21 | 1 2 22 | 4 4 23 | 24 | Answer: 25 | ..I.I 26 | 27 | 28 | Test: 29 | 10 3 30 | 3 5 31 | 4 6 32 | 10 10 33 | 34 | Answer: 35 | II....III. 36 | 37 | 38 | Test: 39 | 5 0 40 | 41 | Answer: 42 | IIIII 43 | 44 | 45 | Test: 46 | 5 5 47 | 5 5 48 | 3 3 49 | 1 1 50 | 2 2 51 | 4 4 52 | 53 | Answer: 54 | ..... 55 | 56 | 57 | Test: 58 | 20 1 59 | 1 20 60 | 61 | Answer: 62 | .................... 63 | 64 | 65 | 66 | Test: 67 | 20 3 68 | 3 8 69 | 13 17 70 | 6 9 71 | 72 | Answer: 73 | II.......III.....III 74 | 75 | 76 | Test: 77 | 15 4 78 | 1 1 79 | 1 4 80 | 6 8 81 | 7 9 82 | 83 | Answer: 84 | ....I....IIIIII -------------------------------------------------------------------------------- /problems/lists/maximal_element.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The largest element 3 | 4 | Statement: 5 | Given 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. 6 | 7 | If the highest element is not unique, print the index of the first instance. 8 | 9 | Test: 10 | 1 2 3 2 1 11 | 12 | Answer: 13 | 3 2 14 | 15 | 16 | Test: 17 | 1 2 3 18 | 19 | Answer: 20 | 3 2 21 | 22 | 23 | Test: 24 | 1 3 2 25 | 26 | Answer: 27 | 3 1 28 | 29 | 30 | Test: 31 | 2 1 3 32 | 33 | Answer: 34 | 3 2 35 | 36 | 37 | Test: 38 | 2 3 1 39 | 40 | Answer: 41 | 3 1 42 | 43 | 44 | Test: 45 | 3 2 1 46 | 47 | Answer: 48 | 3 0 49 | 50 | 51 | Test: 52 | 3 1 2 53 | 54 | Answer: 55 | 3 0 56 | 57 | 58 | Test: 59 | 1 2 3 4 5 60 | 61 | Answer: 62 | 5 4 63 | 64 | 65 | Test: 66 | 5 4 3 2 1 67 | 68 | Answer: 69 | 5 0 70 | 71 | 72 | Test: 73 | -1 -2 -3 -4 -5 74 | 75 | Answer: 76 | -1 0 77 | 78 | 79 | Test: 80 | -5 -4 -3 -2 -1 81 | 82 | Answer: 83 | -1 4 84 | 85 | 86 | Test: 87 | 2147483647 2147483646 2147483645 88 | 89 | Answer: 90 | 2147483647 0 91 | 92 | 93 | Test: 94 | -2147483648 -2147483647 -2147483646 95 | 96 | Answer: 97 | -2147483646 2 98 | 99 | 100 | Test: 101 | -2147483648 -2147483648 -2147483648 102 | 103 | Answer: 104 | -2147483648 0 105 | 106 | 107 | Test: 108 | -2147483646 -2147483647 -2147483648 109 | 110 | Answer: 111 | -2147483646 0 112 | 113 | 114 | Test: 115 | -100 -100 -100 -100 -100 116 | 117 | Answer: 118 | -100 0 119 | 120 | 121 | Test: 122 | -2147483648 0 2147483647 123 | 124 | Answer: 125 | 2147483647 2 126 | 127 | 128 | Test: 129 | 2147483647 0 -2147483648 130 | 131 | Answer: 132 | 2147483647 0 133 | 134 | 135 | Test: 136 | -79 92 70 72 28 45 37 -86 -12 0 -27 -14 -69 63 -68 74 45 49 96 -20 137 | 138 | Answer: 139 | 96 18 140 | 141 | 142 | Test: 143 | 53 14 53 -77 -31 48 51 49 -73 -23 -19 93 85 -50 -73 59 67 -99 98 11 144 | 145 | Answer: 146 | 98 18 147 | 148 | 149 | Test: 150 | -2147483648 151 | 152 | Answer: 153 | -2147483648 0 154 | 155 | 156 | -------------------------------------------------------------------------------- /problems/lists/more_than_neighbours.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Greater than neighbours 3 | 4 | Statement: 5 | Given a list of numbers, determine and print the quantity of elements that are greater than both of their neighbors. 6 | 7 |

8 | The first and the last items of the list shouldn't be considered because they don't have two neighbors. 9 | 10 | Test: 11 | 1 2 3 4 5 12 | 13 | Answer: 14 | 0 15 | 16 | 17 | Test: 18 | 5 4 3 2 1 19 | 20 | Answer: 21 | 0 22 | 23 | 24 | Test: 25 | 1 5 1 5 1 26 | 27 | Answer: 28 | 2 29 | 30 | 31 | Test: 32 | 5 1 5 1 5 33 | 34 | Answer: 35 | 1 36 | 37 | 38 | Test: 39 | 5 5 5 5 5 40 | 41 | Answer: 42 | 0 43 | 44 | 45 | Test: 46 | 1 1 1 5 1 47 | 48 | Answer: 49 | 1 50 | 51 | 52 | Test: 53 | 345354 54 | 55 | Answer: 56 | 0 57 | 58 | 59 | Test: 60 | 1 465 61 | 62 | Answer: 63 | 0 64 | 65 | 66 | Test: 67 | 4 -54643 68 | 69 | Answer: 70 | 0 71 | 72 | 73 | Test: 74 | 2147483647 0 1 2 3 75 | 76 | Answer: 77 | 0 78 | 79 | 80 | Test: 81 | 1 2 3 4 -2147483648 82 | 83 | Answer: 84 | 1 85 | 86 | 87 | Test: 88 | -9 29 -100 64 26 73 -96 28 -92 11 -14 -86 -54 -67 89 | 90 | Answer: 91 | 6 92 | 93 | Test: 94 | 2147483647 0 1 0 2147483647 95 | 96 | Answer: 97 | 1 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /problems/lists/num_distinct.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of distinct elements 3 | 4 | Statement: 5 | Given a list of numbers with all of its elements sorted in ascending order, determine and print the quantity of distinct elements in it. 6 | 7 | Test: 8 | 1 2 2 3 3 3 9 | 10 | Answer: 11 | 3 12 | 13 | 14 | Test: 15 | 1 2 3 4 5 16 | 17 | Answer: 18 | 5 19 | 20 | 21 | Test: 22 | 1 1 1 1 1 23 | 24 | Answer: 25 | 1 26 | 27 | 28 | Test: 29 | 1 1 2 2 2 3 4 5 6 7 30 | 31 | Answer: 32 | 7 33 | 34 | 35 | Test: 36 | -100 -99 -98 -97 -96 37 | 38 | Answer: 39 | 5 40 | 41 | 42 | Test: 43 | -100 -100 -98 -50 1 44 | 45 | Answer: 46 | 4 47 | 48 | 49 | 50 | Test: 51 | -64 -45 -38 -16 -14 -7 2 53 70 80 80 52 | 53 | Answer: 54 | 10 55 | 56 | -------------------------------------------------------------------------------- /problems/lists/num_equal_pairs.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of pairs of equal 3 | 4 | Statement: 5 | Given a list of numbers, count how many element pairs have the same value (are equal). 6 | 7 | Any two elements that are equal to each other should be counted exactly once. 8 | 9 | Test: 10 | 1 2 3 2 3 11 | 12 | Answer: 13 | 2 14 | 15 | 16 | Test: 17 | 1 1 1 1 1 18 | 19 | Answer: 20 | 10 21 | 22 | 23 | Test: 24 | 1 2 3 25 | 26 | Answer: 27 | 0 28 | 29 | 30 | Test: 31 | 1 1 1 32 | 33 | Answer: 34 | 3 35 | 36 | 37 | Test: 38 | 2 3 39 | 40 | Answer: 41 | 0 42 | 43 | 44 | Test: 45 | 2 2 46 | 47 | Answer: 48 | 1 49 | 50 | 51 | Test: 52 | 0 0 53 | 54 | Answer: 55 | 1 56 | 57 | 58 | Test: 59 | 0 0 6 1 1 4 2 1 2 2 60 | 61 | Answer: 62 | 7 63 | 64 | 65 | Test: 66 | 0 1 43 10 13 33 15 8 18 21 67 | 68 | Answer: 69 | 0 70 | 71 | 72 | Test: 73 | 3 2 1 2 2 4 3 2 5 3 2 74 | 75 | Answer: 76 | 13 -------------------------------------------------------------------------------- /problems/lists/queens.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Queens 3 | 4 | Statement: 5 | In 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 6 | of queens that can attach each other on the next move. Print the word NO if no queen can attack another, otherwise print YES. 7 | 8 | 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. 9 | 10 | Test: 11 | 1 7 12 | 2 4 13 | 3 2 14 | 4 8 15 | 5 6 16 | 6 1 17 | 7 3 18 | 8 5 19 | 20 | Answer: 21 | NO 22 | 23 | 24 | Test: 25 | 1 8 26 | 2 7 27 | 3 6 28 | 4 5 29 | 5 4 30 | 6 3 31 | 7 2 32 | 8 1 33 | 34 | Answer: 35 | YES 36 | 37 | 38 | Test: 39 | 3 4 40 | 8 5 41 | 4 1 42 | 7 3 43 | 6 6 44 | 1 7 45 | 5 8 46 | 2 2 47 | 48 | Answer: 49 | YES 50 | 51 | 52 | Test: 53 | 2 5 54 | 8 4 55 | 3 7 56 | 4 1 57 | 6 8 58 | 7 6 59 | 1 2 60 | 5 3 61 | 62 | Answer: 63 | NO 64 | 65 | 66 | Test: 67 | 1 3 68 | 4 8 69 | 6 1 70 | 5 5 71 | 2 7 72 | 8 6 73 | 7 4 74 | 3 2 75 | 76 | Answer: 77 | NO 78 | 79 | 80 | Test: 81 | 7 8 82 | 2 2 83 | 8 5 84 | 4 3 85 | 5 7 86 | 1 4 87 | 6 1 88 | 3 6 89 | 90 | Answer: 91 | YES 92 | 93 | 94 | Test: 95 | 7 5 96 | 8 3 97 | 5 6 98 | 1 4 99 | 2 2 100 | 6 8 101 | 3 7 102 | 4 1 103 | 104 | Answer: 105 | YES 106 | 107 | 108 | Test: 109 | 4 6 110 | 5 1 111 | 3 7 112 | 8 3 113 | 2 2 114 | 1 4 115 | 7 5 116 | 6 8 117 | 118 | Answer: 119 | YES 120 | 121 | 122 | Test: 123 | 2 2 124 | 3 5 125 | 8 6 126 | 7 4 127 | 5 1 128 | 1 4 129 | 4 3 130 | 6 7 131 | 132 | Answer: 133 | YES 134 | 135 | 136 | Test: 137 | 3 4 138 | 7 6 139 | 6 8 140 | 4 7 141 | 4 1 142 | 2 2 143 | 1 5 144 | 5 3 145 | 146 | Answer: 147 | YES 148 | 149 | 150 | Test: 151 | 5 6 152 | 6 4 153 | 7 7 154 | 1 3 155 | 8 5 156 | 3 6 157 | 2 1 158 | 4 8 159 | 160 | Answer: 161 | YES 162 | 163 | 164 | Test: 165 | 6 5 166 | 3 1 167 | 8 4 168 | 5 8 169 | 1 2 170 | 7 7 171 | 6 3 172 | 4 6 173 | 174 | Answer: 175 | YES 176 | 177 | 178 | Test: 179 | 1 1 180 | 2 2 181 | 3 3 182 | 4 4 183 | 5 5 184 | 6 6 185 | 7 7 186 | 8 8 187 | 188 | Answer: 189 | YES 190 | 191 | 192 | Test: 193 | 1 7 194 | 2 1 195 | 3 2 196 | 4 3 197 | 5 4 198 | 6 6 199 | 7 8 200 | 8 5 201 | 202 | Answer: 203 | YES 204 | -------------------------------------------------------------------------------- /problems/lists/remove_element.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Удалить элемент 3 | 4 | Statement: 5 | Дан список из чисел и индекс элемента в списке k. Удалите из списка элемент с индексом k, 6 | сдвинув влево все элементы, стоящие правее элемента с индексом k. 7 | 8 |

Программа получает на вход список, затем число k. Программа сдвигает все элементы, 9 | а после этого удаляет последний элемент списка при помощи метода pop() без параметров. 10 | 11 |

Программа должна осуществлять сдвиг непосредственно в списке, 12 | а не делать это при выводе элементов. Также нельзя использовать дополнительный список. 13 | Также не следует использовать метод pop(k) с параметром. 14 | 15 | Test: 16 | 7 6 5 4 3 2 1 17 | 2 18 | 19 | Answer: 20 | 7 6 4 3 2 1 21 | 22 | 23 | Test: 24 | 4 6 2 4 3 5 12 24 3 5 25 | 4 26 | 27 | Answer: 28 | 4 6 2 4 5 12 24 3 5 29 | 30 | 31 | Test: 32 | 4 6 2 4 3 5 12 24 3 5 33 | 0 34 | 35 | Answer: 36 | 6 2 4 3 5 12 24 3 5 37 | 38 | 39 | Test: 40 | 4 6 2 4 3 5 12 24 3 5 41 | 8 42 | 43 | Answer: 44 | 4 6 2 4 3 5 12 24 5 45 | 46 | 47 | Test: 48 | 4 6 2 4 3 5 12 24 3 5 49 | 9 50 | 51 | Answer: 52 | 4 6 2 4 3 5 12 24 3 53 | 54 | 55 | Test: 56 | 1 2 57 | 0 58 | 59 | Answer: 60 | 2 61 | 62 | 63 | Test: 64 | 1 2 65 | 1 66 | 67 | Answer: 68 | 1 69 | 70 | 71 | -------------------------------------------------------------------------------- /problems/lists/same_sign_neighbours.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Neighbors of the same sign 3 | 4 | Statement: 5 | Given a list of numbers, find and print the first adjacent elements which have the same sign. 6 | If there is no such pair, leave the output blank. 7 | 8 | Test: 9 | -1 2 3 -1 -2 10 | 11 | Answer: 12 | 2 3 13 | 14 | 15 | Test: 16 | 1 -3 4 -2 1 17 | 18 | Answer: 19 | 20 | 21 | Test: 22 | 1 2 -3 -4 -5 23 | 24 | Answer: 25 | 1 2 26 | 27 | 28 | Test: 29 | 1 -2 3 -4 -5 30 | 31 | Answer: 32 | -4 -5 33 | 34 | 35 | Test: 36 | 1 -2 3 -4 5 6 37 | 38 | Answer: 39 | 5 6 40 | 41 | 42 | Test: 43 | -1 2 -3 4 -5 6 44 | 45 | Answer: 46 | 47 | 48 | Test: 49 | 1 -2 3 -4 5 -6 50 | 51 | Answer: 52 | 53 | 54 | Test: 55 | 1 -2 3 -4 56 | 57 | Answer: 58 | 59 | 60 | Test: 61 | -1 2 -3 4 62 | 63 | Answer: 64 | 65 | 66 | Test: 67 | 1 2 3 4 68 | 69 | Answer: 70 | 1 2 71 | 72 | 73 | Test: 74 | -1 -2 -3 -4 75 | 76 | Answer: 77 | -1 -2 78 | 79 | 80 | Test: 81 | 1 -1 1 -1 -1 1 -1 1 -1 1 82 | 83 | Answer: 84 | -1 -1 85 | 86 | 87 | Test: 88 | 1 -1 1 -1 1 1 -1 1 -1 1 89 | 90 | Answer: 91 | 1 1 92 | 93 | 94 | Test: 95 | 1 -1 1 -1 1 96 | 97 | Answer: 98 | 99 | 100 | Test: 101 | -1 1 -1 1 -1 102 | 103 | Answer: 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /problems/lists/sherenga.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Шеренга 3 | 4 | Statement: 5 | Петя перешёл в другую школу. На уроке физкультуры ему понадобилось определить своё место в строю. 6 | Помогите ему это сделать. 7 | 8 |

Программа получает на вход невозрастающую последовательность натуральных чисел, 9 | означающих рост каждого человека в строю. После этого вводится число X – рост Пети. 10 | Все числа во входных данных натуральные и не превышают 200. 11 | 12 |

Выведите номер, под которым Петя должен встать в строй. Если в строю есть люди с одинаковым ростом, 13 | таким же, как у Пети, то он должен встать после них. 14 | 15 | Test: 16 | 165 163 160 160 157 157 155 154 17 | 162 18 | 19 | Answer: 20 | 3 21 | 22 | 23 | Test: 24 | 165 163 160 160 157 157 155 154 25 | 160 26 | 27 | Answer: 28 | 5 29 | 30 | 31 | Test: 32 | 39 35 32 32 31 28 28 27 25 24 20 16 16 12 10 33 | 40 34 | 35 | Answer: 36 | 1 37 | 38 | 39 | Test: 40 | 36 34 34 34 34 31 31 29 25 22 19 17 16 14 14 11 41 | 19 42 | 43 | Answer: 44 | 12 45 | 46 | 47 | Test: 48 | 105 105 104 101 98 96 96 92 89 88 84 82 82 80 77 73 73 72 70 66 65 62 61 61 61 58 56 56 53 53 49 48 46 44 43 43 43 42 42 41 41 39 38 34 31 28 25 22 21 20 16 14 49 | 108 50 | 51 | Answer: 52 | 1 53 | 54 | 55 | Test: 56 | 182 182 181 179 175 174 172 172 171 171 168 166 162 161 159 155 154 152 150 150 149 147 146 145 145 143 143 139 138 136 133 133 132 132 129 126 124 121 121 119 116 113 112 110 108 106 103 103 102 99 95 95 94 93 89 87 84 82 78 76 73 72 69 67 67 66 64 64 64 62 60 58 54 54 53 53 52 52 50 48 47 44 42 42 38 34 33 32 28 24 24 22 18 57 | 183 58 | 59 | Answer: 60 | 1 61 | 62 | 63 | Test: 64 | 151 149 148 148 146 142 142 141 139 137 135 132 132 130 129 126 123 123 123 121 121 121 117 115 113 112 112 111 111 111 111 107 104 101 97 93 90 90 88 88 87 83 82 79 79 77 73 73 72 70 67 65 64 61 60 60 59 55 55 54 52 51 47 47 43 41 39 37 35 31 28 25 23 23 22 19 65 | 117 66 | 67 | Answer: 68 | 24 69 | 70 | 71 | Test: 72 | 24 23 21 17 14 14 14 13 13 73 | 11 74 | 75 | Answer: 76 | 10 77 | 78 | 79 | Test: 80 | 139 139 135 134 130 127 126 125 123 121 117 116 113 112 109 108 104 100 96 92 92 91 88 88 85 81 81 78 77 73 73 70 69 69 69 66 63 63 59 59 56 56 56 53 53 52 50 47 47 46 46 44 42 40 36 32 32 29 25 24 21 17 17 81 | 100 82 | 83 | Answer: 84 | 19 85 | 86 | 87 | Test: 88 | 49 46 45 45 45 45 42 42 40 40 38 38 37 33 29 25 21 20 18 16 14 89 | 22 90 | 91 | Answer: 92 | 17 93 | 94 | 95 | Test: 96 | 131 129 125 122 120 118 117 117 117 115 113 109 109 107 106 104 100 96 93 90 87 84 82 79 78 77 76 73 72 68 64 62 62 59 55 55 55 52 49 46 46 44 41 41 39 37 33 33 31 28 24 20 18 15 13 97 | 15 98 | 99 | Answer: 100 | 55 101 | 102 | 103 | Test: 104 | 42 41 41 37 36 36 33 31 27 26 26 26 25 25 22 22 20 18 17 105 | 42 106 | 107 | Answer: 108 | 2 109 | 110 | 111 | Test: 112 | 138 137 133 133 132 130 128 125 123 119 118 117 117 116 114 111 107 103 99 99 95 94 93 91 87 83 83 80 76 74 73 73 72 68 66 62 62 59 58 56 56 54 53 53 52 50 49 45 42 38 36 35 34 30 27 27 24 20 17 113 | 28 114 | 115 | Answer: 116 | 55 117 | 118 | 119 | Test: 120 | 110 107 107 107 106 102 101 98 95 94 90 86 83 83 81 78 77 77 74 73 69 65 61 59 55 55 53 50 48 48 48 45 45 42 41 38 34 30 28 25 22 20 19 19 19 17 15 11 121 | 20 122 | 123 | Answer: 124 | 43 125 | 126 | 127 | Test: 128 | 118 117 115 115 113 112 112 108 106 104 100 99 95 92 90 87 85 84 81 79 75 72 71 70 66 63 62 59 59 59 59 59 55 55 55 54 53 51 49 48 48 47 44 40 40 38 36 32 31 30 28 27 26 24 20 19 129 | 86 130 | 131 | Answer: 132 | 17 133 | 134 | 135 | Test: 136 | 106 105 105 102 98 98 98 96 93 92 91 91 90 87 83 80 77 74 70 68 68 65 63 59 59 56 52 51 50 47 46 43 41 37 33 31 29 28 27 27 24 24 23 23 22 19 137 | 10 138 | 139 | Answer: 140 | 47 141 | 142 | 143 | Test: 144 | 167 165 161 158 158 158 154 152 148 146 142 142 140 140 139 137 133 132 130 130 129 128 128 124 120 120 116 114 114 110 107 104 102 99 99 95 92 91 89 87 87 84 80 78 74 73 71 70 68 66 62 60 58 57 56 52 49 48 48 45 45 41 40 39 37 33 33 33 29 25 21 17 17 145 | 35 146 | 147 | Answer: 148 | 66 149 | 150 | 151 | Test: 152 | 194 194 193 191 188 187 187 185 183 182 178 176 176 172 168 165 163 160 156 152 150 148 148 147 146 146 143 140 138 136 132 129 127 125 125 124 123 123 119 116 114 112 110 110 106 102 99 95 95 92 89 86 82 82 79 79 77 73 73 70 70 70 66 65 65 63 62 60 58 58 55 55 51 47 47 47 44 42 39 36 36 34 31 31 31 28 28 27 27 23 21 19 16 14 13 11 153 | 94 154 | 155 | Answer: 156 | 50 157 | 158 | 159 | Test: 160 | 1 161 | 1 162 | 163 | Answer: 164 | 2 165 | 166 | 167 | Test: 168 | 1 169 | 2 170 | 171 | Answer: 172 | 1 173 | 174 | 175 | -------------------------------------------------------------------------------- /problems/lists/swap_min_and_max.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Swap min and max 3 | 4 | Statement: 5 | Given a list of unique numbers, swap the minimal and maximal elements of this list. Print the resulting list. 6 | 7 | Test: 8 | 3 4 5 2 1 9 | 10 | Answer: 11 | 3 4 1 2 5 12 | 13 | 14 | Test: 15 | 1 5 4 3 2 16 | 17 | Answer: 18 | 5 1 4 3 2 19 | 20 | 21 | Test: 22 | -30000 30000 23 | 24 | Answer: 25 | 30000 -30000 26 | 27 | 28 | Test: 29 | 1 30 | 31 | Answer: 32 | 1 33 | 34 | 35 | Test: 36 | 2147483647 -2147483648 37 | 38 | Answer: 39 | -2147483648 2147483647 40 | 41 | 42 | Test: 43 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 17 16 15 14 44 | 45 | Answer: 46 | 18 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 17 16 15 14 47 | 48 | 49 | Test: 50 | 1 2 3 4 5 6 7 8 9 10 51 | 52 | Answer: 53 | 10 2 3 4 5 6 7 8 9 1 54 | 55 | 56 | Test: 57 | 10 9 8 7 6 5 4 3 2 1 58 | 59 | Answer: 60 | 1 9 8 7 6 5 4 3 2 10 61 | 62 | 63 | -------------------------------------------------------------------------------- /problems/lists/swap_neighbours.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Swap neighbours 3 | 4 | Statement: 5 | Given a list of numbers, swap adjacent items in pairs (A[0] with A[1], A[2] with A[3], etc.). Print the resulting list. 6 | 7 | If a list has an odd number of elements, leave the last element in place. 8 | 9 | Test: 10 | 1 2 3 4 5 11 | 12 | Answer: 13 | 2 1 4 3 5 14 | 15 | 16 | Test: 17 | 4 5 3 4 2 3 18 | 19 | Answer: 20 | 5 4 4 3 3 2 21 | 22 | 23 | Test: 24 | 9 4 5 2 3 25 | 26 | Answer: 27 | 4 9 2 5 3 28 | 29 | 30 | Test: 31 | 6 32 | 33 | Answer: 34 | 6 35 | 36 | 37 | Test: 38 | 7 8 39 | 40 | Answer: 41 | 8 7 42 | 43 | 44 | Test: 45 | 1 2 3 46 | 47 | Answer: 48 | 2 1 3 49 | 50 | 51 | Test: 52 | 90 45 3 43 53 | 54 | Answer: 55 | 45 90 43 3 56 | 57 | 58 | Test: 59 | 40 64 -80 -98 -68 56 85 87 -68 -78 60 | 61 | Answer: 62 | 64 40 -98 -80 56 -68 87 85 -78 -68 63 | 64 | 65 | Test: 66 | -1 -11 -40 3 -47 -37 -18 -100 6 -29 14 -1 -89 -20 -36 7 5 78 -5 85 67 | 68 | Answer: 69 | -11 -1 3 -40 -37 -47 -100 -18 -29 6 -1 14 -20 -89 7 -36 78 5 85 -5 70 | 71 | 72 | Test: 73 | -46 35 72 -79 38 -32 1 23 -84 -84 50 -46 -57 -44 72 33 91 -6 88 91 -12 -76 -78 95 63 45 54 13 58 -19 30 48 -98 37 97 74 | 75 | Answer: 76 | 35 -46 -79 72 -32 38 23 1 -84 -84 -46 50 -44 -57 33 72 -6 91 91 88 -76 -12 95 -78 45 63 13 54 -19 58 48 30 37 -98 97 77 | 78 | 79 | -------------------------------------------------------------------------------- /problems/lists/unique_elements.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Unique elements 3 | 4 | Statement: 5 | Given a list of numbers, find and print the elements that appear in the list only once. 6 | 7 | The elements must be printed in the order in which they occur in the original list. 8 | 9 | Test: 10 | 1 2 2 3 3 3 11 | 12 | Answer: 13 | 1 14 | 15 | 16 | Test: 17 | 4 3 5 2 5 1 3 5 18 | 19 | Answer: 20 | 4 2 1 21 | 22 | 23 | Test: 24 | 6 9 6 23 12 19 14 26 25 | 26 | Answer: 27 | 9 23 12 19 14 26 28 | 29 | 30 | Test: 31 | 21 21 16 20 28 28 7 32 | 33 | Answer: 34 | 16 20 7 35 | 36 | 37 | Test: 38 | 21 39 | 40 | Answer: 41 | 21 42 | 43 | 44 | Test: 45 | 5 2 29 4 28 8 46 | 47 | Answer: 48 | 5 2 29 4 28 8 49 | 50 | 51 | Test: 52 | 4 2 9 3 2 9 7 8 4 53 | 54 | Answer: 55 | 3 7 8 56 | 57 | -------------------------------------------------------------------------------- /problems/next_and_previous.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Previous and next 3 | 4 | Statement: 5 | Write a program that reads an integer number and prints its previous and next numbers. See the examples below for the exact format your answers should take. There shouldn't be a space before the period. 6 | 7 |

Remember that you can convert the numbers to strings using the function str. 8 | 9 | Test: 10 | 179 11 | 12 | Answer: 13 | The next number for the number 179 is 180. 14 | The previous number for the number 179 is 178. 15 | 16 | Test: 17 | 0 18 | 19 | Answer: 20 | The next number for the number 0 is 1. 21 | The previous number for the number 0 is -1. 22 | 23 | Test: 24 | 2718281828904590 25 | 26 | Answer: 27 | The next number for the number 2718281828904590 is 2718281828904591. 28 | The previous number for the number 2718281828904590 is 2718281828904589. 29 | -------------------------------------------------------------------------------- /problems/rect_triangle_square.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Area of a right triangle 3 | 4 | Statement: 5 | Write a program that reads the two lengths of the base and the height in the right triangle and prints its area. 6 | Every number is given in a separate line. 7 | 8 |

9 | 10 | Test: 11 | 3 12 | 5 13 | 14 | Answer: 15 | 7.5 16 | 17 | Test: 18 | 10 19 | 2 20 | 21 | Answer: 22 | 10.0 23 | 24 | Test: 25 | 179 26 | 1534 27 | 28 | Answer: 29 | 137293.0 30 | 31 | Test: 32 | 1543 33 | 57 34 | 35 | Answer: 36 | 43975.5 37 | -------------------------------------------------------------------------------- /problems/sets/cubes.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Cubes 3 | 4 | Statement: 5 |

Alice and Bob like to play with colored cubes. Each child has its own set of cubes and each cube has a distinct color, but they want to know how many unique colors exist if they combine their block sets. To determine this, the kids enumerated each distinct color with a random number from \( 0 \) to \( 10^{8} \). At this point their enthusiasm dried up, and you are invited to help them finish the task. 6 | 7 |

Given two integers that indicate the number of blocks in Alice's and then Bob's sets \( N \) and \( M \). The following \( N \) lines contain the numerical color value for each cube in Alice's set. Then the last \( M \) rows contain the numberical color value for each cube in Bob's set.

8 | 9 |

Find three sets: the numerical colors of cubes in both sets, the numerical colors of cubes only in Alice's set, and the numerical colors of cubes only in Bob's set. For each set, print the number of elements in the set, followed by the numerical color elements, sorted in ascending order. 10 | 11 | 12 | Test: 13 | 4 3 14 | 0 15 | 1 16 | 10 17 | 9 18 | 1 19 | 3 20 | 0 21 | 22 | Answer: 23 | 2 24 | 0 25 | 1 26 | 2 27 | 9 28 | 10 29 | 1 30 | 3 31 | 32 | 33 | Test: 34 | 2 2 35 | 1 36 | 2 37 | 2 38 | 3 39 | 40 | Answer: 41 | 1 42 | 2 43 | 1 44 | 1 45 | 1 46 | 3 47 | 48 | 49 | Test: 50 | 0 0 51 | 52 | Answer: 53 | 0 54 | 55 | 0 56 | 57 | 0 58 | 59 | 60 | Test: 61 | 1 1 62 | 0 63 | 1 64 | 65 | Answer: 66 | 0 67 | 68 | 1 69 | 0 70 | 1 71 | 1 72 | 73 | 74 | Test: 75 | 8 5 76 | 1 77 | 10 78 | 100 79 | 1000 80 | 10000 81 | 100000 82 | 1000000 83 | 10000000 84 | 1 85 | 100 86 | 10000 87 | 1000000 88 | 100000000 89 | 90 | Answer: 91 | 4 92 | 1 93 | 100 94 | 10000 95 | 1000000 96 | 4 97 | 10 98 | 1000 99 | 100000 100 | 10000000 101 | 1 102 | 100000000 103 | -------------------------------------------------------------------------------- /problems/sets/guess_number.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Guess the number 3 | 4 | Statement: 5 |

Augustus and Beatrice play the following game. Augustus thinks of a secret integer number from \( 1 \) to \( n \). Beatrice tries to guess the number by providing a set of integers. Augustus answers YES if his secret number exists in the provided set, or NO, if his number does not exist in the provided numbers. Then after a few questions Beatrice, totally confused, asks you to help her determine Augustus's secret number.

6 | 7 |

Given the value of \( n \) in the first line, followed by the a sequence Beatrice's guesses, series of numbers seperated by spaces and Agustus's responses, or Beatrice's plea for HELP. When Beatrice calls for help, provide a list of all the remaining possible secret numbers, in ascending order, separated by a space.

8 | 9 | Test: 10 | 10 11 | 1 2 3 4 5 12 | YES 13 | 2 4 6 8 10 14 | NO 15 | HELP 16 | 17 | Answer: 18 | 1 3 5 19 | 20 | 21 | Test: 22 | 10 23 | 1 2 3 4 5 6 7 8 9 10 24 | YES 25 | 1 26 | NO 27 | 2 28 | NO 29 | 3 30 | NO 31 | 4 32 | NO 33 | 6 34 | NO 35 | 7 36 | NO 37 | 8 38 | NO 39 | 9 40 | NO 41 | 10 42 | NO 43 | HELP 44 | 45 | Answer: 46 | 5 47 | 48 | 49 | Test: 50 | 100 51 | 3 5 8 10 11 13 14 15 16 20 21 23 25 27 29 31 32 33 35 42 43 46 47 48 51 52 57 58 67 68 72 74 75 76 79 80 81 82 83 84 86 89 90 91 92 93 94 95 96 99 52 | YES 53 | 1 4 7 9 14 16 17 19 20 23 25 27 28 29 30 31 32 33 41 42 45 46 48 50 52 54 59 60 61 63 66 67 68 69 70 71 73 74 79 81 82 83 89 90 91 92 93 94 95 100 54 | YES 55 | 3 5 6 15 16 18 19 20 21 22 23 24 26 28 29 35 37 38 39 40 41 43 44 45 46 47 53 55 56 60 61 63 64 65 68 70 71 73 76 79 80 81 82 83 86 90 91 95 96 99 56 | YES 57 | 1 2 3 5 11 16 17 23 25 31 32 33 34 35 38 39 41 43 44 46 47 49 51 53 58 59 62 63 68 69 70 72 73 74 76 77 78 79 80 81 82 83 85 86 93 94 95 97 99 100 58 | YES 59 | 3 7 8 9 10 14 17 20 22 23 24 25 26 27 28 30 34 40 42 43 45 47 48 49 50 51 52 53 54 55 59 62 63 66 67 72 73 75 77 81 83 84 86 89 92 93 94 96 98 100 60 | YES 61 | HELP 62 | 63 | Answer: 64 | 23 81 83 65 | 66 | -------------------------------------------------------------------------------- /problems/sets/guess_number_2.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Guess the number 3 | 4 | Statement: 5 |

Augustus and Beatrice are playing the following game. Augustus thinks of some secret integer number from 1 to n. Beatrice tries 6 | to guess the number, so she says some set of integer numbers. Augustus answers YES if his secret number is in that set, or NO 7 | otherwise. After a few questions Beatrice is totally confused and asks you to help her determine what could be a secret number of Augustus.

8 | 9 |

The first line contains n - the maximum number that Augustus can think of. After it given a pair of lines, the first line 10 | contains a Beatrice question (the set of numbers separated by a space) and the Augustus response to this question.

11 | 12 |

You should print all the possible secret numbers in ascending order 13 | separated by space.

14 | 15 | Name: 16 | Угадай число - 2 17 | 18 | Statement: 19 |

Август и Беатриса продолжают играть в игру, но Август начал жульничать. 20 | На каждый из вопросов Беатрисы он выбирает такой вариант ответа YES или NO, 21 | чтобы множество возможных задуманных чисел оставалось как можно больше. Например, 22 | если Август задумал число от 1 до 5, а Беатриса спросила про числа 1 и 2, то Август 23 | ответит NO, а если Беатриса спросит про 1, 2, 3, то Август ответит YES.

24 | 25 |

Если же Бетриса в своем вопросе перечисляет ровно половину из задуманных чисел, то Август 26 | из вредности всегда отвечает NO. 27 | Наконец, Август при ответе учитывает все предыдущие вопросы Беатрисы и свои ответы на них, 28 | то есть множество возможных задуманных чисел уменьшается.

29 | 30 |

Первая строка содержит наибольшее число, которое мог загадать Август. 31 | Каждая следующая строка содержит очередной вопрос Беатрисы: набор чисел, разделенных пробелами. 32 | Последняя строка входных данных содержит одно слово HELP.

33 | 34 |

Для каждого вопроса Беатрисы выведите ответ Августа на этот вопрос. После этого выведите через 35 | пробел, в порядке возрастания, все числа, которые мог загадать Август после ответа на все вопросы 36 | Беатрисы.

37 | 38 | Test: 39 | 10 40 | 1 2 3 4 5 41 | 2 4 6 8 10 42 | HELP 43 | 44 | Answer: 45 | NO 46 | YES 47 | 6 8 10 48 | 49 | 50 | Test: 51 | 10 52 | 1 53 | 2 54 | 3 55 | 4 56 | 5 57 | 6 58 | 7 59 | 8 60 | 9 61 | HELP 62 | 63 | Answer: 64 | NO 65 | NO 66 | NO 67 | NO 68 | NO 69 | NO 70 | NO 71 | NO 72 | NO 73 | 10 74 | 75 | 76 | Test: 77 | 16 78 | 1 2 3 4 5 6 7 8 79 | 9 10 11 12 80 | 13 14 81 | 16 82 | HELP 83 | 84 | Answer: 85 | NO 86 | NO 87 | NO 88 | NO 89 | 15 90 | 91 | 92 | Test: 93 | 100 94 | 2 3 5 6 9 12 13 14 15 17 19 21 22 24 25 28 31 32 33 34 35 38 43 46 48 54 55 56 57 58 60 61 63 69 70 71 76 77 78 79 80 81 83 91 92 93 94 95 96 99 95 | 2 5 6 7 8 11 13 14 19 24 25 26 28 29 30 31 34 36 37 38 40 42 43 46 49 50 54 55 56 57 61 62 65 68 70 71 72 75 78 79 80 81 82 83 87 90 91 96 99 100 96 | 2 4 6 7 9 11 13 16 20 21 28 29 31 33 34 36 40 41 42 43 45 46 47 48 50 52 54 55 59 64 65 68 69 70 71 73 77 78 81 82 83 84 88 90 92 93 96 98 99 100 97 | 1 4 5 7 9 10 12 13 15 16 18 20 22 23 25 27 28 30 31 33 34 36 38 40 41 43 48 49 50 51 52 53 57 62 63 64 69 71 76 79 80 81 84 85 89 90 93 95 98 100 98 | 8 11 13 14 15 16 17 18 19 21 23 24 26 29 30 31 33 34 35 36 44 51 53 55 58 59 60 61 62 63 64 66 68 71 74 75 78 79 80 83 85 88 89 91 94 95 96 97 98 100 99 | 2 3 4 8 9 11 12 18 23 24 26 28 30 32 33 34 35 36 37 39 41 42 45 54 57 59 60 62 64 66 71 72 74 78 79 80 82 83 84 86 87 88 89 90 91 92 95 97 98 100 100 | HELP 101 | 102 | Answer: 103 | NO 104 | NO 105 | NO 106 | YES 107 | YES 108 | NO 109 | 51 53 85 110 | 111 | -------------------------------------------------------------------------------- /problems/sets/number_of_coincidental.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of equal numbers 3 | 4 | Statement: 5 |

Given two lists of numbers. 6 | Count how many unique numbers occur in both of them.

7 | 8 |

This task can be solved in one line of code.

9 | 10 | Test: 11 | 1 3 2 12 | 4 3 2 13 | 14 | Answer: 15 | 2 16 | 17 | 18 | Test: 19 | 1 2 6 4 5 7 20 | 10 2 3 4 8 21 | 22 | Answer: 23 | 2 24 | 25 | 26 | Test: 27 | 1 7 3 8 10 2 5 28 | 6 5 2 8 4 3 7 29 | 30 | Answer: 31 | 5 32 | 33 | 34 | Test: 35 | 75 8 65 66 3 30 38 45 82 93 89 81 68 20 10 99 84 71 59 36 54 50 14 86 91 16 96 37 80 79 69 52 64 88 32 28 53 2 55 95 21 62 31 5 85 22 39 78 7 83 43 18 48 33 97 11 19 100 41 12 29 58 74 36 | 26 94 17 71 84 75 5 29 21 38 2 35 6 78 89 53 58 86 93 63 36 74 27 72 76 49 52 64 65 100 28 69 8 1 48 39 50 87 73 90 70 13 11 62 66 80 37 15 14 54 67 34 59 44 43 20 57 82 45 95 92 56 47 51 33 10 98 37 | 38 | Answer: 39 | 41 40 | -------------------------------------------------------------------------------- /problems/sets/number_of_unique.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of distinct numbers 3 | 4 | Statement: 5 |

Given a list of integers. 6 | Determine how many distinct numbers there are.

7 | 8 |

This task can be solved in one line of code.

9 | 10 | Test: 11 | 1 2 3 2 1 12 | 13 | Answer: 14 | 3 15 | 16 | 17 | Test: 18 | 1 2 3 4 5 6 7 8 9 10 19 | 20 | Answer: 21 | 10 22 | 23 | 24 | Test: 25 | 1 2 3 4 5 1 2 1 2 7 3 26 | 27 | Answer: 28 | 6 29 | 30 | 31 | Test: 32 | 1 1 1 1 1 1 1 1 1 1 1 1 33 | 34 | Answer: 35 | 1 36 | -------------------------------------------------------------------------------- /problems/sets/number_of_words.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of distinct words in some text 3 | 4 | Statement: 5 |

Given a number \( n \), followed by \( n \) lines of text, print the number of distinct words that appear in the text.

6 | 7 |

For this, we define a word to be a sequence of non-whitespace characters, seperated by one or more whitespace or newline characters. Punctuation marks are part of a word, in this definition.

8 | 9 | 10 | Test: 11 | 4 12 | She sells sea shells on the sea shore; 13 | The shells that she sells are sea shells I'm sure. 14 | So if she sells sea shells on the sea shore, 15 | I'm sure that the shells are sea shore shells. 16 | 17 | Answer: 18 | 19 19 | 20 | Test: 21 | 14 22 | The other two, slight air, and purging fire, 23 | Are both with thee, wherever I abide, 24 | The first my thought, the other my desire, 25 | These present-absent with swift motion slide. 26 | For when these quicker elements are gone 27 | In tender embassy of love to thee, 28 | My life being made of four, with two alone, 29 | Sinks down to death, oppressed with melancholy. 30 | Until life's composition be recured, 31 | By those swift messengers returned from thee, 32 | Who even but now come back again assured, 33 | Of thy fair health, recounting it to me. 34 | This told, I joy, but then no longer glad, 35 | I send them back again and straight grow sad. 36 | 37 | 38 | Answer: 39 | 87 40 | 41 | 42 | Test: 43 | 1 44 | a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 45 | 46 | Answer: 47 | 1 48 | 49 | 50 | Test: 51 | 1 52 | a b a c a b a d a b a c a b a 53 | 54 | Answer: 55 | 4 56 | 57 | 58 | Test: 59 | 30 60 | Not much chance, completely cut loose from purpose, 61 | He was a young man riding a bus through North Carolina on the way to somewhere. 62 | And it began to snow. 63 | And the bus stopped at a little cafe in the hills and the passengers entered. 64 | And he sat at the counter with the others, and he ordered, the food arrived. 65 | And the meal was particularly good. 66 | And the coffee. 67 | The waitress was unlike the women he had known. 68 | She was unaffected, and there was a natural humor which came from her. 69 | And the fry cook said crazy things. 70 | And the dishwasher in back laughed a good clean pleasant laugh. 71 | And the young man watched the snow through the window. 72 | And he wanted to stay in that cafe forever. 73 | The curious feeling swam through him that everything was beautiful there. 74 | And it would always stay beautiful there. 75 | And then the bus driver told the passengers that it was time to board. 76 | And the young man thought: “I’ll just stay here, I’ll just stay here.” 77 | And then he rose and he followed the others into the bus. 78 | He found his seat and looked at the cafe through the window. 79 | And then the bus moved off, down a curve, downward, out of the hills. 80 | And the young man looked straight forward. 81 | And he heard the other passengers speaking of other things, 82 | or they were reading or trying to sleep. 83 | And they hadn’t noticed the magic. 84 | And the young man put his head to one side, 85 | closed his eyes, and pretended to sleep. 86 | There was nothing else to do, 87 | just to listen to the sound of the engine, 88 | and the sound of the tires 89 | in the snow. 90 | 91 | Answer: 92 | 148 93 | 94 | 95 | -------------------------------------------------------------------------------- /problems/sets/occurs_before.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Has the number been encountered before 3 | 4 | Statement: 5 |

Given a sequence of numbers, determine if the next number has already been encountered. For each number, print the word YES (in a separate line) if this number has already been encountered, and print NO, if it has not already been encountered.

6 | 7 | Test: 8 | 1 2 3 2 3 4 9 | 10 | Answer: 11 | NO 12 | NO 13 | NO 14 | YES 15 | YES 16 | NO 17 | 18 | 19 | Test: 20 | 1 1 1 1 1 1 1 1 1 1 21 | 22 | Answer: 23 | NO 24 | YES 25 | YES 26 | YES 27 | YES 28 | YES 29 | YES 30 | YES 31 | YES 32 | YES 33 | 34 | 35 | Test: 36 | 1 2 3 4 5 6 7 8 9 10 37 | 38 | Answer: 39 | NO 40 | NO 41 | NO 42 | NO 43 | NO 44 | NO 45 | NO 46 | NO 47 | NO 48 | NO 49 | 50 | 51 | Test: 52 | 10 10 4 2 5 5 10 4 1 10 53 | 54 | Answer: 55 | NO 56 | YES 57 | NO 58 | NO 59 | NO 60 | YES 61 | YES 62 | YES 63 | NO 64 | YES 65 | -------------------------------------------------------------------------------- /problems/sets/polyglotes.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Polyglots 3 | 4 | Statement: 5 |

Each student at a certain school speaks a number of languages. We need to determine which languges are spoken by all the students, which languages are spoken by at least one student.

6 | 7 |

Given, the number of students, and then for each student given the number of languages they speak followed by the name of each language spoken, find and print the number of languages spoken by all the students, followed by a list the languages by name, then print the number of languages spoken by at least one student, followed by the list of the languages by name. Print the languages in alphabetical order.

8 | 9 | Test: 10 | 3 11 | 3 12 | Russian 13 | English 14 | Japanese 15 | 2 16 | Russian 17 | English 18 | 1 19 | English 20 | 21 | Answer: 22 | 1 23 | English 24 | 3 25 | English 26 | Japanese 27 | Russian 28 | 29 | 30 | Test: 31 | 5 32 | 1 33 | German 34 | 1 35 | German 36 | 1 37 | German 38 | 1 39 | German 40 | 1 41 | German 42 | 43 | Answer: 44 | 1 45 | German 46 | 1 47 | German 48 | 49 | 50 | Test: 51 | 4 52 | 3 53 | Russian 54 | Spanish 55 | German 56 | 3 57 | Russian 58 | German 59 | Spanish 60 | 3 61 | Spanish 62 | Russian 63 | German 64 | 3 65 | German 66 | Russian 67 | Spanish 68 | 69 | Answer: 70 | 3 71 | German 72 | Russian 73 | Spanish 74 | 3 75 | German 76 | Russian 77 | Spanish 78 | 79 | -------------------------------------------------------------------------------- /problems/sets/sets_intersection.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The intersection of sets 3 | 4 | Statement: 5 |

Given two lists of numbers. 6 | Find all the numbers that occur in both the first and the second list and print them in ascending order.

7 | 8 |

Even this task can be solved in one line of code.

9 | 10 | Test: 11 | 1 3 2 12 | 4 3 2 13 | 14 | Answer: 15 | 2 3 16 | 17 | 18 | Test: 19 | 1 2 6 4 5 7 20 | 10 2 3 4 8 21 | 22 | Answer: 23 | 2 4 24 | 25 | 26 | Test: 27 | 82 54 91 100 70 33 88 14 52 48 56 20 63 16 22 23 30 8 84 75 45 28 | 10 44 77 90 43 75 25 24 5 21 71 70 83 68 18 92 81 57 27 67 48 6 29 | 30 | 31 | Answer: 32 | 48 70 75 33 | 34 | -------------------------------------------------------------------------------- /problems/sets/strikes.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Забастовки 3 | 4 | Statement: 5 |

Политическая жизнь одной страны очень оживленная. В стране действует K политических партий, 6 | каждая из которых регулярно объявляет национальную забастовку. Дни, когда хотя бы 7 | одна из партий объявляет забастовку, при условии, что это не суббота или воскресенье 8 | (когда и так никто не работает), наносят большой ущерб экономике страны.

9 | 10 |

i-я партия объявляет забастовки строго каждые b_i дней, начиная с 11 | дня с номером a_i. То есть i-я партия объявляет забастовки в дни 12 | a_i, a_i + b_i, a_i + 2 * b_i и т.д. Если в какой-то день несколько 13 | партий объявляет забастовку, то это считается одной общенациональной забастовкой.

14 | 15 |

В календаре страны N дней, пронумерованных, начиная с единицы. Первый день 16 | года является понедельником, шестой и седьмой дни года — выходные, 17 | неделя состоит из семи дней.

18 | 19 |

В первой строке даны числа N и K. Далее идет K строк, описывающие 20 | графики проведения забастовок. i-я строка содержит числа a_i и b_i. Вам 21 | нужно определить число забастовок, произошедших в этой стране в течении года.

22 | 23 | Test: 24 | 19 3 25 | 2 3 26 | 3 5 27 | 9 8 28 | 29 | Answer: 30 | 8 31 | 32 | 33 | Test: 34 | 5 2 35 | 1 2 36 | 2 2 37 | 38 | Answer: 39 | 5 40 | 41 | 42 | Test: 43 | 1000 1 44 | 1 1 45 | 46 | Answer: 47 | 715 48 | 49 | 50 | Test: 51 | 1000 1 52 | 179 1000 53 | 54 | Answer: 55 | 1 56 | 57 | 58 | Test: 59 | 1000 1 60 | 700 1000 61 | 62 | Answer: 63 | 0 64 | 65 | 66 | Test: 67 | 100000 2 68 | 746 23 69 | 9578 12 70 | 71 | Answer: 72 | 8231 73 | 74 | 75 | Test: 76 | 100 3 77 | 39 68 78 | 62 17 79 | 7 72 80 | 81 | Answer: 82 | 3 83 | 84 | 85 | Test: 86 | 1000 10 87 | 14 81 88 | 79 16 89 | 27 44 90 | 96 91 91 | 6 98 92 | 27 48 93 | 89 29 94 | 30 42 95 | 86 90 96 | 14 19 97 | 98 | Answer: 99 | 163 100 | 101 | -------------------------------------------------------------------------------- /problems/str/delete_char.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Delete a character 3 | 4 | Statement: 5 |

Given a string. Remove from this string all the characters @. 6 | 7 | Test: 8 | Bilbo.Baggins@bagend.hobbiton.shire.me 9 | 10 | Answer: 11 | Bilbo.Bagginsbagend.hobbiton.shire.me 12 | 13 | 14 | Test: 15 | dfa;sdkfj;ajva;bvna'sdasdfasdglJLHJKFHLDKJFh 16 | 17 | Answer: 18 | dfa;sdkfj;ajva;bvna'sdasdfasdglJLHJKFHLDKJFh 19 | 20 | 21 | Test: 22 | @ 23 | 24 | Answer: 25 | 26 | 27 | 28 | Test: 29 | @W@E@E@E@R 30 | 31 | Answer: 32 | WEEER 33 | 34 | 35 | Test: 36 | @@@@@@@@@@ 37 | 38 | Answer: 39 | 40 | 41 | 42 | Test: 43 | H@K@M@J@M@L 44 | 45 | Answer: 46 | HKMJML 47 | 48 | 49 | Test: 50 | @@@@@F@@@@KL@@@@@J@J@J@JJJH@JJKK@JJJ@JJ 51 | 52 | Answer: 53 | FKLJJJJJJHJJKKJJJJJ 54 | 55 | 56 | -------------------------------------------------------------------------------- /problems/str/delete_chunk.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Remove the fragment 3 | 4 | Statement: 5 |

Given a string in which the letter h occurs at least twice. 6 | Remove from that string the first and the last occurrence of the letter h, 7 | as well as all the characters between them. 8 | 9 | Test: 10 | In the hole in the ground there lived a hobbit 11 | 12 | Answer: 13 | In tobbit 14 | 15 | 16 | Test: 17 | qwertyhasdfghzxcvb 18 | 19 | Answer: 20 | qwertyzxcvb 21 | 22 | 23 | Test: 24 | asdfghhzxcvb 25 | 26 | Answer: 27 | asdfgzxcvb 28 | 29 | 30 | Test: 31 | ahahahahaha 32 | 33 | Answer: 34 | aa 35 | 36 | 37 | Test: 38 | haaaaaaaaaaaaaaaaaah 39 | 40 | Answer: 41 | 42 | 43 | 44 | Test: 45 | hh 46 | 47 | Answer: 48 | 49 | 50 | 51 | Test: 52 | ahaha 53 | 54 | Answer: 55 | aa 56 | 57 | 58 | -------------------------------------------------------------------------------- /problems/str/delete_every_third_char.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Delete every third character 3 | 4 | Statement: 5 |

Given a string. Delete from it all the characters whose indices are divisible by 3. 6 | 7 | Test: 8 | Python 9 | 10 | Answer: 11 | yton 12 | 13 | 14 | Test: 15 | Hello 16 | 17 | Answer: 18 | elo 19 | 20 | 21 | Test: 22 | qwer 23 | 24 | Answer: 25 | we 26 | 27 | 28 | Test: 29 | a 30 | 31 | Answer: 32 | 33 | 34 | 35 | Test: 36 | ab 37 | 38 | Answer: 39 | b 40 | 41 | 42 | Test: 43 | abc 44 | 45 | Answer: 46 | bc 47 | 48 | 49 | Test: 50 | abcdefg 51 | 52 | Answer: 53 | bcef 54 | 55 | 56 | Test: 57 | abcdefgh 58 | 59 | Answer: 60 | bcefh 61 | 62 | 63 | Test: 64 | abcdefghi 65 | 66 | Answer: 67 | bcefhi 68 | 69 | 70 | Test: 71 | abcdefghij 72 | 73 | Answer: 74 | bcefhi 75 | 76 | 77 | Test: 78 | abcdefghijk 79 | 80 | Answer: 81 | bcefhik 82 | 83 | 84 | Test: 85 | abcdefghijkl 86 | 87 | Answer: 88 | bcefhikl 89 | 90 | 91 | Test: 92 | qwertyuiopasdfghjklzxcvbnm 93 | 94 | Answer: 95 | wetyioasfgjkzxvbm 96 | 97 | 98 | -------------------------------------------------------------------------------- /problems/str/first_and_last_occurences.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The first and last occurrence 3 | 4 | Statement: 5 |

Given a string that may or may not contain a letter of interest. 6 | Print the index location of the first and last appearance of f. 7 | If the letter f occurs only once, then output its index. 8 | If the letter f does not occur, then do not print anything. 9 | 10 |

Don't use loops in this task. 11 | 12 | Test: 13 | comfort 14 | 15 | Answer: 16 | 3 17 | 18 | 19 | Test: 20 | office 21 | 22 | Answer: 23 | 1 2 24 | 25 | 26 | Test: 27 | hello 28 | 29 | Answer: 30 | 31 | 32 | Test: 33 | fffffffffffffff 34 | 35 | Answer: 36 | 0 14 37 | 38 | 39 | Test: 40 | aaaaaaaaaaaaaaaaaaaaafaaaaaaaaaaaaaaaaaaaaaaaa 41 | 42 | Answer: 43 | 21 44 | 45 | 46 | Test: 47 | aaaaaaaaaaaaaaaaaaaaaaaaffaaaaaaaaaaaaaaaaaaaa 48 | 49 | Answer: 50 | 24 25 51 | 52 | 53 | Test: 54 | afafafafafafafa 55 | 56 | Answer: 57 | 1 13 58 | 59 | 60 | -------------------------------------------------------------------------------- /problems/str/num_words.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of words 3 | 4 | Statement: 5 |

Given a string consisting of words separated by spaces. Determine how many words it has. 6 | To solve the problem, use the method count. 7 | 8 | 9 | Test: 10 | Hello world 11 | 12 | Answer: 13 | 2 14 | 15 | 16 | Test: 17 | Hello 18 | 19 | Answer: 20 | 1 21 | 22 | 23 | Test: 24 | q w e 25 | 26 | Answer: 27 | 3 28 | 29 | 30 | Test: 31 | In the hole in the ground there lived a hobbit 32 | 33 | Answer: 34 | 10 35 | 36 | 37 | Test: 38 | One two three four five 39 | 40 | Answer: 41 | 5 42 | 43 | 44 | -------------------------------------------------------------------------------- /problems/str/replace_in_chunk.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Replace within the fragment 3 | 4 | Statement: 5 |

Given a string. Replace every occurrence of the letter h by 6 | the letter H, except for the first and the last ones. 7 | 8 | Test: 9 | In the hole in the ground there lived a hobbit 10 | 11 | Answer: 12 | In the Hole in tHe ground tHere lived a hobbit 13 | 14 | 15 | Test: 16 | qwertyhahsdhfghzxcvb 17 | 18 | Answer: 19 | qwertyhaHsdHfghzxcvb 20 | 21 | 22 | Test: 23 | asdfghhzxcvb 24 | 25 | Answer: 26 | asdfghhzxcvb 27 | 28 | 29 | Test: 30 | ahbhchdheha 31 | 32 | Answer: 33 | ahbHcHdHeha 34 | 35 | 36 | Test: 37 | habcdefgijklmnh 38 | 39 | Answer: 40 | habcdefgijklmnh 41 | 42 | 43 | Test: 44 | hh 45 | 46 | Answer: 47 | hh 48 | 49 | 50 | Test: 51 | hah 52 | 53 | Answer: 54 | hah 55 | 56 | 57 | Test: 58 | hhh 59 | 60 | Answer: 61 | hHh 62 | 63 | 64 | Test: 65 | hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh 66 | 67 | Answer: 68 | hHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHh 69 | 70 | 71 | Test: 72 | aHbhchdheha 73 | 74 | Answer: 75 | aHbhcHdHeha 76 | -------------------------------------------------------------------------------- /problems/str/replace_substring.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Replace the substring 3 | 4 | Statement: 5 |

Given a string. Replace in this string all the numbers 1 by the word 6 | one. 7 | 8 | Test: 9 | 1+1=2 10 | 11 | Answer: 12 | one+one=2 13 | 14 | 15 | Test: 16 | Hello, 2345678990 17 | 18 | Answer: 19 | Hello, 2345678990 20 | 21 | 22 | Test: 23 | 1 24 | 25 | Answer: 26 | one 27 | 28 | 29 | Test: 30 | 1111111111111111111111111111111111 31 | 32 | Answer: 33 | oneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneoneone 34 | 35 | 36 | Test: 37 | 1213141516171819101 38 | 39 | Answer: 40 | one2one3one4one5one6one7one8one9one0one 41 | 42 | 43 | -------------------------------------------------------------------------------- /problems/str/reverse_chunk.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Reverse the fragment 3 | 4 | Statement: 5 |

Given a string in which the letter h occurs 6 | at least two times, reverse the sequence of characters 7 | enclosed between the first and last appearances. 8 | 9 | 10 | Test: 11 | In the hole in the ground there lived a hobbit 12 | 13 | Answer: 14 | In th a devil ereht dnuorg eht ni eloh ehobbit 15 | 16 | 17 | Test: 18 | qwertyhasdfghzxcvb 19 | 20 | Answer: 21 | qwertyhgfdsahzxcvb 22 | 23 | 24 | Test: 25 | asdfghhzxcvb 26 | 27 | Answer: 28 | asdfghhzxcvb 29 | 30 | 31 | Test: 32 | ahbhchdheha 33 | 34 | Answer: 35 | ahehdhchbha 36 | 37 | 38 | Test: 39 | habcdefgijklmnh 40 | 41 | Answer: 42 | hnmlkjigfedcbah 43 | 44 | 45 | Test: 46 | hh 47 | 48 | Answer: 49 | hh 50 | 51 | 52 | Test: 53 | hah 54 | 55 | Answer: 56 | hah 57 | 58 | 59 | Test: 60 | habh 61 | 62 | Answer: 63 | hbah 64 | 65 | 66 | Test: 67 | ahcvbhs 68 | 69 | Answer: 70 | ahbvchs 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /problems/str/second_occurence.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The second occurrence 3 | 4 | Statement: 5 |

Given a string that may or may not contain the letter of interest. 6 | Print the index location of the second occurrence of the letter f. 7 | If the string contains the letter f only once, then print -1, 8 | and if the string does not contain the letter f, then print -2. 9 | 10 | Test: 11 | comfort 12 | 13 | Answer: 14 | -1 15 | 16 | 17 | Test: 18 | coffee 19 | 20 | Answer: 21 | 3 22 | 23 | 24 | Test: 25 | qwerty 26 | 27 | Answer: 28 | -2 29 | 30 | 31 | Test: 32 | f 33 | 34 | Answer: 35 | -1 36 | 37 | 38 | Test: 39 | oooooooooooooooooof 40 | 41 | Answer: 42 | -1 43 | 44 | 45 | Test: 46 | ff 47 | 48 | Answer: 49 | 1 50 | 51 | 52 | Test: 53 | ffffffffffffffff 54 | 55 | Answer: 56 | 1 57 | 58 | 59 | Test: 60 | foooooooooooooof 61 | 62 | Answer: 63 | 15 64 | 65 | 66 | Test: 67 | oooooooooooooff 68 | 69 | Answer: 70 | 14 71 | 72 | 73 | Test: 74 | ofofofofofofofofo 75 | 76 | Answer: 77 | 3 78 | 79 | -------------------------------------------------------------------------------- /problems/str/slices.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Slices 3 | 4 | Statement: 5 |

You are given a string. 6 | 7 |

In the first line, print the third character of this string. 8 | 9 |

In the second line, print the second to last character of this string. 10 | 11 |

In the third line, print the first five characters of this string. 12 | 13 |

In the fourth line, print all but the last two characters of this string. 14 | 15 |

In the fifth line, print all the characters of this string with even indices (remember indexing starts at 0, so the characters are displayed starting with the first). 16 | 17 |

In the sixth line, print all the characters of this string with odd indices (i.e. starting with the second character in the string). 18 | 19 |

In the seventh line, print all the characters of the string in reverse order. 20 | 21 |

In the eighth line, print every second character of the string in reverse order, starting from the last one. 22 | 23 |

In the ninth line, print the length of the given string. 24 | 25 | 26 | Test: 27 | Abrakadabra 28 | 29 | Answer: 30 | r 31 | r 32 | Abrak 33 | Abrakadab 34 | Arkdba 35 | baaar 36 | arbadakarbA 37 | abdkrA 38 | 11 39 | 40 | 41 | Test: 42 | Hello 43 | 44 | Answer: 45 | l 46 | l 47 | Hello 48 | Hel 49 | Hlo 50 | el 51 | olleH 52 | olH 53 | 5 54 | 55 | 56 | Test: 57 | qwertyuiop 58 | 59 | Answer: 60 | e 61 | o 62 | qwert 63 | qwertyui 64 | qetuo 65 | wryip 66 | poiuytrewq 67 | piyrw 68 | 10 69 | 70 | 71 | Test: 72 | asdfghjklzxcv 73 | 74 | Answer: 75 | d 76 | c 77 | asdfg 78 | asdfghjklzx 79 | adgjlxv 80 | sfhkzc 81 | vcxzlkjhgfdsa 82 | vxljgda 83 | 13 84 | -------------------------------------------------------------------------------- /problems/str/swap_two_words.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | To swap the two words 3 | 4 | Statement: 5 |

Given a string consisting of exactly two words separated by a space. 6 | Print a new string with the first and second word positions swapped (the second word is printed first). 7 | 8 |

This task should not use loops and if. 9 | 10 | 11 | Test: 12 | Hello, world! 13 | 14 | Answer: 15 | world! Hello, 16 | 17 | 18 | Test: 19 | A B 20 | 21 | Answer: 22 | B A 23 | 24 | 25 | Test: 26 | Q WERRTYUIOP 27 | 28 | Answer: 29 | WERRTYUIOP Q 30 | 31 | 32 | Test: 33 | QWERTYUIOP M 34 | 35 | Answer: 36 | M QWERTYUIOP 37 | 38 | 39 | Test: 40 | sadfahsjkldfhasjkdfhaklsjdfhjkl asdlkfhasdjklfhaslkdfjhalskdfgalsdf 41 | 42 | Answer: 43 | asdlkfhasdjklfhaslkdfjhalskdfgalsdf sadfahsjkldfhasjkdfhaklsjdfhjkl 44 | 45 | 46 | -------------------------------------------------------------------------------- /problems/str/two_halves.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The two halves 3 | 4 | Statement: 5 |

Given a string. Cut it into two "equal" parts (If the length of the string is odd, place the center character 6 | in the first string, so that the first string contains one more characther than the second). Now print a new string 7 | on a single row with the first and second halfs interchanged (second half first and the first half second) 8 | 9 |

Don't use the statement if in this task. 10 | 11 | Test: 12 | Hi 13 | 14 | Answer: 15 | iH 16 | 17 | 18 | Test: 19 | Hello 20 | 21 | Answer: 22 | loHel 23 | 24 | 25 | Test: 26 | Qwerty 27 | 28 | Answer: 29 | rtyQwe 30 | 31 | 32 | Test: 33 | Z 34 | 35 | Answer: 36 | Z 37 | 38 | 39 | Test: 40 | asdfghj 41 | 42 | Answer: 43 | ghjasdf 44 | 45 | 46 | Test: 47 | asdfghjzxc 48 | 49 | Answer: 50 | hjzxcasdfg 51 | 52 | 53 | -------------------------------------------------------------------------------- /problems/while/bank_percents.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Банковские проценты 3 | 4 | 5 | Statement: 6 |

Вклад в банке составляет x рублей. Ежегодно он увеличивается на p процентов, 7 | после чего дробная часть копеек отбрасывается. Определите, через сколько лет вклад составит не менее y рублей. 8 | 9 |

Выражение «дробная часть копеек отбрасывается» означает, что если у вас оказалось 123.4567 рублей, т. е. 123 рубля и 45.67 копеек, то после округления у вас получится 123 рубля и 45 копеек, т.е. 123.45 рублей. 10 | 11 |

Программа получает на вход три натуральных числа: x, p, y и должна вывести одно целое число. 12 | 13 | 14 | Test: 15 | 100 16 | 10 17 | 200 18 | 19 | Answer: 20 | 8 21 | 22 | 23 | Test: 24 | 100 25 | 100 26 | 200 27 | 28 | Answer: 29 | 1 30 | 31 | 32 | Test: 33 | 1 34 | 1 35 | 2 36 | 37 | Answer: 38 | 100 39 | 40 | 41 | Test: 42 | 100 43 | 1 44 | 200 45 | 46 | Answer: 47 | 70 48 | 49 | 50 | Test: 51 | 400 52 | 32 53 | 743 54 | 55 | Answer: 56 | 3 57 | 58 | 59 | Test: 60 | 400 61 | 7 62 | 1046 63 | 64 | Answer: 65 | 15 66 | -------------------------------------------------------------------------------- /problems/while/is_fibonacci.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The index of a Fibonacci number 3 | 4 | Statement: 5 | The Fibonacci sequence is defined as follows: 6 | $$ \phi_0 = 0, \ \phi_1 = 1, \ \phi_n = \phi_{n-1} + \phi_{n-2} . $$ 7 | Given an integer \( a \), determine its index among the Fibonacci numbers, that is, print the number \( n \) such that \( \phi_n = a \). If \( a \) is not a Fibonacci number, print -1. 8 | 9 | Test: 10 | 8 11 | 12 | Answer: 13 | 6 14 | 15 | 16 | Test: 17 | 10 18 | 19 | Answer: 20 | -1 21 | 22 | 23 | Test: 24 | 13 25 | 26 | Answer: 27 | 7 28 | 29 | 30 | Test: 31 | 55 32 | 33 | Answer: 34 | 10 35 | 36 | 37 | Test: 38 | 56 39 | 40 | Answer: 41 | -1 42 | 43 | 44 | Test: 45 | 57 46 | 47 | Answer: 48 | -1 49 | 50 | 51 | Test: 52 | 54 53 | 54 | Answer: 55 | -1 56 | 57 | 58 | Test: 59 | 2 60 | 61 | Answer: 62 | 3 63 | 64 | 65 | Test: 66 | 3 67 | 68 | Answer: 69 | 4 70 | 71 | 72 | Test: 73 | 4 74 | 75 | Answer: 76 | -1 77 | 78 | 79 | Test: 80 | 5 81 | 82 | Answer: 83 | 5 84 | 85 | 86 | Test: 87 | 6 88 | 89 | Answer: 90 | -1 91 | 92 | 93 | Test: 94 | 1134903170 95 | 96 | Answer: 97 | 45 98 | 99 | 100 | Test: 101 | 1134903171 102 | 103 | Answer: 104 | -1 105 | 106 | 107 | Test: 108 | 1134903169 109 | 110 | Answer: 111 | -1 112 | 113 | 114 | -------------------------------------------------------------------------------- /problems/while/kth_fibonacci.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Fibonacci numbers 3 | 4 | Statement: 5 | The Fibonacci sequence is defined as follows: 6 | $$ \phi_0 = 0, \ \phi_1 = 1, \ \phi_n = \phi_{n-1} + \phi_{n-2} . $$ 7 | Given a non-negative integer \( n \), print the \( n \)th Fibonacci number \( \phi_n \). 8 | 9 |

10 | This problem can also be solved with a for loop. 11 |

12 | 13 | Test: 14 | 6 15 | 16 | Answer: 17 | 8 18 | 19 | 20 | Test: 21 | 0 22 | 23 | Answer: 24 | 0 25 | 26 | 27 | Test: 28 | 2 29 | 30 | Answer: 31 | 1 32 | 33 | 34 | Test: 35 | 3 36 | 37 | Answer: 38 | 2 39 | 40 | 41 | Test: 42 | 4 43 | 44 | Answer: 45 | 3 46 | 47 | 48 | Test: 49 | 1 50 | 51 | Answer: 52 | 1 53 | 54 | 55 | Test: 56 | 5 57 | 58 | Answer: 59 | 5 60 | 61 | 62 | Test: 63 | 7 64 | 65 | Answer: 66 | 13 67 | 68 | 69 | Test: 70 | 8 71 | 72 | Answer: 73 | 21 74 | 75 | 76 | Test: 77 | 9 78 | 79 | Answer: 80 | 34 81 | 82 | 83 | Test: 84 | 10 85 | 86 | Answer: 87 | 55 88 | 89 | 90 | Test: 91 | 11 92 | 93 | Answer: 94 | 89 95 | 96 | 97 | Test: 98 | 12 99 | 100 | Answer: 101 | 144 102 | 103 | 104 | Test: 105 | 13 106 | 107 | Answer: 108 | 233 109 | 110 | 111 | Test: 112 | 14 113 | 114 | Answer: 115 | 377 116 | 117 | 118 | Test: 119 | 15 120 | 121 | Answer: 122 | 610 123 | 124 | 125 | Test: 126 | 16 127 | 128 | Answer: 129 | 987 130 | 131 | 132 | Test: 133 | 17 134 | 135 | Answer: 136 | 1597 137 | 138 | 139 | Test: 140 | 18 141 | 142 | Answer: 143 | 2584 144 | 145 | 146 | Test: 147 | 19 148 | 149 | Answer: 150 | 4181 151 | 152 | 153 | Test: 154 | 20 155 | 156 | Answer: 157 | 6765 158 | -------------------------------------------------------------------------------- /problems/while/list_of_squares.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | List of squares 3 | 4 | Statement: 5 | For a given integer N, print all the squares of integer numbers where the square is less than or equal to N, in ascending order. 6 | 7 | Test: 8 | 50 9 | 10 | Answer: 11 | 1 4 9 16 25 36 49 12 | 13 | 14 | Test: 15 | 10 16 | 17 | Answer: 18 | 1 4 9 19 | 20 | 21 | Test: 22 | 9 23 | 24 | Answer: 25 | 1 4 9 26 | 27 | 28 | Test: 29 | 4 30 | 31 | Answer: 32 | 1 4 33 | 34 | 35 | Test: 36 | 1 37 | 38 | Answer: 39 | 1 40 | 41 | 42 | Test: 43 | 100 44 | 45 | Answer: 46 | 1 4 9 16 25 36 49 64 81 100 47 | 48 | Test: 49 | 99 50 | 51 | Answer: 52 | 1 4 9 16 25 36 49 64 81 53 | -------------------------------------------------------------------------------- /problems/while/minimal_divisor.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Least divisor 3 | 4 | Statement: 5 | Given an integer not less than 2. Print its smallest integer divisor greater than 1. 6 | 7 | Test: 8 | 15 9 | 10 | Answer: 11 | 3 12 | 13 | 14 | Test: 15 | 2 16 | 17 | Answer: 18 | 2 19 | 20 | 21 | Test: 22 | 3 23 | 24 | Answer: 25 | 3 26 | 27 | 28 | Test: 29 | 4 30 | 31 | Answer: 32 | 2 33 | 34 | 35 | Test: 36 | 5 37 | 38 | Answer: 39 | 5 40 | 41 | 42 | Test: 43 | 6 44 | 45 | Answer: 46 | 2 47 | 48 | 49 | Test: 50 | 7 51 | 52 | Answer: 53 | 7 54 | 55 | 56 | Test: 57 | 8 58 | 59 | Answer: 60 | 2 61 | 62 | 63 | Test: 64 | 35 65 | 66 | Answer: 67 | 5 68 | 69 | 70 | Test: 71 | 55 72 | 73 | Answer: 74 | 5 75 | 76 | 77 | Test: 78 | 179 79 | 80 | Answer: 81 | 179 82 | 83 | 84 | -------------------------------------------------------------------------------- /problems/while/powers_of_two.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The power of two 3 | 4 | Statement: 5 |

For a given integer N, find the greatest integer x where \( 2^x \) is less than or equal to N. 6 | Print the exponent value and the result of the expression \( 2^x \).

7 | 8 |

Don't use the operation **.

9 | 10 | 11 | Test: 12 | 50 13 | 14 | Answer: 15 | 5 32 16 | 17 | 18 | Test: 19 | 10 20 | 21 | Answer: 22 | 3 8 23 | 24 | 25 | Test: 26 | 8 27 | 28 | Answer: 29 | 3 8 30 | 31 | 32 | Test: 33 | 7 34 | 35 | Answer: 36 | 2 4 37 | 38 | 39 | Test: 40 | 1 41 | 42 | Answer: 43 | 0 1 44 | 45 | 46 | Test: 47 | 2 48 | 49 | Answer: 50 | 1 2 51 | 52 | 53 | Test: 54 | 3 55 | 56 | Answer: 57 | 1 2 58 | 59 | 60 | Test: 61 | 4 62 | 63 | Answer: 64 | 2 4 65 | 66 | 67 | Test: 68 | 5 69 | 70 | Answer: 71 | 2 4 72 | 73 | 74 | Test: 75 | 100 76 | 77 | Answer: 78 | 6 64 79 | 80 | 81 | Test: 82 | 1025 83 | 84 | Answer: 85 | 10 1024 86 | 87 | 88 | Test: 89 | 15431543 90 | 91 | Answer: 92 | 23 8388608 93 | -------------------------------------------------------------------------------- /problems/while/running.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Morning jog 3 | 4 | 5 | Statement: 6 |

As a future athlete you just started your practice for an upcoming event. 7 | Given that on the first day you run x miles, and by the event you must be able to run y miles. 8 |

Calculate the number of days required for you to finally reach the required distance for the event, if you 9 | increases your distance each day by 10% from the previous day. 10 |

Print one integer representing the number of days to reach the required distance. 11 | 12 | Test: 13 | 10 14 | 20 15 | 16 | 17 | Answer: 18 | 9 19 | 20 | 21 | Test: 22 | 10 23 | 30 24 | 25 | 26 | Answer: 27 | 13 28 | 29 | 30 | Test: 31 | 10 32 | 100 33 | 34 | 35 | Answer: 36 | 26 37 | 38 | 39 | Test: 40 | 10 41 | 10 42 | 43 | 44 | Answer: 45 | 1 46 | 47 | 48 | Test: 49 | 100 50 | 101 51 | 52 | 53 | Answer: 54 | 2 55 | 56 | 57 | Test: 58 | 100 59 | 99 60 | 61 | 62 | Answer: 63 | 1 64 | 65 | 66 | Test: 67 | 1 68 | 1000 69 | 70 | 71 | Answer: 72 | 74 73 | 74 | 75 | Test: 76 | 10 77 | 11 78 | 79 | 80 | Answer: 81 | 2 82 | 83 | 84 | 85 | Test: 86 | 100 87 | 121 88 | 89 | 90 | Answer: 91 | 3 92 | -------------------------------------------------------------------------------- /problems/while/seq_avg.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The average of the sequence 3 | 4 | 5 | Statement: 6 | Determine the average of all elements of the sequence ending with the number 0. 7 | 8 | 9 | Test: 10 | 1 11 | 7 12 | 9 13 | 0 14 | 15 | Answer: 16 | 5.66666666667 17 | 18 | 19 | Test: 20 | 1 21 | 1 22 | 1 23 | 1 24 | 1 25 | 1 26 | 1 27 | 1 28 | 1 29 | 0 30 | 31 | Answer: 32 | 1.0 33 | 34 | 35 | Test: 36 | 34 37 | 2345 38 | 2345 39 | 2345 40 | 2345 41 | 345 42 | 3 43 | 345 44 | 3 45 | 345 46 | 1 47 | 3 48 | 424 49 | 5 50 | 453 51 | 0 52 | 53 | Answer: 54 | 756.066666667 55 | 56 | 57 | Test: 58 | 7883 59 | 0 60 | 61 | Answer: 62 | 7883.0 63 | 64 | 65 | Test: 66 | 1 67 | 2 68 | 3 69 | -6 70 | 0 71 | 72 | Answer: 73 | 0.0 74 | 75 | 76 | Test: 77 | 1 78 | 2 79 | 3 80 | 4 81 | 5 82 | 6 83 | 7 84 | 0 85 | 86 | Answer: 87 | 4.0 88 | 89 | 90 | Test: 91 | 1 92 | 2 93 | 3 94 | 4 95 | 0 96 | 5 97 | 6 98 | 7 99 | 0 100 | 8 101 | 9 102 | 0 103 | 0 104 | 105 | Answer: 106 | 2.5 107 | 108 | 109 | Test: 110 | 5 111 | 3 112 | 6 113 | 7 114 | 4 115 | 2 116 | 4 117 | 5 118 | 6 119 | 7 120 | 4 121 | 3 122 | 4 123 | 6 124 | 7 125 | 4 126 | 5 127 | 7 128 | 8 129 | 4 130 | 4 131 | 3 132 | 6 133 | 3 134 | 7 135 | 5 136 | 5 137 | 4 138 | 3 139 | 5 140 | 0 141 | 142 | Answer: 143 | 4.86666666667 144 | 145 | 146 | Test: 147 | 1 148 | 0 149 | 2 150 | 0 151 | 3 152 | 0 153 | 154 | Answer: 155 | 1.0 156 | 157 | -------------------------------------------------------------------------------- /problems/while/seq_increasing_neighbours.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of elements that are greater than the previous one 3 | 4 | Statement: 5 | A sequence consists of integer numbers and ends with the number 0. Determine how many elements of this sequence are greater than their neighbours above. 6 | 7 | Test: 8 | 1 9 | 7 10 | 9 11 | 0 12 | 13 | Answer: 14 | 2 15 | 16 | 17 | Test: 18 | 1 19 | 5 20 | 2 21 | 4 22 | 3 23 | 0 24 | 25 | Answer: 26 | 2 27 | 28 | 29 | Test: 30 | 1 31 | 2 32 | 3 33 | 4 34 | 5 35 | 0 36 | 37 | Answer: 38 | 4 39 | 40 | 41 | Test: 42 | 5 43 | 4 44 | 3 45 | 2 46 | 1 47 | 0 48 | 49 | Answer: 50 | 0 51 | 52 | 53 | Test: 54 | 1 55 | 5 56 | 1 57 | 5 58 | 1 59 | 0 60 | 61 | Answer: 62 | 2 63 | 64 | 65 | Test: 66 | 5 67 | 1 68 | 5 69 | 1 70 | 5 71 | 0 72 | 73 | Answer: 74 | 2 75 | 76 | 77 | Test: 78 | 5 79 | 5 80 | 5 81 | 5 82 | 5 83 | 0 84 | 85 | Answer: 86 | 0 87 | 88 | 89 | Test: 90 | 1 91 | 1 92 | 1 93 | 5 94 | 1 95 | 0 96 | 97 | Answer: 98 | 1 99 | 100 | 101 | Test: 102 | 345354 103 | 0 104 | 105 | Answer: 106 | 0 107 | 108 | 109 | Test: 110 | 1 111 | 465 112 | 0 113 | 114 | Answer: 115 | 1 116 | 117 | 118 | Test: 119 | 4 120 | 1 121 | 0 122 | 123 | Answer: 124 | 0 125 | 126 | 127 | Test: 128 | 1 129 | 2 130 | 3 131 | 0 132 | 133 | Answer: 134 | 2 135 | 136 | 137 | Test: 138 | 1 139 | 2 140 | 3 141 | 4 142 | 1 143 | 0 144 | 145 | Answer: 146 | 3 -------------------------------------------------------------------------------- /problems/while/seq_index_of_max.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The index of the maximum of a sequence 3 | 4 | 5 | Statement: 6 | A sequence consists of integer numbers and ends with the number 0. Determine the index of the largest element of the sequence. If the highest element is not unique, print the index of the first of them. 7 | 8 | 9 | Test: 10 | 1 11 | 7 12 | 9 13 | 0 14 | 15 | Answer: 16 | 3 17 | 18 | 19 | Test: 20 | 1 21 | 2 22 | 3 23 | 2 24 | 1 25 | 0 26 | 27 | Answer: 28 | 3 29 | 30 | 31 | Test: 32 | 1 33 | 2 34 | 3 35 | 0 36 | 37 | Answer: 38 | 3 39 | 40 | 41 | Test: 42 | 1 43 | 3 44 | 2 45 | 0 46 | 47 | Answer: 48 | 2 49 | 50 | 51 | Test: 52 | 2 53 | 1 54 | 3 55 | 0 56 | 57 | Answer: 58 | 3 59 | 60 | 61 | Test: 62 | 2 63 | 3 64 | 1 65 | 0 66 | 67 | Answer: 68 | 2 69 | 70 | 71 | Test: 72 | 3 73 | 2 74 | 1 75 | 0 76 | 77 | Answer: 78 | 1 79 | 80 | 81 | Test: 82 | 3 83 | 1 84 | 2 85 | 0 86 | 87 | Answer: 88 | 1 89 | 90 | 91 | Test: 92 | 1 93 | 2 94 | 3 95 | 4 96 | 5 97 | 0 98 | 99 | Answer: 100 | 5 101 | 102 | 103 | Test: 104 | 5 105 | 4 106 | 3 107 | 2 108 | 1 109 | 0 110 | 111 | Answer: 112 | 1 113 | 114 | Test: 115 | 3 116 | 5 117 | 1 118 | 2 119 | 5 120 | 0 121 | 122 | Answer: 123 | 2 124 | 125 | 126 | 127 | Test: 128 | 80 129 | 94 130 | 78 131 | 67 132 | 24 133 | 4 134 | 22 135 | 73 136 | 26 137 | 38 138 | 7 139 | 90 140 | 37 141 | 56 142 | 95 143 | 37 144 | 96 145 | 77 146 | 51 147 | 43 148 | 25 149 | 91 150 | 71 151 | 89 152 | 99 153 | 95 154 | 29 155 | 87 156 | 64 157 | 10 158 | 0 159 | 160 | Answer: 161 | 25 162 | 163 | 164 | -------------------------------------------------------------------------------- /problems/while/seq_len.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The length of the sequence 3 | 4 | 5 | Statement: 6 |

Given a sequence of non-negative integers, where each number is written in a separate line. 7 | Determine the length of the sequence, where the sequence ends when the integer is equal to 0. 8 | Print the length of the sequence (not counting the integer 0). 9 | The numbers following the number 0 should be omitted. 10 | 11 | Test: 12 | 1 13 | 7 14 | 9 15 | 0 16 | 5 17 | 18 | Answer: 19 | 3 20 | 21 | 22 | Test: 23 | 1 24 | 2 25 | 3 26 | 4 27 | 5 28 | 6 29 | 7 30 | 0 31 | 1 32 | 2 33 | 3 34 | 35 | Answer: 36 | 7 37 | 38 | 39 | Test: 40 | 100 41 | 0 42 | 43 | Answer: 44 | 1 45 | 46 | 47 | Test: 48 | 0 49 | 50 | Answer: 51 | 0 52 | 53 | Test: 54 | 5 55 | 2 56 | 8 57 | 0 58 | 1 59 | 4 60 | 4 61 | 3 62 | 2 63 | 0 64 | 5 65 | 0 66 | 0 67 | 68 | 69 | Answer: 70 | 3 71 | -------------------------------------------------------------------------------- /problems/while/seq_max.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The maximum of the sequence 3 | 4 | 5 | Statement: 6 | A sequence consists of integer numbers and ends with the number 0. Determine the largest element of the sequence. 7 | 8 | Test: 9 | 1 10 | 7 11 | 9 12 | 0 13 | 14 | Answer: 15 | 9 16 | 17 | 18 | Test: 19 | 1 20 | 2 21 | 3 22 | 2 23 | 1 24 | 0 25 | 26 | Answer: 27 | 3 28 | 29 | 30 | Test: 31 | 1 32 | 2 33 | 3 34 | 0 35 | 36 | Answer: 37 | 3 38 | 39 | 40 | Test: 41 | 1 42 | 3 43 | 2 44 | 0 45 | 46 | Answer: 47 | 3 48 | 49 | 50 | Test: 51 | 2 52 | 1 53 | 3 54 | 0 55 | 56 | Answer: 57 | 3 58 | 59 | 60 | Test: 61 | 2 62 | 3 63 | 1 64 | 0 65 | 66 | Answer: 67 | 3 68 | 69 | 70 | Test: 71 | 3 72 | 2 73 | 1 74 | 0 75 | 76 | Answer: 77 | 3 78 | 79 | 80 | Test: 81 | 3 82 | 1 83 | 2 84 | 0 85 | 86 | Answer: 87 | 3 88 | 89 | 90 | Test: 91 | 1 92 | 2 93 | 3 94 | 4 95 | 5 96 | 0 97 | 98 | Answer: 99 | 5 100 | 101 | 102 | Test: 103 | 5 104 | 4 105 | 3 106 | 2 107 | 1 108 | 0 109 | 110 | Answer: 111 | 5 112 | 113 | 114 | Test: 115 | 80 116 | 94 117 | 78 118 | 67 119 | 24 120 | 4 121 | 22 122 | 73 123 | 26 124 | 38 125 | 7 126 | 90 127 | 37 128 | 56 129 | 95 130 | 37 131 | 96 132 | 77 133 | 51 134 | 43 135 | 25 136 | 91 137 | 71 138 | 89 139 | 99 140 | 95 141 | 29 142 | 87 143 | 64 144 | 10 145 | 0 146 | 147 | Answer: 148 | 99 149 | 150 | 151 | -------------------------------------------------------------------------------- /problems/while/seq_max_chunk_of_repetitions.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The maximum number of consecutive equal elements 3 | 4 | Statement: 5 | Given a sequence of integer numbers ending with the number 0. Determine the length of the widest fragment where all the elements are equal to each other. 6 | 7 | Test: 8 | 1 9 | 7 10 | 7 11 | 9 12 | 1 13 | 0 14 | 15 | Answer: 16 | 2 17 | 18 | 19 | Test: 20 | 1 21 | 2 22 | 3 23 | 4 24 | 5 25 | 6 26 | 7 27 | 8 28 | 9 29 | 10 30 | 11 31 | 0 32 | 33 | Answer: 34 | 1 35 | 36 | 37 | Test: 38 | 4 39 | 4 40 | 4 41 | 4 42 | 4 43 | 4 44 | 4 45 | 4 46 | 4 47 | 4 48 | 4 49 | 4 50 | 4 51 | 4 52 | 4 53 | 0 54 | 55 | Answer: 56 | 15 57 | 58 | 59 | Test: 60 | 6 61 | 0 62 | 63 | Answer: 64 | 1 65 | 66 | 67 | Test: 68 | 1 69 | 2 70 | 3 71 | 2 72 | 3 73 | 3 74 | 2 75 | 4 76 | 4 77 | 4 78 | 4 79 | 2 80 | 3 81 | 3 82 | 3 83 | 2 84 | 2 85 | 3 86 | 0 87 | 88 | Answer: 89 | 4 90 | 91 | 92 | Test: 93 | 1 94 | 2 95 | 2 96 | 1 97 | 2 98 | 1 99 | 2 100 | 1 101 | 2 102 | 0 103 | 104 | Answer: 105 | 2 106 | 107 | 108 | Test: 109 | 1 110 | 2 111 | 2 112 | 0 113 | 114 | Answer: 115 | 2 116 | 117 | 118 | Test: 119 | 2 120 | 2 121 | 1 122 | 0 123 | 124 | Answer: 125 | 2 126 | 127 | 128 | Test: 129 | 1 130 | 2 131 | 3 132 | 3 133 | 2 134 | 2 135 | 4 136 | 4 137 | 4 138 | 4 139 | 4 140 | 5 141 | 5 142 | 5 143 | 6 144 | 3 145 | 3 146 | 3 147 | 3 148 | 3 149 | 3 150 | 5 151 | 5 152 | 5 153 | 5 154 | 3 155 | 3 156 | 3 157 | 4 158 | 5 159 | 5 160 | 5 161 | 0 162 | 163 | Answer: 164 | 6 165 | 166 | 167 | Test: 168 | 1 169 | 2 170 | 1 171 | 1 172 | 1 173 | 2 174 | 0 175 | 176 | Answer: 177 | 3 178 | 179 | 180 | Test: 181 | 2 182 | 1 183 | 1 184 | 1 185 | 1 186 | 2 187 | 1 188 | 0 189 | 190 | Answer: 191 | 4 192 | -------------------------------------------------------------------------------- /problems/while/seq_num_even.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of even elements of the sequence 3 | 4 | Statement: 5 | Determine the number of even elements in the sequence ending with the number 0. 6 | 7 | Test: 8 | 2 9 | 1 10 | 4 11 | 0 12 | 13 | Answer: 14 | 2 15 | 16 | 17 | Test: 18 | 1 19 | 3 20 | 5 21 | 7 22 | 9 23 | 1 24 | 3 25 | 5 26 | 7 27 | 9 28 | 0 29 | 30 | Answer: 31 | 0 32 | 33 | 34 | Test: 35 | 2 36 | 4 37 | 0 38 | 39 | Answer: 40 | 2 41 | 42 | 43 | Test: 44 | 7883 45 | 0 46 | 47 | Answer: 48 | 0 49 | 50 | 51 | Test: 52 | 0 53 | 54 | Answer: 55 | 0 56 | 57 | 58 | Test: 59 | 1 60 | 2 61 | 3 62 | 4 63 | 5 64 | 6 65 | 7 66 | 0 67 | 68 | Answer: 69 | 3 70 | 71 | 72 | Test: 73 | 1 74 | 2 75 | 3 76 | 4 77 | 0 78 | 5 79 | 6 80 | 7 81 | 0 82 | 8 83 | 9 84 | 0 85 | 0 86 | 87 | Answer: 88 | 2 89 | 90 | 91 | Test: 92 | 5 93 | 3 94 | 6 95 | 7 96 | 4 97 | 2 98 | 4 99 | 5 100 | 6 101 | 7 102 | 4 103 | 3 104 | 4 105 | 6 106 | 7 107 | 4 108 | 5 109 | 7 110 | 8 111 | 4 112 | 4 113 | 3 114 | 6 115 | 3 116 | 7 117 | 5 118 | 5 119 | 4 120 | 3 121 | 5 122 | 0 123 | 124 | Answer: 125 | 14 126 | 127 | 128 | Test: 129 | 1 130 | 0 131 | 2 132 | 0 133 | 3 134 | 0 135 | 136 | Answer: 137 | 0 138 | 139 | 140 | Test: 141 | 88 142 | 69 143 | 61 144 | 66 145 | 16 146 | 39 147 | 56 148 | 97 149 | 57 150 | 84 151 | 13 152 | 84 153 | 63 154 | 26 155 | 68 156 | 50 157 | 34 158 | 68 159 | 67 160 | 33 161 | 88 162 | 89 163 | 8 164 | 35 165 | 77 166 | 22 167 | 57 168 | 43 169 | 12 170 | 92 171 | 55 172 | 45 173 | 64 174 | 86 175 | 37 176 | 65 177 | 89 178 | 10 179 | 83 180 | 21 181 | 78 182 | 19 183 | 62 184 | 28 185 | 79 186 | 48 187 | 54 188 | 7 189 | 51 190 | 30 191 | 57 192 | 43 193 | 13 194 | 24 195 | 91 196 | 99 197 | 97 198 | 10 199 | 9 200 | 25 201 | 60 202 | 37 203 | 76 204 | 33 205 | 11 206 | 43 207 | 79 208 | 39 209 | 8 210 | 95 211 | 61 212 | 52 213 | 6 214 | 15 215 | 42 216 | 5 217 | 26 218 | 83 219 | 51 220 | 41 221 | 70 222 | 48 223 | 100 224 | 13 225 | 49 226 | 20 227 | 39 228 | 7 229 | 70 230 | 75 231 | 3 232 | 29 233 | 62 234 | 47 235 | 47 236 | 99 237 | 8 238 | 73 239 | 1 240 | 78 241 | 0 242 | 243 | Answer: 244 | 42 245 | 246 | 247 | -------------------------------------------------------------------------------- /problems/while/seq_num_maximal.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The number of elements equal to the maximum 3 | 4 | Statement: 5 | A sequence consists of integer numbers and ends with the number 0. Determine how many elements of this sequence are equal to its largest element. 6 | 7 | Test: 8 | 1 9 | 7 10 | 9 11 | 0 12 | 13 | Answer: 14 | 1 15 | 16 | 17 | Test: 18 | 1 19 | 3 20 | 3 21 | 1 22 | 0 23 | 24 | Answer: 25 | 2 26 | 27 | 28 | Test: 29 | 1 30 | 2 31 | 3 32 | 4 33 | 5 34 | 0 35 | 36 | Answer: 37 | 1 38 | 39 | 40 | Test: 41 | 5 42 | 4 43 | 3 44 | 2 45 | 1 46 | 0 47 | 48 | Answer: 49 | 1 50 | 51 | 52 | Test: 53 | 1 54 | 2 55 | 3 56 | 2 57 | 3 58 | 3 59 | 3 60 | 0 61 | 62 | Answer: 63 | 4 64 | 65 | 66 | Test: 67 | 1 68 | 2 69 | 3 70 | 2 71 | 3 72 | 3 73 | 3 74 | 2 75 | 0 76 | 77 | Answer: 78 | 4 79 | 80 | 81 | Test: 82 | 1 83 | 1 84 | 1 85 | 1 86 | 1 87 | 1 88 | 0 89 | 90 | Answer: 91 | 6 92 | 93 | 94 | Test: 95 | 179 96 | 0 97 | 98 | Answer: 99 | 1 100 | 101 | 102 | Test: 103 | 5 104 | 4 105 | 3 106 | 2 107 | 1 108 | 5 109 | 0 110 | 111 | Answer: 112 | 2 113 | 114 | 115 | Test: 116 | 10 117 | 39 118 | 77 119 | 33 120 | 86 121 | 79 122 | 19 123 | 62 124 | 27 125 | 79 126 | 0 127 | 128 | Answer: 129 | 1 130 | 131 | 132 | Test: 133 | 74 134 | 56 135 | 70 136 | 43 137 | 28 138 | 20 139 | 97 140 | 95 141 | 58 142 | 6 143 | 56 144 | 41 145 | 96 146 | 82 147 | 44 148 | 82 149 | 42 150 | 65 151 | 14 152 | 3 153 | 0 154 | 155 | Answer: 156 | 1 157 | 158 | 159 | Test: 160 | 78 161 | 25 162 | 67 163 | 79 164 | 50 165 | 60 166 | 18 167 | 84 168 | 2 169 | 64 170 | 98 171 | 42 172 | 41 173 | 20 174 | 63 175 | 65 176 | 64 177 | 53 178 | 62 179 | 62 180 | 71 181 | 93 182 | 7 183 | 86 184 | 97 185 | 90 186 | 2 187 | 2 188 | 45 189 | 58 190 | 0 191 | 192 | Answer: 193 | 1 194 | 195 | Test: 196 | 5 197 | 3 198 | 3 199 | 5 200 | 7 201 | 3 202 | 1 203 | 7 204 | 4 205 | 7 206 | 7 207 | 7 208 | 2 209 | 9 210 | 1 211 | 7 212 | 5 213 | 9 214 | 8 215 | 8 216 | 8 217 | 8 218 | 0 219 | 220 | Answer: 221 | 2 222 | 223 | 224 | -------------------------------------------------------------------------------- /problems/while/seq_second_max.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The second maximum 3 | 4 | Statement: 5 | The sequence consists of distinct positive integer numbers and ends with the number 0. Determine the value of the second largest element in this sequence. It is guaranteed that the sequence has at least two elements. 6 | 7 | Test: 8 | 1 9 | 7 10 | 9 11 | 0 12 | 13 | Answer: 14 | 7 15 | 16 | 17 | Test: 18 | 2 19 | 1 20 | 0 21 | 22 | Answer: 23 | 1 24 | 25 | 26 | Test: 27 | 1 28 | 2 29 | 0 30 | 31 | Answer: 32 | 1 33 | 34 | 35 | Test: 36 | 1 37 | 2 38 | 3 39 | 0 40 | 41 | Answer: 42 | 2 43 | 44 | 45 | Test: 46 | 1 47 | 3 48 | 2 49 | 0 50 | 51 | Answer: 52 | 2 53 | 54 | 55 | Test: 56 | 2 57 | 3 58 | 1 59 | 0 60 | 61 | Answer: 62 | 2 63 | 64 | 65 | Test: 66 | 2 67 | 1 68 | 3 69 | 0 70 | 71 | Answer: 72 | 2 73 | 74 | 75 | Test: 76 | 3 77 | 1 78 | 2 79 | 0 80 | 81 | Answer: 82 | 2 83 | 84 | 85 | Test: 86 | 3 87 | 2 88 | 1 89 | 0 90 | 91 | Answer: 92 | 2 93 | 94 | 95 | Test: 96 | 1 97 | 4 98 | 2 99 | 3 100 | 0 101 | 102 | Answer: 103 | 3 104 | 105 | 106 | Test: 107 | 1 108 | 4 109 | 3 110 | 2 111 | 0 112 | 113 | Answer: 114 | 3 115 | 116 | 117 | Test: 118 | 4 119 | 1 120 | 2 121 | 3 122 | 0 123 | 124 | Answer: 125 | 3 126 | 127 | 128 | Test: 129 | 4 130 | 1 131 | 3 132 | 2 133 | 0 134 | 135 | Answer: 136 | 3 137 | 138 | 139 | Test: 140 | 10 141 | 1 142 | 2 143 | 3 144 | 4 145 | 5 146 | 6 147 | 7 148 | 8 149 | 9 150 | 0 151 | 152 | Answer: 153 | 9 154 | 155 | 156 | Test: 157 | 1 158 | 9 159 | 2 160 | 3 161 | 4 162 | 5 163 | 6 164 | 7 165 | 8 166 | 10 167 | 0 168 | 169 | Answer: 170 | 9 171 | 172 | 173 | Test: 174 | 9 175 | 1 176 | 2 177 | 3 178 | 4 179 | 5 180 | 6 181 | 7 182 | 8 183 | 10 184 | 0 185 | 186 | Answer: 187 | 9 188 | 189 | 190 | Test: 191 | 9 192 | 10 193 | 8 194 | 7 195 | 6 196 | 5 197 | 4 198 | 3 199 | 2 200 | 1 201 | 0 202 | 203 | Answer: 204 | 9 205 | 206 | 207 | Test: 208 | 10 209 | 9 210 | 8 211 | 7 212 | 6 213 | 5 214 | 4 215 | 3 216 | 2 217 | 1 218 | 0 219 | 220 | Answer: 221 | 9 222 | 223 | 224 | Test: 225 | 1 226 | 2 227 | 3 228 | 4 229 | 5 230 | 6 231 | 7 232 | 8 233 | 9 234 | 10 235 | 0 236 | 237 | Answer: 238 | 9 239 | 240 | 241 | Test: 242 | 2 243 | 1 244 | 4 245 | 3 246 | 0 247 | 248 | Answer: 249 | 3 250 | 251 | 252 | Test: 253 | 2 254 | 1 255 | 3 256 | 4 257 | 0 258 | 259 | Answer: 260 | 3 261 | 262 | 263 | Test: 264 | 1 265 | 2 266 | 3 267 | 4 268 | 0 269 | 270 | Answer: 271 | 3 272 | 273 | 274 | Test: 275 | 1 276 | 2 277 | 4 278 | 3 279 | 0 280 | 281 | Answer: 282 | 3 283 | 284 | 285 | Test: 286 | 3 287 | 1 288 | 4 289 | 2 290 | 0 291 | 292 | Answer: 293 | 3 294 | 295 | 296 | Test: 297 | 3 298 | 1 299 | 2 300 | 4 301 | 0 302 | 303 | Answer: 304 | 3 305 | -------------------------------------------------------------------------------- /problems/while/seq_sum.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | The sum of the sequence 3 | 4 | Statement: 5 | Determine the sum of all elements in the sequence, ending with the number 0. 6 | 7 | 8 | Test: 9 | 1 10 | 7 11 | 9 12 | 0 13 | 14 | Answer: 15 | 17 16 | 17 | 18 | Test: 19 | 1 20 | 1 21 | 1 22 | 1 23 | 1 24 | 1 25 | 1 26 | 1 27 | 1 28 | 0 29 | 30 | Answer: 31 | 9 32 | 33 | 34 | Test: 35 | 34 36 | 2345 37 | 2345 38 | 2345 39 | 2345 40 | 345 41 | 3 42 | 345 43 | 3 44 | 345 45 | 1 46 | 3 47 | 424 48 | 5 49 | 453 50 | 0 51 | 52 | Answer: 53 | 11341 54 | 55 | 56 | Test: 57 | 7883 58 | 0 59 | 60 | Answer: 61 | 7883 62 | 63 | 64 | Test: 65 | 0 66 | 67 | Answer: 68 | 0 69 | 70 | 71 | Test: 72 | 1 73 | 2 74 | 3 75 | 4 76 | 5 77 | 6 78 | 7 79 | 0 80 | 81 | Answer: 82 | 28 83 | 84 | 85 | Test: 86 | 1 87 | 2 88 | 3 89 | 4 90 | 0 91 | 92 | Answer: 93 | 10 94 | 95 | 96 | Test: 97 | 0 98 | 99 | 100 | Answer: 101 | 0 102 | 103 | 104 | Test: 105 | 1 106 | 0 107 | 108 | Answer: 109 | 1 110 | 111 | 112 | -------------------------------------------------------------------------------- /problems/while/std_dev.txt: -------------------------------------------------------------------------------- 1 | Name: 2 | Стандартное отклонение 3 | 4 | Statement: 5 |

Дана последовательность натуральных чисел \(x_1\), \(x_2\), ..., \(x_n\). 6 | Стандартным отклонением называется величина 7 | \[ 8 | \sigma = \sqrt{\frac{(x_1-s)^2+(x_2-s)^2+\ldots+(x_n-s)^2}{n-1}} 9 | \] 10 | где \(s=\frac{x_1+x_2+\ldots+x_n}{n}\) — среднее арифметическое последовательности.

11 | 12 |

Определите стандартное отклонение для данной последовательности натуральных чисел, 13 | завершающейся числом 0.

14 | 15 | 16 | Test: 17 | 1 18 | 7 19 | 9 20 | 0 21 | 22 | Answer: 23 | 4.16333199893 24 | 25 | 26 | Test: 27 | 1 28 | 2 29 | 3 30 | 0 31 | 32 | Answer: 33 | 1.0 34 | 35 | 36 | Test: 37 | 1 38 | 1 39 | 1 40 | 1 41 | 1 42 | 1 43 | 1 44 | 1 45 | 1 46 | 1 47 | 0 48 | 49 | Answer: 50 | 0.0 51 | 52 | 53 | Test: 54 | 3 55 | 9 56 | 5 57 | 2 58 | 0 59 | 60 | Answer: 61 | 3.09569593683 62 | 63 | 64 | Test: 65 | 10 66 | 1 67 | 1 68 | 1 69 | 1 70 | 1 71 | 0 72 | 73 | Answer: 74 | 3.67423461417 75 | 76 | 77 | Test: 78 | 58 79 | 12 80 | 51 81 | 27 82 | 79 83 | 5 84 | 44 85 | 9 86 | 86 87 | 13 88 | 0 89 | 90 | Answer: 91 | 29.7029740374 92 | 93 | 94 | Test: 95 | 51 96 | 86 97 | 7 98 | 2 99 | 75 100 | 64 101 | 23 102 | 3 103 | 25 104 | 34 105 | 62 106 | 93 107 | 41 108 | 15 109 | 96 110 | 62 111 | 58 112 | 41 113 | 43 114 | 89 115 | 0 116 | 117 | Answer: 118 | 30.1914940967 119 | --------------------------------------------------------------------------------