description
stringlengths
38
154k
category
stringclasses
5 values
solutions
stringlengths
13
289k
name
stringlengths
3
179
id
stringlengths
24
24
tags
listlengths
0
13
url
stringlengths
54
54
rank_name
stringclasses
8 values
To complete this kata you will have to finish a function that returns a string of characters which when printed resemble a Rubik's cube. The function is named `cube`, and it has one integer parameter (formal argument) `n`, for the dimensions of the cube. For example, when I call the function `cube(3)` it will return a string which when printed appears as so: ``` /\_\_\_\ /\/\_\_\_\ /\/\/\_\_\_\ \/\/\/_/_/_/ \/\/_/_/_/ \/_/_/_/ ``` There are no spaces to the right of the cube edges (same above and below the cube), and it must work for all dimensions greater than, or equal to one (technically 1 x 1 x 1): 1 x 1 x 1 ``` /\_\ \/_/ ``` 2 x 2 x 2 ``` /\_\_\ /\/\_\_\ \/\/_/_/ \/_/_/ ```
algorithms
def cube(n): top = "\n" . join(' ' * (n - i - 1) + '/\\' * (i + 1) + '_\\' * n for i in range(n)) bottom = "\n" . join(' ' * i + '\\/' * (n - i) + '_/' * n for i in range(n)) return top + '\n' + bottom
Rubik's Cube Art
6387ea2cf418c41d277f3ffa
[ "ASCII Art" ]
https://www.codewars.com/kata/6387ea2cf418c41d277f3ffa
7 kyu
<h2>Puzzle</h2> <p>If you don't know who <a href="https://en.wikipedia.org/wiki/Where%27s_Wally%3F">Waldo</a> is, he's a nice guy who likes to be in crowded places. But he's also a bit odd as he always likes to hide in plain sight. Can you spot Waldo in the crowd?</p> <h2>Task</h2> <p>Given <code>crowd</code>, an array of strings of equal length, representing a crowded place, return an array with two integers representing the coordinates <code>[y, x]</code> where Waldo can be found (<code>[0, 0]</code> is top-left, <code>y</code> being the row and <code>x</code> being the column ).</p> <h2>Examples</h2> <p>We've spotted Waldo a couple of times in the past. Below is what we found out. Note that he's been in much more crowded places lately.</p> <h4>#1 Waldo at the beach</h4> <p><code>" " Air " w " Air with a bird " w " Air with a bird "~~~~~~~~~~~~~" Sea ".~..~~.~~~..~" Waves on beach "...P......P.." Beach with some people "......P..P..." Beach with some people "..PW........." Beach with Waldo and presumably a friend next to him </code></p> <p>Unredacted report: Waldo can be found at <code>[7, 3]</code>, wearing his usual outfit</p> <h4>#2 Waldo visiting the Great Pyramid</h4> <p><code>" " Air " " Air " _ " Top of pyramid " _____ " Layer of pyramid " _________ " Layer of pyramid " B _______________ G GG " Ground layer of pyramid with several people, including Waldo </code></p> <p>Unredacted report: Waldo can be found at <code>[5, 2]</code>, wearing special clothes protecting him from the sun</p> <h3>Hints</h3> <p>- he isn't always wearing his usual clothes</p> <p>- why is there more than one bird in the first example ...</p>
games
from collections import defaultdict def find_waldo(crowd): d = defaultdict(list) for y, row in enumerate(crowd): for x, c in enumerate(row): if c . isalpha(): d[c]. append([y, x]) return next(v[0] for k, v in d . items() if len(v) == 1)
Where's Waldo?
638244fb08da6c61361d2c40
[ "Puzzles", "Strings", "Arrays", "Logic" ]
https://www.codewars.com/kata/638244fb08da6c61361d2c40
7 kyu
You are given a string with three lowercase letters ( `pattern` ). **Your Task** Implement a function `find_matched_by_pattern(pattern)` that returns a predicate function, testing a string input and returning `true` if the string is matching the pattern, `false` otherwise. A word is considered a match for a given pattern if the first occurrence of each letter of the pattern is found in the same order in the word. If a character in the pattern is duplicated, the same logic applies further. The pattern will always be a string of size 3. Example of use: ```python predicate = find_matched_by_pattern('acs') predicate('access') # True predicate('sacrifice') # False ``` Examples of inputs/outputs: ``` Pattern: Word: Match: acs access true ascces false scares false vvl veturvel true velivel false bmb bomb true babyboom false ```
algorithms
def find_matched_by_pattern(pattern): def f(s, p=pattern): for c in s: if c == p[0]: p = p[1:] elif c in p: break if not p: return True return False return f
Get match by pattern
637d1d6303109e000e0a3116
[ "Regular Expressions", "Strings" ]
https://www.codewars.com/kata/637d1d6303109e000e0a3116
6 kyu
# Context The Explosive Ordinance Disposal Unit of your country has found a small mine field near your town, and is planning to perform a **controlled detonation** of all of the mines. They have tasked you to write an algorithm that helps them find **all safe spots in the area**, as they want to build a temporal base in the area where all workers can rest safely. All mines they found are of a special kind, as they only release explosive charge in **four straight lines**, each pointing at a different cardinal point **(north, south, east and west)**. However, the charge stops spreading when it crosses a tree in its path because the charge is not strong enough to burn them. In the following diagram, ```M``` represents a mine, ```C``` represents the explosive charge released after its detonation, and ```T``` are the trees in the area: ``` . . . . . . . . . . . . . . . . . T . . . . . . T . . . . . . . . . . . . . C . . . . . T M . . . => . . T M C C C . . . . . . . . . . C . . . . . . . . . . . . . C . . . . . . T . . . . . . T . . . ``` # Task Write an algorithm that, given a mine field represented as an **array of arrays** of size ```M * N```, returns an **array of all safe positions** where workers can build their temporal base. As in the previous model, ```'M'``` represents mines, ```'T'``` represents trees, and ```'.'``` represents empty spaces where explosive charge can spread. The positions in the array **should be in "reading order"** (from left to right, and from up to down). For example: ``` [ ['.', '.', '.', '.', 'M'], . . . . M C C C C M ['.', 'M', '.', 'T', '.'], . M . T . C M C T C ['.', '.', 'T', '.', '.'], ==[represents]=> . . T . . ==[after explosion]=> . C T . C ['.', '.', 'M', '.', 'T'], . . M . T C C M C T ['.', '.', '.', '.', '.'] . . . . . . C C . . ] ``` This should return one of the two following arrays, depending on the language. Check sample test cases for more information. Also, **trees don't count as safe positions**. - ```[(2,0), (2,3), (4,0), (4,3), (4,4)] //For Python``` - ```[[2,0], [2,3], [4,0], [4,3], [4,4]] //For JS and other languages``` Return an empty array if there are no safe positions. # Note Mines will not stop explosive charge from spreading as trees do, and explosive charge won't erase mines it finds in its path. **Make sure you never override any mines in the field.**
algorithms
def safe_mine_field(mine_field): if mine_field: h, w = len(mine_field), len(mine_field[0]) for i, row in enumerate(mine_field): for j, x in enumerate(row): if x == 'M': for a, b in ((- 1, 0), (1, 0), (0, - 1), (0, 1)): k, l = i + a, j + b while 0 <= k < h and 0 <= l < w and 'M' != mine_field[k][l] != 'T': mine_field[k][l], k, l = 'C', k + a, l + b return [(i, j) for i, row in enumerate(mine_field) for j, x in enumerate(row) if x == '.']
Controlled Detonation Safety
63838c67bffec2000e951130
[ "Arrays", "Algorithms", "Puzzles" ]
https://www.codewars.com/kata/63838c67bffec2000e951130
6 kyu
Oh no!! You dropped your interpreter!? That didn't sound so good... Write a function that returns the Nth fibonacci number. The use of the character "(" and the words "while", "for" and "gmpy2" has been disabled (broken). You may only use up to 1000 letters in your solution. The use of one "(" is permited for the line "def fibo(..." it will only exactly work in that line and only once. feel free not to use it :) For your convenience the recursion limit has been raised. No test will be over 200 away from the last one starting at 0 and ending at around 5,000. The fibonacci sequence is defined as: ``` fibonacci(0) = 0 fibonacci(1) = 1 fibonacci(n) = fibonacci(n-1) + fibonacci(n-2) ``` happy coding
games
import numpy funny = numpy . matrix # Sorry funny . __class_getitem__ = numpy . matrix arr = funny[[[1, 1], [1, 0]]] funny . __class_getitem__ = arr . astype arr = funny[object] funny . __class_getitem__ = lambda v: v[0, 1] def fibo(n): return funny[arr * * n]
Fibonacci With a Broken Interpreter
637d054dca318e60ef4a3830
[ "Puzzles", "Restricted" ]
https://www.codewars.com/kata/637d054dca318e60ef4a3830
5 kyu
Write a function that accepts a string consisting only of ASCII letters and space(s) and returns that string in block letters of 5 characters width and 7 characters height, with one space between characters. ```if:cpp The string should be formatted in a way that shows the desired output via cpps' <code>std::cout</code> (see below for example). <b>There's a preloaded <code>std::map\<char, std::vector\<std::string\>\> alpha</code> which you can use. Keys are lower case letters and the space.</b> ``` ```if:javascript The string should be formatted in a way that when passed to Javascripts' <code>console.log()</code> function shows the desired output (see below for example). <b>There's a preloaded map called alpha which you can use. Keys are lower case letters and the space.</b> ``` ```if:typescript The string should be formatted in a way that when passed to TypeScripts' <code>console.log()</code> function shows the desired output (see below for example). <b>There's a preloaded map called alpha which you can use. Keys are lower case letters and the space.</b> ``` ```if:rust The string should be formatted in a way that when passed to Rusts' <code>println!()</code> function shows the desired output (see below for example). A preloaded hashmap `ALPHA: HashMap<char, [&str; 7]>` is provided, which maps each letter to an array of individual lines. ``` ```if:java The string should be formatted in a way that when passed to Javas' <code>System.out.println()</code> function shows the desired output (see below for example). ``` ```if:ruby The string should be formatted in a way that when passed to Rubys' <code>puts()</code> function shows the desired output (see below for example). <b>There's a preloaded Hash map called ALPHA which you can use. Keys are lower case letters and the space.</b> ``` ```if:python The string should be formatted in a way that when passed to Pythons' <code>print()</code> function shows the desired output (see below for example). <b>There's a preloaded dictionary called ALPHA which you can use. Keys are lower case letters and the space. Test failures are reformatted for easier debugging with the preloaded function <code>unbleach()</code>. </b> ``` ```if:scala The string should be formatted in a way that when passed to Scalas' <code>println</code> the function shows the desired output (see below for example). <b>There's a preloaded Map[Char, String] called alpha which you can use. Keys are lower case letters and space.</b> ``` ```if:kotlin The string should be formatted in a way that when passed to Kotlins' <code>println()</code> function shows the desired output (see below for example). <b>There's a preloaded hashMap called alpha which you can use. Keys are lower case letters and space.</b> ``` <ul> <li>The block letters should consist of corresponding capital letters.</li> <li>It's irrelevant whether input consists of lower or upper case letters.</li> <li>Any leading and/or trailing spaces in input should be ignored.</li> <li>Empty strings or such containing only spaces should return an empty string.</li> <li>The remaining spaces (between letters and/or words) are to be treated as any other character. This means that there will be six spaces in output for a space in input, or a multiple of six, if there were more spaces - plus the one from preceding character!</li> <li>Trailing spaces should be removed in the resulting string (and also in its' substrings!).</li> <li>In order to facilitate debugging, test failure messages mangle the output: spaces are replaced with the bullet character <code>U+2022</code>, while end-of-line characters <code>\n</code> are visible.</li> </ul> ```cpp std::cout << blockPrint("heLLo WorLD"); ``` ```javascript console.log(blockPrint("heLLo WorLD")); ``` ```typescript console.log(blockPrint("heLLo WorLD")); ``` ```java System.out.println(BlockLetterPrinter.blockPrint("heLLo WorLD")); ``` ```ruby puts(block_print('heLLo WorLD')) ``` ```python print(block_print('heLLo WorLD')) ``` ```rust println!(block_print("heLLo WorLD"); ``` ```scala println(blockPrint("heLLo WorLD")) ``` ```kotlin println(blockPrint("heLLo WorLD")) ``` should result in an output that looks like this: ``` H H EEEEE L L OOO W W OOO RRRR L DDDD H H E L L O O W W O O R R L D D H H E L L O O W W O O R R L D D HHHHH EEEEE L L O O W W W O O RRRR L D D H H E L L O O W W W O O R R L D D H H E L L O O W W W O O R R L D D H H EEEEE LLLLL LLLLL OOO W W OOO R R LLLLL DDDD ``` As most of the characters can be printed in many different ways (think of Q, F or W), here is what they're expected to look like: ``` AAA BBBB CCC DDDD EEEEE FFFFF GGG H H IIIII JJJJJ K K L M M N N OOO PPPP QQQ RRRR SSS TTTTT U U V V W W X X Y Y ZZZZZ A A B B C C D D E F G G H H I J K K L MM MM NN N O O P P Q Q R R S S T U U V V W W X X Y Y Z A A B B C D D E F G H H I J K K L M M M N N O O P P Q Q R R S T U U V V W W X X Y Y Z AAAAA BBBB C D D EEEEE FFFFF G GGG HHHHH I J KK L M M N N N O O PPPP Q Q RRRR SSS T U U V V W W W X Y Z A A B B C D D E F G G H H I J K K L M M N N O O P Q Q Q R R S T U U V V W W W X X Y Z A A B B C C D D E F G G H H I J K K L M M N NN O O P Q QQ R R S S T U U V V W W W X X Y Z A A BBBB CCC DDDD EEEEE F GGG H H IIIII JJJJ K K LLLLL M M N N OOO P QQQQ R R SSS T UUU V W W X X Y ZZZZZ ``` <font color="gold"><i>Please leave a rating if you liked this kata!</i></font> ```if:python After completing this kata you might want to check out the [\[code golf\]](https://www.codewars.com/kata/6391ead97f85a7bac7fd1c1b) version as well. ```
algorithms
LETTERS = '''\ AAA BBBB CCC DDDD EEEEE FFFFF GGG H H IIIII JJJJJ K K L M M N N OOO PPPP QQQ RRRR SSS TTTTT U U V V W W X X Y Y ZZZZZ A A B B C C D D E F G G H H I J K K L MM MM NN N O O P P Q Q R R S S T U U V V W W X X Y Y Z A A B B C D D E F G H H I J K K L M M M N N O O P P Q Q R R S T U U V V W W X X Y Y Z AAAAA BBBB C D D EEEEE FFFFF G GGG HHHHH I J KK L M M N N N O O PPPP Q Q RRRR SSS T U U V V W W W X Y Z A A B B C D D E F G G H H I J K K L M M N N O O P Q Q Q R R S T U U V V W W W X X Y Z A A B B C C D D E F G G H H I J K K L M M N NN O O P Q QQ R R S S T U U V V W W W X X Y Z A A BBBB CCC DDDD EEEEE F GGG H H IIIII JJJJ K K LLLLL M M N N OOO P QQQQ R R SSS T UUU V W W X X Y ZZZZZ\ ''' . split('\n') def block_print(s): return s . strip() and '\n' . join(" " . join(LETTERS[i][(c - 65) * 6:(c - 64) * 6 - 1] if c > 32 else " " * 5 for c in map(ord, s . strip(). upper())). rstrip() for i in range(7))
Block Letter Printer
6375587af84854823ccd0e90
[ "Strings", "ASCII Art", "Algorithms" ]
https://www.codewars.com/kata/6375587af84854823ccd0e90
6 kyu
Introduction ============ Not having to go to school or work on your birthday is always a treat, so when your birthday would have fallen on a weekend, it's really annoying if a leap year means you miss out. Some friends are discussing this and think they have missed out more than others, so they need your help. The Challenge ============= Given a list of friends, their dates of birth and the date of their conversation, work out who has had the most birthdays fall on a Saturday or Sunday up to and including the date of the conversation. If more than one friend shares that number of weekend birthdays, return the youngest. If the youngest shares their birthday with other friends, then any of the youngest will be accepted. When counting weekend days, don't include the day on which they were born - after all, they wouldn't have been familiar with the concept of a weekend right then! Friends born on 29th February celebrate their birthdays on 28th February in non-leap years. Example ======= The friends are provided as a sequence of pairs containing their name and their date of birth in the format YYYY-MM-DD. The date of their conversation is provided in the similar format. ```python most_weekend_birthdays([("Alice", "2010-11-10"), ("Bob", "2010-11-23")], "2022-12-31") ==> "Alice" ``` Alice has four birthdays falling on a weekend (Saturday in 2012 and 2018, Sunday in 2013 and 2019) compared to three for Bob (Saturday in 2013 and 2019, Sunday in 2014).
algorithms
from dateutil . parser import parse from dateutil . relativedelta import relativedelta def most_weekend_birthdays(friends, conversation_date): def func(args): count, year, birthday = 0, 1, parse(args[1]) while (current := birthday + relativedelta(years=year)) <= today: count += (current . weekday() >= 5) year += 1 return count, birthday today = parse(conversation_date) return max(friends, key=func)[0]
Weekend Birthdays
6375e9030ac764004a036840
[ "Date Time" ]
https://www.codewars.com/kata/6375e9030ac764004a036840
6 kyu
You just started working at a local cinema, and your first task is to write a function that returns the **showtimes of a specific movie**, given its **length**. In order to make your job easier, you will work with **24-hour format** throughout this kata. Your function receives three parameters, all of them being **integers**: - `open` - Hour at which the cinema opens. - `close` - Hour at which the cinema closes. - `length` - Length of the movie, in minutes. It must return an array of times, with each time being in the format `(hour, minute)`. For example, `(19, 30)` means 19:30, and `(2, 0)` means 02:00. **The last session in the array cannot end after the cinema closes.** Also, the times in the array must be sorted from earliest to latest. There's also a **15-minute window** between a session's end and the beginning of the following one, in order to give enough time for users to take a seat. For example, for a cinema opening at **13:00** and closing at **23:00** showing a **60-minute** movie, your function must return the following array: ``` >>> movie_times(13, 23, 60) [(13, 0), (14, 15), (15, 30), (16, 45), (18, 0), (19, 15), (20, 30), (21, 45)] ``` Note that the cinema might close at times such as **02:00** or **03:00**, meaning examples like this must also work: ``` >>> movie_times(16, 3, 75) [(16, 0), (17, 30), (19, 0), (20, 30), (22, 0), (23, 30), (1, 0)] ``` ***IMPORTANT:*** For languages other than Python, **just return an array of arrays.** See sample test cases for more info on how to return the list of times. ***NOTE:** This kata isn't meant to be too challenging, so opening times for all tests will be **12:00** or later, and closing times will always be **6:00** or earlier.* ***NOTE 2:** Midnight will be represented as (0, 0) or 0:00 in this kata, instead of 24:00.* Good luck!
algorithms
def movie_times(open, close, length): if close <= 6 or close < open: close += 24 r, t, u = [], open * 60, close * 60 while t + length <= u: r . append((t / / 60 % 24, t % 60)) t += length + 15 return r
Movie Showtimes
6376bbc66f2ae900343b7010
[ "Logic", "Date Time" ]
https://www.codewars.com/kata/6376bbc66f2ae900343b7010
7 kyu
## Puzzle 12 bits, some are sleeping, some are awake. They are all tired and yearn for some sleep. One of them has to stay awake while all others can go to sleep. Can you figure out which one stays awake? ### Hints * _why exactly 12 bits? (perhaps there are realtime applications for this)_ * _fixed test cases will show some patterns and additional hints_
games
def sleep(bits: str) - > str: i = min(range(12), key=lambda i: (bits[i:] + bits[: i])[:: - 1]) return '0' * i + '1' + '0' * (11 - i)
12 Sleepy Bits
63753f7f64c31060a564e790
[ "Puzzles", "Algorithms", "Set Theory" ]
https://www.codewars.com/kata/63753f7f64c31060a564e790
6 kyu
Given a `string`, your task is to count the number and length of arrow symbols in that string and return an `int` using the following rules: - The string will only contain the characters `.`, `-`, `=`, `<`, `>`. - An arrow must start with either `<` or `>`. - Arrows are scored based on their length and direction, for example: - (Left-facing arrows are scored as negative, while Right-facing arrows are positive) - `> is scored as 1` - `-> is scored as 2` - `< is scored as -1` - `<- is scored as -2` - An arrow's tail (if it has one) must be entirely made up of either `-` or `=`. You cannot mix. - So, `-->` would be a valid arrow of length 3, but `=->` would only count `->` as a part of the arrow. - Additionally, arrows with a tail of `=` are scored twice as high as arrows with a tail of `-`, for example: - `--> is scored as 3` - `==> is scored as 6` - `<= is scored as -4` * Double-sided arrows, like `<->` or `<===>` are counted as `0`. * `.` is an empty character and cannot be the tail of an arrow. ## Examples ```python arrow_search('>.') # 1 arrow_search('<--..') # -3 arrow_search('><=><--') # -2 arrow_search('>===>->') # 11 ```
games
import re # regex is good, let's use it def arrow_search(string: str) - > int: return sum( # calculate sum of scores for each arrow # using the below method: len(arrow) # size of the arrow # multiplied by +1/-1 based on direction * ((">" in arrow) - ("<" in arrow)) * (2 if "=" in arrow else 1) # multiplied by 2 if it has a tail of "=" for arrow in re . findall( # for each arrow found """ # using the below regex: <?-+>? # arrow with "-" tail | # or <?=*>? # arrow with "=" tail """, string, re . VERBOSE) # in the input string )
Finding Arrows in a String
63744cbed39ec3376c84ff4a
[ "Strings" ]
https://www.codewars.com/kata/63744cbed39ec3376c84ff4a
6 kyu
In his book, _Gödel, Escher, Bach_, Douglas Hofstadter describes a sequence of numbers which begins: ``` 1, 3, 7, 12, 18, 26, 35, 45, 56, 69, 83, 98 .. (sequence A) ``` It has the following property: _**The sequence, together with its sequence of first differences (the differences between successive terms), lists all positive integers exactly once.**_ To illustrate this property, write down the first differences of the sequence `A`: ``` 2, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15 .. (sequence B) ``` and note that together, the sequences `A` and `B` list all positive integers. To calculate more terms we can first extend the sequence `B`: ``` 2, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19 .. ``` (We omit `18` as it occurs already in the sequence `A`). Then we can extend the sequence `A` by using the rule that `A(n) = A(n-1) + B(n-1)`: ``` 1, 3, 7, 12, 18, 26, 35, 45, 56, 69, 83, 98, (98+16) .. ``` Write a function which will return the `n`th term of the sequence `A`. For example: ```haskell hof 0 = 1 hof 1 = 3 hof 2 = 7 ``` etc. In the tests, values of `n` up to ```haskell 100 000 ``` ```javascript 1 000 000 ``` ```csharp 1 000 000 ``` ```lambdacalc 1 000 ``` ```python 1_000_000 ``` will be tested.
reference
from itertools import count def hofs(): yield 1 xs, ys, n, y = count(1), hofs(), 1, None while True: x, y = next(xs), y or next(ys) if x == y: yield (n := n + next(xs)) y = None else: yield (n := n + x) hofs_gen, hofs_cache = hofs(), [] def hof(n): while len(hofs_cache) <= n: hofs_cache . append(next(hofs_gen)) return hofs_cache[n]
Hofstadter's Figure-Figure sequence
636bebc1d446bf71b3f65fa4
[ "Lists", "Algorithms", "Recursion", "Performance" ]
https://www.codewars.com/kata/636bebc1d446bf71b3f65fa4
5 kyu
This is a very common case of operations counting. However, time is money. Given a function called `operations` that receives an Integer argument `number > 0` and does mathematical operations with it. Division and subtraction, division by 2 while the number is even, subtraction by 1 while the number is odd; how many of these arithmetic operations are going to take place till 0? Can you count it and return the correct answer without timing out? Make sure your code is performance efficient because some numbers up to 99 ^ 9999 are going to be passed in as the function argument. Hint: The solution could be written in the form (n + m + (n - 1)) Example: The number 12 returns 5: 1. 12 // 2 = 6 2. 6 // 2 = 3 3. 3 - 1 = 2 4. 2 // 2 = 1 5. 1 - 1 = 0 Five operations in total.
algorithms
def operations(x): return x . bit_count() + x . bit_length() - 1
Time Is Money (number of operations)
636b03830ae6cd00388cd228
[ "Algorithms" ]
https://www.codewars.com/kata/636b03830ae6cd00388cd228
6 kyu
You are a security guard at a large company, your job is to look over the cameras. Finding yourself bored you decide to make a game from the people walking in a hallway on one of the cameras. As many people walk past the hallway you decide to figure out the minimum steps it will take before 2 people cross or come into contact with each other (assuming every person takes a step at the same time). People are represented as arrows, ``<`` for a person moving left and ``>`` for a person moving right and ``-`` for an empty space ``A step represents a person moving forward one -, each person moves 1 step at the same time`` ``` in this example the first people to come in contact with each other do it after 1 step ---><---- ``` ``` in this example the first people to come in contact with each other do it after 1 step --->-<------->----<- ``` ``` in the case that no people come in contact return -1 ----<----->---- ```
games
import re def contact(hallway): pairs = re . findall('>-*<', hallway) return min(map(len, pairs)) / / 2 if pairs else - 1
Walking in the hallway
6368426ec94f16a1e7e137fc
[ "Fundamentals", "Strings", "Puzzles", "Algorithms" ]
https://www.codewars.com/kata/6368426ec94f16a1e7e137fc
7 kyu
In the [On-line Encyclopedia of Integer Sequences](https://oeis.org/) a sequence [A112382](https://oeis.org/A112382) which begins ``` 1, 1, 2, 1, 3, 4, 2, 5, 1, 6, 7, 8, 3, 9, 10, 11, 12, 4, 13, 14, 2, 15, 16, 17, 18, 19, 5, 20, .. ``` is described. It is a fractal sequence because it contains every positive integer and also contains a copy of itself as a proper subsequence - this can be seen by deleting the first occurrence of each number from the sequence. The remaining terms will be a copy of the original. For example, deleting the first occurrence of each integer from the list above (replacing them with an `X`) gives: ``` X, 1, X, 1, X, X, 2, X, 1, X, X, X, 3, X, X, X, X, 4, X, X, 2, X, X, X, X, X, 5, X, .. ``` The remaining list begins: ``` 1, 1, 2, 1, 3, 4, 2, 5,.. ``` the same as the original. The sequence is self-descriptive in that each element gives the number of first occurrences of integers (`X`s in the example above) that were removed just before it. Write a function which will return the `n`th term of the sequence described above. For example ```haskell a112382 0 = 1 a112382 1 = 1 a112382 2 = 2 ``` etc. In the tests, values of `n` up to ```haskell 100 000 ``` ```lambdacalc 1 000 ``` will be tested.
reference
from itertools import count, islice def sequence(): cnt, seq = count(1), sequence() while 1: yield next(cnt) n = next(seq) yield from islice(cnt, n - 1) yield n a112382 = list(islice(sequence(), 1_000_000)). __getitem__
A self-descriptive fractal sequence
6363b0c4a93345115c7219cc
[ "Algorithms", "Lists", "Number Theory", "Recursion" ]
https://www.codewars.com/kata/6363b0c4a93345115c7219cc
5 kyu
# Back and Forth: You are carrying boxes between 2 locations, to be easy, we call them `first` and `second`. You will receive a list of numbers as input, called `lst`. You are moving back and forth between `first` and `second`, carrying that amount of boxes to the other side. You always start from `first`. See the following: ``` You move from first to second. v v [1, 2, 3, 4] ^ ^ You move from second to first. ``` ___ # How Many Boxes: Before you carry the boxes, you have to have boxes there to carry, __and the boxes can be used more than once.__ In the above example, we have 2 boxes at `first` and 2 boxes at `second`, note as `(2, 2)`, and here is how it goes: ``` (2, 2), 1 box was moved to the second(right), get (1, 3) (1, 3), 2 boxes were moved to the first(left), get (3, 1) (3, 1), 3 boxes were moved to the second(right), get (0, 4) (0, 4), 4 boxes were moved to the first(left), get (4, 0) ``` __If you have less than 2 boxes at any side, you will run out of boxes while carrying.__ Your task is to find out the `minimum amount` of boxes you need to have at each side, so you won't run out of boxes while carrying the boxes. Return the minimum amount for each side in a tuple(or any similar data type in the language), first element is the amount for `first`, second element is the amount for `second`. ___ # Performance: * 0 <= length of lst <= 100 * 0 <= element of lst <= 200, upper bound may be varied with different languages As the numbers in random tests will get up to certain size(see above), solution with naive brute force approach will time out. ___ # Examples: __Input -> Output__ ``` [] -> (0, 0) [0] -> (0, 0) [3] -> (3, 0) [0, 2] -> (0, 2) [1, 2, 3, 4] -> (2, 2) [4, 3, 2, 1] -> (4, 0) [3, 0, 3] -> (6, 0) [3, 1, 3] -> (5, 0) ```
games
def minimum_amount(lst): f = s = r1 = r2 = 0 for i, x in enumerate(lst): if i % 2: f, s = f + x, s - x r2 = max(r2, - s) else: f, s = f - x, s + x r1 = max(r1, - f) return r1, r2
Back and Forth: How Many for Each Side?
63624a696137b6000ed726a6
[ "Puzzles", "Logic", "Algorithms", "Performance" ]
https://www.codewars.com/kata/63624a696137b6000ed726a6
6 kyu
## Overview This is a simple "chess themed" algorithmic puzzle - but you don't need to know anything about chess to solve it, other than 3 basic moves. The game is played between two players who take turns moving a piece on the board: Player 1, **who always plays the first move,** and Player 2. The game takes place on a 5x5 board, and **at all times there is only 1 single piece on the board - it is either a Rook, a Bishop, or a Queen.** (Quick reminder: the Rook can move horizontally or vertically, the Bishop can move diagonally, the Queen can move horizontally or vertically or diagonally). The winner is the Player who, on their turn, moves the current piece to any of the board's 4 corner squares. Gameplay is simple - after a Player moves the current piece, they either: - win the game, if they managed to move the current piece to any of the board's 4 corner squares. - or, if they do not win on their turn, **the piece will automatically transform into the "next" piece according to the following repeating cyclic pattern, and the other Player then takes their turn (from the current position on the 5x5 board):** ``` repeating 3-cyclic pattern: Rook ---> Bishop ^ / \ v Queen ``` Given the starting piece (Rook, Bishop, or Queen) and a starting location for the piece, **and assuming both players play optimally**, your goal is to determine whether Player 1 has a **guaranteed** win, a **guaranteed** loss, or if the game will become an infinite never-ending **guaranteed** draw. (For the purposes of this kata, "playing optimally" means that: [both Players will attempt to win the game, if there is any combination of moves that will allow them to do so, and conversely will avoid any move that can lead to them losing.](https://en.wikipedia.org/wiki/Combinatorial_game_theory)) --- ## Inputs and Outputs You will be given `starting_piece`, which is a `string`representing the piece that is on the board when the game starts, 1 of 3 possibilities: - `'r'` representing the Rook - `'b'` representing the Bishop - `'q'` representing the Queen You will also be given `starting_row` and `starting_column`, both are `ints` from `0` to `4` inclusive: for example `starting_row == 0` and `starting_column == 0` means that the piece starts in the top-left square of the 5x5 board. We use standard "array row and column" indexing to encode the 5x5 board, as represented in the diagram below: ``` 'r=0, c=0' | 'r=0, c=1' | 'r=0, c=2' | 'r=0, c=3' | 'r=0, c=4' <--- row 0 'r=1, c=0' | 'r=1, c=1' | 'r=1, c=2' | 'r=1, c=3' | 'r=1, c=4' 'r=2, c=0' | 'r=2, c=1' | 'r=2, c=2' | 'r=2, c=3' | 'r=2, c=4' 'r=3, c=0' | 'r=3, c=1' | 'r=3, c=2' | 'r=3, c=3' | 'r=3, c=4' 'r=4, c=0' | 'r=4, c=1' | 'r=4, c=2' | 'r=4, c=3' | 'r=4, c=4' <--- row 4 ^ ^ | | column 0 column 4 ``` You must return a `string`: `'win'`, `'lose'`, or `'draw'` depending on whether Player 1 (who always goes first) has a **guaranteed** win, loss, or draw. Remember - to win the game, the current player just needs to move the current piece to any of the 4 corners: (0,0), (0,4), (4,0), (4,4). --- ## Examples ``` Example 1 _'r'_ _ _ <--- row 0 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ^ | column 1 ``` In the above example game, the piece starts as a Rook, `'r'`, and in `starting_row == 0`, `starting_column == 1`. Here Player 1 has a **guaranteed** winning strategy - the winning strategy is: Player 1 moves the Rook from square (0,1) to corner square (0,0) or (0,4) and immediately wins the game, without even letting Player 2 play a single move. So the expected answer for `starting_piece == 'r'`, `starting_row == 0`, `starting_column == 1` is `'win'`. ``` Example 2 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _'b'_ ``` In the above example game, the piece starts as a Bishop, `'b'`, and in `starting_row == 4`, `starting_column == 3`. Unlike for the previous example, where Player 1 had a guaranteed win immediately, here Player 1 **can't win immediately on their first turn**. So Player 1 needs to try to make a move with the Bishop so that Player 2 **can't win** when they take their turn (which will be with the Queen, since that is the piece "after" the `'b'` Bishop). You should be able to analyse the various possibilities from here on ;) --- ## Similar katas If you like chess katas, I highly recommend [Is the King in check ?](https://www.codewars.com/kata/5e28ae347036fa001a504bbe) by @trashy_incel If you want a weirder and, more challenging, chess themed puzzle, check out [Evil genius game - Find the moving chess piece while blindfolded](https://www.codewars.com/kata/62e068c14129156a2e0df46a) by yours truly ;)
games
tbl = { 'r': [ [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], ], 'b': [ [1, 0, - 1, 0, 1], [0, 1, 0, 1, 0], [- 1, 0, 1, 0, - 1], [0, 1, 0, 1, 0], [1, 0, - 1, 0, 1], ], 'q': [ [1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1], ] } # starting_piece: a string, either 'r', 'b', 'q' # starting_row: an integer from 0 to 4 inclusive # starting_column: an integer from 0 to 4 inclusive def transforming_chess(starting_piece, starting_row, starting_column): # you must return one of three strings: # 'win' if Player 1 has a guaranteed win # 'lose' if Player 1 is guaranteed to lose # 'draw' if the game is a never-ending infinite draw return ['draw', 'win', 'lose'][tbl[starting_piece][starting_row][starting_column]]
Transforming Chess Piece Puzzle
635d9b5c8f20017aa1cf2cf6
[ "Puzzles", "Games", "Logic" ]
https://www.codewars.com/kata/635d9b5c8f20017aa1cf2cf6
7 kyu
For this kata, you need to build two regex strings to paint dogs and cats blue. Each of the given inputs will be a word of mixed case characters followed by either `cat` or `dog`. The string will be matched and replaced by the respective expressions. `search` will be used to capture the given strings. For example: ``` grey dog Fast cat qWeRtY cat blue dog ``` The other will be used to replace the first word with `blue`, but retaining the original animal: ``` grey dog => blue dog Fast cat => blue cat qWeRtY cat => blue cat blue dog => blue dog ``` Good luck! *P.S: both search and substitute must be returned as strings.*
games
search = ".+(?= (dog|cat))" substitute = "blue"
Painting Pets Blue (with regex)
6361bdb5d41160000ee6db86
[ "Strings", "Regular Expressions" ]
https://www.codewars.com/kata/6361bdb5d41160000ee6db86
7 kyu
You are a robot. As a robot, you are programmed to take walks following a path. The path is input to you as a string of the following characters where: * `"^"` -> step up * `"v"` -> step down * `">"` -> step right * `"<"` -> step left For example, a valid path would look like: ``` "^^vv>><<^v>" ``` However, you are a robot that cannot understand this string of characters just by looking at it. You need detailed instructions on how to follow the path. Your objective is to write a program to translate the input path to a set of detailed and readable instructions that even a robot like you could understand. To do this, you must translate the previous example ``` "^^vvvv>><<^v>" ``` to a "line feed separated string" equivalent to: ``` Take 2 steps up Take 4 steps down Take 2 steps right Take 2 steps left Take 1 step up Take 1 step down Take 1 step right ``` Notice that groups of the same characters translate to one instruction only, telling you to take multiple steps. Notes: * The input path will NEVER contain invalid characters, only the four characters for the directions. * The instruction lines are separated only by a newline (`"\n"`) character. This character is not present at the beginning of the first instruction line nor at the end of the last instruction line. * An empty path with no characters should output a `"Paused"` string meaning that you, the robot, are not supposed to move anywhere and are in a paused state.
games
from itertools import groupby DIRS = {'^': 'up', 'v': 'down', '<': 'left', '>': 'right'} def walk(path): if not path: return 'Paused' steps = [] for k, g in groupby(path): l = len(list(g)) steps . append(f"Take { l } step { 's' * ( l > 1 )} { DIRS [ k ]} ") return '\n' . join(steps)
You are a Robot: Translating a Path
636173d79cf0de003d6834e4
[ "Strings", "Algorithms" ]
https://www.codewars.com/kata/636173d79cf0de003d6834e4
6 kyu
<h1>The Task</h1> <p><i>Please read the introduction below if you are not familiar with the concepts you are being presented in this task.</i></p> <p>Given a root note and a color, return a list of notes that represent the chord.</p> <p>Input arguments: <li> <ul>root: the root note of the chord; concatenation of the degree (C, D, E, F, G, A, B) and optionally the accidental (b, #)</ul> <ul>color: the type of chord; (m, M, dim, aug); m -> minor chord, M -> major chord, dim -> diminished chord, aug -> augmented chord</ul> </li> </p> <p>Result value: <li> <ul>chord: a list of 3 notes that make up a tertian triad (optional accidentals; bb, b, # or x); a tertian triad is a chord consisting of 3 notes that stacks intervals of <i>thirds</i>.</ul> </li> </p> <h4>Implementation notes</h4> <p> <li> <ul>Rather than using the accidentals ♯ and ♭, we'll use the following ASCII-friendly notation: bb (instead of ♭♭), b (instead of ♭), # (instead of ♯) and x (instead of ♯♯). </ul> <ul>You will not be asked to deal with notes with more than 2 flats or sharps. For this reason, B# aug will be omitted from test cases, as its 5th is triply augmented (F#x or F###). </ul> <ul>You will need to use the correct degrees; enharmonic equivalence is not allowed in this kata. For instance: C m -> (C, Eb, G) OK, but (C, D#, G) not OK. The interval from C to D# is not a 3th, it's an augmented 2nd. </ul> </li> </p> <h1>Introduction</h1> <p><i>This chapter explains some basic concepts from music theory and notation. Feel free to skip this if you have sufficient knowledge in this field.</i></p> <details> <summary>Musical Note</summary> <p>On a modern piano there are 12 semitones in each octave. We call these the chromatic pitch class set. C major scale consist of 7 notes, each associated with a unique pitch class, and they correspond to the white keys on a piano.</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-0lax{text-align:left;vertical-align:top} .tg .tg-fjir{background-color:#343434;color:#ffffff;text-align:left;vertical-align:top} </style> </p><table class="tg"> <thead> <tr> <th class="tg-0lax">Chromatic pitch classes</th> <th class="tg-0lax">0</th> <th class="tg-0lax">1</th> <th class="tg-0lax">2</th> <th class="tg-0lax">3</th> <th class="tg-0lax">4</th> <th class="tg-0lax">5</th> <th class="tg-0lax">6</th> <th class="tg-0lax">7</th> <th class="tg-0lax">8</th> <th class="tg-0lax">9</th> <th class="tg-0lax">10</th> <th class="tg-0lax">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0lax">Piano keys</td> <td class="tg-0lax">W</td> <td class="tg-fjir">B</td> <td class="tg-0lax">W</td> <td class="tg-fjir">B</td> <td class="tg-0lax">W</td> <td class="tg-0lax">W</td> <td class="tg-fjir">B</td> <td class="tg-0lax">W</td> <td class="tg-fjir">B</td> <td class="tg-0lax">W</td> <td class="tg-fjir">B</td> <td class="tg-0lax">W</td> </tr> <tr> <td class="tg-0lax">C major scale</td> <td class="tg-0lax">C</td> <td class="tg-0lax"></td> <td class="tg-0lax">D</td> <td class="tg-0lax"></td> <td class="tg-0lax">E</td> <td class="tg-0lax">F</td> <td class="tg-0lax"></td> <td class="tg-0lax">G</td> <td class="tg-0lax"></td> <td class="tg-0lax">A</td> <td class="tg-0lax"></td> <td class="tg-0lax">B</td> </tr> </tbody> </table><p></p> <p>Notice that the 5 black keys are not part of the scale. If we want to use such note, we need to take another note, and add sharps or flats to it until the pitch class matches the intended note.</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-j8c8{background-color:#343434;border-color:inherit;color:#ffffff;text-align:left;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} .tg .tg-0lax{text-align:left;vertical-align:top} </style> </p><table class="tg"> <thead> <tr> <th class="tg-0pky">Chromatic pitch classes</th> <th class="tg-0pky">0</th> <th class="tg-0pky">1</th> <th class="tg-0pky">2</th> <th class="tg-0pky">3</th> <th class="tg-0pky">4</th> <th class="tg-0pky">5</th> <th class="tg-0pky">6</th> <th class="tg-0pky">7</th> <th class="tg-0pky">8</th> <th class="tg-0pky">9</th> <th class="tg-0pky">10</th> <th class="tg-0pky">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0pky">Piano keys</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> </tr> <tr> <td class="tg-0pky">C major scale</td> <td class="tg-0pky">C</td> <td class="tg-0pky"></td> <td class="tg-0pky">D</td> <td class="tg-0pky"></td> <td class="tg-0pky">E</td> <td class="tg-0pky">F</td> <td class="tg-0pky"></td> <td class="tg-0pky">G</td> <td class="tg-0pky"></td> <td class="tg-0pky">A</td> <td class="tg-0pky"></td> <td class="tg-0pky">B</td> </tr> <tr> <td class="tg-0lax">Ascending notes</td> <td class="tg-0lax"></td> <td class="tg-0lax">C♯</td> <td class="tg-0lax"></td> <td class="tg-0lax">D♯</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">F♯</td> <td class="tg-0lax"></td> <td class="tg-0lax">G♯</td> <td class="tg-0lax"></td> <td class="tg-0lax">A♯</td> <td class="tg-0lax"></td> </tr> <tr> <td class="tg-0lax">Descending notes</td> <td class="tg-0lax"></td> <td class="tg-0lax">D♭</td> <td class="tg-0lax"></td> <td class="tg-0lax">E♭</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">G♭</td> <td class="tg-0lax"></td> <td class="tg-0lax">A♭</td> <td class="tg-0lax"></td> <td class="tg-0lax">B♭</td> <td class="tg-0lax"></td> </tr> </tbody> </table><p></p> <p>In fact, we can name each note in function of any degree. For example, we can use C as reference note. In practice, we'll never do this, but this shows how many times we can flatten or sharpen a note to get another note with the same degree.</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-j8c8{background-color:#343434;border-color:inherit;color:#ffffff;text-align:left;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} .tg .tg-0lax{text-align:left;vertical-align:top} </style> </p><table class="tg"> <thead> <tr> <th class="tg-0pky">Chromatic pitch classes</th> <th class="tg-0pky">0</th> <th class="tg-0pky">1</th> <th class="tg-0pky">2</th> <th class="tg-0pky">3</th> <th class="tg-0pky">4</th> <th class="tg-0pky">5</th> <th class="tg-0pky">6</th> <th class="tg-0pky">7</th> <th class="tg-0pky">8</th> <th class="tg-0pky">9</th> <th class="tg-0pky">10</th> <th class="tg-0pky">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0pky">Piano keys</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> </tr> <tr> <td class="tg-0pky">C major scale</td> <td class="tg-0pky">C</td> <td class="tg-0pky"></td> <td class="tg-0pky">D</td> <td class="tg-0pky"></td> <td class="tg-0pky">E</td> <td class="tg-0pky">F</td> <td class="tg-0pky"></td> <td class="tg-0pky">G</td> <td class="tg-0pky"></td> <td class="tg-0pky">A</td> <td class="tg-0pky"></td> <td class="tg-0pky">B</td> </tr> <tr> <td class="tg-0lax">In function of note C</td> <td class="tg-0lax">C</td> <td class="tg-0lax">C♯</td> <td class="tg-0lax">C♯♯</td> <td class="tg-0lax">C♯♯♯</td> <td class="tg-0lax">C♯♯♯♯</td> <td class="tg-0lax">C♯♯♯♯♯</td> <td class="tg-0lax">C♯♯♯♯♯♯</td> <td class="tg-0lax">C♭♭♭♭♭</td> <td class="tg-0lax">C♭♭♭♭</td> <td class="tg-0lax">C♭♭♭</td> <td class="tg-0lax">C♭♭</td> <td class="tg-0lax">C♭</td> </tr> </tbody> </table><p></p> </details> <details> <summary>Musical Interval</summary> <p><i>For this kata, only the m3, M3, dim5, p5 and aug5 are important.</i></p> <p>An interval is the range from one note to another. Each interval has 2 properties; the degree interval and the pitch (class) interval. For instance from C to D♯; the degree interval is 2, because D is a second degree away from C (C being a first degree interval of itself), and the pitch class interval is 3, because these notes are 3 semitones or pitches away from eachother. We call the interval from C to D♯ an augmented second (aug2). Let's take another example, this time the interval C to E♭. The degree interval is 3, because E is a third degree away from C, and the pitch class interval is 3, because these notes are 3 semitones or pitches away from eachother. We call the interval from C to E♭ a minor third (m3). Notice that aug2 and m3 have the same number of semitones; these intervals are said to be enharmonic equivalents.</p> <p>Let's add the intervals to the key of C for each of the chromatic notes in our previous table. The 1st, 4th and 5th are called perfect (p). Flattening a perfect interval is called a diminished interval (dim). Sharpening a perfect interval is called an augmented interval (aug). The other degrees, being the 2nd, 3th, 6th and 7th come in pairs of a minor interval (m) and a major interval (M). Flattening a minor interval is called a diminished interval (dim). Sharpening a major interval is called an augmented interval (aug).</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-j8c8{background-color:#343434;border-color:inherit;color:#ffffff;text-align:left;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} .tg .tg-0lax{text-align:left;vertical-align:top} </style> <table class="tg"> <thead> <tr> <th class="tg-0pky">Chromatic pitch classes</th> <th class="tg-0pky">0</th> <th class="tg-0pky">1</th> <th class="tg-0pky">2</th> <th class="tg-0pky">3</th> <th class="tg-0pky">4</th> <th class="tg-0pky">5</th> <th class="tg-0pky">6</th> <th class="tg-0pky">7</th> <th class="tg-0pky">8</th> <th class="tg-0pky">9</th> <th class="tg-0pky">10</th> <th class="tg-0pky">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0pky">Piano keys</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> </tr> <tr> <td class="tg-0pky">C major scale</td> <td class="tg-0pky">C (p1)</td> <td class="tg-0pky"></td> <td class="tg-0pky">D (M2)</td> <td class="tg-0pky"></td> <td class="tg-0pky">E (M3)</td> <td class="tg-0pky">F (p4)</td> <td class="tg-0pky"></td> <td class="tg-0pky">G (p5)</td> <td class="tg-0pky"></td> <td class="tg-0pky">A (M6)</td> <td class="tg-0pky"></td> <td class="tg-0pky">B (M7)</td> </tr> <tr> <td class="tg-0lax">Ascending notes</td> <td class="tg-0lax"></td> <td class="tg-0lax">C♯ (aug1)</td> <td class="tg-0lax"></td> <td class="tg-0lax">D♯ (aug2)</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">F♯ (aug4)</td> <td class="tg-0lax"></td> <td class="tg-0lax">G♯ (aug5)</td> <td class="tg-0lax"></td> <td class="tg-0lax">A♯ (aug6)</td> <td class="tg-0lax"></td> </tr> <tr> <td class="tg-0lax">Descending notes</td> <td class="tg-0lax"></td> <td class="tg-0lax">D♭ (m2)</td> <td class="tg-0lax"></td> <td class="tg-0lax">E♭ (m3)</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">G♭ (dim5)</td> <td class="tg-0lax"></td> <td class="tg-0lax">A♭ (m6)</td> <td class="tg-0lax"></td> <td class="tg-0lax">B♭ (m7)</td> <td class="tg-0lax"></td> </tr> </tbody> </table></p> </details> <details> <summary>Musical Chord</summary> <p>A musical chord is a group of notes that together form a harmonic entity. There exist many kinds of chords, such as secundals, tertian chords, quartal chords, power chords and tone clusters. The chords we care about are tertian chords.</p> <p>A tertian chord consists of stacking 3th intervals together. The common chords minor, major, diminished, augmented, dominant 7th, minor 7th, etc. are all tertian chords.</p> <p>A triad is a chord consisting of 3 notes. This kata concerns the tertian triads: minor, major, diminished and augmented.</p> <h4>Major Chord</h4> <p>The major chord exists of a perfect 1st, a major 3th and perfect 5th. The intervals between consecutive notes are a major 3th and minor 3th.</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-j8c8{background-color:#343434;border-color:inherit;color:#ffffff;text-align:left;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} .tg .tg-0lax{text-align:left;vertical-align:top} </style> <table class="tg"> <thead> <tr> <th class="tg-0pky">Chromatic pitch classes</th> <th class="tg-0pky">0</th> <th class="tg-0pky">1</th> <th class="tg-0pky">2</th> <th class="tg-0pky">3</th> <th class="tg-0pky">4</th> <th class="tg-0pky">5</th> <th class="tg-0pky">6</th> <th class="tg-0pky">7</th> <th class="tg-0pky">8</th> <th class="tg-0pky">9</th> <th class="tg-0pky">10</th> <th class="tg-0pky">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0pky">Piano keys</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> </tr> <tr> <td class="tg-0pky">Major chord</td> <td class="tg-0pky">C</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">E</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">G</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> <tr> <td class="tg-0lax">Intervals</td> <td class="tg-0lax">p1</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">M3</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">p5</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> </tr> <tr> <td class="tg-0lax">Intervals between notes</td> <td class="tg-0lax">p1</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">M3</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">m3</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> </tr> </tbody> </table></p> <h4>Minor Chord</h4> <p>The minor chord exists of a perfect 1st, a minor 3th and perfect 5th. The intervals between consecutive notes are a minor 3th and major 3th.</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-j8c8{background-color:#343434;border-color:inherit;color:#ffffff;text-align:left;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} .tg .tg-0lax{text-align:left;vertical-align:top} </style> <table class="tg"> <thead> <tr> <th class="tg-0pky">Chromatic pitch classes</th> <th class="tg-0pky">0</th> <th class="tg-0pky">1</th> <th class="tg-0pky">2</th> <th class="tg-0pky">3</th> <th class="tg-0pky">4</th> <th class="tg-0pky">5</th> <th class="tg-0pky">6</th> <th class="tg-0pky">7</th> <th class="tg-0pky">8</th> <th class="tg-0pky">9</th> <th class="tg-0pky">10</th> <th class="tg-0pky">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0pky">Piano keys</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> </tr> <tr> <td class="tg-0pky">Minor chord</td> <td class="tg-0pky">C</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">E♭</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">G</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> <tr> <td class="tg-0lax">Intervals</td> <td class="tg-0lax">p1</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">m3</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">p5</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> </tr> <tr> <td class="tg-0lax">Intervals between notes</td> <td class="tg-0lax">p1</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">m3</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax">M3</td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> <td class="tg-0lax"></td> </tr> </tbody> </table></p> <h4>Diminished Chord</h4> <p>The diminished chord exists of a perfect 1st, a minor 3th and diminished 5th. The intervals between consecutive notes are a minor 3th and minor 3th.</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-j8c8{background-color:#343434;border-color:inherit;color:#ffffff;text-align:left;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} </style> <table class="tg"> <thead> <tr> <th class="tg-0pky">Chromatic pitch classes</th> <th class="tg-0pky">0</th> <th class="tg-0pky">1</th> <th class="tg-0pky">2</th> <th class="tg-0pky">3</th> <th class="tg-0pky">4</th> <th class="tg-0pky">5</th> <th class="tg-0pky">6</th> <th class="tg-0pky">7</th> <th class="tg-0pky">8</th> <th class="tg-0pky">9</th> <th class="tg-0pky">10</th> <th class="tg-0pky">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0pky">Piano keys</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> </tr> <tr> <td class="tg-0pky">Diminished chord</td> <td class="tg-0pky">C</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">E♭</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">G♭</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> <tr> <td class="tg-0pky">Intervals</td> <td class="tg-0pky">p1</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">m3</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">dim5</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> <tr> <td class="tg-0pky">Intervals between notes</td> <td class="tg-0pky">p1</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">m3</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">m3</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> </tbody> </table></p> <h4>Augmented Chord</h4> <p>The augmented chord exists of a perfect 1st, a major 3th and augmented 5th. The intervals between consecutive notes are a major 3th and major 3th.</p> <p><style type="text/css"> .tg {border-collapse:collapse;border-color:#ccc;border-spacing:0;} .tg td{background-color:#fff;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{background-color:#f0f0f0;border-color:#ccc;border-style:solid;border-width:1px;color:#333; font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-j8c8{background-color:#343434;border-color:inherit;color:#ffffff;text-align:left;vertical-align:top} .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} </style> <table class="tg"> <thead> <tr> <th class="tg-0pky">Chromatic pitch classes</th> <th class="tg-0pky">0</th> <th class="tg-0pky">1</th> <th class="tg-0pky">2</th> <th class="tg-0pky">3</th> <th class="tg-0pky">4</th> <th class="tg-0pky">5</th> <th class="tg-0pky">6</th> <th class="tg-0pky">7</th> <th class="tg-0pky">8</th> <th class="tg-0pky">9</th> <th class="tg-0pky">10</th> <th class="tg-0pky">11</th> </tr> </thead> <tbody> <tr> <td class="tg-0pky">Piano keys</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> <td class="tg-j8c8">B</td> <td class="tg-0pky">W</td> </tr> <tr> <td class="tg-0pky">Augmented chord</td> <td class="tg-0pky">C</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">E</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">G♯</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> <tr> <td class="tg-0pky">Intervals</td> <td class="tg-0pky">p1</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">M3</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">aug5</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> <tr> <td class="tg-0pky">Intervals between notes</td> <td class="tg-0pky">p1</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">M3</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky">M3</td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> <td class="tg-0pky"></td> </tr> </tbody> </table></p> </details>
reference
from typing import Tuple """Gets the chord, given the root and color. returns ---------- chord : tuple the chord consisting of its notes -> (C, Eb, G), (F#, A, C#), .. arguments ---------- root : str the root note of the chord -> C, D, F#, Ab, .. color : str the color or type of chord -> m, M, dim, aug """ def chord_triad(root: str, color: str) - > Tuple: notes = ('C', 'D', 'E', 'F', 'G', 'A', 'B') shifts = ('bb', 'b', '', '#', 'x') def is_major(note): # checks if the third from the note is major # that's true for C, F, and G only return note in (0, 3, 4) def third_note(note): return notes[(note + 2) % len(notes)] def minor(note, shift): shift -= is_major(note) return third_note(note) + shifts[shift] def major(note, shift): shift += not is_major(note) return third_note(note) + shifts[shift] triads = { 'm': (minor, major), 'M': (major, minor), 'dim': (minor, minor), 'aug': (major, major), } def get_note(root=root): note, shift = root[0], root[1:] return notes . index(note), shifts . index(shift) def get_interval(i, root=root): return triads[color][i](* get_note(root)) third = get_interval(0) return (root, third, get_interval(1, third))
Learning Chords Triads
579f54c672292dc1a20001bd
[ "Logic", "Fundamentals" ]
https://www.codewars.com/kata/579f54c672292dc1a20001bd
6 kyu
Frank, Sam and Tom build the ship. Then they went on a voyage. This was not a good idea, because the ship crashed on an iceberg and started sinking. Your job is to save the survivors. ## Details The crash scheme looks like an ASCII picture ``` |-| |-| |-| | | | | | | ~\-------|-|-|-|-|-|------/~ ~~\ F | S | T /~~ ~~~\----------------x---/~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` where: - The letters F, S, and T are passengers; - ~ is water; - spaces are empty space; - x - hit location. There can be several hits; - any other signs are parts of the ship. Before the collision, all passengers were inside confined spaces. After collision, water can only spread in orthogal directions (up, left, right and down, not diagonally, and not higher than ocean level), in empty spaces according to the picture: ``` |-| |-| |-| |-| |-| |-| |-| |-| |-| | | | | | | | | | | | | | | | | | | ~\-------|-|-|-|-|-|------/~ ~\-------|-|-|-|-|-|------/~ ~\-------|-|-|-|-|-|------/~ ~~\ F | S | ~ T /~~ ---> ~~\ F | S |~~~T /~~ ---> ~~\ F | S |~~~~~~/~~ ~~~\----------------~---/~~~ ~~~\----------------~---/~~~ ~~~\----------------~---/~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~┴~~ ``` People in the non-flooded spaces survived. ## Input An image of the incident, presented as a 2D array of symbols. To aid in the rescue operation, it is translated into a picture. We can also assume that the first column of the picture contains only water and air and can be used to determine the ocean level. ## Output The names of the survivors in the string. In the description example it would be `Frank Sam`. Unfortunately, Tom is gone. ## Examples It's okay: ``` |==| |==| |==| |==| |==| |==| __|__|__|__|__|__|_ __|__|__|__|__|__|_ __|___________________|___ __|___________________|___ __|__[]__[]__[]__[]__[]__[]__|_xxx __|__[]__[]__[]__[]__[]__[]__|_ ~| F S | T /~ ---> ~| F S | T /~ ~|______________x________________/~~ ~|______________~________________/~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` It's almost okay: ``` |==| |==| |==| |==| |==| |==| __|__|__|__|__|__|_ __|__|__|__|__|__|_ __|___________________|___ __|___________________|___ __|__[]__[]__[]__[]__[]__[]__|___ __|__[]__[]__[]__[]__[]__[]__|___ ~| F S | T /~ ---> ~|~~~~~~~~~~~~~~| T /~ ~x____________x_|________________/~~ ~~____________~_|________________/~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Something's wrong: ``` |-| |-| |-| |-| |-| |-| | | | | | | | | | | | | ~\-------|-|-|-|-|-|------/~ ~\-------|-|-|-|-|-|------/~ ~~\ F | S x T /~~ ---> ~~\ F |~~~~~~~~~~~~~~/~~ ~~~\--------------x-----/~~~ ~~~\--------------~-----/~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Not this time, Poseidon: ``` |-| |-| |-| |-| |-| |-| | | | | | | | | | | | | ~\-x-----|-|-|-|-|-|-----xx~ ~\- -----|-|-|-|-|-|-----~~~ ~~\ F x S | T /~~ ---> ~~\ F S | T /~~ ~~~\--------------------/~~~ ~~~\--------------------/~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` This time: ``` |-| |-| |-| |-| |-| |-| | | | | | | | | | | | | ~\-------|-|-|-|-|-|----xxx~ ~\-------|-|-|-|-|-|----~~~~ ~~\ F | S x T /~~ ---> ~~\ F |~~~~~~~~~~~~~~/~~ ~~~\--------------------/~~~ ~~~\--------------------/~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Playing [Another card game](https://www.codewars.com/kata/633874ed198a4c00286aa39d): ``` |-| |-| |-| |-| |-| |-| | | | | | | | | | | | | ~\-------|-|-|-|-|-|------/~ ~\-------|-|-|-|-|-|------/~ ~~\ F S T | | /~~ ---> ~~\ F S T |~~~~~~~| /~~ ~~~\---------xxx--------/~~~ ~~~\---------~~~--------/~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` <font color="yellow">Yellow submarine:</font> ``` ~~~~~~~~~|---------x~~~~~~~~ ~~~~~~~~~|---------~~~~~~~~~ ~~~~~~~~~| x~~~~~~~~ ~~~~~~~~~|~~~~~~~~~~~~~~~~~~ ~\-------|---------|------/~ ~\-------|---------|------/~ ~~\ F | S | T /~~ ---> ~~\ F | S | T /~~ ~~~\--------------------/~~~ ~~~\--------------------/~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
reference
CREW = {"F": "Frank", "S": "Sam", "T": "Tom"} NON_WATER_PROOF = [* CREW, ' ', 'x'] class Flotsam: def __init__(self, pic): self . pic = pic self . sea_level = next(i for i, x in enumerate(pic) if '~' in x) self . bottom = len(self . pic) self . width = len(self . pic[0]) self . survivors = dict(* * CREW) def show(self): print("\n" . join(["" . join(row) for row in self . pic])) def drown(self, person): name = self . survivors . pop(person) print(f" { name } drowned!") def leak(self, i1, j1, i2, j2) - > bool: a, b = self . pic[i1][j1], self . pic[i2][j2] if a == '~' and b in NON_WATER_PROOF: if b in self . survivors: self . drown(b) self . pic[i2][j2] = '~' return True else: return False def sink(self): leaked = False for i in range(self . sea_level, self . bottom): for direction in (1, - 1): for j in [* range(self . width)][:: direction]: if j < self . width - 1: leaked |= self . leak(i, j, i, j + 1) leaked |= self . leak(i, j + 1, i, j) if i > self . sea_level: leaked |= self . leak(i, j, i - 1, j) if self . sea_level <= i < self . bottom - 1: leaked |= self . leak(i, j, i + 1, j) self . show() if leaked and self . survivors: print(self . survivors) self . sink() def flotsam(pic): o = Flotsam(pic) o . show() o . sink() result = " " . join(o . survivors . values()) return (result)
Flotsam
635f67667dadea064acb2c4a
[ "Algorithms", "ASCII Art" ]
https://www.codewars.com/kata/635f67667dadea064acb2c4a
5 kyu
Letter triangles Similar to [Coloured triangles](https://www.codewars.com/kata/5a25ac6ac5e284cfbe000111). But this one sums indexes of letters in alphabet. <font size=5>Examples</font> ``` c o d e w a r s c is 3 o is 15 15+3=18 18. letter in the alphabet is r then append r next is o d sum is 19 append s do this until you iterate through whole string now, string is rsibxsk repeat whole cycle until you reach 1 character then return the char output is l codewars -> l triangle -> d ``` ``` C O D E W A R S R S I B X S K K B K Z Q D M M K Q U Z X B L X Z N X N L ``` ``` A B C D C E G H L T ``` <font size=5>More examples</font> ``` youhavechosentotranslatethiskata -> a cod -> k yes -> b hours -> y circlecipher -> z lettertriangles -> o cod -> rs -> k abcd -> ceg -> hl -> t codewars -> rsibxsk -> kbkzqd -> mmkqu -> zxbl -> xzn -> xn -> l ``` **Note, if the sum is bigger than 26, then start over** Input will always be lowercase letters. Random tests contains strings up to 30 letters.
reference
from itertools import pairwise def triangle(row): return len(row) == 1 and row or triangle('' . join(chr((x + y + 15) % 26 + 97) for x, y in pairwise(map(ord, row))))
Letter triangles
635e70f47dadea004acb5663
[ "Algorithms" ]
https://www.codewars.com/kata/635e70f47dadea004acb5663
6 kyu
# Definition A laser positioned `h` units from the ground on the left wall of a unit square (side = 1) will shoot a ray at an angle `a` with the x-axis and it will bounce around the walls until the ray has length `l`. Calculate the end coordinate of the laser ray to 3 decimal places and return it as a tuple `(x, y)`. All values are continuous (restrained to the max accuracy of the floating point in the language). # Example `a = 60°, h = 0.5, l = 1.8` Visualization: ``` y ^ | (0,1) v__________________________________________ <(1,1) | /\ | | / \ | | / \ | | / \ | | / \ | |/ \ | | \ | | \ | | \ | | \ | | \ . | | \ / | |___________________________________\/_____|________ > x ^ ^ origin (0,0) (1,0) 1st bounce happens at (0.2887, 1) with total length 0.5773 2nd bounce happens at (0.8660, 0) with total length 1.7320 3rd bounce doesn't happen because the ray runs hits the length before hitting the wall, at (0.9,0.0588) Answer = (0.9, 0.0588) ``` # Constraints ``` 0 <= h <= 1 0° <= a <= 90° 0 <= l <= 10^10 The angle will be given in degrees. ```
games
from math import sin, cos, pi, radians def laser_coord(h, a, l): x, y = (l * cos(radians(a))) % 2, (h + l * sin(radians(a))) % 2 return (2 - x if x > 1 else x), (2 - y if y > 1 else y)
Laser in a square room
635d6302fdfe69004a3eba84
[ "Mathematics", "Geometry", "Performance" ]
https://www.codewars.com/kata/635d6302fdfe69004a3eba84
6 kyu
# Definition The Fibonacci number can be extended non-linearly to a new number called `$P(n)$` with the recurrence relation `$\frac{1+P(n+2)}{1+P(n)}=1+P(n+1)$`, for `$n \geq 0$`. Find `$G(n)=P(n)\mod 9$` if `$P(0)=7$` and `$P(1)=31$`. Brute force will not work! # Constraints ``` 0 <= n <= 10^9 ``` ### Good luck!
algorithms
""" (1 + P(n+2)) = (1 + P(n+1)) * (1 + P(n)) (1 + P(n+3)) = (1 + P(n+2)) * (1 + P(n+1)) = (1 + P(n+1))**2 + (1 + P(n)) (1 + P(n+4)) = (1 + P(n+3)) * (1 + P(n+2)) = (1 + P(n+1))**3 + (1 + P(n))**2 (1 + P(n+5)) = (1 + P(n+1))**5 + (1 + P(n))**3 the exponents follow a fibonacci pattern, so we can calculate them by raising the matrix ((0, 1), (1, 1)) to the nth power to keep the variables small, we can use mod 6 because all 10 digit-powers mod 9 repeat every 6 """ def G(n): if n <= 1: return [7, 4][n] def mod_6(x): return x if x <= 6 else 6 + x % 6 a, b, c, d, pow1, pow2, n = 0, 1, 1, 1, 1, 1, n - 2 while n: if n % 2 == 1: pow1, pow2 = map(mod_6, (a * pow1 + b * pow2, c * pow1 + d * pow2)) n -= 1 else: a, b, c, d = map(mod_6, (a * a + b * c, a * b + b * d, a * c + c * d, d * d + b * c)) n / /= 2 return (pow(1 + 7, pow1, 9) * pow(1 + 31, pow2, 9) - 1) % 9
Fibofamily #1
635d422dfdfe6900283eb892
[ "Mathematics", "Performance" ]
https://www.codewars.com/kata/635d422dfdfe6900283eb892
6 kyu
## Overview Imagine you have an `alphabet` of `n` distinct letters. There are of course `n!` permutations of this `alphabet`. For simplicity in this kata we will always use the first `n` letters from the uppercase alphabet `'ABCDEF...XYZ'`. Now imagine that you are also given a list of "bad subpermutations", each of length `1 <= length <= n`. For example if `n=7` then `alphabet = 'ABCDEFG'`, and you could be given `bads = ['BA','CF','EFA','DGFECB']`. We shall say that an individual permutation of `alphabet` is **"totally good"** if - when viewed as a string - it does not contain **any of the given bad subpermutations as a substring**. For a given `bads` list, how many of the `n!` permutations of `alphabet` are **totally good** ? --- ## Example Let's take `n=3`, so `alphabet = 'ABC'`, and `bads = ['AB','CA']`. Then, considering all `n! = 3! = 6` permutations of `'ABC'` as strings we have: ```python 'ABC' # contains 'AB' from bads as a substring 'ACB' # does not contain 'AB', does not contain 'CA', so: TOTALLY GOOD 'BAC' # TOTALLY GOOD 'BCA' # contains 'CA' from bads 'CAB' # contains 'CA', 'AB' from bads 'CBA' # TOTALLY GOOD ``` So for this given `bads` list, only `3` of the permutations of `alphabet` are totally good. --- ## Inputs and Outputs You will be given an `alphabet` as a string of `n` distinct characters. For simplicity we will work with the first `n` letters from the uppercase alphabet, and with `3 <= n <= 26`, so a valid input might be the string `'ABCDEFGH'` with `n=8` for example. You will also be given a list of strings, `bads`, representing the bad subpermutations as defined above. To avoid boring input validation, you can be sure that: - all elements in `bads` will be distinct, so e.g. `['ABC','ABC']` will **not** occur. - none of the elements in `bads` list will contain repeated letters, e.g. a string like `'DDACB'` will never appear in `bads` since clearly it can't appear in any permutation of the **distinct** letters `'ABCDE'` for example. - none of the elements in `bads` list will contain letters that are **not** in the input `alphabet` - for example, if `alphabet = 'ABCD'` then `bads` will **not** contain `'ABZ'` or `'ZYXK'` etc. since these have some or all of their letters that do not belong to `'ABCD'`. You must return an integer, the count of how many of the `n!` permutations of `alphabet` are totally good, given the `bads` list as defined above. --- ## Performance requirements I have tried to arrange the fixed tests in order of "tricky-ness" for your convenience while solving - hopefully you will fail them "in order" and understand what is going wrong step by step. The basic tests will be all with small to medium sized alphabets, `n <= 8`, and with small `bads` lists with around `4` to `10` elements: **this is so that you can debug using brute force approach, if needed.** The full tests will involve up to `n=26` alphabets and `bads` lists with up to `12` elements, such that brute force approaches will time out. --- ## Acknowledgements Thanks to **@monadius**, **@Voile**, and **@dfhwze** for early testing, for suggestions and feedback, and to **@monadius** again for speeding up the reference solution. --- ## Similar katas I thought of this kata while trying several approaches when working on these 2 difficult katas: [The position of a digital string in a infinite digital string](https://www.codewars.com/kata/582c1092306063791c000c00) [Permutation-free strings](https://www.codewars.com/kata/59b53be0bf10a4b39300001f) It didn't help me directly, but it did up being a fun problem in its own right. If you get stuck on this, maybe working on the above 2 will help? Or if you solved this easily, maybe you'll enjoy those 2?
algorithms
from math import comb as nCk, factorial as fac from itertools import combinations, chain, product def totally_good(alphabet, bads): # starting conditions bads = [b for b in bads if not any(o != b and o in b for o in bads)] n, t = len(alphabet), fac(len(alphabet)) # simple edge cases if not bads: return t if any(1 for b in bads if len(b) == 1): return 0 # combinatorics & string patterns def count(group, n): m, seen, start_cluster = 0, set(), product( * [list(range(n - len(b) + 1)) for b in group]) for start_group in start_cluster: word, c = ["*"] * n, False for source_idx, target_idx in enumerate(start_group): if c: break b = group[source_idx] for i in range(len(b)): if word[target_idx + i] != "*" and word[target_idx + i] != b[i]: c = True break word[target_idx + i] = b[i] word = '' . join(word) if word not in seen and all(e in word for e in group) and len(set([c for c in word if c != '*'])) == len([c for c in word if c != '*']): open = word . count("*") m += fac(open) seen . add(word) return m # set theory: inclusion/exclusion principle history, cluster = {tuple(): t}, list( chain(* [combinations(bads, i) for i in range(1, n)])) for group in cluster: if all(history[subgroup] for subgroup in combinations(group, len(group) - 1)): history[group] = count(group, n) t += history[group] * (- 1) * * len(group) else: history[group] = 0 return t
Totally Good Permutations
6355b3975abf4f0e5fb61670
[ "Algorithms", "Mathematics", "Combinatorics", "Discrete Mathematics", "Strings", "Set Theory", "Number Theory" ]
https://www.codewars.com/kata/6355b3975abf4f0e5fb61670
3 kyu
``` X X X X X 𝙫𝙧𝙤𝙤𝙤𝙤𝙢! ===== O='`o X X X X ``` A car is zooming through the streets! Maybe a bit too fast... Here come some more cars! Oh-No!!! # Instructions: You need to find, if given a multi-line string `road`, whether the speeding car will crash or not. A `road` will always contain the following: * The speeding car, O='`o, who's driver is too scared to turn. * The other cars, signified by X's. They will always be heading in the same direction as the car. The function returns `true`/ `True` if there are X's ahead of the speeding car in the same lane, but returns `false`/`False` if the speeding car has already passed all of the car's in the lane, or if its lane is empty. # Examples: These three will all return true (crash): * ``` O='`o X ``` * ``` X O='`o X ``` * ``` XXXXXXX XO='`oX XXXXXXX ``` These three will all return false (no crash): * ``` O='`o ``` * ``` X O='`o ``` * ``` XXXXXXX XO='`o XXXXXXX ```
reference
# The speeding car: "O='`o" # The other cars: "X" def car_crash(road): return "O='`oX" in road . replace(' ', '')
Car Crash! ==== O='`o
6359f0158f20011969cf0ebe
[ "Strings", "Fundamentals" ]
https://www.codewars.com/kata/6359f0158f20011969cf0ebe
7 kyu
Given a string of numbers, you must perform a method in which you will translate this string into text, based on the below image: <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Telephone-keypad2.svg/1024px-Telephone-keypad2.svg.png"> For example if you get `"22"` return `"b"`, if you get `"222"` you will return `"c"`. If you get `"2222"` return `"ca"`. Further details: - `0` is a space in the string. - `1` is used to separate letters with the same number. - always transform the number to the letter with the maximum value, as long as it does not have a `1` in the middle. So, `"777777" --> "sq"` and `"7717777" --> "qs"`. - you cannot return digits. - Given a empty string, return empty string. - Return a lowercase string. ## Examples: ```python "443355555566604466690277733099966688" --> "hello how are you" "55282" --> "kata" "22266631339277717777" --> "codewars" "66885551555" --> "null" "833998" --> "text" "000" --> " " ```
algorithms
import re def phone_words(str): ansd = {'0': ' ', '2': 'a', '22': 'b', '222': 'c', '3': 'd', '33': 'e', '333': 'f', '4': 'g', '44': 'h', '444': 'i', '5': 'j', '55': 'k', '555': 'l', '6': 'm', '66': 'n', '666': 'o', '7': 'p', '77': 'q', '777': 'r', '7777': 's', '8': 't', '88': 'u', '888': 'v', '9': 'w', '99': 'x', '999': 'y', '9999': 'z'} ans = '' for i in re . findall('0|2{1,3}|3{1,3}|4{1,3}|5{1,3}|6{1,3}|7{1,4}|8{1,3}|9{1,4}', str): ans += ansd[i] return ans
PhoneWords
635b8fa500fba2bef9189473
[ "Strings", "Fundamentals" ]
https://www.codewars.com/kata/635b8fa500fba2bef9189473
6 kyu
The police have placed radars that will detect those vehicles that exceed the speed limit on that road. If the driver's speed is ```10km/h to 19km/h``` above the speed limit, the fine will be ```100``` dollars, if it is exceeded by ```20km/h to 29km/h``` the fine will be ```250``` dollars and if it is exceeded by more than 30km/h the fine will be ```500``` dollars. You will be provided with the speed limits of those roads with radar as a collection of speedlimits ```[90,100,110,120,....]``` and the speed of the driver will be the same on all roads and can never be negative and the amount of the fine will be accumulated **example** ```95km/h```. **Example** ```(Speed=100, Signals=[110,100,80]-> 250)```
algorithms
def speed_limit(скорость, сигналы): штраф = 0 for и in сигналы: if 10 <= скорость - и <= 19: штраф += 100 if 20 <= скорость - и <= 29: штраф += 250 if 30 <= скорость - и: штраф += 500 return штраф
Speed Limit
635a7827bafe03708e3e1db6
[ "Arrays" ]
https://www.codewars.com/kata/635a7827bafe03708e3e1db6
7 kyu
This kata will return a string that represents the difference of two perfect squares as the sum of consecutive odd numbers. Specifications: • The first input minus the second input reveals the exact number of consecutive odd numbers required for the solution - you can check this in the examples below. • The first input will always be larger than the second. • All inputs will be valid so no need for error checking. • Outputs will always be positive. • Inputs will range between 0 and 200, (inclusive). • In the returned string there are spaces before and after the plus sign, the minus sign and the equals sign but nowhere else. Examples: squaresToOdd(9, 5) --> "9^2 - 5^2 = 11 + 13 + 15 + 17 = 56" squaresToOdd(10, 7) --> "10^2 - 7^2 = 15 + 17 + 19 = 51" squaresToOdd(100, 98) --> "100^2 - 98^2 = 197 + 199 = 396" squaresToOdd(100, 99) --> "100^2 - 99^2 = 199 = 199"
games
def squares_to_odd(a, b): return f' { a } ^2 - { b } ^2 = { " + " . join ( map ( str , range ( 2 * b + 1 , 2 * a , 2 )))} = { a * a - b * b } '
Difference of perfect squares displayed as sum of consecutive odd numbers
6359b10f8f2001f29ccf0db4
[ "Algorithms", "Mathematics" ]
https://www.codewars.com/kata/6359b10f8f2001f29ccf0db4
6 kyu
# The task You have to make a program capable of returning the sum of all the elements of all the triangles with side of smaller or equal than `$n+1$`. If you have not seen the previous Kata, [take a look](https://www.codewars.com/kata/63579823d25aad000ecfad9f). # The problem Your solution has to support `$0\leq n \leq 10^6$`. Beware, some sequences computed by hand for a few values of `n` may not have a very trivial solution, even if it looks like it. Brute-forcing will not work! # The definition An element `$a_{ij}$` where `$i$` is the column and `$j$` is the row can be defined as `$a_{ij}=\left(2j + i + 1\right)(-1)^{\frac{3j+3i-j(-1)^n+i(-1)^n}{2}}$` where `$0\leq j\leq i\leq n$`. The sum of all elements composing the triangle is defined by `$T(n):=\sum_{(i,j)\in T}a_{ij}$`. The answer for this Kata is returning `$sum(n):=\sum_{i=0..n}T(i)$`. # Examples For `n = 3`: ``` 1 -2 3 -4 \ -4 5 -6 \__ 1-2+3-4-4+5-6+7-8-10 sums to: -18 7 -8 / -10 / 1 2 3 \ -4 -5 \__ 1+2+3-4-5+7 sums to: 4 7 / 1 -2 \__ 1-2-4 sums to: -5 -4 / 1 __ sums to: 1 Therefore: sum(3) = -18 +4 -5 +1 = -18 ``` # Hints * Euler transform * Sums of powers * Special case of #2
games
def get_sum(n): n, m = divmod(n, 2) return - (n + 2 * m - 1) * (n + m + 1) * * 2
Summation Triangle #3
63586460bafe0300643e2caa
[ "Mathematics", "Performance" ]
https://www.codewars.com/kata/63586460bafe0300643e2caa
6 kyu
# The task You have to make a program capable of returning the sum of all the elements of a triangle with side of size `$n+1$`. If you have not seen the previous Kata, [take a look](https://www.codewars.com/kata/6357825a00fba284e0189798). # The problem Your solution has to support `$0\leq n \leq 10^6$`. Brute-forcing will not work! # The definition A triangle element `$a_{ij}$` where `$i$` is the column and `$j$` is the row can be defined as `$a_{ij}=\left(2j + i + 1\right)\cdot(-1)^{2j+i}$` where `$0\leq j\leq i\leq n$` # Examples For `n = 2`: ``` 1 -2 3 \ -4 5 \__ 1-2+3-4+5+7 sums to: 10 7 / sum(2) = 10 ``` For `n = 3`: ``` 1 -2 3 -4 \ -4 5 -6 \__ 1-2+3-4-4+5-6+7-8-10 sums to: -18 7 -8 / -10 / sum(3) = -18 ``` # Hints * Euler transform * Sums of powers * Continuation of #1
games
# see: https://oeis.org/A035608 def get_sum(n): return (- 1) * * n * ((n := n + 1) * n + n - 1 - (n - 1) / / 2)
Summation Triangle #2
63579823d25aad000ecfad9f
[ "Mathematics", "Performance" ]
https://www.codewars.com/kata/63579823d25aad000ecfad9f
6 kyu
It's been a year since a mystery team famously drove a large broadcasting network to bankruptcy by managing to crack its incredibly popular game show [Hat Game](https://www.codewars.com/kata/618647c4d01859002768bc15), allowing them to win consistently. A new network has decided to try and capitalize on the story, by creating yet another game show with entirely new rules and a creative new name... # *Hat Game 2* ### The Rules The game is played in three steps. First, your team is gathered in a room, where you are shown the set of unique hats which will be used for the game. The number of different hats can change from game to game, so you need to be ready for anything. Next, while the hats are cleared out of the room, your team has a chance to talk, make a strategy, and decide who will compete in the game. The only condition is that you may not have more people competing than there are unique hats. (So, if there are `10` unique kinds of hats, then you may have at most `10` competing team members). Finally, all the competing members of your team are organised into a circle facing each other. Then a random assortment of the available hats (which your team saw earlier) will be brought out and placed on the heads of each contestant. No form of communication or information sharing is possible between contestants at this point. All contestants can merely see the hats of all other contestants, but they cannot see their own. Each contestant must then write down a guess of what kind of hat their own is. This guess is **not** seen by any other team members. Your team wins the round if *any* of your team members manages to guess their own hat correctly. However, the game will be played over multiple rounds, so you need to come up with a strategy with your team which is *guaranteed* to win every single round. ***Note:** the hats your team saw earlier represented merely the different kinds of hat available. There is no guarantee that exactly one of each kind will be brought out. It could be that everyone receives the same kind of hat, or all different kinds, or any other combination.* ### Task Write a function which will accept a list of the available kinds of hats, and will return a list of `strategies`. A `strategy` is a function that accepts a list of hats (strings), and returns a single hat (their guess). This is representative of one single player in your team, and how they will guess once they can see all the hats that their teammates are wearing (which will be used as the input). Your team's list of strategies will be tested to ensure that it will always win the round (ie. that at least one team member will guess correctly). Good luck! #### Try some other riddle kata: - [Hat Game](https://www.codewars.com/kata/618647c4d01859002768bc15) - [Extreme Hat Game](https://www.codewars.com/kata/62bf879e8e54a4004b8c3a92) - [Identify Ball Bearings](https://www.codewars.com/kata/61711668cfcc35003253180d)
games
def make_strategies(hats): ''' We can ensure that one team member always wins, by making sure that there is no overlap between the guesses of each of our contestants. We do this by giving each team member a unique number (from 0 to n-1). They are then to assume that the total "sum" of hats modulo n (assigning each hat an arbitrary value) will be equal to their number. They can therefore determine what hat theirs must be by seeing all the other hats, and make their guess. This means that no matter what modulo a particular game produces, one team member will be accounting for it. This kata was inspired by this video, which also explains the solution incredibly well: https://www.youtube.com/watch?v=6hVPNONm7xw ''' def sum_ind(i): return lambda seen: hats[( i - sum(map(hats . index, seen))) % len(hats)] return [sum_ind(i) for i in range(len(hats))]
Hat Game 2
634f18946a80b8003d80e728
[ "Riddles" ]
https://www.codewars.com/kata/634f18946a80b8003d80e728
5 kyu
# The task You have to make a program capable of returning the sum of all the elements of a triangle with side of size `$n+1$`. # The problem Your solution has to support `$0\leq n \leq 10^6$`. Brute-forcing will not work! # The definition A triangle element `$a_{ij}$` where `$i$` is the column and `$j$` is the row can be defined as `$a_{ij}=2j + i + 1$` where `$0\leq j\leq i\leq n$` # Examples For `n = 2`: ``` 1 2 3 \ 4 5 \__ 1+2+3+4+5+7 sums to: 22 7 / sum(2) = 22 ``` For `n = 3`: ``` 1 2 3 4 \ 4 5 6 \__ 1+2+3+4+4+5+6+7+8+10 sums to: 50 7 8 / 10 / sum(3) = 50 ``` # Hints * Euler transform (Optional) * Sums of powers
games
def get_sum(n): return (n + 1) * (n + 2) * (4 * n + 3) / / 6
Summation Triangle #1
6357825a00fba284e0189798
[ "Mathematics", "Performance" ]
https://www.codewars.com/kata/6357825a00fba284e0189798
7 kyu
## The simple task You have to calculate k-th digit of π, knowing that: ``` π = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342... ``` Make sure to check the anti-cheat rules at the bottom. ## Examples ``` For k = 0: 3.14159265358979323... ^ ``` ``` For k = 6: 3.14159265358979323... ^ ``` ## Constraints ``` 0 <= k < 10000 ``` ## Random test cases ``` 1000 tests where 0 <= k < 10000 ``` ## Anti-cheat * The only import allowed in Python is `math` * The code length is limited to 2000 characters. * Words `http`, `www`, `requests`, `gmpy2` and `search` are banned. * `Eval` and `exec` are banned * Only ASCII characters are allowed
algorithms
# for a proper solution: ...://bellard.org/pi/pi1.c def pi_gen(limit): q, r, t, k, n, l, cn, d = 1, 0, 1, 1, 3, 3, 0, limit while cn != d + 1: if 4 * q + r - t < n * t: yield n if d == cn: break cn, nr, n, q = cn + 1, 10 * (r - n * t), ((10 * (3 * q + r)) / / t) - 10 * n, q * 10 r = nr else: nr, nn, q, t, l, k = (2 * q + r) * l, (q * (7 * k) + 2 + (r * l)) / / (t * l), q * k, t * l, l + 2, k + 1 n, r = nn, nr PI = pi_gen(10000) PI = '' . join(map(str, PI)) def pi(n): return int(PI[n])
Calculate k-th digit of π (Pi)
6357205000fba205ed189a52
[ "Number Theory" ]
https://www.codewars.com/kata/6357205000fba205ed189a52
4 kyu
You will be given a string that contains space-separated words. Your task is to group the words in this way: - Group them by their beginning. - Count how many letters they share in said group. - Return the grouped words, ordered in ascending order, ONLY if their group size (or array length) is equal to the number of shared letters in each beginning. See the following example: <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAIcA8ADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKwfEmqappslgNN0+a7WV5PO8qPdtCxMyg+gLBRn8O9Vx4wsNJ0TSpdfnktdQu7dZDbG3Zpi20Fv3SBiME8+lAHTUVn6Nrem+ILAX2lXaXNvvKFlBBVh1Ug4II9CKq6z4s0Tw/cR2+o3uy4lQyJBFE80hUcbtqKSBnvjFAG1RXEeI/Hdpa6Foet6VqNs2m3eqw21xcMPlWE7t+c/dI29+RW9ovivRPEMs8OmXolmgAaSJ43idVPRtrgHB9cYoA2aK5y08e+GL7U49PttWiknlkMUR2OI5HHVUkI2MfYE1t319a6bZTXt7cR29tCpeSWRsKo9SaALFFYGk+NfD2t6gLCwvy12yGRIpYJIWdR1K71G4fTNc54W+J2k3OkRDXdUhi1A3M0MmImEceJnVA7gbUJUL94jPXvQB6FRWNrXivRPD0sMOp3oimmUtHDHG8sjKOrbEBbHvjFR3HjLw9baLa6vJqkJsbtttvJGGkMrf3VVQWJ4OQBkY5oA3aK4/wp4uXxN4q8RW9rcxT6bZR2ptyqFWDOsm8NnnIKjggEVt614j0nw8kJ1O8ELTkrDGqNJJIRydqKCxx3wKANWiuI8SeO7UfD/Udf8ADt9DM9pNFEzOhHlsZUVg6MAVO1j1Ara0nxn4f1y/Njp2pJLc7DIqGN08xP7yFgA6+65FAG7RXOT+PfC9tqjadLq8SzrKIHOxzGknTY0gGxW9ic1JqnjXw9o2onT77U44rpVDOgRmEQPQyMoIQH1YigDfori/Dfje3Pw70fxB4jvYYJrxMEqhzI5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cpdtFb3oe7iUlF3RjapbHUYJx1GfeuJsHS1+H0nhnVvFN7BeAPaz+H4tOhe4kkZz9zK7n3E7g+e+c8V9BgAdBijaN27Az0zQBBYRNBp1rC7SM8cSKzSY3EgAZOMjP0qHTtZsNWlvYrKfzXsbg21wNjLskABK8gZ4I5GRV6qtpp9vZS3csKt5l3N50zMxJZtoUdegCqoA9qALVef+FbdC/xBdohul1WZWJX7yiBMD3HJ/M16BRQB4PZrdafaeAdXudXl0fT10RrUX/2dJkgmJU4beCE3KMbv9nFdFoOhWni2z8ZomrXmqR6nHFbnUJbWOGCSVFO14tmNxUlcnH8IwTXqxAIIIyD2qlqlreXelzW+nX/9n3TACO5EKy+XgjPytweMj8aAOC+HV3e+K9Zn8R6nC8cunWkekqrjH78Ya5bH+9tXP+ya7zWNYsNA0m41TU5/Is7cAyybGfaCQBwoJPJHQVD4e0ODw7okGmwSSS7CzyTSfflkZizu3uWJNWtR0+31XT57C6Vmt512SqrFdynqpI7EcH2JoAtA5AI6GuL+LSlvhZr6gEkwLwP99a7SigDifFkCReL/AAIIYwqxX0yLtH3V+zuMew4Feb2Mw0nwpqug614surG9865juNHXTopJboyO2DGWXdJvBGGzxnqAK9+pCoJBIGR0PpQB5Fe2clnqeo2zC4Jh8AiLM4HmZDSD5sEjd64J5qTRr608N+IPD2r644ttPufC9ra215KMRxSr8zxluilgVPOM4x2r1qkIDDBAI9DQBw/gNhf+IPFmuWcbro+oXcJtHKFRMUiCySKD2Zu/fFS/EL/X+D/+xjtv/QJa7Sud1/wxPrus6Tdvqrw2enXMd2LNYFIklTdhi/UcNjHSgDoqKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACqV5rGmafKIr3UbS2kZdwSadUJHrgnpwau1hP/yNd9/1423/AKHPQBY/4SbQP+g5pv8A4Fx/40f8JN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/W88gD8aANWiqo0rVW/1msRqP8ApjaBT/48zU8eHopP+Pu/v7oejTeWPyjC5/GgCO61Ozs5BFLMDM33YYwXkb6KMk/lTEttT1Thw2m2h68gzuPwyEH5n6Gtaz0+z09ClnawwKeT5aBc+59as0AQWlnb2FstvaxLHEvQDue5J6kn1NT0UUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAVVv9OttShEdwpyp3RyIdrxt6qRyDVqigDn3Gp6ZxcRNf2w6TwL+9Uf7Uff6r/3yKmtNQtL4N9muEkZfvIDhl+qnkfjW1VO90qw1Ag3dpFK6/dcr8y/Ruo/CgCKiq58P+X/AMemp6hbjspkEo/8iBj+tN/svV1+5q8BH/TWzyf0cUAWqKy9Ph1rULZ5m1Gyj2zzQ4Syb/lnIyZ5l77c/jVsaJdyf6/WrrH92COOMH81J/I0ATSSxwxtJK6oi8lmOAPxqiupS33y6TbNc5/5eHykA9938X/AQfqKvQ+HtMikWV7c3Eq8iS6dpmB9RuJx+GK1KAMyw0cW8/2y7mN1e4IEhXCxg9Qi/wAI9+Se5rToooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAoorNude0y2lMLXQknHWGBTK4+qoCR+NAGlWV4g+XTopv8Anjd27/h5qg/oTUZ124k/499GvGHZpWjjH5Ft36VT1ObWdS024tF02ziMqFVd71vlPY4EZ7+9AHS0Vif2prC/f0m1I/6Z3pJ/WMU4a9JH/wAfWk38Q7uirKPyRi36UAbNFUbPWNOv5PKt7uNphyYW+WQfVDhh+VXqACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiig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NEGFCqoZdzE57jAU9aAPXZriG3CmaaOMMdq72AyeuBn6GnRyJNGskTq8bjKspyCPUGuD0DUbX4jae6Xr2U8+j6gQZrP54Jz5Z2umckAh+RnPBGcGuy0nTYdH0ez0y2JMNpAkKFsZIUADOPpQBcooooAKKKKACiiigAooooAKKKKACiiigAooqG6u7ext2nupkhiXqznHPp7n2oAmorDbVNQveLC1W2hPS4vFO4+4jGD/AN9FfpUTaW1xzfX95dH+75piT6bUwCPrmgDbnvLW1Gbi5hhH/TRwv86wNV1/Rm1HRSNWsCI7xmci5T5R5EoyeeBkgfUip4dI022OYbC2QnqyxLk/U4q4FVRgKAPYUASw6xplycQajaSn0SdW/kau1jy2VrcDE1tDIPR4wf51VGh2MXNqslme32SRoh/3yp2n8QaAOiorBWXWLLlZY9RiH8MoEUv4Mo2n6ED61fsNXtb92iXfFcoMvbzLtkUeuO49xke9AF+iiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAOfsx9l1TUbFuD5v2mP3STkn/vsOPy9av03V9PluBFd2e0XttkxhjgSKfvIT6HA57EA1BZXsV9CXj3K6HbJE4w8bd1Ydj/+sUAWaQgMCD0PFLRQByVl4Dgs00qH+19QltNKnE1nbt5YVMAjBwgLcMRknP480/T/AANb2Js4m1XULmxs5zcw2cxj2LLksGJChiASSATgH6CuqooA5q38GW1vLFH/AGhevpkMzTxacxTykZs8ZC7yoLEhSxH5CmWPgqKyvtLm/tfUZ7fSmY2VrKybIlaNo9pIUM2FbAJJIwPfPUUUAFFFFABVTTh9q8RXdwOY7WEW4P8Atsd7j8AI/wA6ZfXkiSLZWSrLfzD5EPSMf339FH6ngVq6dYx6bYpbRsz4yzyN952JyzH3JJNAFqiiigDPutD0u8tJ7Wayh8m4TZKIxsLrnJBK4OOPWptP0yx0mzS006zgtLdP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WTVYx9xL47f8AgUcbH9WNSyypBC8srBI0UszHoAOppPD0Lppf2iVCkt3I1wykcqGPyg+4XaPwoA1aytc12PQoIpZLDUrwSMVC2Fm9wy8dSFHA961aKAPPPEuqaeLq1v7HXNZ03Xbm3VotNggaeSReceZasDjqRk7D/tcV0/hO81++0RZvEdhFZX3mECOMj5o+NrMoZtrHnK7jj1rZEMaytKsaCRwAzhRlgOmTT6AMTVNGsYrPUL1YT9oMc8pcux+dowhbBOM7VVR6DgdTXnnh/wDtnQPB/gXVU167mS8lsrOWxdI/IEMo2gKAu4Mowd245Oe3FetXECXNtLbyZ2SoUbHXBGDWN/wiWnf2Jo+k7p/s2ky28tsd43FocbNxxz056UAeey+JfEOsPrd9Zy+IY57W8nt9PhsbKN7TERKgS7hlixB3cjGeOlQ+Kbm4vI/Ft1dW5trmbwfbSSwN1jctKSp+hJH4V3V/8P8ATL24vmS+1S0ttQcyXtna3OyG4YjDFhgkbhwdpGe9WL7wTo98t+jLNFHe6cmmukTBVSFCxUKMcH5j+lAGJbtqnibxLqmmR63eaVZaRBbIi2QjDyySR7y7M6t8oBACjrzmrfhfb4v8NiXXUW5u7aS606aVCUSYLJsZgoOBuCDP1IHBxWhqHg2zvdQ+321/qWm3bQrBNLYziMzIv3Q4IIJGTggAjPWtbSNIstC0qDTdOh8q1gBCLkk8nJJJ5JJJJJ6k0AXaKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAMbVLKeC6/tOxjMkm0LcW4485R0I/2x29Rx6Yda3cF7AJrdw6HjpggjqCOoI7g1r1l3uipPO13aTG0vCPmkRcrJ/vr0b68H0NAD6Kz2vLyx41KxdVH/LxbAyxn6gDcv4jA9as2t7a3qb7W5imUdTG4bH1xQBPRRRQAUUUjMqKWdgqjkknAFAC0E4GT0rO/tiCdimnxyX8nT/RhlAfdz8o/PPtUyaPc6gQ2ryJ5PX7FATsP++xwX+mAPUGgCvGh8QTqqj/AIlMbZd+1ywPCr6oD1Pfp0zXSUiqqKFUBVAwABgAUtABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAVSu9H06+fzLmygkk7SFAHH0Ycj86u0UAY58O26/6i81CD2W6Zx/4/upP7Bn7a7qQHpiA/zirZooAxx4fz/rdV1KQenmqn/oCinp4c0lWDyWguHHIa6dpyD7bycVq0UAIqhVCqAAOAB2paKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/2Q=="> "a abc abcd abe hi hello" -> ```["a", "abc", "abcd", "abe"]```, ```["abc", "abcd", "ab"]```, ```["abc", "abcd"]```, ```["abcd"]```, ```["hi", "hello"]``` See how we treat these arrays: ```["a", "abc", "abcd", "abe"]``` -> The size of this array is 4, yet they only share in the beginning "a". (1 letter) they don't match. ```["abc", "abcd", "ab"]``` -> The size of this array is 3, and they only share in the beginning "ab" (2 letters) they don't match. ```["abc", "abcd"]``` -> The size of this array is 2, only share in the beginning "abc" (3 letters), they don't match. ```["abcd"]```-> The size of this array is 1, and they share in the beginning "abcd" (4 letters), they don't match. ```["hi", "hello"]```-> The size of this array is 2, and they share in the beginning "h" (1 letter), they don't match. NOTES: - If 2 or more of the same word appear in the string, you should treat them as different words: Example: "is is" -> ```["is", "is"]``` -> The size of the array is 2, and both share the beginning "is" (2 letters) -> Should add it to the returned string. - If in the String any word has an UpperCase Char, you should transform the String into LowerCase. Example: "Or or" -> ```["or, "or"]``` - If none of the cases matches, return the list empty. - Some answers may time out so efficiency is key!
reference
from collections import defaultdict from itertools import chain def letter(msg): D = defaultdict(list) for w in map(str . lower, msg . split()): for i in range(len(w)): D[w[: i + 1]]. append(w) return sorted(chain . from_iterable(v for k, v in D . items() if len(k) == len(v)))
[St]arting [St]ring
635640ee633fad004afb0465
[ "Strings" ]
https://www.codewars.com/kata/635640ee633fad004afb0465
5 kyu
# Pedro's Urns Pedro has `n` urns, numbered from `0` to `n-1`. Each urn `i` contains `r_i` red balls and `b_i` black balls. Pedro removes a random ball from urn `i = 0` and places it in urn `i = 1`. For the next step, he removes a random ball from urn `i = 1` and places it inside urn `i = 2`. He repeats this process until he reaches the final `i = n-1` urn. Your task is to return the probability that Pedro's **last ball is red**. ## Example You will receive the number of urns and two arrays, one indicating the number of black balls in each i-th urn and the other, indicating the number of red balls in each i-th urn, where `0 <= i <= n-1` is the array index. ``` n = 2, b = [9, 4], r = [1, 5] ``` In the above example, there are `9` black balls and `1` red ball in urn `i=0` and `4` black balls and `5` red balls in urn `i=1`. 1. Pedro has `10%` chance of picking a red ball and `90%` chance of picking a black ball in urn `0`. 2. After placing his chosen ball in the last urn, `1`, he has `10% * 60% + 90% * 50% = 51%` chance of getting a red ball and `10% * 40% + 90% * 50% = 49%` chance of picking a black ball. Therefore, for this example, the chance that Pedro retrieves a red ball from the last urn is `51%` ## Format Return the probability that Pedro's last ball is red as a number between `0` and `1`: For example, `51%` must be returned as `0.51`. Returned values will be tested for correctness to within a tolerance of `1e-6`. ## Ranges ``` 1 <= b_i, r_i <= 5000 2 <= n <= 1000 ```
reference
from fractions import Fraction def get_probability(n, nbs, nrs): pr = Fraction(0) for i, (nb, nr) in enumerate(zip(nbs, nrs)): pr = (nr + pr) / (nb + nr + (i != 0)) return float(pr)
Pedro's Urns
6352feb15abf4f44f9b5cbda
[ "Probability" ]
https://www.codewars.com/kata/6352feb15abf4f44f9b5cbda
6 kyu
Given two Arrays in which values are the power of each soldier, return true if you survive the attack or false if you perish. **CONDITIONS** * Each soldier attacks the opposing soldier in the **same index** of the array. The survivor is the number with the **highest** value. * If the value is the same they both perish * If one of the values is empty(different array lengths) the non-empty value soldier survives. * To survive the defending side must have **more** survivors than the attacking side. * In case there are the **same number of survivors** in both sides, the winner is the team with the **highest initial attack power**. If the total attack power of both sides is the same return **true**. * The initial attack power is the sum of all the values in each array. **EXAMPLES** ``` attackers=[ 1, 3, 5, 7 ] defenders=[ 2, 4, 6, 8 ] //0 survivors 4 survivors //return true attackers=[ 1, 3, 5, 7 ] defenders=[ 2, 4 ] //2 survivors (16 damage) 2 survivors (6 damage) //return false attackers=[ 1, 3, 5, 7 ] defenders=[ 2, 4, 0, 8 ] //1 survivors 3 survivors //return true
algorithms
def is_defended(attackers, defenders): survivors = [0, 0] for k in range(max(len(attackers), len(defenders))): if len(attackers) <= k: # Empty attacker survivors[1] += 1 elif len(defenders) <= k: # Empty defender survivors[0] += 1 elif attackers[k] < defenders[k]: survivors[1] += 1 elif attackers[k] > defenders[k]: survivors[0] += 1 return survivors[0] < survivors[1] if survivors[0] != survivors[1] else sum(attackers) <= sum(defenders)
Survive the attack
634d0f7c562caa0016debac5
[ "Arrays" ]
https://www.codewars.com/kata/634d0f7c562caa0016debac5
7 kyu
Imagine a circle. To encode the word `codewars`, we could split the circle into 8 parts (as `codewars` has 8 letters): <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKcAAACnCAYAAAB0FkzsAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAADcVSURBVHhe7Z0LvFVj+sdXVKerLud0OtGFLqd7KpWUcldRRDWj0TSYSEqDhhiMGWOQaYiScYlEyDCYDMZ/cg+REtFd6eKS7hfSxf7/vk/r3XanU53O2Ze19jm/z+f97LXWXnvttd71vM/tfZ7n9Yo7zjzzTH9rN0qXLp01duzYI4488sjjDz300EaHHHJIr4oVK/6ifPnyk8qVK3eXTnkuMzPzwwoVKnyu/dfKli27ukqVKrPLlCmzTu1D/X55qVKlPtJv56stqFq16rRKlSrN17kP6hp36ftH9Ztu2dnZf9B5PfjPSy655BQ+wdlnn13K3yxBcUarVq3KizgzRCzH1axZs3f16tXvEDGOFTHNzMjI2CLiWanTvlLbqeMRfebXfsrzub8WPUeEu4ZP/c+szp07b9L2bLXLRJytRfznidCrad8bPXp0Bp/FEcVqlIpzHVq/fv3M5cuXV9q6dWs9EWW7bdu2XSAirKKvM0WAP+3atavC7rN3Q995kQj0tBv6jSfC8kQ8njiqt2nTJk9E7X333XeeCNz78ssvvTp16ngbN270du7caeesXbvWE8HbufoP76efoNG9wEF9fcgaXf9H3ceP2n9m8ODBn86aNStj3rx5b+j3S+zMYoK0J05xpWoikko//PDDsYsWLcoUsXX88ccfj9fLL6+vj1CD8vbqh8MOO8zLzc217UaNGhkx1q1b15M495o0aeKtWbPGO+OMM7yZM2d6hx9+uJ23YcMGT8TvzZ492+vQoYP3yiuvePXq1fO++eYbaxL/3ocffmi/3bFjh/fOO+94WVlZ3rfffut9//33RvS6L7uWYMTKpwh7iQbTcn0u0nM8rOf5UKpA1gMPPAD3TVukJXFWq1aNl1pWxDVAL/2k1atXN9VLPVycp6KOV7KTBLgiqFWrlhEgXK1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ll4ajiolnajxJrLByX1e9tNQ4IDmKDE0KQy5cvt+Ww8RBAyOvWrbPjnAsRQvQQpQMEnIcrAir1ldF3G/TdxkqVKk0Ut51ZuXLlLxs0aLB54cKFazU4MPpKkM4YPXq0FVmX2K6elZXVv3fv3jj4h6rN6dq162aJ+VnaxhpmLRuzhNUgXLe9r+bO2de5WDK0r3Xtr0SAW8TV3xLXvlf3coM45OlqnS+++OKMU089Nb3TIkpQMIg4o1Lk8ssvP83f7CHd8Hcimm7ikJNESHdL5E8QIX2gzxf0uVBtgTjdbBHYCrWZIur10gvn6DdrJH7f0G/miZN+pHOe1/Y9Ov8BHe+nz7N1zcYaGO2lGpTVb+HaUYg4/a3iCs/7f32kMXbia9+tAAAAAElFTkSuQmCC" alt="" /> Then add the letters in a clockwise direction: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKcAAACnCAYAAAB0FkzsAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAELHSURBVHhe7Z0HmFRF1oZLBMkShqRkgSGjZCQjiCKoqKCirooJFdRVBEy7uqurqOjKouBijuDvYsSsYEIkg4EoIkNWEIEZMtT/vdVdYwMTume6p3sGvuepp2/ne+ueOvmcMkdwIAoXLlxhzJgxVWvVqtXx6KOPrleoUKEzS5YseX7x4sVfLFas2L/1kTeTkpJmlShRYqGeTznmmGN+LVOmzLwiRYr8rjFL30856qij5ui7izWWlC1b9rNSpUot1mef0m/8W++/oO+cVqlSpTv0uV785zXXXNOdR3D22WcfFTw8gsMZzZo1K967d++iIpaTK1eu3Ld8+fIPiRjHiJhmFy1aNFXEs1ofW6uxV69bPWY09h/0mNVI/4wIdyOP+p+5HTp02KrjeRrXizhPEvFfKEIvp+dm1KhRRXk8HHFYrVJxrqNPOOGEpJSUlFJpaWk1RZStdu7cebmIsIzeThIB7t+3b1+JwKcD0HvGWugpAH3HiLCMiMeIo5qtW7caEbX57bffjAjcrFy50lSvXt1s2b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S2O1g+Q4EnzoNx7LHH1pUI7CZi2jV+/HjM+P66+cfAUcVFK+h5OrGGwnNZfd/tFw7BQWxwQgiS/Y1q1arlPAQQMvsI8TqfhQgheojSAwI+iCsCOvUV0Xt/6L0tpUqVel7cdnbp0qVX1qlTZ9vSpUs3aXEEGq0fQcHFqFGj3FYcEtvlK1SoMKBv3750RhussaBz587bJObn6hhr+FcegwPC9ceZDf+ZzD6LJcNYp99eKwJMFVf/Ulz7CZ3LXeKQPTU6XH311UV79OhRsMsissFhxzkzg4jzKEJ+HN9www2njhkz5hMd9pJumCzut1hc82IRzWZxwFLigE1FSOv02FCfwc2zXRwUrrtBBFdHOmFKWlpaVRHdD+KClaUmbN+4ceMqieMU6a36mWKfiCPu1nuLpRcf26pVqwXSO48Vh93I/x8BMOb/AZyDtIv9MqxjAAAAAElFTkSuQmCC" alt="" /> Then remove the circle: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKcAAACnCAYAAAB0FkzsAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAeCSURBVHhe7d1vaM7fH8fx974NiZQ/X9kNuRpTSpZiWTZCmj830O64sfKv3LPcc2MSN/y940/uIJqI1djIv4UsUTOzDGNMasRMI7JI/nT9ds51VqYf312u63Ptfa7P81G6zvl8rlvXXs75fM45n8/JiHYTQKF/3CegDuGEWoQTahFOqEU4oRbhhFqEE2oRTqhFOKEW4YRa3ofzw4cPHa6INMPcOtSiW4dahBNqEU6oRTihFuGEWoQTahFOqEU4oRbhhFqEE2oRTqhFOKEW4QzYjRs37D/Ej3AGpKGhQYqLi6W9vV3ev38vK1eudGfQVyyZC0hJSYmUlpZKXl6eO4J40XIGJDMzk2AmiHBCLcLZ7enTp64ETUIbzp8DmZOT40rJU1BQIHv27HE1kfr6eldCX3FDFKC9e/fK3bt3bbmwsFDWrFljy+gbwgm1uOaEWkkNZ2trqysBiaNbh1p061CLcEKttAjnnTt3pKKi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p6bV1I2Njfa1e7du3XJH0keyfufbt2/LmTNnpKmpyR3xS1zh1PL8SVlZmTx8+FAGDRpk/5ArVqxwZ9JDor+zebmreRPc9evX7Rs5ioqK5OrVq+6sR0y37rvS0tJodyvhaunhyZMnrhS/tWvXRsvLy10tGt26dWt00aJFruYP72+ITPduNnx99+6dO5IeEmk9nz9/Ls3NzXaXix07dsjLly/lx48f7qw/vAznlStXbLd16NAhOXv2rHS3Mu4MjCFDhsjo0aPttjojR46UvLw8WbdunTvrEdeCeqX7GipaWVnpatFoJBKJXrp0ydXQfQ3uSn7ztlvv6Oiwn9XV1dLW1mbLiJk9e7ZcvHjR1WLu37/vSv7wcpyzqqpKDh48KOPGjZMJEyZIZmam3be9oKDAfeP3zCB3Tk6Oq6Uv84LXmpoaGT9+vDx79kyWLFkiy5Ytc2f9wCA81Eq4W2e6DUFJOJxh6CL/pL6+3m4c9TNz7Ff/7xj+zPtxzr+RzNZ+8ODBsnv3bleL2bVrl5w7d87VRGpra+Xy5cuuhr4KZTiT2dpPmTLFfpqJAKOurs62pGZvyB5mjrsvN2voLXThDGLxyowZM+zEgGGCeeTIEXn79q2tGy0tLXaLlHSX7N82dOEMYvFKYWGhnUY1zIIUszfP1KlTbVduWtSgtkLRJtm/bSi79WQzLadhxhWzsrJsOT8/306vHjt2LBStZhACCaemdZ+pkp2dLSUlJTJ58mRbnzdvnnR1dUl7e7tdsob4BRJOLes+U8kEcNq0aZKbm+uOxAIbiURcDfFihghqcc0JtQgn1CKcUItwQi3CCbUIJ9QinFCLcEItwumhVEwPa5iCZoYIatFyQi3CCbUIJ9QinCGm/bFuboigFi0n1CKcUItwQi3CmabS4SFDboigFi0n1CKcUItwQq1QhpMX3vqBGyKoRbcOtQhnQML4MrNko1uHWrScUItwQimR/wFTcn2UWoUYOgAAAABJRU5ErkJggg==" alt="" /> If we read the result from left to right, we get `csordaew`. Decoding is the same process in reverse. If we decode `csordaew`, we get `codewars`. ### Examples: 1. ``` encode "codewars" -> "csordaew" decode "csordaew" -> "codewars" ``` 2. ``` encode "white" -> "wehti" decode "wehti" -> "white" ```
reference
def encode(s): return "" . join(s[((i + 1) / / 2) * (- 1) * * i] for i in range(len(s))) def decode(s): return s[:: 2] + s[1:: 2][:: - 1]
Circle cipher
634d0723075de3f97a9eb604
[ "Ciphers", "Algorithms" ]
https://www.codewars.com/kata/634d0723075de3f97a9eb604
7 kyu
A matrix is "fat" when the sum of the roots of its "Widths" is greater than the sum of the roots of its "Heights". Otherwise, we call it as a "thin" matrix. But what is the meaning of that? A Width of a matrix is the sum of all the elements in a row. Similarly, a Height of a matrix is the sum of all the elements in a column. Difficult to assimilate? Let's look at an example. ``` The matrix [ [1, 3] , [5, 7] ] : - Sum of rooted Widths: √(1+3) + √(5+7) = √4 + √12 - Sum of rooted Heights: √(1+5) + √(3+7) = √6 + √10 Since "width" is smaller than "height", we determine this matrix is "thin". The matrix [ [1, 4, 7], [2, 5, 8], [3, 6, 9] ] : - Sum of rooted Widths:√(1+4+7) + √(2+5+8) + √(3+6+9) = √12 + √15 + √18 = 11.57972565... - Sum of rooted Heights: √(1+2+3) + √(4+5+6) + √(7+8+9) = √6 + √15 + √24 = 11.22145257... Since "height" is smaller than "width", we determine this matrix is "fat". ``` ***TASK: Your task is to return "thin", "fat" or "perfect" depending on the results obtained.*** NOTES: - All matrices will be squared - In case that both sums are equal, the matrix will be considered as "perfect". - DON'T round the roots... every digit matters ;) ***Since the results of the roots may have a slight variation, to determine that a matrix is "perfect", I suggest you use an approximate error of 1E- 10.*** - If a Width or a Height is negative, return None
algorithms
def root(M): return sum(sum(r) * * .5 for r in M) def thin_or_fat(M): w, h = root(M), root(zip(* M)) if not any(isinstance(v, complex) for v in (w, h)): return "perfect" if abs(w - h) < 1e-10 else "fat" if w > h else "thin"
Matrix Weight
6347f9715467f0001b434936
[ "Matrix" ]
https://www.codewars.com/kata/6347f9715467f0001b434936
7 kyu
## Overview One of the most remarkable theorems in basic graph theory is [Cayley's formula](https://en.wikipedia.org/wiki/Cayley%27s_formula) which states that there are `$n^{n-2}$` trees on `$n$` labeled vertices. One of the most ingenious ways of proving this was discovered by Heinz Prüfer who showed that each such labeled tree can be **uniquely** encoded as a sequence of length `$n-2$` using `$n$` symbols. Thus there are `$n^{n-2}$` such **Prüfer sequences**, one for each labeled tree. For example, the sequence `[4,2,3,2]` of length `4` encodes **one and only one** of the possible trees that can be formed with the `n = 4 + 2 = 6` labeled vertices `{1,2,3,4,5,6}`. You can discover what the corresponding tree looks like in the examples below. In this kata, you will write 2 functions - `tree_to_prufer` and `prufer_to_tree` - that will take a given labeled tree and determine its Prüfer sequence, and take a Prüfer sequence and reconstruct the **unique** labeled tree that it represents. **Please note that in this kata, the vertex labeling begins with 1 rather than 0: this is so that the results agree with all of the available mathematical resources on the internet, for your convenience.** **Also, all tests will involve trees with `n >= 3` vertices.** --- ## Part 1 - How to encode a labeled tree to its Prüfer sequence **Pseudocode:** Given a labeled tree on `n` vertices, labeled from `{1,2,3,...,n}`, its Prüfer sequence is found as follows: - Find the leaf with the lowest label value; let's call it leaf `l`. - Remove this leaf, `l`, from the tree and add **the label of the only vertex adjacent to `l` to the current growing Prüfer sequence**. - Repeat these steps until the Prüfer sequence is of length `n-2`. **Example:** ```python # >> Labeled tree on 6 vertices, labeled from 1 to 6: # # 1 --- 4 --- 2 --- 3 --- 5 # / # / # 6 # # This tree will be encoded as the following dict of sets: # # example_tree = { 1:{4}, 2:{3,4,6}, 3:{2,5}, 4:{1,2}, 5:{3}, 6:{2} } # # So in the above, you can read 3:{2,5} as follows: # "Vertex 3 is connected to vertex 2 and to vertex 5" etc. ``` Performing the Pseudocode explained above, we obtain the following results: 1. The leaf `l` with lowest label is `1`; we remove it from the tree and add the label of the vertex adjacent to `1`, which is `4`, to our growing Prüfer sequence. 2. Now the leaf `l` with lowest label is `4`; we remove it and add the label of the vertex adjacent to `4`, which is `2`, to our growing Prüfer sequence. 3. Now the leaf `l` with lowest label is `5`; we remove it and add the label of the vertex adjacent to `5`, which is `3`, to our growing Prüfer sequence. 4. Now the leaf `l` with lowest label is `3`; we remove it and add the label of the vertex adjacent to `3`, which is `2`, to our growing Prüfer sequence. 5. Our Prüfer sequence is now of length `n-2 = 6-2 = 4` so we stop. The final result is therefore the Prüfer sequence `[4,2,3,2]` for this labeled tree. **Inputs and Outputs:** For the `tree_to_prufer` function, you will be passed a `dict` of `set` s that represents a valid labeled tree via its adjacency information. **The trees will always have `n >= 3` vertices.** In other words, if two labelled vertices, `u` and `v`, are connected in the tree then the input `dict` will contain `{ ..., u: {...,v, ...} , ... , v:{ ..., u, ...} , ... }`. Remember, the vertices **will always be labeled starting from 1 up to n**, which gives a total of `n` vertices. For your `tree_to_prufer` function, you must return a `list` of `integers` representing the Prüfer sequence of the input tree. If your algorithm is correct, this list will be of length `n-2` where `n` is the number of vertices in the input tree. The `integers` you can use range from `1` to `n` since these are the `n` distinct labels used in the tree. **Note that the same integer may appear multiple times in a given Prüfer sequence (as in the example `[4,2,3,2]`).** --- ## Part 2 - How to decode a Prüfer sequence to its labeled tree **Pseudocode:** Given a Prüfer sequence of length `n-2`, its corresponding labeled tree is found as follows: - Take a set, `S`, of all labels from `1` to `n`: `{1,2,3,...,n}` - Find the current smallest label, `s`, in `S` that **does not** appear in the **current** Prüfer sequence. - Remove `s` from the set `S`. - Take the first element, `p`, of the **current** Prüfer sequence. - Remove `p` from the **current** Prüfer sequence. - Create an edge in the tree between the vertices `s` and `p`. - Repeat until there are only `2` labels remaining in the set `S`. - Create an edge in the tree between these last `2` remaining labeled vertices. **Example:** Let's work backwards from the same example from Part 1: we start with the Prüfer sequence `[4,2,3,2]`. Since `n-2 = 4` we have that `n=6`. The set, `S`, starts as `S = {1,2,3,4,5,6}`. 1. The smallest label, `s`, in `S` that does not appear in the current Prüfer sequence is `1`. The first element, `p`, of the current Prüfer sequence is `4`. We delete `1` from `S` and delete the first element, `4`, of the current Prüfer sequence. We create an edge `1 --- 4` in our tree. 2. Now `S = {2,3,4,5,6}` and our **current** Prüfer sequence is **updated to** `[2,3,2]`. Continuing as in previous step, we will add the following edges to our tree: `4 --- 2` then `5 --- 3` then `3 --- 2`. 3. At this point our `S` is given by `S = {2,6}`, and our current Prüfer sequence is empty. 4. We therefore create the final edge `2 --- 6` in our tree. 5. Our resulting tree is therefore given by the `dict` of `set`s: `{ 1:{4}, 2:{3,4,6}, 3:{2,5}, 4:{1,2}, 5:{3}, 6:{2} }` You should do these steps on paper and convince yourself that you understand both the encoding and decoding. **Inputs and Outputs:** For the `prufer_to_tree` function, you will be passed a `list` of `integers` and you must return a `dict` of `set`s - the structure being the same as the input trees described in Part 1 above. **The list will always be of length `>= 1` corresponding to the fact that the associated tree always has `n >= 3` vertices** (if the input Prüfer sequence is of length `n-2` then the labeled tree that it represents will contain `n` vertices, and their labels will be `1,2,... n`). Your code will be tested on trees of up to `n = 500` vertices. All input trees will be valid, and similarly all input Prüfer sequences will be valid and correspond to valid trees. --- ## Useful additional resources **There is a good visualization tool available online** that will help you troubleshoot your code - I have used the same labeling conventions as this site, for your convenience: [https://samswanke.com/pruferdecode/](https://samswanke.com/pruferdecode/) You may also find the following resources useful: [How to get the Prüfer sequence of a given labeled tree](https://proofwiki.org/wiki/Pr%C3%BCfer_Sequence_from_Labeled_Tree) [How to reconstruct a labeled tree from a given Prüfer sequence](https://proofwiki.org/wiki/Labeled_Tree_from_Pr%C3%BCfer_Sequence) The short Wikipedia article on [Prüfer sequences](https://en.wikipedia.org/wiki/Pr%C3%BCfer_sequence) contains some useful pseudocode algorithms.
reference
def tree_to_prufer(tree): res = [] for _ in range(len(tree) - 2): mn = min(k for k, v in tree . items() if len(v) == 1) res . append([* tree[mn]][0]) tree . pop(mn) for k, v in tree . items(): if mn in v: v . remove(mn) return res def prufer_to_tree(prufer_sequence): ln, pf = len(prufer_sequence), prufer_sequence[:] s = {* range(1, ln + 3)} res = {k: set() for k in s} for _ in range(ln): cur = min(s - set(pf)) s . remove(cur) res[cur]. add(pf[0]) res[pf . pop(0)]. add(cur) a, b = s res[a]. add(b) res[b]. add(a) return res
Prüfer sequences and labeled trees
6324c4282341c9001ca9fe03
[ "Algorithms", "Mathematics", "Graphs", "Graph Theory", "Trees", "Combinatorics" ]
https://www.codewars.com/kata/6324c4282341c9001ca9fe03
6 kyu
~~~if-not:bf Yup, fill the provided set with the keywords of your language. ~~~ ~~~if:bf Write a program that will output all 8 instuctions. ~~~ The test provides the number of needed keywords, and the error messages contain hints if you need help. <!--Translators: Add 3 keywords, one of which should be difficult/obscure.--> ## Details: ~~~if-not:bf - Keywords are the words put aside as instructions for the compiler. For example (use these to get started): ```python if True nonlocal ``` ```rust if true extern ``` ```csharp if true stackalloc ``` - If your language has contextual or "soft" keywords, you won't find them here. Only keywords that are always recognized are included. - The example test case will only check your list length. - The keywords should be strings. ~~~ ```if:bf Good luck, and bonus points for not searching anything up. ;) ```
games
from keyword import kwlist keywords = set(kwlist)
Oh, so you like programming? Name all of the keywords!
634ac4e77611b9f57dff456d
[ "Puzzles" ]
https://www.codewars.com/kata/634ac4e77611b9f57dff456d
7 kyu
Prince Arthas needs your help! Mal'ganis has spread an infection amongst the Stratholme citizens, and we must help Arthas prevent this infection from spreading to other parts of the Kingdom. You will receive a string `s` as input: Each "word" represents a house, and each letter represents a citizen. All infected citizens are represented as `"i"` or `"I"` in `s`. You must eradicate them, and their neighbors. If an infected citizen appears after or before a space, you should not delete the space, but keep in mind that the distance from "house" to "house" (word to word) has to have only one space. EXAMPLES: ``` "STRING" -> "STG" "1i2 33 i4i5 i555ii5" -> "33 5" "It is a bit chilly" -> "a cly" "Pineapple pizza is delicious" -> "eapple za deus" "It is not there" -> "not there" ``` NOTES: - There are no apostrophes or any non-alphanumeric characters other than spaces. - Make sure there are no leading or trailing spaces in the result string - You will always be given a valid string. - You won't be provided any empty strings. Good luck and for the Alliance!
reference
import re def purify(s: str) - > str: return ' ' . join(re . sub(r"[\S]?[iI][^\siI]?", "", s). split())
The Culling of Stratholme
634913db7611b9003dff49ad
[ "Strings", "Games", "Regular Expressions" ]
https://www.codewars.com/kata/634913db7611b9003dff49ad
7 kyu
The set of words is given. Words are joined if the last letter of one word and the first letter of another word are the same. Return `true` if all words of the set can be combined into one word. Each word can and must be used only once. Otherwise return `false`. ## Input ```if:csharp,cpp,javascript,java,groovy,ruby,vb,go,rust Array of 3 to 7 words of random length. No capital letters. ``` ```if:python List of 3 to 7 words of random length. No capital letters. ``` ## Example `true` Set: excavate, endure, desire, screen, theater, excess, night.<br> Millipede: desirE EndurE ExcavatE ExcesS ScreeN NighT Theater. ## Example `false` Set: trade, pole, view, grave, ladder, mushroom, president.<br> Millipede: presidenT Trade.
algorithms
from itertools import pairwise, permutations def solution(arr): for perm in permutations(arr, len(arr)): if all(a[- 1] == b[0] for a, b in pairwise(perm)): return True return False
Millipede of words
6344701cd748a12b99c0dbc4
[ "Algorithms", "Arrays", "Strings" ]
https://www.codewars.com/kata/6344701cd748a12b99c0dbc4
6 kyu
**Task:** Given an array of tuples (int, int) indicating one or more buildings height and width, draw them consecutively one after another as in a street. For example, given the input of [(5,9), (7,13)], the output should be: ``` ■■■■■■■■■■■■■ ■ ■ ■■■■■■■■■ ■ ■ ■ ■ ■ ■ ■ ___ ■# ■ ___# ■ ■ | | ■| ■ | || ■ ■ | | ■| ■ | || ■ /////////|/////////|//// ``` **Notes:** - For the building walls use the character ```■``` - The minimum size of a building is (4, 5). ``` ■■■■■ ■___■ ■| |■ ■| |■ ///// ``` - A buildings width is always going to be **odd**. - The sizes of buildings are random. - Some buildings are going to be smaller than others, leaving some space overhead. That represents the sky and should be drawn using spaces ```" "```. ``` ■■■■■■■ ..... <--- ■ ■ ..... <--- Dots used to represent spaces ■ ■ ■■■■■ ■ ■ ■ ■ ■ ___ ■ #___■ ■ | | ■ || |■ ■ | | ■ || |■ /////////|//// ``` - Every building has a door, which looks the same regardless of the buildings height and width. ``` ___ <-- 3 underscores | | | | ``` - Between every building there are 2 spaces ```" "```. However if there is only 1 building there isn't any extra space. - Like every other street, our street has a sidewalk made with the character ```/```. The sidewalk starts from the beginning of the first building to the end of the last building. - Of course, our street has to have street lights, as well. Streetlights are set every 10 spaces, beginning from number 10, not number 1. (9, not 0 in 0-index languages). They are closer forward to the viewer, which is why they will block other objects like building walls, doors, and sidewalks. Streetlights look like this: ``` # | | | ``` So for a street [(5, 9)], there won't be any streetlights, because the street is only 9 units long, and streetlights are set at every tenth place: ``` ■■■■■■■■■ ■ ■ ■ ___ ■ ■ | | ■ ■ | | ■ ///////// ``` But street [(5, 11)], which is 11 units long, will have 1 streetlight: ``` ■■■■■■■■■■■ ■ ■ ■ ___ #■ ■ | | |■ ■ | | |■ /////////|/ ``` In street [(5, 17)] we can see the streetlight obstructing the view of the building door: ``` ■■■■■■■■■■■■■■■■■ ■ ■ ■ __# ■ ■ | | ■ ■ | | ■ /////////|/////// ``` **OUTPUT** Return a string which when printed out looks like the drawings above. ``` Input of [(4,9)] gives '■■■■■■■■■\n■ ___ ■\n■ | | ■\n■ | | ■\n/////////' ```
reference
def draw_street(dimensions): maxHeight = max(map(lambda x: x[0], dimensions)) def building(dimensions): h, w = dimensions return [' ' * w] * (maxHeight - h) + [ '■' * w] + [ '■' + ' ' * (w - 2) + '■'] * (h - 4) + [ '■' + '___' . center(w - 2, ' ') + '■', '■' + '| |' . center(w - 2, ' ') + '■', '■' + '| |' . center(w - 2, ' ') + '■'] view = list(map(' ' . join, zip(* map(building, dimensions)))) view . append('/' * len(view[0])) for i in range(9, len(view[0]), 10): for n in range(1, 5): view[- n] = view[- n][: i] + ['#', '|'][n < 4] + view[- n][i + 1:] return '\n' . join(view)
Draw a street
63454405099dba0057ef4aa0
[ "ASCII Art" ]
https://www.codewars.com/kata/63454405099dba0057ef4aa0
6 kyu
<h1>Task</h1> Given a circuit with fixed resistors connected in series and/or in parallel, calculate the total effective resistance of the circuit. All resistors are given in Ω, and the result should be in Ω too (as a float; tested to ± 1e-6). Assume wires have negligible resistance. The voltage of the battery is irrelevant. The circuit is passed to your function in the following form: <ul> <li>I will define a component as any number of resistors connected in series or in parallel.</li> <li>The entire circuit counts as a component.</li> <li>Each component is an array.</li> <li>A series component will have the boolean true in position zero.</li> <li>A parallel component will have the boolean false in position zero.</li> <li> The other positions will either contain: <ul> <li>Numbers, denoting fixed resistors of that resistance.</li> <li>Arrays, denoting nested components.</li> </ul> </li> <li>A series circuit with no other entries represents a single wire</li> <li>A parallel circuit with no other entries represents a break in the circuit (see below for more details)</li> <li>All circuits will be valid and in the form above (short circuits or broken circuits may appear, though)</li> <li>There will be no negative resistances</li> </ul> Example circuit: ```javascript [ true, // series 20, // 20Ω resistor [ false, // parallel [ true, // series 30, // 30Ω resistor 40, // 40Ω resistor ], 30, // 30Ω resistor ], 60, // 60Ω resistor ] ``` ```python [ True, # series 20, # 20Ω resistor [ False, # parallel [ True, # series 30, # 30Ω resistor 40 # 40Ω resistor ], 30 # 30Ω resistor ], 60 # 60Ω resistor ] ``` Looks like: <img src="https://i.imgur.com/7U1tYzZ.png" /> `20 + 1/(1/(30+40)+1/30) + 60 = 101Ω` <hr> <h1>Short Circuits</h1> It might be the case that the circuit has zero resistance. We don't want zero resistance, as these cause short circuits! You should throw an `Error` instead of returning, with the error message `Short Circuit!` if this ever happens. <hr> <h1>Broken Circuits</h1> It might be the case that all the paths in the circuit have a break in them. This creates infinite resistance, and in effect a broken circuit! You should throw an `Error` instead of returning, with the error message `Broken Circuit!` if this ever happens. Example Circuit: ```javascript [ true, // series 10, // 10Ω resistor [ false, // parallel [ false, // parallel, broken circuit ], [ false, // parallel, broken circuit ], ], ] ``` ```python [ True, # series 10, # 10Ω resistor [ False, # parallel [ False # parallel, broken circuit ], [ False # parallel, broken circuit ] ] ] ``` Looks like: <img src="https://i.imgur.com/Hrv4j1k.png" /> <hr> <h1>Helpful Links</h1> If you don't know or don't remember how to calculate the total effective resistance of a series or parallel circuit, then consult the following two kata. <a href="https://www.codewars.com/kata/57164342794d30e78d000a20"> Series Circuit Kata (myjinxin2015; 7kyu) </a> <br> <a href="https://www.codewars.com/kata/571654c3347e6533fa00186b"> Parallel Circuit Kata (myjinxin2015; 7kyu) </a> Additionally, if you would like to visualise some of the circuits by building them, you can do it online here. <a href="https://www.circuitlab.com/editor/#?id=7pq5wm&from=homepage"> Interactive Circuit Builder (used to create the images above) </a>
algorithms
def series(x): return x def parall(x): return 1 / x if x else float('inf') def rec(circuit): if not isinstance(circuit, list): return circuit test, * circuit = circuit if not circuit: return not test and float('inf') func = test and series or parall return func(sum(func(rec(x)) for x in circuit)) def calculate_resistance(circuit): result = rec(circuit) if result == 0: raise Exception("Short Circuit!") if result == float('inf'): raise Exception("Broken Circuit!") return result
Effective Resistance of a Simple Circuit
63431f9b9943dd4cee787da5
[ "Recursion", "Arrays", "Algorithms", "Fundamentals", "Physics" ]
https://www.codewars.com/kata/63431f9b9943dd4cee787da5
6 kyu
'Evil' numbers are non-negative numbers with even parity, that is, numbers with an even number of `1`s in their binary representation. The first few evil numbers are: ``` 0,3,5,6,9,10,12,15,17,18,20 ``` Write a function to return the n<sup>th</sup> evil number. ```haskell input 1 returns 0 input 2 returns 3 input 3 returns 5 -- etc ``` The tests will include values of `n` up to `10^100`.
algorithms
def is_evil(number): count = 0 while number: number &= number - 1 count += 1 return count % 2 == 0 def get_evil(n): t = 2 * (n - 1) return t if is_evil(t) else t + 1
Find the nth evil number
634420abae4b81004afefca7
[ "Mathematics", "Algorithms", "Performance" ]
https://www.codewars.com/kata/634420abae4b81004afefca7
6 kyu
## Story (skippable): Once upon a time, a farmer came across a magic seed shop. Once inside, the salesman sold him a pack of magical trees. Before leaving, the salesman gave him a warning: "These are no ordinary trees, farmer. These trees split up into smaller, further dividing duplicate trees with each passing day," The salesperson said. The farmer returned home with his purchase and decided to clear a patch of land for the new crop. He planted one down in the middle of his field. Upon returning the next day, the farmer was greeted by two slightly smaller trees in place of the original tree, as promised. The farmer got both very excited and very nervous. He realized he had an easy way to turn a profit. That was great news for him! But he also figured he had no idea of how to predict and report what his profits would be. The farmer needs your help coding a function that can return what the field will look like after a certain number of days. ## Task: You are given a multi-line string `p_field` containing a single magic tree that recursively divides itself into a `split` number of shorter copies every day. Return the p_field after `n` days. The tree's splitting decreases its height by one `|` each generation. Only valid tree's will be asked for, there will be no asking for splitting for more days than possible. **WARNING: These fields can get BIG!!! Make sure your code runs efficiently.** ## Example: The following is the start of a `p_field` with a `split` value of `2`: ``` o | | | ``` On day 1, the field will look like this: ``` oo || || ``` The next day, the field would grow to this: ``` oooo |||| ``` In 3 days, which is the maximum possible `n` value for this example, the field will look like this: ``` oooooooo ``` If `n` is 2, your function needs to return the third `p_field` displayed and return the fourth example if `n` was 3. If `split` is 3, the function instead returns `ooooooooooooooooooooooooooo` on the third day. (1 => 3 => 9 => 27)
algorithms
def magic_plant(p_feild, split, n): t = p_feild . split('\n') return '\n' . join(c * (split * * n) for c in t[: len(t) - n])
Magical Duplication Tree
6339de328a3b8f0016cc5b8d
[ "Mathematics", "Performance", "Algorithms" ]
https://www.codewars.com/kata/6339de328a3b8f0016cc5b8d
7 kyu
This kata is a direct continuation of [Infinite continued fractions](https://www.codewars.com/kata/63178f6f358563cdbe128886/python) kata, and we'll use our ability to compute coefficients of continued fractions for integer factorization. ## The task Perform a first step of [CFRAC method](https://en.wikipedia.org/wiki/Continued_fraction_factorization). Use your solution from [Infinite continued fractions](https://www.codewars.com/kata/63178f6f358563cdbe128886/python) to compute convergents of fraction expansion of `sqrt(N)`. Then write a generator, to continuously yield integer numbers `x` (numerators of fractions) in constant time, such that ```math x^2 \equiv A \mod N\newline A < 2 \sqrt N\newline \sqrt N < x < N - \sqrt N ``` A quite weird task, isn't it? But there is actually a direct motivation for integer factorization and breaking RSA cryptosystems. ```if:racket <u>In Racket, write a stream.</u> ``` ## Example ```math 403 = 13 * 31\newline \newline \sqrt{403} = 20 + \cfrac{1}{ 13 + \cfrac{1}{ 2 + \cfrac{1}{ 1 + \cfrac{1}{3 + \dots } } } }\newline 20 + \cfrac{1}{ 13 } = \cfrac{261}{13}\newline 261^2 \equiv 14 \mod 403\newline 14 < 2 * \sqrt{403}\newline ``` <hr /> ```math 20 + \cfrac{1}{ 13 + \cfrac{1}{ 2 + \cfrac{1}{ 1 + \cfrac{1}{ 3 + \cfrac{1}{ 1 } } }}} = \cfrac{3754}{187}\newline 3754^2 \equiv 127^2 \equiv 9 \mod 403\newline 9 < 2 * \sqrt{403}\newline ``` <u>In the examples above, yield 261 and 127, respectively.</u> ## Motivation Surprising as it is, integer factorization is a very difficult task, if you consider it from the perspective of bit length of integer. It takes Wolfram Alpha mere seconds to [factorize a 128-bit number](https://www.wolframalpha.com/input?i=125534992627552787166417427217919095873). But if you take a product of 2 prime 2048-bits integers, it won't complete factorization in a lifetime of the Earth, though obtaining a product of such 2 primes takes milliseconds. An integer series is surprisingly chaotic and is full of obnoxious prime numbers. On average, you will stumble upon a prime number every `log(N)` steps, if you count up to `N`. These numbers are very different in properties (such that some of them allow quick factorization, but others do not), and the hardest type of factorization task is factorizing RSA-numbers, which are semi-primes with equal-bit-length primes. We'll take a look at certain factorization methods and how continued fractions are useful in them. It all starts with Fermat identity: ```math x^2 = N + y^2\newline N = pq = (x-y)(x+y) ``` Finding such `x` and `y` is no easy task, but [it was noticed](https://en.wikipedia.org/wiki/Congruence_of_squares), that a simpler equation may be solved instead: ```math x^2 = kN + y^2\newline x^2 \equiv y^2 \mod N\newline x \neq \pm y \mod N\newline p = gcd(x - y, N)\newline q = gcd(x + y, N) ``` A bit better, but still far from perfection. Play with some semiprimes, to see that finding a square quadratic residual `y` is too difficult! So what do we do? We collect a bunch of such `x_i` and `y_i`, such that a product of `y_i` gives a square! ```math y_1 y_2 y_3 ... y_n = M^2 \mod N\newline x_1^2x_2^2x_3^2...x_n^2 = y_1 y_2 y_3 ... y_n = M^2 \mod N\newline p = gcd(x_1x_2x_3...x_n - M, N)\newline q = gcd(x_1x_2x_3...x_n + M, N)\newline ``` This is [Dixon's method](https://en.wikipedia.org/wiki/Dixon%27s_factorization_method). To simplify searching for such pairs `x_i`, `y_i`, we only consider quadratic residues `y_i` which are products of small primes. These numbers are called `B-smooth` (no prime factor is larger than `B`). The smaller the residue `y_i`, the higher the chance to find `B-smooth` number. Hence, there are methods that compute modular roots, with corresponding residues of order `sqrt(N)`. (Developing an algorithm to reliably find modular roots, that give even smaller residues, is an incredibly hard task). A [quadratic sieve method](https://en.wikipedia.org/wiki/Quadratic_sieve) uses quadratic residues of `isqrt(N) + A` for small `A`, whereas CFRAC method (a hero of today) utilises convergents of fraction expansion of `sqrt(N)`. ## Notes The tests will validate that yielded numbers satisfy the equations above and that they are different. Your generator will have to yield 6000 numbers for a single `N`.
reference
from typing import Generator from fractions import Fraction import math import itertools def generate_continued_fraction(b) - > Generator[int, None, None]: a, c = 0, 1 while True: if not c: yield from itertools . repeat(0) i = (math . isqrt(b) + a) / / c yield i a, c = c * i - a, (b - a * a) / / c + i * (2 * a - c * i) def generate_modular_roots(n) - > Generator[int, None, None]: p, q = 1, 0 z = math . isqrt(n - 1) for a in generate_continued_fraction(n): p, q = (a * p + q) % n, p if p * p % n < 2 * z and z < p < n - z: yield p % n
Integer factorization: CFRAC basics
63348506df3ef80052edf587
[ "Mathematics", "Algorithms", "Fundamentals", "Performance" ]
https://www.codewars.com/kata/63348506df3ef80052edf587
4 kyu
**Introduction** As a programmer, one must be familiar with the usage of iterative statements in coding implementations! Depending on the chosen programming language, iterative statements can come in the form of `for`, `while`, `do-while` etc. Below is an example of a `nested C-style for-loop`: ```c for(int i = 0; i < A; i++){ // some statements for(int j = 0; j < B; j++){ // some statements for(int k = 0; k < C; k++){ // some statements } } } ``` Where `A`, `B` and `C` are natural numbers. **Task** Given an array of length `N`, where `N` denotes the number of iterative statements. Each item-pair in the array represents two elements, with the `1st value` (`V`) indicating the upper boundary for the iteration to take place (can be inclusive or exclusive depending on the `2nd value`) and the `2nd value` (Boolean data type -> `true` / `false` depending on your chosen language) indicating whether the upper boundary (`V`) is inclusive or not. You must write a function that outputs an array in which each element represents the `number of times each for-loop condition is evaluated`. Below is an example for better understanding: **Example** arr = `[[7, true], [5, false]]` ```c for(int i = 0; i <= 7; i++){ // This statement is executed 9 times before termination -> 0, 1, 2, 3, 4, 5, 6, 7, 8 (since 8 > 7 is the breaking condition) for(int j = 0; j < 5; j++){ // In one cycle of outermost loop, this statement is executed 6 times before termination -> 0, 1, 2, 3, 4, 5 (since 5 >= 5 is the breaking condition) // some statements } } ``` **Note** * The array can be empty, with a range of `0 <= N <= 20` * The starting counter of the `C-style for-loop` is always `0` * The iteration expression or operation to be performed is always `incremental` * The range of upper boundary is as follows: `1 <= V <= 20`
algorithms
def count_loop_iterations(arr): res = [] acc = 1 for n, b in arr: n = n + 2 if b else n + 1 res . append(acc * n) acc *= n - 1 return res
Can you count loop's execution?
633bbba75882f6004f9dae4c
[ "Algorithms" ]
https://www.codewars.com/kata/633bbba75882f6004f9dae4c
7 kyu
<h2 style='color:#f88'>EXPLANATIONS </h2> We will work with the numbers of the form: ```math p_1 × p^2_2 × p^3_3 ×.......× p^n_n ``` and ```math p_1, p_2, p_3, .....,p_n ``` It's a chain of ```n``` consecutive primes. As you can see, each prime is raised to an exponent. All the exponents are in an increasing sequence and the difference of two contiguous exponent is one. In the sequence of primes, sorted by their values, each prime has an ordinal number, 2 is the first one, 3 the second, 5 the third one and so on. Let's have ```k```, an integer that defines an ordinal position that locates the first prime of the chain, so we may say that ```p1``` is the ```k-th``` prime of the sequence. On the other hand, let's have ```n```, the amount of primes of the chain. With these integer two integers, ```k``` and ```n```, the value of the number is defined Let's understand it better with an example: ```k = 20, n = 4``` The 20-th prime is ```71```, and ```n = 4``` means that we have the following calculation: ```math 71 × 73^2 × 79^3 × 83^4 = 8,853,147,752,524,961,321 ``` <h4 style='color:#f88'>THE INVOLUTION</h4> It consists in reversing the order of the exponents. The second integer will be of the form: ```math p^n_1 × ....... × p^1_n ``` According to our example above will be: ```math 71^4 × 73^3 × 79^2 × 83 = 5,120,757,976,852,608,731 ``` So the pair of integers (example #1): ```math 8,853,147,752,524,961,321 ``` ```math 5,120,757,976,852,608,731 ``` they are a corresponding pair in this involution. Why an involution? Because if we reverse twice the exponents, we will get the original number. As we will have huge results (number with many digits) we will use a for the output a special numerical system. <h2 style='color:#f88'>NEW NUMERICAL SYSTEMS?</h2> We can create different numerical systems for integers that use only the capital and small letters of the English alphabet. Yes,they do not use digits. The values of the new digits for a numerical system base = 52 are: ```A = 0, B = 1, C = 2,......Z = 25, a = 26, b = 27, ............, z = 51``` But for a numerical system base ```48```, the available characters to be used will be: ```ABCDE....XYZabcde....tuv``` But with one of base ```36```: ```ABCDE....XYZabcde.....hij``` Let's see the equivalent numbers with different bases comparing with our decimal system. <li><code style='color:#f88'>N = 18,725 = GwF<sub> 52</sub></code> <li><code style='color:#f88'>N = 1,854,290 = QknC<sub> 48</sub></code> <li><code style='color:#f88'>N = 2,354,225,960 = BChXINU<sub> 36</sub></code> <li><code style='color:#f88'>N = 988,562,945,281,908 = cDCefTCDbU<sub> 32</sub></code> <li><code style='color:#f88'>N = 9,885,629,452,819,081,894,567 = CBHOGKKPLAHIEJCJKKH<sub> 16</sub></code> So, the pair of numbers are related in the involution of example #1 converted to integers in base 36 of our numerical system will be: <li><code style='color:#f88'>BfJPWiSdcGMbd<sub> 36</sub></code> <li><code style='color:#f88'>BCgVBHOZREBaj<sub> 36</sub></code> <h2 style='color:#f88'>THE TASK</h2> We need a code that receives the following 3 integers as inputs: - ```k```, ordinal number of the corresponding prime in a sorted increasing sequence of primes - ```n```, number of consecutive primes that form the product of powers - ```base```, the base of the numeriacal system that may have values multiple of ```4``` and below or equal ```52```. The code should output a tuple with the pair of the integers encoded into the base required, the starting number ```i1``` and the result of the involution ```i2``` ``` inputs output k, n, base (i1, i2) ``` ``` Examples: (7,5,52) ----------> ('DtHUiBNcDuNnl','HqByzLEKFuRt') (20,4,36) ---------> ("BfJPWiSdcGMbd", "BCgVBHOZREBaj") (34,6,48) ---------> ('GYZEGPcXqMTMgVQNfpRVOXGvvBAf', 'BriSOCpdlVojsMcErcFPEeVpQqWf') ``` <h2 style='color:#f88'>THE TESTS</h2> There will be almost 200 tests to pass the kata. These are the following ranges or values for the inputs in the tests. ``` 5 ≤ k ≤ 700 2 ≤ n ≤ 20 4 ≤ base ≤ 52 ``` All the inputs will be valid, three positive integers for each test. Do your best! All observations in ortography, grammar or in the use of English in general are welcome. Thanks for that.
reference
def primes(n): sieve = n / / 2 * [True] for i in range(3, int(n * * 0.5) + 1, 2): if sieve[i / / 2]: sieve[i * i / / 2:: i] = [False] * ((n - i * i - 1) / / (2 * i) + 1) return [2] + [2 * i + 1 for i in range(1, n / / 2) if sieve[i]] from string import ascii_uppercase as u, ascii_lowercase as l def to_base(n, b, w=u + l): return w[n] if n < b else to_base(n / / b, b). lstrip(w[0]) + w[n % b] def transform(nums, exponents): from math import prod return prod(p * * i for p, i in zip(nums, exponents)) def solver(k, n, base, seq=primes(10 * * 4)): assert k + n - 1 <= len(seq) chain, exp = seq[k - 1: k + n - 1], range(1, n + 1) return tuple(to_base(transform(chain, es), base) for es in (exp, exp[:: - 1]))
Involution in Numbers of Different Bases Using the Alphabetical System.
632abe6080604200319b7818
[ "Mathematics", "Number Theory" ]
https://www.codewars.com/kata/632abe6080604200319b7818
6 kyu
Twelve cards with grades from `0` to `11` randomly divided among `3` players: Frank, Sam, and Tom, `4` cards each. The game consists of `4` rounds. The goal of the round is to move by the card with the most points.<br> In round `1`, the first player who has a card with `0` points, takes the first turn, and he starts with that card. Then the second player (queue - Frank -> Sam -> Tom -> Frank, etc.) can move with any of his cards (each card is used only once per game, and there are no rules that require players to make only the best moves). The third player makes his move after the second player, and he sees the previous moves.<br> The winner of the previous round then makes the first move in the next round with any remaining card.<br> The player who wins `2` rounds first, wins the game. ## Task Return `true` if Frank has a chance of winning the game.<br> Return `false` if Frank has no chance. ## Input `3` arrays of `4` unique numbers in each (numbers in array are sorted in ascending order). Input is always valid, no need to check. ## Example Round `1`: Frank ` 2 5 8 11 `, Sam ` 1 4 7 10 `, Tom ` 0 3 6 9 `. Tom has to start from `0`. Frank is risking nothing and goes `2`. Sam gets lucky and wins round by throwing `4`. Round `2`: Frank ` 5 8 11 `, Sam ` 1 7 10 `, Tom ` 3 6 9 `. Sam starts from `1`. Tom goes `3`, Frank wins with `5`. Round `3`: Frank ` 8 11 `, Sam ` 7 10 `, Tom ` 6 9 `. Frank starts from `11` and wins the round either way. Frank is the first to win `2` rounds and therefore wins the game, the answer is `true`. ## One more example Frank ` 0 1 2 3 `, Sam ` 6 7 8 11 `, Tom ` 4 5 9 10 `.<br> With these cards Frank has no chance, the answer is `false`. ## Tip Players can actually play DUMB moves, especially Sam and Tom.
games
def solution(frank, sam, tom): count = 0 for i in range(4): for j in range(4): if frank[j] > sam[i] and frank[j] > tom[i]: count += 1 frank[j] = 0 break return count >= 2
Another card game
633874ed198a4c00286aa39d
[ "Algorithms", "Games" ]
https://www.codewars.com/kata/633874ed198a4c00286aa39d
7 kyu
There are `N` lights in the room indexed from `0` to `N-1`. All the lights are currently off, and you want to turn them on. At this point, you find that there are `M` switches in the room, indexed from `0` to `M-1`. Each switch corresponds to several lights. Once the switch is toggled, all the lights related to the switch will change their states. Please write a program to check if there is a way to turn all the lights on. ## Input/Output The input is a two-dimensional array representing relationships between lights and switches. The first dimension represents the switches, and the second dimension represents the lights corresponding to each switch. You should output whether it is possible to turn all the lights on. It's guaranteed that `$1 \leq min(N, M) \lt 16$`, `$max(N, M) \lt 32$`. ## Example Given 5 lights and 4 switches. The correspondence between switches and lights: ``` [ [0, 1, 2], // switch 0 controls light 0, 1, 2 [1, 2], // switch 1 controls light 1, 2 [1, 2, 3, 4], // switch 2 controls light 1, 2, 3, 4 [1, 4] // switch 3 controls light 1, 4 ] ``` Initial lights: ``` 0 0 0 0 0 ``` Toggle switch 0: ``` 1 1 1 0 0 ``` Toggle switch 2: ``` 1 0 0 1 1 ``` Toggle switch 1: ``` 1 1 1 1 1 ``` Now all the lights are on. It should return true. ## Tips [Spoiler Alert] Some of the hints may affect your problem solving experience: - <span style="color: gray; background-color: gray">This kata can be solved by searching algorithms. If you have no clue about how to solve this, try BFS(Breadth First Search). But there are better ways.</span> - Pay attention to the time complexity. It's impossible to brute force all `$2^{31}$` possiblities in the given time. - The optimial solution has time complexity of `$O(MN^2)$`. Can you figure it out?
algorithms
def light_switch(n, lights): result = {0} for s in lights: result |= {x ^ sum(1 << x for x in s) for x in result} return (1 << n) - 1 in result
Light Switch
63306fdffa185d004a987b8e
[ "Algorithms", "Puzzles", "Searching", "Performance" ]
https://www.codewars.com/kata/63306fdffa185d004a987b8e
5 kyu
The greatest common divisor (gcd) of two non-negative integers `$a$` and `$b$` is, well, their greatest common divisor. For instance, `$ \mathrm{gcd}(6, 4) = 2$` and `$ \mathrm{gcd}(100, 17) = 1$`. Note that in these cases the gcd can be expressed as a linear combination with integer coefficients of the given two numbers a and b: * `$2 = \mathrm{gcd}(6,4) = 1\cdot 6 + (-1)\cdot 4$` --> with coefficients 1 and -1 * `$1 = \mathrm{gcd}(100, 17) = 8\cdot 100 + (-47)\cdot 17 $` --> with coefficients 8 and -47. More generally, given any two non-negative integers `$a$` and `$b$`, their gcd can always be expressed as a linear combination of `$a$` and `$b$` using integer coefficients. In other words, there exist integer numbers `$x$` and `$y$` such that: `$ \mathrm{gcd}(a, b) = x\cdot a + y\cdot b$`. Note that the coefficients `$x$` and `$y$` are not determined uniquely. Your goal is to write the function gcd_coeff that accepts two non-negative integers `$a$` and `$b$` and returns a tuple `$(x, y)$` of integer coefficients `$x$` and `$y$` expressing `$\mathrm {gcd}(a, b)$` as `$x\cdot a + y\cdot b$`. You may assume that `$a \ge b$` is always satisfied. Note: Testing will involve randomly chosen integers of large magnitude, so efficiency is of importance.
algorithms
from gmpy2 import gcdext def gcd_coeff(a, b): _, x, y = gcdext(a, b) return int(x), int(y)
Greatest common divisor as linear combination
63304cd2c68f640016b5d162
[ "Algorithms", "Mathematics", "Number Theory", "Cryptography" ]
https://www.codewars.com/kata/63304cd2c68f640016b5d162
6 kyu
In a computer operating system that uses paging for virtual memory management, page replacement algorithms decide which memory pages to page out when a page of memory needs to be allocated. Page replacement happens when a requested page is not in memory (page fault) and a free page cannot be used to satisfy the allocation, either because there are none, or because the number of free pages is lower than some threshold. ## The LRU page replacement algorithm The least recently used (LRU) page replacement algorithm works on the idea that pages that have been most heavily used in the past few instructions are most likely to be used heavily in the next few instructions too. If not all the slots in memory are occupied, the requested page is inserted in the first available slot when a page fault happens. If the memory is full and a page fault happens, the least recently used page in memory gets replaced by the requested page. To explain it in a clearer way: the least recently used page is the page that is currently in memory and has been referenced further in the past.<br> Your task is to implement this algorithm. The function will take two parameters as input: the number of maximum pages that can be kept in memory at the same time ```n``` and a ```reference list``` containing numbers. Every number represents a page request for a specific page (you can see this number as the unique ID of a page). The expected output is the status of the memory after the application of the algorithm. Note that when a page is inserted in the memory, it stays at the same position until it is removed from the memory by a page fault. ## Example: Given: * N = 3, * REFERENCE LIST = \[1, 2, 3, 4, 3, 2, 5\], ``` * 1 is read, page fault --> free memory available, memory = [1]; * 2 is read, page fault --> free memory available, memory = [1, 2]; * 3 is read, page fault --> free memory available, memory = [1, 2, 3]; * 4 is read, page fault --> LRU = 1, memory = [4, 2, 3]; * 3 is read, already in memory, nothing happens; * 2 is read, already in memory, nothing happens; * 5 is read, page fault --> LRU = 4, memory = [5, 2, 3]. ``` So, at the end we have the list ```[5, 2, 3]```, which is what you have to return. If not all the slots in the memory get occupied after applying the algorithm, fill the remaining slots (at the end of the list) with ```-1``` to represent emptiness (note that the IDs will always be >= 1).
algorithms
def lru(n, reference_list): cache, time = [- 1] * n, [- 1] * n for i, x in enumerate(reference_list): idx = cache . index(x) if x in cache else time . index(min(time)) cache[idx] = x time[idx] = i return cache
Page replacement algorithms: LRU
6329d94bf18e5d0e56bfca77
[ "Algorithms", "Lists" ]
https://www.codewars.com/kata/6329d94bf18e5d0e56bfca77
6 kyu
## Overview Suppose you build a pyramid out of unit-cubes, starting from a square base, and such that cubes stack exactly onto cubes below them (they do not overlap or sit on "lines" in the level below theirs). For example: if you start with a square base of side = 7 cubes, your first level has a total of `7**2 = 49` unit cubes. Your second level has a square base of side = 5 cubes and consists of `5**2 = 25` unit cubes. Your third level has a square base of side = 3 cubes and consists of `3**2 = 9` unit cubes. Your fourth level - the top one - has a square base of side = 1 cube and consists of only `1` unit cube. In this example, we have built a pyramid of `height = 4` levels. Now that you built your pyramid, you decide to paint all of its exterior surface with red paint (You **do not** paint "under" the pyramid base though). Then you break up your entire pyramid into its constituent unit cubes and put all the unit cubes into a bag. **If you now pick one unit cube out of this bag at random, and then roll it once as if it were a dice, what is the probability that you will obtain a red-painted face?** --- ## Complete Walk-through Example with `height = 4` Referring to the example above, notice how the **different unit cubes will end up having different numbers of red faces**: - On level 4, i.e. the top of pyramid, there is 1 single cube which has **5** red faces. - Then on levels 1,2 and 3, there are 4 "corner cubes" which each have **3** red faces, for a total of 12 "corner cubes". - On levels 1,2 and 3 there are also "edge cubes" which each have **2** red faces. There are 20 edge cubes on level 1, 12 edge cubes on level 2, and 4 edge cubes on level 3, for a total of 20+12+4 = 36 "edge cubes". - Finally there are also "internal cubes" which have **0** red faces. In this pyramid of `height = 4` there are 35 internal cubes. When you "roll the dice", in some cases you will get very lucky and randomly pick the top-most cube out of the bag, which has 5 red faces, and therefore you will have a `5/6` probability of getting a red-painted face when you roll that dice. But, sadly, there is only 1 such dice in your bag so you have a low chance of picking it at random. On the other hand, in many other cases you will be unlucky and pick one of the many internal cubes which do not have any red painted faces, and will therefore have a `0/6` probability of getting a red face. The **total probability** for this `height = 4` pyramid is therefore broken down as follows: ```python (1 /(1+12+36+35)) * (5/6) # 1 top cube with a probability 5/6 of obtaining red +(12/(1+12+36+35)) * (3/6) # 12 corner cubes each with a red probability of 3/6 +(36/(1+12+36+35)) * (2/6) # 36 edge cubes each with a red probability of 2/6 +(35/(1+12+36+35)) * (0/6) # 35 internal cubes each with a red probability of 0/6 __________________________ (113/504) # total probability of obtaining a red face ``` --- ## Inputs and Outputs You will receive an `integer`, `height >= 1`, which counts the number of levels of your pyramid. In the example used above, the `height` is equal to `4`. The first level of the square pyramid therefore has side-length = `2 * height - 1` unit cubes. You must return a `2-ple` of `integers` representing the total probability expressed as a fraction, in the form `(numerator, denominator)` where `numerator < denominator` corresponding to the fact the total probability is `< 1`. Since this is a problem involving discrete probability you will always be able to obtain a result involving only integers, so this avoids you having to express the probability as a real number involving `floats`. You **do not** have to express your "fraction" result in lowest common denominator - for example, if the simplest result is `(2,7)` then the result `(10,35)` will also be accepted as it represents the same fractional probability. ## Code Golf Requirement Depending on language, your code must consist of: - Python: `<= 45` characters - JavaScript: `<= 39` characters
games
def pyramid(h): return (8 * h * h - 4 * h + 1, 8 * h * * 3 - 2 * h)
[Code Golf] Painted Pyramid Probability Puzzle
62f7ca8a3afaff005669625a
[ "Puzzles", "Mathematics", "Restricted", "Probability" ]
https://www.codewars.com/kata/62f7ca8a3afaff005669625a
6 kyu
### Task Given Points `A`, `B`, `C` ∈ ℤ<sup>2</sup> and `dA`, `dB`, `dC` ∈ ℤ their respective squared euclidian distances to a certain point `P` ∈ ℤ<sup>2</sup>, return the value of `P`. ### Note A, B, and C will always be distinct and non-collinear
games
def triangulate(A, dA, B, dB, C, dC): a11, a21 = 2 * (B[0] - A[0]), 2 * (C[0] - A[0]) a12, a22 = 2 * (B[1] - A[1]), 2 * (C[1] - A[1]) b1, b2 = dA - dB - A[0] * * 2 - A[1] * * 2 + B[0] * * 2 + B[1] * * 2, dA - dC - A[0] * * 2 - A[1] * * 2 + C[0] * * 2 + C[1] * * 2 dt = a11 * a22 - a12 * a21 x, y = (b1 * a22 - a12 * b2) / / dt, (a11 * b2 - b1 * a21) / / dt return (x, y)
Locate P using 3 Points and their distances to P
6326533f8b7445002e856ca3
[ "Mathematics", "Geometry" ]
https://www.codewars.com/kata/6326533f8b7445002e856ca3
6 kyu
## Overview Given an `integer`, `n`, consider its binary representation - I shall call a **binary bunching of `n`** any rearrangement of the bits of `n` such that all **set bits are contiguous** (i.e. all its `1`s are side-by-side when viewed as a string). There are many possible ways of binary bunching the bits of `n`; for each possible way, we can calculate its **bunching cost** - this is the **number of bit flips necessary to reach the final binary number from the initial value of `n`.** An example will make all this clear: If we take `n = 52` then in binary `n = 110100`. We see that there are **6 bits** in the binary representation `n = 110100`. There are only 4 possible ways to binary bunch rearrange these **6 bits** of `n = 110100`, listed here with the number of bit flips necessary to do so in each case: - `110100 -> 000111`, requires flipping 1st, 2nd, 5th, 6th bits, so total bunching cost = 4 - `110100 -> 001110`, requires flipping 2nd, 4th, 5th, 6th bits, so total bunching cost = 4 - `110100 -> 011100`, requires flipping 4th, 6th bits, so total bunching cost = 2 - `110100 -> 111000`, requires flipping 3rd, 4th bits, so total bunching cost = 2 Finally, we shall call the **Binary Bunch Transform** of `n` the **smallest** number among all possible numbers which have the **lowest possible bunching cost**. So returning to the above example, of the 4 possible ways of binary bunching `n = 52 = 110100`, the lowest possible bunching cost is `2` and of two possible numbers that shared this minimum bunching cost (`111000 = 56`, and `011100 = 28`) the smallest is 28. Therefore `bunch(52) = 28`. --- ## Inputs and Outputs You will be given a positive `integer`, `n > 0`. Values of `n` up to `2**32` will be tested (depending on language). You must return an `integer`, the Binary Bunch Transform of `n` as defined above. --- ## Further examples with small values Here are some further small examples you can check by hand if you want, before coding your solution. `n = 19 = 10011` -> transforms to `00111` in 2 bit flips, which is the smallest number of bit flips needed to get all `1`s bunched together. `00111` is the smallest bunched binary number that can be reached in 2 bit flips starting from `n = 19 = 10011`. `00111` represents the integer `7` so `bunch(19) = 7`. `n = 49 = 110001` -> transforms to `111000` in 2 bit flips, which is the smallest number of bit flips needed to get all `1`s bunched together. `111000` is the smallest bunched binary number that can be reached in 2 bit flips starting from `n = 49 = 110001`.`111000` represents the integer `56` so `bunch(49) = 56`.
reference
def bunch(n): s, w = n . bit_length(), n . bit_count() base = (1 << w) - 1 chunks = (base << i for i in range(s - w + 1)) return min(chunks, key=lambda v: ((n ^ v). bit_count(), v))
Binary Bunch Transform of an Integer
62cc5882ea688d00428ad2b0
[ "Fundamentals", "Binary" ]
https://www.codewars.com/kata/62cc5882ea688d00428ad2b0
6 kyu
<h2 style="color:#4bd4de">Description</h2> In mathematics, and more specifically number theory, the hyperfactorial of a positive integer `$n$` is the product of the numbers `$1^1 , 2^2, ..., n^n $`: `$H(n) = 1^1 \times 2^2 \times 3^3 \times ... \times (n-1)^{n-1} \times n^n$` `$H(n) = \prod_{i=1}^{n} i^i $` <a href="https://en.wikipedia.org/wiki/Hyperfactorial">Check out this Wikipedia article for more detail</a> <h2 style="color:#62d941">Your task</h2> Implement a function `hyperfact(num)` that takes a positive integer `num` and returns the hyperfactorial of it. In order for your answer not to be too messy (hyperfactorial of 100 is 9015 digits long) give the answer modulo 1000000007. <h2 style="color:#62d941">Notes</h2> `1 <= n <= 300` `50` random tests
reference
from itertools import accumulate H = [0, * accumulate(range(1, 301), lambda a, n: a * n * * n % 1000000007)] hyperfact = H . __getitem__
The Hyperfactorial
6324786fcc1a9700260a2147
[ "Mathematics" ]
https://www.codewars.com/kata/6324786fcc1a9700260a2147
7 kyu
```if-not:c This kata is about static method that should return different values. ``` ```if:c This kata is about a function that should return different values. ``` On the first call it must be 1, on the second and others - it must be a double from previous value. Look tests for more examples, good luck :)
reference
class Class: value = 1 def get_number(): result = Class . value Class . value *= 2 return result
Double value every next call
632408defa1507004aa4f2b5
[ "Object-oriented Programming" ]
https://www.codewars.com/kata/632408defa1507004aa4f2b5
7 kyu
I invented a new operator, ```@```, which is left associative. ```a @ b = (a + b) + (a - b) + (a * b) + (a // b)``` Side note: ```~~``` is shorthand for ```Math.floor```. Given a string containing only integers and the operators, find out the value of that string. The strings will always be "well formed", meaning with a space on each side of the operators, except in TypeScript, where string may appear like this: ```0@1@2``` ``` 1 @ 1 = (1 + 1) + (1 - 1) + (1 * 1) + (1 // 1) = 4 3 @ 2 = 13 6 @ 9 = 66 4 @ -4 = -9\ 1 @ 1 @ -4 = -9 (1 @ 1 is 4, 4 @ -4 is -9) 2 @ 2 @ 2 = 40 0 @ 1 @ 2 = 0 5 @ 0 = None ``` Good luck!
algorithms
from functools import reduce def evaluate(equation): try: return reduce(lambda a, b: a * (b + 2) + a / / b, map(int, equation . split(' @ '))) except ZeroDivisionError: pass
The @ operator
631f0c3a0b9cb0de6ded0529
[ "Algorithms" ]
https://www.codewars.com/kata/631f0c3a0b9cb0de6ded0529
7 kyu
I suggest you write a program that, having a string containing the solution of the level for the game Sokoban, will restore the original level. <i>The rules of the Sokoban:</i><br> The objective of the Sokoban game is to move objects (usually boxes) to designated locations by pushing them. These objects are located inside a room surrounded by walls. The user controls a pusher called "Sokoban" which is said to mean something like "warehouse keeper" in Japanese. The pusher can move up, down, left and right, but cannot pass through walls or boxes, and can only push one box at a time (never pull). At any time, a square can only be occupied by either a wall, a box, or the pusher. <img src="https://upload.wikimedia.org/wikipedia/commons/4/4b/Sokoban_ani.gif"> You can read more about this game here:<br> https://en.wikipedia.org/wiki/Sokoban<br> http://www.sokobano.de/wiki/index.php?title=Main_Page<br><br> you can play in this game:<br> https://sourceforge.net/projects/sokobanyasc/<br> https://sokoban.info/<br><br> <b>TASK:</b> as input, your function will receive a string containing the solution of the level. notation format "LURD"<br> the characters "lurd" (lowercase) indicate the movement of the player to the left, up, right, down.<br> the symbols "LURD" (in uppercase) indicate that the player pushes the box left, up, right, down.<br> (letters in uppercase imply that the player is sure to push the box) ``` solution = "urrrrDrdddldlluuurRlldddrruruUluullllddddRluuuurrrrddrddldllUdrruruulllLrrruulllldDrrrrrddldlluUddrruruuluullllddrRRldddrruruuruLdddldlluuurUdldddrruruuuLuLLLrrrdrdddldlluuurUruLLrddRlldddrruruUruLLdlUruL" ``` at the output, your function should return the drawn level inside the text string.<br> there must be no spaces at the end of substrings, and there must be an end-of-line character "\n" ``` map = """ ####### #... ### #@##$$ # # $ # #.# ## ## # $ # # ### ## ##### """ ``` description of the level format you can find here:<br> http://www.sokobano.de/wiki/index.php?title=Level_format<br> Wall - "#", Player - "@", Player on goal - "+", Box - "$", Box on goal - "*", Goal - ".", Floor - " " (Space)<br><br> when creating a level map, you should add a minimum of elements, only what is necessary. you can not add extra walls and boxes with which the player does not interact.<br> Minimal amount of free space inside the outer bound. Minimal amount of boxes. Outer bound must be of thickness of 1, connected orthogonally and minimal. The level must be drawn with no extra spaces on either side.<br><br> <b>Technical Details</b> * Input will always be valid solution for real level. * level size < 50*50 * you need find solution for 35 hand-made levels, +90 random-generated levels
algorithms
# Just having some fun with the new match/case :D def level_recovery(solution): D, boxes, i, j = {}, set(), 0, 0 for c in solution: D[(i, j)] = ' ' match c: case 'l' | 'L': k, l = 0, - 1 case 'r' | 'R': k, l = 0, 1 case 'u' | 'U': k, l = - 1, 0 case 'd' | 'D': k, l = 1, 0 if c . isupper(): if (i + k, j + l) not in D: boxes . add((i + k, j + l)) D[(i + k, j + l)] = ' ' D[(i + 2 * k, j + 2 * l)] = '.' i, j = i + k, j + l for i, j in boxes: match D[(i, j)]: case '.': D[(i, j)] = '*' case ' ': D[(i, j)] = '$' match D[(0, 0)]: case '.': D[(0, 0)] = '+' case ' ': D[(0, 0)] = '@' Y, X = zip(* D) x, y = min(X) - 1, min(Y) - 1 H, W = max(Y) - y + 2, max(X) - x + 2 res = [[' '] * W for _ in range(H)] for i in range(H): for j in range(W): if (i + y, j + x) in D: res[i][j] = D[(i + y, j + x)] elif any((k + y, l + x) in D for k in range(i - 1, i + 2) for l in range(j - 1, j + 2)): res[i][j] = '#' return '\n' . join(map(str . rstrip, map('' . join, res)))
Sokoban re-solver : level recovery from solution
6319f8370b9cb0ffc2ecd58d
[ "Game Solvers", "Games", "Puzzles", "Algorithms" ]
https://www.codewars.com/kata/6319f8370b9cb0ffc2ecd58d
5 kyu
_The world of reality has its limits; the world of imagination is boundless._ Jean-Jacques Rousseau Each positive integer may have a specific set of pairs of factors which each value equals the number. But, how can it possible to get an _area value_ for each positive integer? In order to get that value for an integer, ```N, N > 0```, we should follow the next steps described below: 1. We get a list of all the pairs of *a<sub>i</sub> , b<sub>i</sub>* such that: *a<sub>i</sub> × b<sub>i</sub> = N* 2. We sort the pairs by the value of the first factor. 3. We represent each pair of factors as it were a point with its coordinates in a cartesian system, the value of a<sub>i</sub> for the x-axis and the b<sub>i</sub> for y-axis coordinates. 4. We draw vertical lines at x = 1 and at x = N 5. We join the contiguous points with segments and we will obtain an irregular polygonal line or a triangle in some easier cases. 6. We calculate the area below the polygonal line between the two vertical lines and the x- axis. 7. We round the value to the lower integer, ```area --> ⌊a⌋``` Let´s see an example with N = 12. The factors obtained are (already sorted by first factor): ```(1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)``` Because: ```12 = 1 × 12 = 2 × 6 = 3 × 4 = 6 × 2 = 12 × 1``` Following all the steps explained above we have the following image: <a href="https://ibb.co/fMrSnXP"><img src="https://i.ibb.co/MnPhGg3/geogebra-export.png" alt="geogebra-export" border="0"></a> As you can see the associated value for ```12``` will be the value of the coloured area ```31.5```. We round down the value and we get ```31```. Another example with a perfect square, ```N = 16```. The factors pairs for it are: ```(1, 16), (2, 8), (4, 4), (8, 2), (16, 1)``` The corresponding area value for the integer ```16``` is ```48```. Let´s get this associated value por a prime number, let´s see, ```N = 23``` The factors for this number will be: ```(1,23), (23,1)``` So the value for the area will be ```264```. If the value of ```N``` is ```1```, it is easy to figure out the the area associated value should be ```0```. But if ```N = 0``, there is no associated value. **_TASK_** You have to create a code that receives a positive integer N, and outputs another integer, A<sub>N</sub>, the associated value for the area. Summarizing the inputs with their corresponding output and adding some new ones: ``` N AN 1 0 12 31 16 38 23 264 36 136 100 495 ``` You will have to pass ```500``` tests and the values in the following range: 1 ≤ N < 1 × 10<sup>13</sup> You will find more fixed cases in the sample box. Enjoy it! I´ll appreciate all the observations, suggestions or issues from users that want quality and simplicity. I'm preparing the JavaScript and Ruby versions for it.
reference
def area_value(n): res, i, j = 0, 1, 2 while j * j <= n: if n % j == 0: res += n / / i * j - n / / j * i i = j j += 1 return 0 if n < 2 else res + ((n / / i) * * 2 - i * i) / / 2
Positive Integers Having Specific Area? # 1
631373e489d71c005d880f18
[ "Mathematics", "Geometry" ]
https://www.codewars.com/kata/631373e489d71c005d880f18
6 kyu
In a string we describe a road. There are cars that move to the right and we denote them with ">" and cars that move to the left and we denote them with "<". There are also cameras that are indicated by: " . ". <br> A camera takes a photo of a car if it moves to the direction of the camera. <b style="font-size: 20px;">Task</b> <br> Your task is to write a function such that, for the input string that represents a road as described, returns the total number of photos that were taken by the cameras. The complexity should be strictly O(N) in order to pass all the tests. <br> <b>Examples</b> ```javascript For ">>." -> 2 photos were taken For ".>>" -> 0 photos were taken For ">.<." -> 3 photos were taken For ".><.>>.<<" -> 11 photos were taken ```
algorithms
def count_photos(road): photos = 0 left = 0 dot_founds = 0 for item in road: if item == ">": left += 1 elif item == ".": photos += left dot_founds += 1 elif item == "<": photos += dot_founds return photos
Count the photos!
6319dba6d6e2160015a842ed
[ "Algorithms", "Performance", "Arrays" ]
https://www.codewars.com/kata/6319dba6d6e2160015a842ed
6 kyu
You are given a list/array of example equalities such as: [ "a + a = b", "b - d = c ", "a + b = d" ] Use this information to solve a given `formula` in terms of the remaining symbol such as: formula = "c + a + b" In this example: "c + a + b" = "2a" so the output is `"2a"`. Notes: * Variables names are case sensitive. * There might be whitespaces between the different characters. Or not... * There should be support for parentheses and their coefficient. Example: `a + 3 (6b - c)`. * You may encounter several imbricated levels of parentheses, but you'll get only constant terms for the accompanying coefficients (never variables). * All equations will be linear. * In your final answer, include a leading 1 when the coefficient is 1 (e.g. `1j` instead of just `j`). * There are no floating-point numbers. See the sample tests for clarification on what exactly the input/ouput formatting should be. Without giving away too many hints, the idea is to substitute the examples into the formula and reduce the resulting equation to one unique term. Look carefully at the example tests: you'll have to identify the pattern used to replace variables in the formula/other equations. Using this pattern, only one solution is possible for each test, so if you keep asking yourself "but what if instead of that I do...", then you've missed the pattern. ```if:ruby Note: `eval` and other related things have been disabled. ```
games
import re token = re . compile(r'([+-]?)\s*(\d*)\s*([a-zA-Z\(\)])') def substitute(formula, substitutes): res = formula for var, sub in substitutes: res = res . replace(var, '({})' . format(sub)) return res if res == formula else substitute(res, substitutes) def reduce(tokens): res = dict() for sign, num, var in tokens: if var == ')': return res coef = int(sign + (num or '1')) if var == '(': for k, v in reduce(tokens). items(): res[k] = res . get(k, 0) + coef * v else: res[var] = res . get(var, 0) + coef return res def simplify(examples, formula): substitutes = [(k . strip(), v) for v, k in map(lambda x: x . split('='), examples)] subbed = substitute(formula, substitutes) reduced = reduce(iter(token . findall(subbed))) return '' . join(map('{0[1]}{0[0]}' . format, reduced . items()))
Simplifying
57f2b753e3b78621da0020e8
[ "Games", "Puzzles" ]
https://www.codewars.com/kata/57f2b753e3b78621da0020e8
3 kyu
A continuation kata published: [Integer factorization: CFRAC basics](https://www.codewars.com/kata/63348506df3ef80052edf587) ## General info A [continued fraction](https://en.wikipedia.org/wiki/Continued_fraction) is a mathematical expression of the following form: ```math [a_0; a_1, a_2, a_3, ..., a_n, ...] = a_0 + \cfrac{1}{ a_1 + \cfrac{1}{ a_2 + \cfrac{1}{ \ddots + \cfrac{1}{a_n + \dots} } } } ``` Any real number may be represented in the following form with integer coefficients. In fact, all rational numbers have finite representation, and all irrational numbers have infinite representation. The latter case is exactly, what we've come for today :D The specific numbers we are obsessed with in this kata are <u>square roots of natural numbers</u>. Continued fractions of square roots are **periodic** and always take a specific form: ```math \sqrt{N} = [a_0; \overline{a_1, a_2, a_3, ..., a_3, a_2, a_1, 2 a_0}] = a_0 + \cfrac{1}{ a_1 + \cfrac{1}{ a_2 + \cfrac{1}{ \ddots + \cfrac{1}{a_2 + \cfrac{1}{ a_1 + \cfrac{1}{ 2 a_0 + \cfrac{1}{ a_1 + \dots } } }} } } } ``` ## The task ```if:python,javascript Your task will be to write a <u>generator function to yield integer coefficients of the continued fraction of `sqrt(N)`</u>. Not only coefficients must be precise, but you'll have to deal with numbers up to `2^1024`. ``` ```if:racket,java Your task will be to write a <u>stream of integer coefficients of the continued fraction, of `sqrt(N)`</u>. Not only coefficients must be precise, but you'll have to deal with numbers up to `2^1024`. ``` Tip: the amount of coefficients before hitting the period is bounded by `0.72 * sqrt(N)`, but obviously we cannot generate that much in adequate time for big numbers. The test suite expects your code to generate <u>2000-4000 coefficients for a single number</u>. You may want to solve other katas about continued fractions: - [Evaluating Continued Fractions](https://www.codewars.com/kata/6013d4f5c7c63100095952aa) - [Exponentials as Fractions](https://www.codewars.com/kata/54f5f22a00ecc4184c000034) - [Pi approximation fractions](https://www.codewars.com/kata/5b7c17fabd29b22df000004f) - [Convergents of e](https://www.codewars.com/kata/5a8d63930025e92f4c000086)
algorithms
from typing import Generator from math import isqrt def generate_continued_fraction(n) - > Generator[int, None, None]: a0 = isqrt(n) a, b, c = a0, 0, 1 yield a0 while True: b = c * a - b c = (n - b * b) / / c if not c: break a = (a0 + b) / / c yield a while True: yield 0
Infinite continued fractions
63178f6f358563cdbe128886
[ "Mathematics", "Fundamentals", "Performance" ]
https://www.codewars.com/kata/63178f6f358563cdbe128886
5 kyu
<div style="width: 100%; margin: 16px 0; border-top: 1px solid grey;" /> - This is Part 2 of this series of two katas — Part 1 is [here](https://www.codewars.com/kata/630647be37f67000363dff04). - If you like playing cards, have also a look at [Hide a message in a deck of playing cards](https://www.codewars.com/kata/59b9a92a6236547247000110) and [Card-Chameleon, a Cipher with Playing cards](https://www.codewars.com/kata/59c2ff946bddd2a2fd00009e). <div style="width: 100%; margin: 16px 0; border-top: 1px solid grey;" /> In [Part 1](https://www.codewars.com/kata/630647be37f67000363dff04) of this series, we were given a deck and we had to return the order of the cards once drawn using a particular procedure. Here, we will do the opposite: we will be given the drawn cards, and we'll have to return the deck that would produce this result if drawn using the procedure. The procedure isn't explained here again, please read it on [Part 1](https://www.codewars.com/kata/630647be37f67000363dff04). # Your task Write a function accepting a list of cards as argument, and returning the deck that would produce this list of cards if drawn using the procedure. ```javascript const prepareDeck = (result) => { ``` ```coffeescript prepareDeck = (result) -> { ``` ```typescript export const prepareDeck = (result: string[]): string[] => { ``` ```python def prepare_deck(drawn_cards): ``` Cards are represented in the same way than in [Part 1](https://www.codewars.com/kata/630647be37f67000363dff04); the same preloaded function is available to print cards on the console. # Example ```javascript const result = ["KC", "QC", "KD", "QD", "KH", "QH", "KS", "QS"]; prepareDeck(deck); ``` ```coffeescript result = ["KC", "QC", "KD", "QD", "KH", "QH", "KS", "QS"] prepareDeck(deck) ``` ```typescript const result = ["KC", "QC", "KD", "QD", "KH", "QH", "KS", "QS"]; prepareDeck(deck); ``` ```python drawn_cards = ['KC','QC','KD','QD','KH','QH','KS','QS'] prepare_deck(drawn_cards) ``` should return: ```javascript ["KC", "KH", "QC", "KS", "KD", "QH", "QD", "QS"]; ``` ```coffeescript ["KC", "KH", "QC", "KS", "KD", "QH", "QD", "QS"] ``` ```typescript ["KC", "KH", "QC", "KS", "KD", "QH", "QD", "QS"]; ``` ```python ['KC','KH','QC','KS','KD','QH','QD','QS'] ``` # Have fun! I hope you will enjoy this kata! Feedbacks and translations are very welcome.
algorithms
from collections import deque def prepare_deck(drawn_cards): deck = deque() for c in reversed(drawn_cards): deck . rotate(1) deck . appendleft(c) return list(deck)
Playing Cards Draw Order – Part 2
6311b2ce73f648002577f04a
[ "Games", "Permutations", "Algorithms" ]
https://www.codewars.com/kata/6311b2ce73f648002577f04a
6 kyu
<div style="width: 100%; margin: 16px 0; border-top: 1px solid grey;" /> - This is Part 1 of this series of two katas — Part 2 is [here](https://www.codewars.com/kata/6311b2ce73f648002577f04a). - If you like playing cards, have also a look at [Hide a message in a deck of playing cards](https://www.codewars.com/kata/59b9a92a6236547247000110) and [Card-Chameleon, a Cipher with Playing cards](https://www.codewars.com/kata/59c2ff946bddd2a2fd00009e). <div style="width: 100%; margin: 16px 0; border-top: 1px solid grey;" /> In this series of two katas, we will draw playing cards from a deck using a particular procedure: after drawing one card, we place the next one at the bottom of the deck. In details, the procedure is: 1. We draw the top card of the deck. 2. We take the next card, and put it at the bottom of the deck. 3. We repeat steps 1 and 2 until there aren't any card left in the deck. Let's take a small deck containing four cards — named A, B, C, D — as an example: 1. The deck order is `A-B-C-D` at the beginning, the card `A` is at the top and `D` at the bottom. 2. `A` is drawn. The deck is now `B-C-D`. 3. `B` is placed at the bottom of the deck. The deck is now `C-D-B`. 4. `C` is drawn. The deck is now `D-B`. 5. `D` is placed at the bottom of the deck. The deck is now `B-D`. 6. `B` is drawn. The deck is now `D`. 7. `D` is drawn. The order of the cards drawn is `A-C-B-D`. # Your task Write a function accepting a deck of cards as argument, and returning the cards drawn following the procedure. ```javascript const draw = (deck) => { ``` ```coffeescript draw = (deck) -> ``` ```typescript export const draw = (deck: string[]): string[] => { ``` ```java public static List<String> draw(List<String> deck) { ``` Each card is represented with a two-character string: the rank of the card and its suit. `AC 2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC` for the Clubs<br /> `AD 2D 3D 4D 5D 6D 7D 8D 9D TD JD QD KD` for the Diamonds<br /> `AH 2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH` for the Hearts<br /> `AS 2S 3S 4S 5S 6S 7S 8S 9S TS JS QS KS` for the Spades<br /> A preloaded function allows to easily print a deck to the console: ```javascript printDeck(deck, unicode); ``` ```coffeescript printDeck deck, unicode ``` ```typescript import { printDeck } from "./preloaded"; printDeck(deck, unicode); ``` ```java DeckPrinter.printDeck(deck, unicode); ``` The first argument is the deck to print, the second one is a boolean value allowing the selection of the character set: regular or Unicode (for which a font containing the playing cards characters needs to be installed on your system). # Example ```javascript const deck = ["KC", "KH", "QC", "KS", "KD", "QH", "QD", "QS"]; draw(deck); ``` ```coffeescript deck = ["KC", "KH", "QC", "KS", "KD", "QH", "QD", "QS"] draw deck ``` ```typescript const deck = ["KC", "KH", "QC", "KS", "KD", "QH", "QD", "QS"]; draw(deck); ``` ```java List<String> deck = Arrays.asList(new String[] {"KC", "KH", "QC", "KS", "KD", "QH", "QD", "QS"}); CardDraw.draw(deck); ``` should return: ```javascript ["KC", "QC", "KD", "QD", "KH", "QH", "KS", "QS"]; ``` ```coffeescript ["KC", "QC", "KD", "QD", "KH", "QH", "KS", "QS"] ``` ```typescript ["KC", "QC", "KD", "QD", "KH", "QH", "KS", "QS"]; ``` ```java ["KC", "QC", "KD", "QD", "KH", "QH", "KS", "QS"]; ``` # Have fun! I hope you will enjoy this kata! Feedbacks and translations are very welcome. After this one, jump to [Part 2](https://www.codewars.com/kata/6311b2ce73f648002577f04a), where we will be ordering the deck to be drawn to have a chosen result!
algorithms
def draw(deck): order = [] while deck: order . append(deck . pop(0)) if deck: deck . append(deck . pop(0)) return order
Playing Cards Draw Order – Part 1
630647be37f67000363dff04
[ "Mathematics", "Games", "Permutations" ]
https://www.codewars.com/kata/630647be37f67000363dff04
7 kyu
> The Twenty-One Card Trick, also known as the 11th card trick or three column trick, is a simple self-working card trick that uses basic mathematics to reveal the user's selected card. > The game uses a selection of 21 cards out of a standard deck. These are shuffled and the player selects one at random. The cards are then dealt out face up in three columns of 7 cards each. The player points to the column containing their card. The cards are picked up and the process is repeated three times, at which point the magician reveals the selected card. Source: [Wikipedia](https://en.wikipedia.org/wiki/Twenty-One_Card_Trick) Your task is to implement an algorithm that is able to execute the Twenty-One Card Trick. To simplify things, the cards will be changed to the set of integers between 1 and 21(inclusive). The function will be passed as argument a member of the audience that has selected a certain card and has a method ```get_input``` that receives a list of 3 lists as arguments and returns the index of the column containing the selected card. Example: ```python audience = Audience(13) # The audience member has selected the card 13 > audience.get_input([[1,2,3,4,5,6,7], [8,9,10,11,12,13,14], [15,16,17,18,19,20,21]]) 1 # Since 13 is at the 2nd column ``` ```ruby audience = Audience.new 13 > audience.get_input [[1,2,3,4,5,6,7], [8,9,10,11,12,13,14], [15,16,17,18,19,20,21]] 1 # Since 13 is at the 2nd column ``` ```javascript const audience = new Audience(13); > audience.getInput([[1,2,3,4,5,6,7], [8,9,10,11,12,13,14], [15,16,17,18,19,20,21]]); 1 // Since 13 is at the 2nd column ``` ```c // In C there is no audience object, you call get_input() directly: get_input((int[]){1,2,3,4,5,6,7}, (int[]){8,9,10,11,12,13,14}, (int[]) {15,16,17,18,19,20,21}); // == 1, since 13 is in the 2nd column ``` After 3 times it is asked, however, the audience member no longer will give an answer. Use these three functions invokations to discover which card the audience member has.
games
DECK = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] def guess_the_card(audience): deck = DECK for _ in range(3): deal = [deck[:: 3], deck[1:: 3], deck[2:: 3]] deal . insert(1, deal . pop(audience . get_input(deal))) deck = sum(deal, []) return deck[10]
Mathemagics: the 21 Cards Trick
62b76a4f211432636c05d0a9
[ "Algorithms", "Mathematics" ]
https://www.codewars.com/kata/62b76a4f211432636c05d0a9
7 kyu
We have a positive integer ```N, N > 0```. We have a special integer ```N1, N1 > N```, such that ```N1 = c ‧ d``` and ```N = c + d``` with the constraint that ```c ≠ d``` Let´s see an example: ``` N = 26 (starting integer) ``` The next integer ```N1```, chained with this property with ```N```, will be ```48```. Because: ``` N1 = 2 x 24 = 48 N = 2 + 24 = 26 ``` But there are another integers chained with ```N``` with the property shown above. In effect the next integer ```N2 = 69``` Let´s see: ``` N2 = 3 x 23 = 69 N = 3 + 23 = 26 ``` The next integer ```N3``` is ```88``` and you may figure out the values for ```c``` and ```d```. If we continue working trying to find the successive values of ```Ni``` for our starting integer ```N = 26``` we will find the following chain. ``` 26 (N) --> 48 (N1) --> 69 (N2) --> 88 (N3) --> ........... --> 160 (N9) --> 165 (N10) --> 168 (N11) ``` You may work to obtain the intermediate values of the above incomplete chain for the starting integer```26``` In the example above ```169``` is discarded as a solution, because as we said before ```c``` and ```d``` should be different. The task for this exercise is the following: *Given a starting integer you have to find the maximum chained integer that fulfills the property explained above* Your code should output an integer in all cases. You will receive always an integer as an input. Special Cases * If your starting integer is less than ```5```, we do not have a result higher than your starting integer. In those cases your code should output ```-1```. As an example: ``` input:4; output:-1 ``` You will see more examples in the fixed examples of the sample box. You have to pass 200 random tests and the values for the starting ```N``` are in the following range: ```c 1000 < N < 1 * 10^9 ``` ```cpp 1000 < N < 1 * 10^9 ``` ```js 10 < N < 1 x 10^14 ``` ```cobol 10 < N < 1 x 10^14 ``` ```csharp 10 < N < 1 x 10^9 ``` ```java 10 < N < 1 x 10^9 ``` ```python 10 < N < 1 x 10^14 ``` ```ruby 10 < N < 1 x 10^14 ``` ```typescript 10 < N < 1 x 10^14 ``` I hope that this challenge will be useful for all the coding lovers. Special Acknowledgements for two Codewarriors: Unnamed and macambira for their observations done in the beta phase.
reference
def max_int_chain(n): return - 1 if n < 5 else (n / / 2) * (n - n / / 2) if n % 2 else (n / / 2 - 1) * (n / / 2 + 1)
I Will Take the Biggest One and Nothing Else.
631082840289bf000e95a334
[ "Mathematics" ]
https://www.codewars.com/kata/631082840289bf000e95a334
7 kyu
Now that you’re back to school for another term, you need to remember how to work the combination lock on your locker. The lock has a dial with 40 calibration marks numbered 0 to 39 in clockwise order. A combination of this lock consists of 3 of these numbers; for example: 15-25-8. ![Example Lock](https://b3h2.scene7.com/is/image/BedBathandBeyond/2020-05-12-15-34_1500D_imageset?$imagePLP$&wid=256&hei=256) > Note that the numbers/markings are on the dial, not the casing. Have a good look at the image above. To open the lock, the following steps are taken: ``` 1. Turn the dial clockwise 2 full turns 2. Continue turning clockwise until the 1st number is reached 3. Turn the dial counter-clockwise 1 full turn 4. Continue turning counter-clockwise until the 2nd number is reached 5. Turn the dial clockwise again until the 3rd number is reached 6. Pull the shank and the lock will open. ``` Given the initial position of the dial and the combination for the lock, how many degrees is the dial rotated in total (clockwise plus counter-clockwise) in opening the lock? > Note that we're looking for the total degrees of rotation, regardless of the direction of rotation. For instance, if you rotated 720° clockwise and 360° counter-clockwise, the total is 1080°. **Input** There is a line of input containing 4 numbers between 0 and 39. The first number is the position of the dial. The next three numbers are the combination. Consecutive numbers in the combination will be distinct. **Output** Return the number of degrees that the dial must be turned to open the lock. A few examples are: ``` degreesOfLock(0, 30, 0, 30) -> 1350 degreesOfLock(5, 35, 5, 35) -> 1350 degreesOfLock(0, 20, 0, 20) -> 1620 degreesOfLock(7, 27, 7, 27) -> 1620 degreesOfLock(0, 10, 0, 10) -> 1890 degreesOfLock(9, 19, 9, 19) -> 1890 ```
algorithms
def degrees_of_lock(initial, first, second, third): return 1080 + ((initial - first) % 40 + (second - first) % 40 + (second - third) % 40) * 9
Combination Lock
630e55d6c8e178000e1badfc
[ "Mathematics" ]
https://www.codewars.com/kata/630e55d6c8e178000e1badfc
6 kyu
## Task Given a list of points, construct a graph that includes all of those points and the position **(0, 0)**. ```if:javascript Points will be objects like so: `{x: 1, y: -1}`. ``` ```if:coffeescript Points will be objects like so: `{x: 1, y: -1}`. ``` ```if:python Points will be dictionaries like so: `{"x": 1, "y": -1}`. ``` ```if:java Points will be java.awt.Point like so: `new Point(1, -1)`. ``` ```if:php Points will be array like so: `["x" => 1, "y" => 1]`. ``` A graph should be represented as a 2d array. ## Example: ```javascript,coffescript Input: constructGraph([{x: 2, y: 2}, {x: -2, y: -2}]) Output: [ [' ', ' ', '|', ' ', '*'], [' ', ' ', '|', ' ', ' '], ['-', '-', '+', '-', '-'], [' ', ' ', '|', ' ', ' '], ['*', ' ', '|', ' ', ' '], ] ``` ```python Input: construct_graph([{"x": 2, "y": 2}, {"x": -2, "y": -2}]) Output: [ [' ', ' ', '|', ' ', '*'], [' ', ' ', '|', ' ', ' '], ['-', '-', '+', '-', '-'], [' ', ' ', '|', ' ', ' '], ['*', ' ', '|', ' ', ' '], ] ``` ```java Input: ConstructAGraph.build(new Point[] {new Point(2, 2), new Point(-2, -2)}) Output: [ [' ', ' ', '|', ' ', '*'], [' ', ' ', '|', ' ', ' '], ['-', '-', '+', '-', '-'], [' ', ' ', '|', ' ', ' '], ['*', ' ', '|', ' ', ' '], ] ``` ```php Input: constructGraph([["x" => 2, "y" => 2], ["x" => -2, "y" => -2]]) Output: [ [' ', ' ', '|', ' ', '*'], [' ', ' ', '|', ' ', ' '], ['-', '-', '+', '-', '-'], [' ', ' ', '|', ' ', ' '], ['*', ' ', '|', ' ', ' '], ] ``` Points on the graph are represented as `'*'`, and the position **(0, 0)** is represented by a `'+'`. All positions along the **x axis** should be `'-'`, and all postions along the **y axis** should be `'|'`. The rest of the positions should be spaces: `' '`. Also, if a point is on the x or y axis, the default char should be replaced with the point char: `'*'`. ## Example: ```javascript,coffescript Input: constructGraph([{x: 0, y: 0}, {x: 1, y: 4}]); Output: [ ['|', '*'] ['|', ' '], ['|', ' '], ['|', ' '], ['*', '-'] ]// ^ //this is (0, 0) ``` ```python Input: construct_graph([{"x": 0, "y": 0}, {"x": 1, "y": 4}]) Output: [ ['|', '*'] ['|', ' '], ['|', ' '], ['|', ' '], ['*', '-'] ]# ^ # this is (0, 0) ``` ```java Input: ConstructAGraph.build(new Point[]{ new Point(0, 0), new Point(1, 4)}); Output: [ ['|', '*'] ['|', ' '], ['|', ' '], ['|', ' '], ['*', '-'] ]// ^ //this is (0, 0) ``` ```php Input: constructGraph([["x" => 0, "y" => 0], ["x" => 1, "y" => 4]]); Output: [ ['|', '*'] ['|', ' '], ['|', ' '], ['|', ' '], ['*', '-'] ]// ^ //this is (0, 0) ``` Graphs should be as minimal as posible while still retaining a rectangular shape. They should be just large enough to include all the points and the position **(0, 0)**. If no points are given, the graph should just include the position **(0, 0)**. Points might have the same value sometimes. ## More Examples: ```javascript,coffescript Input: constructGraph([]); Output: [['+']] ``` ```javascript,coffescript Input: constructGraph([{x: 1, y: 2}, {x: 1, y: 2}]); Output: [ ['|', '*'], ['|', ' '], ['+', '-'] ] ``` ```javascript,coffescript Input: constructGraph([{x: 0, y: 3}]); Output: [ ['*'], ['|'], ['|'], ['+'] ] ``` ```javascript,coffescript Input: constructGraph([{x: -2, y: -3}, {x: 1, y: -3}]); Output: [ ['-', '-', '+', '-'], [' ', ' ', '|', ' '], [' ', ' ', '|', ' '], ['*', ' ', '|', '*'] ] ``` ```python Input: construct_graph([]) Output: [['+']] ``` ```python Input: construct_graph([{"x": 1, "y": 2}, {"x": 1, "y": 2}]) Output: [ ['|', '*'], ['|', ' '], ['+', '-'] ] ``` ```python Input: construct_graph([{"x": 0, "y": 3}]) Output: [ ['*'], ['|'], ['|'], ['+'] ] ``` ```python Input: construct_graph([{"x": -2, "y": -3}, {"x": 1, "y": -3}]) Output: [ ['-', '-', '+', '-'], [' ', ' ', '|', ' '], [' ', ' ', '|', ' '], ['*', ' ', '|', '*'] ] ``` ```java Input: ConstructAGraph.build(new Point[] {}); Output: [['+']] ``` ```java Input: ConstructAGraph.build(new Point[] {new Point(1, 2), new Point(1, 2)}); Output: [ ['|', '*'], ['|', ' '], ['+', '-'] ] ``` ```java Input: ConstructAGraph.build(new Point[] {new Point(0, 3)}); Output: [ ['*'], ['|'], ['|'], ['+'] ] ``` ```java Input: ConstructAGraph.build(new Point[] {new Point(-2, -3), new Point(1, -3)}); Output: [ ['-', '-', '+', '-'], [' ', ' ', '|', ' '], [' ', ' ', '|', ' '], ['*', ' ', '|', '*'] ] ``` ```php Input: constructGraph([]); Output: [['+']] ``` ```php Input: constructGraph([["x" => 1, "y" => 2], ["x" => 1, "y" => 2]]); Output: [ ['|', '*'], ['|', ' '], ['+', '-'] ] ``` ```php Input: constructGraph([["x" => 0, "y" => 3]]); Output: [ ['*'], ['|'], ['|'], ['+'] ] ``` ```php Input: constructGraph([["x" => -2, "y" => -3], ["x" => 1, "y" => -3]]); Output: [ ['-', '-', '+', '-'], [' ', ' ', '|', ' '], [' ', ' ', '|', ' '], ['*', ' ', '|', '*'] ] ```
reference
def construct_graph(points): if not points: return [['+']] min_x = min(0, min(point['x'] for point in points)) min_y = min(0, min(point['y'] for point in points)) max_x = max(0, max(point['x'] for point in points)) max_y = max(0, max(point['y'] for point in points)) graph = [[' '] * (max_x - min_x + 1) for _ in range(min_y, max_y + 1)] def set(x, y, c): graph[max_y - y][x - min_x] = c for x in range(min_x, max_x + 1): set(x, 0, '-') for y in range(min_y, max_y + 1): set(0, y, '|') set(0, 0, '+') for point in points: set(point['x'], point['y'], '*') return graph
Construct a Graph
630649f46a30e8004b01b3a3
[ "Graphs", "ASCII Art" ]
https://www.codewars.com/kata/630649f46a30e8004b01b3a3
6 kyu
# Story & Task You're a pretty busy billionaire, and you often fly your personal Private Jet to remote places. Usually travel doesn't bother you, but this time you are unlucky: it's New Year's Eve, and since you have to fly halfway around the world, you'll probably have to celebrate New Year's Day in mid-air! Your course lies west of your current location and crosses several time zones. The pilot told you the exact schedule: it is known that you will take off at `takeOffTime`, and in `minutes[i]` after takeoff you will cross the `i`-th border between time zones. After crossing each border you will have to set your wrist watch one hour earlier (every second matters to you, so you can't let your watch show incorrect time). It is guaranteed that you won't cross the IDL (International Dateline), i.e. after crossing each time zone border your current time will be set one hour back. You've been thinking about this situation and realized that it might be a good opportunity to celebrate New Year's Day more than once, i.e. each time your wrist watch shows 00:00. Assuming that you set your watch immediately after the border is crossed, how many times will you be able to celebrate this New Year's Day with a nice bottle of champagne? Note that the answer should include celebrations both in mid-air and on the ground (it doesn't matter if the plane landed in the last time zone before the midnight or not, you'll not let the last opportunity to celebrate New Year slip through your fingers). # Example For `takeOffTime = "23:35" and minutes = [60, 90, 140]` the output should be `3`. Here is the list of events by the time zones: ``` initial time zone: at 23:35 your flight starts; at 00:00 you celebrate New Year for the first time; at 00:35 (60 minutes after the take off) you cross the first border; time zone -1: at 23:35 you cross the border (00:35 by your initial time zone); at 00:00 you celebrate New Year for the second time (01:00 by your initial time zone); at 00:05 (90 minutes after the take off) you cross the second border; time zone -2: at 23:05 you cross the border; at 23:55 (140 minutes after the take off) you cross another border; time zone -3: at 22:55 you cross the border; at 00:00 you celebrate New Year for the third time. Thus, the output should be 3. That's a lot of champagne! ``` # Input/Output - `[input]` string `takeOffTime` The take off time in the 24-hour format `"HH:MM"`. It is guaranteed that the given time is valid. The `"00:00"` time corresponds to the midnight of 31st of December / 1st of January. Any other time is before the new year (31st of December). - `[input]` integer array `minutes` A strictly increasing array of integers. `minutes[i]` stands for the number of minutes from the take off to crossing the `i`-th time zone border. Constraints: * `0 ≤ minutes.length ≤ 20` * `1 ≤ minutes[i] ≤ 1500` - [output] an integer The number of times you will be able to celebrate New Year's Day.
games
def new_year_celebrations(take_off_time, minutes): h, m = map(int, take_off_time . split(':')) res, m = 0, 60 * h + m or 1440 for x in map(int . __sub__, minutes, [0] + minutes): res += m <= 1440 and m + x >= 1440 m += x - 60 return res + (m <= 1440)
Simple Fun #100: New Year Celebrations
589816a7d07028ac5c000016
[ "Puzzles" ]
https://www.codewars.com/kata/589816a7d07028ac5c000016
6 kyu
Recently you had a quarrel with your math teacher. Not only that nerd demands knowledge of all the theorems, but he turned to be an constructivist devotee! After you recited by heart [Lagranges theorem of sum of four squares](https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem), he now demands a computer program to obtain such a decomposition, so that to see that you really understand a topic. What a downer! You remember well the theorem. Any positive integer can be decomposed into a sum of four squares of integers. Seems not too hard... But after a quarrel, your teacher wants blood. Apparently he will test your program on extremely huge numbers... And your program better finished working before the break - you don't want to get `F`, do you? Tip: random tests feature 20 numbers as high as `2^128` and 20 number as high as `2^1024`.
algorithms
from typing import Tuple from math import gcd from gmpy2 import is_prime def four_squares(n: int) - > Tuple[int, int, int, int]: print(n) if n == 0: return 0, 0, 0, 0 twos = 1 while n % 4 == 0: n / /= 4 twos *= 2 nums = [] if n % 8 == 7: sqrtn = isqrt(n) while (n - sqrtn * * 2) % 8 in [0, 4, 7]: sqrtn -= 1 nums . append(sqrtn) n -= sqrtn * * 2 else: nums . append(0) x = isqrt(n) while 1: k = n - x * * 2 k2 = k / / 2 if k % 2 == 0 else k if k2 == 1 or (k2 % 4 == 1 and is_prime(k2)): break # print(x, k, k2) x -= 1 k = n - x * * 2 nums . append(x) k2 = k / / 2 if k % 2 == 0 else k decomp = compose_2sq(prime_2sq(k2), [1, 1] if k % 2 == 0 else [1, 0]) nums += decomp return tuple(num * twos for num in nums) def prime_2sq(p): if p == 1: return (1, 0) if p == 2: return (1, 1) for q in range(2, p): if pow(q, (p - 1) / / 2, p) == p - 1: break x = pow(q, (p - 1) / / 4, p) v = p, x rems = [] sqrtp = isqrt(p) while len(rems) < 2: if v[1] <= sqrtp: rems . append(v[1]) v = v[1], v[0] % v[1] return rems[: 2] def compose_2sq(x, y): a, b = x c, d = y return [a * c + b * d, abs(a * d - b * c)] def isqrt(n): x0 = n / / 2 if x0: x1 = (x0 + n / / x0) / / 2 while x1 < x0: x0 = x1 x1 = (x0 + n / / x0) / / 2 return x0 return n
Express number as sum of four squares
63022799acfb8d00285b4ea0
[ "Performance", "Algorithms", "Mathematics" ]
https://www.codewars.com/kata/63022799acfb8d00285b4ea0
1 kyu
### Task Use the characters `" "` and `"█"` to draw the nth iteration of the [Sierpiński carpet](https://en.wikipedia.org/wiki/Sierpi%C5%84ski_carpet). In the following you are given the first three iterations. Implement `sierpinski_carpet_string(n)` which returns the Sierpiński carpet as string for `n` iterations. n = 0: ██ n = 1: ██████ ██░░██ ██████ n = 2: ██████████████████ ██░░████░░████░░██ ██████████████████ ██████░░░░░░██████ ██░░██░░░░░░██░░██ ██████░░░░░░██████ ██████████████████ ██░░████░░████░░██ ██████████████████ # Note 1. Every line but the last ends with `\n` 2. Your solution must be under 4000 chars to avoid hardcoding solutions. 3. Don't let this mislead you: `░` is only used to visualize space ` ` above and in the test cases. Use space ` `. This is done since space is sometimes not displayed with a full length in Markdown which makes everything look bad.
algorithms
def sierpinski_carpet_string(n): m = ["██"] for i in range(n): m = [x + x + x for x in m] + \ [x + x . replace("█", " ") + x for x in m] + [x + x + x for x in m] return "\n" . join(m)
ASCII Sierpiński Carpet
630006e1b4e54c7a7e943679
[ "ASCII Art", "Mathematics" ]
https://www.codewars.com/kata/630006e1b4e54c7a7e943679
6 kyu
# Structural Pattern Matching: ___NOTE: Make Sure You Select Python 3.10 for Structural Pattern Matching.___ Read [PEP 636](https://peps.python.org/pep-0636/) may help you understand it. This Kata is made to practice the Structural Pattern Matching. ___ # Examples of Structural Pattern Matching: There is some special things in Structural Pattern Matching: You can match with `sequence`, `or`, `guard`, `mapping`, using `as`,etc. Not just a replacement of `if ... elif ... elif ... else`, full details are in PEP636. __Examples__ ```python match [1, 2, 3]: case [x, y, z]: print(x) # This would print: 1 print(y) # This would print: 2 print(z) # This would print: 3 # Different item to match, but it would not match the same pattern above. match '123': case [x, y, z]: # This wouldn't match. case _: print(False) # This would match. # another example match ['item0', 'item1', 'item2', 'item3']: case [*x, y]: print(', '.join(x) + ' and ' + y) # This would print: item0, item1, item2 and item3 ``` ___ # Pluspoint of Structural Pattern Matching: From [PEP635](https://peps.python.org/pep-0635/): (This is just part of it, read PEP635 will give you full understanding of it.) > The if ... elif ... elif ... else idiom is often used to find out the type or shape of an object in an ad-hoc fashion, using one or more checks like isinstance(x, cls), hasattr(x, "attr"), len(x) == n or "key" in x as guards to select an applicable block. The block can then assume x supports the interface checked by the guard. For example: ```python if isinstance(x, tuple) and len(x) == 2: host, port = x mode = "http" elif isinstance(x, tuple) and len(x) == 3: host, port, mode = x # Etc. ``` > Code like this is more elegantly rendered using match: ```python match x: case host, port: mode = "http" case host, port, mode: pass # Etc. ``` ___ # Task: You will get an `arg` which consists only of `0, 1, 2, 3, '0', '1', '2', '3'` (or none of them). `arg` will be a string or list. Return the result with the following rules: * If `arg` is an empty list, return `0` * If `arg` is a list with 1 element, `convert the element to integer if not yet an integer, then return it`. * If `arg` is a list with 2 or more elements, convert the first and last elements to integer if not yet integers, then return `first element divided by the last element (float division)`. * If divided by 0 or arg is not a list, return `None`. ___ # Examples (arg --> output) ``` ('') --> None ([]) --> 0 (['2']) --> 2 ([0]) --> 0 ([3, 1, '2']) --> 1.5 ('123') --> None (['0', 0]) --> None (['0', 2, '3']) --> 0.0 ```
reference
def matching(arg): match arg: case[]: return 0 case[x]: return int(x) case[a, * _, 0 | '0']: return None case[a, * _, b]: return int(a) / int(b)
Practicing - Structural Pattern Matching
62fd5b557d267aa2d746bc19
[ "Fundamentals" ]
https://www.codewars.com/kata/62fd5b557d267aa2d746bc19
7 kyu
In a computer operating system that uses paging for virtual memory management, page replacement algorithms decide which memory pages to page out when a page of memory needs to be allocated. Page replacement happens when a requested page is not in memory (page fault) and a free page cannot be used to satisfy the allocation, either because there are none, or because the number of free pages is lower than some threshold. ## The clock page replacement algorithm The clock page replacement algorithm keeps a circular list of slots in memory, with the iterator pointing at the last examined slot in the list. When a page fault occurs and no empty slots exist, the algorithm checks the R-bit (referenced) of the page pointed by the iterator: if the R-bit is 0 the page pointed is removed from the memory, the new page is inserted and the iterator is moved forward, else if the R-bit is 1 it is set to 0 and the iterator is moved forward (this process is repeated until a page with an R-bit equal to 0 is found). Note that the R-bit is set to 1 when a page that is already in memory is referenced again.<br> Your task is to implement this algorithm. The function will take two parameters as input: the number of maximum pages that can be kept in memory at the same time ```n``` and a ```reference list``` containing numbers. Every number represents a page request for a specific page (you can see this number as the unique ID of a page). The expected output is the status of the memory after the application of the algorithm. Note that when a page is inserted in the memory, it stays at the same position until it is removed from the memory by a page fault. ## Example: The circular list is represented as a normal list with toroidal behaviour. Given: * N = 3, * REFERENCE LIST = \[6, 3, 6, 3, 2, 5, 1, 6\], ``` +---+---+ |VAL| R | * 6 is read, page fault +---+---+ * 6 is inserted at position 0 | 6 | 0 | * the iterator is moved forward +---+---+ --> | | | +---+---+ | | | +---+---+ +---+---+ |VAL| R | * 3 is read, page fault +---+---+ * 3 is inserted at position 1 | 6 | 0 | * the iterator is moved forward +---+---+ | 3 | 0 | +---+---+ --> | | | +---+---+ +---+---+ |VAL| R | * 6 is read, already in memory +---+---+ * R-bit set to 1 | 6 | 1 | +---+---+ | 3 | 0 | +---+---+ --> | | | +---+---+ +---+---+ |VAL| R | * 3 is read, already in memory +---+---+ * R-bit set to 1 | 6 | 1 | +---+---+ | 3 | 1 | +---+---+ --> | | | +---+---+ +---+---+ |VAL| R | * 2 is read, page fault +---+---+ * 2 is inserted at position 2 --> | 6 | 1 | * the iterator is moved forward +---+---+ | 3 | 1 | +---+---+ | 2 | 0 | +---+---+ +---+---+ |VAL| R | * 5 is read, page fault +---+---+ * the R-bit of 6 is 1, we set it to 0 and move forward --> | 6 | 0 | * the R-bit of 3 is 1, we set it to 0 and move forward +---+---+ * the R-bit of 2 is 0, we remove it from memory | 3 | 0 | * 5 is inserted at position 2 +---+---+ * the iterator is moved forward | 5 | 0 | +---+---+ +---+---+ |VAL| R | * 1 is read, page fault +---+---+ * the R-bit of 6 is 0, we remove it from memory | 1 | 0 | * 1 is inserted at position 0 +---+---+ * the iterator is moved forward --> | 3 | 0 | +---+---+ | 5 | 0 | +---+---+ +---+---+ |VAL| R | * 6 is read, page fault +---+---+ * the R-bit of 3 is 0, we remove it from memory | 1 | 0 | * 6 is inserted at position 1 +---+---+ * the iterator is moved forward | 6 | 0 | +---+---+ --> | 5 | 0 | +---+---+ ``` So, at the end we have the list ```[1, 6, 5]```, which is what you have to return. If not all the slots in the memory get occupied after applying the algorithm, fill the remaining slots (at the end of the list) with ```-1``` to represent emptiness (note that the IDs will always be >= 1).
algorithms
def clock(n, xs): ks, vs, ptr = [- 1] * n, [0] * n, 0 def inc(): nonlocal ptr ptr = (ptr + 1) % n for x in xs: if x in ks: vs[ks . index(x)] = 1 else: while vs[ptr]: vs[ptr] -= 1 inc() ks[ptr] = x inc() return ks
Page replacement algorithms: clock
62f23d84eb2533004be50c0d
[ "Algorithms", "Lists" ]
https://www.codewars.com/kata/62f23d84eb2533004be50c0d
6 kyu
### The Mandelbrot set The [Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set) is the set of complex numbers `$c$` for which the recursive function `$z = z^2 + c$` does not diverge to infinity when starting at `$z = 0$` We will estimate for a set of values if they belong to the Mandelbrot set. For this estimation we will see if after `max_iterations` the absolute value of `$z$` stayed below 2: `$|z| \lt 2$`. If so we assume the complex number `$c$` to be part of the Mandelbrot set. ### The grid Given a middle point `(x, y)` representing the complex number `x + yi` a `x_radius`, `y_radius` and `stepsize` parameter we can evaluate points to belong to the Mandelbrot set on an rectangular grid lying on the complex plane. The `x_radius` and `y_radius` define how many points belong to the grid, left and right as well as top and bottom. The following depicts a grid with the midpoint `X` with `x_radius = 3` and `y_radius = 1` ``` ******* ***X*** ******* ``` The `stepsize` decides the spacing between the gridpoints in `x`-direction. The stepsize in `y`-direction is chosen to be **double the stepsize** of the `x` dimension to counteract the 1:2 shape of a character. ### The visualization We will estimate for each element `$c$` of the set of complex values on the grid if it belongs to the Mandelbrot set. If estimated to be inside the set, it is represented as solid block `'█'` otherwise as one of the following: `' ', '░', '▒', '▓'` depending on the iterations it took to find out its not part of the set. The iterations `$i$` it took `$|z|$` to exceed 2 (or not in case of '█') decides which of `' ', '░', '▒', '▓', '█'` is used by a linear mapping for the index `char_idx = ⌊4 * i / max_iteraions⌋` ### Task Implement `mandelbrot_string(x, y, x_radius, y_radius, stepsize, max_iter)` which returns a visualization of the mandelbrot set. Every line (but the final line) ends in an addiotinal newline character `"\n"` which makes the amount of chars of the returned string: `n = (x_radius*2+1+1) * (y_radius*2+1) - 1`. ***Notes:*** * Remember that `stepsize` is different in `x` and `y` direction * Notice that the y-axis (imaginary axis) increases in value upwards like in most math plots. * Dont forget the newline chars (except the last line) * If the pictures are to big to be displayed on your screen, reduce the font size of the browser (ctrl and -) ### Examples `mandelbrot_string(-0.8, 0, 27, 12, 0.05, 20)` returns ``` ▓░ ░░▒░▒█ ░░░██▒░░ ░░░░▒████▓░░ ░░░░░░░░▒████▒░░░░░░▓ ░░░▒██▓███████████▓▒▒▒▓▒ ░░░░▒▒██████████████████▓░░ ░▒░░░░░░░░░░▒▓███████████████████▓░▓ ░░░▓▓▒▒█▒▒░░▒██████████████████████▒░░ ░░░▒▓███████▒▓███████████████████████░ ░░░░░░▒▒▒█████████████████████████████████░░ █████████████████████████████████████████████▒░░░ ░░░░░░▒▒▒█████████████████████████████████░░ ░░░▒▓███████▒▓███████████████████████░ ░░░▓▓▒▒█▒▒░░▒██████████████████████▒░░ ░▒░░░░░░░░░░▒▓███████████████████▓░▓ ░░░░▒▒██████████████████▓░░ ░░░▒██▓███████████▓▒▒▒▓▒ ░░░░░░░░▒████▒░░░░░░▓ ░░░░▒████▓░░ ░░░██▒░░ ░░▒░▒█ ▓░ ``` `mandelbrot_string(-1.15, 0.26, 45, 20, 1.4e-3, 60)` returns: ``` ░░░░▒▓░▒▒▒░░░░░░░░░░░░░░░ ░░░░░░█░▒░▓░ ░░░░░▒░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░▒░░░░ ░ ░░▒░░░░░░░░▒█░░░░░░░░░░░░░ ░░░░░░░░░░░░░░▒░░░░░░ ░░ ░░░░░░░░░░░░▒░░▒░░▓░░░░░░░░░░░░░░░░░▓░░░▒█▒▒░░░░░░ ░░░░░░░░ ░░░░░▒░▒▒████▒░░░░▒░░░░░░░░░░░▒▒█▒▒▒█▒░░░░░░ ░░░▒▒░▒░░░ ░░░░░░░▒▒███▒▒▒░▓░░░░░░░░░░░░░▒▓▒░░░░░░░░░░ ░░░░▓░░░░░░ ░░░░░░░▒▒▒▓▒░░▒░▓▓░░▒░░░░░░░█▒█▓▒░▒░░░░░░░░░ ░░░░░░░░░░░░ ░░░░░░░░░░░░▒░░░░▒▓▓█▒▒░▒░░░█▓▒░░░░░░░░░░░░░░░░░░░░░░░░▒░░░░░░ ░░░░░░░▒░░░░░░░░░▒░░▓▒▒▒▓█▒▒▒█▒░░░░░░░░░░░▒▒░░░░░░░░░░░░░░░▒░░░ ░░░░░░░░░▒░░░░░░░░░░░░▒░░░░▒▒▒▒██▒░░▒░░░░░░░░░░░░░░░░░░░░░░░▒▒▓░░░ ░░░░░▒░▒░░░░░░░░░░░░░▓░░░░░░░▒▒▒▓▒█▓░░░░░░░█░░░░░░░░░░░░░░░░░▒▒░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░█▓▒██▓▒▓░░░░▒█▒░░░░░░░░░░▒░▒░▒▒▓▓░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░▒▒█▒▓█▓▒▒▒▒▒▒█▒▒▒▓░░░░░░░░░░▒▒▓▒░░░▒░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░▒▒▒▓██▓█▒▒█▓█▒▒▒░░░░▒░░░░▒▒▒█▓▒▒█▒▓░░▒▒░░░░░ ░░░░░░░░░░░░░▒▒░▒▒███████████▓▒▒▒▒░░▒░░░░░░░▒██▓█▒▒▒▒▓▒░░░░░░░ ░░░░░░░░░░░░▒██▒▒▒▓████████████▓▒▒▒▓█▒█▒▒▒▒▒▒▒██▓▓▒░░░░░░░░░░░░ ░░░ ░░░░▒░░░░█░█▒█▓███████████████▓▒▒▒▒▒█▓▒▒▓▓▓▓▒▓██▓▒▒▒▓░░░░░▓░░░░░░░░░░░░ ░░░░░░░▓▓░░█▒▒▒▒▒▒▓████████████▓█████████▓▓████████▒░░░░░▒▓░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░▒▒▓▓▓█████████████████████████████▓▓▒░░▒░░█▓░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░▒▒▒▒█▓████████████████████████████▓▒█▒▒██▒▓░░░░░░░░░░░░░░ ░░▓░░░░▒░░▒░░░░▒░░░▒▓▒▒▓▓▓███████████████████████████████▒▒▒██▓▓▒▒░░░░░░░░░░▓░ ░░░▒▓▒▒▓░░▒░░░░░▒▒███▓▓▓███████████████████████████████████▓███▒▒░░░░░░░░░░░▒▒ ░░░░░░░▓▒█▓▒▒░░░░▒▒▒██████████████████████████████████████████▒░░░░░░░░░░░░█▒░ ░░░░░░░░░▒▓▓▒▒▒▒▒▒▓▒▒▓██████████████████████████████████████▓▒██▒▒░░░░░░░░░░░▒ ░░░░░░░░▒▒▓█▓█▒▒▒▒▒▓█▓▓████████████████████████████████████████▓██▒▒░░░░░░░░░░░░ ░░░░░░░░░░░░░░▓▒░░▒██▓▒▒▒███▓▓███████████████████████████████████████████████▒░░░░░░█░░░░▒▒ ░▒░░░░░░░░░░░▓█▒▓▒█▓▒░░░▓▒▓███████████████████████████████████████████████▓██▒▒░░░░▒▒▒░▒▒▒▒ ░▒░░░░░░░░░▓▒▒░▓▒█░░░░░░▒▓██▓▓██████████████████████████████████████████████▓▒▒▒░░▒▒▒██████ ░░░░░▒▒▒░░░░░░░░░░░░░░░░░█▒▒▒█▓▓████████████████████████████████████████████▒▒▒▒█▒▒▒▒▓█████ ░░░░▒░░░░░░░░░░░░▒░░░░░░░░░░▒▒▒▒██████████████████████████████████████████▓▒▒▒▒▒█████▓█████ ░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▓▓████████████████████████████████████████▓▒▒▒█████████████ ░░░░░░░░░░░░░░░░░▒▒▒▒▓█▓▓▓████████████████████████████████████████▓▓▓▓██████████████ ░░░░░░░░░░░░░░░░▒▓██████████████████████████████████████████████████████████████ ░░░░░░░░░░░░▒█▒█▒▒▓▓█▓▓███████████████████████████████████████████████████████ ░░░░░░░░░░█▒░▒░░░▒▒██▓██████████████████████████████████████████████████████ ░░░░░░█▒▒▓░░░░░░░▒▒▒▓███████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░▓█▒▒▒████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░██▓░░░░▒▒▓▒▒▓▓▓█████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▓▒▒▓▒▓▓▓▓███████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▓▓███████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░░▒▒▒▒█████████████████████████████████████████████████ ``` ### Fun It looks really good in the Ubuntu terminal (change character size if needed) If you have found a cool looking region increase the resolution by increasing `n` in `mandelbrot_string(x, y, x_radius*n, y_radius*n, stepsize/n)` ``` ░░░░░░░░ ░░░░▓▒░░▒░░░ ░░░░░░░▒▒░░░░░░░░ ░░░░░░░▒▒░░░░░░░░░░░░░ ░░░░░░░░▓█▓▒░░░░░░░░░░░░░░ ░░░░░░░░▒▒▓▒▒█░░░░░░░░░░▒░░░ ░░░░░░░░░░░▒▒▒▒░░░░░▒▒▒▒▓▒█░░░ ░░░░░░░░░░░░░▒▓█▒▒▒▒▒▓▒▓▒▒░░░░░░ ░░░░░░░░░░░░░▒▒▒▓▓█▒▒▒░░░░░░░░░░ ░░░░░░░░░░░░░░░▒▒▒▓▓▒▒▒░░░░░░░░░░░░ ░░░░░░░░░░░░░░▒▒▒▒▓███▒▒▒░░░░░░░░░░░ ░░░░░░░░░░░░░░▓▓▓█▓████▓▒▓█▒░░░░░░░░░░░ ░░░░░░░░░▒▒▒░░▒▒▒▒▓▓███████▓█▓░░░░░░░░░░░░ ░░░░░░░░░▒▒▒▓▓▒▒▒▒█▓▓████████▓▒▒▒▒▒▒▒▒▒▒░░░░░ ░░░░░░░░░░▒▒██▒▓█▓▓▓▓▓████████████▓██▒▒██▓▒░░░░░░░ ░░░░░░░░░░░░░░░░▒▒▒▒████████████████████▓█▓▓█▓█▒▒░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░▒▒▓███████████████████████▓▒▒░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▓███████████████████████▒▒▒░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓█████████████████████████▓███░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓███████████████████████▓█▒░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▓████████████████████████▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░▓▒░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒█████████████████████▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▒░░░ ░░░░░▒██▒░░▒▓▒▒▓▓▒░░░░░░░░░░▒█▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▓▓██████████████████▓▓▒▒▒▒▒▒▒▒░░░░░▒██░░░░░░░░░░░░░░░░░░░░░▒▒▒░░░ ░░░░░░░░░▒██▓▓█▓█▓▒▒▒░░░░░░░░▒▒█████▒▒▒▓██▓▓██▓█▓██████████████████▓▓▓▓█▓▒▓██▒▒▒▒▓████▓░░░░░░░░░░░░░░░░░░██▒░░░░░ ░░░░░░░░░░░▒▒▒▓███▓▓▒▒▓▒█▒▒▒▒▒▒▒███████▓▓███████████████████████████████████████▓▒███████▓░░░░░░░░░░░░░░░░▒██▒░░░░░░ ░░░░░░░░░░░░▒█▓█▓▓██████████▓▒▒▒▒▒▓███████████████████████████████████████████████████████▒▒▒░░░░░░██▒█▒▒░▒▒▒▒█▒▒░░░░░ ░░░░░░░░░░░░░░░▒▒▒▒▓███████████▓▒██████████████████████████████████████████████████████████▓▓▒█▒▒▒▒▒▒▒▓██▓▒▒▒▒▒▓█▓█▓▒▒░░░ ░░░░░░░░░░░░░░░░░░░▒█▓▓██████████▓████████████████████████████████████████████████████████████████▒▒▒▓█████████████▓█▓░░░░░ ░░░░░░░░░░░░░░░░░░░░░▒███████████████████████████████████████████████████████████████████████████████▓▓█████████████▓▒▒▓█░░░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▒▓▓██████████████████████████████████████████████████████████████████████████████████████████▒▒▒░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▓▓███████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░▒▒▓▒▒▒▒▒▓█▓████████████████████████████████████████████████████████████████████████████████████████▓▓▓▒░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░▒▒▒█▓█▓▒▒▒▒▓█████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒░░░░░░░░░░░░ ░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▓████████▓██████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓█████████████████████████████████████████████████████████████████████████████████████████████████████▒▒█▒░░░░░░░░░░░ ░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒██████████████████████████████████████████████████████████████████████████████████████████████████████▓░░░░░░░░░░░░ ░░░░░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓▓███████████████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒░░░░░░▓░░░░ ░░░░░░░░▒██▒░░░░░░░░░░░░░░░░░░░░▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒██▓▓██████████████████████████████████████████████████████████████████████████████████████████████████████▓▒▓██▒▒▒▓▓▒░░░ ░░░░░░░░░▒▓▒▒░░░░░░░░░░░░░░░░░░▒▓█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▓▓█▒░░░░ ░░░░░░░░░░▓▓▒▒▒░░░░░░▓░░░░░░░░░▓█▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▒░░░░ ░░░░░░░░░░░▓▒▓▓▓▓▓▒█▒▒█▒▒▒░░░░▒▒▒▒▓██▒█▒▒▒░▒▒█▒░░░░░░░░░░░░░░░░▒▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒█░░░░░░ ░░░░░░░░░░░░░░▒▒▒▓████▓▓▒█▒▒▒▒▒▒▒▒▓▓████▒▒▒▓▓▓▒▒░░░░░░░░░░░░░░▒▒▒██████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▓▒▒░░░░░░░░░ ░░░░░░░░░░░░░░░▒▒▒▒▓▓███████▒▒▓▓▒▓▓██████▓▓▓▓▓██▒▒▒▒▒░░░░░░░░▒▒▒▒████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▒░░░░░░░░░ ░░░░░░░░░░░░░░░░░▒▒▒▓█████████▓▓██████████████████▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░░ ░░░░░░░░░░░░░░░░▒▒█▓██████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒▓░░░░░ ░░░░░░░░░░░░░░░░░▒▒▒▒▒▓███████████████████████████████████▓▒▒▒▒▒▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓█▒░░░░ ░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▓▓██████████████████████████████████████▒▒▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓█▓░░░░░ ░░░░░░░░░░░░░░░░██▓▓▓████████████████████████████████████████████▓▓▓▓▓██████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒░░░░░░░ ░░░░░░░░░░░░░░░░░░░▒▒▒▒▓██████████████████████████████████████████████▓▓▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░ ░░░░░░░░░░░░░░░▒▓▒░░░░░░░░░▒▒▒▒▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▒█▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒█▒▒▒▒▓▓▒▒▒▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▓█▓█▓▓██▓▓▓▓▓█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░░ ░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓▓██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▒░░░░░░░░░░ ░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▓▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒░░░░░░░░░░░ ░░░░░░░░░░░░░░▒▒█▒▒░░░░░░░░░░▓▒░░░░░░░░░░▒▒▒▓▒▒▓▒▒▓▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░░░░░░░ ██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▓▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░▒▒█▒▒░░░░░░░░░░▓▒░░░░░░░░░░▒▒▒▓▒▒▓▒▒▓▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░░░░░░░ ░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▓▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒░░░░░░░░░░░ ░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓▓██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▒░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▓█▓█▓▓██▓▓▓▓▓█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒█▒▒▒▒▓▓▒▒▒▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▒█▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░ ░░░░░░░░░░░░░░░▒▓▒░░░░░░░░░▒▒▒▒▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒░░░░░ ░░░░░░░░░░░░░░░░░░░▒▒▒▒▓██████████████████████████████████████████████▓▓▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░ ░░░░░░░░░░░░░░░░██▓▓▓████████████████████████████████████████████▓▓▓▓▓██████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒░░░░░░░ ░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▓▓██████████████████████████████████████▒▒▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓█▓░░░░░ ░░░░░░░░░░░░░░░░░▒▒▒▒▒▓███████████████████████████████████▓▒▒▒▒▒▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓█▒░░░░ ░░░░░░░░░░░░░░░░▒▒█▓██████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒▓░░░░░ ░░░░░░░░░░░░░░░░░▒▒▒▓█████████▓▓██████████████████▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░░ ░░░░░░░░░░░░░░░▒▒▒▒▓▓███████▒▒▓▓▒▓▓██████▓▓▓▓▓██▒▒▒▒▒░░░░░░░░▒▒▒▒████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▒░░░░░░░░░ ░░░░░░░░░░░░░░▒▒▒▓████▓▓▒█▒▒▒▒▒▒▒▒▓▓████▒▒▒▓▓▓▒▒░░░░░░░░░░░░░░▒▒▒██████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▓▒▒░░░░░░░░░ ░░░░░░░░░░░▓▒▓▓▓▓▓▒█▒▒█▒▒▒░░░░▒▒▒▒▓██▒█▒▒▒░▒▒█▒░░░░░░░░░░░░░░░░▒▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████▒▒█░░░░░░ ░░░░░░░░░░▓▓▒▒▒░░░░░░▓░░░░░░░░░▓█▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▒░░░░ ░░░░░░░░░▒▓▒▒░░░░░░░░░░░░░░░░░░▒▓█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████▓▓▓█▒░░░░ ░░░░░░░░▒██▒░░░░░░░░░░░░░░░░░░░░▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒██▓▓██████████████████████████████████████████████████████████████████████████████████████████████████████▓▒▓██▒▒▒▓▓▒░░░ ░░░░░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓▓███████████████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒░░░░░░▓░░░░ ░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒██████████████████████████████████████████████████████████████████████████████████████████████████████▓░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓█████████████████████████████████████████████████████████████████████████████████████████████████████▒▒█▒░░░░░░░░░░░ ░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▓████████▓██████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░▒▒▒█▓█▓▒▒▒▒▓█████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░▒▒▓▒▒▒▒▒▓█▓████████████████████████████████████████████████████████████████████████████████████████▓▓▓▒░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▓▓███████████████████████████████████████████████████████████████████████████████████████████░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▒▓▓██████████████████████████████████████████████████████████████████████████████████████████▒▒▒░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░▒███████████████████████████████████████████████████████████████████████████████▓▓█████████████▓▒▒▓█░░░░ ░░░░░░░░░░░░░░░░░░░▒█▓▓██████████▓████████████████████████████████████████████████████████████████▒▒▒▓█████████████▓█▓░░░░░ ░░░░░░░░░░░░░░░▒▒▒▒▓███████████▓▒██████████████████████████████████████████████████████████▓▓▒█▒▒▒▒▒▒▒▓██▓▒▒▒▒▒▓█▓█▓▒▒░░░ ░░░░░░░░░░░░▒█▓█▓▓██████████▓▒▒▒▒▒▓███████████████████████████████████████████████████████▒▒▒░░░░░░██▒█▒▒░▒▒▒▒█▒▒░░░░░ ░░░░░░░░░░░▒▒▒▓███▓▓▒▒▓▒█▒▒▒▒▒▒▒███████▓▓███████████████████████████████████████▓▒███████▓░░░░░░░░░░░░░░░░▒██▒░░░░░░ ░░░░░░░░░▒██▓▓█▓█▓▒▒▒░░░░░░░░▒▒█████▒▒▒▓██▓▓██▓█▓██████████████████▓▓▓▓█▓▒▓██▒▒▒▒▓████▓░░░░░░░░░░░░░░░░░░██▒░░░░░ ░░░░░▒██▒░░▒▓▒▒▓▓▒░░░░░░░░░░▒█▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▓▓██████████████████▓▓▒▒▒▒▒▒▒▒░░░░░▒██░░░░░░░░░░░░░░░░░░░░░▒▒▒░░░ ░░░░░░░░░░░░▓▒░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒█████████████████████▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▒░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▓████████████████████████▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓███████████████████████▓█▒░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓█████████████████████████▓███░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▓███████████████████████▒▒▒░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░▒▒▓███████████████████████▓▒▒░░░░░░░░░░░ ░░░░░░░░░░░░░░░░▒▒▒▒████████████████████▓█▓▓█▓█▒▒░░░░░░░ ░░░░░░░░░░▒▒██▒▓█▓▓▓▓▓████████████▓██▒▒██▓▒░░░░░░░ ░░░░░░░░░▒▒▒▓▓▒▒▒▒█▓▓████████▓▒▒▒▒▒▒▒▒▒▒░░░░░ ░░░░░░░░░▒▒▒░░▒▒▒▒▓▓███████▓█▓░░░░░░░░░░░░ ░░░░░░░░░░░░░░▓▓▓█▓████▓▒▓█▒░░░░░░░░░░░ ░░░░░░░░░░░░░░▒▒▒▒▓███▒▒▒░░░░░░░░░░░ ░░░░░░░░░░░░░░░▒▒▒▓▓▒▒▒░░░░░░░░░░░░ ░░░░░░░░░░░░░▒▒▒▓▓█▒▒▒░░░░░░░░░░ ░░░░░░░░░░░░░▒▓█▒▒▒▒▒▓▒▓▒▒░░░░░░ ░░░░░░░░░░░▒▒▒▒░░░░░▒▒▒▒▓▒█░░░ ░░░░░░░░▒▒▓▒▒█░░░░░░░░░░▒░░░ ░░░░░░░░▓█▓▒░░░░░░░░░░░░░░ ░░░░░░░▒▒░░░░░░░░░░░░░ ░░░░░░░▒▒░░░░░░░░ ░░░░▓▒░░▒░░░ ░░░░░░░░ ``` ``` ░░░▒░░░░▒▓▓░░▒▒░▒░▒░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░█░░░▒░░░▓░░░ ░░░░░░░░░▒░░░░░░░░░░░░▒▒░░░░░░░░░░░░░░░░▒▓░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░▒░▒▒░░░░░░░░ ░░░░░░░░░░▒░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░░░░░░ ░ ░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒░░░░░░░░░░░░░▒░░░░░░░░░░ ░░░░░░▒▒░░░░░░░░░░░░░░░▒▒▓▒░░░░░░░░░░ ░░░░ ░░░░░▒░░░░░░░░░░░░░░░░░▒▒█░░░░░░░░░░░░░░▓░░░░░░░░░░░░ ░░░░░░░▒░░░░░░░░░░░▒░░░░░░░▒▒░░░░░░░░░░░░ ░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░░░▒░░░░░░▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░░░░░░░░▒▒▒░░░▒▓▓█▒░░▒░░▒░░░░ ░░░▒░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░░░▒░░░░█▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░░░▒▓░░░░▒░▒▒██▓▒▒▒░░▒░░░░░░░░░░ ░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░▒▒▓▒▓▒░▒▒▒▓▒▒▒█▒▒░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓▒░░▒▓▓██▓▒▒░░░░░░░░░░░░░░ ░░░░░░░▒░░░░▒▒▓░░░░ ░░░░░░░░░░░▒░░░▒█▒▓███████▓▒▒░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░▒░▒▒██▒▒▒▓▒▒█▒▒░░░░░░░░░░░░░ ░░░░░░▒▒▒░░▒▒▒░░░░░░ ░░░░▒▒░░░░░░░░░▒▓████████▓▒▒▒░░░░▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▒░░░░░░░░░░▒█░░░░░░░░░ ░░░░░░░░░▒░░░░░░░░░░░ ░░░░░░░░░░░░░▒▒▒▒▓█████▓▒▒▒▒▒▒░▒▓▒░░░░░░░▒░░░░░░░░░░░░░░░░░░▒▒▓▒▒░░░░░░░░░░░░░░░░░░░░░ ░░░░░▒░▒▓░░▒░░░░░░░░░ ░░░░░░░░░░░░░░░▒▒▒▒██▓▓▒▒▒▒▒▒▒▒▒▒▒░▒░░░░▒░░░░░░░░░░░▒▒░░░░▒▓▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░▓░░░░░░░░░░░░ ░░░░░░░░░░░░░░▒▒▒█▒▒▓▒▒▒░░░░▒░░▒▓▓▓▒░░░░▒▒░░░░░░░░░░░░░▒█▒▒▓█▓▓▒▒▒░░▒▒░░░░░░░░░░░░░░░░░░ ░░░░░░░░░▓░░░░░░░░░░░░░ ░░░░░░░░▓░░░▒▒▒▒░░▒░░░░▓▒░░░░░░░▒▒▒█▒▒▒▒▒▓░░░▒░░░░░░░░░░▒▒▒▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░▓▒░░░░░░░░░░░░ ░░░░░░░░░░░░░░▒░░░░░░░░░▒▒░░░░░░░░░▒▒▓▓▓██▒▒▒▒▒░░▒░░░░▒░▒█▓▓▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░░░░░░░░░░ ░░░░░░░░░░░░░▓▒▒░▒░░░░░░▒░░░░░░░░░░▒█▓▒▒███▓▒▒▒▓▒▒▓▒▒░░▒▒▒▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░░░░░░░░░ ░░░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░▒░░░░▒▓▒▒▒▒▒▒▒▓▓██▒▒▒▒▒▓██▒░░░░░░░░░░░░░░░░░░░░░░░▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▒█▒░░░▒▒▒█▒▒▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░▒▒▒▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▒░░░░░░░ ░░░░░░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░░░░░░▒▒▒▒▒▒▒▒▓█▒█▒▒░░░░▒▒░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒░▓░░░░░░░ ░░░░░░░▒░░░░▒░░▒▒░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▒░░░░▒▒▓█▓▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓▒█▒░░░░░░░░ ░░░░░░░░░░▒▒░░░▒░░░░░░░░░░░░░░░░░░░░░░░░▒░█▓▒░░░░░░░░░░░░░░▒▓▒▒▒▓▓▒▒▒██▓▒░░░░░░░░░░░░░▓█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▒░░░░░░░░░░░░░░░ ░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓█▓▓▒█▓▒▒▒▒░░░░░░▒▒░▒▒▓█▒░░░░░░░░░░░░░░░░░░░░▒░░░░░░░░░▒░▒▒▓▒▒▒▒░░░░░░░░░░░░░░░░ ░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒█▒▓█▒▓████▓▒▒█▓▒░░░░░░░▒▒▓█▓▒▒░░░░░░░░░░░░░░░░░░░░▒▓░▒▒▒░▓▒▒▒▒▓█▓▒░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▓▓▓███▓▓▒█▓▒▒▒▒▒░░░▓▒▒▒██▒▒░▒░░░░░░░░░░░░░░░░░░░░░░░▒██▒█▒▓▓▒▒░▒░░░░░░░░░░░█▒▓░▓▒░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓░░░▒▒▓▒▒█▒▒▓▓███▓▒▒▒▒▒▒▒▒▒▒▒▒▒█▓▒▒▒█▒▒▓░░░░░░░░░░░░░░░░░░░░░▒▒▒█▓▒▒▒░░░░░░▒█░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░▒▒▒▒▒▒▒█▓██▓▓▒▒██▒██▒▒▒▒▒▒▓█▓▓█▓▓▓▒░░░░░░░░░░░░░░░░░░░░░▒▒▓▓▓▒▒▒░░▒░░░▓░░░░░░▒█░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▓▓███▓▓██▓▒▒▒▒█▓▓▓█▓▒▒▒▒▒▒░░░░░░░░▒░░░░░░░░░▒░▒▒▒▓██▓▒▒▒▒▒█▓▒▒▓▒░░░▒▒▒▒░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒█▓▒▓▓████████▓█▓▓▓█████▒▒▒▒▒▒░░░░░░▒▒░░░░░░░░░░░░▒▒▒▒▓▓█▒▒▓▓██▓█████▒▓▒▓▒▒░▒░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░▓░░░░▒░▒░░░▒▓▒▓██████████████████████▓▓▒▒▒▒▒▒▒░░░░░▒▒░░░░░░░░░░░░░░▒▒████▓██▓▒▒▒▒▒▒▒█▓▒▒░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░▒▒██▒▒▒▒▒▒▒▒▒▓▓▓█████████████████▓▓▓▓█▓▒▒▒▒▒▒▒▒▒▒▒▒░▒█░░░░░░░░▒▒▒▒▒▒▒▓▓██▓▒▒▒░░░▒░▒░░░░░░░░░░░░░░░░░ ░░ ░░░░░░░░░░░░░░░░░░░░░░░▒▒▒███▒▒▒▒▒▒▓▓█████████████████████████▓▒▒▒▒▒▒▒▓██▒▒▒█▒▒░▒▒▒▒▒▒▒▒▒▒▒▒█▓██▓█▓▒▒░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒█▒▓▓▓██▓▓██████████████████████▓▓▒▒▒▒▓▒▒▒█▓████▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓██▓▓▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░▒▒░░░░░░░░░█░░▓█▒▒██▓▓▓██████████████████████████████▓▓▒▒▒█▒▒▒▒▒▓██▓▒▒▒▒▒▓▒▓█▓█▓▒▒▓▓████▓▓▒▒▒▒▒▒░▓░░░░░░░░░░░▓░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░▓░░░░░░▒▒▓▓▓▓█▒▓▓▒▒▒▒▒▓▓▓▓████████████████████████▓▓▓▓▓███▓▓▓████████▒▒▒▒███████▓▓▓█████▓▓█▓▒░░░░░░░░░░░░▒▓▒▓▒▒▒░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░█░░░▓▓▒▓░░░░░█▓▒▒▒▒▒▒▒▒▒▒▒█▓▓████████████████████████▓████████▓██████████▓▓▓▓███████████████▒▒█░░░░░░░░░░▒▒▓░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░▒▒▒▒▒▒▓▓▓██████████████████████████████████████████████▓██████████████▓▒▒▒▒▒░░░░░█░░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓█▓█▓███████████████████████████████████████████████████████████▓█▓▒▒▒░░░░▒▒░░░▒██▓░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒██▓▓▒▓████████████████████████████████████████████████████████████▓▓▓▒▒▒▒▒▒▒▒▒▓▓▒▒▓█▒░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▓██▓▓████████████████████████████████████████████████████████▓▒▒▒█▒▒▒▒████▓▒▒▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓███████████████████████████████████████████████████████▓▓██▓▒▒▒▓▓██▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░▓▓░░░░░░░░░▒░░░░░▒░░░░░░░░░▒░░░░░░░▒▒▓▓▒▒▒▓▓█▓█▓▓█████████████████████████████████████████████████████████████▓▒▒▒▒▒█████▓█▓▒▒░▒░░░░░░░░░░░░░░░░░░░░░▓░░ ░░░░░░▒░░░░░░░░░▒░░░░▒░░░░░░░░░▒▓▒░░█▒▒▒▒███▒▒▒▒▓▓████████████████████████████████████████████████████████████████▓▓█▓▓▒▓▓▓██▓▒▓▓▓█░░░░░░░░░░░░░░░░░░░░░░░█░ ░░░░░░░▒▒▓░▒▒▒▒▓▒░░░░▒▒░░░░░░░░░░▒▒▒▒██████▓▓▓█▓▓██████████████████████████████████████████████████████████████████████▓██████▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒ ░░░░░░░░░░░░░░▒▒▓▒▒▒▒▒██▒░░░░░░░░░░▒▒▒▒▒▒▒█████████████████████████████████████████████████████████████████████████████████▓▓█▒▒░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓░ ░░░░░░░░░░░░░░░▓▒▒██▒▓▒▒▒▒▒░░░░░░░░▒▒▒▒▒▒█▓██████████████████████████████████████████████████████████████████████████████████▒▒░░░░░░░░░░░░░░░░░░░░░░░██▓▒░░ ░░░░░░░░░░░░░▒░░░░▒▒▒▓█▒▒█▒░░░░▒▒▒▒▒▒▒▒███▓███████████████████████████████████████████████████████████████████████████████▓▒▒▒▒▒▒░▒▓▒▒█░░░░░░░░░░░░░░░░▓▒▒░░ ░░░░░░░░░░░░░░░░░░░▒▒▓▒▓█▒▒▒▒▒▒▒▒▒▒▒▒▓▒▒▒▒▓▓▓████████████████████████████████████████████████████████████████████████████▓▓▒▒█▓█▒▒▓▒░░░░░░░░░░░░░░░░░░░░░░░▒ ░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▓█▓▓▒▒▒▒▒▒▓█▓▓█▓▒▓▓███████████████████████████████████████████████████████████████████████████████▓▓████▓▓█▒░░░░░░░░░░░░░░░░░░░░░░░░▒ ░░░░░░░░░░░▒░░░▒▒░▒▒▓███▓▓█▓▒▒▒█▒▒▒▒▒▓▓██▓▓▓▓▓███████████████████████████████████████████████████████████████████████████████▓▓█████▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░ ░░░ ░░░░░░░░░░░░░░░░░▒▒▒▓▒██▓▒▒█▒▓█▓█▒▒██▒▒▒▓▓▓███████████████████████████████████████████████████████████████████████████████████████████▓██▒▒░░░░░░░░░░░░░░░░░░░░██▒▒ ░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓░▒░░░░░▒████▒▓▒▒▒▒▓▒▓██████▓█▓▓█████████████████████████████████████████████████████████████████████████████████████████████▒▒▒░░░░░░░░░░░░█▒░░░░░░░░▒▒▒ ░░▒░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒░░░▒▓▒▓▒▒▒▒▒▒▒▒▒▒▒▓▓▓██████████████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒▒▒▒░░░░░░░░░▒█▒░░░░░░░░░░▒▒ ░░▒░░░░░░░░░░░░░░░░░░░░░░▒▓▒█▓▒▒▓▒▒▒██▓▒▒▒░░░░░▒▓▒▒▓▓███████████████████████████████████████████████████████████████████████████████████████████████▓█████▒▒▒░░░░░░░░░▒█▒▒▒░░▒▒▒▒▒▒▒▒ ░░▒░░░░░░▒░░░░░░░░░░░░░▒▒▒▓▒▒▒▒██▒█▓▒▒▒▒▒▒░░░░░░░▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒▒▒░░░░░░░▒▒▒▒███▒▒██▒▒█▓▒ ░░▒▒░░░░░░░░░░░░░░░░░▒▓▒▒▒▒░░░▓░▒██▒░░░░░▒░░░░░░▒▓▓▓████▓▓▓████████████████████████████████████████████████████████████████████████████████████████████▓▓▒▒▒▒▒▒▒░░░▒▒▒▒▒▒▒███████▓███ ▒▒▓▒░░▓░▒▓░░░░░░░░░░▓░░▓░░░░░░░░█░▒▓▒░░░░░░░░░░░░░▒█▒▒▒▒▒████████████████████████████████████████████████████████████████████████████████████████████▓▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▓███████████ ░░░▓░░░░░▒▒░▒░▒▒░▒░▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█▒▒▒▒▒▒▒█▓▓█▓▓█▓██████████████████████████████████████████████████████████████████████████████████████▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▓▓██████████ ░░░░░░░░▒░▒▒░░▒▓▒░░░░░░░░░░░░░░░░░░▓▓░░░░░░░░░░█▓▓▒░░░░▒▒▓▒▓▒▒▒█▓▓█████████████████████████████████████████████████████████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒████▓███▓▓▓████████ ░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▓████████████████████████████████████████████████████████████████████████████████████▓▓▒▒▒▒▒▒▒▒▒▒██████████▓▓█████████ ░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒█▒█▓▓████████████████████████████████████████████████████████████████████████████████████▓▒▒▒▒▒█▒▒▒▒▒▓▓██████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓▒▒▒▒▒▒▒▒▓▓▓████████████████████████████████████████████████████████████████████████████████▓▓▒▒▒▒▒▒▓█████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▒▒██████▒▒█▓███████████████████████████████████████████████████████████████████████████████████▓▓▓▓▓▓▓▓▓▓████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░▒▒▒█▒▒▓▓██▓▓▓▓▓█████████████████████████████████████████████████████████████████████████████████▓▓▓█▓▓▓████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒█▓███▓███████████████████████████████████████████████████████████████████████████████████▓▓█▓████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▒█▓▓███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▓▒▒▓█▒▓▓█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░▒▓█▒▒▓█▒▒▒▒▒▓█▓▓█▓▓█▓██████████████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░█▒▓▓▓▓▒▒▒░▒▒▒▒▒▒▒▒▒▓▓▓▓███████████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░█▒▒░░░▒▒░░░░░░▒▒▒█████▓▓███████████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░█▒▒▓░░░░░░░░░░░░░▒▒░░░░░░░▒██▓████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░▒█▒▒▓▒▒▓░░░░░░░░░░░░░░░▒▒▒▒▒█▓██████████████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓█▓▒▒▒▓▒▒▓██████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓██▒▒▒▒▒▓███████████████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒██▓▓█▓▓███████████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█▓██▓█░░░░░░░▒▒▒▒█▓▓▒▒▒▓▓█▓▓▓██████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░░░░░░░░▒▒▒██▒▒▒▒▒▒▒▓▒▒▒▒▓▓▓▓▓█▓▓█████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒█▓▒▒▒▒█▓▓▒▓▓▓▓▓▓▓▓██████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▒▓▓█████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▓▒▒▒▓▒▒▒▓██████████████████████████████████████████████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒█░░░▒▒▒▒▒▒▒▒▒█████▓███████████████████████████████████████████████████████████████████████████████████████████ ```
algorithms
def mandelbrot_string(x, y, width, height, stepsize, max_iter): def mandelbrot_pixel(c): z = 0 for n in range(max_iter + 1): z = z * z + c if not abs(z) < 2: break return n return '\n' . join( '' . join( ' ░▒▓█' [4 * mandelbrot_pixel( complex(x + dx * stepsize, y - 2 * dy * stepsize) ) / / max_iter] for dx in range(- width, width + 1) ) for dy in range(- height, height + 1))
ASCII Mandelbrot Set
62fa7b95eb6d08fa9468b384
[ "ASCII Art", "Mathematics" ]
https://www.codewars.com/kata/62fa7b95eb6d08fa9468b384
5 kyu
# Task: In this Golfing Kata, you are going to do simple things: * Reverse a string; then * Return the index of first uppercase letter. ___ # Input: You are going to get a `string` which consists only __uppercase__ and __lowercase__ English letters. It will have at least one uppercase letter. ___ # Output: Return the `index` of __first uppercase letter__ of reversed string. ___ # Examples: __input --> output__ ``` f("HelloWorld") --> 4 f("Codewars") --> 7 f("X") --> 0 f("findX") --> 0 ``` ___ # Golfing Message: The length of your code should be less or equals to `44`. Your code should be one line. The length of the reference solution is `37`. ___ # Special Acknowledgement: Thank for the feedback and helping from @[Unnamed](https://www.codewars.com/users/Unnamed), @[Kacarott](https://www.codewars.com/users/Kacarott), @[scarecrw](https://www.codewars.com/users/scarecrw) and @[Madjosz](https://www.codewars.com/users/Madjosz).
games
def f(s): return s[- 1] > "Z" and - ~ f(s[: - 1])
[Code Golf] Reversed Upper Index
62f8d0ac2b7cd50029dd834c
[ "Strings", "Restricted" ]
https://www.codewars.com/kata/62f8d0ac2b7cd50029dd834c
6 kyu
**SITUATION** Imagine you are trying to roll a ball a certain distance down a road. The ball will have a starting speed that slowly degrades due to friction and cracks in the road. Every time the ball rolls a distance equal to its speed or rolls over a crack, its speed decreases by 1. Given a speed of s which the ball starts rolling, and a roadmap r of the street represented by a string, return whether or not the ball will be able to make it past the end of the road (True or False). **NOTES** - A ball with 0 speed is motionless. - If a ball happens to roll over a crack, the speed decrease must only take effect after the ball has rolled a distance equal to its speed. For example, if the speed was 10, but the ball hit 2 cracks before rolling 10 distance, the ball's speed should stay at 10 until it has reached 10 distance, in which the speed should decrease to 7 (-2 from cracks and -1 due to friction). - On the roadmap, "_" represents flat ground and "x" represents a crack - The length of the roadmap will be equal to the distance to the ball's final destination - The ball must reach the last tile of the road for the solution to be considered valid. **EXAMPLES** - A speed of 100, and a roadmap of '_' should return True because the ball would be moving too quickly for friction to be applied and there are no cracks on the road. - A speed of 1, and a roadmap of '___________' should return False because friction would stop the ball after 1 distance
reference
def ball_test(s, r): if len(r) <= s: return True elif s <= 0 and r: return False cracks = r[: s]. count('x') return ball_test(s - 1 - cracks, r[s:])
Street Bowling
62f96f01d67d0a0014f365cf
[ "Algorithms", "Strings" ]
https://www.codewars.com/kata/62f96f01d67d0a0014f365cf
7 kyu
Copy of [Is the King in check ?](https://www.codewars.com/kata/5e28ae347036fa001a504bbe/javascript). But this time your solution has to be ` < 280` characters, no semicolons or new lines. You have to write a function ``` is_check ``` that takes for input a 8x8 chessboard in the form of a bi-dimensional array of strings and returns ````true```` if the black king is in check or ````false```` if it is not. The array will include 64 squares which can contain the following characters : <ul> <li>'♔' for the black King;</li> <li>'♛' for a white Queen;</li> <li>'♝' for a white Bishop;</li> <li>'♞' for a white Knight;</li> <li>'♜' for a white Rook;</li> <li>'♟' for a white Pawn;</li> <li><pre>' ' (a space) if there is no piece on that square.</pre></li> </ul> Note : these are actually inverted-color [chess Unicode characters](https://en.wikipedia.org/wiki/Chess_symbols_in_Unicode) because the dark codewars theme makes the white appear black and vice versa. Use the characters shown above. There will always be exactly one king, which is the **black** king, whereas all the other pieces are **white**.<br> **The board is oriented from Black's perspective.**<br> Remember that pawns can only move and take **forward**.<br> Also be careful with the pieces' line of sight ;-) . The input will always be valid, no need to validate it.
games
is_check = lambda g, n = '(.{7}|.{11}|.{18}(|..))', r = '((.{9} )*.{9}| *)', b = '((.{8} )*.{8}|(.{10} )*.{10})': bool(__import__( 're'). search(f"♔ { n } ♞|♞ { n } ♔|♔ { r } [♛♜]|[♛♜] { r } ♔|[♛♝] { b } ♔|♔ { b } [♛♝]|♟.{{ 8}} (|..)♔", '||' . join(map('' . join, g))))
One line task: Is the King in check ?
5e320fe3358578001e04ad55
[ "Restricted", "Puzzles" ]
https://www.codewars.com/kata/5e320fe3358578001e04ad55
3 kyu
Everybody likes sliding puzzles! For this kata, we're going to be looking at a special type of sliding puzzle called Loopover. With Loopover, it is more like a flat rubik's cube than a sliding puzzle. Instead of having one open spot for pieces to slide into, the entire grid is filled with pieces that wrap back around when a row or column is slid. Try it out: https://www.openprocessing.org/sketch/576328 Note: computer scientists start counting at zero! **Your task**: return a List of moves that will transform the unsolved grid into the solved one. All values of the scrambled and unscrambled grids will be unique! Moves will be 2 character long Strings like the ones below. For example, if we have the grid: ``` ABCDE FGHIJ KLMNO PQRST UVWXY ``` and we do `R0` (move the 0th row right) then we get: ``` EABCD FGHIJ KLMNO PQRST UVWXY ``` Likewise, if we do `L0` (move the 0th row left), we get: ``` ABCDE FGHIJ KLMNO PQRST UVWXY ``` if we do `U2` (2nd column up): ``` ABHDE FGMIJ KLRNO PQWST UVCXY ``` and if we do `D2` (2nd column down) we will once again return to the original grid. With all of this in mind, I'm going to make a Loopover with a scrambled grid, and your solve method will give me a List of moves I can do to get back to the solved grid I give you. For example: SCRAMBLED GRID: ``` DEABC FGHIJ KLMNO PQRST UVWXY ``` SOLVED GRID: ``` ABCDE FGHIJ KLMNO PQRST UVWXY ``` One possible solution would be `["L0", "L0"]` as moving the top row left twice would result in the original, solved grid. Another would be `["R0", "R0", "R0"]`, etc. etc. NOTE: The solved grid will not always look as nice as the one shown above, so make sure your solution can always get the mixed up grid to the "solved" grid! # Input `mixedUpBoard` and `solvedBoard` are two-dimensional arrays (or lists of lists) of symbols representing the initial (unsolved) and final (solved) grids. Different grid sizes are tested: from `2x2` to `9x9` grids (including rectangular grids like `4x5`). # Output Return a list of moves to transform the `mixedUpBoard` grid to the `solvedBoard` grid. Some configurations cannot be solved. Return `null` (`None` in Python) for unsolvable configurations. Good luck! Let me know if there are any issues with the kata! :)
games
def loopover(mixed, solved): t = {c: (i, j) for (i, row) in enumerate(solved) for (j, c) in enumerate(row)} b = {(i, j): t[c] for (i, row) in enumerate(mixed) for j, c in enumerate(row)} unsolved = {k for k, v in b . items() if k not in ( (0, 0), (0, 1)) and k != v} sol = [] while unsolved: i, j = next(iter(unsolved)) if b[0, 0] in ((0, 0), (0, 1)) else b[0, 0] if i == 0: sol += [f"D { j } ", * j * ["L1"], "L0", "U0", "R0", "D0", * j * ["R1"], f"U { j } "] else: sol += [* j * [f"L { i } "], "L0", * i * ["U0"], "R0", * i * ["D0"], * j * [f"R { i } "]] b[0, 0], b[0, 1], b[i, j] = b[0, 1], b[i, j], b[0, 0] if b[i, j] == (i, j): unsolved . remove((i, j)) if b[0, 0] != (0, 0) and len(mixed) % 2 == 0: sol += [* len(mixed) / / 2 * ["D0", "L0", "D0", "R0"], "D0"] elif b[0, 0] != (0, 0) and len(mixed[0]) % 2 == 0: sol += [* len(mixed[0]) / / 2 * ["R0", "U0", "R0", "D0"], "U0", "R0", "D0"] elif b[0, 0] != (0, 0): return None return sol
Loopover
5c1d796370fee68b1e000611
[ "Puzzles", "Algorithms", "Game Solvers" ]
https://www.codewars.com/kata/5c1d796370fee68b1e000611
1 kyu
<img src='https://i.imgur.com/3W4hpEW.png' align="right">Have you ever played <a href='https://en.wikipedia.org/wiki/Microsoft_Minesweeper'>Minesweeper</a>? It's a WINDOWS own game that mainly tests the player's ability to think logically. Here are the rules of the game, maybe helpful to someone who hasn't played Minesweeper: "The goal of the game is to uncover all the squares that do not contain mines without being "blown up" by clicking on a square with a mine underneath. The location of the mines is discovered by a process of logic. Clicking on the game board will reveal what is hidden underneath the chosen square or squares (a large number of blank squares may be revealed in one go if they are adjacent to each other). Some squares are blank but some contain numbers (1 to 8), each number being the number of mines adjacent to the uncovered square. To help avoid hitting a mine, the location of a suspected mine can be marked by flagging it with the right mouse button. The game is won once all blank squares have been uncovered without hitting a mine, any remaining mines not identified by flags being automatically flagged by the computer. However, in the event that a game is lost and the player mistakenly flags a safe square, that square will either appear with a red X covering the mine (denoting it as safe), or just a red X (also denoting it as safe)." # Task In this kata, I'll give you a string `map` as a game map, and a number `n` indicating the total number of mines. Like this: ``` map = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 0 0 ? ? ? n = 6 ``` Yes, you always get a matrix with some question marks, except for some 0s (because I think you need a place to start your logical reasoning). Digit 0 means that there's 0 mines around here, so you can safely `open` the grid cells around 0. How to open the grid cell? I've preloaded a method `open`, usage is `open(row,column)` (for Java users: `Game.open(int row, int column)`). It will return a number that indicates how many mines are around this grid cell. If there is an error in your logical reasoning, when you use the open method to open a grid cell, but there is a mine hidden in this grid cell, then the test will fail. Please note, method `open` only returns a number, but does not modify the `map`—you should modify the `map` by yourself. You open more and more grid cells until all safe grid cells are opened and all mine grid cells are marked by `'x'`. Then return the result like this: ``` 1 x 1 1 x 1 2 2 2 1 2 2 2 x 2 0 1 x 2 x 2 1 2 2 1 1 1 1 x 1 0 0 0 1 1 1 ``` If the game cannot get a valid result, return `"?"`. See following: ``` map = 0 ? ? 0 ? ? n = 1 First you open two middle grid cells (using `open(0,1)` and `open(1,1)`), then you get: map = 0 1 ? 0 1 ? Now, there is only one mine left, but there are two `?` left. The mine can be hidden in either of them. So, you should return "?" as the result there. ```
games
from itertools import combinations def solve_mine(mapStr, n): return MineSweeper(mapStr, n). solve() class MineSweeper (object): IS_DEBUG = False around = [(dx, dy) for dx in range(- 1, 2) for dy in range(- 1, 2) if (dx, dy) != (0, 0)] def __init__(self, mapStr, nMines): lines = mapStr . split('\n') mapDct, unknowns, posToWorkOn = {}, set(), set() for x, line in enumerate(lines): for y, c in enumerate(line . split(' ')): mapDct[(x, y)] = c if c == '?': unknowns . add((x, y)) else: posToWorkOn . add((x, y)) self . map = mapDct self . unknowns = unknowns self . posToWorkOn = posToWorkOn self . flagged = set() self . nMines = nMines self . lX = len(lines) self . lY = len(lines[0]. split(' ')) def __str__(self): return '\n' . join(' ' . join( self . map[(x, y)] for y in range(self . lY)) for x in range(self . lX)) def getValAt(self, pos): return int(self . map[pos]) def getneighbors(self, pos): return { (pos[0] + dx, pos[1] + dy) for dx, dy in self . around} def printDebug(self): print(" \n------------\n{}\nRemaining mines: {}" . format( self, self . nMines - len(self . flagged))) if self . IS_DEBUG else None def lookaroundThisPos(self, pos): neighbors = self . getneighbors(pos) return {'?': neighbors & self . unknowns, 'x': neighbors & self . flagged} """ MAIN FUNCTION """ def solve(self): self . printDebug() while True: while True: # Archive to check against modifications archivePosToWorkOn = self . posToWorkOn . copy() self . openAndFlag_OnTheFly() self . printDebug() # Open and flag in the map while simple matches can be found self . complexSearch_OpenAndFlag() # Use more complex algorithm to find mines or unknown positions that are surely openable self . printDebug() if archivePosToWorkOn == self . posToWorkOn: break # Repeat these two "simple" steps until its not possible to go further in the resolution # Use witted combinatory approach to go further (if possible) self . complexSearch_CombineApproach() if archivePosToWorkOn == self . posToWorkOn: break # Repeat these to "simple" steps until its not possible to go further in the resolution self . printDebug() # If no more mines remaining but some unknown cases still there if len(self . flagged) == self . nMines: self . openThosePos(self . unknowns . copy()) # If all the remaining "?" are mines, flag them elif len(self . flagged) + len(self . unknowns) == self . nMines: self . flagThosePos(self . unknowns . copy()) self . printDebug() return '?' if self . unknowns else str(self) def openAndFlag_OnTheFly(self): while True: openables, workDonePos = set(), set() for pos in self . posToWorkOn: # Run through all the positions that might neighbors to open openables, workDonePos = [baseSet | newPart for baseSet, newPart in zip( (openables, workDonePos), self . openablePosaround_FlagOnTheFly(pos))] # After the exit of the loop, modification of self.posToWorkOn is possible, so: self . openThosePos(openables) # remove the pos with full number of mines from the working set (to fasten the executions) self . posToWorkOn -= workDonePos if not openables and not workDonePos: break def openablePosaround_FlagOnTheFly(self, pos): around = self . lookaroundThisPos(pos) # If all the unknomn cases can be flagged (or if they are already!)... if self . getValAt(pos) == len(around['?']) + len(around['x']): self . flagThosePos(around['?']) # flag them (if not already done) # return the current position to remove it from self.posToWorkOn ("We're done with you..." / This behaviour will identify the "done" positions generated by the "witted approach") return (set(), {pos}) return (around['?'], {pos}) if self . getValAt(pos) == len(around['x']) else (set(), set()) def openThosePos(self, posToOpen): for pos in posToOpen: self . map[pos] = str(open(* pos)) # Open squares and update the map if self . map[pos] != '0': self . posToWorkOn . add(pos) # Update slef.posToWorkOn if needed self . unknowns -= posToOpen # Remove opened squares from the unknown positions def flagThosePos(self, posToFlag): for pos in posToFlag: self . map[pos] = 'x' # Flag mines self . unknowns -= posToFlag # Remove flagged squares from the unknown positions self . flagged |= posToFlag # update the set of flagged positions def complexSearch_OpenAndFlag(self): markables, openables = set(), set() for pos in self . posToWorkOn: newMark, newOpen = self . intelligencia_OpenAndFlag(pos) markables |= newMark openables |= newOpen self . flagThosePos(markables) self . openThosePos(openables) def intelligencia_OpenAndFlag(self, pos): around = self . lookaroundThisPos(pos) # Cases around the current position # Prepare an array with the number of remaining mines to find for the current position and the neighbor that will be worked on later rMines = [self . getValAt(pos) - len(around['x']), 0] # Search for neighbors (only usefull ones, meaning: self.getValAt(posneighbor) is a number and this neighbor still miss some mines) neighToWorkOn = self . getneighbors(pos) & self . posToWorkOn # markables: position that will be flagged / openables: positions that will be open... of course... / fullUnion: stroe all the squares markables, openables = set(), set() knownParts = [] # knownParts: list of the intersections of the '?' cases of all the neighbors of the current pos and the current neighbor for pos2 in neighToWorkOn: # Cases around the neighbor that is worked on right now around2 = self . lookaroundThisPos(pos2) # Update the number of mines still to find for the current neighbor rMines[1] = self . getValAt(pos2) - len(around2['x']) # Define the '?' that are owned only by the current "pos", and only by the current neighbor ("pos2") onlys = [around['?'] - around2['?'], around2['?'] - around['?']] # Define the minimum (yes "minimum", even if "max" is used!) number of mines that have to be in the '?' that are commun to "pos" and it's current neighbor pos2" mInter = max(n - len(only) for n, only in zip(rMines, onlys)) if mInter <= 0 or 1 not in rMines: continue # If these conditions are met, there is nothing "extrapolable" at the current position, so continue the iteration currentIntersect = around['?'] & around2['?'] if currentIntersect: # Store (if it exists) the current intersection of '?' cases for further checks knownParts . append(currentIntersect) for i in range(2): # Work on the two current LOCATIONS (pos, pos2) if len(onlys[i]) == rMines[i] - mInter: # The number of '?' cases that are only around the treated LOCATION matches the number mines of this LOCATION that are out of the interesction "pos & pos2". So, those cases will be flagged markables |= onlys[i] elif mInter == rMines[i]: openables |= onlys[i] # If the number of mines surely present in the intersection "pos & pos2" matches the number of mines still to found arorund the treated LOCATION, all the cases out of the intersection for the current LOCATION can be opened # Final check on the different intersections parts: # Union of all the intersections for the current position and its differente neighbors fullIntersection = { posInter for posSet in knownParts for posInter in posSet} if len(knownParts) == rMines[0] and sum(len(s) for s in knownParts) == len(fullIntersection): # If some '?' cases are still unchecked while we can be sure that all the remaining mines are elsewhere (even without knowing their exact location), the leftovers can be opened openables |= around['?'] - fullIntersection return markables, openables def complexSearch_CombineApproach(self): # number of remaining mines to find rMines = self . nMines - len(self . flagged) matchPos = [] if rMines != 0: # '?' that are joined to the current posToWorkOn... borderUnknowns = { pos2 for pos in self . posToWorkOn for pos2 in self . lookaroundThisPos(pos)['?']} # ...then add the "next layer" of "?", ot be able to make more guesses on the remaining farther squares borderUnknowns |= { pos2 for pos in borderUnknowns for pos2 in self . lookaroundThisPos(pos)['?']} for n in range(rMines if not (self . unknowns - borderUnknowns) else 1, min(rMines, len(borderUnknowns) - 1) + 1): for posMines in combinations(borderUnknowns, n): setPosMines = set(posMines) for pos in self . posToWorkOn: around = self . lookaroundThisPos(pos) if self . getValAt(pos) != len(around['x']) + len(around['?'] & setPosMines): break else: # if the for loop execute until its end, the current position is valid. Archive it. matchPos . append(setPosMines) # search for '?' that are never marked in any of the valid combinations untouched = borderUnknowns - {flagPos for s in matchPos for flagPos in s} if len(matchPos) == 1: # Flag the found mines if only 1 match self . flagThosePos(matchPos[0]) self . openThosePos(untouched) # open the untouched '?' (free of mines!!)
Mine Sweeper
57ff9d3b8f7dda23130015fa
[ "Puzzles", "Game Solvers" ]
https://www.codewars.com/kata/57ff9d3b8f7dda23130015fa
1 kyu
# Whitespace [Whitespace](http://compsoc.dur.ac.uk/whitespace/tutorial.php) is an esoteric programming language that uses only three characters: * `[space]` or `" "` (ASCII 32) * `[tab]` or `"\t"` (ASCII 9) * `[line-feed]` or `"\n"` (ASCII 10) All other characters may be used for comments. The interpreter ignores them. Whitespace is an imperative, stack-based programming language, including features such as subroutines. Each command in whitespace begins with an *Instruction Modification Parameter* (IMP). ```if:haskell The return value is of type `Either String String`. If the program exits with no error, it should return `Right` with the output of the program. If there is an error, it should return `Left` with an error message (The content of the error message will not be check). ``` ## IMPs ---- * `[space]`: Stack Manipulation * `[tab][space]`: Arithmetic * `[tab][tab]`: Heap Access * `[tab][line-feed]`: Input/Output * `[line-feed]`: Flow Control There are two types of data a command may be passed: numbers and labels. ### Parsing Numbers * Numbers begin with a `[sign]` symbol. The sign symbol is either `[tab]` -> **negative**, or `[space]` -> **positive**. * Numbers end with a `[terminal]` symbol: `[line-feed]`. * Between the sign symbol and the terminal symbol are binary digits `[space]` -> **binary-0**, or `[tab]` -> **binary-1**. * A number expression `[sign][terminal]` will be treated as **zero**. * The expression of just `[terminal]` should **throw an error**. *(The Haskell implementation is inconsistent about this.)* ### Parsing Labels * Labels begin with any number of `[tab]` and `[space]` characters. * Labels end with a **terminal** symbol: `[line-feed]`. * Unlike with numbers, the expression of just `[terminal]` is **valid**. * Labels **must** be unique. * A label **may** be declared either before or after a command that refers to it. ## Input/Output As stated earlier, there commands may read data from input or write to output. ### Parsing Input Whitespace will accept input either characters or integers. Due to the lack of an input stream mechanism, the input will be passed as a string to the interpreter function. * Reading a character involves simply taking a character from the input stream. * Reading an integer involves parsing a decimal or hexadecimal number (prefixed by 0x) from the current position of the input stream, up to and terminated by a line-feed character. Octal numbers (prefixed by 0) and binary numbers (prefixed by 0b) may optionally be supported. * The original implementation being in Haskell has stricter requirements for parsing an integer. * The Javascript and Coffeescript implementations will accept any number that can be parsed by the **parseInt** function as a single parameter. * The Python implementations will accept any number that can be parsed by the **int** function as a single parameter. * The Java implementations **will** use an `InputStream` instance for input. For `InputStream` use `readLine` if the program requests a number and `read` if the program expects a character. * An error should be thrown if the input ends before parsing is complete. *(This is a non-issue for the Haskell implementation, as it expects user input)* ### Writing Output * For a number, append the output string with the number's string value. * For a character, simply append the output string with the character. * The Java implementations will support an optional `OutputStream` for output. If an `OutputStream` is provided, it should be flushed before and after code execution and filled as code is executed. The output string should be returned in any case. ## Commands Notation: ***n*** specifies the parameter, `[number]` or `[label]`. **Errors should be thrown** for invalid numbers, labels, and heap addresses, or if there are not enough items on the stack to complete an operation (unless otherwise specified). In addition, an error should be thrown for unclean termination. ### IMP \[space\] - Stack Manipulation * `[space]` `(number)`: Push *n* onto the stack. * `[tab][space]` `(number)`: Duplicate the *n*th value from the top of the stack and push onto the stack. * `[tab][line-feed]` `(number)`: Discard the top *n* values below the top of the stack from the stack. (*For **n**<**0** or **n**>=**stack.length**, remove everything but the top value.*) * `[line-feed][space]`: Duplicate the top value on the stack. * `[line-feed][tab]`: Swap the top two value on the stack. * `[line-feed][line-feed]`: Discard the top value on the stack. ### IMP \[tab\]\[space\] - Arithmetic * `[space][space]`: Pop `a` and `b`, then push `b+a`. * `[space][tab]`: Pop `a` and `b`, then push `b-a`. * `[space][line-feed]`: Pop `a` and `b`, then push `b*a`. * `[tab][space]`: Pop `a` and `b`, then push `b/a`\*. If `a` is zero, throw an error. * \***Note that the result is defined as the floor of the quotient.** * `[tab][tab]`: Pop `a` and `b`, then push `b%a`\*. If `a` is zero, throw an error. * \***Note that the result is defined as the remainder after division and sign (+/-) of the divisor (a).** ### IMP \[tab\]\[tab\] - Heap Access * `[space]`: Pop `a` and `b`, then store `a` at heap address `b`. * `[tab]`: Pop `a` and then push the value at heap address `a` onto the stack. ### IMP \[tab\]\[line-feed\] - Input/Output * `[space][space]`: Pop a value off the stack and output it as a **character**. * `[space][tab]`: Pop a value off the stack and output it as a **number**. * `[tab][space]`: Read a **character** from input, `a`, Pop a value off the stack, `b`, then store the ASCII value of `a` at heap address `b`. * `[tab][tab]`: Read a **number** from input, `a`, Pop a value off the stack, `b`, then store `a` at heap address `b`. ### IMP \[line-feed\] - Flow Control * `[space][space]` `(label)`: Mark a location in the program with label *n*. * `[space][tab]` `(label)`: Call a subroutine with the location specified by label *n*. * `[space][line-feed]` `(label)`: Jump unconditionally to the position specified by label *n*. * `[tab][space]` `(label)`: Pop a value off the stack and jump to the label specified by *n* **if** the value is zero. * `[tab][tab]` `(label)`: Pop a value off the stack and jump to the label specified by *n* **if** the value is less than zero. * `[tab][line-feed]`: Exit a subroutine and return control to the location from which the subroutine was called. * `[line-feed][line-feed]`: Exit the program. ---- ## Notes ### Division and modulo Whitespace expects floored division and modulo * In Javascript and Coffeescript, the modulus operator is implemented differently than it was in the original Whitespace interpreter. Whitespace was influenced by having been originally implemented in Haskell. Javascript and Coffeescript also lack integer division operations. You need to pay a little extra attention in regard to the implementation of integer division and the modulus operator (See: [floored division in the Wikipedia article "Modulo operation"](https://en.wikipedia.org/wiki/Modulo_operation#Remainder_calculation_for_the_modulo_operation) * Java defines methods for floor division and modulo in `Math` class. The methods differ from the traditional `/` and `%` operators. * There is no difference between Whitespace and Python in regard to the standard implementation of integer division and modulo operations.
algorithms
def whitespace(code, inp=''): code = '' . join(['STN' [' \t\n' . index(c)] for c in code if c in ' \t\n']) output, stack, heap, calls, pos, run, search, inp = [ ], [], {}, [], [0], [True], [None], list(inp) def set_(t, i, val): t[i] = val # Stack operations def pop(n=0): return (assert_(n < len(stack)), stack[n], set_(stack, slice(n, n + 1), ()))[1] def get(n): return (assert_(n >= 0 and n < len(stack)), stack[n])[1] def push(n): return stack . insert(0, n) # Parsing utilities def accept(tokens, action=None): for token in tokens . split(','): if code[pos[0]: pos[0] + len(token)] == token: pos[0] += len(token) if action: p = 0 if token in ('SS', 'STS', 'STN'): p = number() elif token in ('NST', 'NSN', 'NTS', 'NTT', 'NSS'): p = label() ((not search[0]) or token == 'NSS') and action(p) return token def assert_(* args): if len(args) and args[0]: return args[0] raise Exception('error') def number(): if accept('N'): raise Exception('No digits for number') n = '+0' if accept('S,T') == 'S' else '-0' while not accept('N'): n += str(int(accept('S,T') != 'S')) return int(n, 2) def label(l=''): while not accept('N'): l += accept('S,T') or '' return l + '1' instructions = {'SS': lambda n: push(n), 'STS': lambda n: push(get(n)), 'STN': lambda n: set_(stack, slice(1, len(stack) if n < 0 else 1 + n), ()), 'SNS': lambda _: push(get(0)), 'SNT': lambda _: set_(stack, slice(1, 1), [pop()]), 'SNN': lambda _: pop(), 'TSSS': lambda _: push(pop(1) + pop()), 'TSST': lambda _: push(pop(1) - pop()), 'TSSN': lambda _: push(pop(1) * pop()), 'TSTS': lambda _: push(pop(1) / assert_(pop())), 'TSTT': lambda _: (lambda d: push((pop() % d + d) % d))(assert_(pop())), 'TTS': lambda _: set_(heap, pop(1), pop()), 'TTT': lambda _: (assert_(stack[0] in heap), push(heap[pop()])), 'TNSS': lambda _: output . append(chr(pop())), 'TNST': lambda _: output . append(str(pop())), 'TNTS': lambda _: (set_(heap, pop(), ord(assert_(inp)[0])), inp . pop(0)), 'TNTT': lambda _: (lambda n: (set_(heap, pop(), int(assert_('' . join(inp[: n])))), set_(inp, slice(0, n + 1), ())))(inp . index('\n') if '\n' in inp else len(inp)), 'NST': lambda l: (calls . append(pos[0]), set_(pos, 0, heap[l]) if heap . get(l) else set_(search, 0, l)), 'NSN': lambda l: set_(pos, 0, heap[l]) if heap . get(l) else set_(search, 0, l), 'NTS': lambda l: (not pop()) and (set_(pos, 0, heap[l]) if heap . get(l) else set_(search, 0, l)), 'NTT': lambda l: pop() < 0 and (set_(pos, 0, heap[l]) if heap . get(l) else set_(search, 0, l)), 'NTN': lambda _: set_(pos, 0, assert_(calls). pop()), 'NNN': lambda _: set_(run, 0, False), 'NSS': lambda l: (assert_((not heap . get(l)) or heap[l] == pos[0]), set_(heap, l, pos[0]), search[0] == l and set_(search, 0, 0)), } while run[0]: assert_(pos[0] < len(code)) any(accept(* instruction) for instruction in instructions . items()) or assert_() return '' . join(output)
Whitespace Interpreter
52dc4688eca89d0f820004c6
[ "Esoteric Languages", "Interpreters", "Algorithms" ]
https://www.codewars.com/kata/52dc4688eca89d0f820004c6
2 kyu
_(Revised version from previous series 6)_ # Number Pyramid: Image a number pyramid starts with `1`, and the numbers increasing by `1`. Today, it has total `5000` levels. For example, the top 4 levels of the pyramid looks like: ``` 1 2 3 4 5 6 7 8 9 10 ``` ___ # Left and Right: Now from the center line, cut the pyramid into `Left` and `Right`. In the above example, it will become: ``` Left: # Right: # 2 # 3 4 # 6 7 8 # 9 10 (The numbers of center line was cut, do not go on any side.) ``` ___ # Input: You will be given a number `n`, it will not go beyond `5000` levels. ___ # Output: You need to return the number is locating at `Left` or `Right` part. * Return `'L'` for Left. * Return `'R'` for Right. * Return `'C'` for Center/been Cut __Examples:__ ``` left_right(1) --> 'C' left_right(2) --> 'L' left_right(3) --> 'R' left_right(4) --> 'L' left_right(5) --> 'C' left_right(6) --> 'R' ``` ___ # Golfing Message: The length of your code should be less or equal to `72`. The length of reference solution is `65` (Python) and `67` (JS). ___ If you like this series, welcome to do [other kata](https://www.codewars.com/collections/code-golf-number-pyramid-series) of it.
games
def left_right(n): return 'CLR' [int((8 * n - 4) * * .5 % 2 / / - 1)]
[Code Golf] Number Pyramid Series 6(Revised) - Left or Right
62eedcfc729041000ea082c1
[ "Mathematics", "Restricted" ]
https://www.codewars.com/kata/62eedcfc729041000ea082c1
6 kyu
In a computer operating system that uses paging for virtual memory management, page replacement algorithms decide which memory pages to page out when a page of memory needs to be allocated. Page replacement happens when a requested page is not in memory (page fault) and a free page cannot be used to satisfy the allocation, either because there are none, or because the number of free pages is lower than some threshold. ## The FIFO page replacement algorithm The first-in, first-out (FIFO) page replacement algorithm is a low-overhead algorithm that requires little bookkeeping on the part of the operating system. The idea is obvious from the name: the operating system keeps track of all the pages in memory in a queue, with the most recent arrival at the back, and the oldest arrival in front. When a page needs to be replaced, the oldest page is selected. Note that a page already in the queue is not pushed at the end of the queue if it is referenced again.<br> Your task is to implement this algorithm. The function will take two parameters as input: the number of maximum pages that can be kept in memory at the same time ```n``` and a ```reference list``` containing numbers. Every number represents a page request for a specific page (you can see this number as the unique ID of a page). The expected output is the status of the memory after the application of the algorithm. Note that when a page is inserted in the memory, it stays at the same position until it is removed from the memory by a page fault. ## Example: Given: * N = 3, * REFERENCE LIST = \[1, 2, 3, 4, 2, 5\], ``` * 1 is read, page fault --> memory = [1]; * 2 is read, page fault --> memory = [1, 2]; * 3 is read, page fault --> memory = [1, 2, 3]; * 4 is read, page fault --> memory = [4, 2, 3]; * 2 is read, already in memory, nothing happens; * 5 is read, page fault --> memory = [4, 5, 3]. ``` So, at the end we have the list ```[4, 5, 3]```, which is what you have to return. If not all the slots in the memory get occupied after applying the algorithm, fill the remaining slots (at the end of the list) with ```-1``` to represent emptiness (note that the IDs will always be >= 1).
algorithms
def fifo(n, reference_list): memory = [- 1] * n c = 0 for ref in reference_list: if ref in memory: continue memory[c] = ref c = (c + 1) % n return memory
Page replacement algorithms: FIFO
62d34faad32b8c002a17d6d9
[ "Algorithms", "Lists" ]
https://www.codewars.com/kata/62d34faad32b8c002a17d6d9
7 kyu
## Overview The genius supervillain Professor Lan X, head of the mysterious organization Just4EvilCoders, is bored in his secret volcano research laboratory and challenges you to the following game: First, **you will be blindfolded**. Then on a very, very large 2d chessboard, he will place a chess piece on a starting square, at coordinates = `(0,0)`. The chess piece he uses may be a standard King or Knight, or it may be a **completely custom piece with custom possible move-set**. Then he will select a basic move pattern from that piece's **distinct** possible moves, **without telling you which move(s) he has chosen**. Then he will begin repeatedly moving the piece **in the same repeating pattern of moves** over and over. To make things clear, let's look at an example: ```python known inputs: moves = [(-1, 1), (1, 0), (0, -1), (0, 1), (-1, 0), (1, -1), (-1, -1), (1, 1)] unknown to you: actual_length_of_move_pattern = 2 actual_move_pattern_chosen = right (1,0) then down (0,-1), repeating forever ``` In the above game instance, he has decided to play with a standard King, which has a total `moves` list of `8` possible moves: you **do know** the `moves` list before the game starts. **Unknown to you** he then chose to play the game with the following 2 King moves: "rightwards" `(1,0)` followed by "downwards" `(0,-1)`, **in that order**. So, to be clear, what will be the chess piece's actual location during this particular game? - After his first move (rightwards), the King is at `(1,0)` - After his second move (downwards), the King is at `(1,-1)` - After his third move (**the repeating pattern now returns to rightwards again**), the King is at `(2,-1)` - After his fourth move (**the repeating pattern now returns to downwards again**), the King is at `(2,-2)` - After his fifth move (he moves rightwards again), the King is at `(3,-2)` etc. Your game rules are as follows: After **each** of the supervillain's moves, you must guess the location of where you think the chess piece **currently** is on the chessboard. If your guess correctly matches the **current** location of the piece, you win. Remember: you are blindfolded **and** you do not know which moves the evil genius is performing - only that he is repeating a basic pattern of distinct moves. Professor Lan X is very busy working on his Death Ray so **you will only be given a limited number of guesses: you have 500 guesses to win each game he decides to play**. If you haven't found the chess piece within this guess limit you will lose and you will ~~BE THROWN INTO THE JUST4EVILCODERS SHARK TANK~~ find that nothing bad happens to you of course... those sharks?? Oh, they are just there for.. ummmm... decorative purposes!! Yes, yes, they are quite friendly really :) --- ## Inputs You will be given `moves`, which is a `list` of `2-ples` of `integers`, which represents **all possible moves** of a given chess piece. For example, for a game played with a standard King, you would be given the list: `[(-1, 1), (1, 0), (0, -1), (0, 1), (-1, 0), (1, -1), (-1, -1), (1, 1)]` which represents all 8 possible moves of a King. As another example, here is a possible `moves` input list for a **completely custom** strange chess piece which has only 7 possible moves: `[(10000,43), (-2,13), (5,5), (4,-11), (0,10), (999,-444), (0,1)]` The maximum size of the `moves` list in the tests will be `8`, and the minimum size of the `moves` list will be `5`. The largest step size of the custom pieces will be `+/- 10000`, i.e. `(10000, -10000)` is a valid possible move for a custom piece. On the other hand, `(0,0)` will never be used as a random move for any random chess piece. **IMPORTANT:** A move, if chosen, will **only occur once** in the repeating basic pattern of moves - therefore for example `[(1,1), (-1,0), (1,1)]` **is not an allowed basic pattern of 3 moves to repeat**, because there is a move - `(1,1)` - that has been used more than once in this basic pattern of length 3. ## Outputs You must return a `list` of `2-ples` of `integers`. This list represents your guesses **sorted in the order in which you will make each guess**. Note that each of your guesses takes place **after** the supervillain makes his move from the starting square `(0,0)`, so for example the following guess list: `your_returned_solution_guess_list = [ (4,7), (33,-5), (123,-40), ...]` means that you guess that the piece is at square `(4,7)` after the supervillain moved the piece **once**, then you guess that the piece is at square `(33,-5)` after the supervillain moved the piece **twice**, etc. Your code must be able to handle any game strategy that Professor Lan X decides to use: whichever chess piece he decides to use, whether he uses from `1` up to `max = len(moves)` distinct moves of that chess piece, **and** whichever repeated basic pattern he decides to keep performing those moves in. ## Final important reminder Remember that your returned solution list of guesses must be of `length <= 500` for each possible game that Professor Lan X challenges you to. --- ## Acknowledgements This kata was significantly improved after discussions with **@Just4FunCoder** and **@LanXnHn**, and early comments by @Blind4Basics, @Kacarott, @Madjosz - thanks!
algorithms
from functools import reduce from itertools import combinations def _add(v0, v1): return v0[0] + v1[0], v0[1] + v1[1] def _mul(v, k): return v[0] * k, v[1] * k def _blindfold_chess(moves): mcs = {k: [reduce(_add, c) for c in combinations(moves, k)] for k in range(1, len(moves) + 1)} i = 0 while mcs: i += 1 for j, ms in reversed(mcs . items()): if i % j == 0: yield _mul(ms . pop(), i / / j) if not ms: del mcs[j] break else: yield (0, 0) def blindfold_chess(moves): return list(_blindfold_chess(moves))
Evil genius game - Find the moving chess piece while blindfolded
62e068c14129156a2e0df46a
[ "Algorithms", "Mathematics", "Combinatorics", "Performance" ]
https://www.codewars.com/kata/62e068c14129156a2e0df46a
4 kyu
One of the common ways of representing color is the RGB color model, in which the Red, Green, and Blue primary colors of light are added together in various ways to reproduce a broad array of colors. One of the ways to determine brightness of a color is to find the value V of the alternative HSV (Hue, Saturation, Value) color model. Value is defined as the largest component of a color: ``` V = max(R,G,B) ``` You are given a list of colors in 6-digit [hexidecimal notation](https://en.wikipedia.org/wiki/Web_colors) `#RRGGBB`. Return the brightest of these colors! For example, ``` brightest(["#001000", "#000000"]) == "#001000" brightest(["#ABCDEF", "#123456"]) == "#ABCDEF" ``` If there are multiple brightest colors, return the first one: ``` brightest(["#00FF00", "#FFFF00", "#01130F"]) == "#00FF00" ``` Note that both input and output should use upper case for characters `A, B, C, D, E, F`.
reference
# String comparison is enough, no need to convert def brightest(colors): return max(colors, key=lambda c: max(c[1: 3], c[3: 5], c[5:]))
Which color is the brightest?
62eb800ba29959001c07dfee
[ "Algorithms", "Strings" ]
https://www.codewars.com/kata/62eb800ba29959001c07dfee
7 kyu
In this kata you will compute the last digit of the sum of squares of Fibonacci numbers. Consider the sum `$S_n = F_0^2 + F_1^2 + ... + F_n^2$`, where `$F_0=0$`, `$F_1=1$` and `$F_i=F_{i-1}+F_{i-2}$` for `$i\geq2$` , you must compute the last digit of `$S_n$`. Example: Given input `$n=7$`, `$S_n=273$`. Therefore the output is 3. Note that `$0\leq n\leq10^{18}$`. So bruteforce will not work.
algorithms
def fibonacci_squared_sum(n): return int( "012650434056210098450676054890" [n % 30])
Last digit of the squared sum of Fibonacci numbers
62ea53ae888e170058f00ddc
[ "Mathematics" ]
https://www.codewars.com/kata/62ea53ae888e170058f00ddc
6 kyu
# Summary If you've ever been at rock/metal concerts, you know that they're great, but can be quite uncomfortable sometimes. In this kata, we're going to find the best place at the dance floor to be standing at! `dance_floor` will be given as an array of strings, each containing: * ASCII letters (uppercase and lowercase), representing people. * Space characters (`' '`), representing empty space. There will always be at least one string. All strings will have the same length (> 0). Your task is to rank potential places to stand at and return the best one. If multiple places happen to share the same best score, you may return any of them. ```if:python In Python, return value is expected to be a tuple of two ints: `(y, x)`, where `y` is index of the string and `x` is index of the character in that string. ``` ```if:cpp In C++, your function should return `std::pair<size_t, size_t>`, where `first` is index of the string and `second` is index of the character in that string (look at it as `{Y, X}` coordinates). ``` ```if:go In Go, your function should return `(y, x int)`, where `y` is index of the string and `x` is index of the character in that string. ``` # Factors for ranking ### The place must be empty You're not a tough guy and you can't just push someone away and take their place. So, you're only considering empty space for yourself. Input will always contain at least one such place. ### Distance from stage The closer you are to the stage, the better! So, the base score for a place equals length of the `dance_floor` minus the index of the string. Example: if `dance_floor` contains 5 strings, the first (closest to the stage) gets score of 5 and the last gets score of 1. ### Height of the person in front of you Even if you are close to the stage, a huge guy in front of you can spoil all the view! Because of that, you need to factor in his/her height. In the input strings, people are represented as letters. Height of a person is encoded as a position of the letter in the alphabet. `A` has height of 1, `B` - 2, `C` - 3, and so on. You'll need to multiply the initial score by `0.99 ^ height` (`0.99` to the power of `height`). If there's nobody right in front of you, the score is left as is. ### Beer Some of the fans are standing with a glass of beer in their hand. They are represented as uppercase letters (as opposed to lowercase letters without beer). You know that this beer always gets split around, so you want to avoid standing next to these people. For each beer holder next to you, you should multiply the score by `0.8`. "People next to you" are people to the left, to the right, in front of you, or behind you. ### Moshpits When you see a large free area that contains a 2x2 square of spaces, you know that it's not an accident. It's a moshpit! You don't like being kicked around, so you avoid moshpits at all costs and consider them only if there's no other free space available. **Note:** moshpits can be of any shape, not necessarily square or rectangle. They just need to contain a 2x2 piece somewhere. See example below. # Example ``` dance_floor = ["gbvKq JfiM I", "q jecl fvoX", "L Foa ygKT"] best_place(dance_floor) -> (1, 1) ``` `dance_floor` more visually: ``` # (stage here) "gbvKq JfiM I" "q jecl fvoX" "L Foa ygKT" ``` Each `' '` explained: * `(0,11)` gets score of `(3-0) * 0.8^2 = 1.92`. Even though it's right in front of the stage, you're surrounded with 2 beer holders, which makes it not ideal. * `(1,1)` gets score of `(3-1) * 0.99^2 = 1.9602`. This place is a bit further, but the person in front of you is very short, so you choose to spend the concert there. * `(0,5), (0,6), (1,6), (1,7), (1,8), (2,6), (2,7), (2,8)` is a moshpit (looks more a wall of death in this case, haha). You can recognize it by noticing the `(1,6)..(2,7)` square or the `(1,7)..(2,8)` square. In this example, there are other places where you can stand in peace, so you don't even consider these, even though `(0,5)` has the best score in the entire club. * `(2,1)` gets score of `(3-2) * 0.8 = 0.8`. There's nodoby in front of you, but you would stand even further away from the stage and carry a beer risk. * `(2,2)` gets score of `(3-2) * 0.99^10 * 0.8 = 0.7235`. Same distance and risk, plus there's a person in front.
algorithms
def places_around(dance_floor, row, col, empty=False): places = [] for i in ((- 1, 0), (0, - 1), (0, 1), (1, 0)): rel_row, rel_col = row + i[0], col + i[1] if 0 <= rel_row < rows and 0 <= rel_col < cols and (not empty or dance_floor[rel_row][rel_col] == ' '): places . append((rel_row, rel_col)) return places def best_place(dance_floor): global rows, cols rows, cols = len(dance_floor), len(dance_floor[0]) empty_places = [] for row in enumerate(dance_floor): # list all empty places for col in enumerate(row[1]): if col[1] == ' ': empty_places . append((row[0], col[0])) moshpit_places = set() for row, col in empty_places: # find 2x2 moshpits if row < rows - 1 and col < cols - 1 and dance_floor[row][col + 1] == dance_floor[row + 1][col] == dance_floor[row + 1][col + 1] == ' ': moshpit_places = moshpit_places . union( {(row, col), (row, col + 1), (row + 1, col), (row + 1, col + 1)}) moshpit_checked = set() # places that were already checked for branches while True: # branches of 2x2 moshpits length = len(moshpit_places) moshpit_unchecked = moshpit_places . difference(moshpit_checked) moshpit_checked = moshpit_checked . union(moshpit_places) for row, col in moshpit_unchecked: moshpit_places = moshpit_places . union( set(places_around(dance_floor, row, col, True))) if length - len(moshpit_places) == 0: # stop if no new branches were found break best_score = float('-inf') for row, col in empty_places: score = rows - row # distance from stage if row > 0: # height of person in front score *= .99 * * int(bin(ord(dance_floor[row - 1][col]))[- 5:], 2) for rel_row, rel_col in places_around(dance_floor, row, col): # beer score *= 1 - dance_floor[rel_row][rel_col]. isupper() * .2 score -= 999 * ((row, col) in moshpit_places) # moshpits if score > best_score: # keep track of best spot best_score = score best_place = (row, col) return best_place
Best place at concert
6112917ef983f2000ecbd506
[ "Strings", "Arrays", "Algorithms" ]
https://www.codewars.com/kata/6112917ef983f2000ecbd506
5 kyu
# Peg Solitaire <svg width="92.004997mm" height="92.004997mm" viewBox="0 0 92.004997 92.004997" version="1.1" id="svg5" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <defs id="defs2"> <linearGradient id="linearGradient1150"> <stop style="stop-color:#ffaaaa;stop-opacity:1" offset="0" id="stop1146" /> <stop style="stop-color:#ff0000;stop-opacity:1" offset="0.52336627" id="stop3090" /> <stop style="stop-color:#800000;stop-opacity:1" offset="1" id="stop1148" /> </linearGradient> <radialGradient xlink:href="#linearGradient1150" id="radialGradient1152" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,73.011649,11.260739)" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4897" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,86.011649,11.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4901" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,99.011649,11.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4905" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,73.011649,24.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4909" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,86.011649,24.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4913" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,99.011649,24.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4917" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,47.011649,37.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4921" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,60.011649,37.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4925" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,73.011649,37.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4929" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,86.011649,37.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4933" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,112.01165,37.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4937" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,125.01165,37.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4941" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,125.01165,50.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4945" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,112.01165,50.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4949" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,99.011649,50.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4953" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,60.011649,50.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4957" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,47.011649,50.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4961" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,47.011649,63.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4965" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,73.011649,63.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4969" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,99.011649,63.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4973" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,112.01165,63.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4977" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,125.01165,63.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4981" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,73.011649,76.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4985" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,99.011649,76.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4989" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,99.011649,89.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4993" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,86.011649,89.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient4997" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,73.011649,89.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient931" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,99.011649,37.260424)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient941" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,86.011334,76.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient943" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,86.011334,63.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient947" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,73.011334,50.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> <radialGradient xlink:href="#linearGradient1150" id="radialGradient951" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1.1956985,-0.73160339,0.65129485,-1.0645771,60.011334,63.260739)" cx="25.113058" cy="-14.110431" fx="25.113058" fy="-14.110431" r="5" /> </defs> <g id="layer1" transform="translate(0.20025,0.20025)"> <path style="fill:#c87137;stroke:#000000;stroke-width:1.005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 26.30225,0.30225 h 39 v 25.999999 h 25.999999 v 39 H 65.30225 v 25.999999 h -39 V 65.302249 h -26 v -39 h 26 z" id="path394" /> <circle style="fill:#000000;stroke-width:0.0928686" id="path572" cx="32.80225" cy="6.8022499" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle855" cx="45.80225" cy="6.8022499" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle857" cx="58.80225" cy="6.8022499" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle859" cx="32.80225" cy="19.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle861" cx="45.80225" cy="19.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle863" cx="58.80225" cy="19.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle865" cx="32.80225" cy="71.802246" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle867" cx="45.80225" cy="71.802246" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle869" cx="58.80225" cy="71.802246" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle871" cx="32.80225" cy="84.802246" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle873" cx="45.80225" cy="84.802246" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle875" cx="58.80225" cy="84.802246" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle877" cx="6.8022504" cy="32.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle879" cx="6.8022504" cy="45.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle881" cx="6.8022504" cy="58.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle883" cx="19.80225" cy="32.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle885" cx="19.80225" cy="45.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle887" cx="19.80225" cy="58.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle889" cx="32.80225" cy="32.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle891" cx="32.80225" cy="45.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle893" cx="32.80225" cy="58.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle895" cx="45.80225" cy="32.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle897" cx="45.80225" cy="45.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle899" cx="45.80225" cy="58.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle901" cx="58.80225" cy="32.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle903" cx="58.80225" cy="45.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle905" cx="58.80225" cy="58.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle907" cx="71.802254" cy="32.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle909" cx="71.802254" cy="45.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle911" cx="71.802254" cy="58.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle913" cx="84.802254" cy="32.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle915" cx="84.802254" cy="45.80225" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle917" cx="84.802254" cy="58.80225" r="1.755" /> <ellipse style="fill:url(#radialGradient1152);fill-opacity:1;stroke-width:0.203105" id="path941" cx="32.80225" cy="6.8023143" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4897);fill-opacity:1;stroke-width:0.203105" id="ellipse4895" cx="45.80225" cy="6.8023143" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4901);fill-opacity:1;stroke-width:0.203105" id="ellipse4899" cx="58.80225" cy="6.8023143" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4905);fill-opacity:1;stroke-width:0.203105" id="ellipse4903" cx="32.80225" cy="19.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4909);fill-opacity:1;stroke-width:0.203105" id="ellipse4907" cx="45.80225" cy="19.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4913);fill-opacity:1;stroke-width:0.203105" id="ellipse4911" cx="58.80225" cy="19.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4917);fill-opacity:1;stroke-width:0.203105" id="ellipse4915" cx="6.8022504" cy="32.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4921);fill-opacity:1;stroke-width:0.203105" id="ellipse4919" cx="19.80225" cy="32.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4925);fill-opacity:1;stroke-width:0.203105" id="ellipse4923" cx="32.80225" cy="32.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4929);fill-opacity:1;stroke-width:0.203105" id="ellipse4927" cx="45.80225" cy="32.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4933);fill-opacity:1;stroke-width:0.203105" id="ellipse4931" cx="71.802254" cy="32.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4937);fill-opacity:1;stroke-width:0.203105" id="ellipse4935" cx="84.802254" cy="32.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4941);fill-opacity:1;stroke-width:0.203105" id="ellipse4939" cx="84.802254" cy="45.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4945);fill-opacity:1;stroke-width:0.203105" id="ellipse4943" cx="71.802254" cy="45.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4949);fill-opacity:1;stroke-width:0.203105" id="ellipse4947" cx="58.80225" cy="45.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4953);fill-opacity:1;stroke-width:0.203105" id="ellipse4951" cx="19.80225" cy="45.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4957);fill-opacity:1;stroke-width:0.203105" id="ellipse4955" cx="6.8022504" cy="45.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4961);fill-opacity:1;stroke-width:0.203105" id="ellipse4959" cx="6.8022504" cy="58.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4965);fill-opacity:1;stroke-width:0.203105" id="ellipse4963" cx="32.80225" cy="58.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4969);fill-opacity:1;stroke-width:0.203105" id="ellipse4967" cx="58.80225" cy="58.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4973);fill-opacity:1;stroke-width:0.203105" id="ellipse4971" cx="71.802254" cy="58.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4977);fill-opacity:1;stroke-width:0.203105" id="ellipse4975" cx="84.802254" cy="58.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4981);fill-opacity:1;stroke-width:0.203105" id="ellipse4979" cx="32.80225" cy="71.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4985);fill-opacity:1;stroke-width:0.203105" id="ellipse4983" cx="58.80225" cy="71.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4989);fill-opacity:1;stroke-width:0.203105" id="ellipse4987" cx="58.80225" cy="84.802307" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4993);fill-opacity:1;stroke-width:0.203105" id="ellipse4991" cx="45.80225" cy="84.802307" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient4997);fill-opacity:1;stroke-width:0.203105" id="ellipse4995" cx="32.80225" cy="84.802307" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient931);fill-opacity:1;stroke-width:0.203105" id="ellipse929" cx="58.80225" cy="32.802002" rx="3.8381851" ry="3.8382502" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle933" cx="45.801933" cy="71.802246" r="1.755" /> <circle style="fill:#000000;stroke-width:0.0928686" id="circle935" cx="45.801933" cy="58.80225" r="1.755" /> <ellipse style="fill:url(#radialGradient943);fill-opacity:1;stroke-width:0.203105" id="ellipse937" cx="45.801933" cy="58.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient941);fill-opacity:1;stroke-width:0.203105" id="ellipse939" cx="45.801933" cy="71.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient947);fill-opacity:1;stroke-width:0.203105" id="ellipse945" cx="32.801933" cy="45.802315" rx="3.8381851" ry="3.8382502" /> <ellipse style="fill:url(#radialGradient951);fill-opacity:1;stroke-width:0.203105" id="ellipse949" cx="19.801935" cy="58.802315" rx="3.8381851" ry="3.8382502" /> </g> </svg> ## Game Instructions [Peg solitaire](https://en.wikipedia.org/wiki/Peg_solitaire) is a puzzle game which involves moving pegs on a board. Each move consists of taking a peg and "jumping" it over another peg to an empty hole two spaces away, either vertically or horizontally. The peg that was "jumped" over is then removed from the board. The goal of the game is to remove all but a single peg from the board. While the image above shows the standard "English" board, there are many different board layouts and initial peg configurations. ## Kata Task Given a board's initial state, return a list of valid moves which will leave the board with only a single peg remaining. #### The board The board will be given as a string where each line represents a row and each character represents a position on the board where * `'.'` represents an open hole * `'O'` represents a peg in a hole * `'_'` represents a non-usable space For example, the standard English board shown in the image above would be represented as: ``` __OOO__ __OOO__ OOOOOOO OOO.OOO OOOOOOO __OOO__ __OOO__ ``` Each position on the board can be identified by its number when counted starting from 1 in row-major order. For example, the standard English board would be numbered: ``` __ __ 01 02 03 __ __ __ __ 04 05 06 __ __ 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 __ __ 28 29 30 __ __ __ __ 31 32 33 __ __ ``` #### Moves Your solution should return a list of tuples, where each tuple represents a single move. The first value being the peg to be moved, the second value being where the peg should be moved to. For example, a valid first move on the standard English board could be `(5, 17)`, which would move the peg at position `5` to the hole at position `17` removing the peg at position `10` from the board. ``` __OOO__ __OOO__ __OOO__ __O.O__ OOOOOOO OOO.OOO OOO.OOO ==> OOOOOOO OOOOOOO OOOOOOO __OOO__ __OOO__ __OOO__ __OOO__ ``` ## Example Given the initial board: ``` _O. .OO O.. ``` Which would be numbered as: ``` __ 01 02 03 04 05 06 07 08 ``` A valid solution would be: `[(1, 7), (6, 8), (8, 2)]` ``` _O. _.. _.. _.O .OO ==> ..O ==> ..O ==> ... O.. OO. ..O ... ``` ## Notes * All tested boards will be solvable * Some boards may have non-usable space between two holes, you may not jump over these spaces * Tests consist of: * 10 fixed tests * 30 random tests where the board's dimensions satisfy `4 <= width, length <= 6`
algorithms
from functools import cache def solve(board): moves, board = [], board . splitlines() poss = {p: i for i, p in enumerate( ((x, y) for x, r in enumerate(board) for y, v in enumerate(r) if v != '_'), 1)} @ cache def dfs(pegs): if len(pegs) == 1: return True for (x, y), m in poss . items(): if (x, y) not in pegs: for dx, dy in ((- 1, 0), (0, - 1), (1, 0), (0, 1)): if ((x1 := x + dx), (y1 := y + dy)) in pegs and ((x2 := x + 2 * dx), (y2 := y + 2 * dy)) in pegs: moves . append((poss[x2, y2], m)) if dfs(pegs - frozenset([(x1, y1), (x2, y2)]) | frozenset([(x, y)])): return True moves . pop() return False if dfs(frozenset((x, y) for x, y in poss if board[x][y] == 'O')): return moves
Peg Solitaire
62e41d4816d2d600367aee79
[ "Game Solvers", "Games" ]
https://www.codewars.com/kata/62e41d4816d2d600367aee79
4 kyu
## Backstory The problem is based on these katas, although completing it does not require completing these ones first: https://www.codewars.com/kata/514b92a657cdc65150000006 https://www.codewars.com/kata/62e5ab2316d2d6d2a87af831 Since my previous enhancement was not big of a deal, I decided to give my friend a real challenge this time. ## The task ### The original task "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." ### The enhanced task This time it is not only about the multiples of 3 or 5. This time you will get not only the numberlimit, but also a whole array of primes. Your task is to find every number that - is below the limit, and - is a multiple of one or more primes in the array. Then (as usual) return the sum of those numbers. ## Examples If you get ```10``` as limit, and ```[ 2, 3 ]``` as primes, you should return the sum of ```2, 3, 4, 6, 8, 9```, which is ```32```. Even though 6 is a multiple of 2 and 3 as well, you should count every number only once. 10 is not in the solution, since we are looking for numbers below the limit. If you get ```10``` as limit, and ```[ 11, 13 ]``` as primes, your code should return ```0```, since there are no multiples of 11 or 13 below 10. ## Additional information - Your inputs: - a string containing a positive, whole number - an array of Integers, containing positive prime numbers - Your output: a string containing a positive, whole number (aka your solution) - You can expect the inputs to be valid, so: - the limit will contain only digits (0-9) - the array of primes will contain only primes, there will be no duplicates - although the limit can be really big, up to 30 digits - also your array can contain up to 20 different primes (this includes the possibility of an empty array as well) - I think this task is more about logic than performance, but I still recommend you to optimalize your code
games
from itertools import combinations from functools import reduce from operator import mul def find_them(number_limit, primes): res = 0 for ln in range(1, len(primes) + 1): for cmb in combinations(primes, ln): mlt, sgn = reduce(mul, cmb), (- 1) * * (ln + 1) pw = (number_limit - 1) / / mlt res += pw * (pw + 1) / / 2 * mlt * sgn return res
Multiples of some primes
62e66bea9db63bab88f4098c
[ "Mathematics", "Algorithms", "Performance" ]
https://www.codewars.com/kata/62e66bea9db63bab88f4098c
5 kyu
```0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, …``` This is the ```Van Eck's Sequence```. Let's go through it step by step. ``` Term 1: The first term is 0. Term 2: Since we haven’t seen 0 before, the second term is 0. Term 3: Since we had seen a 0 before, one step back, the third term is 1 Term 4: Since we haven’t seen a 1 before, the fourth term is 0 Term 5: Since we had seen a 0 before, two steps back, the fifth term is 2. ``` And so on... In case you missed it, the rule here is that term `n+1` is the "distance" (`n - m`) between term `n`, and the highest term `m` with the same value, where `m < n`. If there is no such `m` (ie. We haven't "seen" it before) then the term is `0`. For example: ``` ------- V | We "saw" a 0 two positions earlier, so the next term is 2 0, 0, 1, 0, 2, 0, ? ``` Your task is to find the ```n_th number``` in Van Eck's Sequence. ```(1-based)``` There are 200 random tests of range 100 to 1000. Good luck!
reference
def dist(arr): for i in range(1, len(arr)): if arr[- 1 - i] == arr[- 1]: return i return 0 def seq(n): s = [0, 0] for _ in range(n): s . append(dist(s)) return s[n - 1]
Van Eck's Sequence
62e4df54323f44005c54424c
[ "Algorithms" ]
https://www.codewars.com/kata/62e4df54323f44005c54424c
6 kyu
*Note: this kata assumes that you are familiar with basic functional programming.* In this kata, you are going to infer the type of an expression based on a given context. Your goal is to implement the `infer_type` function so that it can take in a context like: ```python """ myValue : A concat : List -> List -> List append : List -> A -> List map : (A -> B) -> (List -> List) pure : A -> List """ ``` and evaluate the type of an expression like: ```python "append (concat (pure myValue) (pure myValue)) myValue" # should be "List" ``` Each line in the context string is a type declaration that defines what type the value on the left of the `:` should be of: `<value_name> : <type>`. This syntax is similar to declarations in Haskell/Idris. In the above context, `myValue` is a value of type `A`, and `pure` is a function that takes in a value of type `A` and produces a value of type `List`. `map`, on the other hand, is a function that takes in a function from `A` to `B`, and produces a function from `List` to `List`. In this kata, the syntax for a `type` is: ``` type := [A-Z][a-zA-Z0-9]* | type -> type | '(' type ')' ``` Note that the arrow `->` in a type is right associative (due to [currying](https://en.wikipedia.org/wiki/Currying)), i.e. `A -> B -> C -> D` is equivalent to `A -> (B -> (C -> D))`. As another example, the type signature `f : A -> B -> C` actually means `f : A -> (B -> C)`, which read as "the function `f` takes in a value of type `A` and returns a function of type `B -> C`". Therefore, calling the function like `(f a) b` can be simplified to `f a b` as function application is left-associative. The syntax for an `expression` (whose type is to be evaluated by the `infer_type` method) is: ``` expression := [a-z][a-zA-Z0-9]* | expression ' ' expression | '(' expression ')' ``` (the second production rule is function application) ## Error-Handling All inputs will be in valid syntax; however, your code should __raise an error__ (throw `IllegalArgumentException` in Java language) in the following cases: - a value in the expression is not declared in the context - function application on a value (e.g. `foo param` when `foo` is not a function) - invoking a function with a value of an incorrect type (e.g. applying value of type `C` to a function of type `A -> B`) ## Notes - Functions are values!!! They can be passed as an argument to another function. - Functions can be partially applied, e.g. `A -> B -> C` applied to a value of type `A` should be of type `B -> C`. - Your code must be able to handle extra whitespaces and parentheses in both the context and the expression, e.g. `myFunc:A -> (((B) -> C))` for context, and `func (val)` for expression. - The return value of `infer_type` must not contain any unnecessary parentheses, e.g. `A -> (B -> C)` should be written as `A -> B -> C`. The return value is allowed to contain extra spaces though.
reference
import re def parse_type(s): tokens = re . findall(r'->|[()]|[A-Z][a-zA-Z0-9]*', s) def next_token(): return tokens and tokens . pop(0) or None def peek_token(): return tokens and tokens[0] or None def parse_func(): ty = parse_atom() if peek_token() == "->": next_token() ty = (ty, parse_func()) return ty def parse_atom(): match next_token(): case "(": ty = parse_func() assert next_token() == ")" return ty case ty: return ty return parse_func() def parse_context(context): res = {} for r in context . split('\n'): if ':' in r: val, s = map(str . strip, r . split(':')) res[val] = parse_type(s) return res def parse_expr(expr): tokens = re . findall(r'[()]|[a-z][a-zA-Z0-9]*', expr) def next_token(): return tokens and tokens . pop(0) or None def peek_token(): return tokens and tokens[0] or None def parse_app(): e = parse_atom() while peek_token() and peek_token() != ')': e = (e, parse_atom()) return e def parse_atom(): match next_token(): case '(': e = parse_app() assert next_token() == ')' return e case e: return e return parse_app() def infer_type(context, expression): ctx = parse_context(context) def infer(expr): match expr: case(a, b): ta, tb = map(infer, expr) match ta: case(t_arg, t_ret) if t_arg == tb: return t_ret case _: raise "Type error" case v: return ctx[v] def to_string(ty): match ty: case((a, b), c): return f'( { to_string (( a , b ))} ) -> { to_string ( c )} ' case(a, b): return f' { to_string ( a )} -> { to_string ( b )} ' case _: return ty return to_string(infer(parse_expr(expression)))
The Little Typer: Values, Functions and Currying
62975e268073fd002780cb0d
[ "Functional Programming" ]
https://www.codewars.com/kata/62975e268073fd002780cb0d
3 kyu
Define a variable `ALPHABET` that contains the *(english)* alphabet in lowercase. <br> **Too simple?** Well, you can only use the following characters set: - ` abcdefghijklmnopqrstuvwxyz().` (space included) <br> You code must starts with `ALPHABET = ` then respects the charset limitation. *Ofc you wouldn't cheat by importing the string module or using `eval`/`exec`...*
games
ALPHABET = str(). join(chr(i) for i in range(sum(range(len(str(complex))))) if chr(i). islower())
Hellphabet - Can you give the alphabet
62dcbe87f4ac96005f052962
[ "Puzzles", "Restricted", "Strings" ]
https://www.codewars.com/kata/62dcbe87f4ac96005f052962
6 kyu
## Description Given a list of strings of equal length, return any string which **minimizes** the **maximum** hamming distance between it and every string in the list. The string returned does not necessarily have to come from the list of strings. #### Hamming Distance The hamming distance is simply the amount of points in two equally large Strings that are different Example: ```if:java `hammingDistance("aooob","loppb") - > 3` ``` ```if:python `hamming_distance('aooob','loppb') - > 3` ``` as the two strings differ on position 0, 2, 3 ## Examples #### Example 1 ```if:python `closest_string(['ooi','oio','ooi']) -> 'ooo'` ``` ```if:java `closestString(["ooi","oio","ooi"]) -> "ooo"` ``` ```if:python It is important to note that `'oii'` would have also worked, but `'ooi'` would have not worked, because `'ooi'` has a hamming distance of 2 with `'oio'` which is worse than `'ooo'` hamming distance of 1 ``` ```if:java It is important to note that `"oii"` would have also worked, but `"ooi"` would have not worked, because `"ooi"` has a hamming distance of 2 with `"oio"` which is worse than `"ooo"` hamming distance of 1 ``` #### Example 2 ```if:python `closest_string(['uvwx','xuwv','xvwu']) -> 'uuwu'` ``` ```if:java `closestString(["uvwx","xuwv","xvwu"]) -> "uuwu"` ``` ```if:python It is important to note that `'xvwx'` would have also worked ``` ```if:java It is important to note that `"xvwx"` would have also worked ``` ### Author's Note feel free to use brute force
algorithms
from collections import Counter def closest_string(list_str): counters = [Counter(s[i] for s in list_str) for i in range(len(list_str[0]))] minweight = len(list_str[0]) + 1 mins = None # backtracking with prunning: def rec(s, weights): nonlocal minweight, mins if max(weights) >= minweight: return if len(s) == len(list_str[0]): mins = s minweight = max(weights) return for c in counters[len(s)]. keys(): rec(s + c, [ prevw + (c != list_str[i][len(s)]) for i, prevw in enumerate(weights) ]) rec('', [0] * len(list_str)) return mins
Closest String
6051151d86bab8001c83cc52
[ "Algorithms" ]
https://www.codewars.com/kata/6051151d86bab8001c83cc52
6 kyu
Even more meticulously, Alex keeps records of [_snooker_](https://en.wikipedia.org/wiki/Snooker) matches. Alex can see into the past or the future (magic vision or balls stuffed with all sorts of electronics?). Your task is to find out how many points the player scored in the match, having only one single record of a pocketed ball. ### Input ------ The input is an instance of the "Ball" class, which has the following attributes: color, value of the ball in points, bindings to the previous and next "Ball". Class Ball is [_dataclass_](https://docs.python.org/3/library/dataclasses.html). Dataclass is used to store data. ```python from dataclasses import dataclass from typing import Union, NewType Ball = NewType("Ball", dataclass) @dataclass class Ball: previous: Union[Ball, None] # The variable holds a reference to the previous element in the sequence. next: Union[Ball, None] # The variable holds a reference to the next element in the sequence. color: str # Вall color point: int # The value of the ball in game points def __repr__(self): return self.color ``` _previous, next, color and point_ is an instance attribute and can either be called or assigned ```python red = Ball(None, None, "Red", 1) red.point # 1 red.color # "Red" red.previous # None yellow = Ball(None, None, "Yellow", 2) red.next = yellow # set next element yellow.previous = red # set red like a previous element red # Ball(previous=None, next=yellow, color='Red', point=1) yellow # Ball(previous=red, next=None, color='Yellow', point=2) ``` ### Snooker ball value * Red - 1 point * Yellow - 2 points * Green - 3 points * Brown - 4 points * Blue - 5 points * Pink - 6 points * Black - 7 points ### Output ------ As a result, it is necessary to accumulate **the sum of all balls pocketed into the pockets**, restoring the entire sequence of balls pocketed by the player (from the first ball pocketed to the last ball pocketed). The first one does not refer to the previous "Ball". and the latter does not refer to the next potted "Ball". ### Balls in the sequence In snooker ball's color differ from shot to shot: a red ball, if potted, must be followed by a colour, a potted colour must be followed by a red, and so on until red balls ends. The alternation between red balls and colours ends when all reds have been potted and an attempt (successful or not) to pot a colour is made after the last red is potted. All six colours have then to be potted in ascending order of their value (yellow, green, brown, blue, pink, black). Each becomes the target ball in that order. During this phase, the colours are not replaced on the table after being legally potted. Sequence is [_doubly linked list_](https://en.wikipedia.org/wiki/Doubly_linked_list). A doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. ```python balls = [Red, Black, Red, Green, Red, Black, Red, Yellow, Red, Green, Red, Yellow, Red, Green, Red, Blue, Red, Blue, Red, Yellow, Red, Black, Red, Blue, Red, Green, Red, Black, Red, Yellow, Yellow, Green, Brown, Blue, Pink, Black] ``` At the input of the function, a ball is randomly selected from the sequence.
games
def score(ball: Ball) - > int: res, left, right = ball . point, ball . previous, ball . next while left: res += left . point left = left . previous while right: res += right . point right = right . next return res
Alex & snooker: Find Them All
62dc0c5df4ac96003d05152c
[ "Puzzles", "Fundamentals", "Algorithms" ]
https://www.codewars.com/kata/62dc0c5df4ac96003d05152c
6 kyu
You've sent your students home for the weekend with an assignemnt. The assignment is to write a 4 part ```harmony``` consisting of 4 chords. ---- Scale: ---- The major scale has 7 notes: ```"do re mi fa sol la ti"``` ---- Chord: ---- For this assignment a chord may consist of any 4 notes from the major scale. Example: example chord = ```'do re fa sol'``` ---- Harmony: ---- Each ```harmony``` consists of 4 chords: ```harmony = [chordOne, chordTwo, chordThree, chordFour]``` ----- Octave: ----- When two singers are singing the same note like below (```do```) the interval between them is called an octave: ``` | v v do re mi do ^ ^ ``` ---- Parallel Octave: ----- A parallel octave occurs when two singers *move* from one chord to the next staying one octave apart. For example: ``` do mi sol do v v < Parallel octave ti re fa ti ``` This ```harmony``` contains a parallel octave because the bass and soprano are both singing ```'do'``` on the first chord, and then on the second chord they both move to ```'ti'```. In other words they stay one octave apart from eacthother as they move from one chord to the next. A parallel octave does NOT occur when two singers stay one octave apart but do not *move* or change notes from one chord to the next. For example: ``` do re mi do | | < NOT a parallel octave do re mi do ``` ----- Your Task ----- You want to write a function to detect whether the harmony contains any parallel octaves. If it contains parallel octaves return "Fail" otherwise return "Pass". ----- Examples ----- ``` harmony = [ 'do re mi fa' , 'mi fa sol do' , 'fa ti fa ti' , | | < NOT a parallel octave 'fa do fa mi' , ] ``` This student should ```'Pass'``` because the bass and alto are singing octaves on the 3rd and 4th chord```'fa'``` but they do not *move*. ``` harmony = [ 'mi re mi fa' , | | < Parallel octave v v 'sol fa sol do', | | < Parallel octave v v 'fa ti fa ti' , 'fa do fa mi' , ] ``` This student should ```'Fail'``` because the bass and alto stay one octave apart on the first and second chord and they move to another note together. ```mi``` -> ```sol``` There is also another parallel octave as they move from the second to third chord. ```sol```->```fa``` ``` harmony = [ 'mi mi mi mi' , 'fa mi do re' , 'ti ti ti ti' , 'fa mi do re' , No parallel octaves ] ``` This student should ```'Pass'``` because there are no parallel octaves in this harmony.
reference
from itertools import combinations def pass_or_fail(harmony): for c1, c2 in zip(harmony, harmony[1:]): for (n1, n2), (n3, n4) in combinations(zip(c1 . split(), c2 . split()), 2): if n1 == n3 != n2 == n4: return "Fail" return "Pass"
Find Parallel Octaves
62dabb2225ea8e00293da513
[ "Algorithms" ]
https://www.codewars.com/kata/62dabb2225ea8e00293da513
7 kyu
# Number Pyramid: Image a number pyramid starts with `1`, and the numbers increasing by `1`. For example, when the pyramid has `4` levels: ``` 1 2 3 4 5 6 7 8 9 10 ``` ___ # Spiral: Now let's make a `spiral`, starts with `1`, `clockwise` direction, move `inward`. In the above example, we will get the numbers in the following sequence: ``` 1, 3, 6, 10, 9, 8, 7, 4, 2, 5 ``` And the last number of the spiral is: ``` 5 ``` ___ # Input: You will be given a number `n`, which means how many levels the pyramid has. `1 <= n <= 5000` ___ # Output: You need to return the last number of the spiral. __Examples:__ ``` last(1) --> 1 last(2) --> 2 last(3) --> 2 last(4) --> 5 last(5) --> 8 ``` ___ # Golfing Message: The length of your code should be less or equal to `45`. The length of reference solution is `39`. ___ If you like this series, welcome to do [other kata](https://www.codewars.com/collections/code-golf-number-pyramid-series) of it.
games
def last(n): return (2 * - ~ n / / 3) * * 2 + 1 >> 1
[Code Golf] Number Pyramid Series 5 - Spiral End with
62d6b4990ba2a64cf62ef0c0
[ "Mathematics", "Restricted" ]
https://www.codewars.com/kata/62d6b4990ba2a64cf62ef0c0
5 kyu
# Description Steve, from minecraft, is jumping down from blocks to blocks and can get damages at each jump. Damage depends on `distance` between blocks and `block type` he jumped on. The goal is to know if he survives his descent or not. You are given a list of `N` blocks as strings, in the format `'BLOCK_HEIGHT BLOCK_TYPE'`. Steve jumps from one block to the next, and get damages calculated with the following formula: DMG = max(0, (DISTANCE - 3.5) * (1 - DMG_REDUCTION)) The distance is calculated as the difference between the `height` of the current and the next block. DMG should be **rounded down** to the nearest integral. `DMG_REDUCTION` depends on `BLOCK_TYPE`: BLOCK_TYPE --> DMG_REDUCTION 'D' --> 0 #Dirt block 'B' --> 0.5 #Bed 'H' --> 0.8 #Hay block 'W' --> 1 #Water block ## Task Write a function, that returns the outcome for Steve: - If he survives, it returns `'jumped to the end with X remaining HP'`, where `X` is the remaining HP at the end of the array. - If he dies before the end of the array, it returns `'died on I'`, where `I` is the index of the jump he dies. ### Rules - Steve has `20 HP` at the start. If `HP` drops below or equal `0`, Steve dies. - `BLOCK_TYPE` can be `'D'` or `'B'` or `'H'` or `'W'` only. - `N` cannot be less than `2`. - `BLOCK_HEIGHT[i]` cannot be less than `BLOCK_HEIGHT[i+1]` and always non-negative integral. - All inputs are valid according to the rules. #### Examples (input --> output) ['10 D', '4 D', '0 D'] --> 'jumped to the end with 18 remaining HP' | | | | | The third block with height 0 and type D | The second block with height 4 and type D The first block with height 10 and type D /*All blocks are type D, so DMG_REDUCTION will be 0 for all cases DISTANCE on the first jump will be 10 - 4 = 6 DMG on the first jump will be max(0, (6 - 3.5) * (1 - 0)) = 2.5 -> 2 (rounding down) DISTANCE on the second jump will be 4 - 0 = 4 DMG on the second jump will be max(0, (4 - 3,5) * (1 - 0)) = 0.5 -> 0 (rounding down) So HP in the end will be 20 - 2 - 0 = 18*/ ['100 D', '50 H'] --> 'jumped to the end with 11 remaining HP' ['999 D', '0 W'] --> 'jumped to the end with 20 remaining HP' ['999 D', '0 D'] --> 'died on 1'
reference
dmg = dict(zip("DBHW", (0, 0.5, 0.8, 1))) def jumping(arr): hp = 20 for i, (p1, p2) in enumerate(zip(arr, arr[1:]), 1): (h1, _), (h2, b) = p1 . split(), p2 . split() hp -= max(0, int((int(h1) - int(h2) - 3.5) * (1 - dmg[b]))) if hp <= 0: return f"died on { i } " return f"jumped to the end with { hp } remaining HP"
Steve jumping
62d81c6361677d57d8ff86c9
[ "Fundamentals", "Algorithms" ]
https://www.codewars.com/kata/62d81c6361677d57d8ff86c9
7 kyu
<h2 style="color:#4bd4de">Foreword</h2> Most kata on Codewars require to define a function of specific name that either returns a value from given inputs or alters the input itself. The whole thing looks like this. ``` def some_func(arg1, arg2): # code... # code... # code... return # something ``` <b>Kata sensei has access to the raw string of user's code and therefore is able to do things such as:</b> • Check whether the code string contains prohibited substrings • Examine the length of the code • Apply basically any rules to user's input code </p> <h2 style="color:#4bd4de">The task</h2> <b>Implement a function `change_list(arr)` that takes a list as an argument and mutates its elements in such way:</b> • If the element is an integer, square it • If the element is a string, append its reversed copy to its end like that `"string"` becomes `"stringgnirts"` • If the element is a bool, simply reverse it. `True` becomes `False` and `False` becomes `True` • Reverse the list </p> <h2 style="color:#4bd4de">Rules/restrictions</h2> Here comes the fun part. A string, composed of every other symbol of your very input — `your_code[::2]`, when executed as Python code, should also do everything stated above. Define a function `change_list` that mutates its input by the stated rules. For your awareness, that is what `code[::2]` of a snippet used in the <b>Foreword</b> paragraph looks like: ``` dfsm_ucag,ag) oe. oe. oe. eun oehn ``` God knows how many reasons to cause an error upon execution it has... </p> <h2 style="color:#62d941">Notes</h2> • There are 100 random tests on short arrays with less than 50 elements. • You will see how `your_code[::2]` looks like in every test.
games
# d e f c h a n g e _ l i s t ( x ) : # f o r i , v i n e n u m e r a t e ( x [ : : - 1 ] ) : # i f i s i n s t a n c e ( v , b o o l ) : # x [ i ] = n o t v # e l i f i s i n s t a n c e ( v , s t r ) : # x [ i ] = v + v [ : : - 1 ] # e l s e : # x [ i ] = v * * 2 # ' ' ' def change_list(x): for i, v in enumerate(x[:: - 1]): if isinstance(v, bool): x[i] = not v elif isinstance(v, str): x[i] = v + v[:: - 1] else: x[i] = v * * 2 # ' ' '
Leapfrog Code
62d6d9e90ba2a6b6942ee6e5
[ "Restricted" ]
https://www.codewars.com/kata/62d6d9e90ba2a6b6942ee6e5
6 kyu
# Number Pyramid: Image a number pyramid starts with `1`, and the numbers increasing by `1`. And now, the pyramid has `5000` levels. For example, the top `5` levels of the pyramid are: ``` 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 ... ``` ___ # Location: Define the `location` of a number as a 2-elements `tuple(x, y)` where: * `x` is the index of the level (start from the __top__) which contains the number; * `y` is the index of the number (start from the __left__) in the level. _Both 1-base index._ For example, the `location` of `5` is: ``` (3, 2) ``` ___ # Task: You will be given a number `n`, it will not go beyond 5000 levels. You need to return the `location` of the number `n`. __Examples:__ ``` location(1) --> (1, 1) location(2) --> (2, 1) location(3) --> (2, 2) location(4) --> (3, 1) location(5) --> (3, 2) location(6) --> (3, 3) ``` ___ # Golfing Message: The length of your code should be less or equal to `57`. The length of reference solution is `51`. ___ If you like this series, welcome to do [other kata](https://www.codewars.com/collections/code-golf-number-pyramid-series) of it.
games
def location(c, r=1): while c > r: c -= r r += 1 return r, c
[Code Golf] Number Pyramid Series 4 - Location
62d1d6389e2b3904b3825309
[ "Mathematics", "Restricted" ]
https://www.codewars.com/kata/62d1d6389e2b3904b3825309
6 kyu