info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"abaabbabaab`abbabbabaabbab\\nab\", \"AABABCAC\\nB\", \"AbCdEfG\\naBcDeFh\", \"abaabbbbaab`abbabbabaabaab\\nab\", \"AACABCAC\\nB\", \"AbGdEfC\\naBcDeFh\", \"abaabbbbaab`abbabbabaabaab\\n`b\", \"AACABCAC\\nC\", \"AbGdEfC\\naBcDhFe\", \"abaabbbbaaa`abbabbabbabaab\\n`b\", \"AACAACAC\\nC\", \"AbGd...
Problem Given the strings $ s $, $ t $. First, let the string set $ A = $ {$ s $}, $ B = \ phi $. At this time, I want to perform the following operations as much as possible. operation step1 Perform the following processing for all $ u ∊ A $. 1. From all subsequences of $ u $ (not necessarily contiguous), choose ...
0.125
{"tests": "{\"inputs\": [[8], [1], [-2], [-1], [0]], \"outputs\": [[\"8 is more than zero.\"], [\"1 is more than zero.\"], [\"-2 is equal to or less than zero.\"], [\"-1 is equal to or less than zero.\"], [\"0 is equal to or less than zero.\"]]}", "source": "primeintellect"}
Correct this code so that it takes one argument, `x`, and returns "`x` is more than zero" if `x` is positive (and nonzero), and otherwise, returns "`x` is equal to or less than zero." In both cases, replace `x` with the actual value of `x`. Write your solution by modifying this code: ```python def corrections(x): `...
0
{"tests": "{\"inputs\": [[[1, 2, 4, 7, 11]], [[0, 1, 2, 3, 100000]], [[0, 1, 2, 100000, 4]], [[0, 1, 100000, 3, 4]], [[0, 100000, 2, 3, 4]]], \"outputs\": [[\"Non-linear sequence\"], [\"Non-linear sequence\"], [\"Non-linear sequence\"], [\"Non-linear sequence\"], [\"Non-linear sequence\"]]}", "source": "primeintellect"...
This is a follow-up from my previous Kata which can be found here: http://www.codewars.com/kata/5476f4ca03810c0fc0000098 This time, for any given linear sequence, calculate the function [f(x)] and return it as a function in Javascript or Lambda/Block in Ruby. For example: ```python get_function([0, 1, 2, 3, 4])(5) =...
0
{"tests": "{\"inputs\": [\"20 228 779 225 819 142 849 24 494 45 172 95 207 908 510 424 78 100 166 869 456\\n\", \"4 220 380 729 969\\n\", \"23 486 261 249 312 592 411 874 397 18 70 417 512 338 679 517 997 938 328 418 793 522 745 59\\n\", \"17 644 532 255 57 108 413 51 284 364 300 597 646 712 470 42 730 231\\n\", \"16 2...
How to make a cake you'll never eat. Ingredients. * 2 carrots * 0 calories * 100 g chocolate spread * 1 pack of flour * 1 egg Method. 1. Put calories into the mixing bowl. 2. Take carrots from refrigerator. 3. Chop carrots. 4. Take chocolate spread from refrigerator. 5. Put chocolate spread ...
0.625
{"tests": "{\"inputs\": [[\"Abcd1234\"], [\"Abcd123\"], [\"abcd1234\"], [\"AbcdefGhijKlmnopQRsTuvwxyZ1234567890\"], [\"ABCD1234\"], [\"Ab1!@#$%^&*()-_+={}[]|\\\\:;?/>.<,\"], [\"!@#$%^&*()-_+={}[]|\\\\:;?/>.<,\"], [\"\"], [\" aA1----\"], [\"4aA1----\"]], \"outputs\": [[true], [false], [false], [true], [false], [true], [...
## Description Your job is to create a simple password validation function, as seen on many websites. The rules for a valid password are as follows: - There needs to be at least 1 uppercase letter. - There needs to be at least 1 lowercase letter. - There needs to be at least 1 number. - The password needs to be at le...
0
{"tests": "{\"inputs\": [\"55\\n\", \"46\\n\", \"16\\n\", \"53\\n\", \"99\\n\", \"87\\n\", \"3\\n\", \"47\\n\", \"62\\n\", \"6\\n\", \"11\\n\", \"93\\n\", \"89\\n\", \"34\\n\", \"38\\n\", \"22\\n\", \"85\\n\", \"25\\n\", \"82\\n\", \"26\\n\", \"74\\n\", \"100\\n\", \"51\\n\", \"69\\n\", \"7\\n\", \"95\\n\", \"23\\n\", ...
This is an interactive problem. In the output section below you will see the information about flushing the output. Bear Limak thinks of some hidden number — an integer from interval [2, 100]. Your task is to say if the hidden number is prime or composite. Integer x > 1 is called prime if it has exactly two distinct ...
0
{"tests": "{\"inputs\": [\"4\\n4\\n1 5\\n2 4\\n2 3\\n3 4\\n5\\n1 5\\n2 3\\n2 5\\n3 5\\n2 2\\n3\\n1 3\\n2 4\\n2 3\\n7\\n1 10\\n2 8\\n2 5\\n3 4\\n4 4\\n6 8\\n7 7\\n\", \"1\\n1\\n1 200000\\n\", \"1\\n1\\n100000 100001\\n\", \"1\\n1\\n100000 100001\\n\", \"1\\n1\\n1 200000\\n\", \"1\\n1\\n1 99274\\n\", \"4\\n4\\n1 5\\n2 4\...
You are given $n$ segments on a coordinate axis $OX$. The $i$-th segment has borders $[l_i; r_i]$. All points $x$, for which $l_i \le x \le r_i$ holds, belong to the $i$-th segment. Your task is to choose the maximum by size (the number of segments) subset of the given set of segments such that each pair of segments i...
0
{"tests": "{\"inputs\": [\"3\\n4\\n3 4 3 3\\n-1 1 2 2\\n-1 2 2 3\\n2\\n5 6\\n-1 5\\n-1 1\\n3\\n3 5 2\\n-1 1 1\\n-1 3 5\\n\", \"3\\n4\\n3 4 3 3\\n-1 1 2 2\\n-1 2 2 3\\n2\\n5 6\\n-1 5\\n0 1\\n3\\n3 5 2\\n-1 1 1\\n-1 3 5\\n\", \"3\\n4\\n3 4 3 3\\n-1 1 2 2\\n-1 2 2 3\\n2\\n5 9\\n-1 5\\n0 1\\n3\\n3 5 2\\n-1 1 1\\n-1 3 5\\n\...
You have $n$ chains, the $i$-th chain consists of $c_i$ vertices. Vertices in each chain are numbered independently from $1$ to $c_i$ along the chain. In other words, the $i$-th chain is the undirected graph with $c_i$ vertices and $(c_i - 1)$ edges connecting the $j$-th and the $(j + 1)$-th vertices for each $1 \le j ...
0
{"tests": "{\"inputs\": [\"4\\n5 2 6 10 8 3\\n1 7\\n2 10 4\\n2 9 5\\n\", \"5\\n3 12 10 19\\n5 1 4 18 11 13\\n4 17 15 2 6\\n4 3 12 18 10\\n4 2 8 5 9\\n\", \"10\\n1 77966\\n1 79480\\n1 94920\\n1 53920\\n1 15585\\n1 57339\\n1 1585\\n1 91802\\n1 27934\\n1 20354\\n\", \"5\\n3 2 4 10\\n2 1 6\\n2 8 7\\n3 2 4 10\\n2 1 6\\n\", ...
Paw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web. <image> There are n main threads going from the center of the web. All main threads are located in one plane and divide it into n equal infinite sectors. The sectors are in...
0.625
{"tests": "{\"inputs\": [\"1\\n10\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n3 7\\n3 8\\n4 9\\n4 10\\n\", \"1\\n10\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n3 7\\n3 8\\n4 9\\n7 10\\n\", \"1\\n10\\n1 2\\n1 3\\n2 4\\n2 5\\n2 6\\n3 7\\n3 8\\n4 9\\n4 10\\n\", \"1\\n10\\n1 2\\n1 3\\n4 4\\n2 5\\n2 6\\n3 7\\n3 8\\n6 9\\n4 10\\n\", \"1\\n3\\n1 2\\...
Assume that you have $k$ one-dimensional segments $s_1, s_2, \dots s_k$ (each segment is denoted by two integers — its endpoints). Then you can build the following graph on these segments. The graph consists of $k$ vertexes, and there is an edge between the $i$-th and the $j$-th vertexes ($i \neq j$) if and only if the...
0
{"tests": "{\"inputs\": [\"2012.12.31\\n2.12.16.14.14\\n7138.5.13\\n10.5.5.1.2\\n10000000.12.31\\n#\", \"2012.12.31\\n2.12.16.14.14\\n7138.5.13\\n10.2.5.1.5\\n10000000.12.31\\n#\", \"2012.12.31\\n2.12.16.14.14\\n6138.5.13\\n10.5.2.1.5\\n10000000.12.31\\n#\", \"2012.12.31\\n2.12.16.04.14\\n7138.5.13\\n10.5.5.1.2\\n10000...
Shinya watched a program on TV called "Maya's Great Prophecy! Will the World End in 2012?" After all, I wasn't sure if the world would end, but I was interested in Maya's "long-term calendar," which was introduced in the program. The program explained as follows. The Maya long-term calendar is a very long calendar con...
0
{"tests": "{\"inputs\": [\"3\\n9\\niredppipe\\npiedpiper\\n4\\nestt\\ntest\\n4\\ntste\\ntest\\n\", \"4\\n1\\na\\nz\\n5\\nadhas\\ndasha\\n5\\naashd\\ndasha\\n5\\naahsd\\ndasha\\n\", \"6\\n7\\ncontest\\nntecost\\n7\\ncontest\\nnstteco\\n7\\ncontest\\ntnsteco\\n7\\ncontest\\ncotestn\\n7\\ncontest\\ncontest\\n7\\nontestc\\...
The problem was inspired by Pied Piper story. After a challenge from Hooli's compression competitor Nucleus, Richard pulled an all-nighter to invent a new approach to compression: middle-out. You are given two strings $s$ and $t$ of the same length $n$. Their characters are numbered from $1$ to $n$ from left to right ...
0
{"tests": "{\"inputs\": [\"VEEMU:VEEMU:GTE:GTE:KZZEDTUECE:VEEMU:GTE:CGOZKO:CGOZKO:GTE:ZZNAY.,GTE:MHMBC:GTE:VEEMU:CGOZKO:VEEMU:VEEMU.,CGOZKO:ZZNAY..................\\n\", \"V:V:V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V..,V:V.,V.,V.,V..,V:V.,V.,V.,V.,V..,V:V.,V.,V..,V:V..,V:V.,V..,V.,V:V..,V.,V.,V.,V.,V.,V....
The Beroil corporation structure is hierarchical, that is it can be represented as a tree. Let's examine the presentation of this structure as follows: * employee ::= name. | name:employee1,employee2, ... ,employeek. * name ::= name of an employee That is, the description of each employee consists of his name,...
0
{"tests": "{\"inputs\": [\"6\\n258 877 696 425 663 934\\n\", \"37\\n280 281 169 68 249 389 977 101 360 43 448 447 368 496 125 507 747 392 338 270 916 150 929 428 118 266 589 470 774 852 263 644 187 817 808 58 637\\n\", \"100\\n469 399 735 925 62 153 707 723 819 529 200 624 57 708 245 384 889 11 639 638 260 419 8 142 40...
One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that divided the wall into several parts. Some parts were painted red and all the other were painted blue. Besides,...
0.75
{"tests": "{\"inputs\": [[10], [20], [0], [1], [200]], \"outputs\": [[23], [78], [0], [0], [9168]]}", "source": "primeintellect"}
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Finish the solution so that it returns the sum of all the multiples of 3 or 5 **below** the number passed in. > Note: If the number is a multiple of **both** 3 and 5, only count it *once*...
0
{"tests": "{\"inputs\": [[1892376], [189237], [18922314324324234423437], [189223141324324234423437], [1892231413243242344321432142343423437], [0]], \"outputs\": [[true], [false], [false], [true], [true], [true]]}", "source": "primeintellect"}
###Lucky number Write a function to find if a number is lucky or not. If the sum of all digits is 0 or multiple of 9 then the number is lucky. `1892376 => 1+8+9+2+3+7+6 = 36`. 36 is divisble by 9, hence number is lucky. Function will return `true` for lucky numbers and `false` for others. Write your solution by mo...
0
{"tests": "{\"inputs\": [[100, 12], [99, 0], [10, 15], [85, 5], [55, 3], [55, 0], [20, 2]], \"outputs\": [[100], [100], [100], [90], [75], [0], [0]]}", "source": "primeintellect"}
Create a function finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects. This function should take two arguments: exam - grade for exam (from 0 to 100); projects - number of completed projects (from 0 and above); This function sh...
0
{"tests": "{\"inputs\": [\"AA\\n\", \"A\\n\", \"ABCDEF\\n\", \"BA\\n\", \"CC\\n\", \"B\\n\", \"FEDCBA\\n\", \"CBWBB\\n\", \"BBWBWB\\n\", \"BVWB\\n\", \"WWWOONOOOWWW\\n\", \"AB\\n\", \"C\\n\", \"EEDCBA\\n\", \"BBWBC\\n\", \"BBWBWA\\n\", \"BVXB\\n\", \"WWWOONOOOVWW\\n\", \"AC\\n\", \"D\\n\", \"DEECBA\\n\", \"BBWCB\\n\", ...
Balph is learning to play a game called Buma. In this game, he is given a row of colored balls. He has to choose the color of one new ball and the place to insert it (between two balls, or to the left of all the balls, or to the right of all the balls). When the ball is inserted the following happens repeatedly: if so...
0.25
{"tests": "{\"inputs\": [\"2\\nwhite 10\\nblack 10\\n4\\nblack\\nwhite\", \"3\\nwgite 10\\nerd 40\\nwhite 30\\n2\\nwhite\\nerd\\nwhite\", \"2\\nwhite 20\\nblack 10\\n2\\nkcalb\\norange\", \"2\\nwhite 20\\nblack 10\\n2\\nblack\\nhwite\", \"4\\nred 3444\\nred 3018\\nred 3098\\nred 3319\\n4\\nred\\nred\\nrec\\nred\", \"3\...
In the Jambo Amusement Garden (JAG), you sell colorful drinks consisting of multiple color layers. This colorful drink can be made by pouring multiple colored liquids of different density from the bottom in order. You have already prepared several colored liquids with various colors and densities. You will receive a d...
0
{"tests": "{\"inputs\": [[1, 1, 2], [2, 0, 3], [423, 100, 150], [1, 2, 0], [1, 2, 2], [-1.0, 2, 2]], \"outputs\": [[[2, 6]], [[0, 4, 12, 24]], [[4272300, 4357746, 4444038, 4531176, 4619160, 4707990, 4797666, 4888188, 4979556, 5071770, 5164830, 5258736, 5353488, 5449086, 5545530, 5642820, 5740956, 5839938, 5939766, 6040...
Quantum mechanics tells us that a molecule is only allowed to have specific, discrete amounts of internal energy. The 'rigid rotor model', a model for describing rotations, tells us that the amount of rotational energy a molecule can have is given by: `E = B * J * (J + 1)`, where J is the state the molecule is in...
0
{"tests": "{\"inputs\": [[\"Jimmy\"], [\"Samantha\"], [\"Sam\"], [\"Kayne\"], [\"Melissa\"], [\"James\"], [\"Gregory\"], [\"Jeannie\"], [\"Kimberly\"], [\"Timothy\"], [\"Dani\"], [\"Saamy\"], [\"Saemy\"], [\"Saimy\"], [\"Saomy\"], [\"Saumy\"], [\"Boyna\"], [\"Kiyna\"], [\"Sayma\"], [\"Ni\"], [\"Jam\"], [\"Suv\"]], \"ou...
Nickname Generator Write a function, `nicknameGenerator` that takes a string name as an argument and returns the first 3 or 4 letters as a nickname. If the 3rd letter is a consonant, return the first 3 letters. If the 3rd letter is a vowel, return the first 4 letters. If the string is less than 4 characters, retur...
0
{"tests": "{\"inputs\": [\"2\\n0 2\", \"2\\n-1 4\", \"2\\n0 4\", \"2\\n0 1\", \"2\\n1 0\", \"2\\n0 7\", \"2\\n-1 2\", \"2\\n2 0\", \"2\\n-1 10\", \"2\\n-2 2\", \"2\\n2 -1\", \"2\\n-2 4\", \"2\\n4 -1\", \"2\\n-2 8\", \"2\\n4 0\", \"2\\n-2 5\", \"2\\n5 0\", \"2\\n1 1\", \"2\\n2 2\", \"2\\n2 4\", \"2\\n4 4\", \"2\\n0 0\",...
Problem statement There is a positive integer sequence $ a_1, a_2, \ ldots, a_N $ of length $ N $. Consider the following game, which uses this sequence and is played by $ 2 $ players on the play and the play. * Alternately select one of the following operations for the first move and the second move. * Select a pos...
0
{"tests": "{\"inputs\": [\"5\\n0 1 0 1 0\\n1 1 0 0 1\\n1 0 1 0 1\\n0 0 1 1 0\\n\", \"3\\n1 0 0\\n0 0 0\\n0 0 0\\n0 0 0\\n\", \"1\\n0\\n1\\n1\\n0\\n\", \"7\\n1 0 0 1 1 0 1\\n1 0 0 0 1 1 1\\n1 1 1 0 0 1 0\\n0 1 1 1 0 0 0\\n\", \"7\\n0 0 1 0 1 0 1\\n0 0 0 0 0 0 1\\n0 1 0 1 0 1 0\\n1 0 0 0 0 0 0\\n\", \"7\\n0 0 0 0 0 0 0\\...
Pupils Alice and Ibragim are best friends. It's Ibragim's birthday soon, so Alice decided to gift him a new puzzle. The puzzle can be represented as a matrix with $2$ rows and $n$ columns, every element of which is either $0$ or $1$. In one move you can swap two values in neighboring cells. More formally, let's number...
0
{"tests": "{\"inputs\": [[[1, 2]], [[1, 3]], [[1, 5]], [[]], [[0]], [[0, 1]], [[1, 3, 5, 7]], [[2, 4]], [[-1]], [[-1, -1]], [[-1, 0, 1]], [[-3, 3]], [[-5, 3]]], \"outputs\": [[1], [3], [null], [null], [0], [1], [7], [null], [-1], [null], [-1], [3], [null]]}", "source": "primeintellect"}
Integral numbers can be even or odd. Even numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) think of odd numbers as `n = 2m + 1`. Now, some odd numbers can be more odd than others: when for some `n`, `m` is more odd than for another's. Recursively. :] Even numbers are just ...
0
{"tests": "{\"inputs\": [[\"a\"], [\"b\"], [\"c\"], [\"\"], [\"aaa\"], [\"abc\"], [\"Mary Had A Little Lamb\"], [\"Mary had a little lamb\"], [\"CodeWars rocks\"], [\"And so does Strive\"]], \"outputs\": [[97], [98], [99], [0], [291], [294], [1873], [2001], [1370], [1661]]}", "source": "primeintellect"}
You'll be given a string, and have to return the total of all the unicode characters as an int. Should be able to handle any characters sent at it. examples: uniTotal("a") == 97 uniTotal("aaa") == 291 Write your solution by modifying this code: ```python def uni_total(string): ``` Your solution should implement...
0
{"tests": "{\"inputs\": [\"341143514535\\n158\\n143565553551655311343411652235654535651124615163\\n551544654451431564\\n4\\n3411\\n6363636363\\n153414\", \"341143514535\\n314\\n10141283183115209195186599000583233654691126402\\n551544654451431564\\n4\\n3411\\n6363636363\\n153414\", \"341143514535\\n158\\n143565553551655...
One day, Taro received a strange email with only the number "519345213244" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, "Oh, I sent it with a pocket bell because I was in a hurry. It's convenient. Nice to meet you!" I got it. You know this cousin, who is always ...
0
{"tests": "{\"inputs\": [[6, 11, 2], [11, 345, 17], [0, 1, 7], [20, 20, 2], [20, 20, 8], [19, 20, 2], [0, 10, 1], [11, 14, 2], [101, 9999999999999999999999999999999999999999999, 11], [1005, 9999999999999999999999999999999999999999999, 109]], \"outputs\": [[3], [20], [1], [1], [0], [1], [11], [2], [909090909090909090909...
Complete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible by `k`. More scientifically: `{ i : x ≤ i ≤ y, i mod k = 0 }` ## Example Given ```x = 6, y = 11, k = 2``` the function should return `3`, bec...
0
{"tests": "{\"inputs\": [\"4\\n2\\n1 2\\n3\\n5 5 5\\n4\\n1 3 3 7\\n6\\n3 4 2 1 3 3\\n\", \"1\\n74\\n9 3 10 8 6 6 1 6 9 3 7 3 2 8 1 5 8 4 6 4 1 6 5 6 10 3 6 6 6 4 9 5 8 7 2 1 6 2 4 9 10 9 5 4 7 5 7 2 10 10 1 5 2 4 1 7 7 3 8 10 2 5 8 4 3 9 2 9 9 8 6 8 4 1\\n\", \"1\\n3\\n11 11 154\\n\", \"1\\n3\\n11 11 154\\n\", \"1\\n74...
$n$ people gathered to hold a jury meeting of the upcoming competition, the $i$-th member of the jury came up with $a_i$ tasks, which they want to share with each other. First, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation $p$ of numbers from $1$ to $n$ (an ...
0
{"tests": "{\"inputs\": [\"500 3\\n2002 1 1\\n2003 500 500\\n2004 500 500\\n\", \"2 3\\n1 1 1\\n100 2 2\\n10000 1 1\\n\", \"500 2\\n950 500 500\\n3000 1 1\\n\", \"500 1\\n26969 164 134\\n\", \"4 3\\n851 4 3\\n1573 1 4\\n2318 3 4\\n\", \"500 2\\n2000 1 1\\n4000 1 1\\n\", \"10 3\\n26 10 9\\n123 2 2\\n404 5 6\\n\", \"727 ...
You are a paparazzi working in Manhattan. Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r south-to-north streets intersects each of the r west-to-east streets; the interse...
0.75
{"tests": "{\"inputs\": [[5], [3], [9], [10], [20]], \"outputs\": [[[1, 2, 3, 4, 5]], [[1, 2, 3]], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]]}", "source": "primeintellect"}
You take your son to the forest to see the monkeys. You know that there are a certain number there (n), but your son is too young to just appreciate the full number, he has to start counting them from 1. As a good parent, you will sit and count with him. Given the number (n), populate an array with all numbers up to a...
0
{"tests": "{\"inputs\": [\"6\\nAIZU 10\\nLINER 6\\nLINE 4\\nALL 2\\nAS 1\\nCIEL 10\\nASLA\\nCILI\\nIRZN\\nUELE\\n21\", \"6\\nAIZU 10\\nLINER 6\\nLHNE 4\\nALL 2\\nAS 1\\nCIEL 10\\nASLA\\nCILI\\nIRZN\\nUELE\\n21\", \"6\\nAIZU 10\\nLINER 6\\nLHNE 3\\nALL 2\\nAS 1\\nCIEL 10\\nBSLA\\nCILI\\nIRZN\\nUELE\\n21\", \"6\\nUZI@ 4\...
Problem Statement Mr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by playing the following games on her mobile phone. The mobile phone she has is a touch panel type that ...
0.25
{"tests": "{\"inputs\": [[1], [2], [5], [0], [-25]], \"outputs\": [[\"1\"], [\"1\\n22\"], [\"1\\n22\\n333\\n4444\\n55555\"], [\"\"], [\"\"]]}", "source": "primeintellect"}
## Task: You have to write a function `pattern` which returns the following Pattern(See Pattern & Examples) upto `n` number of rows. * Note:`Returning` the pattern is not the same as `Printing` the pattern. #### Rules/Note: * If `n < 1` then it should return "" i.e. empty string. * There are `no whitespaces` in the ...
0
{"tests": "{\"inputs\": [\"((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[1]())[8](()[3]()*)\", \"((()[8]())[2]())[5](((()[3]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[1]())[8](()[3]()))\", \"((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[0]())[8](()[3]'))...
C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vertex has exactly one vertex called the parent of that vertex, which is c...
0
{"tests": "{\"inputs\": [\"1\\n1 1\\nA\\n\", \"1\\n2 2\\nAA\\nAA\\n\", \"1\\n3 3\\nAAA\\nAAA\\nAAA\\n\", \"1\\n4 4\\nAAAA\\nAAAA\\nAAAA\\nAAAA\\n\", \"4\\n7 8\\nAAPAAAAA\\nAAAAPPPP\\nPPPPAAAA\\nAPAAPPPP\\nAPAPPAPP\\nAAAAPPAP\\nAAAAPPAA\\n6 5\\nAAAAA\\nAAAAA\\nAAPAA\\nAAPAP\\nAAAPP\\nAAAPP\\n4 4\\nPPPP\\nPPPP\\nPPPP\\nP...
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Beingawesomei...
0
{"tests": "{\"inputs\": [\"4\", \"1026\", \"1000000001000000000\", \"0\", \"530\", \"1100000001000000000\", \"1\", \"706\", \"1100000001000010000\", \"2\", \"152\", \"1100000001001010000\", \"7\", \"192\", \"1100000011001010000\", \"5\", \"292\", \"1100000001001010010\", \"271\", \"1101000001001010010\", \"266\", \"110...
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7. Constraints * 1≦N≦10^{18...
0
{"tests": "{\"inputs\": [[0], [1], [2], [10], [100], [1000], [10000], [100000], [1000000], [10000000]], \"outputs\": [[0], [1], [2], [6], [20], [118], [720], [11108], [114952], [1153412]]}", "source": "primeintellect"}
*This kata is based on [Project Euler Problem #349](https://projecteuler.net/problem=349). You may want to start with solving [this kata](https://www.codewars.com/kata/langtons-ant) first.* --- [Langton's ant](https://en.wikipedia.org/wiki/Langton%27s_ant) moves on a regular grid of squares that are coloured either b...
0
{"tests": "{\"inputs\": [\"2\\n1 2 2 2\\n1 1 2 2\\n\", \"1\\n69 69 69 69\\n\", \"5\\n1 1 1000000000 1000000000\\n1 1 1000000000 1000000000\\n1 1 1000000000 1000000000\\n1 1 1000000000 1000000000\\n1 1 65537 65537\\n\", \"1\\n1 1 131073 131073\\n\", \"1\\n69 69 69 69\\n\", \"1\\n3 2 4 7\\n\", \"5\\n1 1 1000000000 100000...
Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $(x_1,y_1)$ to the point $(x_2,y_2)$. He has a rope, which he can use to pull the box. He can only pull the box if he stands exactly $1$ unit away from the box in the direction of one of two coordinate axes. H...
0
{"tests": "{\"inputs\": [\"1\\n100000\\n\", \"3\\n0 0 3\\n\", \"1\\n100010\\n\", \"5\\n0 11 1 13 14\\n\", \"5\\n0 12 1 13 14\\n\", \"3\\n0 3 3\\n\", \"3\\n0 1 2\\n\", \"4\\n2 1 0 1\\n\", \"4\\n0 6 0 6\\n\", \"4\\n4 0 0 0\\n\", \"5\\n1 3 0 13 48\\n\", \"5\\n0 1 3 3 13\\n\", \"3\\n0 2 3\\n\", \"4\\n0 6 0 4\\n\", \"1\\n00...
An array is called beautiful if all the elements in the array are equal. You can transform an array using the following steps any number of times: 1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the source index and j be the sink index. 2. Decrease the i-th element by x, an...
0
{"tests": "{\"inputs\": [[[12, 10, 8, 12, 7, 6, 4, 10, 12]], [[12, 10, 8, 12, 7, 6, 4, 10, 10]], [[12, 10, 8, 12, 7, 6, 4, 10, 12, 10]], [[12, 10, 8, 8, 3, 3, 3, 3, 2, 4, 10, 12, 10]], [[1, 2, 3]], [[1, 1, 2, 3]], [[1, 1, 2, 2, 3]]], \"outputs\": [[12], [10], [12], [3], [3], [1], [2]]}", "source": "primeintellect"}
Complete the method which returns the number which is most frequent in the given input array. If there is a tie for most frequent number, return the largest number among them. Note: no empty arrays will be given. ## Examples ``` [12, 10, 8, 12, 7, 6, 4, 10, 12] --> 12 [12, 10, 8, 12, 7, 6, 4, 10, 12, ...
0
{"tests": "{\"inputs\": [\"4\\n1 1\\n2 2\\n3 2\\n4 3\\n\", \"4\\n1 1\\n3 2\\n3 2\\n4 3\\n\", \"4\\n1 1\\n3 2\\n3 2\\n5 3\\n\", \"4\\n1 1\\n2 2\\n3 3\\n4 3\\n\", \"4\\n1 1\\n3 2\\n3 2\\n3 3\\n\", \"4\\n1 1\\n3 2\\n3 2\\n5 5\\n\", \"4\\n1 1\\n2 2\\n5 3\\n4 3\\n\", \"4\\n1 1\\n3 2\\n2 2\\n3 3\\n\", \"4\\n1 1\\n2 2\\n5 3\\...
You have a sequence $a$ with $n$ elements $1, 2, 3, \dots, k - 1, k, k - 1, k - 2, \dots, k - (n - k)$ ($k \le n < 2k$). Let's call as inversion in $a$ a pair of indices $i < j$ such that $a[i] > a[j]$. Suppose, you have some permutation $p$ of size $k$ and you build a sequence $b$ of size $n$ in the following manner...
0.125
{"tests": "{\"inputs\": [\"2 2\\nTG\\nAC\\n\", \"2 2\\nAG\\nTC\\n\", \"2 2\\nGA\\nTC\\n\", \"3 5\\nGACGA\\nAGCAG\\nAGCAG\\n\", \"2 2\\nTG\\nCA\\n\", \"2 2\\nGA\\nCT\\n\", \"2 2\\nGT\\nAC\\n\", \"2 2\\nGT\\nCA\\n\", \"3 5\\nAGGAC\\nGACGA\\nGACGA\\n\", \"3 5\\nAGCAG\\nAGCAG\\nGACGA\\n\", \"2 2\\nG@\\nCT\\n\", \"2 2\\nG?\...
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that differs from the given table in the minimum number of characters. Input First...
0
{"tests": "{\"inputs\": [\"3 2\\n1 2 5\", \"3 1\\n3 2 1\", \"0 3\\n2 3 1\", \"0 4\\n2 3 1\", \"0 3\\n3 3 1\", \"3 2\\n2 2 3\", \"3 2\\n2 2 5\", \"0 3\\n4 3 1\", \"0 4\\n3 3 1\", \"0 3\\n3 0 1\", \"0 2\\n2 2 3\", \"0 2\\n4 3 1\", \"0 3\\n3 1 1\", \"0 2\\n2 4 3\", \"0 2\\n6 3 1\", \"0 3\\n3 2 1\", \"0 2\\n3 4 3\", \"0 2\...
Problem Given a permutation of length $ N $ $ P = \\ {P_1, P_2, \ ldots, P_N \\} $ and the integer $ K $. Determine if the permutation $ P $ can be monotonically increased by repeating the following operation any number of times $ 0 $ or more. * Choose the integer $ x \ (0 \ le x \ le N-K) $. Patrol right shift aroun...
0.125
{"tests": "{\"inputs\": [\"386 20 29 30\\n1 349\\n2 482\\n1 112\\n1 93\\n2 189\\n1 207\\n2 35\\n2 -5\\n1 422\\n1 442\\n1 402\\n2 238\\n3 258\\n3 54\\n2 369\\n2 290\\n2 329\\n3 74\\n3 -62\\n2 170\\n1 462\\n2 15\\n2 222\\n1 309\\n3 150\\n1 -25\\n3 130\\n1 271\\n1 -43\\n351 250 91 102 0 286 123 93 100 205 328 269 188 83 7...
Motorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came true! Kojiro now wants to get to his girlfriend Johanna to show off his car to her. Kojiro wants to get to his girlfriend, so he will go to her along a coordinate line. For simplicity, we can assume that Kojiro is...
0
{"tests": "{\"inputs\": [[[\"American Redstart\", \"Northern Cardinal\", \"Pine Grosbeak\", \"Barred Owl\", \"Starling\", \"Cooper's Hawk\", \"Pigeon\"]], [[\"Great Crested Flycatcher\", \"Bobolink\", \"American White Pelican\", \"Red-Tailed Hawk\", \"Eastern Screech Owl\", \"Blue Jay\"]], [[\"Black-Crowned Night Heron...
In the world of birding there are four-letter codes for the common names of birds. These codes are created by some simple rules: * If the bird's name has only one word, the code takes the first four letters of that word. * If the name is made up of two words, the code takes the first two letters of each word. * If th...
0
{"tests": "{\"inputs\": [[\"abc\", \"z\"], [\"\", \"z\"], [\"abc\", \"\"], [\"_3ebzgh4\", \"&\"], [\"//case\", \" \"]], \"outputs\": [[\"zzz\"], [\"\"], [\"\"], [\"&&&&&&&&\"], [\" \"]]}", "source": "primeintellect"}
An AI has infected a text with a character!! This text is now **fully mutated** to this character. If the text or the character are empty, return an empty string. There will never be a case when both are empty as nothing is going on!! **Note:** The character is a string of length 1 or an empty string. # Example ...
0
{"tests": "{\"inputs\": [\"2\\naa\\na\\n\", \"5\\naaaaa\\naaaa\\naaa\\naa\\na\\n\", \"2\\nanud\\nanu\\n\", \"4\\nax\\nay\\nby\\nbz\\n\", \"1\\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\\n\", \"6\\nax\\nay\\nby\\nbz\\ncz\\ncx\\n\", \"4\\nax\\nay\\nby\\nbx\\n\", ...
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order. After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in l...
0.125
{"tests": "{\"inputs\": [[3], [15], [-3], [-25], [0]], \"outputs\": [[\"1 1\\n 2 2 \\n 3 \\n 2 2 \\n1 1\"], [\"1 1\\n 2 2 \\n 3 3 \\n 4 4 \\n 5 5 \\n 6 6 \\n 7 ...
### Task: You have to write a function `pattern` which returns the following Pattern(See Examples) upto (2n-1) rows, where n is parameter. * Note:`Returning` the pattern is not the same as `Printing` the pattern. #### Parameters: pattern( n ); ^ ...
0
{"tests": "{\"inputs\": [[\"\"], [\"0\"], [\"0oO0oO\"], [\"1234567890\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"()\"], [\"E\"], [\"aA\"], [\"BRA\"], [\"%%\"]], \"outputs\": [[0], [1], [6], [5], [8], [1], [0], [1], [3], [4]]}", "source": "primeintellect"}
Gigi is a clever monkey, living in the zoo, his teacher (animal keeper) recently taught him some knowledge of "0". In Gigi's eyes, "0" is a character contains some circle(maybe one, maybe two). So, a is a "0",b is a "0",6 is also a "0",and 8 have two "0" ,etc... Now, write some code to count how many "0"s in the tex...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5, 8, 7, 8, 9]], [[2, 8, 6, 7, 4, 3, 1, 5, 9]], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 2, 3, 4, 5, 6, 7, 8]], [[1, 3, 5, 7, 9, 11, 13, 15]], [[1, 3, 5, 7, 8, 12, 14, 16]], [[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]], [[0, 2, 4, 6, 8]], [[2, 4, 6, 8, 10]], [[2, 4, 6, 8, 10, 12, 14, 16, 18,...
Create a function that will return true if all numbers in the sequence follow the same counting pattern. If the sequence of numbers does not follow the same pattern, the function should return false. Sequences will be presented in an array of varied length. Each array will have a minimum of 3 numbers in it. The seque...
0
{"tests": "{\"inputs\": [\"15 15 15\\n1 10 1\\n2 11 0\\n2 6 4\\n1 1 0\\n1 7 5\\n1 14 3\\n1 3 1\\n1 4 2\\n1 9 0\\n2 10 1\\n1 12 1\\n2 2 0\\n1 5 3\\n2 3 0\\n2 4 2\\n\", \"5 20 20\\n1 15 3\\n2 15 3\\n2 3 1\\n2 1 0\\n1 16 4\\n\", \"3 4 5\\n1 3 9\\n2 1 9\\n1 2 8\\n\", \"20 50000 50000\\n2 45955 55488\\n1 19804 29337\\n2 376...
Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisions will happen before one enters the stage. On the sides of t...
0
{"tests": "{\"inputs\": [\"3\\n0 2 2\\n1 1 0\\n\", \"2\\n1 1\\n1 0\\n\", \"10\\n0 1 2 3 5 5 6 7 8 5\\n9 8 7 1 5 4 3 2 0 0\\n\", \"5\\n0 0 1 4 2\\n0 2 0 1 0\\n\", \"1\\n1\\n0\\n\", \"10\\n1 1 1 0 3 0 6 2 4 5\\n7 6 2 3 5 1 2 0 1 0\\n\", \"10\\n1 0 2 2 5 0 0 0 2 7\\n4 3 1 0 4 3 3 2 1 0\\n\", \"19\\n1 1 3 4 5 3 5 7 0 6 5 3...
Frog Gorf is traveling through Swamp kingdom. Unfortunately, after a poor jump, he fell into a well of $n$ meters depth. Now Gorf is on the bottom of the well and has a long way up. The surface of the well's walls vary in quality: somewhere they are slippery, but somewhere have convenient ledges. In other words, if Go...
0
{"tests": "{\"inputs\": [\"49\\nssizfrtawiuefcgtrrapgoivdxmmipwvdtqggsczdipnkzppi\\npqzrmpifgttneasigivkrouigpdivczigcxdsmtwpzpwfsadr\\n\", \"50\\nzyzxzyzwzyzxzyzvzyzxzyzwzyzxzyzuzyzxzyzwzyzxzyzvzy\\nwxzyzzzyzyvzzvyzxxzyxwzuzzzzzyzyzzxyyzzzywzxzzyzyy\\n\", \"50\\nabbabaabbaababbabaababbaabbabaabbaababbaabbabaabab\\nbaa...
Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock...
0
{"tests": "{\"inputs\": [\"20\\n4 13\\n17 7\\n19 10\\n18 1\\n5 15\\n2 6\\n11 7\\n3 6\\n5 1\\n20 16\\n12 5\\n10 17\\n14 18\\n8 13\\n13 15\\n19 1\\n9 19\\n6 13\\n17 20\\n14 12 4 2 3 9 8 11 16\\n\", \"37\\n27 3\\n27 35\\n6 8\\n12 21\\n4 7\\n32 27\\n27 17\\n24 14\\n1 10\\n3 23\\n20 8\\n12 4\\n16 33\\n2 34\\n15 36\\n5 31\\n...
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too. An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and they are connected by n - 1 edges so that there is a path between any pair of ver...
0.25
{"tests": "{\"inputs\": [[1965], [1938], [1998], [2016], [1924], [1968], [2162], [6479], [3050], [6673], [6594], [9911], [2323], [3448], [1972]], \"outputs\": [[\"Wood Snake\"], [\"Earth Tiger\"], [\"Earth Tiger\"], [\"Fire Monkey\"], [\"Wood Rat\"], [\"Earth Monkey\"], [\"Water Dog\"], [\"Earth Goat\"], [\"Metal Dog\"...
The [Chinese zodiac](https://en.wikipedia.org/wiki/Chinese_zodiac) is a repeating cycle of 12 years, with each year being represented by an animal and its reputed attributes. The lunar calendar is divided into cycles of 60 years each, and each year has a combination of an animal and an element. There are 12 animals and...
0
{"tests": "{\"inputs\": [\"3 9\\n500\\n300\\n800\\n200\\n100\\n600\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\n500\\n311\\n800\\n335\\n100\\n600\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\n559\\n311\\n800\\n335\\n100\\n563\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\...
Taro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshelf in the room, it will be quite small, so you have to devise to make the width of the bookshelf as...
0.375
{"tests": "{\"inputs\": [\"8587340257\\n\", \"7420738134810\\n\", \"2975\\n\", \"1000000000000\\n\", \"236\\n\", \"27\\n\", \"9\\n\", \"3047527844089\\n\", \"16\\n\", \"5\\n\", \"614125\\n\", \"9999925100701\\n\", \"30971726\\n\", \"266418\\n\", \"401120980262\\n\", \"319757451841\\n\", \"1307514188557\\n\", \"128\\n\"...
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circl...
0
{"tests": "{\"inputs\": [\"3\\n0 0 1 0 0 1 1 1\\n0 0 1 0 2 1 1 2\\n-1 1 1 0 0 1 0 -1\", \"3\\n0 1 1 0 0 1 1 1\\n-1 0 1 0 2 1 1 2\\n-1 1 0 0 0 1 0 -1\", \"3\\n0 1 1 0 0 1 1 1\\n-1 0 1 1 2 1 1 2\\n-1 1 0 0 0 1 0 -1\", \"3\\n0 1 1 0 0 1 1 1\\n-1 0 1 1 1 1 1 2\\n-1 1 0 0 0 0 0 -1\", \"3\\n0 2 1 0 0 1 1 1\\n-1 0 1 0 1 1 1 2...
For given two segments s1 and s2, print the distance between them. s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3. Constraints * 1 ≤ q ≤ 1000 * -10000 ≤ xpi, ypi ≤ 10000 * p0 ≠ p1 and p2 ≠ p3. Input The entire input looks like: q (the number of queries) 1st query 2nd query ... qth...
0
{"tests": "{\"inputs\": [[0], [59], [60], [3599], [3600], [86399], [86400], [359999]], \"outputs\": [[\"00:00:00\"], [\"00:00:59\"], [\"00:01:00\"], [\"00:59:59\"], [\"01:00:00\"], [\"23:59:59\"], [\"24:00:00\"], [\"99:59:59\"]]}", "source": "primeintellect"}
Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (`HH:MM:SS`) * `HH` = hours, padded to 2 digits, range: 00 - 99 * `MM` = minutes, padded to 2 digits, range: 00 - 59 * `SS` = seconds, padded to 2 digits, range: 00 - 59 The maximum time never excee...
0
{"tests": "{\"inputs\": [\"5 10 7\\n98765 78654 25669 45126 98745\\n\", \"2 7597 8545\\n74807 22362\\n\", \"1 1 1000000000\\n100\\n\", \"5 2 9494412\\n5484 254 1838 18184 9421\\n\", \"95 97575868 5\\n4612 1644 3613 5413 5649 2419 5416 3926 4610 4419 2796 5062 2112 1071 3790 4220 3955 2142 4638 2832 2702 2115 2045 4085 ...
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to n from the left to the right. Unfortunately, Joe ...
0
{"tests": "{\"inputs\": [[\"ceggodegge heggeregge\"], [\"FeggUNegg KeggATeggA\"], [\"egegggegg\"], [\"Heggeleggleggo weggoreggleggdegg\"], [\"seggceggreggameggbeggleggedegg egegggeggsegg\"], [\"egegggeggyegg beggreggeadegg\"], [\"veggegeggyeggmeggitegge onegg teggoaseggtegg\"]], \"outputs\": [[\"code here\"], [\"FUN KA...
Unscramble the eggs. The string given to your function has had an "egg" inserted directly after each consonant. You need to return the string before it became eggcoded. ## Example Kata is supposed to be for beginners to practice regular expressions, so commenting would be appreciated. Write your solution by modify...
0
{"tests": "{\"inputs\": [\"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTMTMTT\\n6\\nTMTTTT\\n6\\nTTMMTT\\n\", \"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTMTMTT\\n6\\nMTTTTT\\n6\\nTTMMTT\\n\", \"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTMTMTT\\n6\\nMTTTTT\\n6\\nTTMTTM\\n\", \"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTTTMMT\\n6\\nTMTTTT\\n6\\nTTMMTT\\n\", \"5\\n3\\nTTM\\n3\\...
The student council has a shared document file. Every day, some members of the student council write the sequence TMT (short for Towa Maji Tenshi) in it. However, one day, the members somehow entered the sequence into the document at the same time, creating a jumbled mess. Therefore, it is Suguru Doujima's task to fig...
0.125
{"tests": "{\"inputs\": [\"5\\n7\\n?R???BR\\n7\\n???R???\\n1\\n?\\n1\\nB\\n10\\n?R??RB??B?\\n\", \"1\\n2\\n??\\n\", \"5\\n7\\n?R???BR\\n7\\n???R???\\n1\\n?\\n1\\nB\\n10\\n?R??RB??B?\\n\", \"1\\n2\\n??\\n\", \"5\\n7\\n?R???BR\\n7\\n???R???\\n1\\n?\\n1\\nB\\n10\\n?B??BR??R?\\n\", \"5\\n7\\n?B???RR\\n7\\n???R???\\n1\\n?\\...
As their story unravels, a timeless tale is told once again... Shirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, Shirahime comes up with a new simple puzzle and wants Mocha to solve them. However, these puzzles are too easy for Mocha to s...
0
{"tests": "{\"inputs\": [[\"LOL\"], [\"HOW R U\"], [\"WHERE DO U WANT 2 MEET L8R\"], [\"lol\"], [\"0\"], [\"ZER0\"], [\"1\"], [\"IS NE1 OUT THERE\"], [\"#\"], [\"#codewars #rocks\"]], \"outputs\": [[9], [13], [47], [9], [2], [11], [1], [31], [1], [36]]}", "source": "primeintellect"}
Prior to having fancy iPhones, teenagers would wear out their thumbs sending SMS messages on candybar-shaped feature phones with 3x4 numeric keypads. ------- ------- ------- | | | ABC | | DEF | | 1 | | 2 | | 3 | ------- ------- ------- ------- ------- ------- | GHI | | JKL | | MNO | ...
0
{"tests": "{\"inputs\": [\"10000\\n5000 3150\\n5000 5000\\n0 0\\n5000 1050\\n5000 3980\\n5000 210\\n5000 5000\\n5000 5000\\n0 0\\n5000 2100\\n5000 2100\\n5000 2100\\n29170\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 101000\\n100000 100000\\n10...
You want to go on a trip with a friend. However, friends who have a habit of spending money cannot easily save travel expenses. I don't know when my friends will go on a trip if they continue their current lives. So, if you want to travel early, you decide to create a program to help your friends save in a planned mann...
0
{"tests": "{\"inputs\": [\"3\\n3\\n1 10 100\\n1\\n1\\n2\\n2 4\\n\", \"1\\n100\\n74 14 24 45 22 9 49 78 79 20 60 1 31 91 32 39 90 5 42 57 30 58 64 68 12 11 86 8 3 38 76 17 98 26 85 92 56 65 89 66 36 87 23 67 13 48 15 47 81 73 63 50 34 93 82 44 77 69 96 100 41 19 35 16 88 27 99 40 62 95 70 18 46 21 53 59 37 6 61 71 2 4 5...
Masha and Grisha like studying sets of positive integers. One day Grisha has written a set A containing n different integers a_{i} on a blackboard. Now he asks Masha to create a set B containing n different integers b_{j} such that all n^2 integers that can be obtained by summing up a_{i} and b_{j} for all possible pa...
0
{"tests": "{\"inputs\": [\"4 5\\n1 3 5\\n3 4 6\\n4 2 7\\n2 1 18\\n2 3 17\", \"4 5\\n1 3 5\\n3 4 6\\n4 2 7\\n2 1 6\\n2 3 17\", \"4 5\\n1 3 5\\n3 2 6\\n4 2 7\\n2 1 18\\n2 3 12\", \"4 5\\n1 3 5\\n3 4 6\\n4 2 13\\n2 1 6\\n2 3 17\", \"4 1\\n1 3 5\\n3 2 6\\n4 2 7\\n2 1 18\\n2 3 12\", \"8 5\\n1 3 5\\n3 4 6\\n4 2 7\\n2 1 18\\n...
Problem F Pizza Delivery Alyssa is a college student, living in New Tsukuba City. All the streets in the city are one-way. A new social experiment starting tomorrow is on alternative traffic regulation reversing the one-way directions of street sections. Reversals will be on one single street section between two adjac...
0
{"tests": "{\"inputs\": [\"9\\n487264 453898 452366 383095 172725 168148 164570 141228 1\\n\", \"28\\n434419 433070 431479 424448 423449 392416 368998 367310 329030 316399 311541 302510 283863 262469 257928 248272 242310 217371 183364 172064 164154 131734 131169 117466 23544 19990 11006 1\\n\", \"58\\n3000000 2511334 2...
Billy investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amount of n coins of different face values, and the coins of each value are not limited in number. The task is to collect t...
0
{"tests": "{\"inputs\": [[2, 6, 2], [1, 5, 1], [1, 5, 3], [0, 15, 3], [16, 15, 3], [2, 24, 22], [2, 2, 2], [2, 2, 1], [1, 15, 3], [15, 1, 3]], \"outputs\": [[12], [15], [5], [45], [0], [26], [2], [2], [35], [0]]}", "source": "primeintellect"}
Your task is to make function, which returns the sum of a sequence of integers. The sequence is defined by 3 non-negative values: **begin**, **end**, **step**. If **begin** value is greater than the **end**, function should returns **0** *Examples* ~~~if-not:nasm ~~~ This is the first kata in the series: 1) Sum ...
0
{"tests": "{\"inputs\": [\"eternalalexandersookeustzeouuanisafqaqautomaton\\nnoiol\\n\", \"acacdddadaddcbbbbdacb\\nbabbbcadddacacdaddbdc\\n\", \"yz\\nzy\\n\", \"tqlrrtidhfpgevosrsya\\nysrsvgphitrrqtldfeoa\\n\", \"babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaabbabaabbaababababbaabaaabaaaaababbaabaaaaabaabbabaaababbbb...
Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future. <image> Kaavi has a string T of length m and a...
0.375
{"tests": "{\"inputs\": [[\"\"], [\"A\"], [\"AA\"], [\"AAAABBBCCDAABBB\"], [\"AADD\"], [\"AAD\"], [\"ADD\"], [\"ABBCcAD\"], [[1, 2, 3, 3]], [[\"a\", \"b\", \"b\"]]], \"outputs\": [[[]], [[\"A\"]], [[\"A\"]], [[\"A\", \"B\", \"C\", \"D\", \"A\", \"B\"]], [[\"A\", \"D\"]], [[\"A\", \"D\"]], [[\"A\", \"D\"]], [[\"A\", \"B...
Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements. For example: ```python unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B'] unique_in_order('...
0
{"tests": "{\"inputs\": [\"3\\n3 4 1\", \"5\\n2 1 2 1 2\", \"5\\n2 1 1 1 2\", \"5\\n3 1 1 1 1\", \"3\\n1 3 4\", \"3\\n3 5 1\", \"5\\n2 1 2 2 2\", \"3\\n3 5 2\", \"5\\n3 1 2 2 2\", \"3\\n3 5 3\", \"5\\n6 1 2 2 2\", \"3\\n3 7 3\", \"5\\n1 1 2 2 2\", \"3\\n3 1 3\", \"5\\n1 1 2 1 2\", \"5\\n1 1 2 1 4\", \"3\\n3 3 1\", \"5\...
There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S_1<S_2<...<S_N holds lexicographically, where S_i is the i-th string from the left. At least how many different characters are contained in ...
0
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n\", \"8 1\\n8 2\\n2 5\\n5 1\\n7 2\\n2 4\\n3 5\\n5 6\\n\", \"5 1\\n4 1\\n3 1\\n5 1\\n1 2\\n\", \"25 2\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n2 7\\n3 8\\n3 9\\n3 10\\n4 11\\n4 12\\n4 13\\n4 14\\n14 15\\n14 16\\n14 17\\n4 18\\n18 19\\n18 20\\n18 21\\n1 22\\n22 23\\n22 24\\n22 25\\n\", \"33 ...
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog. Let us define k-multihedgehog as fol...
0
{"tests": "{\"inputs\": [\"7\\n1\\n2\\n6\\n13\\n14\\n3620\\n10000\\n\", \"100\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n16\\n17\\n18\\n19\\n20\\n21\\n22\\n23\\n24\\n25\\n26\\n27\\n28\\n29\\n30\\n31\\n32\\n33\\n34\\n35\\n36\\n37\\n38\\n39\\n40\\n41\\n42\\n43\\n44\\n45\\n46\\n47\\n48\\n49\\n50\\...
The only difference between easy and hard versions is the maximum value of $n$. You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$. The positive integer is called good if it can be represented as a sum of distinct powers ...
0
{"tests": "{\"inputs\": [[\"coverage\"], [\"coverage coverage\"], [\"nothing\"], [\"double space \"], [\"covfefe\"]], \"outputs\": [[\"covfefe\"], [\"covfefe covfefe\"], [\"nothing covfefe\"], [\"double space covfefe\"], [\"covfefe covfefe\"]]}", "source": "primeintellect"}
# Covfefe Your are given a string. You must replace the word(s) `coverage` by `covfefe`, however, if you don't find the word `coverage` in the string, you must add `covfefe` at the end of the string with a leading space. For the languages where the string is not immutable (such as ruby), don't modify the given strin...
0
{"tests": "{\"inputs\": [\"10\\njcfdh 1000000\\nchk 1000000\\nkga 1000000\\nbeh 1000000\\ngeg 1000000\\nhaj 1000000\\nagah 1000000\\ndhk 1000000\\nhj 1000000\\ndb 1000000\\n5\\n1000000 1000000 1000000 1000000 1000000\\ndb\\n\", \"5\\nteamc 8\\nteamd 7\\nteame 15\\nteama 3\\nteamb 21\\n3\\n1 2 3\\nteamb\\n\", \"20\\ng 1...
Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game! n racers take part in the championship, which consists of a number of races. After each race racers are a...
0
{"tests": "{\"inputs\": [[30], [15], [9999], [35353], [100], [1000000243], [142042158218941532125212890], [2679388715912901287113185885289513476], [640614569414659959863091616350016384446719891887887380], [2579111107964987025047536361483312385374008248282655401675211033926782006920415224913494809688581314878892733564]]...
# Fourier transformations are hard. Fouriest transformations are harder. This Kata is based on the SMBC Comic on fourier transformations. A fourier transformation on a number is one that converts the number to a base in which it has more `4`s ( `10` in base `6` is `14`, which has `1` four as opposed to none, hence, f...
0
{"tests": "{\"inputs\": [[\"badpresent\", 3], [\"goodpresent\", 9], [\"crap\", 10], [\"bang\", 27], [\"dog\", 23]], \"outputs\": [[\"Take this back!\"], [\"pxxmy{n|nw}\"], [\"acpr\"], [\"300\"], [\"pass out from excitement 23 times\"]]}", "source": "primeintellect"}
Your colleagues have been good enough(?) to buy you a birthday gift. Even though it is your birthday and not theirs, they have decided to play pass the parcel with it so that everyone has an even chance of winning. There are multiple presents, and you will receive one, but not all are nice... One even explodes and cove...
0
{"tests": "{\"inputs\": [\"3\\n6\\n3 4 5 1 1 2\\n10\\n3 2 9 5 2 9 4 14 7 10\\n8\\n14 5 13 19 17 10 18 12\", \"3\\n6\\n3 4 5 1 1 2\\n10\\n3 2 9 5 2 9 4 14 7 10\\n8\\n9 5 13 19 17 10 18 12\", \"3\\n6\\n3 4 5 1 1 2\\n10\\n3 2 9 5 2 9 4 14 7 10\\n8\\n9 5 13 19 23 10 18 12\", \"3\\n6\\n3 4 5 1 1 2\\n10\\n3 2 9 5 2 3 4 14 7 ...
Read problems statements in Mandarin Chinese and Russian as well. As every other little boy, Mike has a favorite toy to play with. Mike's favorite toy is a set of N disks. The boy likes to compose his disks in stacks, but there's one very important rule: the disks in a single stack must be ordered by their radiuses i...
0
{"tests": "{\"inputs\": [\"10\\n1 1 1 2 1 1 1 2 2 2\\n\", \"1\\n2\\n\", \"10\\n1 1 1 1 2 2 2 2 2 2\\n\", \"5\\n2 1 1 1 1\\n\", \"4\\n1 1 1 1\\n\", \"5\\n1 2 2 2 2\\n\", \"214\\n1 2 2 1 1 1 2 2 2 2 1 1 1 2 2 2 2 2 2 1 2 1 1 2 2 1 1 2 2 2 2 1 2 2 2 1 1 2 2 2 1 1 2 2 1 2 2 2 1 1 2 1 1 2 1 1 1 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2...
We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a single number written on it — either 1 or 2. However, there is one condition you must fulfill in order to receive the prize. You will need to put all the tiles from the bag in a sequence, in a...
0
{"tests": "{\"inputs\": [\"76.820252 66.709341\\n61.392328 82.684207\\n44.267775 -2.378694\\n\", \"6.949504 69.606390\\n26.139268 72.136945\\n24.032442 57.407195\\n\", \"36.856072 121.845502\\n46.453956 109.898647\\n-30.047767 77.590282\\n\", \"-7.347450 36.971423\\n84.498728 89.423536\\n75.469963 98.022482\\n\", \"88....
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a spec...
0
{"tests": "{\"inputs\": [\"13\\n\", \"396\\n\", \"998\\n\", \"23333\\n\", \"8\\n\", \"49997\\n\", \"33\\n\", \"5\\n\", \"831\\n\", \"3939\\n\", \"10492\\n\", \"12\\n\", \"30000\\n\", \"20\\n\", \"1000\\n\", \"17\\n\", \"11\\n\", \"10001\\n\", \"49999\\n\", \"10000\\n\", \"14\\n\", \"99\\n\", \"1317\\n\", \"418\\n\", \"...
The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days. On the rim of the Floral Clock are 2n flowers, numbered from 1 to 2n clockwise, each of which has a colour among all n possible ones. For each colour, the...
0
{"tests": "{\"inputs\": [[\"1,2,3,4,5\"], [\"21,12,23,34,45\"], [\"-1,-2,3,-4,-5\"], [\"1,2,3,,,4,,5,,,\"], [\",,,,,1,2,3,,,4,,5,,,\"], [\"\"], [\",,,,,,,,\"]], \"outputs\": [[[1, 2, 3, 4, 5]], [[21, 12, 23, 34, 45]], [[-1, -2, 3, -4, -5]], [[1, 2, 3, 4, 5]], [[1, 2, 3, 4, 5]], [[]], [[]]]}", "source": "primeintellect"...
Given a string containing a list of integers separated by commas, write the function string_to_int_list(s) that takes said string and returns a new list containing all integers present in the string, preserving the order. For example, give the string "-1,2,3,4,5", the function string_to_int_list() should return [-1,2,...
0
{"tests": "{\"inputs\": [\"10\\n802 0 10\\n814 0 4\\n820 1 4\\n826 1 4\\n832 3 5\\n838 5 5\\n845 7 3\\n849 10 3\\n853 14 4\\n857 18 3\\n3\\n0 0 5\\n8 0 5\\n8 8 5\\n3\\n0 0 5\\n7 3 6\\n16 0 5\\n9\\n0 3 5\\n8 0 8\\n19 2 8\\n23 14 6\\n23 21 6\\n23 28 6\\n19 40 8\\n8 42 8\\n0 39 5\\n11\\n0 0 5\\n8 0 5\\n18 8 10\\n8 16 5\\n...
There is a chain consisting of multiple circles on a plane. The first (last) circle of the chain only intersects with the next (previous) circle, and each intermediate circle intersects only with the two neighboring circles. Your task is to find the shortest path that satisfies the following conditions. * The path co...
0
{"tests": "{\"inputs\": [\"3 1\\n0\", \"6 2\\n1\\n6\", \"6 2\\n2\\n6\", \"3 0\\n0\", \"3 0\\n-1\", \"6 2\\n4\\n6\", \"6 2\\n5\\n6\", \"6 1\\n5\\n6\", \"6 1\\n3\\n6\", \"6 1\\n3\\n0\", \"7 1\\n3\\n0\", \"7 1\\n3\\n1\", \"7 1\\n5\\n1\", \"7 1\\n5\\n0\", \"7 2\\n5\\n0\", \"5 1\\n1\", \"6 2\\n0\\n5\", \"4 2\\n1\\n4\", \"6 ...
You are a secret agent from the Intelligence Center of Peacemaking Committee. You've just sneaked into a secret laboratory of an evil company, Automated Crime Machines. Your mission is to get a confidential document kept in the laboratory. To reach the document, you need to unlock the door to the safe where it is kept...
0.5
{"tests": "{\"inputs\": [\"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n3 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n4 1 7 3 4 5 6\\n3 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n6 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n4 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 5 7 6\\n2 1\\...
Santa has to send presents to the kids. He has a large stack of $n$ presents, numbered from $1$ to $n$; the topmost present has number $a_1$, the next present is $a_2$, and so on; the bottom present has number $a_n$. All numbers are distinct. Santa has a list of $m$ distinct presents he has to send: $b_1$, $b_2$, ...,...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]], [[1, 5, 2, 3, 1, 5, 2, 3, 1]], [[1, 5, 4, 8, 7, 11, 10, 14, 13]], [[0, 1]], [[4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4]], [[4, 5, 3, -2, -1, 0, -2, -7, -6]], [[4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5, 3...
In this kata, your task is to identify the pattern underlying a sequence of numbers. For example, if the sequence is [1, 2, 3, 4, 5], then the pattern is [1], since each number in the sequence is equal to the number preceding it, plus 1. See the test cases for more examples. A few more rules : pattern may contain neg...
0
{"tests": "{\"inputs\": [[12, 0, \"am\"], [12, 1, \"am\"], [12, 2, \"am\"], [12, 3, \"am\"], [12, 4, \"am\"], [12, 5, \"am\"], [12, 6, \"am\"], [12, 7, \"am\"], [12, 8, \"am\"], [12, 9, \"am\"], [12, 10, \"am\"], [12, 11, \"am\"], [12, 12, \"am\"], [12, 13, \"am\"], [12, 14, \"am\"], [12, 15, \"am\"], [12, 16, \"am\"],...
Converting a normal (12-hour) time like "8:30 am" or "8:30 pm" to 24-hour time (like "0830" or "2030") sounds easy enough, right? Well, let's see if you can do it! You will have to define a function named "to24hourtime", and you will be given an hour (always in the range of 1 to 12, inclusive), a minute (always in th...
0
{"tests": "{\"inputs\": [\"55\\n73792\\n39309\\n73808\\n47389\\n34803\\n87947\\n32460\\n14649\\n70151\\n35816\\n8272\\n78886\\n71345\\n61907\\n16977\\n85362\\n0\\n43792\\n8118\\n83254\\n89459\\n32230\\n87068\\n82617\\n94847\\n83528\\n37629\\n31438\\n97413\\n62260\\n13651\\n47564\\n43543\\n61292\\n51025\\n64106\\n0\\n19...
Dima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue and a deck. Inna wants her present to show Dima how great a programmer he is. For that, she is going to g...
0
{"tests": "{\"inputs\": [[[\"bitcoin\", \"take\", \"over\", \"the\", \"world\", \"maybe\", \"who\", \"knows\", \"perhaps\"]], [[\"turns\", \"out\", \"random\", \"test\", \"cases\", \"are\", \"easier\", \"than\", \"writing\", \"out\", \"basic\", \"ones\"]], [[\"lets\", \"talk\", \"about\", \"javascript\", \"the\", \"bes...
You will be given a vector of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value. The returned value must be a string, and have `"***"` between each of its letters. You should not remove or add elements from/to the array. Write your s...
0
{"tests": "{\"inputs\": [[\"\"], [\"127.0.0.1\"], [\"0.0.0.0\"], [\"255.255.255.255\"], [\"10.20.30.40\"], [\"10.256.30.40\"], [\"10.20.030.40\"], [\"127.0.1\"], [\"127.0.0.0.1\"], [\"..255.255\"], [\"127.0.0.1\\n\"], [\"\\n127.0.0.1\"], [\" 127.0.0.1\"], [\"127.0.0.1 \"], [\" 127.0.0.1 \"], [\"127.0.0.1.\"], [\".127.0...
Implement `String#ipv4_address?`, which should return true if given object is an IPv4 address - four numbers (0-255) separated by dots. It should only accept addresses in canonical representation, so no leading `0`s, spaces etc. Write your solution by modifying this code: ```python def ipv4_address(address): ``` ...
0
{"tests": "{\"inputs\": [\"1\\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\n\", \"4\\nANTON\\nNAAN\\nAAAAAA\\nOAANTTON\\n\", \"4\\nNOTNA\\nNAAN\\nAAAAAA\\nOAANTTON\\n\", \"4\\nNOTNA\\nNAAN\\nAAAAAA\\nOTANTAON\\n\", \"4\\nNOTNA\\nAANN\\nAAAAAA\\nOAANTTON\\n\", \"4\\nNOTNA\\nNAAN\\nAAAAAA\\nNOA...
After rejecting 10^{100} data structure problems, Errorgorn is very angry at Anton and decided to kill him. Anton's DNA can be represented as a string a which only contains the characters "ANTON" (there are only 4 distinct characters). Errorgorn can change Anton's DNA into string b which must be a permutation of a. ...
0
{"tests": "{\"inputs\": [[153], [370], [371], [407], [1634], [8208], [9474], [54748], [92727], [93084], [548834], [1741725], [4210818], [9800817], [9926315], [24678050], [88593477], [146511208], [472335975], [534494836], [912985153], [4679307774], [115132219018763992565095597973971522401]], \"outputs\": [[true], [true]...
A Narcissistic Number is a number of length n in which the sum of its digits to the power of n is equal to the original number. If this seems confusing, refer to the example below. Ex: 153, where n = 3 (number of digits in 153) 1^(3) + 5^(3) + 3^(3) = 153 Write a method is_narcissistic(i) (in Haskell: isNarcissistic ...
0
{"tests": "{\"inputs\": [\"10 1000000\\n307196 650096 355966 710719 99165 959865 500346 677478 614586 6538\\n\", \"4 0\\n1 4 4 4\\n\", \"3 4\\n1 2 7\\n\", \"10 20\\n6 4 7 10 4 5 5 3 7 10\\n\", \"2 0\\n182 2\\n\", \"4 100\\n1 1 10 10\\n\", \"4 42\\n1 1 1 1000000000\\n\", \"123 54564\\n38 44 41 42 59 3 95 15 45 32 44 69 ...
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly 1 coin from the richest person in the city and he will give it to t...
0
{"tests": "{\"inputs\": [[2, 222], [2, 77], [2700, 3000], [500, 999], [999, 2500]], \"outputs\": [[[22, 25, 27, 32, 33, 35, 52, 55, 57, 72, 75, 77]], [[22, 25, 27, 32, 33, 35, 52, 55, 57, 72, 75]], [[2722, 2723, 2725, 2727, 2732, 2733, 2735, 2737, 2752, 2755, 2757, 2772, 2773, 2775]], [[522, 525, 527, 532, 533, 535, 53...
You are given two positive integers `a` and `b` (`a < b <= 20000`). Complete the function which returns a list of all those numbers in the interval `[a, b)` whose digits are made up of prime numbers (`2, 3, 5, 7`) but which are not primes themselves. Be careful about your timing! Good luck :) Write your solution b...
0
{"tests": "{\"inputs\": [\"3\\n2 2 2\\n1 1 1\\n\", \"1\\n100000000 100000000 100000000\\n100000000\\n\", \"1\\n100000000 100000000 100000000\\n1\\n\", \"4\\n6 7 8\\n8 8 8 12\\n\", \"1\\n1 1 1\\n100000000\\n\", \"3\\n1 1 1\\n2 2 2\\n\", \"9\\n10 20 30\\n5 5 5 5 5 5 45 45 45\\n\", \"20\\n43 36 6\\n6 49 22 40 17 48 44 19 ...
Do you know the story about the three musketeers? Anyway, you must help them now. Richelimakieu is a cardinal in the city of Bearis. He found three brave warriors and called them the three musketeers. Athos has strength a, Borthos strength b, and Caramis has strength c. The year 2015 is almost over and there are stil...
0
{"tests": "{\"inputs\": [[\"H\"], [\"Cr\"], [\"C\"], [\"Br\"], [\"V\"]], \"outputs\": [[\"H -> 1s1\"], [\"Cr -> 1s2 2s2 2p6 3s2 3p6 3d5 4s1\"], [\"C -> 1s2 2s2 2p2\"], [\"Br -> 1s2 2s2 2p6 3s2 3p6 3d10 4s2 4p5\"], [\"V -> 1s2 2s2 2p6 3s2 3p6 3d3 4s2\"]]}", "source": "primeintellect"}
## Introduction Each chemical element in its neutral state has a specific number of electrons associated with it. This is represented by the **atomic number** which is noted by an integer number next to or above each element of the periodic table (as highlighted in the image above). As we move from left to right, st...
0
{"tests": "{\"inputs\": [\"3\\n4 6\\n.R....\\n......\\n......\\n.W....\\n4 4\\n.R.W\\n....\\n....\\n....\\n5 1\\nR\\nW\\nR\\nW\\nR\\n\", \"1\\n3 1\\n.\\nR\\n.\\n\", \"1\\n1 1\\n.\\n\", \"1\\n5 5\\n.....\\n.....\\n.....\\n.....\\n....W\\n\", \"1\\n5 5\\n.....\\n.....\\n.....\\n.....\\n....W\\n\", \"1\\n1 1\\n.\\n\", \"1...
Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag). You are given an $n \times m$ grid of "R", "W", and "." characters. "R" is red, "W" is white and "." is blank. The neighbours of a cell are those that share an edge with it ...
0.375
{"tests": "{\"inputs\": [\"3\\n2 0 0\\n1 1\\n10 1 0 0 1 0\", \"2\\n1 1\\n3 0\", \"2\\n1 1\\n2 0\", \"3\\n2 0 0\\n1 1\\n10 1 0 0 2 0\", \"2\\n1 0\\n2 0\", \"3\\n3 0 0\\n1 1\\n10 1 0 0 2 0\", \"2\\n1 1\\n2 -1\", \"3\\n3 0 0\\n1 1\\n10 2 0 0 2 0\", \"2\\n1 1\\n2 -2\", \"3\\n3 0 0\\n0 1\\n10 2 0 0 2 0\", \"2\\n1 1\\n0 -2\"...
Problem There are $ N $ Amidakuji with 3 vertical lines. No matter which line you start from, the Amidakuji that ends at the starting line is considered a good Amidakuji. You can select one or more Amidakuji and connect them vertically in any order. Output "yes" if you can make a good Amidakuji, otherwise output "no"....
0.125
{"tests": "{\"inputs\": [\"8 9 10 1 0\\n1 2 1\\n2 4 1\\n1 3 0\\n3 4 0\\n4 5 0\\n5 6 1\\n6 0 1\\n5 7 0\\n7 0 0\\n\", \"7 9 320 0 3\\n0 1 0\\n1 2 0\\n2 3 0\\n0 4 1\\n4 1 1\\n1 5 100\\n5 2 100\\n2 6 59\\n6 3 61\\n\", \"1000 1 5 999 0\\n0 999 0\\n\", \"4 5 7 0 3\\n0 1 0\\n1 2 3\\n2 3 0\\n0 2 5\\n1 3 5\\n\", \"5 5 3 0 2\\n0...
ZS the Coder has drawn an undirected graph of n vertices numbered from 0 to n - 1 and m edges between them. Each edge of the graph is weighted, each weight is a positive integer. The next day, ZS the Coder realized that some of the weights were erased! So he wants to reassign positive integer weight to each of the edg...
0
{"tests": "{\"inputs\": [\"24 32 6 2 7 4\\n\", \"45 62 28 48 28 50\\n\", \"100 32 71 12 71 22\\n\", \"57 85 29 40 29 69\\n\", \"95 28 50 12 50 13\\n\", \"5 4 1 1 5 4\\n\", \"100 100 1 1 100 100\\n\", \"51 76 50 5 45 76\\n\", \"37 100 33 13 32 30\\n\", \"47 91 36 61 32 63\\n\", \"28 7 17 5 11 6\\n\", \"1 2 1 1 1 2\\n\",...
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue. We'll describe ...
0