question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing One Card Poker.
One Card Poker is a two-player game using playing cards.
Each card in this game shows an integer between 1 and 13, inclusive.
The strength of a card is determined by the number written on it, as follows:
W... |
Solve the programming task below in a Python markdown code block.
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two num... |
Solve the programming task below in a Python markdown code block.
Write a function that returns a sequence (index begins with 1) of all the even characters from a string. If the string is smaller than two characters or longer than 100 characters, the function should return "invalid string".
For example:
`````
"abcde... |
Solve the programming task below in a Python markdown code block.
B: Parentheses Number
problem
Define the correct parenthesis string as follows:
* The empty string is the correct parenthesis string
* For the correct parenthesis string S, `(` S `)` is the correct parenthesis string
* For correct parentheses S, T ST... |
Solve the programming task below in a Python markdown code block.
You are given an array $a_1, a_2, \dots, a_n$ of integer numbers.
Your task is to divide the array into the maximum number of segments in such a way that:
each element is contained in exactly one segment; each segment contains at least one element;... |
Solve the programming task below in a Python markdown code block.
Snuke and Ciel went to a strange stationery store. Each of them got a transparent graph paper with H rows and W columns.
Snuke painted some of the cells red in his paper. Here, the cells painted red were 4-connected, that is, it was possible to travers... |
Solve the programming task below in a Python markdown code block.
Given an integer $n$, find the maximum value of integer $k$ such that the following condition holds:
$n$ & ($n-1$) & ($n-2$) & ($n-3$) & ... ($k$) = $0$
where & denotes the bitwise AND operation.
-----Input-----
The first line contains a single inte... |
Solve the programming task below in a Python markdown code block.
Alice got an array of length $n$ as a birthday present once again! This is the third year in a row!
And what is more disappointing, it is overwhelmengly boring, filled entirely with zeros. Bob decided to apply some changes to the array to cheer up Ali... |
Solve the programming task below in a Python markdown code block.
Imagine that you are given two sticks. You want to end up with three sticks of equal length. You are allowed to cut either or both of the sticks to accomplish this, and can throw away leftover pieces.
Write a function, maxlen, that takes the lengths of... |
Solve the programming task below in a Python markdown code block.
Given an array containing only zeros and ones, find the index of the zero that, if converted to one, will make the longest sequence of ones.
For instance, given the array:
```
[1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1]
```
replacing th... |
Solve the programming task below in a Python markdown code block.
Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right); ... |
Solve the programming task below in a Python markdown code block.
Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.
Ivar has $n$ warriors, he places them on a straight line in front of the main gate, in a w... |
Solve the programming task below in a Python markdown code block.
Cheaterius is a famous in all the Berland astrologist, magician and wizard, and he also is a liar and a cheater. One of his latest inventions is Cheaterius' amulets! They bring luck and wealth, but are rather expensive. Cheaterius makes them himself. Th... |
Solve the programming task below in a Python markdown code block.
It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Now you are suggested to solve the following problem: given a year number, find the minimum... |
Solve the programming task below in a Python markdown code block.
Deadpool wants to decorate his girlfriend’s house with a series of bulbs. The number of bulbs is M. Initially, all the bulbs are switched off. Deadpool finds that there are K numbers of buttons, each of them is connected to a set of bulbs. Deadpool can... |
Solve the programming task below in a Python markdown code block.
We have an analog clock whose three hands (the second hand, the minute hand and the hour hand) rotate quite smoothly. You can measure two angles between the second hand and two other hands.
Write a program to find the time at which "No two hands overla... |
Solve the programming task below in a Python markdown code block.
Recently you've discovered a new shooter. They say it has realistic game mechanics.
Your character has a gun with magazine size equal to $k$ and should exterminate $n$ waves of monsters. The $i$-th wave consists of $a_i$ monsters and happens from the $... |
Solve the programming task below in a Python markdown code block.
B: 階層的計算機 (Hierarchical Calculator)
Problem
Ebi-chan has N formulae: y = a_i x for i =1, ..., N (inclusive). Now she considers a subsequence of indices with length k: s_1, s_2, ..., s_k. At first, let x_0 be 1 and evaluate s_1-th formulae with x = x_0... |
Solve the programming task below in a Python markdown code block.
If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print -1.
- The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros ar... |
Solve the programming task below in a Python markdown code block.
Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or... |
Solve the programming task below in a Python markdown code block.
Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b dots on the other half. The set contains exactly 21 dominoes.... |
Solve the programming task below in a Python markdown code block.
Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits x and y. For example, if x = 4, and y = 7, then numbers 47, 744, 4 are lucky.
... |
Solve the programming task below in a Python markdown code block.
Suppose we have a sequence of non-negative integers, Namely a_1, a_2, ... ,a_n. At each time we can choose one term a_i with 0 < i < n and we subtract 1 from both a_i and a_i+1. We wonder whether we can get a sequence of all zeros after several operatio... |
Solve the programming task below in a Python markdown code block.
The aim of the kata is to decompose `n!` (factorial n) into its prime factors.
Examples:
```
n = 12; decomp(12) -> "2^10 * 3^5 * 5^2 * 7 * 11"
since 12! is divisible by 2 ten times, by 3 five times, by 5 two times and by 7 and 11 only once.
n = 22; de... |
Solve the programming task below in a Python markdown code block.
After learning a lot about space exploration, a little girl named Ana wants to change the subject.
Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's... |
Solve the programming task below in a Python markdown code block.
In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statu... |
Solve the programming task below in a Python markdown code block.
++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+
++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>+++++++
+++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>.<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<
<<<<<>>>>>>>>>>>>>+.-<... |
Solve the programming task below in a Python markdown code block.
Inna likes sweets and a game called the "Candy Matrix". Today, she came up with the new game "Candy Matrix 2: Reload".
The field for the new game is a rectangle table of size n × m. Each line of the table contains one cell with a dwarf figurine, one ce... |
Solve the programming task below in a Python markdown code block.
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without... |
Solve the programming task below in a Python markdown code block.
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the abso... |
Solve the programming task below in a Python markdown code block.
Consider the infinite sequence $s$ of positive integers, created by repeating the following steps:
Find the lexicographically smallest triple of positive integers $(a, b, c)$ such that $a \oplus b \oplus c = 0$, where $\oplus$ denotes the bitwise X... |
Solve the programming task below in a Python markdown code block.
Given an array of N elements, check if it is possible to obtain a sum of S, by choosing some (or none) elements of the array and adding them.
Input:
First line of the input contains number of test cases T. Each test case has three lines.
First line has... |
Solve the programming task below in a Python markdown code block.
Given is a permutation P of \{1, 2, \ldots, N\}.
For a pair (L, R) (1 \le L \lt R \le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \ldots, P_R.
Find \displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} X_{L,R}.
-----Constraints-----
- ... |
Solve the programming task below in a Python markdown code block.
You are provided with array of positive non-zero ints and int n representing n-th power (n >= 2).
For the given array, calculate the sum of each value to the n-th power. Then subtract the sum of the original array.
Example 1: Input: {1, 2, 3}, 3 --> (... |
Solve the programming task below in a Python markdown code block.
Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure below. [Im... |
Solve the programming task below in a Python markdown code block.
You are given an angle $\text{ang}$.
The Jury asks You to find such regular $n$-gon (regular polygon with $n$ vertices) that it has three vertices $a$, $b$ and $c$ (they can be non-consecutive) with $\angle{abc} = \text{ang}$ or report that there is n... |
Solve the programming task below in a Python markdown code block.
You are given a string $s$ of even length $n$. String $s$ is binary, in other words, consists only of 0's and 1's.
String $s$ has exactly $\frac{n}{2}$ zeroes and $\frac{n}{2}$ ones ($n$ is even).
In one operation you can reverse any substring of $s$.... |
Solve the programming task below in a Python markdown code block.
You are given two positive integers A and B. Compare the magnitudes of these numbers.
-----Constraints-----
- 1 ≤ A, B ≤ 10^{100}
- Neither A nor B begins with a 0.
-----Input-----
Input is given from Standard Input in the following format:
A
B
---... |
Solve the programming task below in a Python markdown code block.
Create a function that finds the [integral](https://en.wikipedia.org/wiki/Integral) of the expression passed.
In order to find the integral all you need to do is add one to the `exponent` (the second argument), and divide the `coefficient` (the first a... |
Solve the programming task below in a Python markdown code block.
Create a function that takes a number as an argument and returns a grade based on that number.
Score | Grade
-----------------------------------------|-----
Anything greater than 1 or less than 0.6 | "F"
0.9 or greate... |
Solve the programming task below in a Python markdown code block.
It's a very unfortunate day for Volodya today. He got bad mark in algebra and was therefore forced to do some work in the kitchen, namely to cook borscht (traditional Russian soup). This should also improve his algebra skills.
According to the borscht ... |
Solve the programming task below in a Python markdown code block.
Jeff got 2n real numbers a_1, a_2, ..., a_2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose index... |
Solve the programming task below in a Python markdown code block.
"The zombies are lurking outside. Waiting. Moaning. And when they come..."
"When they come?"
"I hope the Wall is high enough."
Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. In p... |
Solve the programming task below in a Python markdown code block.
Complete the function that returns an array of length `n`, starting with the given number `x` and the squares of the previous number. If `n` is negative or zero, return an empty array/list.
## Examples
```
2, 5 --> [2, 4, 16, 256, 65536]
3, 3 --> ... |
Solve the programming task below in a Python markdown code block.
Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut o... |
Solve the programming task below in a Python markdown code block.
Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some o... |
Solve the programming task below in a Python markdown code block.
The Central Company has an office with a sophisticated security system. There are $10^6$ employees, numbered from $1$ to $10^6$.
The security system logs entrances and departures. The entrance of the $i$-th employee is denoted by the integer $i$, while... |
Solve the programming task below in a Python markdown code block.
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers.
You can assume that a word consists of at most 30 characters, and the page number is less than... |
Solve the programming task below in a Python markdown code block.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. [Image]
Barney asked the bar tender Carl about this distance va... |
Solve the programming task below in a Python markdown code block.
There is a square of size $10^6 \times 10^6$ on the coordinate plane with four points $(0, 0)$, $(0, 10^6)$, $(10^6, 0)$, and $(10^6, 10^6)$ as its vertices.
You are going to draw segments on the plane. All segments are either horizontal or vertical an... |
Solve the programming task below in a Python markdown code block.
Kurohashi has never participated in AtCoder Beginner Contest (ABC).
The next ABC to be held is ABC N (the N-th ABC ever held).
Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.
What is the earliest A... |
Solve the programming task below in a Python markdown code block.
You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.
A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this s... |
Solve the programming task below in a Python markdown code block.
Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, ... |
Solve the programming task below in a Python markdown code block.
One tradition of welcoming the New Year is launching fireworks into the sky. Usually a launched firework flies vertically upward for some period of time, then explodes, splitting into several parts flying in different directions. Sometimes those parts a... |
Solve the programming task below in a Python markdown code block.
### Task:
You have to write a function `pattern` which creates the following pattern (See Examples) upto desired number of rows.
If the Argument is `0` or a Negative Integer then it should return `""` i.e. empty string.
### Examples:
`pattern(9)`:
... |
Solve the programming task below in a Python markdown code block.
The new "Avengers" movie has just been released! There are a lot of people at the cinema box office standing in a huge line. Each of them has a single `100`, `50` or `25` dollar bill. An "Avengers" ticket costs `25 dollars`.
Vasya is currently working ... |
Solve the programming task below in a Python markdown code block.
Flash has invited his nemesis The Turtle (He actually was a real villain! ) to play his favourite card game, SNAP. In this game a 52 card deck is dealt out so both Flash and the Turtle get 26 random cards.
Each players cards will be represented by an ... |
Solve the programming task below in a Python markdown code block.
$n$ players are playing a game.
There are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same... |
Solve the programming task below in a Python markdown code block.
Snuke loves working out. He is now exercising N times.
Before he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.
Find Snuke's power after he exercises N times. Since the answer can be extremely la... |
Solve the programming task below in a Python markdown code block.
Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor $x$, Egor on the floor $y$ (not on the same fl... |
Solve the programming task below in a Python markdown code block.
Lunar New Year is approaching, and Bob is struggling with his homework – a number division problem.
There are $n$ positive integers $a_1, a_2, \ldots, a_n$ on Bob's homework paper, where $n$ is always an even number. Bob is asked to divide those number... |
Solve the programming task below in a Python markdown code block.
Mr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to count the time he has wasted signing... |
Solve the programming task below in a Python markdown code block.
Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: the Euclidean distance between A and B is one ... |
Solve the programming task below in a Python markdown code block.
Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.
The game is played on the following field. [Image]
Players are making moves by t... |
Solve the programming task below in a Python markdown code block.
Given a string `S` and a character `C`, return an array of integers representing the shortest distance from the current character in `S` to `C`.
### Notes
* All letters will be lowercase.
* If the string is empty, return an empty array.
* If the chara... |
Solve the programming task below in a Python markdown code block.
In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a ... |
Solve the programming task below in a Python markdown code block.
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.
The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we... |
Solve the programming task below in a Python markdown code block.
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.
She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possib... |
Solve the programming task below in a Python markdown code block.
Everyone knows that long ago on the territory of present-day Berland there lived Bindian tribes. Their capital was surrounded by n hills, forming a circle. On each hill there was a watchman, who watched the neighbourhood day and night.
In case of any d... |
Solve the programming task below in a Python markdown code block.
Tanya wants to go on a journey across the cities of Berland. There are n cities situated along the main railroad line of Berland, and these cities are numbered from 1 to n.
Tanya plans her journey as follows. First of all, she will choose some city c_... |
Solve the programming task below in a Python markdown code block.
problem
JOI Pizza sells pizza home delivery along the d-meter-long ring road that runs through the city center.
JOI Pizza has n stores S1, ..., Sn on the loop line. The head office is S1. The distance from S1 to Si when moving the loop line clockwise ... |
Solve the programming task below in a Python markdown code block.
This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.
Array a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly $\frac{n}{k}$ tim... |
Solve the programming task below in a Python markdown code block.
N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.
Tak the traveler has the following two personal principles:
- He never travels a distance of more than L in a single day.
- He never sleeps in the open... |
Solve the programming task below in a Python markdown code block.
PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of $6$ slices, medium ones consist of $8$ slices, and large pizzas consist of $10$ slices each. Baking them takes $15$, $20$ and $25$ minut... |
Solve the programming task below in a Python markdown code block.
Chef and his girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed one by one. Before walking Chef and his girlfriend stay at the beginning of the first segment, they want to achieve the end... |
Solve the programming task below in a Python markdown code block.
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many... |
Solve the programming task below in a Python markdown code block.
-----Input-----
The input contains a single integer a (10 ≤ a ≤ 999).
-----Output-----
Output 0 or 1.
-----Examples-----
Input
13
Output
1
Input
927
Output
1
Input
48
Output
0
Read the inputs from stdin solve the problem and write the answe... |
Solve the programming task below in a Python markdown code block.
In the board game Talisman, when two players enter combat the outcome is decided by a combat score, equal to the players power plus any modifiers plus the roll of a standard 1-6 dice. The player with the highest combat score wins and the opposing player... |
Solve the programming task below in a Python markdown code block.
No Story
No Description
Only by Thinking and Testing
Look at the results of the testcases, and guess the code!
---
## Series:
01. [A and B?](http://www.codewars.com/kata/56d904db9963e9cf5000037d)
02. [Incomplete string](http://www.codewars.com/kat... |
Solve the programming task below in a Python markdown code block.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex $1$, in which every leaf (excluding root) is an input,... |
Solve the programming task below in a Python markdown code block.
Given an array of integers, find the one that appears an odd number of times.
There will always be only one integer that appears an odd number of times.
Write your solution by modifying this code:
```python
def find_it(seq):
```
Your solution shou... |
Solve the programming task below in a Python markdown code block.
It is known that passages in Singer house are complex and intertwined. Let's define a Singer k-house as a graph built by the following process: take complete binary tree of height k and add edges from each vertex to all its successors, if they are not y... |
Solve the programming task below in a Python markdown code block.
This morning, Roman woke up and opened the browser with $n$ opened tabs numbered from $1$ to $n$. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too many ta... |
Solve the programming task below in a Python markdown code block.
One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been recently resolved. It turns out that the reason is not (as ... |
Solve the programming task below in a Python markdown code block.
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.
As for you, you're just a simple peasant. There's no sur... |
Solve the programming task below in a Python markdown code block.
Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to use the Amidakuji to improve luck by gaining the ability to read the future. Of course, not only ... |
Solve the programming task below in a Python markdown code block.
New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People want... |
Solve the programming task below in a Python markdown code block.
Students love to celebrate their holidays. Especially if the holiday is the day of the end of exams!
Despite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to go to a cafe so that each of them... |
Solve the programming task below in a Python markdown code block.
Americans are odd people: in their buildings, the first floor is actually the ground floor and there is no 13th floor (due to superstition).
Write a function that given a floor in the american system returns the floor in the european system.
With the ... |
Solve the programming task below in a Python markdown code block.
Example
Input
5
Output
5
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters. |
Solve the programming task below in a Python markdown code block.
Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. [Image]
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process... |
Solve the programming task below in a Python markdown code block.
You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.
a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equa... |
Solve the programming task below in a Python markdown code block.
Polycarp loves ciphers. He has invented his own cipher called Right-Left.
Right-Left cipher is used for strings. To encrypt the string $s=s_{1}s_{2} \dots s_{n}$ Polycarp uses the following algorithm: he writes down $s_1$, he appends the current word... |
Solve the programming task below in a Python markdown code block.
In this Kata you need to write the method SharedBits that returns true if 2 integers share at least two '1' bits. For simplicity assume that all numbers are positive
For example
int seven = 7; //0111
int ten = 10; //1010
int fifteen = 15; //1111... |
Solve the programming task below in a Python markdown code block.
Given is an integer N. Snuke will choose integers s_1, s_2, n_1, n_2, u_1, u_2, k_1, k_2, e_1, and e_2 so that all of the following six conditions will be satisfied:
* 0 \leq s_1 < s_2
* 0 \leq n_1 < n_2
* 0 \leq u_1 < u_2
* 0 \leq k_1 < k_2
* 0 \leq e... |
Solve the programming task below in a Python markdown code block.
Mr Leicester's cheese factory is the pride of the East Midlands, but he's feeling a little blue. It's the time of the year when **the taxman is coming round to take a slice of his cheddar** - and the final thing he has to work out is how much money he's... |
Solve the programming task below in a Python markdown code block.
Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the floors from bottom to top with integers from 1 to n. Now you're on the floor number a. You are very bored, so you want to take the ... |
Solve the programming task below in a Python markdown code block.
The rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned. Valid decimal values for RGB are 0 - 255. Any values that fall out of that range must be rounded to the closest... |
Solve the programming task below in a Python markdown code block.
Polycarp has built his own web service. Being a modern web service it includes login feature. And that always implies password security problems.
Polycarp decided to store the hash of the password, generated by the following algorithm: take the passwo... |
Solve the programming task below in a Python markdown code block.
Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.
Roma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.