Winter Code Clash- Problem Set
Winter Code Clash- Problem Set
Roman numerals are usually written from largest to smallest from left to right. However, in
certain cases, subtraction is used to represent numbers. For example:
● IV = 4 (5 - 1)
● IX = 9 (10 - 1)
● XL = 40 (50 - 10)
● XC = 90 (100 - 10)
● CD = 400 (500 - 100)
● CM = 900 (1000 - 100)
Input:
● A Roman numeral string s (1 ≤ length of s ≤ 15), consisting of the symbols 'I', 'V', 'X', 'L',
'C', 'D', 'M'.
Output:
● The integer value of the given Roman numeral.
Example:
Input Output Explanation
III 3 III = 1 + 1 + 1 = 3
2. Game Selection
Four friends decide to play some games. They will play a game if at least three of them agree to
it. You are given the opinions of the four friends for mmm games. Your task is to count how
many games they will play.
Input:
● The first line contains an integer mmm (1≤m≤10001 \leq m \leq 10001≤m≤1000) — the
number of games.
● The next mmm lines contain four integers (0 or 1) separated by spaces. Each number
represents a friend’s agreement (1 = agrees, 0 = disagrees).
Output:
● Print the number of games they will play.
Example:
Input Output
3 2
1 1 1 0
1 1 0 0
1111
3. Valid Parentheses
Given a string S containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input
string is valid. A string is considered valid if:
Output:
● Print true if the input string is valid, otherwise, print false.
Constraints:
Example:
Input Output
() true
()[]{} true
(] false
([]) true
4. Username Mood
In a gaming community, usernames often reveal the mood of the player. The mood is
determined by counting the number of distinct letters in their username:
● If the number of distinct letters is even, the mood is "HAPPY!".
● If the number of distinct letters is odd, the mood is "ANGRY!".
Input:
● A single line containing a username — a non-empty string of lowercase English letters (at
most 100 characters).
Output:
● Print "HAPPY!" if the number of distinct letters is even.
● Print "ANGRY!" if the number of distinct letters is odd.
Example:
Input Output
gamerzone HAPPY!
proplayer ANGRY!
Write a program that takes a string as input and returns the string in reverse order.
Input:
● A string s of length n (1 ≤ n ≤ 1000), consisting of lowercase Latin letters and/or spaces.
Output:
● The string S reversed.
Example:
Input Output
hello olleh
world dlrow
Constraints:
● The length of the string S is at least 1 and at most 1000.
● The string may contain spaces between characters.
Input:
● The first line contains an even integer 𝑛 (2≤𝑛≤50) — the length of the number.
● The second line contains an n-digit number (it may have leading zeros).
Output:
● Print "YES" if the number is a balanced lucky number.
● Otherwise, print "NO".
Examples:
4 YES The number is lucky, and the sum of the first half 4+4=84 + 4 =
4477 84+4=8 equals the sum of the second half 7+7=87 + 7 = 87+7=8. So,
the number is balanced.
7. Divisor Words
Given a number 𝑁 (1 𝑡ℎ𝑟𝑜𝑢𝑔ℎ 1000), print:
● "Alpha" if the number is divisible by 4,
● "Beta" if the number is divisible by 6,
● "AlphaBeta" if the number is divisible by both 4 and 6.
● If none of these conditions are true, print nothing.
Input:
A single line contains a positive integer 𝑁 (1≤𝑁≤1000).
Output:
Print "Alpha", "Beta", "AlphaBeta", or nothing, depending on the conditions.
Examples:
Input Output
8 Alpha
18 Beta
24 AlphaBeta
7
8. Remove Duplicate Numbers from an Array
In a small town, a local store sells a variety of numbered items, and each item is uniquely
identified by a number. One day, the store owner noticed that some of the items were repeated
in the inventory list, making it difficult to track how many unique items they had in stock.
The store owner asked for your help to organize the inventory by removing duplicate items. Your
task is to take the inventory list and return a new list that contains only the unique items,
maintaining the order in which they first appeared.
Input:
You are given an array of integers representing the inventory list. Some items might be repeated.
Output:
A new list containing only the unique integers from the original list, preserving the order of their
first occurrence.
Example:
1. Input: [1, 2, 3, 1, 2, 3, 4, 5, 5, 7, 3, 4]
Output: [1, 2, 3, 4, 5, 7]
2. Input: [10, 20, 20, 10, 30]
Output: [10, 20, 30]
3. Input: [1, 1, 1, 1, 1]
Output: [1]
9. Odd or Even
In a small village, there is a tradition where people gather around and play a number game every
evening. The villagers take turns picking a number, and everyone needs to determine whether
the number is odd or even. The village elder, who loves puzzles, has asked you to help with the
game.
Your task is simple: given a number, you need to determine whether it is odd or even.
Input:
● A single integer, N, is provided.
Output:
● Print "Odd" if the number is odd, and "Even" if the number is even.
Example:
1. Input: 5
Output: Odd
2. Input: 10
Output: Even
3. Input: 7
Output: Odd
Input:
1. The first line contains an integer K, the total number of test cases.
2. The next K lines each contain an integer M.
Output:
For each test case, output the given string or "-1", each on a new line.
Constraints:
● 1≤𝐾≤1000
● − 50≤𝑀≤50
Example:
Input Output
4 Happy Farmer!
5 -1
-3 Happy Farmer!
0 Happy Farmer!
10
Your task is to swap the two given numbers and print them in the new order.
Input:
● Two integers, a and b, are provided.
Output:
● Print the two integers, b and a, in the swapped order.
Example:
1. Input: 5 10
Output: 10 5
2. Input: 2 7
Output: 7 2
Constraints:
● The length of 𝐶 = 1.
● S consists of lower and upper case letters, digits, and spaces.
● S may span multiple lines, and the input ends with "END_OF_TEXT".
Input:
● The first line contains the character C.
● The following lines contain the text S, ending with "END_OF_TEXT".
Output:
Print the count of C in the text S.
Example:
Input Output
e 8
Everyone excels in execution
Endurance, effort, and excellence
END_OF_TEXT
Your task is to help the mathematician solve this puzzle by counting the divisors of c that lie
between a and b.
Input:
Three integers a, b, and c are given in a single line, separated by spaces.
Output:
Print the number of divisors of c that lie in the range from a to b (inclusive).
Constraints:
● 1≤𝑎, 𝑏, 𝑐≤10000
● 𝑎≤𝑏
Example:
Input:
Two floating-point numbers x and y , separated by a space, are given in a single line.
Output:
For the given two floating-point numbers x and y , print:
● 𝑥 < 𝑦: 𝐼𝑓 𝑥 𝑖𝑠 𝑙𝑒𝑠𝑠 𝑡ℎ𝑎𝑛 𝑦.
● 𝑥 > 𝑦: 𝐼𝑓 𝑥 𝑖𝑠 𝑔𝑟𝑒𝑎𝑡𝑒𝑟 𝑡ℎ𝑎𝑛 𝑦.
● 𝑥 == 𝑦: 𝐼𝑓 𝑥 𝑒𝑞𝑢𝑎𝑙𝑠 𝑦 (𝑢𝑝 𝑡𝑜 𝑠𝑖𝑥 𝑑𝑒𝑐𝑖𝑚𝑎𝑙 𝑝𝑙𝑎𝑐𝑒𝑠).
Constraints:
● − 106≤𝑥, 𝑦≤106.
● The values of x and y are given with at most six decimal places.
Example:
Input Output
3.14159 x == y
3.14159
Input:
● The first and only line contains the word s, which Vasya typed. This word consists of
small Latin letters, its length is no less than 1 and no more than 100 letters.
Output:
● If Vasya managed to say "world", print "YES", otherwise print "NO".
Example:
The operator op can be one of these: '+', '-', '*', '/', '^', '%'. The operators represent:
Input:
● The input consists of multiple datasets. Each dataset follows the format: x op y
● The input ends with a dataset where the operator 𝑜𝑝 = ′? ′. Your program should stop
processing when it encounters this dataset.
Output:
For each dataset, output the result of the operation on a new line.
Constraints:
● 0≤𝑥, 𝑦≤10000
● No divisions by zero will be given.
Example :
Input Output
5+7 12
10 - 3 7
3*4 12
15 / 3 5
2^3 8
8%3 2
7?7
Output:
Print the time in the format days:hours:minutes:seconds. Each value should be printed with no
leading zeroes, and the values should be separated by colons.
Constraints:
● 0≤𝑆≤315360000 (𝑇ℎ𝑒 𝑚𝑎𝑥𝑖𝑚𝑢𝑚 𝑣𝑎𝑙𝑢𝑒 𝑜𝑓 𝑆𝑆𝑆 𝑟𝑒𝑝𝑟𝑒𝑠𝑒𝑛𝑡𝑠 10, 000 𝑦𝑒𝑎𝑟𝑠).
Example:
Input Output
100000 1:3:46:40
3600 0:1:0:0
The farmer wonders how many sheep in total were affected after counting d sheep.
Input:
● Five integers: k, l, m, n, and d, each on a separate line.
○ k, l, m, n are the frequencies of each event.
○ d is the total number of sheep.
Output:
● Output the number of sheep that were affected in any way.
Example:
2 17 The farmer affects sheep based on every 2nd, 3rd, 4th, and 5th sheep,
3 and after removing duplicates, 17 sheep were affected.
4
5
24
19. Find Minimum, Maximum, and Check if All Numbers Are Equal
Vasya is learning about numbers and wants to practice finding the smallest and largest numbers
in a list. He also wants to check if all the numbers in a given list are equal. Help him with these
tasks!
Task:
Input:
● A list of integers (length of the list will be between 1 and 100).
Output:
● First, print the minimum value from the list.
● Then, print the maximum value from the list.
● Finally, print "YES" if all numbers are the same, otherwise print "NO".
Example:
1. Input : 4 5 2 8 3
Output: 2 8 NO
Explanation:
○ The minimum value is 2 and the maximum value is 8.
○ The numbers are not all equal, so the output is "NO".
2. Input: 7 7 7 7
Output 2:7 7 YES
Explanation:
○ The minimum and maximum values are both 7.
○ All numbers are the same, so the output is "YES".
Constraints:
● The list will contain at least 1 number.
● The numbers are all integers between 1 and 100, inclusive.
Input:
● A single string sss consisting of lowercase Latin letters.
● The length of the string is at most 100.
Output:
● Print "YES" if the string is a palindrome.
● Otherwise, print "NO".
Constraints:
● The string contains only lowercase Latin letters.
● The length of the string does not exceed 100 characters.
Example:
Input Output
madam YES
hello NO
Happy Coding!
There are a set of 20 practice problems. The contest will feature 10 questions from here,
similar in type but not identical to the practice set. If you solve these practice problems
properly, you’ll have a strong advantage in the competition.