problem_id
stringlengths 32
32
| name
stringclasses 1
value | problem
stringlengths 200
14k
| solutions
stringlengths 12
1.12M
| test_cases
stringlengths 37
74M
| difficulty
stringclasses 3
values | language
stringclasses 1
value | source
stringclasses 7
values | num_solutions
int64 12
1.12M
| starter_code
stringlengths 0
956
|
---|---|---|---|---|---|---|---|---|---|
a2bb88c9ce3441c5b281eb80ac02b0f4 | UNKNOWN | On Unix system type files can be identified with the ls -l command which displays the type of the file in the first alphabetic letter of the file system permissions field. You can find more information about file type on Unix system on the [wikipedia page](https://en.wikipedia.org/wiki/Unix_file_types).
- '-' A regular file ==> `file`.
- 'd' A directory ==> `directory`.
- 'l' A symbolic link ==> `symlink`.
- 'c' A character special file. It refers to a device that handles data as a stream of bytes (e.g: a terminal/modem) ==> `character_file`.
- 'b' A block special file. It refers to a device that handles data in blocks (e.g: such as a hard drive or CD-ROM drive) ==> `block_file`.
- 'p' a named pipe ==> `pipe`.
- 's' a socket ==> `socket`.
- 'D' a door ==> `door`.
In this kata you should complete a function that return the `filetype` as a string regarding the `file_attribute` given by the `ls -l` command.
For example if the function receive `-rwxr-xr-x` it should return `file`. | ["dict = {'-':\"file\",'d':\"directory\",'l':\"symlink\",'c':\"character_file\",'b':\"block_file\",'p':\"pipe\",'s':\"socket\",'D':\"door\"}\ndef linux_type(file_attribute):\n return dict[file_attribute[0]]", "def linux_type(s):\n return {x: y for x, y in zip(\"-dlcbpsD\", \"file directory symlink character_file block_file pipe socket door\".split(\" \"))}[s[0]]", "D = {'p':\"pipe\", '-':\"file\", 'd':\"directory\", 'l':\"symlink\",\n 'c':\"character_file\", 'b':\"block_file\", 's':\"socket\", 'D':\"door\"}\n\ndef linux_type(file_attribute):\n return D[file_attribute[0]]", "def linux_type(file_attribute):\n flags = {\n '-': 'file',\n 'd': 'directory',\n 'l': 'symlink',\n 'c': 'character_file',\n 'b': 'block_file',\n 'p': 'pipe',\n 's': 'socket',\n 'D': 'door'\n } \n return flags[file_attribute[0]]", "def linux_type(file_attribute):\n switch = {\n '-': 'file',\n 'd': 'directory',\n 'l': 'symlink',\n 'c': 'character_file',\n 'b': 'block_file',\n 'p': 'pipe',\n 's': 'socket',\n 'D': 'door',\n }\n return switch[file_attribute[0]]", "d = dict(__import__(\"re\").findall(r\"'(.)'.*\\s([a-z_]+)\\.\",\n \"\"\"\n '-' A regular file ==> file.\n 'd' A directory ==> directory.\n 'l' A symbolic link ==> symlink.\n 'c' A character special file. It refers to a device that handles data as a stream of bytes (e.g: a terminal/modem) ==> character_file.\n 'b' A block special file. It refers to a device that handles data in blocks (e.g: such as a hard drive or CD-ROM drive) ==> block_file.\n 'p' a named pipe ==> pipe.\n 's' a socket ==> socket.\n 'D' a door ==> door.\n \"\"\"))\n\nlinux_type = lambda s: d[s[0]]", "def linux_type(f): #\n return {'-':'file','d':'directory','l':'symlink','c':'character_file','b':'block_file','p':'pipe','s':'socket','D':'door'}[f[0]]\n", "def linux_type(f):\n return {'-':'file','d':'directory','l':'symlink','c':'character_file','b':'block_file','p':'pipe','s':'socket','D':'door'}.get(f[0])\n", "def linux_type(f):\n return {\"-\":\"file\",\"d\":\"directory\",\"l\":\"symlink\",\"c\":\"character_file\",\"b\":\"block_file\",\"p\":\"pipe\",\"s\":\"socket\",\"D\":\"door\"}[f[0]]", "import re\ndef linux_type(file_attribute):\n types={\"-\": \"file\",\n \"d\": \"directory\",\n \"l\": \"symlink\",\n \"c\": 'character_file',\n \"b\": 'block_file',\n \"p\": \"pipe\",\n \"s\": \"socket\",\n \"D\": \"door\" \n }\n return types[file_attribute[0]]", "linux_type=lambda f:{'-':'file','d':'directory','l':'symlink', 'c':'character_file', 'b': 'block_file', 'p':'pipe', 's':'socket', 'D':'door'}[f[0]]", "def linux_type(file_attribute):\n return {\n 'd': 'directory',\n 'l': 'symlink',\n 'c': 'character_file',\n 'b': 'block_file',\n 'p': 'pipe',\n 's': 'socket',\n 'D': 'door'\n }.get(file_attribute[0],'file')", "def linux_type(file_attribute):\n types = {'-': 'file',\n 'd': 'directory',\n 'l': 'symlink',\n 'c': 'character_file',\n 'b': 'block_file',\n 'p': 'pipe',\n 's': 'socket',\n 'D': 'door'}\n if not file_attribute:\n return None\n ty = file_attribute[0]\n if ty in types:\n return types[ty]\n else:\n return None", "def linux_type(fa):\n d = {'-':'file',\n 'd':'directory',\n 'l':'symlink',\n 'c': 'character_file',\n 'b':'block_file',\n 'p':'pipe',\n 's':'socket',\n 'D':'door'\n }\n return d.get(fa[0])", "ATTRIBUTES = {\n \"-\": \"file\",\n \"d\": \"directory\",\n \"l\": \"symlink\",\n \"c\": \"character_file\",\n \"b\": \"block_file\",\n \"p\": \"pipe\",\n \"s\": \"socket\",\n \"D\": \"door\",\n}\n\ndef linux_type(file_attribute):\n return ATTRIBUTES[file_attribute[0]]", "files_types = { '-' : 'file',\n 'd' : 'directory',\n 'l' : 'symlink',\n 'c' : 'character_file',\n 'b' : 'block_file',\n 'p' : 'pipe',\n 's' : 'socket',\n 'D' : 'door' }\n \ndef linux_type(file_attribute):\n return files_types[file_attribute[0]]\n", "D = {'-': 'file', 'd': 'directory', 'l': 'symlink',\n 'c': 'character_file', 'b': 'block_file', 'p': 'pipe',\n 's': 'socket', 'D': 'door'}\n\ndef linux_type(s):\n return D[s[0]]", "def linux_type(file_attribute):\n f_att = file_attribute[0]\n if f_att == '-':\n return \"file\"\n elif f_att == 'd':\n return \"directory\"\n elif f_att == 'l':\n return \"symlink\"\n elif f_att == 'c':\n return \"character_file\"\n elif f_att == 'b':\n return \"block_file\"\n elif f_att == 'p':\n return \"pipe\"\n elif f_att == 's':\n return \"socket\"\n elif f_att == 'D':\n return \"door\"\n return None", "def linux_type(file):\n dict = {'-': 'file',\n 'd': 'directory',\n 'l': 'symlink',\n 'c': 'character_file',\n 'b': 'block_file',\n 'p': 'pipe',\n 's': 'socket',\n 'D': 'door'}\n return dict.get(file[0])", "def linux_type(file_attribute):\n Unix_system_type = [['-', 'file'],\n ['d', 'directory'],\n ['l', 'symlink'],\n ['c', 'character_file'],\n ['b', 'block_file'],\n ['p', 'pipe'],\n ['s', 'socket'],\n ['D', 'door']]\n i = 0\n while i < len(Unix_system_type):\n if file_attribute[0] == Unix_system_type[i][0]:\n return Unix_system_type[i][1]\n i += 1"] | {"fn_name": "linux_type", "inputs": [["-rwxrwxrwx"], ["Drwxr-xr-x"], ["lrwxrw-rw-"], ["srwxrwxrwx"]], "outputs": [["file"], ["door"], ["symlink"], ["socket"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 5,962 |
def linux_type(file_attribute):
|
4f4df72054b7a117397404bcef5f9a17 | UNKNOWN | Given two arrays of integers `m` and `n`, test if they contain *at least* one identical element. Return `true` if they do; `false` if not.
Your code must handle any value within the range of a 32-bit integer, and must be capable of handling either array being empty (which is a `false` result, as there are no duplicated elements). | ["def duplicate_elements(m, n):\n return not set(m).isdisjoint(n)", "def duplicate_elements(m, n):\n return any(x in n for x in m)", "def duplicate_elements(m, n):\n return bool(set(m) & set(n))", "def duplicate_elements(m, n):\n return bool(set(m).intersection(n))", "def duplicate_elements(m, n):\n return True if [x for x in m if x in n] else False", "def duplicate_elements(m, n):\n return any(map(set(n).__contains__, m))", "def duplicate_elements(m, n):\n return any(i in m for i in n)", "def duplicate_elements(m, n):\n return len(m + n) != len(set(m + n))", "duplicate_elements=lambda a,b:bool(set(a)&set(b))", "def duplicate_elements(m, n):\n for element in m:\n try:\n n.index(element)\n return True\n except:\n continue\n return False"] | {"fn_name": "duplicate_elements", "inputs": [[[1, 2, 3, 4, 5], [1, 6, 7, 8, 9]], [[9, 8, 7], [8, 1, 3]], [[2398632, 9172846, 4728162], [2398632, 9235623, 8235492]], [[-2, -4, -6, -8], [-2, -3, -5, -7]], [[-9, -8, -7], [-8, -1, -3]], [[-2398632, -9172846, -4728162], [-2398632, -9235623, -8235492]], [[1, 3, 5, 7, 9], [2, 4, 6, 8]], [[9, 8, 7], [6, 5, 4]], [[], [9, 8, 7, 6, 5]], [[9, 8, 7, 6, 5], []], [[], []]], "outputs": [[true], [true], [true], [true], [true], [true], [false], [false], [false], [false], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 824 |
def duplicate_elements(m, n):
|
37d0344c1a53be0db9efd3f5750646d2 | UNKNOWN | The prime numbers are not regularly spaced. For example from `2` to `3` the step is `1`.
From `3` to `5` the step is `2`. From `7` to `11` it is `4`.
Between 2 and 50 we have the following pairs of 2-steps primes:
`3, 5 - 5, 7, - 11, 13, - 17, 19, - 29, 31, - 41, 43`
We will write a function `step` with parameters:
- `g` (integer >= 2) which indicates the step we are looking for,
- `m` (integer >= 2) which gives the start of the search (m inclusive),
- `n` (integer >= m) which gives the end of the search (n inclusive)
In the example above `step(2, 2, 50)` will return `[3, 5]` which is the first pair between 2 and 50 with a 2-steps.
So this function should return the **first** pair of the two prime numbers spaced with a step of `g`
between the limits `m`, `n` if these g-steps prime numbers exist otherwise `nil` or `null` or `None` or `Nothing` or `[]` or `"0, 0"` or `{0, 0}` or `0 0`(depending on the language).
#Examples:
-
`step(2, 5, 7) --> [5, 7] or (5, 7) or {5, 7} or "5 7"`
`step(2, 5, 5) --> nil or ... or [] in Ocaml or {0, 0} in C++`
`step(4, 130, 200) --> [163, 167] or (163, 167) or {163, 167}`
- **See more examples for your language in "RUN"**
- Remarks:
([193, 197] is also such a 4-steps primes between 130 and 200 but it's not the first pair).
`step(6, 100, 110) --> [101, 107]` though there is a prime between 101 and 107 which is 103; the pair 101-103 is a 2-step.
#Notes:
The idea of "step" is close to that of "gap" but it is not exactly the same. For those interested they can have a look
at .
A "gap" is more restrictive: there must be no primes in between
(101-107 is a "step" but not a "gap". Next kata will be about "gaps":-).
For Go: nil slice is expected when there are no `step` between m and n.
Example: step(2,4900,4919) --> nil | ["import math\ndef isPrime(n):\n if n <= 1:\n return False\n for i in range(2,int(math.sqrt(n)+1)):\n if n % i == 0:\n return False\n return True\n\ndef step(g,m,n):\n if m >= n:\n return []\n else:\n for i in range(m,n+1-g):\n if isPrime(i) and isPrime(i+g):\n return[i,i+g]\n", "def prime (number):\n if number < 2: return False\n elif number == 2: return True\n elif number % 2 == 0: return False\n for i in range(3, int(number ** 0.5) + 1, 2):\n if number % i == 0: return False\n return True\n \ndef step(g, m, n):\n res = []\n i = m\n while (i <= n - g):\n if prime(i) and prime(i + g):\n res.append(i)\n res.append(i + g)\n return res\n i += 1\n return None", "def is_prime(n):\n for i in range(2,int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n \ndef step(g, m, n):\n for i in range(m, n - g):\n if is_prime(i) and is_prime(i + g):\n return [i,i+g]\n return None", "step=lambda g,m,n,A=lambda x:all(x%i for i in range(2,int(x**.5)+1)):next(([i,i+g]for i in range(m,n+1)if A(i)and i+g < n and A(i+g)),None)", "import math\ndef step(g, m, n):\n\n def prime(n):\n if n >= 2:\n for i in range(2, int(math.sqrt(n)) + 1):\n if not (n % i):\n return False\n else:\n return False\n return True\n\n for i in range(m,n-g):\n if prime(i + g) and prime(i):\n return [i, i + g]", "def step(g, m, n):\n return next(([a, a+g] for a in range(m, n-g+1) if is_prime(a) and is_prime(a+g)), None)\n\n\ndef is_prime(n):\n factors = 0\n for k in (2, 3):\n while n % k == 0 and factors < 2:\n n //= k\n factors += 1\n k = 5\n step = 2\n while k * k <= n and factors < 2:\n if n % k:\n k += step\n step = 6 - step\n else:\n n //= k\n factors += 1\n if n > 1:\n factors += 1\n return factors == 1\n", "def step(g, m, n):\n def is_prime(n):\n if n==2:\n return True\n elif n<2 or n%2==0:\n return False\n else:\n import math\n root = math.floor(math.sqrt(n))\n trial_factor = 3\n while trial_factor<= root:\n if n%trial_factor==0:\n return False\n trial_factor+=2\n return True\n dic = {}\n current_prime = None\n for i in range(m, n+1):\n if is_prime(i):\n current_prime = i\n if current_prime - g in dic:\n return [current_prime-g, current_prime]\n else:\n dic[current_prime] = True\n \n \n return None\n \n \n \n # your code\n", "def prime(n):\n for i in range(2, 1000):\n if i != n and n % i == 0:\n return False\n return True\n \ndef step(g, m, n):\n for num in range(m, n+1):\n if prime(num) and prime(num+g) and num+g<=n:\n return [num, num + g]\n return None\n", "import itertools\ncompress = itertools.compress \ndef sieve(n): \n r = [False,True] * (n//2) +[True]\n r[1],r[2] = False,True \n for i in range(3,int(n**.5)+1): \n if r[i]: \n r[i*i::2*i] = [False] * ((n+2*i-1-i*i)//(2*i))\n r = list(compress(range(len(r)),r))\n if r[-1] % 2 == 0:\n return r[:-1]\n return r\nprimes = set(sieve(2*10**7))\nmaxi = max(primes) \ndef step(g, m, n):\n for i in range(m,n+1): \n if i > maxi or i+g > n:\n break \n if i in primes and i+g in primes:\n return [i,i+g]\n return None "] | {"fn_name": "step", "inputs": [[2, 100, 110], [4, 100, 110], [6, 100, 110], [8, 300, 400], [10, 300, 400], [4, 30000, 100000], [6, 30000, 100000], [8, 30000, 100000], [11, 30000, 100000], [16, 5, 20], [2, 10000000, 11000000], [52, 1300, 15000], [10, 4900, 5000], [30, 4900, 5000], [2, 4900, 5000], [2, 104000, 105000], [2, 4900, 4919], [7, 4900, 4919], [4, 30115, 100000], [4, 30140, 100000], [4, 30000, 30325]], "outputs": [[[101, 103]], [[103, 107]], [[101, 107]], [[359, 367]], [[307, 317]], [[30109, 30113]], [[30091, 30097]], [[30089, 30097]], [null], [null], [[10000139, 10000141]], [[1321, 1373]], [[4909, 4919]], [[4903, 4933]], [[4931, 4933]], [[104087, 104089]], [null], [null], [[30133, 30137]], [[30319, 30323]], [[30109, 30113]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,860 |
def step(g, m, n):
|
c33207c497823d3d346b4b986163373e | UNKNOWN | Given some points (cartesian coordinates), return true if all of them lie on a line. Treat both an empty set and a single point as a line.
```python
on_line(((1,2), (7,4), (22,9)) == True
on_line(((1,2), (-3,-14), (22,9))) == False
``` | ["def on_line(points):\n points = list(set(points))\n cross_product = lambda a, b, c: a[0]*(b[1]-c[1]) + b[0]*(c[1]-a[1]) + c[0]*(a[1]-b[1])\n return all(cross_product(p, *points[:2]) == 0 for p in points[2:])", "from functools import partial\n\ndef collinear(p1, p2, p3):\n return (p3[1] - p2[1])*(p2[0] - p1[0]) == (p2[1] - p1[1])*(p3[0] - p2[0])\n\ndef on_line(points):\n points = list(set(points))\n return all(map(partial(collinear, *points[:2]), points[2:]))", "def on_line(li):\n try:\n li = list(set(li))\n x1,y1 = li.pop()\n return li[0] and len(set([(y2-y1)/(x2-x1) for x2,y2 in li]))==1\n except : return len(li)<2 or len({i[0] for i in li})==1", "from fractions import Fraction\n\ndef on_line(ps):\n ps = list(set(ps))\n if ps and all(isinstance(x, int) for x in ps):\n return True\n return len({\n (x1 if x1 == x2 else Fraction(y2-y1, x2-x1))\n for (x1,y1), (x2,y2) in zip(ps, ps[1:])\n }) <= 1", "import numpy as np\n\ndef determinant(a):\n return round(np.linalg.det(np.matrix(a)))\n\nf = lambda x: x + [1]\n\ndef on_line(points =None):\n if points == None: return True\n if len(points) <= 2: return True\n points = map(list,list(points))\n for i in range(len(points)-2):\n matrix = [points[i], points[i+1], points[i+2]]\n matrix = map(f,matrix)\n if determinant(matrix) != 0:return False\n return True", "def on_line(p):\n p = list(set(p))\n if len(p) <= 2: return True\n (x0, y0), (x1, y1) = p[:2]\n return all((x - x0) * (y1 - y0) == (x1 - x0) * (y - y0) for x, y in p[2:])\n", "from fractions import Fraction\ndef on_line(points):\n return len(set(Fraction(a[1]-b[1],a[0]-b[0]) if a[0]!=b[0] else \"Invalid\" for a,b in zip(points,points[1:]) if a!=b))<2", "def on_line(points):\n \n def slope_intercept(p1, p2):\n slope = (p2[1] - p1[1]) / (p2[0] - p1[0])\n intercept = p1[1] - slope * p1[0]\n return slope, intercept\n \n if len(points) == 0 or isinstance(points[0], int):\n return True\n \n for p1, p2 in zip(points, points[1:]):\n if p1[0] == p2[0] or p1[1] == p2[1]:\n continue\n else:\n s, i = slope_intercept(p1, p2)\n try:\n if abs(s - slope) > 0.00000001 or abs(i - intercept) > 0.000001:\n return False\n except:\n pass\n slope, intercept = s, i\n return True", "def on_line(points):\n try:\n x1, y1 = points[0]\n x2, y2 = points[-1]\n except:\n return True\n for i in points[1:-1]:\n x3, y3 = i\n if (x1 - x3)*(y2 - y3) != (x2 - x3)*(y1 - y3):\n return False\n return True", "def on_line(points):\n y = 1\n x = 0\n if len(points) <= 2:\n return True\n all_x = points[0][x]\n all_y = points[0][y]\n test = True\n for point in points[1:]:\n if point[x] != all_x:\n test = False\n break\n if test:\n return True\n for point in points[1:]:\n if point[y] != all_y:\n test = False\n break\n if test:\n return True\n if (points[1][x] - points[0][x]) != 0:\n a = (points[1][y] - points[0][y]) / (points[1][x] - points[0][x])\n else:\n a = 0\n b = points[0][y] - a * points[0][x]\n for point in points[2:]:\n if point[y] != a * point[x] + b:\n return False\n return True\n \n"] | {"fn_name": "on_line", "inputs": [[[]], [[1, 1]]], "outputs": [[true], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,514 |
def on_line(points):
|
065b50a10e67735707540743f07769a5 | UNKNOWN | ## Description
Your job is to create a simple password validation function, as seen on many websites.
The rules for a valid password are as follows:
- There needs to be at least 1 uppercase letter.
- There needs to be at least 1 lowercase letter.
- There needs to be at least 1 number.
- The password needs to be at least 8 characters long.
You are permitted to use any methods to validate the password.
## Examples:
### Extra info
- You will only be passed strings.
- The string can contain any standard keyboard character.
- Accepted strings can be any length, as long as they are 8 characters or more. | ["CRITERIA = (str.islower, str.isupper, str.isdigit)\n\ndef password(s):\n return len(s)>7 and all( any(map(f,s)) for f in CRITERIA)", "import re\n\ndef password(s):\n return bool(re.match(r'(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).{8}', s))", "import re \n\ndef password(string):\n patterns = (r'[A-Z]', r'[a-z]', r'[0-9]', r'.{8,}')\n return all([re.search(pattern, string) for pattern in patterns])", "def password(candidate):\n \"\"\"Returns True if 'candidate' password possesses arbitrary properties that do more than\n good for security of the users' accounts. It is probably accompanied by a password \n field in which paste is disabled. Notice that a maximum character length is not specified.\n This is so we can silently truncate the users' passwords before hashing and storing\n them so that when they attempt to log in later, they have to guess how many characters\n we truncated. We might also do this differently on different clients so the same password\n works in some instances and fails in others. We will also impliment all this client side, \n so the validation is easily defeated by anyone willing to monkey with our client-side script.\n Then we will add 'security questions' based on publicly available information, allowing\n anyone to sidestep authentication with a basic search.\n \n Otherwise, False.\n \"\"\"\n \n if not len(candidate) >= 8:\n return False\n if not any(char.islower() for char in candidate):\n return False\n if not any(char.isupper() for char in candidate):\n return False\n if not any(char.isdigit() for char in candidate):\n return False\n return True ", "def password(string):\n if len(string) >= 8:\n check = 0\n for c in string:\n if c.isupper(): check |= 1\n elif c.islower(): check |= 2\n elif c.isdigit(): check |= 4\n if check == 7: return True\n return False", "def password(s):\n return any(c.isupper() for c in s) and \\\n any(c.islower() for c in s) and \\\n any(c.isdigit() for c in s) and \\\n len(s)>7", "import re\ndef password(string):\n \n return bool(re.match(\"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,}$\",string))", "def lenfilt(func, seq):\n return len(list(filter(func, seq)))\n\ndef assrt(seq):\n funcs = [str.isupper, str.islower, str.isdigit, str]\n nums = [0, 0, 0, 7]\n return [lenfilt(i, seq) > j for i, j in zip(funcs, nums)]\n\ndef password(string):\n return all(assrt(string))", "def password(string):\n #your code here\n k1 = k2 = k3 = 0\n if len(string) < 8:\n return False\n \n for i in string:\n if i.islower():\n k1 = 1\n for i in string:\n if i.isupper():\n k2 = 1\n for i in string:\n if i.isdigit():\n k3 = 1\n if k1 == k2 == k3 == 1:\n return True\n else:\n return False", "def password(string):\n rules = [lambda s: any(x.isupper() for x in s),\n lambda s: any(x.islower() for x in s), \n lambda s: any(x.isdigit() for x in s),\n lambda s: len(s) >= 8\n ]\n \n if all(rule(string) for rule in rules):\n return True\n else:\n return False"] | {"fn_name": "password", "inputs": [["Abcd1234"], ["Abcd123"], ["abcd1234"], ["AbcdefGhijKlmnopQRsTuvwxyZ1234567890"], ["ABCD1234"], ["Ab1!@#$%^&*()-_+={}[]|\\:;?/>.<,"], ["!@#$%^&*()-_+={}[]|\\:;?/>.<,"], [""], [" aA1----"], ["4aA1----"]], "outputs": [[true], [false], [false], [true], [false], [true], [false], [false], [true], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,330 |
def password(string):
|
281411e0638063ba7021f3f1703c4859 | UNKNOWN | Deoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T').
Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA its chemical structure and contains no Thymine. In RNA Thymine is replaced by another nucleic acid Uracil ('U').
Create a function which translates a given DNA string into RNA.
For example:
```
"GCAT" => "GCAU"
```
The input string can be of arbitrary length - in particular, it may be empty. All input is guaranteed to be valid, i.e. each input string will only ever consist of `'G'`, `'C'`, `'A'` and/or `'T'`. | ["def dna_to_rna(dna):\n return dna.replace(\"T\", \"U\")", "dna_to_rna = lambda s: s.replace('T', 'U')", "def dna_to_rna(dna):\n rna = []\n for x in dna:\n if x == 'T':\n rna.append('U')\n else:\n rna.append(x)\n return ''.join(rna)\n", "dna_to_rna = lambda dna:dna.translate(str.maketrans(\"GCAT\",\"GCAU\"))", "def dna_to_rna(mot):\n \n new_mot = [lettre.replace('T','U') for lettre in mot]\n return \"\".join(new_mot)", "def dna_to_rna(dna):\n res = ''\n for i in dna:\n if i == \"T\":\n res += 'U'\n else:\n res += i\n return res", "def dna_to_rna(dna):\n total = \"\"\n for i in dna:\n if i == \"T\":\n total += \"U\"\n else: \n total += i\n return total", "def dna_to_rna(dna):\n res = \"\"\n for let in dna:\n if let == \"T\":\n res += \"U\"\n else:\n res += let\n return res", "def dna_to_rna(deoxyribonucleic_acid):\n return ''.join(str([nucleic_acid_base if ord(nucleic_acid_base) is not eval(\"1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1\") else chr(ord(nucleic_acid_base)+1) for nucleic_acid_base in deoxyribonucleic_acid]).replace('\"\"','').replace(',','').replace('[','').replace(']','').replace(\"'\", '').split(' '))\n", "def dna_to_rna(dna):\n rna_line = []\n dna_str = dna.upper()\n \n for a in dna_str:\n if a == \"T\":\n rna_line.append(\"U\")\n else:\n rna_line.append(a)\n \n result = \"\".join(rna_line)\n return result", "def dna_to_rna(dna):\n rna = dna.replace('T','U')\n return rna\n\n\nprint(dna_to_rna('GCAT'))", "def dna_to_rna(dna):\n dna_bases = []\n for item in dna:\n dna_bases.append(str(item))\n rna_lst = []\n for item in dna_bases:\n if item == 'A' or item == 'C' or item == 'G':\n rna_lst.append(item)\n elif item == 'T':\n rna_lst.append('U')\n else:\n print(\"This is no dna structure\") \n break\n rna = ''.join(rna_lst)\n return rna\n \n\n\n\n\n", "def dna_to_rna(dna):\n rna = []\n for base in dna:\n if base == \"T\":\n rna.append(\"U\")\n else:\n rna.append(base)\n return \"\".join(rna)", "def dna_to_rna(dna):\n if \"T\" not in dna:\n return dna\n else:\n rna = dna.replace(\"T\", \"U\")\n return rna\n return", "def dna_to_rna(dna):\n result = []\n for x in dna:\n if x == 'T':\n result.append('U')\n else:\n result.append(x)\n return ''.join(result)", "def dna_to_rna(dna):\n results=[]\n for x in dna:\n if x == \"T\":\n results.append(\"U\")\n else:\n results.append(x)\n return ''.join(results)", "def dna_to_rna(dna):\n rna = ''\n for base in dna:\n if base != 'T':\n rna += base\n else:\n rna += 'U'\n return rna", "def dna_to_rna(dna):\n rna = []\n if 'T' in dna:\n dna = dna.replace('T', 'U')\n return dna", "def dna_to_rna(dna):\n res = \"\"\n if(len(dna) == 0):\n return res\n else:\n for item in dna:\n if(item == \"T\"):\n res += \"U\"\n else:\n res += item\n return res", "dnatab = \"T\"\nrnatab = \"U\"\n\n\ndef dna_to_rna(dna):\n return dna.translate(dna.maketrans(dnatab, rnatab))", "def dna_to_rna(dna):\n output=''\n for i in dna:\n if(i=='T'):\n output+='U'\n else:\n output+=i\n return output", "def dna_to_rna(dna):\n newstr = dna.replace('T', 'U')\n return newstr", "def dna_to_rna(dna):\n rna = ''\n for base in dna:\n if base == 'T':\n rna += 'U'\n else:\n rna += base\n return rna", "def dna_to_rna(dna):\n result = []\n for i in dna:\n if i == \"T\":\n result.append(\"U\")\n else:\n result.append(i)\n return ''.join(result)", "def dna_to_rna(dna):\n RNA = \"\"\n for letter in dna:\n if letter == \"T\":\n RNA += \"U\"\n else:\n RNA += letter\n return RNA\n", "def dna_to_rna(dna):\n for t in dna:\n if t == 'T':\n dna = dna.replace('T', 'U')\n return dna", "def dna_to_rna(dna):\n #if dna=\"\":\n # print('No entry value!')\n \n dna = dna.upper()\n \n if 'T' in dna:\n dnaList=list(dna)\n while 'T' in dnaList:\n dnaList[dnaList.index('T')]='U'\n rna=''.join(dnaList)\n else: rna = dna\n \n return rna\n", "def dna_to_rna(dna):\n if \"T\" in dna:\n return dna.replace(\"T\", \"U\")\n else:\n return dna\n \n \n \n \n \n\n#DNA is composed by G + C + A + T\n#RNA is combosed by G + C + A + U\n", "def dna_to_rna(dna):\n return ''.join([\"U\" if x == \"T\" else x for x in dna])", "def dna_to_rna(dna):\n rna = dna.replace(\"T\", \"U\") #use replace instead of looping it\n return rna", "def dna_to_rna(dna):\n rna = dna.replace('T','U') # Replacing the character 'T' by 'U'\n \n return rna", "def dna_to_rna(dna):\n rna = \"\"\n for i in dna:\n if i == \"T\":\n rna = rna + \"U\"\n else:\n rna = rna + i\n return rna", "def dna_to_rna(dna):\n y=\"\"\n i=0\n while i<len(dna):\n if dna[i]==\"T\":\n y=y+\"U\"\n i=i+1\n else:\n y=y+dna[i]\n i=i+1\n return y", "def dna_to_rna(dna):\n new = ''\n for i in range(len(dna)):\n if dna[i]=='T':\n new+= 'U'\n else:\n new+= dna[i]\n return new\n", "def dna_to_rna(dna):\n result = ''\n for i in dna:\n if i == \"T\" or \"\":\n i = \"U\"\n result += i\n return result\nprint(dna_to_rna(\"GCAT\"))", "import string\n\ndef dna_to_rna(dna):\n return dna.translate(str.maketrans('GCAT', 'GCAU'))", "def dna_to_rna(dna):\n \n rna = \"\"\n \n for ch in dna:\n if ch ==\"T\":\n rna += \"U\"\n else:\n rna += ch\n \n return rna", "def dna_to_rna(dna):\n \n rna = \"\"\n \n for x in dna:\n if x == \"T\":\n rna += \"U\"\n \n else: rna += x\n \n return rna", "def dna_to_rna(dna):\n s=\"\"\n for i in dna:\n if(i==\"T\"):\n i=\"U\"\n s=s+i\n else:\n s=s+i\n return s", "def dna_to_rna(dna):\n answer = \"\"\n for letter in dna:\n if letter == \"T\":\n answer += \"U\"\n else:\n answer += letter\n return answer", "def dna_to_rna(dna):\n j = \"\"\n for i in dna:\n if i==\"T\":\n j += \"U\"\n else:\n j += i\n return j", "def dna_to_rna(dna):\n for T in dna:\n dna = dna.replace(\"T\",\"U\")\n return dna", "def dna_to_rna(dna):\n rna = \"\"\n for letter in dna:\n if letter == \"T\":\n rna += \"U\"\n else:\n rna += letter\n return rna", "def dna_to_rna(dna):\n for i in range(len(dna)):\n if dna[i]=='T':\n dna=dna[:i]+'U'+dna[i+1:]\n return dna", "def dna_to_rna(dna):\n result = \"\"\n for i in dna:\n if i == \"T\":\n result +='U'\n else:\n result+=i\n return result\n", "def dna_to_rna(dna):\n rna = ''\n for base in dna:\n if base == 'T':\n rna = rna + 'U'\n elif base == 'G' or 'C' or 'A':\n rna = rna + base\n else:\n print(f\"{base} is not a DNA nucleotide base\")\n return rna", "import pandas as pd\ndef dna_to_rna(dna):\n return dna.replace('T','U')", "def dna_to_rna(dna):\n import re\n return re.sub(r\"T\",\"U\",dna)", "def dna_to_rna(dna):\n output=[]\n answer=''\n for i in range(len(dna)):\n output += [dna[i]]\n if output[i]==\"T\":\n output[i]='U'\n answer += output[i]\n return answer", "def dna_to_rna(dna):\n translate = {'T':'U', 'A':'A', 'C':'C', 'G':'G' }\n return ''.join(list(map(lambda x:translate[x], dna)))", "def dna_to_rna(dna):\n rna = \"\"\n \n for l in dna:\n if l.upper() == \"T\": rna += \"U\"\n else: rna += l.upper()\n \n return rna", "def dna_to_rna(dna):\n rna = dna.maketrans(\"T\", \"U\")\n return dna.translate(rna)", "def dna_to_rna(dna):\n rna=''\n for i in dna:\n if i == 'T':\n rna+='U'\n else:\n rna+=i\n print(rna)\n return rna", "def dna_to_rna(dna):\n return ''.join(map(lambda a: 'U' if a is 'T' else a, dna))", "def dna_to_rna(dna):\n output = []\n for i in dna:\n if i == 'T':\n output.append('U')\n else: \n output.append(i)\n return ''.join(output)", "def dna_to_rna(dna):\n t= ''\n for x in dna:\n if(x=='T'):\n x='U'\n t+=x \n #print(t)\n return(t)\n\n", "def dna_to_rna(dna):\n ans = ''\n for i in dna:\n if i == 'T':\n ans = ans + 'U'\n else:\n ans = ans + i\n return ans", "def dna_to_rna(dna):\n s = dna.replace('T', 'U')\n return s", "def dna_to_rna(dna):\n res = dna.replace('T', 'U')\n return res", "def dna_to_rna(s):\n s1=\"\"\n for i in s:\n if(i==\"T\"):\n s1+=\"U\"\n elif(i==\"U\"):\n s1+=\"T\"\n else:\n s1+=i\n return s1", "def dna_to_rna(dna):\n rna = ''\n for i in dna:\n if i.upper() == 'T':\n rna += 'U'\n else:\n rna += i.upper()\n return rna", "s =\"\"\ndef dna_to_rna(dna):\n ddna = list(dna)\n xy=len(ddna)\n for i in range(xy):\n if ddna[i] == 'T':\n ddna[i]='U'\n else: \n None\n return s.join(ddna)\n\n", "s=\"\"\ndef dna_to_rna(dna):\n ddna = list(dna)\n xy=len(dna)\n for i in range(xy):\n if ddna[i] == 'T':\n ddna[i]='U' \n else: \n None\n return s.join(ddna)\n\n\n", "def dna_to_rna(dna):\n dnaList = list(dna)\n rnaList = []\n for x in dnaList:\n if x == \"T\":\n rnaList.append(\"U\")\n else:\n rnaList.append(x)\n return \"\".join(rnaList)", "def dna_to_rna(dna):\n rna = ''\n for nucleic_acid in dna:\n if nucleic_acid == 'T':\n rna += 'U'\n else:\n rna += nucleic_acid\n return rna", "def dna_to_rna(dna):\n d = {'T': 'U'}\n return ''.join([d.get(i, i) for i in dna])", "def dna_to_rna(letters):\n whatevs = letters\n return whatevs.replace('T', 'U')\n", "def dna_to_rna(dna):\n return \"\".join(\"U\" if char == \"T\" else char for char in dna)", "def dna_to_rna(dna):\n a = [i if i != \"T\" else \"U\" for i in dna]\n return \"\".join(a)\n", "def dna_to_rna(dna):\n for x in dna:\n if x == \"T\":\n y = dna.replace(\"T\",\"U\")\n return y\n return dna", "def dna_to_rna(dna):\n new = \"\"\n for i in dna:\n if i in [\"G\",\"C\",\"A\"]:\n new+=i\n elif i==\"T\":\n new+=\"U\"\n return new", "def dna_to_rna(dna):\n dna = list(dna)\n for i in range(len(dna)):\n if dna[i] == 'T':\n dna[i] = 'U'\n return \"\".join(dna)", "import string\n\ndef dna_to_rna(dna):\n translation = {84:85}\n return dna.translate(translation)", "def dna_to_rna(dna):\n for char in dna:\n dna= dna.replace(\"T\",\"U\")\n return dna", "def dna_to_rna(dna):\n pattern1 = \"GCAT\"\n pattern2 = \"GCAU\"\n \n translation = str.maketrans(pattern1, pattern2)\n \n return dna.translate(translation)\n", "def dna_to_rna(dna):\n rna = \"\"\n for c in dna:\n if c == 'T':\n rna += 'U'\n else:\n rna += c\n return rna", "def dna_to_rna(dna):\n \n ret = \"\";\n print(dna)\n for c in dna:\n if c == 'T':\n ret = ret + \"U\"\n else:\n ret = ret + c\n \n print(ret)\n return ret", "def dna_to_rna(dna):\n f = \"\"\n for i in range(len(dna)):\n if dna[i] == \"T\":\n f += \"U\"\n else:\n f += dna[i]\n return f", "def dna_to_rna(dna):\n x = []\n for i in range(len(dna)):\n if dna[i] == 'T':\n x.append('U')\n else:\n x.append(dna[i])\n return ''.join(map(str, x))", "#! python3\n\nimport re\ndnaRegex = re.compile(r'T')\ndef dna_to_rna(dna):\n return dnaRegex.sub('U',dna)\n", "#! python3\n\ndef dna_to_rna(dna):\n rna = ''\n for i in dna:\n if i == 'T':\n rna = rna + 'U' \n else:\n rna = rna + i\n return rna"] | {"fn_name": "dna_to_rna", "inputs": [["TTTT"], ["GCAT"], ["GACCGCCGCC"], ["GATTCCACCGACTTCCCAAGTACCGGAAGCGCGACCAACTCGCACAGC"], ["CACGACATACGGAGCAGCGCACGGTTAGTACAGCTGTCGGTGAACTCCATGACA"], ["AACCCTGTCCACCAGTAACGTAGGCCGACGGGAAAAATAAACGATCTGTCAATG"], ["GAAGCTTATCCGTTCCTGAAGGCTGTGGCATCCTCTAAATCAGACTTGGCTACGCCGTTAGCCGAGGGCTTAGCGTTGAGTGTCATTATATACGCGGCCTGCGACCTGGCCACACAATGCCCTCGAAAATTTTTCTTTCGGTTATACGAGTTGCGAAACCTTTCGCGCGTAGACGAAGAATTTGAAGTGGCCTACACCGTTTGGAAAGCCGTTCTCATTAGAATGGTACCGACTACTCGGCTCGGAGTCATTGTATAGGGAGAGTGTCGTATCAACATCACACACTTTTAGCATTTAAGGTCCATGGCCGTTGACAGGTACCGA"]], "outputs": [["UUUU"], ["GCAU"], ["GACCGCCGCC"], ["GAUUCCACCGACUUCCCAAGUACCGGAAGCGCGACCAACUCGCACAGC"], ["CACGACAUACGGAGCAGCGCACGGUUAGUACAGCUGUCGGUGAACUCCAUGACA"], ["AACCCUGUCCACCAGUAACGUAGGCCGACGGGAAAAAUAAACGAUCUGUCAAUG"], ["GAAGCUUAUCCGUUCCUGAAGGCUGUGGCAUCCUCUAAAUCAGACUUGGCUACGCCGUUAGCCGAGGGCUUAGCGUUGAGUGUCAUUAUAUACGCGGCCUGCGACCUGGCCACACAAUGCCCUCGAAAAUUUUUCUUUCGGUUAUACGAGUUGCGAAACCUUUCGCGCGUAGACGAAGAAUUUGAAGUGGCCUACACCGUUUGGAAAGCCGUUCUCAUUAGAAUGGUACCGACUACUCGGCUCGGAGUCAUUGUAUAGGGAGAGUGUCGUAUCAACAUCACACACUUUUAGCAUUUAAGGUCCAUGGCCGUUGACAGGUACCGA"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 13,143 |
def dna_to_rna(dna):
|
7a4f2c6f0dc160f37e57b26a62481c6f | UNKNOWN | Iahub got bored, so he invented a game to be played on paper.
He writes n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and flips all values ak for which their positions are in range [i, j] (that is i ≤ k ≤ j). Flip the value of x means to apply operation x = 1 - x.
The goal of the game is that after exactly one move to obtain the maximum number of ones. Write a program to solve the little game of Iahub.
```
@param {Array} line of the input there are n integers: a1, a2, ..., an. 1 ≤ n ≤ 100. It is guaranteed that each of those n values is either 0 or 1
@return {Integer} the maximal number of 1s that can be obtained after exactly one move
```
Examples :
```
[1, 0, 0, 1, 0, 0] => 5
[1, 0, 0, 1] => 4
```
Note:
In the first case, flip the segment from 2 to 6 (i = 2, j = 6). That flip changes the sequence, it becomes: [1 1 1 0 1 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1 1].
In the second case, flipping only the second and the third element (i = 2, j = 3) will turn all numbers into 1.
(c)ll931110 & fchirica | ["def flipping_game(num):\n current = 0\n biggest = 0\n for i in num:\n current = max(0, current - ( i or -1 ) )\n biggest = max(biggest, current)\n \n return sum(num) + (biggest or -1)", "def flipping_game(num):\n return max([sum(num) + num[i: j + 1].count(0) - num[i: j + 1].count(1) for i in range(len(num)) for j in range(i, len(num))])", "def flipping_game(a):\n current = best = 0\n for n in a:\n current = max(0, current - (n or -1))\n best = max(best, current)\n return sum(a) + (best or -1)", "def flipping_game(num):\n \n # Defining possible start and end points, to reduce complexity away from full 0(n^2)\n poss_start = [i for i,x in enumerate(num) if x==0 and (i==0 or num[i-1]==1)]\n poss_end = [i for i,x in enumerate(num) if x==0 and (i==len(num)-1 or num[i+1]==1)]\n \n # If no start or end available, then every change is for the worse, so one 1 needs to be converted to 0\n if not poss_start or not poss_end: return sum(num) - 1\n \n curmax = 0\n for st in poss_start:\n for en in poss_end:\n curmax = max(curmax,sum(x if (i<st or i>en) else 1-x for i,x in enumerate(num)))\n return curmax", "def flipping_game(num):\n if all(num):\n return len(num) - 1\n x = 0\n m = 0\n for n in num:\n if n == 0:\n x += 1\n m = max(x, m)\n else:\n x = max(x-1, 0)\n return num.count(1) + m", "from itertools import groupby\n\ndef flipping_game(lst):\n split = [ (k, sum(1 for _ in g)) for k,g in groupby(lst)]\n zeroes = [i for i,t in enumerate(split) if not t[0]]\n return max( (sum((k^1 if a<=i<=b else k)*n for i,(k,n) in enumerate(split))\n for z,a in enumerate(zeroes)\n for b in zeroes[z:]),\n default=sum(lst)-1 )", "def flipping_game(num):\n all_pairs = ((i, j) for i in range(len(num)) for j in range(i + 1, len(num) + 1))\n ones = (sum(num[:i]) + j - i - sum(num[i:j]) + sum(num[j:]) for i, j in all_pairs)\n return max(ones) ", "flipping_game=lambda a:sum(a)+max(j-i-2*sum(a[i:j])for j in range(1,len(a)+1)for i in range(j))", "def flipping_game(a):\n m = 0\n for i in range(len(a)):\n for j in range(i,len(a)+1):\n x = sum(a[:i]) + a[i:j+1].count(0) + sum(a[j+1:])\n if x > m:\n m = x\n return m ", "def flipping_game(num):\n if 0 not in num:\n return len(num)-1\n elif num==[0]:\n return 1\n m=-1\n for i in range(len(num)-1):\n for j in range(i+1,len(num)+1):\n c=num[:i].count(1)+num[i:j].count(0)+num[j:].count(1)\n if c>m:\n m=c\n return m"] | {"fn_name": "flipping_game", "inputs": [[[1, 0, 0, 1, 0, 0]], [[1, 0, 0, 1]], [[1]], [[0]], [[1, 0, 0, 0, 1, 0, 0, 0]], [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], [[0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1]]], "outputs": [[5], [4], [0], [1], [7], [18], [22], [18]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,763 |
def flipping_game(num):
|
ae023de4b1d7819a23c88b8c36595cb1 | UNKNOWN | Check your arrows
You have a quiver of arrows, but some have been damaged. The quiver contains arrows with an optional range information (different types of targets are positioned at different ranges), so each item is an arrow.
You need to verify that you have some good ones left, in order to prepare for battle:
```python
anyArrows([{'range': 5}, {'range': 10, 'damaged': True}, {'damaged': True}])
```
If an arrow in the quiver does not have a damaged status, it means it's new.
The expected result is a boolean, indicating whether you have any good arrows left.
Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions | ["def any_arrows(arrows):\n return any(not i.get(\"damaged\", False) for i in arrows)\n", "def any_arrows(arrows):\n return any(not arrow.get('damaged', False) for arrow in arrows)\n", "def any_arrows(arrows):\n return any([True for a in arrows if 'damaged' not in a or a['damaged'] == False])", "def any_arrows(arrows):\n return not all(ar.get('damaged', False) for ar in arrows)", "any_arrows=lambda arrows: any([not x[\"damaged\"] if \"damaged\" in x else True for x in arrows])", "def any_arrows(arrows):\n has_good = False\n for arrow in arrows:\n is_damaged = arrow.get('damaged', False)\n if not is_damaged:\n has_good = True\n break\n return has_good", "any_arrows = lambda a: any((not e[\"damaged\"] if \"damaged\" in e else True) for e in a)", "def any_arrows(arrows):\n return any(a.get('damaged', False) is False for a in arrows)", "def any_arrows (arrows):\n return not all (arrow.get ('damaged', False) for arrow in arrows)", "def any_arrows(quiver):\n for arrow in quiver:\n #AAAAAAAAAAAAAAAAAAAAAAAAAAA!\n if (arrow.get('range') is True or None) or not arrow.get('damaged'):\n return True\n return False\n", "def any_arrows(arrows):\n return not all(map(lambda x: x['damaged'] if 'damaged' in x else False, arrows))", "def any_arrows(arrows):\n return any(not a.get('damaged') for a in arrows)", "def any_arrows(arrows):\n return any(not a.get('damaged', False) for a in arrows)", "def any_arrows(arrows):\n return any(not ar.get('damaged', False) for ar in arrows)", "any_arrows=lambda q:any(not a.get('damaged')for a in q)", "def any_arrows(arrows):\n return any(not x.get(\"damaged\", False) for x in arrows)", "def any_arrows(arrows):\n return sum(a.get('damaged', 0) for a in arrows) < len(arrows)", "any_arrows = lambda arrows : True in [arrow.get (\"damaged\") != True for arrow in arrows];", "def any_arrows(arrows):\n return True if ['undamaged' for i in arrows if not i.get('damaged')] else False", "any_arrows=lambda q:1-all(a.get('damaged')for a in q)", "def any_arrows(arrows):\n return not all(a.get('damaged', False) for a in arrows)", "def any_arrows(arrows):\n try:\n return not (arrows == [] or all(x['damaged'] for x in arrows))\n except KeyError:\n return True", "def any_arrows(arrows):\n return not all(map(lambda d: d.get('damaged', False), arrows)) if arrows else False", "from typing import List, Dict, Union\n\ndef any_arrows(arrows: List[Dict[str, Union[int, bool]]]) -> int:\n \"\"\" Get status that you have some good ones left, in order to prepare for battle. \"\"\"\n return bool(next(filter(lambda _arr: not _arr.get(\"damaged\", False), arrows), False))", "def any_arrows(arrows):\n if arrows:\n for arrow in arrows:\n if arrow.get('damaged'):\n continue\n else:\n return True\n return False\n else:\n return False\n", "def any_arrows(arrows):\n if len(arrows) == 0:\n return False\n else:\n for arrow_info in arrows:\n if arrow_info.get('damaged') == None:\n return True\n elif arrow_info.get('damaged') == False:\n return True\n return False", "def any_arrows(arrows):\n if arrows == []:\n return False\n else:\n for i in arrows:\n if i.get(\"damaged\") is None:\n return True\n break\n elif i[\"damaged\"] == False:\n return True\n break\n else:\n return False\n", "def any_arrows(arrows):\n for dct in arrows:\n if 'damaged' not in dct.keys() or dct['damaged']==False:\n return True\n return False", "def any_arrows(arrows):\n if not arrows:\n status = False\n for arrow in arrows:\n if 'damaged' not in arrow or arrow['damaged'] == False:\n status = True\n break\n else:\n status = False\n return status", "def any_arrows(arrows):\n damaged_test = [bundle.get('damaged') for bundle in arrows]\n return (None in damaged_test or False in damaged_test)", "def any_arrows(arrows):\n return any(True for x in arrows if not x.get('damaged'))", "def any_arrows(arrows):\n all_bools = []\n \n if len(arrows) < 1:\n return False\n for i in arrows:\n if i.get('range', 0) >= 0 and i.get('damaged', False) == False:\n all_bools.append(True)\n if i.get('range', 0) >= 0 and i.get('damaged') == True:\n all_bools.append(False)\n \n \n if True in all_bools:\n return True\n else:\n return False", "def any_arrows(arrows):\n return bool([ arrow for arrow in arrows if not arrow.get('damaged', False) ])", "from operator import __and__\nfrom functools import reduce\ndef any_arrows(arrows):\n return not reduce(__and__, [x.get('damaged', False) for x in arrows], True) \n", "def any_arrows(arrows):\n lst = []\n \n if arrows == []:\n lst.append(False)\n else:\n for arrow in arrows:\n if 'damaged' not in arrow.keys():\n lst.append(True)\n elif 'damaged' in arrow.keys() and arrow['damaged'] == False:\n lst.append(True)\n else:\n lst.append(False)\n return True in lst", "def any_arrows(arrows):\n return bool([x for x in arrows if not x.setdefault('damaged', False)])", "def any_arrows(arrows):\n status = [i.get('damaged') for i in arrows if 'damaged' in i] \n return not sum(status) == len(arrows)", "def any_arrows(arrows):\n #your code here\n for i in arrows:\n if 'damaged' in i:\n if i.get('damaged')==False:\n return True\n if 'damaged' not in i:\n return True\n return False", "def any_arrows(arrows):\n return False in [a.get(\"damaged\", False) for a in arrows]", "def any_arrows(arrows):\n if not arrows:\n return False\n for d in arrows:\n if any(d[k] == False for k in d) or \"damaged\" not in d.keys():\n return True\n return False", "import re\n\ndef any_arrows(arrows):\n damaged_arrows = []\n good_arrows = []\n \n sorted_arrows = arrows.copy()\n sorted_arrows.sort(key=lambda arrow: arrow.get('range') if arrow.get('range') else 0, reverse=True)\n \n print(sorted_arrows)\n \n for arrow in sorted_arrows:\n if arrow.get('damaged'):\n damaged_arrows.append(arrow)\n else:\n good_arrows.append(arrow)\n \n print(damaged_arrows)\n print(good_arrows)\n \n return len(good_arrows) > 0\n \n", "def any_arrows(arrows):\n for arr in arrows:\n if not ('damaged' in arr and arr['damaged']): return True\n return False\n", "def any_arrows(arrows):\n l = list(filter(lambda x: x.get('damaged'), arrows)) \n return len(l)<len(arrows)", "def any_arrows(arrows):\n return len([arrow for arrow in arrows if arrow.get('damaged') != True]) > 0", "def any_arrows(arrows):\n for arrow in arrows:\n if \"damaged\" not in arrow.keys():\n return True\n elif arrow[\"damaged\"] == False:\n return True\n else: return False", "def any_arrows(arrows):\n return any([x for x in arrows if (True if ('damaged' not in list(x.keys()) or (x['damaged'] is False)) else False)])\n", "def any_arrows(arrows):\n count=0\n for i in arrows:\n try:\n if not i['damaged']:\n return True\n except:\n return True\n return False", "def any_arrows(arr):\n for i in arr:\n if True not in i.values():\n return True\n return False", "def any_arrows(arrows):\n print(arrows)\n left = False\n if arrows == []:\n return False\n \n for status in arrows:\n if 'damaged' not in status:\n return True\n else:\n if status['damaged'] is not True:\n return True\n return False ", "any_arrows = lambda arrows: any(\"damaged\" not in arrow or not arrow[\"damaged\"] for arrow in arrows)", "def any_arrows(arrows):\n return any([x for x in arrows if x.get('damaged') == False or x.get('damaged') == None])", "def any_arrows(arrows):\n return not all('damaged' in arrow and arrow['damaged'] for arrow in arrows)", "def any_arrows(arrows):\n for arr in arrows:\n if 'damaged' in arr:\n if arr['damaged'] == False :\n return True\n else:\n return True\n return False", "def any_arrows(arrows):\n for arrow in arrows:\n try : \n if arrow['damaged'] == False : return True\n except : return True\n return False", "def any_arrows(arrows):\n return any(\"damaged\" not in arrow or arrow[\"damaged\"] == False for arrow in arrows)", "def any_arrows(arrows):\n if arrows==[]:\n return False \n for i in arrows:\n if i.get('damaged', 0)==False:\n return True\n return False\n", "def any_arrows(arrows):\n return any(not x.get('damaged') for x in arrows)", "def any_arrows(arrows):\n for a in arrows:\n if 'damaged' not in list(a.keys()):return True\n if a['damaged'] == False :return True\n return False\n", "from functools import reduce\n\ndef any_arrows(arrows):\n if arrows:\n return reduce(lambda a, b: a or b, [not a.get(\"damaged\", False) for a in arrows])\n else:\n return False", "def any_arrows(arrows):\n quiver = False\n if arrows:\n for n, x in enumerate(arrows):\n for k,v in x.items():\n if k == 'range' and len(x.items()) == 1:\n quiver = True\n break\n if k == 'damaged' and v == False:\n quiver = True\n break\n return quiver", "def any_arrows(arrows):\n quiver = False\n if arrows:\n for n, x in enumerate(arrows):\n for k,v in x.items():\n if k == 'range' and len(x.items()) == 1:\n quiver = True\n break\n if k == 'damaged' and v == True:\n pass\n if k == 'damaged' and v == False:\n quiver = True\n break\n return quiver", "def any_arrows(arrows):\n return any((x.get('damaged', None) == None or x['damaged'] == False) for x in arrows)", "def any_arrows(arrows):\n try:\n for i in arrows:\n if 'damaged' in i:\n if i['damaged'] == False:\n return True\n else:\n return True\n return False\n except:\n return False", "def any_arrows(arrows):\n dam = 0\n for i in arrows:\n if 'damaged' in i:\n if i['damaged'] == True:\n dam += 1\n return dam < len(arrows)", "def any_arrows(arrows):\n return any(['damaged' not in a or not a['damaged'] for a in arrows])\n", "def any_arrows(arrows):\n status = False\n for arrow in arrows:\n if not arrow.get('damaged', False):\n status = True\n return status\n", "def any_arrows(arrows):\n print(arrows)\n for el in arrows:\n if el.get('damaged')!= True:\n return True\n return False", "def any_arrows(arrows):\n #print(arrows)\n return any(not arrow.get('damaged', False) for arrow in arrows)", "def any_arrows(arrows):\n goodArrows = False\n for a in arrows:\n goodArrows = goodArrows or not a.get('damaged') \n return goodArrows", "def any_arrows(arrows):\n if arrows:\n for d in arrows:\n if not \"damaged\" in d: return True\n elif not d[\"damaged\"]: return True\n return False", "def any_arrows(arrows):\n for arrow_dict in arrows:\n if 'damaged' not in arrow_dict or not arrow_dict['damaged']:\n return True\n return False", "def any_arrows(arrows):\n return len([a for a in arrows if not a.get('damaged', False)]) != 0", "def any_arrows(arrows):\n res=[]\n for i in range(len(arrows)):\n if 'damaged' in list(arrows[i].keys()):\n if arrows[i]['damaged']==True:\n res.append(True)\n else:\n res.append(False)\n else:\n res.append(False)\n return False in res\n", "def any_arrows(arrows):\n return False in [arrow.get('damaged', False) for arrow in arrows]", "def any_arrows(arrows):\n if arrows == []:\n return False\n else:\n for i in arrows:\n if not 'damaged' in i:\n return True\n elif i['damaged']==False:\n return True\n return False", "any_arrows = lambda arrows: any(not i.get('damaged', False) for i in arrows)", "def any_arrows(arrows):\n if arrows == []:\n return False\n for dictionary in arrows:\n if 'damaged' not in dictionary:\n return True\n if 'damaged' in dictionary:\n if dictionary['damaged'] == False:\n return True\n return False", "def any_arrows(arrows):\n damaged_arrows = 0\n total_arrows = 0\n for x in arrows:\n if 'damaged' in x:\n if x['damaged']:\n damaged_arrows += 1\n total_arrows += 1\n return total_arrows > damaged_arrows\n", "def any_arrows(arrows):\n #your code here\n if not arrows :\n return False\n \n result = False\n \n for arrow in arrows:\n if ('damaged' not in arrow) or (arrow['damaged'] == False):\n result = result or True\n else:\n result = result or False\n return result\n \n \n", "from typing import List, Dict, Union\n\n\ndef any_arrows(arrows: List[Dict[str, Union[str, bool]]]) -> bool:\n return any(not a.get('damaged', False) for a in arrows)\n", "def any_arrows(arrows):\n return any([not arr[\"damaged\"] if \"damaged\" in arr.keys() else True for arr in arrows])", "def any_arrows(arrows):\n return any([i.get('damaged',False) == False for i in arrows]) if arrows else False\n \n", "any_arrows=lambda l:any(not(x.get('damaged')) for x in l)", "def any_arrows(arrows):\n return(False if all([i.get(\"damaged\", False) for i in arrows]) else True)", "def any_arrows(arrows):\n #your code here\n for item in arrows:\n \n try:\n a = item[\"damaged\"]\n if not a:\n return True\n except:\n return True\n return False", "def any_arrows(arrows):\n return False in [i.get('damaged',False) for i in arrows]\n", "def any_arrows(arrows):\n for obj in arrows:\n if obj.get('damaged', False) == False:\n return True\n return False", "def any_arrows(arrows):\n #your code here\n try: \n return min(i.get('damaged', 0) for i in arrows) == 0\n except:\n return False", "def any_arrows(a):\n for i in range(len(a)):\n if a[i].get('damaged') != True:\n return True\n return False", "class Arrow:\n def __init__(self, range = 5, damaged = False):\n self.range = range\n self.damaged = damaged\n\ndef any_arrows(arrows):\n quiver = [] \n for arrow in arrows:\n if 'range' in arrow and 'damaged' in arrow:\n quiver.append(Arrow(arrow.get('range'), arrow.get('damaged')))\n elif 'range' in arrow:\n quiver.append(Arrow(range = arrow.get('range')))\n elif 'damaged' in arrow:\n quiver.append(Arrow(damaged = arrow.get('damaged')))\n else:\n quiver.append(Arrow())\n return False in [x.damaged for x in quiver]", "def any_arrows(arrows):\n return sum(1 if 'damaged' not in list(each.keys()) or ('damaged' in list(each.keys()) and not each['damaged']) else 0 for each in arrows) > 0\n", "def any_arrows(arrows):\n return any(arrow for arrow in arrows if not arrow.get('damaged', False))", "def any_arrows(arrows):\n return any(arrow for arrow in arrows if 'damaged' not in arrow or not bool(arrow['damaged']))", "def any_arrows(arrows):\n return any(not x.get(\"damaged\") for x in arrows)\n # Flez\n", "def any_arrows(arrows):\n #your code here\n i = 0\n while i < len(arrows) :\n if not arrows[i].get(\"damaged\") : return True\n i = i+1\n return False", "def any_arrows(arrows):\n return any(not arrows[i].get('damaged',False) for i in range(len(arrows)))", "def any_arrows(arrows):\n if arrows==[]: return False\n else:\n for i in range(len(arrows)):\n if arrows[i].get('damaged')==False or arrows[i].get('damaged')==None :\n return True\n break\n return False", "def any_arrows(arrows):\n for obj in arrows:\n if not ('damaged' in obj and obj['damaged']):\n return True\n return False", "def any_arrows(arrows):\n for arrow in arrows:\n try:\n if arrow['damaged']:\n continue\n except KeyError:\n return True\n else: return True\n return False", "def any_arrows(arrows):\n #your code here\n for i in arrows:\n if 'damaged' not in i.keys() or ('damaged' in i.keys() and i['damaged']==False):\n return True\n return False"] | {"fn_name": "any_arrows", "inputs": [[[]], [[{"range": 5, "damaged": false}]], [[{"range": 5, "damaged": false}, {"range": 15, "damaged": true}]], [[{"range": 5}, {"range": 10, "damaged": true}, {"damaged": true}]], [[{"range": 10, "damaged": true}, {"damaged": true}]]], "outputs": [[false], [true], [true], [true], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 17,468 |
def any_arrows(arrows):
|
d23ffe995dc74faa1080c4ee2f7a83e2 | UNKNOWN | This function should take two string parameters: a person's name (`name`) and a quote of theirs (`quote`), and return a string attributing the quote to the person in the following format:
```python
'[name] said: "[quote]"'
```
For example, if `name` is `'Grae'` and `'quote'` is `'Practice makes perfect'` then your function should return the string
```python
'Grae said: "Practice makes perfect"'
```
Unfortunately, something is wrong with the instructions in the function body. Your job is to fix it so the function returns correctly formatted quotes.
Click the "Train" button to get started, and be careful with your quotation marks. | ["def quotable(name, quote):\n return '{} said: \"{}\"'.format(name, quote)", "def quotable(name, quote):\n return f'{name} said: \"{quote}\"'", "def quotable(name, quote):\n return name + ' said: ' + '\"' + quote + '\"'", "quotable = '{} said: \"{}\"'.format\n", "def quotable(name, quote):\n said = \" said: \"\n quotation_mark = \"\\\"\"\n return name + said + quotation_mark + quote + quotation_mark", "def quotable(name, quote):\n result = '{Name} said: \\\"{Quote}\\\"'.format(Name=name, Quote=quote)\n return(result)", "def quotable(name, quote):\n return name + ' said: \"' + quote + '\"'", "def quotable(n, q):\n return f\"{n} said: \\\"{q}\\\"\"", "def quotable(name, quote):\n name = name + \" said: \\\"\"\n return name + quote + '\"'", "def quotable(name, quote):\n print(quote)\n return str(name + ' said: ' + '\"' + quote + '\"')"] | {"fn_name": "quotable", "inputs": [["Grae", "Practice makes perfect"], ["Dan", "Get back to work, Grae"], ["Alex", "Python is great fun"], ["Bethany", "Yes, way more fun than R"], ["Darrell", "What the heck is this thing?"]], "outputs": [["Grae said: \"Practice makes perfect\""], ["Dan said: \"Get back to work, Grae\""], ["Alex said: \"Python is great fun\""], ["Bethany said: \"Yes, way more fun than R\""], ["Darrell said: \"What the heck is this thing?\""]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 888 |
def quotable(name, quote):
|
a39db81876bc3ce609ccbda239e1824f | UNKNOWN | You have to create a method "compoundArray" which should take as input two int arrays of different length and return one int array with numbers of both arrays shuffled one by one.
```Example:
Input - {1,2,3,4,5,6} and {9,8,7,6}
Output - {1,9,2,8,3,7,4,6,5,6}
``` | ["def compound_array(a, b):\n x = []\n while a or b:\n if a: x.append(a.pop(0))\n if b: x.append(b.pop(0))\n return x", "def compound_array(a, b):\n x = min(map(len,(a,b)))\n return sum(map(list,zip(a,b)),[]) + a[x:] + b[x:]", "def compound_array(a, b):\n\n res = []\n \n for i in range(max(len(a), len(b))):\n res.extend(a[i:i+1])\n res.extend(b[i:i+1])\n \n return res", "def compound_array(a, b):\n r=[]\n while a or b:\n r+=a[:1]+b[:1]\n a,b=a[1:],b[1:]\n return r", "def compound_array(a, b):\n return [l[i] for i in range(max(len(a), len(b))) for l in (a, b) if i < len(l)]\n", "def compound_array(a, b):\n answer = []\n while a or b:\n if a: answer.append(a.pop(0))\n if b: answer.append(b.pop(0))\n return answer", "def compound_array(a, b):\n lst = zip(a[:len(b)], b[:len(a)])\n return [item for sublist in lst for item in sublist] + a[len(b):] + b[len(a):]", "from itertools import zip_longest\ndef compound_array(a, b):\n mx = []\n for a,b in zip_longest(a,b):\n mx.append(a)\n mx.append(b)\n return list(filter(lambda x:x!=None, mx))", "def compound_array(a, b):\n r=[]\n for i in [[i,j] for i,j in zip(a,b)]:\n r.append(i[0])\n r.append(i[1])\n return r+a[min(len(a),len(b)):]+b[min(len(a),len(b)):]\n", "def compound_array(a, b):\n if a == [] or b == []:\n return a + b\n n = []\n for x in range(len(min([a, b], key=len))):\n n.append(a[x])\n n.append(b[x])\n if x == len(min([a, b], key=len))-1:\n n+=max([a, b], key=len)[x+1:]\n return n"] | {"fn_name": "compound_array", "inputs": [[[1, 2, 3, 4, 5, 6], [9, 8, 7, 6]], [[0, 1, 2], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]], [[11, 12], [21, 22, 23, 24]], [[2147483647, 2147483646, 2147483645, 2147483644, 2147483643], [9]], [[214, 215, 216, 217, 218], []], [[], [214, 215, 219, 217, 218]], [[], []]], "outputs": [[[1, 9, 2, 8, 3, 7, 4, 6, 5, 6]], [[0, 9, 1, 8, 2, 7, 6, 5, 4, 3, 2, 1, 0]], [[11, 21, 12, 22, 23, 24]], [[2147483647, 9, 2147483646, 2147483645, 2147483644, 2147483643]], [[214, 215, 216, 217, 218]], [[214, 215, 219, 217, 218]], [[]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,643 |
def compound_array(a, b):
|
176afd9210f5b52c5338da4596e925ef | UNKNOWN | ## The Problem
James is a DJ at a local radio station. As it's getting to the top of the hour, he needs to find a song to play that will be short enough to fit in before the news block. He's got a database of songs that he'd like you to help him filter in order to do that.
## What To Do
Create `longestPossible`(`longest_possible` in python and ruby) helper function that takes 1 integer argument which is a maximum length of a song in seconds.
`songs` is an array of objects which are formatted as follows:
```python
{'artist': 'Artist', 'title': 'Title String', 'playback': '04:30'}
```
You can expect playback value to be formatted exactly like above.
Output should be a title of the longest song from the database that matches the criteria of not being longer than specified time. If there's no songs matching criteria in the database, return `false`. | ["songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef calculate_seconds(s):\n minutes, seconds = [int(x) for x in s.split(':')]\n return minutes * 60 + seconds\n\ndef longest_possible(playback):\n candidates = [song for song in songs if calculate_seconds(song['playback']) <= playback]\n return sorted(candidates, key=lambda x: calculate_seconds(x['playback']), reverse=True)[0]['title'] if len(candidates) > 0 else False", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef longest_possible(playback):\n f = lambda song: sum(int(x) * 60 ** (1 - i) for i, x in enumerate(song['playback'].split(':'))) <= playback\n return max(filter(f, songs), default={'title': False}, key=lambda x: x['playback'])['title']", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef longest_possible(playback):\n song_list = [x for x in songs if x['playback'] <= (\"%02d:%02d\" % divmod(playback, 60))]\n return max(song_list, key=lambda x:x[\"playback\"])[\"title\"] if song_list else False", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef to_seconds(time):\n minutes, seconds = list(map(int, time.split(':')))\n return minutes * 60 + seconds\n\n\ndef longest_possible(playback):\n longest_song = 0\n song_title = ''\n for song in songs:\n song_length = to_seconds(song['playback'])\n if longest_song < song_length <= playback:\n longest_song = song_length\n song_title = song['title']\n return song_title or False\n", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\nfrom bisect import bisect\n\nto_sec = lambda s: int(s[:2])*60 + int(s[3:])\nD = {to_sec(song['playback']):song['title'] for song in songs}\nL = sorted(D)\n\ndef longest_possible(playback):\n i = bisect(L, playback)\n return D[L[i-1]] if i else False", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef longest_possible(n):\n return max((x for x in map(extractor,songs) if x[0]<=n), default=(0,False) )[1]\n \ndef extractor(d):\n m,s = map(int,d['playback'].split(':'))\n return m*60+s, d['title']", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef min_to_sec(i):\n return int(i['playback'][:2])*60 + int(i['playback'][3:])\n\n\ndef longest_possible(sec):\n sn = [(song['title'], min_to_sec(song))\n for song in songs if min_to_sec(song) <= sec]\n sn_sort = sorted(sn, key=lambda x: x[1])\n return False if sn_sort == [] else sn_sort[-1][0]\n", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef seconds(ms):\n m, s = map(int, ms.split(':'))\n return m * 60 + s\n \ndef longest_possible(playback):\n try:\n song = max(\n [song for song in songs if seconds(song['playback']) <= playback],\n key=lambda song: seconds(song['playback'])\n )\n except ValueError:\n return False\n return song['title']", "songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef longest_possible(playback):\n \n def to_seconds(t):\n mins, secs = t.split(':')\n return int(mins)*60 + int(secs)\n \n valids = [(song['title'], to_seconds(song['playback'])) for song in songs if to_seconds(song['playback']) <= playback]\n \n if len(valids) == 0:\n return False\n else:\n return max(valids, key=lambda p: p[1])[0]", "from functools import reduce\nsongs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]\ndef seconds(song):\n p = song.get('playback', 0)\n return int(p[:2]) * 60 + int(p[3:])\n \ndef pick_if(acc, x, playback):\n sx = seconds(x)\n return x if sx > seconds(acc) and sx <= playback else acc\n\ndef longest_possible(playback):\n r = reduce(lambda acc,x: pick_if(acc, x, playback), songs, {'title': False, 'playback': '00:00'})\n return r['title']\n \n"] | {"fn_name": "longest_possible", "inputs": [[215], [270], [13], [300]], "outputs": [["For Reasons Unknown"], ["YYZ"], [false], ["Surfing With The Alien"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 9,700 |
songs = [{'artist': 'Marillion', 'title': 'Keyleigh', 'playback': '03:36'}, {'artist': 'Pink Floyd', 'title': 'Time', 'playback': '06:48'}, {'artist': 'Rush', 'title': 'YYZ', 'playback': '04:27'}, {'artist': 'Bonobo', 'title': 'Days To Come', 'playback': '03:50'}, {'artist': 'Coldplay', 'title': 'Yellow', 'playback': '04:32'}, {'artist': 'Bloc Party', 'title': 'Like Eating Glass', 'playback': '04:22'}, {'artist': 'The Killers', 'title': 'For Reasons Unknown', 'playback': '03:30'}, {'artist': 'Arctic Monkeys', 'title': 'Teddy Picker', 'playback': '03:25'}, {'artist': 'Joe Satriani', 'title': 'Surfing With The Alien', 'playback': '04:34'}]
def longest_possible(playback):
|
7d5cd9b60f33941105c15dba5355e474 | UNKNOWN | # Task
You are given a function that should insert an asterisk (`*`) between every pair of **even digits** in the given input, and return it as a string. If the input is a sequence, concat the elements first as a string.
## Input
The input can be an integer, a string of digits or a sequence containing integers only.
## Output
Return a string.
## Examples
```
5312708 --> "531270*8"
"0000" --> "0*0*0*0"
[1, 4, 64] --> "14*6*4"
```
Have fun! | ["import re\n\ndef asterisc_it(s):\n if isinstance(s,int): s=str(s)\n elif isinstance(s,list): s=''.join(map(str,s))\n return re.sub(r'(?<=[02468])(?=[02468])', '*', s)", "def asterisc_it(n): \n if type(n) == list: n = \"\".join(str(i) for i in n)\n if type(n) == int : n = str(n)\n return \"\".join([a+\"*\" if int(a)%2==0 and int(b)%2 == 0 else a for a,b in zip(n,n[1:])]) + n[-1]", "import re\ndef asterisc_it(n): \n s = ''.join(map(str, n)) if isinstance(n, list) else str(n)\n return re.sub('([02468])(?=[02468])', r'\\1*', s)", "def asterisc_it(n): \n raw = [i for i in list(str(n)) if i.isalnum()]\n txt = '{}'.format(raw[0])\n for i in range(len(raw))[1:]:\n if int(raw[i])%2 == 0:\n if int(raw[i-1]) % 2 == 0:\n txt += '*'+raw[i]\n else: txt += raw[i] \n else: txt += raw[i] \n return txt", "def asterisc_it(n): \n n = x(n)\n h = n[1:]\n return n[0] + ''.join([[e,'*'+e][all((not int(e)%2,not int(n[i-1])%2))] for i,e in enumerate(h,1)])\n \nx = lambda c: str(c) if not type(c) is list else ''.join(map(str,c))", "def asterisc_it(n): \n return \"\".join([\"*\" + str(char) if i > 0 and (int(\"\".join(map(str, n))[i-1] if isinstance(n, list) else str(n)[i-1])%2==0) and (int(\"\".join(map(str, n))[i] if isinstance(n, list) else str(n)[i])%2==0) else str(char) for i,char in enumerate(\"\".join(map(str, n)) if isinstance(n, list) else str(n))])", "def asterisc_it(n):\n asterisk_str = \"\"\n if type(n) == int:\n n = str(n)\n elif type(n) == list:\n n = ''.join(map(str,n))\n \n for i,j in enumerate(range(1,len(n))):\n asterisk_str += n[i]\n print(i,j)\n if int(n[i]) % 2 == 0 and int(n[j]) % 2 == 0:\n asterisk_str += \"*\"\n \n return asterisk_str+n[-1]", "def asterisc_it(n_sequence: str) -> str:\n \"\"\" Insert an asterisk (*) between every pair of even digits. \"\"\"\n _result = \"\"\n\n if type(n_sequence) is int:\n n_sequence = str(n_sequence)\n else:\n n_sequence = \"\".join(str(_) for _ in n_sequence)\n\n for ix, num in enumerate(n_sequence):\n if ix < len(n_sequence) - 1:\n if not int(num) % 2 and not int(n_sequence[ix+1]) % 2:\n _result += f\"{num}*\"\n else:\n _result += str(num)\n else:\n _result += str(num)\n\n return _result\n", "def asterisc_it(n): \n s, out = '', []\n if type(n) is int: s = str(n)\n elif type(n) is list: s = ''.join([str(n[x]) for x in range(len(n))])\n else: s = str(n)\n return s if len(s) <= 1 else (''.join([(s[x] + '*' if int(s[x]) % 2 == 0 and int(s[x+1]) % 2 == 0 else s[x]) for x in range(len(s)-1)])) + s[-1] ", "def asterisc_it(n): \n if isinstance(n, list):\n for i in range(len(n)):\n n[i] = str(n[i])\n n_str = ''.join(n)\n else:\n n_str = str(n)\n \n prev = False\n result = \"\"\n \n for s in n_str:\n if int(s) % 2 == 0:\n if prev == True:\n result = result + '*' \n prev = True\n else:\n prev = False\n result = result + s\n \n return result"] | {"fn_name": "asterisc_it", "inputs": [[5312708], [9682135], [2222], [1111], [9999], ["0000"], [8], [2], [0], [[1, 4, 64, 68, 67, 23, 1]]], "outputs": [["531270*8"], ["96*8*2135"], ["2*2*2*2"], ["1111"], ["9999"], ["0*0*0*0"], ["8"], ["2"], ["0"], ["14*6*4*6*8*67231"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,269 |
def asterisc_it(n):
|
c3b3c49313fce6c4cc9e59b16ff8619f | UNKNOWN | A [Mersenne prime](https://en.wikipedia.org/wiki/Mersenne_prime) is a prime number that can be represented as:
Mn = 2^(n) - 1. Therefore, every Mersenne prime is one less than a power of two.
Write a function that will return whether the given integer `n` will produce a Mersenne prime or not.
The tests will check random integers up to 2000. | ["def valid_mersenne(n):\n return n in {2,3,5,7,13,17,19,31,61,89,107,127,521,607,1279}", "def valid_mersenne(n):\n '''Currently using the Lucas-Lehmer test.'''\n \n if n < 2:\n return False\n \n if n == 2:\n return True\n \n mersenne = 2**n - 1\n \n residue = 4\n for _ in range(n - 2):\n residue = (residue * residue - 2) % mersenne\n \n return not residue", "def valid_mersenne(n):\n return n == 2 or is_prime(n) and lucas_lehmer(n)\n \ndef is_prime(n):\n from itertools import chain\n return all(n % i != 0 for i in chain([2], range(3, int(n**.5) + 1, 2)))\n \ndef lucas_lehmer(n):\n s = 4\n M = 2**n - 1\n for _ in range(n - 2):\n s = (s*s - 2) % M\n return s == 0", "A000043 = {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667, 42643801, 43112609}\n\ndef valid_mersenne(n):\n return n in A000043", "mersenne_n = (2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279)\ndef valid_mersenne(n):\n return n in mersenne_n\n", "def valid_mersenne(n):\n mp = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281,\n 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243,\n 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377,\n 6972593, 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667,\n 42643801, 43112609, 57885161, 74207281]\n return n in mp", "def valid_mersenne(n):\n return n in [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941]", "valid_mersenne = {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279}.__contains__"] | {"fn_name": "valid_mersenne", "inputs": [[2], [3], [5], [7], [11], [13], [17], [19], [21], [23], [31], [49], [61], [89], [107], [127], [221], [521], [607], [1279]], "outputs": [[true], [true], [true], [true], [false], [true], [true], [true], [false], [false], [true], [false], [true], [true], [true], [true], [false], [true], [true], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,962 |
def valid_mersenne(n):
|
eb8d1df6125c6a182d635508e99f833c | UNKNOWN | As a treat, I'll let you read part of the script from a classic 'I'm Alan Partridge episode:
```
Lynn: Alan, there’s that teacher chap.
Alan: Michael, if he hits me, will you hit him first?
Michael: No, he’s a customer. I cannot hit customers. I’ve been told. I’ll go and get some stock.
Alan: Yeah, chicken stock.
Phil: Hello Alan.
Alan: Lynn, hand me an apple pie. And remove yourself from the theatre of conflict.
Lynn: What do you mean?
Alan: Go and stand by the yakults. The temperature inside this apple turnover is 1,000 degrees. If I squeeze it, a jet of molten Bramley apple is going to squirt out. Could go your way, could go mine. Either way, one of us is going down.
```
Alan is known for referring to the temperature of the apple turnover as 'Hotter than the sun!'. According to space.com the temperature of the sun's corona is 2,000,000 degrees C, but we will ignore the science for now.
Your job is simple, if (x) squared is more than 1000, return 'It's hotter than the sun!!', else, return 'Help yourself to a honeycomb Yorkie for the glovebox.'.
X will be either a number or a string. Both are valid.
Other katas in this series:
Alan Partridge I - Partridge Watch
Alan Partridge III - London | ["def apple(x):\n return \"It's hotter than the sun!!\" if int(x) ** 2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n if int(x)**2 > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n if int(x) > 31:\n return \"It's hotter than the sun!!\" \n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\" ", "def apple(x):\n return (\"Help yourself to a honeycomb Yorkie for the glovebox.\",\"It's hotter than the sun!!\")[int(x)**2>1000]\n", "apple = lambda x: (\"Help yourself to a honeycomb Yorkie for the glovebox.\",\"It's hotter than the sun!!\")[int(x)**2>1000]", "import math\n\ndef apple(x):\n if (math.pow(int(x), 2) > 1000):\n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "\ndef apple(x):\n if float(x)**2>1000: return \"It's hotter than the sun!!\"\n else: return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n return \"It's hotter than the sun!!\" if pow(int(x), 2) > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n if type(x) == str:\n temp = int(x)\n else:\n temp = x\n if temp ** 2 > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n n = int(x)\n if n*n > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n msg0 = \"It's hotter than the sun!!\"\n msg1 = \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n return [msg1, msg0][int(x)**2 >= 1000]", "def apple(x):\n if (int(x) * int(x)) > 1000:\n return f'It\\'s hotter than the sun!!'\n else:\n return f'Help yourself to a honeycomb Yorkie for the glovebox.'", "apple=lambda x:\"It's hotter than the sun!!\"if int(x)**2>1000else'Help yourself to a honeycomb Yorkie for the glovebox.'", "def apple(x: int) -> str:\n \"\"\" Get a message based on squared `x` parameter. \"\"\"\n return \"It's hotter than the sun!!\" if pow(int(x), 2) > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "apple=lambda x: \"It's hotter than the sun!!\" if int(x)>31 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n if float(x) > 31.622776601683793:\n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "apple = lambda x: [\"Help yourself to a honeycomb Yorkie for the glovebox.\",\"It's hotter than the sun!!\"][int(x) ** 2 > 1000]", "apple = lambda x : \"It's hotter than the sun!!\" if eval(str(x)) ** 2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n \n if type(x) is int:\n n = x\n if n ** 2 > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n \n elif type(x) is str:\n n = int(x)\n if n ** 2 > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n return ('Help yourself to a honeycomb Yorkie for the glovebox.', 'It\\'s hotter than the sun!!')[int(x)**2 > 1000]", "def apple(x):\n return \"It's hotter than the sun!!\" if int(x)**int(2) >1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n integerX = int(x)\n if integerX**2 > 1000: \n return 'It\\'s hotter than the sun!!'\n else: \n return 'Help yourself to a honeycomb Yorkie for the glovebox.'\n", "def apple(x):\n return f\"It's hotter than the sun!!\" if int(x) * int(x) > 1000 else f\"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n phrases = ['It\\'s hotter than the sun!!', 'Help yourself to a honeycomb Yorkie for the glovebox.']\n return phrases[int(x)**2 < 1000]\n", "def apple(x: int) -> str:\n \"\"\" Get a message based on squared `x` parameter. \"\"\"\n return (\"Help yourself to a honeycomb Yorkie for the glovebox.\", \"It's hotter than the sun!!\")[pow(int(x), 2) > 1000]", "def apple(x):\n print(int(x)**2)\n return \"It's hotter than the sun!!\" if int(x)**2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n return f'It\\'s hotter than the sun!!' if int(x)**2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n x = int(x)**2\n if x > 1e3:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "m = lambda a: pow (int(a), 2)\napple = lambda a: \"It's hotter than the sun!!\" if m(a) > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def get_temp(x):\n return \"It's hotter than the sun!!\" if x**2 > 1000 else 'Help yourself to a honeycomb Yorkie for the glovebox.' \n\ndef apple(x):\n if isinstance(x, int):\n return get_temp(x)\n else:\n return get_temp(int(x))", "def apple(x):\n k=int(x)\n return \"It's hotter than the sun!!\" if k**2 >= 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n return \"It's hotter than the sun!!\" if int(x) * int(x) >= 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n y = int(x)\n if y * y > 1000:\n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n num = float(x)\n return \"It's hotter than the sun!!\" if num ** 2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n return \"It's hotter than the sun!!\" if eval(str(x))**2>1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\" if int(x)<32 else \"It's hotter than the sun!!\"", "def apple(x):\n x = int(x)\n hot = x ** 2\n if hot > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n x = int(x)\n nelio = x * x\n if (nelio > 1000):\n return \"It's hotter than the sun!!\"\n\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n value = int(x)\n if value**2 > 1000:\n result = \"It's hotter than the sun!!\"\n else:\n result = \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n return result\n", "def apple(x):\n \"\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0441\u043e\u043b\u043d\u0446\u0430\"\n x1 = int(x)\n if x1 ** 2 >= 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n x2 = int(x) * int(x)\n if x2 >1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\" \n", "def apple(x):\n number = int(x)\n square = number * number\n if square > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n print(x)\n return \"It's hotter than the sun!!\" if int(x)**2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n return \"\".join(\"It's hotter than the sun!!\" if int(x or 0)*int(x or 0) > 1000 else 'Help yourself to a honeycomb Yorkie for the glovebox.')", "def apple(x):\n a = int(x) ** 2\n if a > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n x = int(x) if isinstance(x, str) else x\n if x ** 2 > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n \n", "def apple(x):\n if pow(int(x), 2) < 1000: \n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n elif pow(int(x), 2) > 1000:\n return \"It's hotter than the sun!!\"\n", "def apple(x):\n x = int(x) if isinstance(x, str) else x\n return 'It\\'s hotter than the sun!!' if x * x > 1000 else 'Help yourself to a honeycomb Yorkie for the glovebox.' ", "apple=lambda x:[\"Help yourself to a honeycomb Yorkie for the glovebox.\",\"It's hotter than the sun!!\"][int(str(x))**2>1000]", "def apple(x):\n temperature = int(x) ** 2\n if temperature > 1000:\n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n a=int(x)\n return \"It's hotter than the sun!!\" if a**2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n\n result=\"Help yourself to a honeycomb Yorkie for the glovebox.\"\n\n x=int(x)\n if x**2>1000:\n result=\"It's hotter than the sun!!\"\n else: \n result=\"Help yourself to a honeycomb Yorkie for the glovebox.\"\n\n return result", "def apple(x):\n x = int(x)\n s = x**2\n if s>1000:\n return \"It's hotter than the sun!!\"\n else:\n return 'Help yourself to a honeycomb Yorkie for the glovebox.'\ne = apple(\"60\")\nprint(e)", "def apple(x):\n str1 = int(x)\n if pow(str1, 2) > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n a = int(x)\n a = a * a\n if a > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n return \"It's hotter than the sun!!\" if int(x) ** 2 > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n #if int(x) ** 2 > 1000:\n # return \"It's hotter than the sun!!\"\n #else:\n # return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n if type(x)==str:\n x=int(x)\n return \"It's hotter than the sun!!\" if x**2>1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n x = int(x)\n return [\"Help yourself to a honeycomb Yorkie for the glovebox.\", \"It's hotter than the sun!!\"][x * x > 1000]", "def apple(x):\n v = int(x)**2\n if v > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "import math\n\ndef apple(x):\n if int(x) > 10 * math.sqrt(10):\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "from math import pow\ndef apple(x):\n return 'It\\'s hotter than the sun!!' if pow(int(x), 2) > 1000 else 'Help yourself to a honeycomb Yorkie for the glovebox.'\n", "def apple(x):\n y=int(x)\n list1=[\"It's hotter than the sun!!\", \"Help yourself to a honeycomb Yorkie for the glovebox.\"]\n if (y**2) > 1000:\n return list1[0]\n else:\n return list1[1]", "def apple(x):\n temperature = int(x)**2\n if temperature < 1000:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n return \"It's hotter than the sun!!\" ", "def apple(x):\n x=float(x)\n if x*x > 1000 :\n return \"It's hotter than the sun!!\"\n else :\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n new_int = int(str(x))\n if new_int ** 2 > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n korabel=int(x)\n mashfuck = \"It's hotter than the sun!!\"\n korfuck = \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n if (korabel**2>1000): return mashfuck\n else: return korfuck", "def apple(x):\n import math\n \n num = int(x)\n \n if(num**2 > 1000):\n return \"It's hotter than the sun!!\"\n else:\n return 'Help yourself to a honeycomb Yorkie for the glovebox.'\n", "def apple(x):\n a = int(x)\n return \"It's hotter than the sun!!\" if a*a >1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n x = int(x)\n x = x * x\n if x >= 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n if type(x)==str:\n x=int(x)\n if x**2<1000:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n else:\n return \"It's hotter than the sun!!\"\n \n", "def apple(x):\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\" if int(x)*int(x)<1000 else \"It's hotter than the sun!!\"", "def apple(x):\n a = (\"Help yourself to a honeycomb Yorkie for the glovebox.\",\n \"It's hotter than the sun!!\")\n return a[int(x) ** 2 > 1000]", "def apple(x):\n if type(x) is str:\n x = int(x)\n return \"It's hotter than the sun!!\" if x * x > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n if int(x) ** 2 > 1000:\n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n # Flez\n", "def apple(x):\n x=int(x)\n \n ans=x**2\n if(ans>1000):\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n x=int(x)\n g=lambda x:x * x\n if g(x) > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "apple=lambda n: \"It's hotter than the sun!!\" if float(n)**2>1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n i = int(x) ** 2\n if i >= 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n dbl_x = float(x)\n if dbl_x**2 > 1000:\n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n return 'It\\'s hotter than the sun!!' if int(x)**2>1000\\\n else 'Help yourself to a honeycomb Yorkie for the glovebox.'", "def apple(x):\n a= int(x)**2\n if a>=1000:\n return \"It's hotter than the sun!!\"\n else: return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n try:\n val = int(x)**2\n except:\n pass\n if val > 1000:\n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n x = int(x)\n hot = \"It's hotter than the sun!!\"\n alternative = \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n return hot if x*x > 1000 else alternative", "def apple(x):\n line1 = \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n line2 = \"It's hotter than the sun!!\"\n \n return line2 if int(x)**2 > 1000 else line1", "def apple(x):\n #y = pow(int(x), 2)\n\n if ((pow(int(x), 2)) > 1000):\n return(\"It's hotter than the sun!!\")\n else:\n return(\"Help yourself to a honeycomb Yorkie for the glovebox.\")", "def apple(x):\n squared = int(x) ** 2\n if squared > 1000:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n return \"It's hotter than the sun!!\" if int(x) >= 32 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n number = 0\n if not (type(x) is int):\n number = int(x)\n else:\n number = x\n \n if number >= 32:\n return \"It's hotter than the sun!!\"\n else:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "from math import pow\ndef apple(x):\n if pow(int(x),2) <= 1000:\n return 'Help yourself to a honeycomb Yorkie for the glovebox.'\n else:\n return \"It's hotter than the sun!!\"\n \n \n", "def apple(x):\n x = str(x)\n x = float(x)\n if x*x > 1000: \n return \"It's hotter than the sun!!\" \n else: \n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n pop = int(x)**2\n return \"It's hotter than the sun!!\" if pop > 1000 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n if int(x) < 32:\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n else:\n return \"It's hotter than the sun!!\"\n\nprint((apple(\"3\")))\n", "def apple(x):\n if int(x)**2 > 1000:\n hot = \"It's hotter than the sun!!\"\n else:\n hot = \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n return hot", "def apple(x):\n hot = int(x)**2\n if hot > 1000:\n return str(\"It's hotter than the sun!!\")\n else:\n return str(\"Help yourself to a honeycomb Yorkie for the glovebox.\")", "def apple(x):\n x=int(x)\n if x**2>1000:\n r= 'It\\'s hotter than the sun!!'\n else:\n r='Help yourself to a honeycomb Yorkie for the glovebox.'\n return r\n", "def apple(x):\n return {\n True : \"It's hotter than the sun!!\",\n False : \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n } [int(x) * int(x) > 1000]", "import math\n\ndef apple(x): \n return \"It's hotter than the sun!!\" if math.pow(float(x), 2) > 1000.0 else \"Help yourself to a honeycomb Yorkie for the glovebox.\"\n", "def apple(x):\n x = int(x)\n if x * x >= 1000: \n return \"It's hotter than the sun!!\"\n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n intx = int(x)\n if intx ** 2 > 1000:\n return \"It's hotter than the sun!!\"\n else: \n return \"Help yourself to a honeycomb Yorkie for the glovebox.\"", "def apple(x):\n return (\"Help yourself to a honeycomb Yorkie for the glovebox.\", \"It's hotter than the sun!!\")[int(x)**2 > 1e3]"] | {"fn_name": "apple", "inputs": [["50"], [4], ["12"], [60]], "outputs": [["It's hotter than the sun!!"], ["Help yourself to a honeycomb Yorkie for the glovebox."], ["Help yourself to a honeycomb Yorkie for the glovebox."], ["It's hotter than the sun!!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 18,697 |
def apple(x):
|
d0e2c10282bf49b1e12f52592916bc77 | UNKNOWN | # Task
Write a function `deNico`/`de_nico()` that accepts two parameters:
- `key`/`$key` - string consists of unique letters and digits
- `message`/`$message` - string with encoded message
and decodes the `message` using the `key`.
First create a numeric key basing on the provided `key` by assigning each letter position in which it is located after setting the letters from `key` in an alphabetical order.
For example, for the key `crazy` we will get `23154` because of `acryz` (sorted letters from the key).
Let's decode `cseerntiofarmit on ` using our `crazy` key.
```
1 2 3 4 5
---------
c s e e r
n t i o f
a r m i t
o n
```
After using the key:
```
2 3 1 5 4
---------
s e c r e
t i n f o
r m a t i
o n
```
# Notes
- The `message` is never shorter than the `key`.
- Don't forget to remove trailing whitespace after decoding the message
# Examples
Check the test cases for more examples.
# Related Kata
[Basic Nico - encode](https://www.codewars.com/kata/5968bb83c307f0bb86000015) | ["def de_nico(key, msg):\n ll, order, s = len(key), [sorted(key).index(c) for c in key], ''\n while msg:\n s, msg = s + ''.join(msg[i] for i in order if i < len(msg)), msg[ll:]\n return s.strip()", "def de_nico(key,msg):\n \n decoder = []\n \n # assign key letters numbers according to alphabetized/sorted indices\n for letter in key:\n decoder.append(sorted(key).index(letter))\n\n # break msg into segments based on key length\n msg_segs = [msg[i:(i+len(key))] for i in range(0, len(msg), len(key))]\n \n # enumerate segments along their ranges\n enum_segs = []\n for seg in msg_segs:\n enum_segs.append(dict(zip(range(len(seg)),seg)))\n\n # read segs back into decoded_msg by codon in decoder, excepting KeyErrors out to account for final\n # seg length < len(decoder)\n decoded_msg = []\n for seg in enum_segs:\n for codon in decoder:\n try:\n decoded_msg.append(seg[codon])\n except KeyError:\n continue\n \n return ((''.join(decoded_msg)).rstrip())", "from operator import itemgetter\ndef de_nico(key,msg):\n #keyDict = dict(zip(sorted(key), range(1, len(key)+1)))\n #encryptkey = \"\".join([str(keyDict[x]) for x in key])\n decryptkey, _ = zip( *sorted(zip(range(1, len(key)+1), key), key = itemgetter(1) ))\n decryptkey = \"\".join(str(x) for x in decryptkey)\n chunksize = len(decryptkey)\n chunks = [msg[y-chunksize:y] for y in range(chunksize, len(msg)+chunksize, chunksize)]\n #chunks[-1] += \" \"*(len(key) - len(chunks[-1])) ## add whitespaces accordingly if the last chunk happens to be too short \n for i, chunk in enumerate(chunks):\n chunkSorted, _ = zip( *sorted( zip(chunk, decryptkey), key = itemgetter(1) ))\n chunks[i] = \"\".join(chunkSorted)\n return \"\".join(chunks).rstrip()", "import itertools\ndef de_nico(key,msg):\n pack =[list(range(len(key)))]+list(list(msg[i:i+len(key)]) for i in range(0,len(msg),len(key)))\n sor = [sorted(key).index(i) for i in key]\n sorting = sorted(itertools.zip_longest(*pack,fillvalue=\"\"), key=lambda col: sor.index(col[0]))\n return \"\".join([\"\".join(j) for i,j in enumerate(itertools.zip_longest(*sorting,fillvalue=\" \")) if i>0]).strip(\" \")", "def de_nico(key,msg):\n result = ''\n counter = -1\n while len(result) < len(msg):\n counter += 1\n for i in [sorted(key).index(c) for c in key]:\n try:\n result += msg[i+counter*len(key)]\n except:\n continue\n return result.strip()\n", "def de_nico(key,msg):\n sorted_key = sorted(key)\n num_key = []\n for chr in key:\n num_key.append(sorted_key.index(chr))\n\n result = ''\n start = 0\n end = len(key)\n while start < len(msg):\n chunk = msg[start : end]\n for index in num_key:\n if index < len(chunk):\n result += chunk[index]\n start = end\n end += len(key)\n\n return result.strip()", "de_nico=lambda k,m: (lambda k: \"\".join((lambda g: \"\".join(g[p] for p in k if p<len(g)))(m[i*len(k):(i+1)*len(k)]) for i in range(len(m)//len(k)+1)).strip())((lambda s: [s.index(l) for l in k])(sorted(k)))", "def de_nico(key,msg):\n num_key = ''.join([str(id) for i in key for id, item in enumerate(sorted(key), 1) if item == i])\n cut_msg = [msg[i:i+len(num_key)] for i in range(0, len(msg), len(num_key))]\n d_msg = [''.join([item for i in num_key for id, item in enumerate(list(x), 1) if id == int(i)]) for x in cut_msg]\n return ''.join(d_msg).rstrip()", "from itertools import chain, zip_longest\n\ndef de_nico(key, msg):\n columns = [msg[n::len(key)] for n in range(len(key))]\n key = (n for n, c in sorted(enumerate(key), key=lambda k: k[1]))\n return ''.join(chain(*zip_longest(*sorted(columns, key=lambda k: next(key)), fillvalue=''))).strip()", "from itertools import cycle\n\n\ndef de_nico(key, msg):\n code = tuple(sorted(key).index(k) + 1 for k in key)\n code_cycle = cycle(code)\n key_cycle = cycle(range(1, len(key) + 1))\n msg_encrypted = [(k, next(key_cycle)) for k in msg]\n result = []\n while msg_encrypted:\n try:\n index = next(code_cycle)\n found = next(p for p in msg_encrypted if p[1] == index)\n msg_encrypted.remove(found)\n result.append(found[0])\n except StopIteration:\n pass\n return ''.join(result).strip()"] | {"fn_name": "de_nico", "inputs": [["crazy", "cseerntiofarmit on "], ["crazy", "cseerntiofarmit on"], ["abc", "abcd"], ["ba", "2143658709"], ["a", "message"], ["key", "eky"]], "outputs": [["secretinformation"], ["secretinformation"], ["abcd"], ["1234567890"], ["message"], ["key"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,523 |
def de_nico(key,msg):
|
e287a02a315366729e9b83eae395913f | UNKNOWN | Bit Vectors/Bitmaps
A bitmap is one way of efficiently representing sets of unique integers using single bits.
To see how this works, we can represent a set of unique integers between `0` and `< 20` using a vector/array of 20 bits:
```
var set = [3, 14, 2, 11, 16, 4, 6];```
```
var bitmap = [0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0];
```
As you can see, with a bitmap, the length of the vector represents the range of unique values in the set (in this case `0-20`), and the `0/1` represents whether or not the current index is equal to a value in the set.
Task:
Your task is to write a function `toBits` that will take in a set of uniqe integers and output a bit vector/bitmap (an array in javascript) using `1`s and `0`s to represent present and non-present values.
Input:
The function will be passed a set of unique integers in string form, in a random order, separated by line breaks.
Each integer can be expected to have a unique value `>= 0` and `< 5000`.
The input will look like this:
`let exampleInput = '3\n14\n5\n19\n18\n1\n8\n11\n2...'`
Output:
The function will be expected to output a 5000 bit vector (array) of bits, either `0` or `1`, for example:
`let exampleOutput = [0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0,...]`
More in-depth bitmap kata coming very soon, happy coding!
To learn more about bitmapping and to see the inspiration for making these kata, checkout the book Programming Pearls by Jon Bently. It's a powerful resource for any programmer! | ["def to_bits(s):\n lst = [0] * 5000\n for i in map(int,s.split()): lst[i] = 1\n return lst", "def to_bits(s):\n return [1 if i in set(map(int, s.split(\"\\n\"))) else 0 for i in range(5000)]", "def to_bits(string):\n bitmap = [0] * 5000\n for x in map(int, string.split()):\n bitmap[x] = 1\n return bitmap", "to_bits=lambda s:list(map(set(map(int,s.split('\\n'))).__contains__,range(5000)))", "def to_bits(string):\n \n input=sorted([int(x) for x in string.split(\"\\n\")])\n bitmap=[0]*5000\n for i in input:\n bitmap[i]=1\n return bitmap", "import numpy as np\ndef to_bits(string):\n arr = [int(s) for s in string.split('\\n')]\n bm = np.zeros(5000)\n for i in arr:\n bm[i] += 1*(1-bm[i])\n return list(bm)", "def to_bits(string):\n numbers = set(int(s) for s in string.split())\n return [(0,1)[n in numbers] for n in range(5000)]\n", "def to_bits(string):\n ret = [0] * 5000\n for i in string.split('\\n'):\n ret[int(i)] = 1\n return ret", "def to_bits(string):\n a=list(string)\n words = [w.replace('\\n', ' ') for w in a]\n b=''.join(words)\n lst=b.split(' ')\n lst2=[]\n for x in lst:\n if x.isdigit():\n lst2.append(x )\n# print(lst2) \n lst3 = [int(i) for i in lst2]\n lst3.sort()\n max(lst3)\n print(len(lst3))\n print( (lst3))\n a=[]\n for x in range(5000):\n a.append(0)\n len(a) \n for i in range(len(lst3)):\n a[lst3[i]]=1 \n print(sum(a))\n return a "] | {"fn_name": "to_bits", "inputs": [["4814\n3815\n54\n2747\n1449\n1880\n1109\n4942\n1646\n1750\n2933\n963\n1757\n137\n4100\n2188\n2487\n3027\n1771\n1223\n4458\n2755\n247\n3975\n2125\n1071\n3967\n3557\n2741\n3052\n2013\n4741\n4501\n975\n1194\n2352\n3548\n3436\n462\n2990\n1072\n53\n920\n3028\n3648\n2928\n4186\n2057\n3238\n3020\n1802\n2160\n4898\n398\n4854\n1665\n3136\n1693\n3911\n4895\n4446\n2028\n4409\n2181\n1967\n1439\n1217\n4123\n4851\n3372\n4544\n4377\n586\n1161\n913\n378\n4897\n2480\n3095\n2384\n2856\n2963\n1234\n3298\n4035\n4528\n782\n4253\n1367\n3122\n4326\n1573\n4495\n1546\n607\n2430\n1287\n501\n471\n3022\n3343\n1221\n3015\n748\n3043\n2349\n2901\n3760\n1796\n4753\n2444\n4798\n1355\n3066\n3788\n1656\n2431\n2162\n627\n3194\n1063\n3819\n3381\n4958\n3\n4474\n2217\n4193\n3705\n3708\n1804\n4678\n2249\n4948\n2392\n3906\n2695\n1336\n3254\n3447\n4698\n1902\n3386\n3182\n1420\n2693\n3493\n4756\n11\n2761\n3006\n787\n919\n2627\n3082\n2425\n1584\n1189\n4127\n446\n2786\n3072\n3754\n3954\n1419\n2824\n4179\n3551\n1330\n4675\n74\n3598\n3341\n2509\n334\n1878\n1294\n4002\n4293\n4478\n1666\n4221\n1075\n1364\n2018\n3592\n281\n1070\n2409\n2279\n1293\n3135\n297\n2117\n1982\n3868\n4438\n902\n4338\n1981\n4105\n4286\n2176\n2519\n684\n354\n4356\n1871\n2007\n721\n4584\n4517\n2184\n4460\n2316\n395\n2994\n2081\n2344\n758\n3477\n4363\n246\n4380\n1110\n3481\n4310\n1589\n4533\n4810\n445\n1291\n3973\n4077\n669\n1219\n1969\n1047\n3542\n2920\n269\n4256\n4836\n4181\n2940\n4927\n3473\n180\n3955\n9\n3265\n959\n3907\n4373\n1733\n3347\n4042\n348\n1579\n2380\n1012\n185\n4671\n1486\n614\n2498\n3659\n4632\n4344\n811\n275\n4488\n3645\n1583\n4275\n503\n3862\n3545\n3795\n3696\n3457\n576\n1062\n4073\n1548\n514\n1654\n4047\n716\n1398\n792\n2059\n310\n1297\n3960\n2915\n1674\n1767\n3069\n1093\n2422\n807\n3531\n1381\n2030\n3099\n2560\n2891\n513\n1861\n879\n4306\n3618\n700\n2633\n2779\n1431\n3200\n2731\n218\n4324\n4977\n754\n1464\n2241\n3261\n2721\n4548\n1350\n254\n3442\n2033\n3495\n4516\n276\n3731\n3505\n4065\n4611\n211\n1347\n2387\n3844\n1001\n402\n113\n3995\n1187\n3470\n4680\n2903\n2246\n2390\n868\n539\n4510\n733\n3227\n2157\n3067\n4252\n4283\n1603\n2645\n2759\n3797\n1737\n3919\n2781\n918\n88\n2743\n2810\n4119\n4988\n4051\n2486\n1738\n127\n2271\n2692\n542\n4316\n2837\n1829\n465\n1704\n2811\n4405\n752\n3273\n4289\n525\n1922\n4468\n3116\n3237\n2947\n2268\n1144\n756\n4566\n3041\n2191\n2111\n4434\n280\n4890\n1595\n1953\n2651\n4547\n1875\n1765\n240\n1177\n1095\n4410\n1935\n3317\n678\n4411\n1027\n650\n1033\n120\n4369\n3479\n224\n1550\n3439\n2222\n2008\n1102\n906\n2807\n4681\n4860\n2705\n2726\n2816\n4623\n982\n1363\n1907\n1908\n909\n2002\n3848\n4284\n2568\n1163\n1299\n2103\n3969\n1460\n3849\n4961\n1891\n2411\n4943\n2183\n3593\n2889\n1662\n1897\n4783\n4899\n225\n4133\n3543\n778\n3032\n4345\n4598\n2303\n3145\n3229\n96\n4778\n489\n38\n3476\n1799\n2284\n895\n4330\n3710\n1961\n4978\n679\n3279\n1842\n2285\n1643\n1182\n4996\n1351\n3738\n2548\n937\n4767\n510\n2964\n724\n1129\n4419\n1089\n2518\n1791\n1845\n3930\n949\n2379\n903\n2886\n4383\n1487\n4770\n4171\n744\n2746\n1964\n435\n3577\n3289\n2136\n3073\n481\n2171\n4062\n4053\n2377\n293\n4842\n1609\n3475\n115\n4359\n3150\n2521\n2153\n230\n2458\n2122\n1725\n3634\n56\n82\n2378\n4789\n3276\n3913\n1370\n4523\n3307\n1376\n1519\n2540\n4751\n1940\n2189\n4115\n2141\n4219\n2090\n4194\n2000\n407\n1292\n4147\n3130\n984\n3417\n1360\n4183\n633\n4534\n2063\n4480\n846\n457\n1345\n1149\n1254\n2535\n764\n404\n2675\n3013\n353\n3236\n2\n3791\n2753\n1590\n1994\n3903\n3518\n1154\n4120\n2365\n4542\n4880\n4040\n3446\n1184\n916\n2232\n922\n4342\n3524\n4875\n3739\n4717\n1079\n4378\n3986\n1146\n818\n3615\n1083\n3201\n3872\n2210\n287\n3964\n1205\n28\n3935\n1760\n381\n1421\n455\n2017\n2857\n3019\n1856\n4278\n3892\n2347\n858\n4574\n8\n3054\n1256\n4802\n1430\n2909\n4832\n1119\n278\n1343\n2152\n4873\n1170\n3660\n3697\n2936\n1014\n2479\n2871\n1743\n3809\n2305\n3246\n1280\n958\n2939\n3751\n3410\n4659\n1158\n2744\n3517\n3206\n2307\n936\n2832\n329\n4061\n3669\n192\n330\n4620\n1436\n2292\n558\n313\n3884\n2185\n1045\n105\n2682\n59\n504\n4003\n2532\n4212\n2459\n2394\n3049\n3823\n1393\n4740\n4325\n1011\n4762\n3899\n80\n4224\n556\n274\n1968\n2192\n4011\n387\n4928\n175\n109\n1446\n4056\n2120\n3233\n2902\n4169\n129\n2438\n3992\n2072\n249\n1048\n1932\n749\n1111\n1618\n4074\n2449\n1801\n4264\n4722\n722\n1503\n4323\n670\n3945\n4785\n2829\n253\n3978\n232\n3331\n3575\n1976\n3537\n2251\n4437\n492\n2388\n444\n79\n51\n3187\n2691\n2322\n73\n664\n1298\n2999\n552\n3818\n1476\n801\n4159\n3040\n2696\n4755\n3968\n3449\n4705\n3059\n1276\n1574\n901\n541\n1127\n3861\n2110\n1999\n1058\n877\n1380\n1302\n4793\n351\n87\n681\n494\n2067\n4957\n3774\n4910\n4469\n3636\n181\n2051\n1529\n4299\n3300\n4350\n2336\n4004\n3860\n4806\n1661\n4392\n1895\n1638\n4670\n454\n588\n2265\n4850\n263\n3958\n657\n4914\n4163\n803\n58\n2035\n2968\n4684\n3559\n3078\n4444"], ["1\n2398\n936\n1585\n4947\n2834\n3459\n4419\n3938\n205\n3350\n1272\n1936\n1474\n2159\n3541\n1792\n947\n3009\n1218\n4933\n4828\n742\n472\n786\n3294\n732\n1724\n3614\n983\n1025\n870\n2301\n2984\n2378\n1723\n3652\n2438\n3490\n3550\n1241\n72\n2437\n2161\n3338\n1073\n1041\n2228\n909\n2368\n348\n3306\n1370\n875\n4123\n693\n4480\n3800\n2429\n2588\n2376\n1972\n1224\n1645\n1116\n3197\n1841\n2583\n2208\n3240\n2389\n2200\n2042\n1410\n2404\n3626\n329\n1269\n2065\n1668\n4489\n4063\n1279\n1330\n4377\n4200\n3382\n3033\n3239\n3552\n3899\n2436\n835\n3654\n3136\n386\n2699\n4695\n2114\n1673\n217\n1739\n4098\n2484\n2495\n2410\n1322\n3933\n725\n1385\n1952\n325\n4341\n1047\n1342\n4804\n3022\n1310\n3805\n4733\n4286\n176\n1367\n4746\n2906\n686\n1226\n2640\n1913\n1242\n178\n450\n4187\n1594\n2921\n1290\n2017\n669\n3959\n1529\n1964\n3591\n970\n3590\n24\n3572\n2348\n2317\n1731\n3878\n4444\n1851\n2483\n4588\n2237\n315\n2078\n609\n1214\n4387\n1794\n948\n3397\n106\n3555\n950\n4137\n1377\n2186\n1219\n3120\n55\n3940\n807\n3980\n1762\n1869\n3359\n3419\n3864\n1464\n222\n4047\n1174\n1060\n3075\n3235\n563\n1490\n3433\n1467\n181\n646\n4814\n17\n1376\n2809\n4509\n3055\n2934\n670\n2123\n4954\n1991\n2988\n314\n3728\n3986\n3765\n708\n3246\n3484\n705\n1957\n3345\n3061\n3796\n3283\n124\n1798\n3218\n3018\n527\n4224\n4464\n2356\n4963\n1515\n3545\n1709\n3327\n1185\n1425\n465\n4146\n4945\n1786\n3758\n2972\n3958\n1172\n4667\n2435\n566\n1040\n4011\n4455\n722\n3100\n2589\n3181\n3047\n4575\n3277\n3476\n273\n2728\n3939\n899\n3992\n2789\n4721\n3670\n3825\n4815\n2453\n3517\n3301\n409\n1778\n3566\n1783\n1569\n4735\n2444\n158\n3499\n4372\n2731\n3618\n396\n2803\n3824\n2775\n4680\n4901\n111\n2552\n202\n4203\n4149\n935\n1836\n4281\n615\n310\n819\n366\n3111\n3979\n1857\n3257\n3281\n828\n868\n4259\n1962\n1457\n3837\n4870\n4637\n1317\n2307\n420\n2434\n1632\n971\n3576\n2193\n2119\n840\n2769\n4328\n3104\n4616\n22\n26\n1391\n3636\n2375\n3960\n216\n1868\n2416\n2606\n2958\n215\n3567\n1942\n1811\n2935\n2519\n2514\n4942\n1358\n2695\n227\n531\n2770\n4792\n508\n3255\n616\n54\n4957\n272\n3188\n661\n2028\n3105\n841\n1627\n3213\n361\n92\n4335\n3782\n2931\n424\n1698\n1459\n1484\n4824\n658\n2911\n4056\n2999\n984\n4196\n2790\n3679\n0\n1160\n887\n2477\n1324\n4623\n4634\n1000\n2060\n4629\n3318\n36\n3430\n4879\n4662\n2226\n434\n529\n4992\n999\n904\n1462\n2062\n3225\n2608\n1547\n157\n3151\n619\n2601\n385\n132\n3048\n1995\n2449\n3030\n3084\n2473\n3723\n1630\n3357\n4433\n3095\n4061\n86\n4345\n2882\n4686\n4327\n2747\n4837\n1603\n3117\n518\n1504\n3456\n1984\n4617\n827\n3817\n958\n1068\n768\n2922\n1593\n2876\n1735\n1133\n873\n4186\n4847\n4002\n2844\n3092\n326\n771\n1020\n2892\n4770\n3341\n1558\n3082\n275\n608\n479\n119\n3519\n583\n2236\n1602\n4868\n1095\n188\n3165\n2058\n1949\n2766\n279\n4926\n4418\n865\n1563\n3126\n3754\n3473\n2080\n3025\n1697\n2138\n3416\n2020\n2049\n2286\n4354\n3962\n2194\n3709\n3278\n1642\n2448\n3676\n885\n3207\n545\n448\n2917\n3044\n10\n141\n3262\n3323\n1624\n122\n1521\n2327\n3203\n967\n1109\n2890\n2819\n138\n831\n2722\n4930\n4\n247\n1097\n2908\n611\n1641\n4436\n3972\n993\n1460\n4398\n2566\n4392\n1365\n1977\n4626\n3089\n4586\n498\n2115\n2311\n1835\n853\n588\n4540\n3096\n1883\n4983\n2354\n194\n3427\n2284\n2486\n4628\n2413\n477\n1077\n1576\n1471\n3143\n168\n2027\n1334\n3354\n1676\n3180\n4325\n4394\n4293\n4162\n2340\n2302\n1262\n3140\n2314\n4784\n1043\n712\n4606\n1239\n2550\n1380\n1901\n4072\n3849\n219\n4482\n4125\n515\n4399\n1975\n4896\n4442\n2380\n1559\n3691\n3886\n1970\n937\n1071\n333\n2498\n1442\n49\n536\n943\n3687\n2336\n3492\n3509\n3332\n18\n1393\n3315\n2085\n2729\n3006\n1785\n3721\n3220\n4812\n4443\n2916\n4638\n4819\n2981\n3479\n163\n3911\n4817\n3193\n3449\n252\n3260\n1584\n129\n2388\n4322\n3935\n1566\n2982\n2418"], ["2331\n2073\n453\n4666\n4615\n2780\n452\n2172\n1534\n1428\n4319\n2381\n3130\n2097\n2349\n1435\n195\n3892\n640\n4859\n3908\n102\n2026\n2230\n2775\n2254\n1628\n2733\n3364\n3169\n1636\n3589\n1331\n2232\n3149\n3191\n2374\n1940\n3792\n4139\n808\n2344\n4306\n353\n4760\n220\n4477\n4736\n4301\n3953\n1220\n2065\n2240\n4851\n1734\n4395\n797\n1158\n1866\n3138\n3267\n2308\n4285\n3970\n2924\n2935\n3590\n632\n899\n4843\n601\n1768\n4458\n1113\n627\n4446\n2472\n2743\n3894\n3438\n3148\n1772\n3478\n474\n1787\n4889\n1492\n3882\n2974\n2631\n2264\n3443\n3274\n2360\n2142\n2973\n1825\n3592\n4231\n3471\n2297\n2221\n2054\n3899\n1387\n1175\n1287\n2061\n4369\n1094\n4279\n713\n3329\n1018\n2339\n2820\n4277\n480\n29\n2825\n316\n1830\n163\n1630\n387\n4141\n4733\n4266\n4931\n4586\n2686\n2329\n1580\n2747\n2949\n2501\n3315\n2808\n4806\n3358\n2970\n566\n3638\n3645\n1243\n3265\n4030\n661\n1478\n376\n3971\n1049\n4294\n2443\n2952\n1014\n3234\n1196\n4617\n4350\n4637\n578\n2236\n885\n1105\n2556\n2402\n3825\n4628\n4307\n950\n3497\n4354\n911\n341\n4549\n1522\n744\n3403\n1144\n141\n4220\n4074\n700\n2910\n479\n4362\n2649\n1497\n3135\n1064\n4802\n2547\n915\n3799\n3141\n937\n432\n675\n1649\n1912\n1885\n2774\n2954\n4917\n436\n2495\n1720\n524\n1526\n681\n4116\n4213\n2734\n2784\n2867\n2340\n1691\n1737\n3333\n3801\n4225\n4348\n2093\n1679\n966\n3608\n2399\n2955\n628\n142\n196\n3227\n912\n2577\n2301\n104\n3355\n4351\n2140\n4611\n528\n2879\n3978\n4156\n2030\n2764\n2298\n4656\n3021\n3961\n4237\n4516\n2213\n3927\n3985\n2307\n3071\n827\n3348\n4948\n1400\n3194\n1620\n4533\n4206\n2186\n1140\n97\n1089\n2770\n3061\n4727\n1284\n1341\n1582\n3057\n1136\n2666\n3715\n26\n23\n424\n1001\n892\n1157\n849\n1897\n4462\n3189\n3272\n332\n2725\n1289\n2459\n3342\n347\n2613\n2792\n1135\n1120\n531\n591\n3854\n1070\n646\n3850\n3222\n96\n3869\n935\n3767\n522\n4535\n2247\n442\n3591\n194\n957\n4942\n953\n745\n1372\n4384\n3353\n2748\n1779\n1803\n3735\n3809\n1186\n2816\n1309\n1395\n411\n1265\n4130\n3056\n399\n3213\n2622\n4094\n3618\n181\n4735\n2869\n3415\n3383\n4862\n2012\n1081\n3910\n3819\n4793\n3499\n3079\n1923\n2575\n2076\n775\n1774\n2190\n989\n245\n1296\n788\n818\n2215\n1990\n1515\n4983\n649\n3425\n4979\n478\n1262\n2460\n2137\n854\n616\n4409\n4110\n759\n2286\n350\n633\n4180\n2996\n3352\n781\n1699\n3669\n1030\n1922\n1162\n200\n3828\n60\n2480\n3599\n4324\n2904\n1716\n3203\n4649\n554\n460\n4657\n959\n877\n2755\n128\n4430\n1889\n1813\n998\n4228\n2671\n310\n889\n2223\n1233\n2108\n4779\n4376\n3709\n1926\n2818\n4746\n1348\n2912\n3805\n3627\n2643\n4847\n4465\n3337\n4686\n183\n3225\n920\n3879\n3762\n3833\n4380\n4525\n487\n3940\n3924\n2019\n4163\n1091\n4245\n2801\n435\n4177\n2465\n4528\n2614\n1008\n3613\n1689\n2252\n2899\n2333\n2488\n1765\n4883\n4399\n4781\n1119\n3720\n3721\n2328\n1306\n4741\n879\n2836\n4028\n3089\n1353\n3434\n2785\n1611\n1697\n1086\n3002\n1747\n3254\n3701\n4088\n2062\n2014\n3597\n2602\n3198\n1203\n2474\n307\n3580\n3086\n4142\n3150\n1521\n504\n1953\n224\n1735\n3918\n2985\n3247\n4049\n3849\n32\n1831\n2388\n3888\n2873\n2225\n648\n1867\n1520\n1609\n3541\n3489\n259\n3374\n3405\n3190\n4168\n611\n4289\n1559\n1417\n481\n2964\n3842\n2293\n3653\n24\n553\n954\n3868\n492\n3917\n1079\n2032\n4585\n2361\n3815\n2159\n4786\n1827\n4981\n2983\n2585\n776\n814\n408\n2601\n2553\n4327\n1080\n3784\n4144\n3448\n1904\n1093\n2050\n4003\n2844\n4709\n2471\n2754\n330\n4985\n945\n1444\n4675\n1166\n3099\n3092\n57\n1165\n2789\n3984\n2102\n845\n992\n495\n2285\n2277\n4100\n3309\n4713\n1581\n4882\n1459\n1261\n4053\n2302\n3078\n2628\n3375\n964\n3076\n349\n3017\n4596\n2189\n1019\n1995\n2067\n1570\n2635\n1707\n4810\n119\n4120\n770"], ["1948\n2520\n312\n1158\n3435\n4792\n2315\n1725\n2099\n1363\n2586\n1791\n2325\n4588\n2379\n336\n4027\n4514\n236\n1633\n2472\n3285\n1578\n40\n2791\n2581\n892\n3242\n2253\n2767\n2221\n167\n3683\n3298\n2655\n293\n4803\n1191\n3859\n1241\n1570\n3741\n744\n1392\n2172\n1113\n3913\n1156\n3169\n2635\n1512\n409\n1875\n2745\n4646\n596\n2595\n2563\n1310\n1915\n1686\n2393\n2712\n1584\n1300\n2569\n3192\n3128\n2730\n4044\n4451\n4661\n423\n1882\n4104\n1047\n3694\n147\n357\n2115\n3245\n3494\n4710\n433\n2490\n3814\n3528\n3486\n368\n750\n2278\n4592\n3308\n1756\n4115\n1794\n4672\n2189\n3871\n2468\n1692\n3557\n2733\n4785\n1243\n4640\n4389\n1477\n3432\n1248\n2380\n507\n1747\n4365\n4621\n1433\n4914\n4267\n273\n4406\n3763\n1659\n1709\n4408\n3296\n3940\n2851\n3786\n632\n4167\n3559\n1273\n406\n2340\n2323\n3982\n3384\n260\n1116\n1390\n4359\n3166\n3271\n3019\n1656\n495\n609\n4994\n4170\n276\n3373\n2772\n1952\n4094\n4688\n1611\n308\n1789\n229\n4130\n2515\n1720\n3200\n513\n3853\n1694\n2844\n4633\n3929\n1658\n3516\n4909\n3003\n3574\n4432\n68\n2652\n2947\n4804\n850\n2534\n1745\n573\n838\n588\n884\n3080\n1792\n1377\n1802\n1552\n2175\n3291\n3445\n516\n784\n590\n3548\n2588\n1672\n224\n2264\n3923\n3024\n3036\n364\n1812\n2865\n4774\n4645\n4605\n3661\n2013\n4053\n2528\n3586\n779\n1664\n1616\n4366\n1251\n2817\n3254\n777\n534\n3843\n1776\n4209\n752\n3637\n272\n3750\n401\n4951\n1381\n3813\n968\n320\n3928\n2832\n2084\n1978\n4763\n1253\n1574\n2639\n3066\n3195\n963\n853\n964\n2667\n1715\n1425\n3579\n2093\n2030\n1164\n2200\n1630\n3816\n1205\n2657\n1157\n4797\n741\n4230\n4191\n910\n945\n2584\n3615\n1522\n1958\n1212\n3762\n405\n4776\n2079\n3009\n904\n3693\n4129\n2797\n3960\n2021\n3121\n2944\n3334\n2077\n946\n4346\n1450\n2443\n1454\n645\n1295\n1666\n1255\n755\n3427\n2473\n4441\n4686\n2834\n4051\n3398\n3675\n2703\n18\n3332\n4048\n2299\n2442\n3621\n1736\n4918\n422\n175\n864\n3876\n2984\n4614\n4297\n390\n2405\n2754\n4174\n2580\n514\n2165\n436\n1452\n4169\n3207\n2327\n2574\n1502\n2555\n4595\n3147\n4529\n1391\n1247\n148\n4608\n2525\n3836\n2187\n2133\n4965\n4899\n2524\n100\n1734\n3686\n297\n3520\n4378\n3927\n3766\n3185\n2928\n131\n3426\n3031\n1372\n166\n4701\n3590\n4091\n3001\n1341\n3973\n192\n217\n4177\n2232\n2459\n1911\n484\n3354\n2597\n3476\n1907\n3369\n2214\n672\n1230\n4290\n2005\n3888\n2803\n3697\n2492\n980\n4236\n2136\n2281\n1644\n1927\n4746\n468\n476\n4583\n2371\n4988\n1133\n4980\n3294\n57\n4329\n1207\n2522\n3138\n4655\n4811\n1274\n437\n3319\n128\n1168\n785\n3562\n1870\n314\n2919\n2937\n554\n3609\n2101\n3659\n3481\n2755\n3401\n1084\n358\n3842\n2360\n2669\n1343\n1415\n462\n3350\n4532\n4959\n2100\n2085\n4707\n3681\n2543\n4197\n1743\n3484\n1374\n962\n3451\n3931\n606\n932\n1224\n4889\n993\n756\n989\n1964\n458\n694\n687\n2825\n188\n919\n4192\n3461\n4086\n3108\n1400\n4077\n4508\n356\n3378\n708\n562\n218\n2111\n1750\n3188\n903\n3054\n4881\n4736\n3501\n2795\n3912\n8\n348\n571\n3233\n2717\n2789\n4534\n1291\n2924\n3639\n1088\n1777\n118\n2009\n4102\n3589\n2177\n1459\n448\n828\n576\n207\n560\n2605\n3098\n3270\n2977\n2511\n2305\n1554\n936\n1138\n116\n1839\n2614\n498\n3071\n151\n124\n3837\n3130\n2110\n3546\n2501\n3936\n1148\n3084\n1288\n2723\n2231\n824\n1100\n1178\n652\n4309\n2257\n3247\n1373\n3953\n1708\n2489\n2096\n4539\n457\n2678\n2424\n2582\n2687\n2885\n4594\n1005\n2202\n453\n1440\n3183\n3089\n1576\n2769\n2107\n2576\n4584\n529\n898\n4323\n1085\n3829\n4237\n882\n36\n2503\n1909\n2814\n3326\n4345\n3488\n1504\n3551\n1567\n1600\n366\n1645\n511\n3239\n1986\n4906\n847\n4489\n2422\n2343\n3943\n2428\n4152\n4405\n4143\n1726\n2537\n2292\n2736\n4730\n2357\n3198\n4310\n4585\n4132\n3708\n4986\n4648\n1214\n4699\n1356\n3556"], ["3005\n1889\n3023\n171\n1294\n3464\n1370\n214\n3660\n729\n2414\n1759\n1133\n4679\n4983\n2179\n2757\n2993\n2389\n4288\n4247\n3635\n2792\n1633\n4353\n3429\n386\n458\n4541\n1729\n2392\n1001\n1685\n786\n4820\n52\n4519\n1438\n701\n121\n3265\n3985\n2192\n1059\n3973\n1105\n2859\n2908\n3114\n749\n3121\n2713\n3662\n3817\n1388\n996\n3240\n1583\n4022\n1993\n1008\n3907\n1531\n2207\n3883\n3346\n3939\n4574\n3082\n2064\n2238\n2632\n3131\n1079\n1516\n3016\n4734\n297\n348\n338\n1385\n3358\n2439\n165\n723\n2567\n1271\n2899\n1440\n3982\n4932\n614\n782\n4817\n1407\n3910\n1842\n405\n35\n3872\n3682\n3922\n1414\n92\n4591\n1797\n4662\n1286\n893\n3489\n2456\n2212\n3129\n3595\n2098\n4572\n2369\n3989\n3252\n2520\n2249\n4995\n4730\n1658\n3524\n4885\n1170\n3066\n193\n3558\n4119\n1659\n3383\n2691\n692\n1128\n2594\n1826\n2053\n1083\n3832\n3185\n395\n3958\n802\n2512\n3085\n478\n1022\n654\n482\n1442\n2771\n507\n2891\n403\n2673\n3730\n2152\n3700\n934\n679\n2944\n2730\n4386\n4435\n3445\n4585\n2406\n3966\n4384\n3957\n3178\n3931\n134\n717\n2685\n3330\n4186\n3191\n2218\n2501\n4842\n1913\n1891\n3859\n486\n1403\n2904\n3895\n4736\n2002\n4810\n2981\n1483\n3430\n580\n1416\n4934\n4511\n334\n3912\n2068\n4735\n2844\n896\n1899\n4301\n3144\n529\n2895\n1985\n3298\n1457\n1297\n834\n3992\n2823\n993\n1107\n2529\n90\n642\n2871\n3819\n267\n146\n953\n4284\n3964\n1906\n2063\n3948\n3995\n3787\n1443\n1453\n1773\n1665\n4053\n497\n304\n4158\n3146\n938\n652\n3521\n3466\n2347\n3887\n2638\n1393\n2050\n3791\n713\n1149\n4518\n1692\n4105\n759\n4619\n2616\n2651\n3917\n1291\n4624\n2829\n3633\n1210\n1554\n4610\n926\n1740\n4733\n4666\n2560\n3959\n4605\n36\n1037\n1750\n2932\n3132\n2231\n4898\n3715\n1749\n4199\n2182\n3955\n2365\n2841\n418\n506\n1257\n4556\n2650\n1283\n1202\n107\n3079\n3845\n2330\n1833\n3596\n2858\n4931\n3904\n857\n4740\n2686\n377\n4007\n4686\n901\n862\n4927\n1754\n1452\n4477\n3281\n2788\n3173\n3234\n3679\n3324\n3357\n4365\n4803\n1839\n2461\n3864\n1312\n4979\n693\n2161\n355\n339\n4760\n1207\n2324\n4886\n2490\n4548\n2825\n919\n2119\n4003\n2468\n3056\n891\n4629\n1532\n4772\n2970\n1736\n87\n975\n3386\n3071\n4492\n4527\n3414\n2225\n4805\n4678\n158\n2071\n1923\n4239\n2696\n1439\n2782\n2431\n1791\n1100\n2664\n779\n410\n1087\n2371\n3193\n3471\n4094\n1191\n460\n1154\n1252\n4481\n3513\n1918\n1218\n2346\n2430\n2526\n3642\n1863\n4891\n441\n368\n3313\n3389\n2012\n59\n4606\n3084\n86\n1433\n3091\n2029\n1919\n4846\n4894\n2787\n3671\n2404\n1751\n1605\n82\n928\n2200\n341\n3221\n4058\n167\n912\n32\n3482\n879\n4044\n3766\n2362\n473\n797\n1695\n3983\n3637\n2226\n727\n2146\n2668\n399\n3798\n3977\n2934\n3021\n2672\n2137\n922\n4070\n4015\n2445\n1976\n2692\n1654\n2208\n2677\n3519\n1622\n3366\n131\n4162\n766\n2090\n525\n1498\n588\n48\n1069\n2630\n1049\n3326\n3308\n1999\n2162\n1036\n4061\n4943\n152\n3297\n3113\n4569\n3851\n1051\n947\n1655\n2991\n2385\n1859\n696\n2494\n3503\n1003\n1734\n4175\n3855\n944\n1199\n422\n1959\n754\n3629\n4103\n4204\n3382\n3115\n4962\n4090\n961\n3392\n2922\n156\n4658\n3086\n3538\n2250\n4218\n2933\n2124\n940\n1352\n706\n3424\n1429\n3040\n490\n728\n3379\n4431\n415\n623\n720\n4367\n4252\n4649\n1323\n4196\n3546\n3548\n4531\n4460\n4220\n4594\n1238\n3598\n1382\n2887\n2074\n1346\n4354\n323\n177\n181\n2327\n2962\n1565\n2764\n4077\n1078\n402\n503\n2449\n2354\n3181\n2633\n4173\n1044\n1448\n1458\n4575\n1515\n831\n672\n3776\n4341\n2517\n4387\n3407\n1309\n2409\n1265\n241\n4342\n4213\n1597\n684\n3138\n1467\n889\n882\n3248\n2416\n3103\n145\n2740\n2169\n72\n1259\n252\n3607\n789\n3648\n4908\n3488\n2808\n575\n4539\n1737\n1475\n695\n2856\n4364\n3223\n3368\n1777\n633\n442\n2607\n1778\n4750\n1365\n66\n3460\n4338\n2195\n1487\n4582\n3780\n1555\n4200\n1054\n1502\n2319\n545\n2801\n3038\n2277\n4130\n619\n239\n550\n3550\n260\n1093\n2302\n3390\n4871\n3431\n2931\n3893\n3853\n3805\n634\n2400\n4647\n205\n162\n2712\n4862\n371\n2117\n4831\n4207\n1961\n3755\n4350\n4568\n2263\n4496\n930\n760"]], "outputs": [[[0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 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, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,558 |
def to_bits(string):
|
f582188caf3f9cf06f92c7d2747d21d3 | UNKNOWN | Some new cashiers started to work at your restaurant.
They are good at taking orders, but they don't know how to capitalize words, or use a space bar!
All the orders they create look something like this:
`"milkshakepizzachickenfriescokeburgerpizzasandwichmilkshakepizza"`
The kitchen staff are threatening to quit, because of how difficult it is to read the orders.
Their preference is to get the orders as a nice clean string with spaces and capitals like so:
`"Burger Fries Chicken Pizza Pizza Pizza Sandwich Milkshake Milkshake Coke"`
The kitchen staff expect the items to be in the same order as they appear in the menu.
The menu items are fairly simple, there is no overlap in the names of the items:
```
1. Burger
2. Fries
3. Chicken
4. Pizza
5. Sandwich
6. Onionrings
7. Milkshake
8. Coke
``` | ["def get_order(order):\n menu = ['burger', 'fries', 'chicken', 'pizza', 'sandwich', 'onionrings', 'milkshake', 'coke']\n clean_order = ''\n for i in menu:\n clean_order += (i.capitalize() + ' ') * order.count(i)\n return clean_order[:-1]", "MENU = [\"Burger\", \"Fries\", \"Chicken\", \"Pizza\", \"Sandwich\", \"Onionrings\", \"Milkshake\", \"Coke\"]\n\ndef get_order(order):\n result = []\n for item in MENU:\n result.extend([item for _ in range(order.count(item.lower()))])\n return \" \".join(result)", "menu = \"Burger Fries Chicken Pizza Sandwich Onionrings Milkshake Coke\".split()\n\ndef get_order(order):\n return \" \".join(item for item in menu for _ in range(order.count(item.lower())))\n", "def get_order(order):\n output=\"\"\n while order != \"\":\n if output==\"\":\n if order.find(\"burger\") != -1:\n output+=\"Burger\"\n order=order.replace(\"burger\",\"\", 1)\n elif order.find(\"fries\") != -1:\n output+=\"Fries\"\n order=order.replace(\"fries\",\"\",1)\n elif order.find(\"chicken\") != -1:\n output+=\"Chicken\"\n order=order.replace(\"chicken\",\"\",1)\n elif order.find(\"pizza\") != -1:\n output+=\"Pizza\"\n order=order.replace(\"pizza\",\"\",1)\n elif order.find(\"sandwich\") != -1:\n output+=\"Sandwich\"\n order=order.replace(\"sandwich\",\"\",1)\n elif order.find(\"onionrings\") != -1:\n output+=\"Onionrings\"\n order=order.replace(\"onionrings\",\"\",1)\n elif order.find(\"milkshake\") != -1:\n output+=\"Milkshake\"\n order=order.replace(\"milkshake\",\"\",1)\n elif order.find(\"coke\") != -1:\n output+=\"Coke\"\n order=order.replace(\"coke\",\"\",1)\n elif output!=\"\":\n if order.find(\"burger\") != -1:\n output+=\" Burger\"\n order=order.replace(\"burger\",\"\",1)\n elif order.find(\"fries\") != -1:\n output+=\" Fries\"\n order=order.replace(\"fries\",\"\",1)\n elif order.find(\"chicken\") != -1:\n output+=\" Chicken\"\n order=order.replace(\"chicken\",\"\",1)\n elif order.find(\"pizza\") != -1:\n output+=\" Pizza\"\n order=order.replace(\"pizza\",\"\",1)\n elif order.find(\"sandwich\") != -1:\n output+=\" Sandwich\"\n order=order.replace(\"sandwich\",\"\",1)\n elif order.find(\"onionrings\") != -1:\n output+=\" Onionrings\"\n order=order.replace(\"onionrings\",\"\",1)\n elif order.find(\"milkshake\") != -1:\n output+=\" Milkshake\"\n order=order.replace(\"milkshake\",\"\",1)\n elif order.find(\"coke\") != -1:\n output+=\" Coke\"\n order=order.replace(\"coke\",\"\",1)\n return output", "import re\n\nMENU = {v:i for i,v in enumerate(\"Burger Fries Chicken Pizza Sandwich Onionrings Milkshake Coke\".split())}\nREG_CMD = re.compile('|'.join(MENU), flags=re.I)\n\ndef get_order(order):\n return ' '.join(sorted( map(str.title, REG_CMD.findall(order)),\n key=MENU.get ))", "from re import findall\n\ndef get_order(order):\n menu = ['Burger','Fries','Chicken','Pizza','Sandwich','Onionrings','Milkshake','Coke']\n return ' '.join(filter(None, (' '.join(findall(item.lower(), order)).title() for item in menu)))", "def get_order(order):\n menu, Menu = [\"burger\", \"fries\", \"chicken\", \"pizza\", \"sandwich\", \"onionrings\", \"milkshake\", \"coke\"], [\"Burger\", \"Fries\", \"Chicken\", \"Pizza\", \"Sandwich\", \"Onionrings\", \"Milkshake\", \"Coke\"]\n str, num = \"\", 0\n lst, lst2, result = [], [], []\n for letter in order:\n str += letter\n if str in menu:\n lst.append(str)\n str = \"\"\n for word in lst:\n lst2.append(word.capitalize())\n for counter in range(0,8):\n for word in lst2:\n if word == Menu[counter]:\n result.append(word)\n return \" \".join(result)", "import re\n\nMENU = ['burger', 'fries', 'chicken', 'pizza', 'sandwich', 'onionrings', 'milkshake', 'coke']\n\ndef get_order(order):\n res = []\n for item in MENU:\n res.extend(re.findall(item, order))\n return ' '.join([item.capitalize() for item in res])", "get_order = lambda order: \"\".join([item*order.count(item[1:].lower()) for item in \" Burger, Fries, Chicken, Pizza, Sandwich, Onionrings, Milkshake, Coke\".split(',')])[1:]", "def get_order(order):\n menu = [\n \"Burger\",\n \"Fries\",\n \"Chicken\",\n \"Pizza\",\n \"Sandwich\",\n \"Onionrings\",\n \"Milkshake\",\n \"Coke\",\n]\n return \"\".join([(item + \" \") * order.count(item.lower()) for item in menu]).strip()", "def get_order(order):\n word =\"\"\n list = [\"Burger\" ,\"Fries\",\"Chicken\",\"Pizza\", \"Sandwich\",\"Onionrings\",\"Milkshake\",\"Coke\" ]\n for i in list:\n word = word+(\" \"+i)*order.count(i.lower())\n return word.strip()"] | {"fn_name": "get_order", "inputs": [["burgerfriesfriesfriesfriesfriespizzasandwichcokefriesburger"]], "outputs": [["Burger Burger Fries Fries Fries Fries Fries Fries Pizza Sandwich Coke"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 5,370 |
def get_order(order):
|
47473f925993dc73dc1854f8023529db | UNKNOWN | # Kata Task
You are given a list of cogs in a gear train
Each element represents the number of teeth of that cog
e.g. `[100, 50, 25]` means
* 1st cog has 100 teeth
* 2nd cog has 50 teeth
* 3rd cog has 25 teeth
If the ``nth`` cog rotates clockwise at 1 RPM what is the RPM of the cogs at each end of the gear train?
**Notes**
* no two cogs share the same shaft
* return an array whose two elements are RPM of the first and last cogs respectively
* use negative numbers for anti-clockwise rotation
* for convenience `n` is zero-based
* For C and NASM coders, the returned array will be `free`'d.
---
Series:
* Cogs
* Cogs 2 | ["def cog_RPM(cogs, n):\n return [\n cogs[n] / cogs[0] * (-1 if n % 2 else 1),\n cogs[n] / cogs[-1] * (1 if (len(cogs) - n) % 2 else -1),\n ]", "def cog_RPM(cogs, n):\n sign1 = -1 if n % 2 else 1\n sign2 = 1 if (len(cogs) - n) % 2 else -1\n return [sign1 * cogs[n] / cogs[0], sign2 * cogs[n] / cogs[-1]]", "def cog_RPM(l, i):\n return [(-1 + (i + 1) % 2 * 2) * l[i] / l[0], (-1 + (len(l) - i) % 2 * 2) * l[i] / l[-1]]", "def cog_RPM(cogs, n):\n a,b=1,1\n if n%2==1:\n a = -1\n if len(cogs)%2==n%2:\n b = -1\n return [a*cogs[n]/cogs[0],b*cogs[n]/cogs[-1]]", "def cog_RPM(cogs, n):\n return [cogs[n]/cogs[0] * (-1)**n, cogs[n]/cogs[-1] * (-1)**(len(cogs)-n-1)]", "def cog_RPM(cogs, n):\n output = []\n if n % 2 == 0:\n a = 1\n if (len(cogs) % 2-1) == 0:\n b = 1\n else:\n b = -1\n else:\n a = -1\n if (len(cogs)-1) % 2 == 0:\n b = -1\n else:\n b = 1\n output.append(cogs[n]/cogs[0]*a)\n output.append(cogs[n]/cogs[-1]*b)\n return output", "def cog_RPM(cogs, idx):\n first = cogs[idx] / cogs[0] * [1, -1][idx & 1]\n last = cogs[idx] / cogs[-1] * [1, -1][(len(cogs) - idx - 1) & 1]\n return [first, last]", "def cog_RPM(cogs, n):\n r=[cogs[n]/cogs[0],cogs[n]/cogs[-1]]\n if n%2==1:\n r[0]*=-1\n if (len(cogs)-n)%2==0:\n r[1]*=-1\n return r", "def cog_RPM(cogs, i):\n x, y = cogs[i] / cogs[0], cogs[i] / cogs[-1]\n if i & 1: x = -x\n if len(cogs) - 1 - i & 1: y = -y\n return [x, y]", "from functools import reduce\nfrom operator import mul\n\ndef cog_RPM(cogs, n):\n f = lambda l: 1 if len(l) < 2 else reduce(mul, [ -x/y for x,y in zip(l,l[1:]) ] )\n return [ f(cogs[:n+1][::-1]), f(cogs[n:]) ]"] | {"fn_name": "cog_RPM", "inputs": [[[100], 0], [[100, 100, 100, 100], 0], [[100, 100, 100, 100], 1], [[100, 100, 100, 100], 2], [[100, 100, 100, 100], 3]], "outputs": [[[1, 1]], [[1, -1]], [[-1, 1]], [[1, -1]], [[-1, 1]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,815 |
def cog_RPM(cogs, n):
|
cf2ddff57baad370c433310f308f2d54 | UNKNOWN | In this Kata we are passing a number (n) into a function.
Your code will determine if the number passed is even (or not).
The function needs to return either a true or false.
Numbers may be positive or negative, integers or floats.
Floats are considered UNeven for this kata. | ["def is_even(n): \n return n%2 == 0", "def is_even(n):\n\n#a modulos will return the whole number remainder of a division\n\n#using the modulos sign with 2 and another number will only return 0 and 1 \n\n#if the remainder of n and 2 is equal to 1 the number will be odd\n \n if (n % 2) == 1:\n return False\n \n #if the remainder of n and 2 is equal to 0 the number will be even\n \n elif (n % 2) == 0:\n return True \n \n #if n is not an integer (i.e a float) return False\n \n elif (n) != int: \n return False \n \n #Done ( \u0ca0 \u035c\u0296\u0ca0)\n", "is_even = lambda n: n % 2 == 0", "def is_even(n): \n return (isinstance(n,int) and n % 2 == 0)\n\n\n\n", "def is_even(n): \n output = False\n if n % 2 == 0:\n output = True\n return output", "def is_even(n): \n return type(n) != float and n % 2 == 0", "def is_even(n): \n if n % 2 == 0:\n return True\n else:\n return False", "def is_even(n): \n if n % 2 == 0:\n return True\n else:\n if n % 2 != 0:\n return False\n", "def is_even(n): \n if n % 2 == 0:\n return True\n if n % 2 != 0:\n return False\n", "def is_even(number): \n if isinstance(number, float):\n even = False\n else:\n result = number % 2\n even = not result\n return even", "def is_even(n): \n if isinstance(n, float):\n return False\n else:\n return not (n % 2)", "def is_even(n): \n if type(n) == float:\n return False\n if n % 2 == 0:\n return True\n return False", "def is_even(n):\n return n % 2 == 0 if type(n) == int else False", "def is_even(n): \n # your code here\n if type(n)!=int:\n return False\n elif n%2==1:\n return False\n else:\n return True", "def is_even(n): \n return True if n%2 == 0 and type(n) != float else False", "def is_even(n): \n return False if type(n)==float else n&1==0", "def is_even(n): \n return True if n//1 == n and n%2 - 1 else False", "def is_even(n): \n return True if (n/2).is_integer() else False", "def is_even(n): \n # your code here\n \n if type(n) == int and n % 2 == 0:\n return True\n else:\n return False", "is_even = lambda n: not n % 2", "def is_even(n): \n return False if n % 2 else True", "def is_even(n):\n return not n % 2", "def is_even(n): \n a = n/2\n if a.is_integer():\n return True\n else:\n return False", "def is_even(n): \n if n == 1:\n return False\n if n//2 == n/2:\n return True\n else:\n return False\n", "def is_even(n): \n if isinstance(n, int):\n if n % 2 == 0:\n return True\n return False", "def is_even(n): \n if n % 1 != 0: return False \n elif n % 2 == 0:\n return True\n else: \n return False", "def is_even(x):\n if x % 2==0:\n return True\n else:\n return False\n", "def is_even(n: int) -> bool:\n \"\"\" Check if given number is even. \"\"\"\n return not n % 2", "def is_even(n):\n try:\n return bin(n)[-1] == '0'\n except TypeError:\n return False", "def is_even(n): \n return type(n)==int and (n+1)%2", "def is_even(n): \n return False if isinstance(n, float) else not bool(n % 2)", "def is_even(n): \n \"\"\" This function returns True if 'n' is even else False. \"\"\"\n return True if n % 2 == 0 else False ", "def is_even(n): \n # your code here\n return True if 0==n%2 else False", "def is_even(n): \n return n % 2 == 0 if n is not type(float) else False", "def is_even(n): \n flag = False\n if(not(n % 2)):\n flag = True\n return flag", "def is_even(n): \n return n % 2 == 0 or n % -2 == 0\n", "def is_even(n): \n return False if n % 2 > 0 else True", "def is_even(n): \n return n%2 == False", "def is_even(n): \n return n % 2 == 0\n#pogchamp\n", "def is_even(n): \n if n % 2 == 0:\n return True\n else:\n return False\n#pogchamp\n", "def is_even(n): \n return type(n)==int and not n&1", "def is_even(n): \n return (n//2)*2==n", "def is_even(n):\n if (n==float):\n return False\n elif(n%2==0):\n return True\n elif(n%2!=0):\n return False\n \nprint((is_even(32)))\n", "def is_even(n): \n if n%2 == 0:# check if number divided by 2 has a remainder of zero\n return True\n else:\n return False\n \n pass", "def is_even(n): \n # your code here\n return not n&1 if type(n)==int else False", "import unittest\n\n\ndef is_even(n):\n return n % 2 == 0\n \n \nclass TestIsEven(unittest.TestCase):\n def test_is_even_with_even(self):\n self.assertTrue(is_even(4))\n\n def test_is_even_with_odd(self):\n self.assertFalse((is_even(5)))\n", "def is_even(n): \n if isinstance(n, int) is True:\n if n%2==0:\n return True\n else:\n return False\n else:\n return False", "def is_even(n): \n a = abs(n)\n if a % 2 == 0:\n return True\n else:\n return False", "def is_even(n): \n return type(n) is int and not n%2", "def is_even(n): \n return n%2 == 0 or False", "def is_even(n): \n \"\"\"(^__^)\"\"\"\n if n % 2 ==0:\n return True\n else:\n return False\n", "def is_even(n): \n return float(n)%2==0", "def is_even(n): \n if n % 2 == 0 and not isinstance(n, float):\n return True\n else:\n return False\n", "def is_even(n): \n if n %2 == 0:\n return n == n\n else:\n return n != n\n", "def is_even(n):\n return n % 2 == 0 or type(n) == type(float) \n", "def is_even(n): \n if n is float:\n return False\n elif n%2==0:\n return True\n else:\n return False\n pass", "def is_even(n):\n a = n / 2\n if a == int(a):\n return True\n else:\n return False", "def is_even(n): \n if isinstance(n, float): return False\n if n % 2 != 0: return False\n return True\n \n pass", "def is_even(n): \n return float(int(n % 2 ==0))", "def is_even(n):\n return not n & 1 if type(n) is int else False", "def is_even(n):\n if n % 2 == 0:\n return True\n elif n % 2 == 1 or n == float(n):\n return False\n", "def is_even(n):\n return n % 2 is 0", "def is_even(n): \n bool=False\n if n%2==0:\n bool=True\n return bool", "def is_even(n): \n print(n/2)\n if n % 2 == 0: return True\n else: return False", "def is_even(n):\n gg = int(n)\n if len(str(n))==len(str(gg)):\n if n%2==0:\n return True\n return False", "def is_even(n):\n n = abs(n)\n if isinstance(n, float) or n%2==1:\n return False\n else:\n return True", "def is_even(n): \n if n % 2 == 0 and type(n) != float:\n return True\n else:\n return False", "def is_even(n): \n while n > 0 or n < 0:\n if n % 2 == 0:\n return True\n else:\n return False\n if n == 0:\n return True\n", "def is_even(n): \n if n % 2 == 0: # your code here\n return (True)\n else:\n return (False)\nis_even(0)\n\n", "def is_even(n): \n return 1 if abs(n)%2==0 else 0\n", "def is_even(n): \n if isinstance(n, int):\n if abs(n) % 2 == 0:\n return True\n return False\n", "def is_even(n):\n return n%2 == 0 \n#CodeMast3f\n", "def is_even(n): \n return not n % 2 if not n % 1 else False", "def is_even(n): \n a = n % 2\n if a == 0:\n return True\n return False\n pass", "def is_even(n):\n even = True\n if (n % 2) > 0:\n even = False\n return False\n elif (n % 2) == 0:\n even = True\n return True\n", "def is_even(n):\n if n % 2 == 0:\n return True\n else:\n return False\n return n\n \n", "def is_even(n): \n # your code here\n n /= 2\n if n == int(n):\n return True\n else:\n return False", "def is_even(n):\n result = True\n\n if type(n) == float or n % 2 != 0:\n result = False\n\n return result", "def is_even(n: int) -> bool:\n return n % 2 == 0", "def is_even(n): \n # your code here\n if type(n) == float:\n return False\n if type(n) == int:\n if n%2 == 0:\n return True\n if n%2 == 1:\n return False", "def is_even(n): \n return not n%2 if isinstance(n, int) else False", "def is_even(n): \n return 1 if n % 2 == 0 else 0", "def is_even(n): \n return False if type(n) == float else not abs(n) % 2", "def is_even(n): \n return n % 1 == 0 and n % 2 == 0", "def is_even(n = 0):\n if (n % 2) == 0:\n return True\n else:\n return False", "def is_even(n): \n return True if type(n) is int and n % 2 == 0 else False", "def is_even(n): \n x = True if n % 2 == 0 else False\n return x", "is_even = lambda n : n%2==0 and isinstance(n, int) or 0", "def is_even(n): \n # your code here\n return isinstance (n,int) and (abs(n) % 2 == 0 )", "def is_even(n): \n return n//2 == n/2", "def is_even(n): \n results = False\n if n % 2 == 0:\n results = True\n return results\n \n \n", "def is_even(n): \n if n % 2 == 0:\n even = True\n else:\n even = False\n return even", "def is_even(n): \n n = n/2\n if n - n//1 == 0:\n return True\n else: \n return False", "def is_even(num): \n return num %2==0\n", "def is_even(n): \n return False if type(n) == float else n%2 == 0", "def is_even(n):\n if (n % 2) == 1:\n return False \n elif (n % 2) == 0:\n return True \n elif (n) != int: \n return False ", "def is_even(n): \n torf = False\n if n%2 == 0:\n torf = True\n return torf\n else:\n return torf\n pass", "def is_even(n):\n if type(n) == int:\n if (n % 2) == 0: \n t_f = True \n else: \n t_f = False\n else:\n t_f = False\n return(t_f) \n", "def is_even(n): \n if (n % 2) == 0:\n return True\n elif n is float:\n return False\n else:\n return False", "def is_even(n): \n if not n % 2:\n return True\n return False "] | {"fn_name": "is_even", "inputs": [[0], [0.5], [1], [2], [-4], [15], [20], [220], [222222221], [500000000]], "outputs": [[true], [false], [false], [true], [true], [false], [true], [true], [false], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 10,317 |
def is_even(n):
|
a67a79d5a30ccd431f1541e665715109 | UNKNOWN | ## Story
> "You have serious coding skillz? You wannabe a [scener](https://en.wikipedia.org/wiki/Demoscene)? Complete this mission and u can get in teh crew!"
You have read a similar message on your favourite [diskmag](https://en.wikipedia.org/wiki/Disk_magazine) back in the early 90s, and got really excited. You contacted the demo crew immediately and they gave you the following job: write a vertical sinus scroller... **for the printer!**
## Your task
Write a function that takes three parameters: `text`, `amp` (for [peak amplitude](https://en.wikipedia.org/wiki/Amplitude)) and `period` (or [wavelength](https://en.wikipedia.org/wiki/Wavelength)). Return a string (split into multiple lines) that will display the text as a vertical sine wave.
Note: `amp` and `period` are measured in characters and are always positive integers; `text` is never empty.
## Example
```python
>>> scroller('Hello World!', 3, 10)
' H\n e\n l\n l\n o\n \n W\no\nr\n l\n d\n !'
```
Doesn't make much sense? Well, let's print it!
```python
H 1
e 2
l 3
l 4
o 5
6
W 7
o 8
r 9
l 10
d 1
! 2
3210123
```
(Obviously, the numbers are only shown above to demonstrate `amp` and `period`)
Happy coding!
*Note:* due to the inevitable use of floats, solutions with slight rounding errors (1 space difference in less than 10% of the output lines) will be accepted.
---
## My other katas
If you enjoyed this kata then please try [my other katas](https://www.codewars.com/collections/katas-created-by-anter69)! :-)
#### *Translations are welcome!* | ["from math import pi, sin\n\ndef scroller(text, amp, period):\n return '\\n'.join(' ' * (amp + int(round(sin(i * 2 * pi / period) * amp))) + c for i, c in enumerate(text))\n", "import math\ndef scroller(text, amp, period):\n l = lambda i, c: ' '*(amp+i) + c + \"\\n\"\n return (''.join([l(round(amp * math.sin(2*math.pi*(i/period))), text[i]) for i in range(len(text))]))[:-1]", "from math import sin, pi\n\ndef scroller(text, amp, period):\n step = 2 * pi / period\n output = []\n \n for i, char in enumerate(text):\n line = ' ' * (int(round(amp * sin(step * i) + amp))) + char\n output.append(line)\n \n return '\\n'.join(output)", "from math import*;scroller=lambda t,a,p:\"\\n\".join(\" \"*round(a+a*sin(i/p*tau))+c for i,c in enumerate(t))", "from math import*;scroller=lambda s,a,l:'\\n'.join('{:>{:.0f}}'.format(c,1+a*(1+sin(n*2*pi/l)))for n,c in enumerate(s))", "def sinus(u):\n y = (abs(u) * 16 - 8) * u\n return (abs(y) * 0.224 + 0.776) * y\n\ndef scroller(t, a, p):\n return \"\\n\".join(' ' * round((sinus(i % p / p - 1/2) + 1) * a) + c for i, c in enumerate(t))", "import math\ndef scroller(text, amp, period):\n phi = 2*math.pi/period \n ans = []\n for i, e in enumerate(text):\n x = math.sin(phi*i)+1 \n t = round(x*amp)\n temp = ' '*int(t) + e\n ans.append(temp)\n return '\\n'.join(ans)", "from math import sin, pi\n\ndef scroller(text, amp, period):\n ans = [f'{\" \" * round(amp + sin(2 * pi / period * i) * amp)}{ch}'\n for i, ch in enumerate(text)]\n return '\\n'.join(ans)", "from math import sin, pi\n\n\ndef scroller(text, amp, period):\n ret = []\n for m, i in enumerate(text):\n ret.append('{}{}'.format(' ' * round(amp + (amp * sin(m * pi * 2/ period))), i))\n return '\\n'.join(ret)", "from math import sin, pi\n\n\ndef sin_gen(text, amp, period):\n for n, i in enumerate(text):\n yield int(round(amp + amp * sin((2 * pi / period) * n)))\n\n\ndef scroller(text, amp, period):\n return \"\\n\".join([\" \" * y + text[i] for i, y in enumerate(sin_gen(text, amp, period))])"] | {"fn_name": "scroller", "inputs": [["Hello World!", 3, 10], ["I'm a Codewars warrior lately...", 5, 18]], "outputs": [[" H\n e\n l\n l\n o\n \n W\no\nr\n l\n d\n !"], [" I\n '\n m\n \n a\n \n C\n o\n d\n e\n w\n a\n r\ns\n \n w\n a\n r\n r\n i\n o\n r\n \n l\n a\n t\n e\n l\n y\n .\n .\n."]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,130 |
def scroller(text, amp, period):
|
88b67b66e5bc27c21ff6035f438d0769 | UNKNOWN | Implement a function that normalizes out of range sequence indexes (converts them to 'in range' indexes) by making them repeatedly 'loop' around the array. The function should then return the value at that index. Indexes that are not out of range should be handled normally and indexes to empty sequences should return undefined/None depending on the language.
For positive numbers that are out of range, they loop around starting at the beginning, so
```python
norm_index_test(seq, len(seq)) # Returns first element
norm_index_test(seq, len(seq) + 1) # Returns second element
norm_index_test(seq, len(seq) + 2) # Returns third element
# And so on...
norm_index_test(seq, len(seq) * 2) # Returns first element
```
For negative numbers, they loop starting from the end, so
```python norm_index_test(seq, len(seq))
norm_index_test(seq, -1) # Returns last element
norm_index_test(seq, -2) # Returns second to last element
norm_index_test(seq, -3) # Returns third to last element
# And so on...
norm_index_test(seq, -len(seq)) # Returns first element
``` | ["def norm_index_test(a, n):\n if a: return a[n % len(a)]", "def norm_index_test(seq, ind):\n if seq:\n return seq[ind%len(seq)]\n return None", "def norm_index_test(seq, ind): \n try:\n return seq[ind%len(seq)]\n except:\n pass", "def norm_index_test(seq, ind): \n if seq==[]:\n return None\n elif ind >= len(seq) or ind < 0:\n return seq[ind%len(seq)]\n else:\n return seq[ind]\n \n", "def norm_index_test(seq, ind): \n return None if len(seq)==0 else seq[ind%len(seq)] ", "def norm_index_test(seq, ind): \n if seq:\n return seq[ind % len(seq)]", "norm_index_test = lambda seq, ind: None if len(seq) == 0 else seq[ind % len(seq)]", "def norm_index_test(arr, ind): \n return arr[ind % len(arr)] if arr else None", "def norm_index_test(lst, ind): \n return lst[ind % len(lst)] if lst else None", "def norm_index_test(seq, n):\n try:\n return seq[n% len(seq)]\n except ZeroDivisionError:\n return None"] | {"fn_name": "norm_index_test", "inputs": [[[], 10]], "outputs": [[null]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,014 |
def norm_index_test(seq, ind):
|
ff61ddaee461aa97721e4388733a012b | UNKNOWN | You're given an ancient book that unfortunately has a few pages in the wrong position, fortunately your computer has a list of every page number in order from ``1`` to ``n``.
You're supplied with an array of numbers, and should return an array with each page number that is out of place. Incorrect page numbers will not appear next to each other. Duplicate incorrect page numbers are possible.
Example:
```Given: list = [1,2,10,3,4,5,8,6,7]
```
``Return: [10,8]
``
Your returning list should have the incorrect page numbers in the order they were found. | ["def find_page_number(pages):\n n, miss = 1, []\n for i in pages:\n if i!=n: miss.append(i)\n else: n+=1\n return miss", "def find_page_number(pages):\n n = [1]\n return [i for i in pages if n[-1] != i or n.append(n[-1]+1)]", "def find_page_number(p):\n r, i = [], 0\n\n while i < len(p):\n if p[i] != i+1:\n r += [p.pop(i)]\n i -= 1\n i += 1\n\n return r", "def find_page_number(pages):\n n, res = 1, []\n for p in pages:\n if p == n:\n n += 1\n else:\n res.append(p)\n return res", "def find_page_number(pages):\n wrong_pages = []\n last_page = 0\n \n for page_num in pages:\n if page_num == last_page + 1:\n last_page += 1\n else:\n wrong_pages.append(page_num)\n\n return wrong_pages", "def find_page_number(pages):\n result = []\n for j, page in enumerate(pages):\n if page != j - len(result) + 1:\n result.append(page)\n \n return result", "def find_page_number(p):\n res = []; x = 1\n for v in p:\n if v != x: res.append(v)\n else: x += 1\n return res", "def find_page_number(pages):\n r=[]\n i=0\n while i<len(pages):\n if pages[i]!=i+1:\n r.append(pages.pop(i))\n i-=1\n i+=1\n return r", "def find_page_number(pages):\n p=pages[:]\n x=1\n r=[]\n while(p):\n if p[0]!=x:\n r.append(p.pop(0))\n else:\n x+=1\n p.pop(0)\n return r", "def find_page_number(pages):\n arr,l=[],0\n for i,p in enumerate(pages,1):\n if p!=i-l:\n arr.append(p)\n l+=1\n return arr"] | {"fn_name": "find_page_number", "inputs": [[[1, 2, 10, 3, 4, 5, 8, 6, 7]], [[1, 2, 3, 4, 50, 5, 6, 7, 51, 8, 40, 9]], [[1, 2, 3000, 3, 4, 5, 8, 6, 7, 8, 100, 9, 40, 10, 11, 13]], [[1, 2, 3, 4, 50, 5, 6, 7, 51, 8, 9]], [[4, 1, 2, 3, 3, 4, 26, 5, 6, 2, 7]]], "outputs": [[[10, 8]], [[50, 51, 40]], [[3000, 8, 100, 40, 13]], [[50, 51]], [[4, 3, 26, 2]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,745 |
def find_page_number(pages):
|
17a850b45c6ee0deec7315aa7439429e | UNKNOWN | Your job is to write a function which increments a string, to create a new string.
- If the string already ends with a number, the number should be incremented by 1.
- If the string does not end with a number. the number 1 should be appended to the new string.
Examples:
`foo -> foo1`
`foobar23 -> foobar24`
`foo0042 -> foo0043`
`foo9 -> foo10`
`foo099 -> foo100`
*Attention: If the number has leading zeros the amount of digits should be considered.* | ["def increment_string(strng):\n head = strng.rstrip('0123456789')\n tail = strng[len(head):]\n if tail == \"\": return strng+\"1\"\n return head + str(int(tail) + 1).zfill(len(tail))", "def increment_string(strng):\n \n # strip the decimals from the right\n stripped = strng.rstrip('1234567890')\n \n # get the part of strng that was stripped\n ints = strng[len(stripped):]\n \n if len(ints) == 0:\n return strng + '1'\n else:\n # find the length of ints\n length = len(ints)\n \n # add 1 to ints\n new_ints = 1 + int(ints)\n \n # pad new_ints with zeroes on the left\n new_ints = str(new_ints).zfill(length)\n \n return stripped + new_ints", "import re\n\ndef increment_string(input):\n match = re.search(\"(\\d*)$\", input)\n if match:\n number = match.group(0)\n if number is not \"\":\n return input[:-len(number)] + str(int(number) + 1).zfill(len(number))\n return input + \"1\"\n", "def increment_string(s):\n if s and s[-1].isdigit():\n return increment_string(s[:-1]) + \"0\" if s[-1] == \"9\" else s[:-1] + repr(int(s[-1]) + 1)\n return s + \"1\"\n", "import re\ndef increment_string(strng):\n m = re.match('^(.*?)(\\d+)$', strng)\n name, num = (m.group(1), m.group(2)) if m else (strng, '0')\n return '{0}{1:0{2}}'.format(name, int(num)+1, len(num))", "def increment_string(s):\n if s and s[-1].isdigit():\n num = s[len(s.rstrip(\"0123456789\")):]\n return s[:-len(num)] + str(int(num) + 1).zfill(len(num))\n \n return s + \"1\"", "def increment_string(strng):\n text = strng.rstrip('0123456789')\n nums = strng[len(text):]\n if nums == \"\": return strng+\"1\"\n return text + str(int(nums) + 1).zfill(len(nums))", "def increment_string(s):\n c = s.rstrip('0123456789')\n n = s[len(c):]\n if n=='':\n return s+'1'\n else:\n return c+str(int(n)+1).zfill(len(n))", "increment_string=f=lambda s:s and s[-1].isdigit()and(f(s[:-1])+\"0\",s[:-1]+str(int(s[-1])+1))[s[-1]<\"9\"]or s+\"1\"", "import re\n\ndef increment_string(s):\n number = re.findall(r'\\d+', s)\n if number:\n s_number = number[-1]\n s = s.rsplit(s_number, 1)[0]\n number = str(int(s_number) + 1)\n return s + '0' * (len(s_number) - len(number)) + number\n return s + '1'", "def increment_string(s):\n from re import findall as fa\n return (s.replace((fa('(\\d+)', s))[-1], str(int((fa('(\\d+)', s))[-1])+1).rjust(len((fa('(\\d+)', s))[-1]),'0')) if (fa('(\\d+)', s)) else s + '1')", "import re\ndef increment_string(strng):\n if not strng or not strng[-1].isdigit(): return strng + '1'\n num = re.match('.*?([0-9]+)$', strng).group(1)\n return strng[:-len(num)] + str(int(num)+1).zfill(len(num))", "import string\n\n\ndef increment_string(strng):\n if strng == '':\n return '1'\n a = list(strng)\n s = ''\n for i in range(0, len(a)):\n if a[-1] in string.digits:\n s += a[-1]\n del a[-1]\n s = reversed(s)\n s = ''.join(s)\n if s == '':\n s = '0'\n c = len(s)\n aa = int(s)\n aa += 1\n a = ''.join(a)\n return str(a) + str(aa).zfill(c)", "import re\ndef increment_string(strng):\n res = re.search(r\"^(.*?)(\\d*)$\",strng)\n ln = len(res.group(2))\n idx = int(res.group(2)) if ln else 0\n return res.group(1)+str(idx+1).zfill(ln)\n", "def increment_string(s):\n import re\n if s and s[-1].isdigit():\n num = re.search(r'(\\d+)$', s).group(1)\n return re.sub(num, str(int(num) + 1).zfill(len(num)), s)\n return ''.join([s, '1'])", "def increment_string(s):\n if s and s[-1].isdigit():\n n = s[len(s.rstrip('0123456789')):]\n return s[:len(s) - len(n)] + '%0*d' % (len(n), int(n) + 1)\n \n return s + '1'", "def increment_string(s):\n if s == '' or not s[-1].isdigit(): return s + '1'\n \n n = s[len(s.rstrip('0123456789')):]\n return s[:len(s) - len(n)] + '%0*d' % (len(n), int(n) + 1)\n", "import re\n\ndef increment_string(s):\n n = ''.join(re.findall(r'\\d*$', s))\n l = len(s) - len(n)\n n = '0' if n == '' else n\n \n return s[:l] + '%0*d' % (len(n), int(n) + 1)", "def increment_string(strng):\n s1 = strng.rstrip('0123456789')\n s2 = strng[len(s1):]\n if s2 == '': return strng+'1'\n return s1 + str(int(s2)+1).zfill(len(s2))", "def increment_string(strng):\n import re\n match = re.search(r'\\d+$', strng)\n if match:\n s = match.group()\n s1 = strng[:len(strng)-len(s)] + str.rjust(str(int(s)+1), len(s), '0')\n else:\n s1 = strng+'1'\n return s1", "def increment_string(s):\n b = []\n if s and s[-1].isdigit():\n for c in reversed(s):\n if c.isdigit():\n b.append(c)\n else:\n break\n return s[:-len(b)]+str(int(\"\".join(reversed(b)))+1).zfill(len(b))\n return s+\"1\"", "import re\nincrement_string = lambda s: re.sub(r'\\d+\\Z', lambda m: f'{int(s[m.start():]) + 1}'.zfill(m.end() - m.start()), s) if re.search(r'\\d\\Z', s) else s + '1'\n", "def increment_string(strng):\n if strng.isdigit():\n return '0' * (len(strng) - len(str(int(strng) + 1))) + str(int(strng) + 1)\n numbers = ''\n for i in range(len(strng[-1::-1])):\n if i == 0 and not strng[-1::-1][i].isdigit():\n break\n if strng[-1::-1][i].isdigit():\n numbers += strng[-1::-1][i]\n else:\n strng = strng[: -i]\n numbers = numbers[-1::-1]\n break\n lenght = len(numbers)\n numbers = int(numbers) + 1 if numbers else 1\n return strng + '0' * (lenght - len(str(numbers))) + str(numbers)\n", "from re import compile\n\np = compile(r\"(.*?)(\\d*$)\")\n\n\ndef increment_string(strng):\n s, n = p.search(strng).groups()\n return f\"{s}{int(n or 0) + 1:0{len(n)}d}\"", "def increment_string(st):\n if not st or st[-1].isalpha():\n return st + '1'\n if int(st[-1])<9:\n return st[:-1] + str( int(st[-1]) + 1 )\n end, i = '', len(st)-1\n while st[i].isdigit() and int(st[i])==9:\n i -=1\n end += '0'\n return increment_string(st[:i+1]) + end", "def increment_string(strng):\n y=''\n for x in range(len(strng)-1,-1,-1):\n if strng[x].isnumeric():\n y=strng[x]+y\n else:\n break\n l=len(y)\n if l==0:\n y='1'\n else:\n y=str(int(y)+1)\n if len(y)<=l:\n y=\"0\"*(l-len(y))+y\n strng=strng[0:len(strng)-l]+y\n return strng\n", "import re\n\ndef increment_string(s):\n if s.isalpha() or not len(s):\n return s + '1'\n r = re.split(r'(\\d+$)', s, flags=re.MULTILINE)\n return f'{r[0]}{(int(r[1]) + 1):0{len(r[1])}}'", "def increment_string(strng):\n s,m = strng[::-1],''\n for i in s:\n if i.isdigit():\n m = i + m\n strng = strng[:-1]\n else:\n break\n if m == '':\n return strng + '1'\n n = str(int(m)+1)\n if len(n)<len(m):\n n = '0'*(len(m)-len(n)) + n\n return strng + n", "def increment_string(s):\n num = ''\n for c in reversed(s):\n if c.isdigit():\n num += c\n s = s[:-1]\n else:\n break\n\n if not num:\n return s + '1'\n \n fmt = \"0{}d\".format(len(num)) # so it preverses the amount of digits\n return s + format(int(num[::-1])+1, fmt)\n", "import re\n\ndef rep(m):\n t = m.groups()[0]\n return str(int(t)+1).zfill(len(t))\n \ndef increment_string(strng):\n if len(strng) == 0 or not strng[-1].isdigit():\n return strng + '1'\n return re.sub(r'([0-9]+)$', rep,strng)\n", "def increment_string(foo):\n index = -1\n for i in range(len(foo)-1, -1, -1):\n if not foo[i] in '0123456789':\n break\n index = i\n \n if index == -1:\n foo = foo + '1'\n else:\n a = len(foo[index:])\n foo = foo[:index] + (\"{:0>\" + str(a) + \"d}\").format( int(foo[index:])+1 )\n \n return(foo)\n", "import re\ndef increment_string(strng):\n number = re.findall(r'\\d+$',strng)\n if len(number)==0:\n number.append(0)\n number = str(number[0])\n\n strng = strng.replace(number,'')\n \n if len(number) == 0:\n number.append('0')\n \n numlen = len(number)\n number = int(number)+1\n number = str(number).zfill(numlen)\n strng = strng + number\n return strng", "import string\n\n\ndef increment_string(strng):\n if strng == '':\n return '1'\n a = list(strng)\n s = ''\n for i in range(0, len(a)):\n if a[-1] in string.digits:\n s += a[-1]\n del a[-1]\n s = reversed(s)\n s = ''.join(s)\n # print('s = ' + s)\n if s == '':\n s = '0'\n c = len(s)\n aa = int(s)\n aa += 1\n a = ''.join(a)\n return str(a) + str(aa).zfill(c)", "import re\ndef increment_string(strng):\n num = re.search(\"(\\d+$)\", strng)\n txt = strng[:-len(num.group(1))] if num else strng\n return \"{}{}\".format(txt if txt else \"\", str(int(num.group(1))+1).zfill(len(num.group(1))) if num else \"1\")", "import re\n\ndef increment_string(strng):\n m = re.match(r'^(.*?)(\\d*)$', strng)\n word, digits = m.group(1), m.group(2)\n if digits:\n digits = str(int(digits)+1).zfill(len(digits))\n else:\n digits = '1'\n return word + digits", "import re\n\ndef increment_string(strng):\n s = list([_f for _f in re.split(r'(\\d+)', strng) if _f])\n if not s or not s[-1].isdigit():\n return strng + '1'\n else:\n return ''.join(s[:-1]) + str(int(s[-1])+1).zfill(len(strng)-len(''.join(s[:-1])))\n", "def increment_string(strng):\n if strng=='':\n return '1'\n if not '0'<=strng[-1]<='9':\n return strng+'1'\n if '0'<=strng[-1]<'9':\n return strng[:-1]+str(int(strng[-1])+1)\n i=-1\n while strng[i]=='9':\n i=i-1\n if not '0'<=strng[i]<'9':\n return strng[:i+1]+'1'+'0'*(-i-1)\n return strng[:i]+str(int(strng[i])+1)+'0'*(-i-1)", "# Look ma! No regex!\n\ndef increment_string(s):\n i, s2, n = 0, s[::-1], ''\n while True and i < len(s):\n if s2 and s2[i].isdigit():\n n += s2[i]\n i += 1\n else:\n break\n s, n = s[ : len(s) - len(n)], int(n[::-1])+1 if n > '' else 1\n return s + str(n).zfill(i)", "def increment_string(string):\n numbers=''\n others=''\n if string == '':\n return '1' \n for i in range(len(string)-1,-1,-1): #separates the numbers and the others\n if '0' <= string[i] <= '9':\n numbers = string[i] + numbers\n if string[i] < '0' or string[i] > '9':\n others = string[:i+1]\n break\n if numbers == '': #the string doesnt contain numbers (in the end)\n return others + '1'\n i=0\n while numbers[i] == '0' and i < len(numbers)-1: #to separate 0's from numbers\n i=i+1\n zeros = ''\n if i != 0: #separates 0's from numbers\n zeros = numbers[:i]\n numbers = numbers[i:]\n if len(numbers) != len(str(int(numbers)+1)) and zeros != '': # ex: if 099 goes to 100 and not 0100 removes one 0 if needed\n zeros = zeros[:-1]\n numbers = str(int(numbers)+1) #increment\n return others + zeros + numbers", "import re\n\ndef increment_string(strng):\n pattern = re.compile(r'[0-9]+')\n match = re.findall(pattern, strng)\n print(strng)\n\n if match:\n found = match[-1]\n length = len(found)\n add = str(int(found) + 1)\n changed = add.zfill(length)\n modified = strng.replace(found, changed)\n else:\n modified = strng + '1'\n return modified", "import re;increment_string=lambda i: (lambda x: i+'1' if x==None else i[:i.index(x.group(0))]+str(int(x.group(0))+1).zfill(len(x.group(0))))(re.search(\"\\d+$\", i))\n", "import re\ndef increment_string(s): return s + \"1\" if not re.search(r\"[0-9]{1,}$\", s) else s.replace(re.findall(r\"[0-9]{1,}$\", s)[-1], str(int(re.findall(r\"[0-9]{1,}$\", s)[-1]) + 1).zfill(len(re.findall(r\"[0-9]{1,}$\", s)[-1])))", "def increment_string(strng):\n import re\n try:\n h = re.findall(\"\\d+$\", strng)[0]\n return re.sub(\"\\d+$\", str(int(h)+1).zfill(len(h)), strng)\n except:\n return strng + \"1\"", "import re\n\n\ndef increment_string(s):\n\n if re.match('.*?([0-9]+)$', s) == None:\n return s + \"1\"\n last_digits = re.match('.*?([0-9]+)$', s).group(1)\n first_letters = s.rstrip(last_digits)\n print(s)\n return first_letters + str(int(last_digits) + 1).zfill(len(last_digits))", "import string\n\n\ndef increment_string(strng):\n\n nums = ''\n righty = []\n here = ''\n\n\n for i in strng:\n print(i)\n #all non no in righty\n righty.append(i)\n for i in strng[::-1]:\n if i not in string.digits:\n break\n elif i in string.digits:\n\n print('this is i', i)\n #all no in num\n here = i + nums\n nums = i + nums\n\n if nums == '':\n\n righty = ''.join(righty)\n return righty + '1'\n print('first', righty)\n ok = int(nums) + 1\n ok = str(ok)\n nums = nums[:-len(ok)]\n nums = nums + ok\n print('n', nums)\n print('r', righty)\n\n hmmm = ''.join(righty)\n print('hr', hmmm )\n hmmm = hmmm.replace(here, nums)\n return hmmm \n\nprint(increment_string('123foo001'))", "def increment_string(string):\n print(string)\n if len(string)!=0:\n if string[-1].isdigit():\n if string.isdigit():\n result=str(int(string)+1).zfill(len(string))\n else:\n c=0\n re_str=string[::-1]\n for i in re_str: \n if i.isdigit()==False:\n num=string[-c:]\n result=string[:len(string)-len(num)]+str(int(num)+1).zfill(len(num))\n break\n c+=1\n else: result=string+'1'\n else: result=string+'1'\n return result", "import re\n\ndef increment_string(strng):\n return '1' if len(strng) == 0 else strng[:-1] + str(int(strng[len(strng) - 1]) + 1) if strng[len(strng) - 1].isdigit() and 0 <= int(strng[len(strng) - 1]) <= 8 else strng + '1' if not strng[len(strng) - 1].isdigit() else strng[:-len((re.search(r'\\d9+$', strng))[0])] + str(int((re.search(r'\\d9+$', strng))[0]) + 1)", "def increment_string(strng):\n if strng=='': # To ensure there aren't any index errors.\n return '1'\n if strng[-1] not in ['0','1','2','3','4','5','6','7','8','9']:\n return strng+'1' # To add a '1' at the end of any string without numbers at the end.\n numChar=1 # numChar is the number of characters that are numbers at the end of strng.\n try:\n while True:\n if strng[-numChar] in ['0','1','2','3','4','5','6','7','8','9']:\n numChar+=1\n else:\n break\n except:\n numChar=len(strng)\n strngNum=strng[-numChar+1:]\n finalNum=str(int(strngNum)+1)\n while len(strngNum)>len(finalNum): # This is to ensure there are the correct number of 0s.\n finalNum='0'+finalNum\n return strng[:-numChar+1]+finalNum", "import re\ndef increment_string(string):\n if bool(re.match('.*?([0-9]+)$',string)): numeros= str(int(re.match('.*?([0-9]+)$', string).group(1)) + 1).zfill(len(re.match('.*?([0-9]+)$', string).group(1)))\n else: numeros = str(1)\n if bool(re.match('(.*?)[0-9]*$',string)): letras = re.match('(.*?)[0-9]*$', string).group(1)\n else: letras = \"\"\n return letras + numeros\n", "def increment_string(strng):\n import re\n if re.search(\"\\d+$\", strng):\n x = re.findall(\"(\\d+)$\", strng)[0]\n y = str(int(x) + 1)\n return re.sub(\"(\\d+)$\", \"\", strng) + \"0\"*(len(x) - len(y)) + y\n else:\n return strng + \"1\"\n", "import re\ndef increment_string(strng):\n num = re.search(\"\\d*$\",strng).group()\n if num:\n return strng[:-len(num)]+(\"%0\"+str(len(num))+\"d\")%(int(num)+1)\n return strng+'1'\n", "import re\n\ndef increment_string(string):\n digits = re.search(r'\\d+$', string)\n if not len(string): return '{}'.format('1')\n elif digits: return '{}{}'.format(string.replace(digits.group(), ''), str(int(digits.group())+1).zfill(len(digits.group())))\n else: return '{}{}'.format(string, '1')\n", "import re\ndef increment_string(strng):\n return strng.replace(re.search('[0-9]*$',strng).group(),'')+str(int(0 if re.search('[0-9]*$',strng).group()=='' else re.search('[0-9]*$',strng).group())+1).rjust(len(re.search('[0-9]*$',strng).group()),'0')\n", "import re\ndef increment_string(strng):\n x = re.findall(\".*\\D(\\d*)\", 'a'+strng)\n if not x or not x[0] :\n return strng + '1'\n return [strng[:-len(r)] + str(int(r)+1).zfill(len(r)) for r in x][0]", "def increment_string(s):\n for i in range(5,0,-1):\n if len(s) > i-1 and s[-i].isdigit():\n return s[:-i] + str(int(s[-i:])+1).zfill(i) \n return s+'1'", "import re\ndef increment_string(strng):\n if not strng or not strng[-1].isdigit(): return strng + '1'\n num = re.match('.*?([0-9]+)$', strng).group(1)\n return strng[:-len(str(num))] + str(int(num)+1).zfill(len(str(num)))\n", "import re\ndef increment_string(strng):\n m =re.split(r\"(\\d+)\",strng)\n if len(m) < 2:\n return strng+\"1\"\n else: \n number = str(int(m[-2]) +1).zfill(len(m[-2]))\n return ''.join(m[0:-2])+number\n", "def increment_string(strng):\n head = strng.rstrip('1234567890')\n tail = strng[len(head):]\n return head + str(int('0'+tail)+1).zfill(len(tail))", "from re import compile, search\n\nREGEX = compile(r'(?P<num>\\d+)$')\n\n\ndef increment_string(strng):\n m = search(REGEX, strng)\n if m:\n num = m.group('num')\n return '{}{:0>{}}'.format(strng[:m.start()], int(num) + 1, len(num))\n return '{}1'.format(strng)\n", "import re\n\ndef increment_string(strng):\n if strng and strng[-1].isdigit():\n value = int(strng[-1])\n value += 1\n if value >= 10:\n value = value % 10\n strng = increment_string(strng[:-1]) + str(value)\n else:\n strng = strng[:-1] + str(value)\n else:\n strng += '1'\n return strng\n", "import re\n\ndef increment_string(strng):\n # Reverse the string because I want the digits at the end\n item = strng[::-1]\n pattern = r'\\d+'\n number = re.search(pattern, item)\n \n # If theirs a number present in the string\n if number:\n reversed_word = re.split(pattern, item, 1)[1]\n reversed_num = number.group()\n num = reversed_num[::-1]\n if num == \"9\":\n num = \"10\"\n elif len(num) > 1:\n length = len(num)\n number = int(num)+1\n number = str(number)\n # Add leading zeros\n num = number.zfill(length)\n else:\n num = int(num)+1\n else:\n return strng+\"1\"\n \n return reversed_word[::-1]+str(num)\n \n \n \n# return strng\n", "def increment_string(strng):\n list1 = ''\n i = 0\n length = len(strng)\n if strng =='':\n return '1'\n if strng[-1].isdigit():\n i+=1 \n while(i<length and strng[-i].isdigit()):\n i+=1\n else:\n return strng + '1'\n i-=1\n number_string = str(int(strng[-i:]) + 1)\n return strng[:-i] + '0'*(i - len(number_string)) + number_string\n", "def increment_string(strng):\n if len(strng) == 0:\n return \"1\"\n \n if not strng[-1].isdigit():\n return strng + \"1\"\n elif len(strng) == 1:\n return str(int(strng) + 1)\n \n # Append all non-digit characters to new string, keeping track of the index where characters end\n idx = 0\n for i, c in enumerate(strng):\n if not c.isdigit():\n idx = i\n \n num_str = strng[idx + 1:]\n inc_num_str = str(int(num_str) + 1)\n \n return strng[:idx + 1] + inc_num_str.zfill(len(num_str))\n \n \n \"\"\"if len(strng) > 0 and strng[-1].isdigit():\n next_num = int(strng[-1]) + 1\n \n cur_index = -1 # Start at end of string\n \n if next_num < 10:\n strng = strng[:cur_index] + str(next_num)\n else:\n strng = strng[:cur_index] + str(0)\n cur_index -= 1\n \n while (abs(cur_index) <= len(strng)):\n if not strng[cur_index].isdigit():\n return strng[:cur_index ] + \"1\" + strng[cur_index:]\n \n cur_num = int(strng[cur_index])\n if cur_num < 9:\n strng = strng[:cur_index] + str(cur_num + 1) + strng[cur_index + 1:]\n return strng\n else:\n strng = strng[:cur_index] + str(0) + strng[cur_index + 1:]\n cur_index -= 1\n else:\n strng += '1'\n \n return strng\n \"\"\"", "def increment_string(strng):\n if not strng:\n return \"1\"\n end_idx = len(strng) - 1\n digit_str = ''\n while end_idx >= 0:\n if not strng[end_idx].isdigit():\n break\n digit_str = strng[end_idx] + digit_str\n end_idx -= 1\n\n if not digit_str.isdigit():\n increment_str = \"1\"\n elif digit_str[0] != '0':\n increment_str = str(int(digit_str) + 1)\n elif int(digit_str) == 0:\n increment_str = (len(digit_str) - 1) * '0' + '1'\n else:\n len_digit_str = len(digit_str)\n start_idx = 0\n while start_idx < len_digit_str:\n if digit_str[start_idx] != '0':\n break\n start_idx += 1\n increment = str(int(digit_str[start_idx:]) + 1)\n increment_str = (len_digit_str - len(increment)) * '0' + increment\n\n return strng[0:end_idx+1]+increment_str\n", "def increment_string(strng):\n if strng == '':\n return '1'\n if not strng[-1].isdigit():\n return strng + '1'\n strng_filtered = ''\n for a in strng:\n if not a.isdigit():\n strng_filtered += ' '\n else:\n strng_filtered += a\n num_suffix = strng_filtered.split()[-1]\n num_suffix_incr = str(int(num_suffix) + 1).zfill(len(num_suffix))\n return strng[0:-len(num_suffix)] + num_suffix_incr", "import re\n\ndef increment_string(strng):\n end_num = re.search(\"\\d+$\", strng)\n if end_num:\n new_num = str(int(end_num.group()) + 1).zfill(len(end_num.group()))\n return re.sub(end_num.group() + \"$\", new_num, strng)\n else:\n return strng + \"1\"\n", "def increment_string(strng):\n \n lastnonnum = 0\n \n for x in range(0, len(strng)):\n if (not strng[x].isnumeric()):\n lastnonnum = x\n \n for x in range(lastnonnum, len(strng)):\n if (strng[x].isnumeric()):\n print((strng[x]))\n number = strng[x:len(strng)]\n newnumber = str(int(number)+1)\n while len(number) > len(newnumber):\n newnumber = '0' + newnumber\n strng = strng[0:x] + newnumber\n return strng\n \n return strng + '1'\n", "import re\ndef increment_string(strng):\n num_str=re.findall(r'\\d+', strng)\n if not num_str:\n return strng+'1'\n num_str=num_str[-1]\n \n num_old=int(num_str)\n num_new=num_old+1\n if len(num_str)!=len(str(num_old)):\n if num_old==0:\n strng=strng[:-1]\n return strng + str(num_new)\n if len(str(num_old))!=len(str(num_new)):\n strng=strng[:-len(str(num_old))][:-1]\n return strng + str(num_new)\n \n \n else:\n return strng[:-len(str(num_old))] + str(num_new)\n else:\n return strng[:-len(str(num_old))] + str(num_new)", "def increment_string(s):\n num = \"\"\n zerosFound = False\n zeros = 0\n result = \"\"\n for x,i in enumerate(s):\n if(i.isdigit()):\n if(int(i) > 0):\n zerosFound = True\n if(i == \"0\" and not zerosFound):\n zeros += 1\n num += i\n if(not i.isdigit() and num is not ''):\n num = ''\n zeros = 0\n zerosFound = False\n if(num is not '' and int(num) > 0):\n print(\"J\")\n result = s.replace(num, '')\n if(len(str(int(num)+1)) is not len(str(int(num)))):\n zeros -= 1\n result += str(\"0\" * zeros) + str(int(num) + 1)\n else:\n result = s + \"1\" if s[-1:] is not \"0\" else s[:-1] + \"1\"\n return result\n", "def increment_string(strng):\n if strng == \"\":\n return \"1\"\n if not strng[-1].isdigit():\n strng += \"1\"\n else:\n c = \"\"\n ll = len(strng) - 1\n while strng[ll].isdigit():\n c = strng[ll] + c\n ll -= 1\n if ll<0:\n break\n lenc = len(c)\n c = str(int(c)+1)\n if len(c) < lenc:\n c = \"0\" * (lenc-len(c)) + c\n strng = strng[:ll+1] + c\n return strng\n", "def increment_string(strng):\n s = strng.rstrip(\"0123456789\")\n n = strng[len(s):]\n if n is '':\n return s + \"1\"\n else:\n n_ = int(n) + 1\n d = len(str(n)) - len(str(n_))\n if d != 0:\n return s + d * \"0\" + str(n_)\n else:\n return s + str(n_)\n", "def increment_string(strng):\n digit_count = 0\n for ch in strng[::-1]:\n if ch.isdigit():\n digit_count += 1\n else:\n break\n if not digit_count:\n return strng + '1'\n return f'{strng[: -digit_count]}{(int(strng[-digit_count:]) + 1):0{digit_count}}'\n", "import re\n \ndef increment_string(strng):\n num = re.findall(r'\\d+',strng)\n \n if len(num) == 0:\n return strng + '1'\n \n else:\n num = num[-1] \n new_num = int(num) + 1\n \n if len(str(num)) > len(str(new_num)):\n num_zeros = len(str(num)) - len(str(new_num))\n new_strng = strng.replace(str(num), str('0'*num_zeros + str(new_num)))\n else:\n new_strng = strng.replace(str(num), str(new_num))\n \n return new_strng", "def increment_string(strng):\n import re\n a = re.findall(r'\\d+',strng)\n\n if len(a)>0:\n a = a[-1]\n longitud = len(str(a))\n b = int(a)+1\n if longitud > len(str(b)):\n diff = longitud-len(str(b))\n number = str(0)*diff+str(b)\n strng = strng.replace(str(a), str(number))\n else:\n strng = strng.replace(str(a), str(b))\n \n \n else:\n strng = strng+\"1\"\n return strng\n\n \n", "def increment_string(strng):\n num = []\n for alpha in strng[::-1]:\n if alpha.isdigit():\n num.insert(0, alpha)\n else:\n break\n if num and num[0] == '0':\n temp = int(''.join(num)) + 1\n temp = str(temp).zfill(len(num))\n strng = strng[:-len(num)] + temp\n elif num and num[0] != '0':\n temp = int(''.join(num)) + 1\n strng = strng[:-len(num)] + str(temp)\n else:\n strng = strng + '1'\n return strng\n", "def increment_string(strng:str)->str:\n head = strng.rstrip('0123456789')\n tail = strng[len(head):]\n if tail == \"\": return strng+\"1\"\n return head + str(int(tail) + 1).zfill(len(tail))", "def increment_string(strng):\n i = -1\n number = []\n if len(strng) == 0 or strng[i] not in ['1','2','3','4','5','6','7','8','9','0']:\n return strng+'1'\n while strng[i] in ['0','1','2','3','4','5','6','7','8','9'] and i*-1 < len(strng):\n number.append(strng[i])\n i -= 1\n number.reverse()\n zero = len(number)\n if len(number) > 0:\n result = int(\"\".join(number))+1\n else:\n result = int(strng) + 1\n\n \n return strng[:-zero]+'0'*(len(number)-len(str(result)))+str(result)", "def increment_string(string):\n l = 0\n for x in range(1,100):\n if not string[-x::].isnumeric():\n l = x\n break\n if l == 1:\n return string + '1'\n else :\n num = string[-x + 1:]\n lenNum = len(num)\n num = int(num)+1\n return string[:-x + 1] + str(num).zfill(lenNum)", "def increment_string(strng):\n originalnum=''\n for t in reversed(strng):\n if not t.isdigit():\n break\n originalnum = t + originalnum\n if len(originalnum) > 0:\n num = int(originalnum)+1\n else:\n return strng+\"1\"\n if len(str(num)) < len(originalnum):\n numstr=str(num).zfill(len(originalnum))\n else:\n numstr=str(num)\n return strng[0:-len(originalnum)] + numstr\n", "import re\n\ndef increment_string(string):\n string = string[::-1]\n first_letter = re.search(\"\\D\", string)\n if first_letter is not None:\n first_letter = first_letter.span()\n substring = f\"{string[first_letter[0]:]}\"[::-1]\n number = f\"{string[:first_letter[0]]}\"[::-1]\n else:\n substring = \"\"\n number = string[::-1]\n \n # if string and the last number are detected correctly\n number_len = len(number)\n if number_len == 0:\n number = \"1\"\n else:\n new_number = str(int(number) + 1)\n if number_len <= len(new_number):\n number = new_number\n else:\n number = str(number[:(number_len - len(new_number))]) + new_number\n return f'{substring}{number}'\n", "import re\n\ndef increment_string(strng):\n digits_regex = \"\\d+$\"\n value_regex = \"[1-9]+$\"\n \n ret_str = \"\"\n \n #any digits on the end of the string\n digits_match = re.search(digits_regex, strng)\n if digits_match:\n digits = digits_match.group(0)\n print(digits)\n #add non-digit characters to return string\n substr = strng[0 : strng.index(digits)]\n ret_str += substr\n #non-zero digits on the end of the string\n value_match = re.search(value_regex, digits)\n if value_match:\n value = value_match.group(0)\n print(value)\n #split off zeros\n leading_zeros = digits[0 : digits.rfind(value)]\n #check if value contains only 9s. This number will roll over to use an \n #additional digit when 1 is added\n if value.count(\"9\") == len(value):\n leading_zeros = leading_zeros[0 : -1]\n ret_str += leading_zeros\n #add 1 to non-zero number\n value = str(int(value) + 1)\n ret_str += value\n else:\n #remove the last zero when there are only zeros and replace with \"1\"\n digits = digits[0 : -1] + \"1\"\n ret_str += digits\n else:\n #string does not end with and digits, therefore append \"1\"\n ret_str = strng + \"1\"\n \n return ret_str\n \n \n \n", "def increment_string(strng: str):\n number = \"\"\n for letter in strng[::-1]:\n if letter.isdigit():\n number = letter + number\n else:\n break\n if not number:\n return strng + \"1\"\n result = str(int(number) + 1)\n result = \"0\" * (len(number) - len(result)) + result\n return strng[:len(strng) - len(number)] + result", "def increment_string(strng):\n end_num_str = ''\n while strng[-1:].isnumeric():\n end_num_str = strng[-1:]+end_num_str\n strng = strng[:-1]\n num_len = len(end_num_str)\n end_num_str = str(int(end_num_str)+1) if end_num_str else '1'\n while len(end_num_str) < num_len:\n end_num_str = '0'+end_num_str\n return strng+end_num_str\n", "def increment_string(string):\n number=['0','1','2','3','4','5','6','7','8','9']\n f=0\n for i in string[-3:]:\n if i in number:\n f+=1\n \n if f==0:\n return string+\"1\"\n if string == \"foobar00999\":\n return \"foobar01000\"\n \n \n return string[:-f] + str(int(string[-f:])+1).zfill(f)", "def increment_string(strng):\n numeric_str = ''\n for i in reversed(strng):\n if not i.isdigit():\n break\n if i.isdigit():\n numeric_str += i\n \n if(numeric_str == ''):\n return strng + '1'\n else:\n numeric_str = numeric_str[::-1]\n str_num = str(int(numeric_str)+1)\n return strng[:-len(numeric_str)] + '0' * (len(numeric_str) - len(str_num)) + str_num\n \n", "def increment_string(strng):\n s = ''\n a = ''\n for i in strng[::-1]:\n if i.isnumeric() and len(a) == 0:\n s += i\n else:\n a += i\n \n if len(s) == 0:\n return strng+\"1\"\n \n a = a[::-1]\n s = s[::-1]\n s2 = int(s)+1\n return a + str(s2).zfill(len(s))\n", "def increment_string(strng):\n if strng == '':\n return '1'\n \n print(strng)\n # no number\n num_start = 0\n for i in reversed(list(range(len(strng)))):\n if strng[i].isdigit() == False:\n num_start = i + 1\n break\n\n if num_start == len(strng):\n return strng + '1'\n \n orig_str = strng[0:num_start]\n num_str = strng[num_start::]\n \n digits = len(num_str)\n suffix_num = str(int(num_str) + 1)\n \n return orig_str + ('0' * (digits - len(suffix_num))) + str(suffix_num)\n \n", "import re\n\ndef increment_string(strng):\n array = re.findall(r'[0-9]+', strng)\n if array:\n size=len(array[-1])\n num=str(int(array[-1])+1)\n base=strng[0:-size]\n while len(num)<size:\n num='0'+num\n return base+num\n else:\n return strng+'1'\n return strng", "def increment_string(strng):\n nums = \"0123456789\"\n num = \"\"\n digits = 0\n for char in reversed(strng):\n if char in nums:\n num = char + num\n digits += 1\n else: break\n return strng.rstrip(num) + str(int(num)+1).zfill(digits) if len(num) >0 else strng + \"1\"", "def increment_string(strng):\n head = strng.rstrip('0123456789')\n tail = strng[len(head):]\n print(head)\n print(tail)\n if tail == \"\": return strng+\"1\"\n return head + str(int(tail) + 1).zfill(len(tail))", "import re\n\ndef increment_string(string):\n if string:\n num=[]\n word=''\n for i,s in enumerate(string[::-1]):\n if re.findall('\\d',s):\n num.insert(0,s)\n i=i+1\n else:\n break\n if i>len(string)-1:\n pass\n else:\n j=i\n while j<len(string):\n word=word+string[j-i]\n j=j+1\n if num:\n return word+str(int(''.join(num))+1).zfill(len(num))\n else:\n return word+'1'\n else:\n return '1'", "import re\n\ndef increment_string(strng):\n m = re.search(r\"(\\s*)(\\d*)$\", strng)\n x = m.group(2)\n if x:\n i = int(x)\n digits = len(x)\n return f\"{strng[:-digits]}{str(i + 1).zfill(digits)}\"\n else:\n return f\"{strng}1\"\n", "def increment_string(strng):\n if strng == \"\": return \"1\"\n if strng.isdigit(): return str(int(strng) + 1).rjust(len(strng), \"0\")\n index = -1\n while strng[index].isdigit():\n index -= 1\n if index == -1: return strng + \"1\"\n data = [strng[:index + 1], strng[index + 1:]]\n data[1] = str(int(data[1]) + 1).rjust(len(data[1]), \"0\")\n return ''.join(data)", "def increment_string(s):\n l = []\n for i in s[::-1]:\n if i.isdigit():\n l.append(int(i))\n else:\n break\n l.reverse()\n if len(l) != 0:\n p = ''.join(map(str, l))\n q = p.lstrip('0')\n if len(q)>0:\n r = int(q) + 1\n s = s[:len(s) - len(l)] + str(r).zfill(len(l))\n else:\n s = s[:len(s) - len(l)] + '1'.zfill(len(l))\n else:\n s = s + '1'\n return s", "def increment_string(strng):\n print(strng)\n n=strng\n m=[]\n x = \"\"\n z2=''\n r=[]\n r2=''\n y = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\",\"7\", \"8\", \"9\"]\n if n==\"\":\n x=\"1\"\n else:\n for i in n:\n m.append(i)\n if m[-1] not in y:\n x=n+\"1\"\n else:\n m.reverse()\n for j in m:\n if j in y:\n r.append(j)\n else:\n break\n r.reverse()\n for j1 in r:\n r2=r2+j1\n z1=m[(len(r2)):]\n z1.reverse()\n for j2 in z1:\n z2=z2+j2\n s2 = int(r2)\n s21 = str(s2)\n s = int(r2) + 1\n s1 = str(s)\n if len(r2)==len(s21):\n x=z2+s1\n else:\n s3=r2[0:(len(r2)-len(s21))]\n s4=r2[0:(len(r2)-len(s21)-1)]\n if len(s21)==len(s1) :\n x=z2+s3+s1\n else:\n x=z2+s4+s1\n\n return x", "import re\n\ndef increment_string(strng):\n if strng == \"\":\n return \"1\"\n \n try:\n strngSearch = re.search(\"[^1-9]\", strng[::-1]).start()\n absStart = re.search(\"[^\\d]\", strng[::-1]).start()\n except AttributeError:\n return str(int(strng)+1).zfill(len(strng))\n\n if absStart > 0:\n sa = strng[-absStart:]\n oldNum = int(sa)\n newNum = str(oldNum + 1).zfill(len(sa))\n newStrng = strng[:-absStart] + newNum\n return newStrng\n else:\n return strng+\"1\"\n"] | {"fn_name": "increment_string", "inputs": [["foo"], ["foobar001"], ["foobar1"], ["foobar00"], ["foobar99"], [""], ["foobar000"], ["foobar999"], ["foobar00999"], ["1"], ["009"]], "outputs": [["foo1"], ["foobar002"], ["foobar2"], ["foobar01"], ["foobar100"], ["1"], ["foobar001"], ["foobar1000"], ["foobar01000"], ["2"], ["010"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 38,445 |
def increment_string(strng):
|
02b5bfa76f22e0517a18dff4da0d35a5 | UNKNOWN | The Earth has been invaded by aliens. They demand our beer and threaten to destroy the Earth if we do not supply the exact number of beers demanded.
Unfortunately, the aliens only speak Morse code. Write a program to convert morse code into numbers using the following convention:
1 .----
2 ..---
3 ...--
4 ....-
5 .....
6 -....
7 --...
8 ---..
9 ----.
0 ----- | ["MORSE_TO_NUM = {\n \".----\" : \"1\",\n \"..---\" : \"2\",\n \"...--\" : \"3\",\n \"....-\" : \"4\",\n \".....\" : \"5\",\n \"-....\" : \"6\",\n \"--...\" : \"7\",\n \"---..\" : \"8\",\n \"----.\" : \"9\",\n \"-----\" : \"0\",\n}\n\ndef morse_converter(s):\n return int(\"\".join(MORSE_TO_NUM[s[i:i+5]] for i in range(0, len(s), 5)))\n", "def morse_converter(s):\n it = ['-----', '.----', '..---', '...--', '....-', '.....', '-....', '--...', '---..', '----.']\n return int(''.join(str(it.index(s[i:i+5])) for i in range(0, len(s), 5)))", "import re\n\nMORSE_TO_INT = {\n \".----\" : \"1\", \"..---\": \"2\", \"...--\": \"3\",\n \"....-\": \"4\", \".....\": \"5\", \"-....\": \"6\",\n \"--...\": \"7\", \"---..\": \"8\", \"----.\": \"9\", \n \"-----\": \"0\"\n}\n\ndef morse_converter(string):\n return int(\"\".join(MORSE_TO_INT[x] for x in re.findall(\".....\", string)))", "morse_digits = [\"-----\", \".----\", \"..---\", \"...--\", \"....-\", \".....\", \"-....\", \"--...\", \"---..\", \"----.\"]\n\ndef morse_converter(stg):\n return int(\"\".join(str(morse_digits.index(stg[i:i+5])) for i in range(0, len(stg), 5)))", "tbl = {\n x: str(i % 10)\n for i, x in enumerate(['.----', '..---', '...--', '....-', '.....', '-....', '--...', '---..', '----.', '-----'], 1)\n}\n\ndef morse_converter(s):\n return int(''.join(tbl[s[i:i+5]] for i in range(0, len(s), 5)))", "import textwrap\ndef morse_converter(string):\n v = (textwrap.wrap(string, 5))\n dicti = {\".----\":\"1\",\"..---\":\"2\",\"...--\":\"3\",\"....-\":\"4\",\".....\":\"5\",\"-....\":\"6\",\"--...\":\"7\",\"---..\":\"8\",\"----.\":\"9\",\"-----\":\"0\"}\n \n li = []\n for i in v:\n \n li.append(dicti[i])\n \n return (int(''.join(li)))", "def morse_converter(string):\n dict = {tuple(a) : str(c) for c, a in enumerate(['-----', '.----', '..---', '...--', '....-', '.....', '-....', '--...', '---..', '----.'])}\n return int(''.join(map(dict.get, zip(*[iter(string)] * 5))))", "MORSE_DICT = {\"-----\":\"0\", \".----\":\"1\", \"..---\":\"2\", \"...--\":\"3\", \"....-\":\"4\", \".....\":\"5\", \"-....\":\"6\", \"--...\":\"7\", \"---..\":\"8\", \"----.\":\"9\"}\ndef morse_converter(string):\n return int( ''.join( MORSE_DICT[string[n:n+5]] for n in range(0,len(string),5) ) )", "def morse_converter(s):\n c={'.----':'1','..---':'2','...--':'3','....-':'4','.....':'5','-....':'6','--...':'7','---..':'8','----.':'9','-----':'0'}\n return int(\"\".join([c[s[i:i+5]] for i in range(0, len(s),5)]))", "morse_converter=lambda s:int(''.join(str(9-'----.....-----'.rindex(s[i:i+5]))for i in range(0,len(s),5)))"] | {"fn_name": "morse_converter", "inputs": [[".----.----.----.----.----"], ["..----------...-....----------"], ["---------------"], ["..---.--------....--"], [".----..---...--....-.....-....--...---..----.-----"]], "outputs": [[11111], [207600], [0], [2193], [1234567890]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,692 |
def morse_converter(s):
|
a8e1ae8020aafc59fce7817e208cfbad | UNKNOWN | For every good kata idea there seem to be quite a few bad ones!
In this kata you need to check the provided 2 dimensional array (x) for good ideas 'good' and bad ideas 'bad'. If there are one or two good ideas, return 'Publish!', if there are more than 2 return 'I smell a series!'. If there are no good ideas, as is often the case, return 'Fail!'.
The sub arrays may not be the same length.
The solution should be case insensitive (ie good, GOOD and gOOd all count as a good idea). All inputs may not be strings. | ["from itertools import chain\n\ndef well(arr):\n c = sum(isinstance(x, str) and x.lower() == 'good' for x in chain.from_iterable(arr))\n return (\n 'I smell a series!' if c > 2 else\n 'Publish!' if c > 0 else\n 'Fail!'\n )", "def well(arr):\n good_ideas = str(arr).lower().count('good')\n return 'I smell a series!' if (good_ideas > 2) else 'Fail!' if not(good_ideas) else 'Publish!'", "def well(arr):\n nb_good = sum(1 for lst in arr for word in lst if str(word).lower() == \"good\")\n return \"I smell a series!\" if nb_good > 2 else \"Publish!\" if nb_good > 0 else \"Fail!\"\n", "from itertools import chain\nfrom typing import List, Any\n\n\ndef well(arr: List[List[Any]]) -> str:\n good = (a for a in chain(*arr) if isinstance(a, str) and a.lower() == \"good\")\n \n if next(good, False):\n if next(good, False) and next(good, False):\n return \"I smell a series!\"\n return \"Publish!\"\n return \"Fail!\"\n", "def well(arr):\n total = 0\n for i in arr:\n for j in i:\n if isinstance(j, str) and j.lower() == 'good':\n total += 1\n return 'Fail!' if total == 0 else 'I smell a series!' if total > 2 else 'Publish!'\n", "def well(arr):\n bad1 = 0\n good = 0\n for i in arr:\n for j in i:\n if str(j).lower() == \"bad\":\n bad1+=1\n if str(j).lower() == \"good\":\n good+=1\n if 0 < good < 3:\n return \"Publish!\"\n if good > 2:\n return \"I smell a series!\"\n if good == 0:\n return \"Fail!\"\n \n \n \n", "well = lambda a,f=__import__(\"itertools\").chain.from_iterable: {0: 'Fail!', 1: 'Publish!', 2: 'Publish!'}.get(sum(str(w).lower() == 'good' for w in f(a)), 'I smell a series!')", "def well(arr):\n c = ''.join(map(str,arr)).lower().count('good')\n return ['Fail!','Publish!','I smell a series!'][bool(c)+(c>2)]", "def well(arr):\n c = len([j for i in arr for j in i if str(j)[0] in \"Gg\"])\n if c == 0: return \"Fail!\"\n elif c <= 2: return \"Publish!\"\n else: return \"I smell a series!\"\n \n", "def well(arr):\n s = []\n for x in arr:\n s += x\n a = []\n for c in s:\n if isinstance(c, str):\n a.append(c)\n cpt = 0 \n for w in a:\n if w.lower() == 'good':\n cpt += 1\n if cpt > 2: return 'I smell a series!'\n if 0 < cpt < 3: return 'Publish!'\n return 'Fail!'\n# Flez\n"] | {"fn_name": "well", "inputs": [[[["bad", "bAd", "bad"], ["bad", "bAd", "bad"], ["bad", "bAd", "bad"]]], [[["gOOd", "bad", "BAD", "bad", "bad"], ["bad", "bAd", "bad"], ["GOOD", "bad", "bad", "bAd"]]], [[["gOOd", "bAd", "BAD", "bad", "bad", "GOOD"], ["bad"], ["gOOd", "BAD"]]]], "outputs": [["Fail!"], ["Publish!"], ["I smell a series!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,531 |
def well(arr):
|
8ed4c8d47ca4be0c6196ece54903846c | UNKNOWN | A lot of goods have an International Article Number (formerly known as "European Article Number") abbreviated "EAN". EAN is a 13-digits barcode consisting of 12-digits data followed by a single-digit checksum (EAN-8 is not considered in this kata).
The single-digit checksum is calculated as followed (based upon the 12-digit data):
The digit at the first, third, fifth, etc. position (i.e. at the odd position) has to be multiplied with "1".
The digit at the second, fourth, sixth, etc. position (i.e. at the even position) has to be multiplied with "3".
Sum these results.
If this sum is dividable by 10, the checksum is 0. Otherwise the checksum has the following formula:
checksum = 10 - (sum mod 10)
For example, calculate the checksum for "400330101839" (= 12-digits data):
4·1 + 0·3 + 0·1 + 3·3 + 3·1 + 0·3 + 1·1 + 0·3 + 1·1 + 8·3 + 3·1 + 9·3
= 4 + 0 + 0 + 9 + 3 + 0 + 1 + 0 + 1 + 24 + 3 + 27
= 72
10 - (72 mod 10) = 8 ⇒ Checksum: 8
Thus, the EAN-Code is 4003301018398 (= 12-digits data followed by single-digit checksum).
Your Task
Validate a given EAN-Code. Return true if the given EAN-Code is valid, otherwise false.
Assumption
You can assume the given code is syntactically valid, i.e. it only consists of numbers and it exactly has a length of 13 characters.
Examples
```python
validate_ean("4003301018398") # => True
validate_ean("4003301018392") # => False
```
Good Luck and have fun. | ["validate_ean = lambda code: (sum(map(int, code[0::2])) + sum(map(int, code[1::2])) * 3) % 10 == 0", "def validate_ean(code):\n data, last = code[:12], int(code[12])\n checksum = -sum(int(d) * 3**(i % 2) for i, d in enumerate(data)) % 10\n return last == checksum ", "def validate_ean(code):\n checksum = int(code[-1:])\n code = list(map(int, code[:-1]))\n odd = sum([code[i] for i in range(0, len(code), 2)])\n even = sum([code[i]*3 for i in range(1, len(code), 2)])\n total = odd + even\n if total % 10 == 0:\n if checksum == 0:\n return True\n else:\n return False\n else:\n new_checksum = 10 - (total % 10)\n if new_checksum == checksum:\n return True\n else:\n return False\n", "def validate_ean(code):\n return sum(x * (i%2*2+1) for i,x in enumerate(map(int, code))) % 10 == 0", "def validate_ean(code):\n '''Return True if code is a valid EAN-13 code (else False)'''\n \n # separate single-digit checksum from code\n check_digit = int(code[-1])\n # convert 12-digit string to list of int\n code = list(map(int, code[:-1]))\n # multiply digits at even positions with 3\n totals = sum([digit * 3 if pos % 2 == 0 else digit for pos, digit in enumerate(code, 1)])\n \n if totals % 10 == 0:\n checksum = 0\n else:\n checksum = 10 - (totals % 10)\n return check_digit == checksum", "def validate_ean(code):\n return sum([int(x) if i%2==0 else 3*int(x) for i,x in enumerate(code)])%10==0", "def validate_ean(code):\n sum1 = sum(map(int, code[0:-1:2]))\n sum2 = sum(map(lambda x: x*3, map(int, code[1:-1:2])))\n checksum = 10 - ((sum1 + sum2) % 10)\n checksum = 0 if checksum == 10 else checksum\n return int(code[-1]) == checksum", "def validate_ean(code):\n sum_odd = sum(int(x) for x in code[:-1:2])\n sum_even = sum(int(x) * 3 for x in code[1::2])\n checksum = (sum_odd + sum_even) % 10\n if checksum:\n return (10 - checksum) == int(code[-1])\n else:\n return checksum == int(code[-1])"] | {"fn_name": "validate_ean", "inputs": [["9783815820865"], ["9783815820864"], ["9783827317100"]], "outputs": [[true], [false], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,103 |
def validate_ean(code):
|
c08eef28332a86c5f66f7643b4e25db2 | UNKNOWN | The town sheriff dislikes odd numbers and wants all odd numbered families out of town! In town crowds can form and individuals are often mixed with other people and families. However you can distinguish the family they belong to by the number on the shirts they wear. As the sheriff's assistant it's your job to find all the odd numbered families and remove them from the town!
~~~if-not:cpp
Challenge: You are given a list of numbers. The numbers each repeat a certain number of times. Remove all numbers that repeat an odd number of times while keeping everything else the same.
~~~
~~~if:cpp
Challenge: You are given a vector of numbers. The numbers each repeat a certain number of times. Remove all numbers that repeat an odd number of times while keeping everything else the same.
~~~
```python
odd_ones_out([1, 2, 3, 1, 3, 3]) = [1, 1]
```
In the above example:
- the number 1 appears twice
- the number 2 appears once
- the number 3 appears three times
`2` and `3` both appear an odd number of times, so they are removed from the list. The final result is: `[1,1]`
Here are more examples:
```python
odd_ones_out([1, 1, 2, 2, 3, 3, 3]) = [1, 1, 2, 2]
odd_ones_out([26, 23, 24, 17, 23, 24, 23, 26]) = [26, 24, 24, 26]
odd_ones_out([1, 2, 3]) = []
odd_ones_out([1]) = []
```
Are you up to the challenge? | ["def odd_ones_out(numbers):\n return [i for i in numbers if numbers.count(i) % 2 == 0]", "from collections import Counter\n\ndef odd_ones_out(numbers):\n cnt = Counter(numbers)\n return [v for v in numbers if not cnt[v]&1 ]", "def odd_ones_out(numbers):\n temp = []\n count = 0\n for i in range(len(numbers)):\n count = numbers.count(numbers[i])\n if count % 2 == 0:\n temp.append(numbers[i])\n return temp", "from collections import Counter\n\ndef odd_ones_out(a):\n d = Counter(a)\n return [x for x in a if not d[x] % 2]", "from collections import Counter\ndef odd_ones_out(numbers):\n return [x for x in numbers if x in [k for k, v in Counter(numbers).items() if v % 2 == 0]]", "def odd_ones_out(numbers):\n dup = 0\n sec = list(set(numbers))\n for i in range(0, len(sec)):\n dup = 0\n for j in range(0, len(numbers)):\n if sec[i] == numbers[j]:\n dup = dup + 1\n if dup % 2 == 1:\n numbers = [value for value in numbers if value != sec[i]]\n return numbers", "from collections import Counter\ndef odd_ones_out(numbers):\n dct = Counter(numbers)\n return [num for num in numbers if dct[num]%2 == 0]\n", "def odd_ones_out(numbers):\n temp = []\n for num in numbers:\n if (numbers.count(num) %2 ==0):\n temp.append(num)\n return temp", "def odd_ones_out(numbers):\n return list(filter(lambda x: not numbers.count(x) % 2, numbers))", "from collections import Counter\n\ndef odd_ones_out(numbers):\n c = Counter(numbers)\n return [n for n in numbers if c[n] % 2 == 0]"] | {"fn_name": "odd_ones_out", "inputs": [[[1, 2, 3, 1, 3, 3]], [[75, 68, 75, 47, 68]], [[42, 72, 32, 4, 94, 82, 67, 67]], [[100, 100, 5, 5, 100, 50, 68, 50, 68, 50, 68, 5, 100]], [[82, 86, 71, 58, 44, 79, 50, 44, 79, 67, 82, 82, 55, 50]]], "outputs": [[[1, 1]], [[75, 68, 75, 68]], [[67, 67]], [[100, 100, 100, 100]], [[44, 79, 50, 44, 79, 50]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,637 |
def odd_ones_out(numbers):
|
996c7da2019d0f055c292ac104db9752 | UNKNOWN | # Task
Given an array of roots of a polynomial equation, you should reconstruct this equation.
___
## Output details:
* If the power equals `1`, omit it: `x = 0` instead of `x^1 = 0`
* If the power equals `0`, omit the `x`: `x - 2 = 0` instead of `x - 2x^0 = 0`
* There should be no 2 signs in a row: `x - 1 = 0` instead of `x + -1 = 0`
* If the coefficient equals `0`, skip it: `x^2 - 1 = 0` instead of `x^2 + 0x - 1 = 0`
* Repeating roots should not be filtered out: `x^2 - 4x + 4 = 0` instead of `x - 2 = 0`
* The coefficient before `q^n` is always `1`: `x^n + ... = 0` instead of `Ax^n + ... = 0`
___
## Example:
```
polynomialize([0]) => "x = 0"
polynomialize([1]) => "x - 1 = 0"
polynomialize([1, -1]) => "x^2 - 1 = 0"
polynomialize([0, 2, 3]) => "x^3 - 5x^2 + 6x = 0"
```
___
## Tests:
```python
Main suite: Edge cases:
(Reference - 4000 ms) (Reference - 30 ms)
N of roots | N of tests N of roots | N of tests
----------------------- -----------------------
1-10 | 100 20-40 | 125
700-750 | 25 2-20 | 125
``` | ["import re\n\ndef polynomialize(roots):\n \n def deploy(roots):\n r = -roots[0]\n if len(roots) == 1: return [r, 1]\n \n sub = deploy(roots[1:]) + [0]\n return [c*r + sub[i-1] for i,c in enumerate(sub)]\n \n coefs = deploy(roots)\n poly = ' + '.join([\"{}x^{}\".format(c,i) for i,c in enumerate(coefs) if c][::-1])\n poly = re.sub(r'x\\^0|\\^1\\b|\\b1(?=x)(?!x\\^0)', '', poly).replace(\"+ -\", \"- \") + ' = 0'\n return poly", "def poly(lst):\n ans = [1, -lst.pop()]\n while lst:\n ans.append(0)\n r = lst.pop()\n for i in range(len(ans)-1, 0, -1):\n ans[i] -= r*ans[i-1]\n return ans \n\nimport re\ndef polynomialize(roots):\n if len(roots) == 1:\n if roots[0] == 0:\n return 'x = 0'\n elif roots[0] < 0:\n return 'x + ' + str(abs(roots[0])) + ' = 0'\n else:\n return 'x - ' + str(roots[0]) + ' = 0'\n if len([i for i in roots if i != 0]) == 0:\n return 'x^' + str(len(roots)) + ' = 0'\n \n# ans = np.poly(roots)\n ans = poly(roots)\n ans1 = ans[:]\n \n final = []\n for i in range(len(ans[:-1])):\n try:\n if int(ans[i]) == 0:\n continue\n except:\n continue\n if int(ans[i]) == 1:\n num = len(ans1[:-1])-i\n if num == 1:\n final.append('x')\n else:\n final.append('x^{}'.format(str(num)))\n else:\n num = len(ans1[:-1])-i\n if num == 1:\n final.append(str(int(ans[i])) + 'x')\n else:\n final.append(str(int(ans[i])) + 'x^{}'.format(str(num)))\n if int(ans[-1]) != 0:\n final.append(str(int(ans[-1])))\n if isinstance(final[0], list):\n final = final[-1]\n answer = '+'.join(final)\n\n answer = answer.replace('+-', ' - ')\n answer = answer.replace('+', ' + ')\n answer = re.sub(\" 1x\", ' x', answer)\n return answer + ' = 0'", "def polynomialize(roots):\n coeffs = [1]\n for root in roots:\n coeffs = [1] + [coeffs[i] + coeffs[i-1] * -root for i in range(1,len(coeffs))] + [-root * coeffs[-1]] \n coeffs = [d for d in list(enumerate(coeffs[::-1]))[::-1] if d[1] != 0]\n r = ['{:+0d}x^{}'.format(d[1], d[0]) for d in coeffs if d[0]>1]\n r += ['{:+0d}x'.format(d[1]) for d in coeffs if d[0]==1]\n r += ['{:+0d}'.format(d[1]) for d in coeffs if d[0]==0]\n f = ' '.join(r).replace('+1x', '+x').replace('-1x', '-x').replace('-', '- ').replace('+', '+ ').lstrip('+').strip(' ')\n return f + ' = 0'", "import numpy as np\n\nstring = lambda v: \"\" if not v else \"x\" if v == 1 else f\"x^{v}\"\n\ndef coefficients(roots):\n coeffs = [1, -roots.pop()]\n while roots:\n coeffs.append(0)\n r = roots.pop()\n for i in reversed(range(1, len(coeffs))):\n coeffs[i] -= r * coeffs[i-1]\n return coeffs\n\n# numpy.poly1d gives slighty different coeffs\ndef polynomialize(roots):\n #coeffs = list(map(int, np.poly1d(roots, True)))\n coeffs = coefficients(roots)\n z = zip(reversed(range(len(coeffs))), coeffs)\n res = [string(next(z)[0])]\n res.extend(f\" {'-+'[b > 0]} {(abs(b), '')[a and abs(b) == 1]}{string(a)}\" for a,b in z if b)\n res.append(\" = 0\")\n return ''.join(res)", "def polynomialize(roots):\n space_sign_space = lambda c: ' + ' if 0 < c else ' - '\n space_sign_space_num = lambda c: space_sign_space(c) + (str(abs(c)) if abs(c) != 1 else '')\n max_power = len(roots)\n # Calculate coefficients\n coefs = [1, -roots[0]]\n if max_power > 1:\n for r in roots[1:]:\n coefs = [1,] + [c[0]-r*c[1] for c in zip(coefs[1:], coefs[:-1])] + [-r*coefs[-1],]\n # Construct equation (first line, separately as it needs no leading +)\n eq = 'x' + ('^' + str(max_power) if max_power > 1 else '')\n power = max_power\n # Loop for x^(max_power -1) up to x^2 if it exists\n for c in coefs[1:-2]:\n power -= 1\n if c == 0:\n continue\n eq += space_sign_space_num(c)\n eq += 'x^' + str(power)\n # Coefficient for x\n if (max_power > 1) and coefs[-2] != 0:\n eq += space_sign_space_num(coefs[-2])\n eq += 'x'\n # Coefficient for const\n if coefs[-1] != 0:\n eq += space_sign_space(coefs[-1]) + str(abs(coefs[-1]))\n eq += ' = 0'\n return eq", "def polynomialize(roots):\n def add_root(poly, root):\n # Multiply poly * (x - root)\n poly1 = poly + [0] # Increase order (multiply by x)\n poly2 = [0] + [-root * coef for coef in poly] # Multiply by -root\n poly = [coef1 + coef2 for coef1, coef2 in zip(poly1, poly2)] # Add\n return poly\n def poly2str(poly):\n spoly = \"\"\n for i, coef in enumerate(poly):\n if i == 0:\n signum = \"\"\n elif coef > 0:\n signum = \" + \"\n elif coef < 0:\n signum = \" - \"\n else:\n continue\n \n if abs(coef) == 1:\n scoef = \"\"\n else:\n scoef = str(abs(coef))\n \n exp = len(poly)-i-1\n if exp == 1:\n sexp = \"x\"\n elif exp == 0:\n if scoef == \"\":\n sexp = \"1\"\n else:\n sexp = \"\"\n else:\n sexp = \"x^\"+str(exp)\n spoly += signum + scoef + sexp\n spoly += \" = 0\"\n return spoly\n \n poly = [1, -roots[0]]\n for root in roots[1:]:\n poly = add_root(poly, root)\n \n return poly2str(poly)\n \n \n \n", "from functools import reduce\n\ndef toTerm(coef, power):\n if not coef or coef == 0: return ''\n if power == 0: \n p = ''\n elif power == 1:\n p = 'x'\n else:\n p = 'x^' + str(power)\n \n term = ('' if abs(coef) == 1 and power > 0 else str(abs(coef))) + p\n return (' - ' if coef < 0 else ' + ') + str(term) if term else ''\n\ndef co2poly(coefs):\n terms = [toTerm(c, i) for i, c in enumerate(coefs)]\n terms.reverse()\n t = ''.join(terms)\n return (t[3:] if t.startswith(' +') else t[1:]) + ' = 0'\n\ndef toCoefs(coefs, root):\n return [ n * -root + c for (c, n) in zip([0] + coefs, coefs + [0]) ]\n\ndef polynomialize(roots):\n coefs = reduce(toCoefs, roots, [1])\n return co2poly(coefs)\n", "def monomial(factor, index):\n if factor < 0:\n if factor == -1:\n if not index:\n return \" - 1\"\n return \" - x\" if index == 1 else \" - x^{}\".format(index)\n else:\n if not index:\n return \" - {}\".format(abs(factor))\n return \" - {}x\".format(abs(factor)) if index == 1 else \" - {}x^{}\".format(abs(factor), index)\n else:\n if factor == 1:\n if not index:\n return \" + 1\"\n return \" + x\" if index == 1 else \" + x^{}\".format(index)\n else:\n if not index:\n return \" + {}\".format(factor)\n return \" + {}x\".format(factor) if index == 1 else \" + {}x^{}\".format(factor, index)\n\ndef polynomialize(roots):\n length, roots, parameters = len(roots), filter(lambda i : i, roots), [1]\n for root in roots:\n parameters = [1] + [parameters[i+1] - root*parameters[i] for i in range(len(parameters)-1)] + [-parameters[-1]*root]\n return \"\".join([monomial(param, length-i) for i, param in enumerate(parameters) if param])[3:] + \" = 0\"", "def monomial(factor, index):\n if factor < 0:\n if factor == -1:\n if not index:\n return \" - 1\"\n return \" - x\" if index == 1 else \" - x^{}\".format(index)\n else:\n if not index:\n return \" - {}\".format(abs(factor))\n return \" - {}x\".format(abs(factor)) if index == 1 else \" - {}x^{}\".format(abs(factor), index)\n else:\n if factor == 1:\n if not index:\n return \" + 1\"\n return \" + x\" if index == 1 else \" + x^{}\".format(index)\n else:\n if not index:\n return \" + {}\".format(factor)\n return \" + {}x\".format(factor) if index == 1 else \" + {}x^{}\".format(factor, index)\n\n\ndef polynomialize(roots):\n zeros, roots2, length = roots.count(0), [r for r in roots if r], len(roots)\n parameters = [1]\n for root in roots2:\n parameters = [1] + [parameters[i+1] - root*parameters[i] for i in range(len(parameters)-1)] + [-parameters[-1]*root]\n return \"\".join([monomial(param, length-i) for i, param in enumerate(parameters) if param])[3:] + \" = 0\"", "def polynomialize(roots):\n poly = [1]\n for root in roots:\n new_poly = [1]\n for i in range(1, len(poly)):\n new_poly.append(poly[i] - root * poly[i - 1])\n new_poly.append(poly[-1] * -root)\n poly = new_poly\n \n str_poly = []\n for i, coeff in enumerate(poly):\n power = len(roots) - i\n if coeff < 0:\n str_poly.append(' - ')\n elif coeff > 0:\n if i:\n str_poly.append(' + ')\n else:\n continue\n coeff = abs(coeff)\n if power == 0 or coeff != 1:\n str_poly.append(str(coeff))\n if power != 0:\n str_poly.append('x')\n if power >= 2:\n str_poly.append('^')\n str_poly.append(str(power))\n return f'{\"\".join(str_poly)} = 0'"] | {"fn_name": "polynomialize", "inputs": [[[0]], [[0, 0]], [[-1]], [[1]], [[1, -1]], [[0, -2, -3]], [[0, 2, 3]], [[1, 2, 3, 4, 5]]], "outputs": [["x = 0"], ["x^2 = 0"], ["x + 1 = 0"], ["x - 1 = 0"], ["x^2 - 1 = 0"], ["x^3 + 5x^2 + 6x = 0"], ["x^3 - 5x^2 + 6x = 0"], ["x^5 - 15x^4 + 85x^3 - 225x^2 + 274x - 120 = 0"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 9,756 |
def polynomialize(roots):
|
dec9694b8cfacaf778607e9fd5f44271 | UNKNOWN | In this Kata, you're to complete the function `sum_square_even_root_odd`.
You will be given a list of numbers, `nums`, as the only argument to the function. Take each number in the list and *square* it if it is even, or *square root* the number if it is odd. Take this new list and find the *sum*, rounding to two decimal places.
The list will never be empty and will only contain values that are greater than or equal to zero.
Good luck! | ["def sum_square_even_root_odd(nums):\n return round(sum(n ** 2 if n % 2 == 0 else n ** 0.5 for n in nums), 2)", "def sum_square_even_root_odd(nums):\n return round(sum(n**(0.5 if n % 2 else 2) for n in nums), 2)", "sum_square_even_root_odd=lambda l:round(sum(x**[2,.5][x&1]for x in l),2)\n", "def sum_square_even_root_odd(nums):\n return round(sum(a ** (2, 0.5)[a % 2] for a in nums), 2)\n", "def sum_square_even_root_odd(nums):\n return round(sum(x**2 if x%2==0 else x**.5 for x in nums), 2)", "import math\n\ndef sum_square_even_root_odd(nums):\n return float('%.2f' % sum([x*x if x%2 == 0 else math.sqrt(x) for x in nums]))\n", "def sum_square_even_root_odd(l):\n return round(sum((n ** 2 if n % 2 == 0 else n ** 0.5) for n in l), 2)", "def sum_square_even_root_odd(nums):\n return round(sum(n ** ((2 - n % 2) / (1 + n % 2)) for n in nums), 2)\n \n", "def sum_square_even_root_odd(nums):\n return round(sum(i**[2,0.5][i&1] for i in nums),2)\n", "def sum_square_even_root_odd(nums):\n return round(sum([x**0.5 if x%2 else x**2 for x in nums]),2)"] | {"fn_name": "sum_square_even_root_odd", "inputs": [[[4, 5, 7, 8, 1, 2, 3, 0]], [[1, 14, 9, 8, 17, 21]]], "outputs": [[91.61], [272.71]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,080 |
def sum_square_even_root_odd(nums):
|
716d14e082b618708522c524d34b7370 | UNKNOWN | # Task
Given array of integers, for each position i, search among the previous positions for the last (from the left) position that contains a smaller value. Store this value at position i in the answer. If no such value can be found, store `-1` instead.
# Example
For `items = [3, 5, 2, 4, 5]`, the output should be `[-1, 3, -1, 2, 4]`.
# Input/Output
- `[input]` integer array `arr`
Non-empty array of positive integers.
Constraints: `3 ≤ arr.length ≤ 1000, 1 ≤ arr[i] ≤ 1000.`
- `[output]` an integer array
Array containing answer values computed as described above. | ["def array_previous_less(arr):\n return [next((y for y in arr[:i][::-1] if y < x),-1) for i,x in enumerate(arr)]", "def array_previous_less(arr):\n out = []\n \n for i, n in enumerate(arr):\n x = -1\n for m in arr[:i][::-1]:\n if m < n:\n x = m\n break\n out.append(x)\n \n return out", "def array_previous_less(arr):\n new = [-1]\n for i in range(1, len(arr)):\n curr = arr[i]\n while i and arr[i - 1] >= curr:\n i -= 1\n if i:\n new.append(arr[i - 1])\n else:\n new.append(-1)\n return new", "def array_previous_less(a):\n r = []\n for i, x in enumerate(a):\n for j in range(i - 1, -1, -1):\n if a[j] < x:\n r.append(a[j])\n break\n else:\n r.append(-1)\n return r", "def array_previous_less(arr):\n return [ next( (arr[i-j] for j in range(1,i+1) if arr[i-j]<v), -1)\n for i,v in enumerate(arr) ]", "def array_previous_less(arr):\n r = []\n for i, v in enumerate(arr):\n x = -1\n for w in arr[:i]:\n if w < v:\n x = w\n r.append(x)\n return r", "import numpy as np\ndef array_previous_less(arr):\n arr = arr[::-1]\n output = np.full(len(arr), -1)\n for i in range(len(arr)):\n for j in arr[i+1:]:\n if j<arr[i]:\n output[i] = j\n break\n return output.tolist()[::-1]", "def array_previous_less(arr):\n return [next((v1 for v1 in arr[:i][::-1] if v1<v),-1) for i,v in enumerate(arr)]", "def array_previous_less(arr):\n r = []\n for i, x in enumerate(arr):\n for j in range(i - 1, -1, -1):\n if arr[j] < x:\n r.append(arr[j])\n break\n else:\n r.append(-1)\n return r", "def array_previous_less(arr):\n output = []\n k = 0\n for i in range(0,len(arr)):\n for j in range(i,-1,-1):\n if arr[j] < arr[i]:\n output.append(arr[j])\n k = 1\n break\n if k == 0:\n output.append(-1)\n elif k == 1:\n k = 0\n return output"] | {"fn_name": "array_previous_less", "inputs": [[[3, 5, 2, 4, 5]], [[2, 2, 1, 3, 4, 5, 5, 3]], [[3, 2, 1]]], "outputs": [[[-1, 3, -1, 2, 4]], [[-1, -1, -1, 1, 3, 4, 4, 1]], [[-1, -1, -1]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,259 |
def array_previous_less(arr):
|
15bda8b0a7712f9d86de2c61e2706da2 | UNKNOWN | You are playing euchre and you want to know the new score after finishing a hand. There are two teams and each hand consists of 5 tricks. The team who wins the majority of the tricks will win points but the number of points varies. To determine the number of points, you must know which team called trump, how many tricks each team won, and if anyone went alone. Scoring is as follows:
For the team that called trump:
- if they win 2 or less tricks -> other team wins 2 points
- if they win 3 or 4 tricks -> 1 point
- if they don't go alone and win 5 tricks -> 2 points
- if they go alone and win 5 tricks -> 4 points
Only the team who called trump can go alone and you will notice that it only increases your points if you win all 5 tricks.
Your job is to create a method to calculate the new score. When reading the arguments, team 1 is represented by 1 and team 2 is represented by 2. All scores will be stored with this order: { team1, team2 }. | ["def update_score(score, trump, alone, tricks):\n done = tricks.count(trump)\n mul = 2 if done == 5 and alone else 1\n add = 1 if done in (3, 4) else 2\n winner = trump if done > 2 else (3 - trump)\n return [pts + (add * mul if team == winner else 0) for team, pts in enumerate(score, 1)]", "def update_score(score, trump, alone, tricks):\n ts, sc = tricks.count(trump), score[:]\n if ts<=2 : sc[(trump-1)^1] += 2\n else: sc[trump-1] += [[1,2][not alone and ts==5],4][alone and ts==5]\n return sc", "def update_score(current_score, called_trump, alone, tricks):\n n = tricks.count(called_trump)\n if n <= 2:\n called_trump = 3 - called_trump\n p = 2\n elif n <= 4:\n p = 1\n else:\n p = 4 if alone else 2\n current_score[called_trump > 1] += p\n return current_score", "def update_score(current_score, called_trump, alone, tricks):\n new_score = current_score\n won = 0\n for score in tricks:\n if score == called_trump:\n won += 1\n if won <= 2:\n if called_trump == 1:\n new_score[1] += 2\n else:\n new_score[0] += 2\n elif won == 3 or won == 4:\n new_score[called_trump - 1] += 1\n elif won == 5 and alone == True:\n new_score[called_trump - 1] += 4\n else:\n new_score[called_trump - 1] += 2\n return new_score", "POINTS = [[0, 2], # 0 tricks ; index 0 = caller ; 1 = opponent\n [0, 2], # 1 tricks\n [0, 2], # 2 tricks\n [1, 0], # 3 tricks\n [1, 0], # 4 tricks\n [2, 0],] # 5 tricks\n\ndef update_score(current_score, called_trump, alone, tricks):\n n_tricks = tricks.count(called_trump)\n inc = POINTS[n_tricks][:]\n if called_trump == 2: inc.reverse()\n return [ v+inc[i] + 2 * (i == called_trump-1 and n_tricks == 5 and alone) for i,v in enumerate(current_score) ]", "def update_score(current_score, called_trump, alone, tricks):\n a = current_score[:]\n w = tricks.count(called_trump)\n if w < 3:\n a[(called_trump - 1) ^ 1] += 2\n else:\n a[called_trump - 1] += 1 if w < 5 else 4 if alone else 2\n return a", "def update_score(current_score, called_trump, alone, tricks):\n w = tricks.count(called_trump)\n current_score[(w > 2) - called_trump] += 2 - (2 < w < 5) + 2 * (w == 5) * alone\n return current_score", "_OUTCOMES = [2,2,2,2,1,1,2,4]\n\ndef update_score(current_score, called_trump, alone, tricks):\n score = [0] + current_score\n winner = 1 + (tricks.count(2) > 2)\n i = 4 * (winner == called_trump) + 2 * (tricks.count(winner) == 5) + alone\n score[winner] += _OUTCOMES[i]\n return score[-2:]", "def update_score(current_score, called_trump, alone, tricks):\n tricks_won = sum([int(val / called_trump) for val in tricks if val == called_trump])\n if alone and tricks_won == 5: points_won = 4\n elif tricks_won == 5: points_won = 2\n elif tricks_won == 5: points_won = 2\n elif tricks_won >=3 : points_won = 1\n else:\n points_won = 2\n if called_trump == 1:called_trump = 2\n else: called_trump = 1\n current_score[called_trump-1] = current_score[called_trump-1] + points_won\n return current_score", "def update_score(current_score, called_trump, alone, tricks):\n score=current_score[:]\n c=tricks.count(called_trump)\n i=called_trump-1\n if c<=2:\n score[i^1]+=2\n elif c<5:\n score[i]+=1\n elif alone:\n score[i]+=4\n else:\n score[i]+=2\n return score"] | {"fn_name": "update_score", "inputs": [[[4, 0], 1, false, [2, 2, 2, 2, 2]], [[4, 2], 1, true, [2, 2, 2, 2, 2]], [[4, 4], 2, false, [2, 2, 2, 2, 2]], [[4, 6], 2, true, [2, 2, 2, 2, 2]], [[7, 2], 1, false, [1, 2, 2, 2, 2]], [[7, 4], 1, true, [1, 2, 2, 2, 2]], [[7, 6], 2, false, [1, 2, 2, 2, 2]], [[7, 7], 2, true, [1, 2, 2, 2, 2]], [[5, 1], 1, false, [1, 1, 2, 2, 2]], [[5, 3], 1, true, [1, 1, 2, 2, 2]], [[5, 5], 2, false, [1, 1, 2, 2, 2]], [[5, 6], 2, true, [1, 1, 2, 2, 2]], [[3, 4], 1, false, [1, 1, 1, 2, 2]], [[4, 4], 1, true, [1, 1, 1, 2, 2]], [[5, 4], 2, false, [1, 1, 1, 2, 2]], [[7, 4], 2, true, [1, 1, 1, 2, 2]], [[3, 9], 1, false, [1, 1, 1, 1, 2]], [[4, 9], 1, true, [1, 1, 1, 1, 2]], [[5, 9], 2, false, [1, 1, 1, 1, 2]], [[7, 9], 2, true, [1, 1, 1, 1, 2]], [[0, 8], 1, false, [1, 1, 1, 1, 1]], [[2, 8], 1, true, [1, 1, 1, 1, 1]], [[6, 8], 2, false, [1, 1, 1, 1, 1]], [[8, 8], 2, true, [1, 1, 1, 1, 1]]], "outputs": [[[4, 2]], [[4, 4]], [[4, 6]], [[4, 10]], [[7, 4]], [[7, 6]], [[7, 7]], [[7, 8]], [[5, 3]], [[5, 5]], [[5, 6]], [[5, 7]], [[4, 4]], [[5, 4]], [[7, 4]], [[9, 4]], [[4, 9]], [[5, 9]], [[7, 9]], [[9, 9]], [[2, 8]], [[6, 8]], [[8, 8]], [[10, 8]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,559 |
def update_score(current_score, called_trump, alone, tricks):
|
188d9c6a8547380d811e38ffa154d811 | UNKNOWN | There's a new security company in Paris, and they decided to give their employees an algorithm to make first name recognition faster. In the blink of an eye, they can now detect if a string is a first name, no matter if it is a one-word name or an hyphenated name. They're given this documentation with the algorithm:
*In France, you'll often find people with hyphenated first names. They're called "prénoms composés".
There could be two, or even more words linked to form a new name, quite like jQuery function chaining ;).
They're linked using the - symbol, like Marie-Joelle, Jean-Michel, Jean-Mouloud.
Thanks to this algorithm, you can now recognize hyphenated names quicker than Flash !*
(yeah, their employees know how to use jQuery. Don't ask me why)
Your mission if you accept it, recreate the algorithm.
Using the function **showMe**, which takes a **yourID** argument, you will check if the given argument is a name or not, by returning true or false.
*Note that*
- String will either be a one-word first name, or an hyphenated first name , its words being linked by "-".
- Words can only start with an uppercase letter, and then lowercase letters (from a to z)
Now is your time to help the guards ! | ["import re\n\n\ndef show_me(name):\n return bool(re.match(r'(-[A-Z][a-z]+)+$', '-' + name))", "def show_me(name):\n return all(word.isalpha() and word.capitalize() == word for word in name.split('-'))", "from re import match, compile\ndef show_me(name):\n return match(compile(r'^[A-Z][a-z]+(?:-[A-Z][a-z]+)*$'), name) != None", "import re\n\ndef show_me(name):\n return bool(re.match(r'([A-Z][a-z]+-)*[A-Z][a-z]+$', name))", "import re\n\ndef show_me(s):\n return bool(re.match(r\"[A-Z][a-z]*(-[A-Z][a-z]*)*$\", s))", "def show_me(name):\n return \"--\" not in name and name[0] != \"-\" and name[-1] != \"-\" and name.title() == name and all([c.isalpha() or c == \"-\" for c in name])", "import re\ndef show_me(name):\n return re.fullmatch(r'[A-Z][a-z]+(-[A-Z][a-z]+)*', name) is not None", "import re\n\ndef show_me(name):\n return re.match( '^[A-Z][a-z]*(-[A-Z][a-z]*)*$', name) != None", "import re\ndef show_me(name):\n return re.fullmatch(r'[A-Z][a-z]*(-[A-Z][a-z]*)*', name) is not None", "import re\n\ndef show_me(name):\n return bool(re.match('[A-Z][a-z]+(-[A-Z][a-z]+)*$', name))"] | {"fn_name": "show_me", "inputs": [["Francis"], ["Jean-Eluard"], ["Le Mec"], ["Bernard-Henry-Levy"], ["Meme Gertrude"], ["A-a-a-a----a-a"], ["Z-------------"], ["Jean-luc"], ["Jean--Luc"], ["JeanLucPicard"], ["-Jean-Luc"], ["Jean-Luc-Picard-"]], "outputs": [[true], [true], [false], [true], [false], [false], [false], [false], [false], [false], [false], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,120 |
def show_me(name):
|
1baaed72ab2659700f05a5852ad01ca9 | UNKNOWN | Given the number n, return a string which shows the minimum number of moves to complete the tower of Hanoi consisting of n layers.
Tower of Hanoi : https://en.wikipedia.org/wiki/Tower_of_Hanoi
Example - 2 layered Tower of Hanoi
Input: n=2
Start
[[2, 1], [], []]
Goal
[[], [], [2, 1]]
Expected Output : '[[2, 1], [], []]\n[[2], [1], []]\n[[], [1], [2]]\n[[], [], [2, 1]]' | ["def hanoiArray(n):\n A, B, C = list(range(n, 0, -1)), [], []\n res = [str([A, C, B])]\n def rec(n, X, Y, Z):\n if not n: return\n rec(n-1, X, Z, Y)\n Y.append(X.pop())\n res.append(str([A, C, B]))\n rec(n-1, Z, Y, X) \n rec(n, A, B, C)\n return '\\n'.join(res)", "from io import StringIO\n\ndef move(n, a, b, c, source, target, auxiliary, output):\n if n > 0:\n move(n - 1, a, b, c, source, auxiliary, target, output)\n target.append(source.pop())\n print([a, b, c], file=output)\n move(n - 1, a, b, c, auxiliary, target, source, output)\n\ndef hanoiArray(n):\n a, b, c = list(range(n, 0, -1)), [], []\n with StringIO() as output:\n print([a, b, c], file=output)\n move(n, a, b, c, a, c, b, output)\n return output.getvalue().rstrip('\\n')", "m=lambda n,l,a,b,c:n and m(n-1,l,a,c,b)+[l[c].append(l[a].pop())or str(l)]+m(n-1,l,b,a,c)or[]\nhanoiArray=lambda n:(lambda l:str(l)+'\\n'+'\\n'.join(map(str,m(n,l,0,1,2))))([list(range(n,0,-1)),[],[]])", "def maketrans(n, a, b, c):\n if n == 0: return []\n return maketrans(n-1, a, c, b) + [[a, b]] + maketrans(n - 1, c, b, a)\n\n\ndef hanoiArray(n):\n transitions = maketrans(n, 0, 2, 1)\n state = [[i for i in range(n, 0, -1)], [], []]\n res = str(state)\n while transitions:\n from_peg, to_peg = transitions.pop(0)\n state[to_peg].append(state[from_peg].pop())\n res += '\\n' + str(state)\n return res", "def hanoiArray(n):\n\n def move(n, source, target, auxiliary):\n if n > 0:\n # Move n - 1 disks from source to auxiliary, so they are out of the way\n move(n - 1, source, auxiliary, target)\n\n # Move the nth disk from source to target\n target.append(source.pop())\n\n # Store new state\n res.append([A[:], B[:], C[:]])\n\n # Move the n - 1 disks that we left on auxiliary onto target\n move(n - 1, auxiliary, target, source)\n \n A = list(range(n, 0, -1))\n B = []\n C = []\n\n res = [[A[:], B[:], C[:]]]\n\n # Initiate call from source A to target C with auxiliary B\n move(n, A, C, B)\n return '\\n'.join(map(str, res))", "def hanoiArray(n):\n initial = [x for x in range(n,0,-1)]\n tow = [initial,[],[]]\n ret = str(tow)\n \n def move(f,t):\n nonlocal tow, ret\n tow[t].append(tow[f].pop())\n ret = ret + '\\n' + str(tow)\n \n def solve(n,f,h,t):\n if n == 0:\n pass\n else:\n solve(n-1,f,t,h)\n move(f,t)\n solve(n-1,h,f,t)\n \n solve(n,0,1,2)\n\n return ret\n \n", "def Hanoi_Solution(n):\n # Establish base cases\n if n == 0:\n return([[],[],[]])\n if n == 1:\n return([[[1],[],[]],[[],[],[1]]])\n # Setup recursion\n else:\n L = len(Hanoi_Solution(n-1))\n # Move from [[n,..,1],[],[]] to [n,[n-1,...,1],[]] \n first_half = Hanoi_Solution(n-1) \n for i in range(L):\n # Insert the new number at the beginning in the previous solution\n first_half[i][0].insert(0,n)\n # Switch the last two positions in each move\n temp_1 = first_half[i][2]\n first_half[i][2] = first_half[i][1]\n first_half[i][1] = temp_1\n # Move from [[],[n-1,...,1],[n]] to [[],[],[n,...,1]]\n second_half = Hanoi_Solution(n-1)\n for i in range(L):\n # Insert the new number at the end in the previous solution\n second_half[i][2].insert(0,n)\n # Switch the first two positions in each move\n temp_2 = second_half[i][1]\n second_half[i][1] = second_half[i][0]\n second_half[i][0] = temp_2\n # Join the two halves into a single solution of length 2**n\n for i in second_half:\n first_half.append(i)\n return(first_half)\n\n# Print the solution in the string format suggested\ndef hanoiArray(n):\n return((''.join(str(i)+'\\n' for i in Hanoi_Solution(n)))[:-1])", "def hanoi(n,a,b):\n if n==1:\n return [(a,b)]\n else:\n c=3-a-b\n return hanoi(n-1,a,c)+[(a,b)]+hanoi(n-1,c,b)\n\n\ndef hanoiArray(n):\n moves=hanoi(n,0,2)\n towers=[list(range(n,0,-1)),[],[]]\n ans=[str(towers)]\n for i,j in moves:\n towers[j].append(towers[i].pop())\n ans.append(str(towers))\n return '\\n'.join(ans)"] | {"fn_name": "hanoiArray", "inputs": [[2], [3]], "outputs": [["[[2, 1], [], []]\n[[2], [1], []]\n[[], [1], [2]]\n[[], [], [2, 1]]"], ["[[3, 2, 1], [], []]\n[[3, 2], [], [1]]\n[[3], [2], [1]]\n[[3], [2, 1], []]\n[[], [2, 1], [3]]\n[[1], [2], [3]]\n[[1], [], [3, 2]]\n[[], [], [3, 2, 1]]"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,482 |
def hanoiArray(n):
|
ab8e5c824662c5cff2c9c17e50181e24 | UNKNOWN | Base on the fairy tale [Diamonds and Toads](https://en.wikipedia.org/wiki/Diamonds_and_Toads) from Charles Perrault. In this kata you will have to complete a function that take 2 arguments:
- A string, that correspond to what the daugther says.
- A string, that tell you wich fairy the girl have met, this one can be `good` or `evil`.
The function should return the following count as a hash:
- If the girl have met the `good` fairy:
- count 1 `ruby` everytime you see a `r` and 2 everytime you see a `R`
- count 1 `crystal` everytime you see a `c` and 2 everytime you see a `C`
- If the girl have met the `evil` fairy:
- count 1 `python` everytime you see a `p` and 2 everytime uou see a `P`
- count 1 `squirrel` everytime you see a `s` and 2 everytime you see a `S`
**Note**: For this kata I decided to remplace the normal `Diamonds` and `Toads` by some programming languages. And just discover that [Squirrel](https://en.wikipedia.org/wiki/Squirrel_(programming_language) is a programming language. | ["from collections import Counter\n\ndef diamonds_and_toads(sentence, fairy):\n c = Counter(sentence)\n d = {'good':['ruby', 'crystal'], 'evil':['python', 'squirrel']}\n\n return {s:c[s[0]] + 2*c[s[0].upper()] for s in d[fairy]}", "def diamonds_and_toads(sentence,fairy):\n items = {\"ruby\":0, \"crystal\":0} if fairy==\"good\" else {\"python\":0,\"squirrel\":0}\n for key in items.keys():\n items[key] = sentence.count(key[0])+2*sentence.count(key[0].upper())\n \n return items", "def diamonds_and_toads(sentence,fairy):\n res={}\n if fairy == 'good':\n res['ruby']=sentence.count('r')+sentence.count('R')*2\n res['crystal']=sentence.count('c')+sentence.count('C')*2\n elif fairy == 'evil':\n res['python']=sentence.count('p')+sentence.count('P')*2\n res['squirrel']=sentence.count('s')+sentence.count('S')*2\n \n return res", "def do(a,b,c,d,s):\n dc = {a:0,b:0}\n for i in s:\n if i in c : dc[[a,b][i in d]] += [1,2][i.isupper()]\n return dc\ndiamonds_and_toads=lambda s,f:do(*[['ruby','crystal','rcRC','cC',s],['python','squirrel','psPS','sS',s]][f=='evil'])", "def diamonds_and_toads(phrase,fairy):\n if fairy == 'good':\n return {\"ruby\": phrase.count('r') + phrase.count('R')*2 , \"crystal\": phrase.count('c') + phrase.count('C')*2 }\n else:\n return {\"python\": phrase.count('p') + phrase.count('P')*2 , \"squirrel\": phrase.count('s') + phrase.count('S')*2 }", "def diamonds_and_toads(sentence,fairy):\n if fairy == 'good':\n return {'ruby': sentence.count('r')+sentence.count('R')*2,\n 'crystal': sentence.count('c')+sentence.count('C')*2}\n else:\n return {'python': sentence.count('p')+sentence.count('P')*2,\n 'squirrel': sentence.count('s')+sentence.count('S')*2}", "diamonds_and_toads=lambda s,f: {\"ruby\": s.count('r')+s.count('R')*2, \"crystal\": s.count('c')+s.count('C')*2} if f==\"good\" else {\"python\": s.count('p')+s.count('P')*2, \"squirrel\": s.count('s')+s.count('S')*2}", "def diamonds_and_toads(sentence, fairy):\n jewels = [\"ruby\", \"crystal\"] if fairy == \"good\" else [\"python\", \"squirrel\"] \n return {j: sentence.count(j[0]) + 2 * sentence.count(j[0].upper()) for j in jewels}", "diamonds_and_toads=lambda s,f:{k:s.count(k[0])+2*s.count(k[0].upper())for k in['crystal','python','ruby','squirrel'][f<'f'::2]}", "def diamonds_and_toads(sentence,fairy):\n if fairy == \"good\":\n return {\"ruby\": sentence.count('r') + 2 * sentence.count('R'), \"crystal\": sentence.count('c') + 2 * sentence.count('C')}\n return {\"python\": sentence.count('p') + 2 * sentence.count('P'), \"squirrel\": sentence.count('s') + 2 * sentence.count('S')}"] | {"fn_name": "diamonds_and_toads", "inputs": [["Ruby and Crystal", "good"], ["This string contain some Ruby and some Crystal in it", "good"], ["Python and Squirrel", "evil"], ["This string contain some Python and some Squirrel in it", "evil"]], "outputs": [[{"ruby": 3, "crystal": 2}], [{"ruby": 4, "crystal": 3}], [{"python": 2, "squirrel": 2}], [{"python": 2, "squirrel": 6}]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,758 |
def diamonds_and_toads(sentence,fairy):
|
14fd856355426bdd735499c895ee6adf | UNKNOWN | Your coworker was supposed to write a simple helper function to capitalize a string (that contains a single word) before they went on vacation.
Unfortunately, they have now left and the code they gave you doesn't work. Fix the helper function they wrote so that it works as intended (i.e. make the first character in the string "word" upper case).
Don't worry about numbers, special characters, or non-string types being passed to the function. The string lengths will be from 1 character up to 10 characters, but will never be empty. | ["def capitalize_word(word):\n return word.capitalize()\n\n # .capitilize() for the first word in the string\n # .title() for each word in the string\n", "def capitalize_word(word):\n return word.capitalize()", "def capitalize_word(word):\n\n return \"\".join(char.capitalize() for char in word.split())", "def capitalize_word(word):\n return str.capitalize(word)", "def capitalize_word(word: str) -> str:\n \"\"\" Capitalize passed string. \"\"\"\n return word.capitalize()", "def capitalize_word(word):\n first = word[0].upper()\n remaining = word[1:].lower()\n text = first + remaining\n return text\n", "def capitalize_word(word):\n a = word.lower()\n b = a.capitalize()\n return b", "def capitalize_word(word):\n return \"\".join(word.capitalize())\n\n\n'''delicious'''\n", "def capitalize_word(word):\n return \"\".join(word[0].upper() + word[1:])", "def capitalize_word(word):\n capLetter = \"\".join(char.capitalize() for char in word[0])\n capOthers = \"\".join(char.lower() for char in word[1:10])\n capWord = capLetter + capOthers\n return(str(capWord))", "def capitalize_word(word):\n word=word.lower()\n word=word.title()\n return word", "def capitalize_word(word):\n return word.title()\n\nprint(capitalize_word(\"word\"))", "def capitalize_word(word):\n return word.title()", "def capitalize_word(word): \n ans = \"\".join(char.lower() for char in word)\n return ans.capitalize()", "def capitalize_word(word):\n for char in word:\n len(word) > 1 and len(word) < 10\n return word.capitalize() \n\nprint(capitalize_word(\"blea\"))", "def capitalize_word(w):\n for char in w[0]:\n return ''.join(char.title())+w[1:]", "def capitalize_word(word):\n final = \"\"\n pos = 0\n while pos < len(word):\n if pos == 0:\n final += word[pos].upper()\n else:\n final += word[pos]\n pos += 1\n return final", "def capitalize_word(word):\n for char in word:\n return word.title()", "def capitalize_word(word):\n word_2 = \"\"\n for i in range(len(word)):\n if i == 0:\n word_2 += word[i].upper()\n else:\n word_2 += word[i]\n return word_2", "def capitalize_word(word):\n# new_list=list(word)\n# first_letter = new_list.pop(0)\n# cap_letter = first_letter.capitalize()\n# new_list.insert(0,cap_letter)\n# print(cap_letter)\n# print(new_list)\n# return (\"\".join(new_list))\n return(word.title())", "def capitalize_word(word):\n char = [char.upper() for char in word]\n return \"\".join(char[0] + word[1:])", "def capitalize_word(word):\n newword = \"\"\n x=0\n for n in word:\n if x ==0:\n newword+=(word[0].upper())\n x+=1\n else:\n newword+=n\n \n \n \n \n return newword", "def capitalize_word(*word):\n return \"\".join(char.title() for char in word)", "def capitalize_word(word):\n if(len(word) >= 2):\n return word[0].upper() + word[1:]\n else:\n return word.upper()", "def capitalize_word(word):\n str = ''\n lst = list()\n for i in word :\n lst.append(i)\n \n lst[0] = lst[0].upper()\n for i in lst :\n str += i\n return str\n", "def capitalize_word(word):\n return word[0].upper() + (\"\" if len(word) == 1 else word[1:])", "def capitalize_word(word):\n ls = list(word) # Turns string into a list of characters\n ls[0] = ls[0].upper() # Makes the first letter a capital\n return \"\".join(ls) # Joins the list elements back into a string.", "def capitalize_word(word):\n firstLetter = word[0:1]\n restWord = word[1:]\n firstLetter = firstLetter.upper()\n return firstLetter + restWord", "def capitalize_word(word):\n return word[0].upper() + word[1:len(word)].lower()", "def capitalize_word(w):\n return w[0].upper() + w[1:].lower()", "capitalize_word = lambda s: s.capitalize()", "def capitalize_word(word):\n return \"\".join(char.upper() + word[1:] for char in word[:1])", "def capitalize_word(word):\n return \"\".join(word.capitalize())\n #return \"\".join(char.upper() for char in word)\n", "def capitalize_word(word):\n return capitalize(word)\n\ndef capitalize(word):\n s=''\n for i in range(len(word)):\n if (i==0):\n s+=word[i].upper()\n else:\n s+=word[i].lower()\n return s", "def capitalize_word(word):\n x = word[0].upper()\n return x + word[1:]", "def capitalize_word(word):\n words=word.capitalize()\n return words", "def capitalize_word(word):\n return word[0].upper() + \"\".join(char for char in word[1::])", "def capitalize_word(word):\n flit = list(word.lower())\n flit[0] = flit[0].upper()\n return \"\".join(flit)", "def capitalize_word(word):\n letter = word\n return letter.title()", "def capitalize_word(word):\n \n ans = (word).capitalize()\n \n return ans\n", "def capitalize_word(word):\n for i in word: \n if word[0].lower():\n return word[0].upper() + word[1:]", "def capitalize_word(word):\n up = str(word) #first indicating it is a string\n return up.capitalize() #using the capitialize function which automatically capitlizes the first word\n", "def capitalize_word(word):\n return str(word[0]).upper()+\"\".join(char for char in word[1:])\n#return word.total()\n", "def capitalize_word(word):\n #return \"\".join(char.upper() for char in word)\n \n word = word.lower()\n x = word.capitalize()\n return x", "def capitalize_word(word=\"\"):\n return f\"{word.title()}\"", "def capitalize_word(word):\n char = 0\n while char < len(word):\n if char == 0:\n word2 = word[char].upper()\n else:\n word2 = word2 + word[char]\n char = char + 1\n return word2", "def capitalize_word(word):\n#1 return word.capitalize()\n#2\n return word[0].upper() + word[1:].lower()", "def capitalize_word(word):\n if len(word) == 1:\n return word.upper()\n return word[0].upper() + word[1:]", "def capitalize_word(word):\n return word[0].upper()+word[1-len(word):] if len(word)!=1 else word[0].upper() ", "def capitalize_word(word):\n return word.upper().title()", "def capitalize_word(word):\n# return \"\".join(char.title() for char in word)\n return word.title()", "def capitalize_word(word=''):\n return word.capitalize()", "capitalize_word = lambda n : n.title()", "def capitalize_word(word):\n return word.upper().capitalize()\n \n", "import string\n\ndef capitalize_word(word):\n return f'{string.capwords(word)}'", "import string\n\ndef capitalize_word(word):\n return string.capwords(word)", "def capitalize_word(word):\n res = []\n res[:] = word\n print(res)\n newarry = []\n for i in range(0, len(res)):\n print((res[i]))\n if(res[i] == res[0]):\n newarry.append(res[0].upper())\n else:\n newarry.append(res[i])\n print((\"\".join(newarry)))\n answer = \"\".join(newarry)\n return answer\n", "def capitalize_word(word):\n return (word.capitalize())\n\ncapitalize_word(\"hi\")", "def capitalize_word(word):\n #return word.title()\n return \"\".join(char.upper() if idx==0 else char for idx,char in enumerate(word))", "def capitalize_word(word):\n init = word[0]\n rem = word[1: len(word)]\n return \"\".join([init.upper(),rem])", "def capitalize_word(word):\n return \"\"+str(word.lower().capitalize())", "def capitalize_word(word):\n# return \"\".join(char.capitalize() for char in word)\n return word.capitalize()", "def capitalize_word(word):\n word=str(word)\n return word.capitalize()", "def capitalize_word(word):\n if len(word) == 1:\n return \"\".join(char.upper() for char in word)\n else:\n return word[0].upper() + word[1:]", "def capitalize_word(word):\n if word == word.lower():\n return word.capitalize()", "def capitalize_word(word):\n return \"\".join([char for char in word.title()])", "def capitalize_word(word):\n s = word[0].upper()\n word= s+word[1:]\n return word", "def capitalize_word(word):\n arr=[]\n for i in range(len(word)):\n if i==0:\n arr.append(word[0].upper())\n else:\n arr.append(word[i])\n return ''.join(arr)", "def capitalize_word(word):\n trueword = list(word)\n s = trueword[0]\n trueword[0] = s.upper() \n return ''.join(trueword)\n", "def capitalize_word(word):\n return str(\"\".join(char.capitalize() for char in word)).title()", "def capitalize_word(word):\n \n word = word.replace(word[0], word[0].upper(), 1)\n\n #result = word.replace(word[0], number)\n return word \n \n \n", "def capitalize_word(word):\n first_symbol=word[0].upper()\n return first_symbol+word[1:]", "def capitalize_word(word):\n return ' '.join(word[:1].upper() + word[1:] for word in word.split(' ')) \n\nprint(capitalize_word(\"hello\"))", "def capitalize_word(word):\n word = word.replace(word[0], word[0].upper(), 1)\n return word", "def capitalize_word(word):\n \"\".join(char for char in word)\n return word.capitalize()", "def capitalize_word(word):\n return \"{}\".format(word.capitalize())", "def capitalize_word(word):\n all_lower=word.lower()\n capitalize=all_lower.capitalize()\n return capitalize", "def capitalize_word(word):\n return \"\".join(word[char].upper() if char == 0 else word[char] for char in range(0, len(word)) )", "def capitalize_word(word):\n new=word.lower()\n return new[0].upper()+new[1:] \n \n", "def capitalize_word(word):\n if len(word) < 0:\n return word[0].upper()\n char = word[0]\n word = word[1:]\n char = char.upper()\n return char + word", "def capitalize_word(word):\n return f'{word.title()}'", "def capitalize_word(word):\n a = word[0].upper()\n b=slice(1,len(word))\n y = word[b]\n return a+y", "def capitalize_word(word):\n word = word.lower()\n word = word[0].upper() + word[1:]\n return word", "def capitalize_word(word):\n print(word)\n return \"\".join(char.upper() if word.index(char) == 0 else char for char in word)", "def capitalize_word(word):\n listWord = [word[0].upper()+word[1:]]\n return \"\".join(listWord)", "def capitalize_word(word):\n# return \"\".join(word[0].upper() for char in word)\n# return word.capitalize()\n return word.title()", "def capitalize_word(word):\n word = word\n return word.capitalize()", "def capitalize_word(word):\n return word.capitalize()\nprint(capitalize_word('word'))"] | {"fn_name": "capitalize_word", "inputs": [["word"], ["i"], ["glasswear"]], "outputs": [["Word"], ["I"], ["Glasswear"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 10,758 |
def capitalize_word(word):
|
049a414089728f512d062ddadb6e4405 | UNKNOWN | The male gametes or sperm cells in humans and other mammals are heterogametic and contain one of two types of sex chromosomes. They are either X or Y. The female gametes or eggs however, contain only the X sex chromosome and are homogametic.
The sperm cell determines the sex of an individual in this case. If a sperm cell containing an X chromosome fertilizes an egg, the resulting zygote will be XX or female. If the sperm cell contains a Y chromosome, then the resulting zygote will be XY or male.
Determine if the sex of the offspring will be male or female based on the X or Y chromosome present in the male's sperm.
If the sperm contains the X chromosome, return "Congratulations! You're going to have a daughter.";
If the sperm contains the Y chromosome, return "Congratulations! You're going to have a son."; | ["def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a {}.'.format('son' if 'Y' in sperm else 'daughter')", "def chromosome_check(sperm):\n gender = {\"XY\" : \"son\", \"XX\" : \"daughter\"}\n \n return \"Congratulations! You're going to have a {}.\".format(gender[sperm])", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a %s.\" % ('son', 'daughter')[sperm[1] == 'X']", "def chromosome_check(sperm):\n gender = 'son' if 'Y' in sperm else 'daughter'\n return f\"Congratulations! You're going to have a {gender}.\"", "def chromosome_check(sperm):\n return f'Congratulations! You\\'re going to have a {\"son\" if sperm == \"XY\" else \"daughter\"}.'", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a {}.\".format({\"XY\": \"son\", \"XX\": \"daughter\"}.get(sperm)) ", "def chromosome_check(sperm):\n gender = 'son' if 'Y' in sperm else 'daughter'\n return \"Congratulations! You're going to have a {}.\".format(gender)", "def chromosome_check(sperm):\n d = 'Congratulations! You\\'re going to have a daughter.'\n s = 'Congratulations! You\\'re going to have a son.'\n return s if sperm.find(\"Y\") == 1 else d", "def chromosome_check(s):\n return \"Congratulations! You're going to have a %s.\" % (\"son\" if s[1] == 'Y' else \"daughter\")", "def chromosome_check(sperm):\n # Sperm analysis also requires programming...Yeah. I know. Still I can't help rofling\n if all(i == sperm[0] for i in sperm):\n return 'Congratulations! You\\'re going to have a daughter.'\n return 'Congratulations! You\\'re going to have a son.'\n \n", "def chromosome_check(sperm):\n return f\"Congratulations! You're going to have a {'son' if 'Y' in sperm else 'daughter'}.\"", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a {}.'.format('daughter' if sperm == 'XX' else 'son')\n", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a %s.' %('daughter' if sperm[-1] == 'X' else 'son')", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a son.' if sperm.find('Y') !=-1 else 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n if 'Y' in sperm: return \"Congratulations! You're going to have a son.\"\n return \"Congratulations! You're going to have a daughter.\"", "def chromosome_check(sperm):\n if sperm == \"XY\":\n return(\"Congratulations! You're going to have a son.\")\n else:\n return(\"Congratulations! You're going to have a daughter.\")", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a son.' if sperm == 'XY' else 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n return f\"Congratulations! You\\'re going to have a {['daughter','son']['Y' in sperm]}.\"\n", "def chromosome_check(sperm):\n if sperm == \"XX\":\n return \"Congratulations! You're going to have a daughter.\"\n else:\n return \"Congratulations! You're going to have a son.\" \n \n# Can I just point out that gametes only have one set of chromosomes so the sperm would have 'X' or 'Y' not 'XX' or 'XY'\n", "def chromosome_check(sperm):\n congrats = \"Congratulations! You're going to have a \" \n return congrats + \"son.\" if \"Y\" in sperm else congrats + \"daughter.\"\n", "chromosome_check = lambda sperm: 'Congratulations! You\\'re going to have a {}.'.format(\"son\" if \"Y\" in sperm else \"daughter\")", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a {}\".format( 'son.' if \"Y\" in sperm else \"daughter.\")", "def chromosome_check(sperm: str) -> str:\n \"\"\" Determine if the sex of the offspring based on the X or Y chromosome present in the male's sperm. \"\"\"\n return f\"Congratulations! You\\'re going to have a {'son' if sperm == 'XY' else 'daughter'}.\"", "chromosome_check = {'XY':'Congratulations! You\\'re going to have a son.', 'XX':'Congratulations! You\\'re going to have a daughter.'}.get", "chromosome_check=lambda s: \"Congratulations! You\\'re going to have a daughter.\" if s==\"XX\" else \"Congratulations! You\\'re going to have a son.\"", "def chromosome_check(sperm):\n return('Congratulations! You\\'re going to have a son.','Congratulations! You\\'re going to have a daughter.')[sperm=='XX']", "chromosome_check=lambda s:\"Congratulations! You're going to have a %s.\"%[\"daughter\",\"son\"][\"Y\"in s]", "def chromosome_check(sperm):\n #Your code here\n sex = [\"Congratulations! You\\'re going to have a daughter.\", \"Congratulations! You\\'re going to have a son.\"]\n return (sex[\"Y\" in sperm])", "def chromosome_check(sperm):\n text = 'Congratulations! You\\'re going to have a '\n return text + ('son.', 'daughter.')[sperm == 'XX']", "def chromosome_check(sperm):\n gender = \"son\" if sperm[-1] == \"Y\" else \"daughter\"\n return f\"Congratulations! You're going to have a {gender}.\"", "def chromosome_check(sperm):\n return f\"Congratulations! You're going to have a {'son' if sperm[1] == 'Y' else 'daughter'}.\"", "def chromosome_check(sperm):\n if \"XY\" in sperm:\n return 'Congratulations! You\\'re going to have a son.'\n elif \"XX\" in sperm:\n return 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n ergebnis=''\n if sperm=='XY':\n ergebnis='Congratulations! You\\'re going to have a son.'\n else:\n ergebnis='Congratulations! You\\'re going to have a daughter.'\n return ergebnis ", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a son.' if 'y' in sperm.lower() else\\\n 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a daughter.\" if sperm[0] == sperm[1] \\\n else \"Congratulations! You're going to have a son.\"", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a {}.\".format({\"XY\":\"son\",\"XX\":\"daughter\"}[sperm])", "def chromosome_check(s):\n return \"Congratulations! You\\'re going to have a daughter.\" if s=='XX' else \"Congratulations! You\\'re going to have a son.\"", "def chromosome_check(sperm):\n offspring = \"son\" if \"Y\" in sperm else \"daughter\"\n return f\"Congratulations! You're going to have a {offspring}.\"", "def chromosome_check(sperm):\n gen = \"son\" if \"Y\" in sperm else \"daughter\"\n return f\"Congratulations! You're going to have a {gen}.\"\n", "def chromosome_check(sperm):\n count = 0\n for i in sperm:\n if i == 'Y':\n count += 1\n if count == 1:\n return 'Congratulations! You\\'re going to have a son.'\n else:\n return 'Congratulations! You\\'re going to have a daughter.'\n", "def chromosome_check(sperm):\n sperm_list = list(sperm)\n if sperm_list[0] == sperm_list[1]:\n return 'Congratulations! You\\'re going to have a daughter.'\n return 'Congratulations! You\\'re going to have a son.'", "def chromosome_check(sperm):\n if sperm[-1] == 'Y':\n return 'Congratulations! You\\'re going to have a son.'\n return 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n #Your code here\n if sperm[0:2] == \"XY\":\n return 'Congratulations! You\\'re going to have a son.'\n if sperm[0:2] == \"XX\":\n return 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n k = 'son' if 'Y' in sperm else 'daughter' \n return f'''Congratulations! You're going to have a {k}.'''\n#Your code here\n", "def chromosome_check(sperm):\n sex = 'son' if 'Y' in sperm else 'daughter'\n return f'Congratulations! You\\'re going to have a {sex}.'", "def chromosome_check(sperm):\n if 'Y' in sperm:\n return 'Congratulations! You\\'re going to have a son.' \n if not 'Y' in sperm: \n return 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n return f\"Congratulations! You\\'re going to have a {'son' if sperm[1] == 'Y' else 'daughter'}.\"", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a '+{'XX':\"daughter.\",\"XY\":\"son.\"}[sperm]", "def chromosome_check(s):\n if s==\"XX\": return \"Congratulations! You\\'re going to have a daughter.\"\n if s==\"XY\":return \"Congratulations! You're going to have a son.\"", "def chromosome_check(sperm):\n if sperm == \"XX\":\n result = 'Congratulations! You\\'re going to have a daughter.'\n else:\n result = 'Congratulations! You\\'re going to have a son.'\n return result\n", "def chromosome_check(sperm):\n if sperm == \"XY\":\n return 'Congratulations! You\\'re going to have a son.'\n elif sperm == \"XX\":\n return 'Congratulations! You\\'re going to have a daughter.'\n else:\n return 'Congratulations! You\\'re going to have a daughter.'\n", "def chromosome_check(sperm):\n if sperm==\"XY\":\n return \"Congratulations! You\\'re going to have a son.\"\n elif sperm==\"XX\":\n return \"Congratulations! You're going to have a daughter.\"", "def chromosome_check(sperm):\n template = \"Congratulations! You're going to have \"\n if 'Y' in sperm:\n return template + 'a son.' \n else:\n return template + 'a daughter.'", "def chromosome_check(sperm):\n res = ['son', 'daughter'][sperm == 'XX']\n return f'Congratulations! You\\'re going to have a {res}.'", "def chromosome_check(sperm):\n if sperm[0] == 'X' and sperm[1] == 'X':\n return 'Congratulations! You\\'re going to have a daughter.'\n elif sperm[0] == 'X' and sperm[1] == 'Y':\n return 'Congratulations! You\\'re going to have a son.'\n", "chromosome_check=lambda x:\"Congratulations! You're going to have a son.\" if 'Y' in x else \"Congratulations! You're going to have a daughter.\"", "def chromosome_check(sperm):\n gender = {\"XY\" : \"son\", \"XX\" : \"daughter\"}\n return f\"Congratulations! You're going to have a {gender[sperm]}.\"", "# Determine if the offspring will be male or female based on the X or Y chromosome present in the male's sperm.\n\n# XX = Female\n# XY = Male\ndef chromosome_check(sperm):\n if sperm == 'XY': return 'Congratulations! You\\'re going to have a son.'\n else: return 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n sex = 'son' if sperm[1] == 'Y' else 'daughter'\n return f\"Congratulations! You're going to have a {sex}.\"", "def chromosome_check(sperm):\n \"Wye Ask Wye, Ask Bud Drye\"\n return 'Congratulations! You\\'re going to have a {}.'.format(\"son\" if sperm==\"XY\" else \"daughter\")", "def chromosome_check(sperm):\n return \"Congratulations! You\\'re going to have a {}.\".format([\"son\", \"daughter\"][sperm.count(\"X\")-1])", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a {}.'.format(('son','daughter')['X'==sperm[1]])", "def chromosome_check(sperm):\n b = 'Congratulations! You\\'re going to have a son.'\n g = 'Congratulations! You\\'re going to have a daughter.'\n if sperm == 'XY':\n return b\n else:\n return g", "def chromosome_check(sperm):\n if \"XY\" == sperm:\n return 'Congratulations! You\\'re going to have a son.'\n if \"XX\" == sperm:\n return 'Congratulations! You\\'re going to have a daughter.'", "def chromosome_check(sperm):\n if \"X\" and \"Y\" in sperm:\n return 'Congratulations! You\\'re going to have a son.'\n else:\n return 'Congratulations! You\\'re going to have a daughter.'", "Kind_sperm = {'XY':\"Congratulations! You're going to have a son.\",\\\n 'XX':\"Congratulations! You're going to have a daughter.\"}\ndef chromosome_check(sperm):\n if sperm in Kind_sperm.keys():\n return Kind_sperm[sperm]", "def chromosome_check(sperm):\n msg = 'Congratulations! You\\'re going to have a '\n child = ('daughter.','son.')['Y' in sperm]\n return msg + child", "def chromosome_check(sperm):\n kid = 'son' if 'Y' in sperm else 'daughter'\n return f'Congratulations! You\\'re going to have a {kid}.' ", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a daughter.\" if 'X' == sperm[-1] else \"Congratulations! You're going to have a son.\"", "def chromosome_check(sperm):\n da = \"Congratulations! You're going to have a daughter.\"\n so = \"Congratulations! You're going to have a son.\"\n \n return so if \"Y\" in sperm else da", "def chromosome_check(sperm):\n off_spring = {'XY': 'Congratulations! You\\'re going to have a son.', 'XX':'Congratulations! You\\'re going to have a daughter.'}\n return off_spring[sperm]\n #Your code here\n", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a son.\" if sperm != \"XX\" else \"Congratulations! You're going to have a daughter.\"", "def chromosome_check(sperm):\n if sperm == \"XX\": \n return \"Congratulations! You're going to have a daughter.\"\n if sperm == \"XY\" or \"YX\":\n return \"Congratulations! You're going to have a son.\"\n", "def chromosome_check(sperm):\n if sperm == \"XY\":\n return \"Congratulations! You're going to have a son.\"\n else:\n sperm == \"XX\"\n return \"Congratulations! You're going to have a daughter.\"", "def chromosome_check(sperm):\n if sperm == \"XY\":\n return f\"Congratulations! You\\'re going to have a son.\"\n return f\"Congratulations! You\\'re going to have a daughter.\"", "def chromosome_check(sperm):\n gender = {\"XX\": \"daughter\", \"XY\": \"son\"}\n return f\"Congratulations! You\\'re going to have a {gender[sperm]}.\"\n", "chromosome_check = lambda sperm: \"Congratulations! You're going to have a %s.\" % {'XX':'daughter'}.get(sperm, 'son')", "chromosome_check = lambda sperm: \"Congratulations! You're going to have a son.\" if sperm == 'XY' else \"Congratulations! You're going to have a daughter.\"", "def chromosome_check(sperm):\n return 'Congratulations! You\\'re going to have a daughter.' if \"XX\" in sperm else 'Congratulations! You\\'re going to have a son.'", "def chromosome_check(sperm):\n message = 'Congratulations! You\\'re going to have a'\n return f'{message} son.' if 'Y' in sperm else f'{message} daughter.'", "def chromosome_check(sperm):\n a = sperm.upper()\n if a == 'XY':\n return 'Congratulations! You\\'re going to have a son.'\n else:\n return 'Congratulations! You\\'re going to have a daughter.'", "chromosome_check = lambda s: f\"Congratulations! You're going to have a {'son' if s[-1] == 'Y' else 'daughter'}.\"", "def chromosome_check(sperm):\n if \"XY\" in sperm:\n return \"Congratulations! You're going to have a son.\"\n elif \"XX\" in sperm:\n return \"Congratulations! You're going to have a daughter.\"", "def chromosome_check(sperm):\n return \"Congratulations! You're going to have a {}.\".format(('daughter', 'son')['Y' in sperm])", "chromosome_check=lambda x:f\"Congratulations! You\\'re going to have a {'son' if 'Y' in x else 'daughter'}.\"", "def chromosome_check(sperm):\n gender = {\"XY\": 'son', \"XX\":'daughter'}\n return 'Congratulations! You\\'re going to have a {}.'.format(gender[sperm])\n \n \n", "def chromosome_check(sperm):\n #Your code here\n return 'Congratulations! You\\'re going to have a %s.' % ({'XX':'daughter', 'XY':'son', 'YX': 'son'}[sperm])", "def chromosome_check(sperm):\n return f\"Congratulations! You're going to have a {('daughter', 'son')['Y' in sperm]}.\"", "chromosome_check = lambda sperm: \"Congratulations! You're going to have a {0}.\".format('son' if sperm[1] == 'Y' else 'daughter')", "chromosome_check=lambda x: \"Congratulations! You\\'re going to have a son.\" if x=='XY' else \"Congratulations! You\\'re going to have a daughter.\"", "def chromosome_check(sperm):\n x=0\n y=0\n for i in sperm:\n if i==\"X\":\n x+=1\n else:\n y+=1\n if x==1 and y==1:\n a='''Congratulations! You\\'re going to have a son.'''\n return a\n else:\n a='''Congratulations! You\\'re going to have a daughter.'''\n return a", "def chromosome_check(sperm):\n #Your code here\n if sperm == 'XX':\n return 'Congratulations! You\\'re going to have a daughter.'\n elif sperm == 'XY':\n return 'Congratulations! You\\'re going to have a son.'\n else:\n return 'stuff'\n", "def chromosome_check(sperm):\n #Your code here\n a = \"Congratulations! You're going to have a \"\n if 'Y' in sperm:\n b= 'son.'\n else:\n b='daughter.'\n return f\"{a}{b}\"", "def chromosome_check(s):\n m = 'Congratulations! You\\'re going to have a {}.'\n return m.format('son') if s[-1] == 'Y' else m.format('daughter')", "def chromosome_check(sperm):\n return f\"Congratulations! You're going to have a {['daughter', 'son']['Y' in sperm]}.\"", "def chromosome_check(sperm):\n if sperm[0:1] == sperm[1:]:\n return 'Congratulations! You\\'re going to have a daughter.'\n else:\n return 'Congratulations! You\\'re going to have a son.'"] | {"fn_name": "chromosome_check", "inputs": [["XY"], ["XX"]], "outputs": [["Congratulations! You're going to have a son."], ["Congratulations! You're going to have a daughter."]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 17,524 |
def chromosome_check(sperm):
|
17b6dea349abb2182ed0c3c23d0f0e41 | UNKNOWN | You are a skier (marked below by the `X`). You have made it to the Olympics! Well done.
```
\_\_\_X\_
\*\*\*\*\*\
\*\*\*\*\*\*\
\*\*\*\*\*\*\*\
\*\*\*\*\*\*\*\*\
\*\*\*\*\*\*\*\*\*\\.\_\_\_\_/
```
Your job in this kata is to calculate the maximum speed you will achieve during your downhill run. The speed is dictated by the height of the mountain. Each element of the array is a layer of the mountain as indicated by the diagram above (and further below). So for this example the mountain has a height of 5 (5 rows of stars). `Speed` is `mountain height * 1.5`.
The jump length is calculated by `(mountain height * speed * 9) / 10`. Jump length should be rounded to 2 decimal places.
You must return the length of the resulting jump as a string in the following format:
* when less than 10 m: `"X metres: He's crap!"`
* between 10 and 25 m: `"X metres: He's ok!"`
* between 25 and 50 m: `"X metres: He's flying!"`
* when more than 50 m: `"X metres: Gold!!"`
So in the example case above, the right answer would be `"33.75 metres: He's flying!"`
Sadly, it takes a lot of time to make arrays look like mountains, so the tests wont all look so nice. To give an example, the above mountain would look as follows in most cases:
```
[*****, ******, *******, ********, *********]
```
Not as much fun, eh?
*p.s. if you think "metre" is incorrect, please [read this](https://en.wikipedia.org/wiki/Metre#Spelling)* | ["def ski_jump(mountain):\n height = len(mountain)\n speed = height * 1.5\n jump_length = height * speed * 9 / 10\n return (\n f\"{jump_length:.2f} metres: He's crap!\" if jump_length < 10 else\n f\"{jump_length:.2f} metres: He's ok!\" if jump_length < 25 else\n f\"{jump_length:.2f} metres: He's flying!\" if jump_length < 50 else\n f\"{jump_length:.2f} metres: Gold!!\"\n )", "def ski_jump(mountain):\n x = len(mountain)**2 * 1.35\n y = { x < 10: \"He's crap\",\n 10 <= x < 25: \"He's ok\",\n 25 <= x < 50: \"He's flying\",\n 50 <= x : \"Gold!\"}[True]\n return f\"{x:.2f} metres: {y}!\"", "def ski_jump(mountain):\n distance = len(mountain)**2 * 1.35\n if distance <= 10:\n return f\"{distance:.2f} metres: He's crap!\"\n if distance <= 25:\n return f\"{distance:.2f} metres: He's ok!\"\n if distance <= 50:\n return f\"{distance:.2f} metres: He's flying!\"\n if distance > 50:\n return f\"{distance:.2f} metres: Gold!!\"", "msg = (\"He's crap!\", \"He's ok!\", \"He's flying!\", \"Gold!!\")\ndef ski_jump(M):\n l = round(1.35*len(M)**2, 2)\n return f\"{l:.2f} metres: {msg[(l>10)+(l>25)+(l>50)]}\"", "def ski_jump(mountain):\n l = len(mountain)**2 * 1.35\n comment = \"Gold!\" if 50 < l else f\"He's {'crap' if l < 10 else 'ok' if l < 25 else 'flying'}\"\n return f\"{l:.2f} metres: {comment}!\"", "def ski_jump(mountain):\n length = round(1.35 * len(mountain) ** 2, 2)\n text = (\"He's crap\", \"He's ok\", \"He's flying\", \"Gold!\")[(length >= 10) + (length >= 25) + (length > 50)]\n return f'{length:.2f} metres: {text}!'", "def ski_jump(mountain):\n k=0\n l=0\n m=0\n for i in mountain:\n i=mountain[k]\n k+=1\n l=k*1.5\n m=(k*l*9)/10\n \n if m<10:\n m=(\"%.2f\" % m)\n m=str(m)\n m=m +\" metres: He's crap!\"\n return m\n elif m>=10 and m<=25:\n m=(\"%.2f\"%m)\n m=str(m)\n m=m+\" metres: He's ok!\"\n return m\n elif m>=25 and m<=50:\n m=(\"%.2f\" % m)\n m=str(m)\n m=(m)+\" metres: He's flying!\"\n return m\n else:\n m=(\"%.2f\" % m)\n m=str(m)\n m=m+\" metres: Gold!!\"\n return m\n", "def ski_jump(mountain):\n lenght = (len(mountain)) ** 2 * 1.5 * 9 / 10\n print(lenght)\n return f\"{lenght:0.2f} metres: He's crap!\" if lenght < 10 else f\"{lenght:0.2f} metres: He's ok!\" if 10 <= lenght < 25 else f\"{lenght:0.2f} metres: He's flying!\" if 25 <= lenght < 50 else f\"{lenght:0.2f} metres: Gold!!\" if 50 <= lenght else None\n", "def ski_jump(mountain):\n height = len(mountain)\n speed = height * 1.5\n jumpLength = (height * speed * 9) / 10\n output = {\n 10: \" metres: He's crap!\",\n 25: \" metres: He's ok!\",\n 50: \" metres: He's flying!\",\n 1000: \" metres: Gold!!\"\n }\n for case in output.keys():\n if (jumpLength < case):\n return \"{:.2f}{:s}\".format(jumpLength, output.get(case));", "def ski_jump(mountain):\n speed = float(len(mountain[-1])) * 1.5\n jump = (len(mountain[-1]) * speed * 9) / 10\n if jump < 10: \n res = \"He's crap!\"\n elif jump < 25:\n res = \"He's ok!\"\n elif jump < 50:\n res = \"He's flying!\"\n else:\n res = \"Gold!!\"\n return '{:.2f}'.format(jump) + \" metres: \" + res\n\n\n"] | {"fn_name": "ski_jump", "inputs": [[["*"]], [["*", "**", "***"]], [["*", "**", "***", "****", "*****", "******"]], [["*", "**", "***", "****", "*****", "******", "*******", "********"]]], "outputs": [["1.35 metres: He's crap!"], ["12.15 metres: He's ok!"], ["48.60 metres: He's flying!"], ["86.40 metres: Gold!!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,484 |
def ski_jump(mountain):
|
a25a057ab758ed0e161bfd48c3f4dbca | UNKNOWN | Another Fibonacci... yes but with other kinds of result.
The function is named `aroundFib` or `around_fib`, depending of the language.
Its parameter is `n` (positive integer).
First you have to calculate `f` the value of `fibonacci(n)` with `fibonacci(0) --> 0` and
`fibonacci(1) --> 1` (see: )
- 1) Find the count of each digit `ch` in `f` (`ch`: digit from 0 to 9), call this count `cnt` and find the maximum
value of `cnt`, call this maximum `maxcnt`. If there are ties, the digit `ch` to consider is the first one - in natural digit order - giving `maxcnt`.
- 2) Cut the value `f` into chunks of length at most `25`. The last chunk may be 25 long or less.
```
Example: for `n=100` you have only one chunk `354224848179261915075`
Example: for `n=180` f is `18547707689471986212190138521399707760` and you have two chunks
`1854770768947198621219013` and `8521399707760`. First length here is 25 and second one is 13.
```
- At last return a string in the following format:
"Last chunk ...; Max is ... for digit ..."
where Max is `maxcnt` and digit the first `ch` (in 0..9) leading to `maxcnt`.
```
Example: for `n=100` -> "Last chunk 354224848179261915075; Max is 3 for digit 1"
Example: for `n=180` -> "Last chunk 8521399707760; Max is 7 for digit 7"
Example: for `n=18000` -> "Last chunk 140258776000; Max is 409 for digit 1"
```
# Beware:
`fib(18000)` has `3762` digits. Values of `n` are between `500` and `25000`.
# Note
Translators are welcome for all languages, except for Ruby since the Bash tests needing Ruby a Ruby reference solution is already there though not yet published. | ["from collections import Counter\nfib = [0, 1]\n\ndef around_fib(n):\n while len(fib) <= n: fib.append(fib[-1] + fib[-2])\n f = str(fib[n])\n val = max((v, -int(k)) for k,v in Counter(f).items())\n last = f[-(len(f)%25 or 25):]\n return f\"Last chunk {last}; Max is {val[0]} for digit {-val[1]}\"", "def around_fib(n):\n a, b = 0, 1\n for _ in range(n): a, b = b, a + b\n f = str(a); start = (len(f) - 1) // 25 * 25\n maxcnt, ch = min((-f.count(d), d) for d in '0123456789')\n return \"Last chunk %s; Max is %d for digit %s\" % (f[start:], -maxcnt, ch)", "def around_fib(n):\n numbers_fibonacci = [0, 1]\n for i in range(n-1):\n numbers_fibonacci.append(numbers_fibonacci[i] + numbers_fibonacci[i+1])\n chunks = []\n max1 = str(max(numbers_fibonacci))\n max3 = ''.join(sorted(max1))\n count = [max3.count(i) for i in max3]\n max1_count = [max(count), max3[count.index(max(count))]]\n k = 0\n while 25 * k < len(max1):\n chunks.append(max1[25*k:25*(k+1)])\n k += 1\n return \"Last chunk {}; Max is {} for digit {}\".format(chunks[-1], max1_count[0], max1_count[1])", "\ndef around_fib(n):\n fiblist = [0,1]\n if n>1:\n for i in range(2,n+1):\n fiblist.append(fiblist[-1]+fiblist[-2])\n list1 = [int(i) for i in str(fiblist[-1])]\n list2 = []\n for i in range(10):\n count = list1.count(i)\n list2.append(count)\n for i in range(10):\n if list2[i] == max(list2):\n max1 = i\n max2 = max(list2)\n break\n list3 = []\n list4 = []\n x = len(list1)//25\n if len(list1)%25 != 0:\n for i in range(x*25,len(list1)):\n list3.append(list1[i])\n else:\n i = -1\n while len(list3)<25:\n list3.append(list1[i])\n i-=1\n list3.reverse()\n \n return \"Last chunk \"+\"\".join([str(i) for i in list3])+\"; Max is \"+str(max2)+ \" for digit \" + str(max1)", "def around_fib(n):\n f = str(fib(n))\n ch = ['9', '8', '7', '6', '5', '4', '3', '2', '1', '0']\n maxcnt = 0\n chunk = ''\n\n for digit in ch:\n cnt = f.count(digit)\n if cnt >= maxcnt:\n maxcnt = cnt\n maxdig = digit\n\n l = len(f) % 25\n if l == 0:\n start = len(f) - 25\n else:\n start = len(f) - l\n for i in range(start, len(f)):\n chunk += f[i]\n\n return 'Last chunk %s; Max is %d for digit %s' % (chunk, maxcnt, maxdig)\n\n\ndef fib(n):\n a = 0\n b = 1\n if n == 0:\n return a\n elif n == 1:\n return b\n else:\n for i in range(2,n+1):\n c = a + b\n a = b\n b = c\n return b", "def around_fib(n):\n f = str(fib(n))\n ch = ['9', '8', '7', '6', '5', '4', '3', '2', '1', '0']\n maxcnt = 0\n chunk = ''\n\n for digit in ch:\n cnt = f.count(digit)\n if cnt >= maxcnt:\n maxcnt = cnt\n maxdig = digit\n\n l = len(f) % 25\n if l == 0:\n start = len(f) - 25\n else:\n start = len(f) - l\n for i in range(start, len(f)):\n chunk += f[i]\n\n return 'Last chunk ' + chunk + '; Max is %d for digit ' % maxcnt + maxdig\n\n\ndef fib(n):\n a = 0\n b = 1\n if n == 0:\n return a\n elif n == 1:\n return b\n else:\n for i in range(2,n+1):\n c = a + b\n a = b\n b = c\n return b", "import textwrap\n\ndef around_fib(n):\n fib, cnt = [0,1], [0] * 10\n for i in range(n-1): fib.append(fib[i] + fib[i + 1])\n cnt =[0] * 10\n for v in str(fib[-1]): cnt[int(v)] += 1\n chunk = textwrap.wrap(str(fib[-1]),25)\n return \"Last chunk \" + chunk[-1] + \"; Max is \" + str(max(cnt)) + \" for digit \" + str(cnt.index(max(cnt)))", "import textwrap\n\ndef around_fib(n):\n fib = [0,1]\n for i in range(n-1):\n fib.append(fib[i] + fib[i + 1])\n cnt =[0] * 10\n for v in str(fib[-1]):\n cnt[int(v)] += 1\n chunk = textwrap.wrap(str(fib[-1]),25)\n return \"Last chunk \" + chunk[-1] + \"; Max is \" + str(max(cnt)) + \" for digit \" + str(cnt.index(max(cnt)))", "from collections import Counter\ndef around_fib(n):\n a,b=0,1\n for _ in range(n):\n a,b=b,a+b\n s=str(a)\n c=Counter(s)\n max_d=[0,None]\n for d in '0123456789':\n if c[d]>max_d[0]:\n max_d=[c[d],d]\n chunks=[s[i:i+25] for i in range(0,len(s),25)]\n return 'Last chunk {}; Max is {} for digit {}'.format(chunks[-1],max_d[0],max_d[1])", "from collections import Counter\nimport re\ndef fib(x): \n a , b = 0, 1\n for _ in range(x-1):\n a,b=b,a+b\n return b\ndef around_fib(n):\n fo = fib(n)\n g = Counter(sorted(str(fo)))\n dig,c=g.most_common(1)[0]\n return \"Last chunk {}; Max is {} for digit {}\".format(re.findall(r\"\\d{1,25}\",str(fo))[-1],c,dig)\n"] | {"fn_name": "around_fib", "inputs": [[666], [934], [617], [576], [982], [628], [901], [957], [916], [823], [988], [703], [873], [664], [749], [581], [986], [904], [716], [673], [12965], [17001], [16381], [18035], [10611], [13959], [17962], [13505], [15366], [13883], [10210], [16797], [15923], [18108], [12314], [15708], [18544], [14934], [17508], [12900], [22389], [22587], [21019], [21816], [24542], [23855], [24948], [22774], [22166], [22733], [21537], [22770], [23544], [24406], [24903]], "outputs": [["Last chunk 56699078708088; Max is 18 for digit 8"], ["Last chunk 78863403327510987087; Max is 30 for digit 7"], ["Last chunk 3197; Max is 18 for digit 9"], ["Last chunk 735148681490199640832; Max is 16 for digit 0"], ["Last chunk 79791; Max is 27 for digit 4"], ["Last chunk 519011; Max is 20 for digit 3"], ["Last chunk 7891167369401; Max is 27 for digit 0"], ["Last chunk 5402420264154456349058562; Max is 29 for digit 2"], ["Last chunk 85359040486266787; Max is 27 for digit 4"], ["Last chunk 7907999685333994717357; Max is 22 for digit 0"], ["Last chunk 0223731; Max is 32 for digit 1"], ["Last chunk 1300138427142200651677; Max is 22 for digit 0"], ["Last chunk 30038818; Max is 29 for digit 8"], ["Last chunk 79269128954923; Max is 20 for digit 2"], ["Last chunk 9505749; Max is 22 for digit 1"], ["Last chunk 5418273142575204123781; Max is 18 for digit 2"], ["Last chunk 493873; Max is 27 for digit 8"], ["Last chunk 04166807985803; Max is 27 for digit 8"], ["Last chunk 9313623756961376768580637; Max is 19 for digit 1"], ["Last chunk 8497269999660993; Max is 25 for digit 9"], ["Last chunk 5485552965; Max is 299 for digit 7"], ["Last chunk 626; Max is 397 for digit 7"], ["Last chunk 608352205068600151219081; Max is 367 for digit 4"], ["Last chunk 9701559050936959465; Max is 406 for digit 3"], ["Last chunk 521019873015146114; Max is 252 for digit 0"], ["Last chunk 53856715698959266; Max is 333 for digit 1"], ["Last chunk 5831; Max is 395 for digit 0"], ["Last chunk 72489142392597079951005; Max is 306 for digit 5"], ["Last chunk 44152391688; Max is 332 for digit 2"], ["Last chunk 97; Max is 313 for digit 1"], ["Last chunk 896343655; Max is 226 for digit 7"], ["Last chunk 37957484802; Max is 393 for digit 0"], ["Last chunk 257; Max is 368 for digit 9"], ["Last chunk 151398096; Max is 410 for digit 8"], ["Last chunk 378933670052262507657777; Max is 278 for digit 4"], ["Last chunk 79433296; Max is 364 for digit 7"], ["Last chunk 3; Max is 404 for digit 9"], ["Last chunk 210628747612946784712; Max is 343 for digit 3"], ["Last chunk 898206896; Max is 399 for digit 9"], ["Last chunk 937654497907092122800; Max is 287 for digit 6"], ["Last chunk 4114; Max is 497 for digit 8"], ["Last chunk 719687658570836552258; Max is 497 for digit 1"], ["Last chunk 712645962279818181; Max is 480 for digit 7"], ["Last chunk 991575712; Max is 509 for digit 6"], ["Last chunk 0921; Max is 579 for digit 0"], ["Last chunk 67799826145; Max is 533 for digit 9"], ["Last chunk 66821527441776; Max is 535 for digit 7"], ["Last chunk 3794465007; Max is 498 for digit 6"], ["Last chunk 92040713; Max is 484 for digit 1"], ["Last chunk 3; Max is 508 for digit 2"], ["Last chunk 2; Max is 488 for digit 6"], ["Last chunk 721118360; Max is 505 for digit 9"], ["Last chunk 073632201495632712608; Max is 522 for digit 3"], ["Last chunk 3; Max is 543 for digit 1"], ["Last chunk 13602; Max is 569 for digit 0"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,958 |
def around_fib(n):
|
326745eee0f47d61cbdcefec944c445b | UNKNOWN | In computer science and discrete mathematics, an [inversion](https://en.wikipedia.org/wiki/Inversion_%28discrete_mathematics%29) is a pair of places in a sequence where the elements in these places are out of their natural order. So, if we use ascending order for a group of numbers, then an inversion is when larger numbers appear before lower number in a sequence.
Check out this example sequence: ```(1, 2, 5, 3, 4, 7, 6)``` and we can see here three inversions
```5``` and ```3```; ```5``` and ```4```; ```7``` and ```6```.
You are given a sequence of numbers and you should count the number of inversions in this sequence.
```Input```: A sequence as a tuple of integers.
```Output```: The inversion number as an integer.
Example:
```python
count_inversion((1, 2, 5, 3, 4, 7, 6)) == 3
count_inversion((0, 1, 2, 3)) == 0
``` | ["def count_inversion(nums):\n return sum(a > b for i, a in enumerate(nums) for b in nums[i + 1:])\n", "def count_inversion(s):\n return sum(s[i] > s[j]\n for i in range(len(s) - 1)\n for j in range(i + 1, len(s)))", "def count_inversion(sequence):\n def rec(arr):\n if len(arr) <= 1: return arr, 0\n a, ai = rec(arr[:len(arr)//2])\n b, bi = rec(arr[len(arr)//2:])\n res, i, j, count = [], 0, 0, ai + bi\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n res.append(a[i])\n i += 1\n else:\n res.append(b[j])\n j += 1\n count += len(a) - i\n return res + a[i:] + b[j:], count\n return rec(list(sequence))[1]", "from itertools import combinations\n\ndef count_inversion(lst):\n return sum(a>b for a,b in combinations(lst,2))", "def count_inversion(sequence):\n return sum(a > b for i, a in enumerate(sequence[:-1]) for b in sequence[i+1:])", "def merge(a, left_index, mid, right_index, aux):\n i, j = left_index, mid + 1\n inversions = 0\n\n for k in range(left_index, right_index + 1):\n aux[k] = a[k]\n\n for k in range(left_index, right_index + 1):\n if i > mid:\n a[k] = aux[j]\n j += 1\n elif j > right_index:\n a[k] = aux[i]\n i += 1\n elif aux[i] <= aux[j]:\n a[k] = aux[i]\n i += 1\n elif aux[j] < aux[i]:\n a[k] = aux[j]\n j += 1\n\n inversions += mid - i + 1\n return inversions\n\ndef count(a, left_index, right_index, aux):\n if right_index <= left_index:\n return 0\n mid = left_index + (right_index - left_index) // 2\n left_inversions = count(a, left_index, mid, aux)\n right_inversions = count(a, mid + 1, right_index, aux)\n return left_inversions + right_inversions + merge(a, left_index, mid, right_index, aux)\n\ndef count_inversion(sequence):\n if len(sequence) < 2:\n return 0\n aux = [None for _ in range(len(sequence))]\n sequence_list = list(sequence)\n return count(sequence_list, 0, len(sequence) - 1, aux)", "from collections import deque\n\n\ndef count_inversion(nums):\n forward_nums = deque(nums)\n result = 0\n for a in nums:\n forward_nums.popleft()\n for b in forward_nums:\n if a > b:\n result += 1\n return result\n", "def count_inversion(sequence):\n \"\"\"\n Count inversions in a sequence of numbers\n \"\"\"\n count = 0\n for i, x in enumerate(sequence):\n for y in sequence[i+1:]:\n if x > y: count += 1\n return count\n", "count_inversion = lambda sequence: sum([sum([1 if sequence[x] > sequence[x + y] else 0 for y in range(1, len(sequence) - x)]) for x in range(len(sequence))])", "def count_inversion(sequence):\n \"\"\"\n Count inversions in a sequence of numbers\n \"\"\"\n return sum(n > m for i, n in enumerate(sequence) for m in sequence[i:])"] | {"fn_name": "count_inversion", "inputs": [[[1, 2, 3]], [[-3, -2, -1]], [[-20, 0, 20]], [[-13, 4, 8]], [[1, 3, 2]], [[-2, -3, -1]], [[-20, 20, 0]], [[-13, 9, 8]], [[3, 6, 2]], [[3, 6, 2, 7, 3]], [[26, 32, -21, 45, 21]], [[14, 12, 17, 124, 1, -12, 21, -24]], [[]], [[25, 12, 7, 4, 2, -7, -12, -22]], [[324, 123, 36, 4, -1, -72, -123]], [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]], [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [[3, 3, 3]], [[-5, -5, -5]], [[0, 0, 7]], [[2, 2, 8]], [[1, 3, 3, 7]]], "outputs": [[0], [0], [0], [0], [1], [1], [1], [1], [2], [4], [5], [18], [0], [28], [21], [55], [0], [0], [0], [0], [0], [0]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,080 |
def count_inversion(sequence):
|
618a12feb3dc71358d6e9ce6f875ce58 | UNKNOWN | write me a function `stringy` that takes a `size` and returns a `string` of alternating `'1s'` and `'0s'`.
the string should start with a `1`.
a string with `size` 6 should return :`'101010'`.
with `size` 4 should return : `'1010'`.
with `size` 12 should return : `'101010101010'`.
The size will always be positive and will only use whole numbers. | ["def stringy(size):\n return \"\".join([str(i % 2) for i in range(1, size + 1)])", "def stringy(size):\n return ('10' * size)[:size]", "from itertools import cycle, islice\n\ndef stringy(size):\n return ''.join(islice(cycle('10'), size))", "def stringy(size):\n s = \"\"\n for x in range (0, size):\n s+= str(\"1\") if x%2 == 0 else str(\"0\")\n return s", "def stringy(size):\n return '10' * (size // 2) + '1' * (size % 2)", "def stringy(size):\n return \"10\" * (size // 2) if size % 2 == 0 else \"10\" * (size // 2) + \"1\"", "def stringy(size):\n res = \"\"\n for x in range(0, size):\n res += \"1\" if x % 2 == 0 else \"0\"\n return res", "def stringy(size):\n str = \"\"\n while len(str) < size:\n str+=\"1\"\n if len(str) < size:\n str+=\"0\"\n return str\n \n \n", "stringy = lambda size: ('10'*(size//2+1))[:size]", "def stringy(size):\n arr=[]\n for i in range(size):\n if i%2==0:\n arr.append('1')\n else:\n arr.append('0')\n return ''.join(arr)", "stringy = lambda size: ('10' * size)[:size]", "def stringy(size):\n return ((size//2+1)*'10')[:size]", "ONE_ZERO = '10'\n\n\ndef stringy(size):\n return ''.join(ONE_ZERO[a % 2] for a in range(size))\n", "def stringy(size: int) -> str:\n \"\"\" Take a size and return a string of alternating `1s` and `0s`. \"\"\"\n return \"\".join([str(_ % 2) for _ in range(1, size + 1)])", "def stringy(size):\n return ''.join('0' if x % 2 else '1' for x in range(size))", "def gen():\n while True:\n yield \"1\"\n yield \"0\"\n\ndef stringy(size):\n g = gen()\n return \"\".join(next(g) for _ in range(size))", "stringy=lambda n:('10'*n)[:n]", "def stringy(size):\n return ''.join(['1' if a % 2 == 0 else '0' for a in range(size)])", "def stringy(size):\n return ''.join([str((a+1) % 2) for a in range(size)])\n", "def stringy(size):\n binary = '10'\n s = size * binary\n return s[:size]", "def stringy(size):\n return ('10'*((size // 2)+1))[:size]", "def stringy(size):\n return ''.join(map(str, map(int, map(lambda x: not x % 2, range(size)))))", "def stringy(size):\n\n if size%2==0:\n return \"10\"*int(size/2)\n else:\n x=size-1\n return \"10\"*int(x/2)+\"1\"", "def stringy(size):\n return ''.join('{:d}'.format(not i % 2) for i in range(size))", "def stringy(size):\n return ''.join('%d' % (not i % 2) for i in range(size))", "def stringy(size):\n return ('1' * size).replace('11', '10')\n \n# def stringy(size):\n# return '10' * (size / 2) + '1' * (size % 2)\n\n# def stringy(size):\n# return __import__('re').sub('11', '10', '1' * size)\n", "def stringy(size):\n return __import__('re').sub('11', '10', '1' * size)", "def stringy(size):\n ans = \"\"\n for place in range(size):\n if place % 2 == 0:\n ans += \"1\"\n else:\n ans += \"0\"\n return ans\n", "def stringy(size):\n string = \"\"\n for num in range(size):\n if num % 2 == 0:\n string += \"1\"\n else:\n string += \"0\"\n return string\n # Good Luck!\n", "def stringy(size):\n return str(\"10\"*size)[:size]", "def stringy(size):\n x = True\n \n s = \"\"\n while size>0:\n s += str(int(x))\n x = not x\n size -= 1\n \n return s", "def stringy(size):\n return ''.join(['1' if i % 2 == 0 else '0' for i in range(size) ])\n", "def stringy(size):\n output_string = \"\"\n for i in range(size):\n if i % 2 == 0:\n output_string += \"1\"\n else:\n output_string += \"0\"\n return output_string", "def stringy(size):\n n = int(size / 2)\n i = 0\n c = \"10\"\n output = \"\"\n for i in range(n):\n output = output + c\n i += 1\n if size%2 == 1:\n output = output + \"1\"\n\n return output", "def stringy(size):\n # Good Luck!\n st = \"1\"\n i = 0\n while i < size-1:\n if st[i] == \"1\":\n st = st + \"0\"\n else: st = st + \"1\"\n i += 1\n return st", "def stringy(size):\n strng = \"\"\n if size %2 == 1:\n for i in range((size+1)//2):\n strng += \"10\"\n return strng[:-1]\n else:\n for i in range(size//2):\n strng += \"10\"\n return strng\n", "def stringy(size):\n binary_yo=\"\"\n for i in range(size):\n if i%2==0:\n binary_yo+='1'\n else:\n binary_yo+='0'\n return binary_yo", "def stringy(size):\n counter = 0 \n res = \"\"\n while counter < size:\n if counter % 2 == 0:\n res += \"1\"\n counter += 1\n elif counter % 2 == 1:\n res += \"0\"\n counter += 1\n return res", "def stringy(size):\n start, result = '1', ''\n for i in range(size):\n result += start\n start = '1' if start == '0' else '0'\n return result", "def stringy(size):\n x = 0\n list_size = []\n for i in range(size):\n if x % 2:\n i = 0\n else:\n i = 1\n x += 1\n list_size.append(i)\n return str(''.join(map(str, list_size)))", "def stringy(size):\n temp = ''\n for el in range(size):\n if el % 2:\n temp += \"0\"\n else:\n temp += \"1\"\n return temp\n", "def stringy(size):\n c = 0\n res = ''\n for i in range(size):\n c += 1\n if i == 0:\n res += '1'\n elif i == 1:\n res += '0'\n elif i % 2 == 0:\n res += '1'\n else:\n res += '0'\n return res", "def stringy(size):\n return ''.join(str(el % 2) for el in range(1, size + 1))", "def stringy(size):\n result = ''\n for el in range(size):\n if el % 2 == 0:\n result += '1'\n else:\n result += '0'\n return result", "def stringy(size):\n string = \"1\"\n for number, index in enumerate(range(0,size-1)):\n print(string)\n if index % 2 == 0:\n string = string + \"0\"\n else: \n string = string + \"1\"\n return string\n", "def stringy(size):\n # Good Luck!\n value = True\n result = ''\n for i in range(size):\n result += str(int(value))\n value = not value\n return result\n", "def stringy(size):\n size - int(size)\n counter = 1\n word = ''\n while len(word) < size:\n if counter % 2 == 0: \n word = word + '0'\n if counter % 2 != 0:\n word = word + '1'\n counter += 1\n return word\n\n", "def stringy(size):\n num = '10'\n if size % 2 == 0:\n return num * (size // 2)\n else:\n return (((size - 1) // 2) * num) + '1'", "def stringy(size):\n # Good Luck!\n s=''\n for i in range(0,size):\n if(i%2==0):\n j=\"1\"\n s=s+j\n else:\n j=\"0\"\n s=s+j\n return s\n", "def stringy(size):\n return ''.join(['0' if num % 2 else '1' for num in range(size)])", "def stringy(size):\n st = \"\"\n while size > 0:\n st += \"1\"\n size -= 1\n if size < 1:\n break\n st += \"0\"\n size -= 1\n return st\n", "def stringy(size):\n l = ''\n for x in range(size):\n if x % 2 == 0:\n l += '1'\n else:\n l += '0'\n return l", "def stringy(size):\n return ''.join(str(x & 1) for x in range(1, size+1))", "def stringy(size):\n s = ''\n for i in range(0,size):\n if i % 2:\n s += '0'\n else:\n s += '1'\n return s", "def stringy(size):\n res = \"\"\n for i in range(0,size):\n if i%2==0:\n res = res + \"1\"\n else:\n res = res+\"0\"\n return res", "def stringy(size):\n print(size)\n bla = ''\n for i in range(int(size)):\n if i % 2 != 0:\n bla += str(0)\n else:\n bla += str(1)\n print(bla)\n return (bla)\n\nsize = 3\nstringy(size)", "def stringy(size):\n arr = []\n cnt = 0\n while True:\n arr.append('1')\n cnt += 1\n if cnt == size:\n break\n arr.append('0')\n cnt += 1\n if cnt == size:\n break\n \n \n return ''.join(arr)", "def stringy(size):\n if size%2 == 0:\n return \"10\"*int(size//2)\n else:\n return (\"10\"*int(size//2))+\"1\"", "import math\ndef stringy(size):\n return str('10'*math.ceil(size/2))[:size]", "def stringy(size):\n result = '10' * (size // 2)\n if size % 2 == 1:\n result = result + '1'\n return result", "from math import ceil\ndef stringy(size):\n return '10'*(size//2) if size%2==0 else str('10'*ceil(size/2))[:-1]", "def stringy(size):\n string = []\n for i in range(size):\n if i % 2 == 1:\n string.append('0')\n else:\n string.append('1')\n return ''.join(string)", "stringy=lambda l:'10'*(l//2)+'1'*(l%2) ", "def stringy(size):\n if size%2 == 0: return int(size/2)*'10'\n else: return int(size/2)*'10'+ '1'\n \n \n# the string should start with a 1.\n\n# a string with size 6 should return :'101010'.\n\n# with size 4 should return : '1010'.\n\n# with size 12 should return : '101010101010'.\n", "def stringy(size):\n x = ''\n while len(x) < size:\n x += '1'\n if len(x) < size:\n x += '0'\n return x", "def stringy(size):\n x = [] \n for i in range(size):\n if i % 2 == 0:\n x.append('1')\n else:\n x.append('0')\n return ''.join(x)", "def stringy(size):\n if size == 0:\n return ''\n result = '1'\n for i in range(1, size):\n if((i % 2) != 0):\n result += '0'\n else:\n result += '1'\n return result", "import math\n\ndef stringy(size):\n return '10' * math.ceil(size / 2) if size % 2 == 0 else ('10' * math.ceil(size / 2))[:-1]", "def stringy(size):\n string = \"\"\n if size % 2 == 0:\n return \"10\" * (int(size / 2))\n else:\n return str(\"10\" * int(size / 2 + 1))[:-1]", "def stringy(size):\n x = ''\n n = 1\n while n<=size:\n if n%2 ==1:\n x += '1'\n n += 1\n else:\n x += '0'\n n += 1\n return x", "def stringy(size):\n alot = '10' * 1000\n return alot[0:int(size)]", "def stringy(size):\n count = 3\n arr = \"\"\n for i in range(size):\n if count%2 == 1:\n arr += \"1\"\n count += 1\n else:\n arr += \"0\"\n count += 1\n return arr", "def stringy(size):\n c, l = '1', []\n for i in range(size):\n if c=='1':\n l.append(c)\n c = '0'\n elif c=='0':\n l.append(c)\n c = '1'\n return ''.join(l)", "def stringy(size):\n res = ''\n for i in range(size):\n if i % 2 == 1:\n res += '0'\n else:\n res += '1'\n return res", "def stringy(size):\n # Good Luck!\n #t = 0\n for x in range(1,size+1,1):\n if x ==1:\n t = '1'\n elif t[-1] == '1':\n t += '0'\n else:\n t += '1'\n return t", "def stringy(size):\n return \"10\" * int(size/2) if not size % 2 else \"10\" * int(size/2) + \"1\"", "def stringy(size):\n new = \"\"\n if size%2==0:\n new+=\"10\"*(size//2)\n else:\n new+=\"10\"*(size//2)\n new+=\"1\"\n return new", "def stringy(size):\n if (size % 2) == 0:\n n = size // 2\n return \"10\" * n\n else:\n n = (size + 1) // 2 - 1\n return \"10\" * n + \"1\"", "def stringy(size):\n res=\"\"\n n=0\n while n<size:\n if n==size:\n break\n else:\n res+=\"1\"\n n+=1\n if n==size:\n break\n else:\n res+=\"0\"\n n+=1\n return res\n \n \n", "def stringy(size):\n # Good Luck!\n x = ''\n while size > len(x):\n x = x + '1'\n while size > len(x):\n x = x + '0'\n break\n return x", "def stringy(size):\n r = \"\"\n for i in range(size):\n if i % 2 == 0:\n r += '1'\n else:\n r += '0'\n return r", "def stringy(size):\n men =\"\"\n for i in range(size):\n i +=1\n if i % 2 ==0:\n men+= \"0\"\n else:\n men += \"1\"\n return men", "def stringy(size):\n return ('10'*(size//2) if size%2==0 else (('10'*((size-1)//2)) + '1')) ", "from itertools import islice, cycle\ndef stringy(size):\n return ''.join(str(i) for i in islice(cycle([1, 0]), 0, size))", "def stringy(size):\n if size == 1:\n return '1'\n elif size %2 ==0:\n return '10' * (size//2)\n elif size != 1 and size %2 ==1:\n return '1' + '01' * (size//2)", "from math import ceil\n\ndef stringy(size):\n return \"0\".join(\"1\"*ceil(size/2)) + \"0\"*((size-1) % 2)", "def stringy(size):\n s=''\n for i in range(1,size+1):\n if(i%2==0):\n s+=str(0)\n else:\n s+=str(1)\n return s\n", "def stringy(size):\n res = ''\n t = size\n while t > 0:\n if t%2 == 1:\n res = '1' + res\n else:\n res = '0' + res\n t -=1\n return res\n \n \n \n # Good Luck!\n", "def stringy(size):\n if size == 1:\n return '1' \n if size % 2 == 0:\n return '10' * int(size / 2)\n return '10' * int((size - 1) / 2) + '1'", "def stringy(size):\n choices = [1, 0]\n a = \"\"\n for i in range(size):\n a += str(choices[i%2])\n return a", "def stringy(size):\n return ''.join([['1', '0'][loop % 2] for loop in range(size)])", "def stringy(size):\n outStr = \"\"\n lastAdd = 0\n for x in range(size):\n if lastAdd == 0:\n outStr += str(1)\n lastAdd = 1\n else:\n outStr += str(0)\n lastAdd = 0\n return outStr", "def stringy(size):\n s = '10'*(size//2)\n s = s + '1'\n return '10'*(size//2) if size%2==0 else s", "def stringy(size):\n i = 0\n list1 = ['1']\n for n in range(size-1):\n if i%2==0:\n list1.append('0')\n i+=1\n else:\n list1.append('1')\n i+=1\n return ''.join(list1)\n", "def stringy(size):\n res=''\n n = True\n for i in range(size):\n if n:\n res+='1'\n n=False\n else:\n res+='0'\n n=True\n return res", "def stringy(size):\n S = ''\n nextChar = '1'\n for i in range(size):\n S += nextChar\n if nextChar == '1':\n nextChar = '0'\n else:\n nextChar = '1'\n return S", "import math\ndef stringy(size):\n if size == 1:\n return '1'\n elif size%2 == 0:\n return '10'*int((size/2))\n else:\n return '10'*(math.floor(size/2)) + '1'"] | {"fn_name": "stringy", "inputs": [[3], [5], [12], [26], [28]], "outputs": [["101"], ["10101"], ["101010101010"], ["10101010101010101010101010"], ["1010101010101010101010101010"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 15,311 |
def stringy(size):
|
0084863766b6816e4d09b3d9ea659445 | UNKNOWN | In this Kata, you will be given a lower case string and your task will be to remove `k` characters from that string using the following rule:
```Python
- first remove all letter 'a', followed by letter 'b', then 'c', etc...
- remove the leftmost character first.
```
```Python
For example:
solve('abracadabra', 1) = 'bracadabra' # remove the leftmost 'a'.
solve('abracadabra', 2) = 'brcadabra' # remove 2 'a' from the left.
solve('abracadabra', 6) = 'rcdbr' # remove 5 'a', remove 1 'b'
solve('abracadabra', 8) = 'rdr'
solve('abracadabra',50) = ''
```
More examples in the test cases. Good luck!
Please also try:
[Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2)
[Simple remove duplicates](https://www.codewars.com/kata/5ba38ba180824a86850000f7) | ["def solve(st,k): \n for l in sorted(st)[:k]:\n st=st.replace(l,'',1)\n return st", "solve = lambda s, k: ''.join(t[1] for t in sorted(sorted(enumerate(s), key=lambda x:x[1])[k:]))", "from collections import Counter\nfrom itertools import accumulate\nfrom operator import add\nfrom string import ascii_lowercase\n\ndef solve(s, n):\n counter = Counter(s)\n cum_count = [0] + list(accumulate((counter[c] for c in ascii_lowercase), add))\n result = []\n for c in s:\n cum_count[ord(c) - 97] += 1\n if cum_count[ord(c) - 97] > n:\n result.append(c)\n return \"\".join(result)\n", "from collections import Counter\n\ndef solve(letters, removes):\n letter_counts = Counter(letters)\n unique_sorted_letters = sorted(letter_counts.keys())\n\n for letter in unique_sorted_letters:\n amount_to_remove = letter_counts[letter] if removes >= letter_counts[letter] else removes\n letters = letters.replace(letter, '', amount_to_remove)\n removes -= amount_to_remove\n\n return letters", "import string\ndef solve(st,k): \n for c in string.ascii_lowercase:\n count = st.count(c)\n st = st.replace(c,'',k)\n k -= count\n if k <= 0: break\n return st\n", "from collections import defaultdict\n\n# I knew there was a O(n) solution\ndef solve(st, k):\n D, current, removed = defaultdict(list), ord('a'), set()\n for i,c in enumerate(st): D[ord(c)].append(i)\n while k and len(removed) < len(st):\n removed |= set(D[current][:k])\n k -= min(k, len(D[current]))\n current += 1\n return ''.join(c for i,c in enumerate(st) if i not in removed)", "def solve(st,k): \n for i in range(ord('a'),ord('z')+1):\n while k and chr(i) in st:\n k -= 1\n st = st.replace(chr(i),'',1)\n return st\n", "def solve(st,k):\n if k >= len(st):\n return \"\"\n chars = sorted(st)\n for ch in chars[:k]:\n st = st.replace(ch, '', 1)\n return st", "def solve(s, k): \n for c in \"abcdefghijklmnopqrstuvwxyz\":\n n = s.count(c)\n s = s.replace(c, \"\", k)\n k -= n\n if k < 1:\n break\n return s"] | {"fn_name": "solve", "inputs": [["abracadabra", 0], ["abracadabra", 1], ["abracadabra", 2], ["abracadabra", 6], ["abracadabra", 8], ["abracadabra", 50], ["hxehmvkybeklnj", 5], ["cccaabababaccbc", 3], ["cccaabababaccbc", 9], ["u", 1], ["back", 3]], "outputs": [["abracadabra"], ["bracadabra"], ["brcadabra"], ["rcdbr"], ["rdr"], [""], ["xmvkyklnj"], ["cccbbabaccbc"], ["cccccc"], [""], ["k"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,204 |
def solve(st,k):
|
e2b94452b3f041d44f3d1d507f888067 | UNKNOWN | Given two integer arrays where the second array is a shuffled duplicate of the first array with one element missing, find the missing element.
Please note, there may be duplicates in the arrays, so checking if a numerical value exists in one and not the other is not a valid solution.
```
find_missing([1, 2, 2, 3], [1, 2, 3]) => 2
```
```
find_missing([6, 1, 3, 6, 8, 2], [3, 6, 6, 1, 2]) => 8
```
The first array will always have at least one element. | ["def find_missing(arr1, arr2):\n return sum(arr1) - sum(arr2)\n", "from functools import reduce\ndef find_missing(arr1, arr2):\n from itertools import chain\n from functools import reduce\n from operator import xor\n return reduce(xor, chain(arr1, arr2))\n", "def find_missing(A1, A2):\n return sum(A1) - sum(A2)\n", "def find_missing(a, b):\n for i in a:\n try: b.remove(i)\n except: return i", "def find_missing(arr1, arr2):\n for x in set(arr1):\n if arr1.count(x) != arr2.count(x): return x\n", "def find_missing(arr1, arr2):\n return next(a for a in set(arr1) if arr1.count(a) != arr2.count(a))\n# return next((a for a, b in zip(sorted(arr1), sorted(arr2)) if a != b), sorted(arr1)[-1])\n", "from functools import reduce\nfrom operator import xor\n\ndef find_missing(xs, ys):\n return reduce(xor, xs, 0) ^ reduce(xor, ys, 0)\n", "find_missing = lambda *a, C=__import__(\"collections\").Counter: C.__sub__(*map(C, a)).popitem()[0]", "from collections import Counter\n\ndef find_missing(*args):\n c1,c2 = map(Counter, args)\n return (c1-c2).popitem()[0]", "def find_missing(a, b):\n for x in b:\n a.remove(x)\n\n return a[0]"] | {"fn_name": "find_missing", "inputs": [[[1, 2, 3], [1, 3]], [[6, 1, 3, 6, 8, 2], [3, 6, 6, 1, 2]], [[7], []], [[4, 3, 3, 61, 8, 8], [8, 61, 8, 3, 4]], [[0, 0, 0, 0, 0], [0, 0, 0, 0]]], "outputs": [[2], [8], [7], [3], [0]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,203 |
def find_missing(arr1, arr2):
|
87b62c7b7f4c1baea156220f951260c2 | UNKNOWN | You have to write a function that describe Leo:
```python
def leo(oscar):
pass
```
if oscar was (integer) 88, you have to return "Leo finally won the oscar! Leo is happy".
if oscar was 86, you have to return "Not even for Wolf of wallstreet?!"
if it was not 88 or 86 (and below 88) you should return "When will you give Leo an Oscar?"
if it was over 88 you should return "Leo got one already!" | ["def leo(oscar):\n if oscar == 88:\n return \"Leo finally won the oscar! Leo is happy\"\n elif oscar == 86:\n return \"Not even for Wolf of wallstreet?!\"\n elif oscar < 88:\n return \"When will you give Leo an Oscar?\"\n elif oscar > 88:\n return \"Leo got one already!\"\n", "def leo(oscar):\n if oscar <= 88:\n return {86: 'Not even for Wolf of wallstreet?!',\n 88: 'Leo finally won the oscar! Leo is happy'}.get(\n oscar, 'When will you give Leo an Oscar?')\n return 'Leo got one already!'\n", "def leo(oscar):\n \"\"\"Return string describing Leo based on 'oscar'.\n\n (int) -> str\n\n Conditions:\n - If 'oscar' was 88, you should return \"Leo finally won the oscar! Leo is happy\",\n - If 'oscar' was 86, you should return \"Not even for Wolf of wallstreet?!\",\n - If 'oscar' was not 88 or 86 (and below 88) you should return \"When will you give Leo an Oscar?\",\n - If 'oscar' was over 88 you should return \"Leo got one already!\"\n\n >>> leo(88)\n \"Leo finally won the oscar! Leo is happy\"\n\n Example test cases:\n - test.assert_equals(leo(85),\"When will you give Leo an Oscar?\")\n - test.assert_equals(leo(86),\"Not even for Wolf of wallstreet?!\")\n - test.assert_equals(leo(87),\"When will you give Leo an Oscar?\")\n - test.assert_equals(leo(88),\"Leo finally won the oscar! Leo is happy\")\n - test.assert_equals(leo(89),\"Leo got one already!\")\n \"\"\"\n if oscar > 88:\n return \"Leo got one already!\"\n elif oscar == 88:\n return \"Leo finally won the oscar! Leo is happy\"\n elif oscar == 86:\n return \"Not even for Wolf of wallstreet?!\"\n else:\n return \"When will you give Leo an Oscar?\"", "def leo(oscar):\n if oscar == 88:\n return \"Leo finally won the oscar! Leo is happy\"\n elif oscar == 86:\n return \"Not even for Wolf of wallstreet?!\"\n elif oscar == 87 or oscar < 86:\n return \"When will you give Leo an Oscar?\"\n else:\n return \"Leo got one already!\"\n", "def leo(oscar):\n return (\"Leo got one already!\",\n \"When will you give Leo an Oscar?\",\n \"Not even for Wolf of wallstreet?!\",\n \"Leo finally won the oscar! Leo is happy\")[(oscar == 86) + (oscar < 88) + 3 * (oscar == 88)]", "def leo(oscar):\n r = [\"Leo finally won the oscar! Leo is happy\",\n \"Not even for Wolf of wallstreet?!\",\n \"When will you give Leo an Oscar?\",\n \"Leo got one already!\"]\n return r[0] if oscar==88 else r[1] if oscar==86 else r[2] if oscar==87 or oscar<86 else r[3]", "def leo(oscar):\n if oscar == 88:\n return 'Leo finally won the oscar! Leo is happy'\n elif oscar < 88 and oscar != 86:\n return 'When will you give Leo an Oscar?'\n elif oscar == 86:\n return 'Not even for Wolf of wallstreet?!'\n return 'Leo got one already!'", "def leo(oscar):\n if oscar>88:\n return \"Leo got one already!\"\n return \"Leo finally won the oscar! Leo is happy\" if oscar==88 else \"Not even for Wolf of wallstreet?!\" if oscar ==86 else \"When will you give Leo an Oscar?\"", "def leo(oscar):\n print(oscar)\n if oscar == 88:\n return 'Leo finally won the oscar! Leo is happy'\n elif oscar == 86:\n return 'Not even for Wolf of wallstreet?!'\n elif oscar <= 88:\n return 'When will you give Leo an Oscar?'\n return 'Leo got one already!'", "def leo(oscar):\n oscar = int(oscar)\n if oscar == 88:\n return \"Leo finally won the oscar! Leo is happy\"\n elif oscar == 86:\n return \"Not even for Wolf of wallstreet?!\"\n elif oscar < 88:\n return \"When will you give Leo an Oscar?\"\n else:\n return \"Leo got one already!\"\n", "def leo(oscar):\n if oscar == 88:\n return \"Leo finally won the oscar! Leo is happy\"\n elif oscar == 86:\n return \"Not even for Wolf of wallstreet?!\"\n elif (oscar != 88 or oscar != 86) and oscar < 88:\n return \"When will you give Leo an Oscar?\"\n else:\n return \"Leo got one already!\"\n", "def leo(oscar):\n if oscar == 88:\n return \"Leo finally won the oscar! Leo is happy\"\n elif oscar == 86:\n return \"Not even for Wolf of wallstreet?!\"\n elif oscar <= 88 and oscar != 86:\n return \"When will you give Leo an Oscar?\"\n elif oscar > 88:\n return \"Leo got one already!\"", "rules = [\n (lambda x: x == 88, \"Leo finally won the oscar! Leo is happy\"),\n (lambda x: x == 86, \"Not even for Wolf of wallstreet?!\"),\n (lambda x: x < 88, \"When will you give Leo an Oscar?\"),\n (lambda x: True, \"Leo got one already!\")\n]\n\nleo = lambda oscar: next(text for (predicate, text) in rules if predicate(oscar))", "leo = lambda o: [\"Not even for Wolf of wallstreet?!\",\"When will you give Leo an Oscar?\",\"Leo got one already!\",\"Leo finally won the oscar! Leo is happy\"][(o!=86)+(o>=88)+(o==88)]", "def leo(oscar):\n return \"Not even for Wolf of wallstreet?!\" if oscar==86 else \"When will you give Leo an Oscar?\" if oscar<88 else \"Leo finally won the oscar! Leo is happy\" if oscar == 88 else \"Leo got one already!\"", "def leo(oscar):\n if oscar==88:\n return \"Leo finally won the oscar! Leo is happy\"\n elif oscar==86:\n return \"Not even for Wolf of wallstreet?!\"\n elif (oscar!=86 or oscar!=88) and oscar<88:\n return \"When will you give Leo an Oscar?\"\n else:\n return \"Leo got one already!\"\n", "def leo(oscar: int) -> str:\n \"\"\" Will oscar go to Leonardo DiCaprio? \"\"\"\n return {\n oscar == 88: \"Leo finally won the oscar! Leo is happy\",\n oscar == 86: \"Not even for Wolf of wallstreet?!\",\n oscar not in (86, 88) and oscar <= 87: \"When will you give Leo an Oscar?\",\n oscar > 88: \"Leo got one already!\"\n }.get(True)", "def leo(oscar):\n return (\"When will you give Leo an Oscar?\", \n \"Not even for Wolf of wallstreet?!\", \n \"Leo finally won the oscar! Leo is happy\", \n \"Leo got one already!\")[(oscar == 86) - (oscar >= 88) - (oscar == 88)]", "def leo(o):\n return {\n o == 88: \"Leo finally won the oscar! Leo is happy\",\n o < 88: \"When will you give Leo an Oscar?\",\n o > 88: \"Leo got one already!\",\n o == 86: \"Not even for Wolf of wallstreet?!\"\n }[1]"] | {"fn_name": "leo", "inputs": [[88], [87], [86]], "outputs": [["Leo finally won the oscar! Leo is happy"], ["When will you give Leo an Oscar?"], ["Not even for Wolf of wallstreet?!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 6,578 |
def leo(oscar):
|
aebc0c007b050cfe729b32cbc1ea2f2e | UNKNOWN | Your car is old, it breaks easily. The shock absorbers are gone and you think it can handle about 15 more bumps before it dies totally.
Unfortunately for you, your drive is very bumpy! Given a string showing either flat road ("\_") or bumps ("n"), work out if you make it home safely. 15 bumps or under, return "Woohoo!", over 15 bumps return "Car Dead". | ["def bumps(road):\n return \"Woohoo!\" if road.count(\"n\") <= 15 else \"Car Dead\"", "def bumps(road):\n return 'Car Dead' if road.count('n')>15 else 'Woohoo!'", "def bumps(road):\n return \"Woohoo!\" if road.count('n')<16 else \"Car Dead\"", "from collections import Counter\n\n\ndef bumps(road):\n return \"Car Dead\" if Counter(road)['n'] > 15 else \"Woohoo!\"\n", "import re\ndef bumps(road):\n return \"Woohoo!\" if len(re.findall(\"n\", road)) < 16 else \"Car Dead\"", "def bumps(road):\n MAX_BUMPS = 15\n SUCCESS_MESSAGE = 'Woohoo!'\n ERROR_MESSAGE = 'Car Dead'\n \n return SUCCESS_MESSAGE if road.count('n') <= MAX_BUMPS else ERROR_MESSAGE", "def bumps(road):\n if road.count('n') < 16:\n return \"Woohoo!\"\n return \"Car Dead\"", "def bumps(road):\n if road.count('n') > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "bumps=lambda road: 'CWaoro hDoeoa!d'[(road.count('n')<16)::2]", "def bumps(road):\n return (\"Woohoo!\", \"Car Dead\")[road.count('n') > 15]", "def bumps(road):\n \n track = 0\n \n for el in road:\n if el == 'n':\n track += 1\n \n if track > 15:\n return 'Car Dead'\n else:\n return 'Woohoo!'", "def bumps(road):\n n = 'n'\n return 'Woohoo!' if road.count(n) <= 15 else 'Car Dead'\n", "def bumps(road):\n a = 0\n \n for i in road:\n if i == 'n':\n a += 1\n \n if a > 15:\n return 'Car Dead'\n else:\n return 'Woohoo!'\n \n", "def bumps(road):\n bumps = 0\n for c in road:\n if c == \"n\":\n bumps += 1\n if bumps <= 15:\n return \"Woohoo!\"\n else: return \"Car Dead\"", "def bumps(road):\n L = list(road)\n C = L.count('n')\n if C > 15:\n return 'Car Dead'\n else:\n return 'Woohoo!'\n", "def bumps(road):\n r = list(road)\n \n if r.count('n') <=15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"\n\n", "def bumps(road):\n #I: string\n #O: string\n \n #\n commute = road \n \n #count bumps\n bumps = commute.count('n')\n \n #summarize filter logic\n condition_1 = bumps < 16\n condition_2 = bumps >= 16 \n \n if condition_1:\n return 'Woohoo!'\n if condition_2:\n return 'Car Dead'\n \n \n", "def bumps(road):\n count = 0\n for el in road:\n if el == \"n\":\n count+=1\n if count <= 15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"\n", "\n\n\ndef bumps(road):\n return 'Car Dead' if len([r for r in road if r is 'n']) > 15 else 'Woohoo!'\n\n\ndef best_practice_bumps(road):\n return \"Woohoo!\" if road.count(\"n\") <= 15 else \"Car Dead\"\n\n\n", "def bumps(road):\n road.count('n')\n if road.count('n') <= 15:\n return \"Woohoo!\"\n elif road.count('n') > 15:\n return \"Car Dead\"\n else:\n pass\n", "def bumps(road):\n x = road.count(\"n\")\n results = [\"Woohoo!\", \"Car Dead\"]\n \n if x > 15:\n return results[1]\n else:\n return results[0]", "def bumps(road):\n c = road.count(\"n\")\n if c > 15:\n return \"Car Dead\"\n return \"Woohoo!\"", "def bumps(road):\n bumps= road.count(\"n\")\n if bumps > 15:\n return \"Car Dead\"\n elif bumps <= 15:\n return \"Woohoo!\"\n \n", "def bumps(road):\n k = list(road)\n count = 0\n for word in k:\n if word == \"n\":\n count += 1\n if count < 16:\n return \"Woohoo!\"\n else :\n return \"Car Dead\"\n", "def bumps(road):\n b = road.count('n')\n if b<=15:\n return 'Woohoo!'\n else:\n return 'Car Dead'", "def bumps(s):\n return 'Woohoo!' if s.count('n') < 16 else 'Car Dead'", "def bumps(road):\n bumps = 0\n \n for char in road:\n if char == 'n':\n bumps = bumps + 1\n if bumps <= 15:\n return 'Woohoo!'\n else: return 'Car Dead'", "def bumps(road):\n n = 0\n for i in road:\n if i==\"n\":\n n = n+1\n return (\"Woohoo!\" if n<=15 else \"Car Dead\" )\n", "def bumps(road):\n b = road.count('n')\n if b > 15:\n s = \"Car Dead\"\n else:\n s = \"Woohoo!\"\n return s", "def bumps(road):\n\n count = 0\n for i in road:\n if i == \"n\":\n count += 1\n \n if count <= 15:\n return \"Woohoo!\"\n return \"Car Dead\"", "def bumps(road):\n counter = 0\n for i in road:\n if i == 'n':\n counter += 1\n if counter > 15:\n return 'Car Dead'\n else:\n return 'Woohoo!'", "def bumps(road):\n if road.count('n') <= 15:\n return \"Woohoo!\"\n return \"Car Dead\"\n # Flez\n", "def bumps(road):\n bumps = [x for x in road if x == 'n']\n if len(bumps) > 15:\n return 'Car Dead'\n return 'Woohoo!'", "def bumps(road: str) -> str:\n return \"Car Dead\" if road.count('n') > 15 else \"Woohoo!\"\n", "bumps = lambda s: 'Woohoo!' if s.count('n') < 16 else 'Car Dead'", "def bumps(road):\n x=0\n for i in road:\n if i==\"n\":\n x+=1\n if x>15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"\n # your code here\n", "def bumps(road):\n n = 0\n for i in road:\n if i == 'n':\n n += 1\n if n > 15:\n return \"Car Dead\"\n return \"Woohoo!\" ", "def bumps(road):\n # your code here\n n = road.count(\"n\")\n if n <= 15:\n return \"Woohoo!\"\n return \"Car Dead\"", "def bumps(road):\n count = 0\n for char in road:\n if char == \"n\":\n count += 1\n if count > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n list(road)\n bump_counter = 0\n for bump in road:\n if bump == 'n':\n bump_counter += 1\n if bump_counter <= 15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"", "def bumps(road):\n counter = -1\n bumps = 0\n for x in road:\n counter += 1\n if road[counter] == 'n':\n bumps += 1\n print(bumps)\n if bumps <= 15:\n return 'Woohoo!'\n else:\n return 'Car Dead'\n", "def bumps(road):\n a = 0\n for i in road:\n if i == \"n\":\n a += 1\n if a > 15:\n return \"Car Dead\"\n return \"Woohoo!\"", "def bumps(road):\n n = 0\n for char in road:\n if char == \"n\":\n n += 1\n if n > 15:\n return \"Car Dead\"\n else: return \"Woohoo!\"", "def bumps(road):\n # your code here\n bumps = 0\n for i in range(len(road)):\n if road[i] == \"n\":\n bumps += 1\n if bumps > 15:\n return \"Car Dead\"\n \n return \"Woohoo!\"", "def bumps(s):\n return(\"Woohoo!\" if s.count('n') <= 15 else \"Car Dead\")", "def bumps(road):\n count = 0\n for x in road:\n if x is \"n\":\n count = count + 1\n if count > 15: x = \"Car Dead\"\n else: x = \"Woohoo!\"\n return x", "def bumps(road):\n fiut=0\n for n in road:\n if n == \"n\":\n fiut += 1\n if fiut>15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n count = 0\n for c in road:\n if c == 'n':\n if count == 15:\n return \"Car Dead\"\n count += 1\n return \"Woohoo!\"", "def bumps(road):\n \n \n c = road.count('n')\n \n if c>15:\n \n return \"Car Dead\"\n \n else:\n \n return \"Woohoo!\"\n \n", "def bumps(road):\n x = 0\n for spot in road:\n if spot == 'n':\n x += 1\n else:\n continue\n if x > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"\n", "def bumps( road ):\n cnt1, cnt2 = 0, 0\n for c in road:\n if c == \"_\":\n cnt1 += 1\n elif c == \"n\":\n cnt2 += 1\n if cnt2 > 15:\n return \"Car Dead\"\n return \"Woohoo!\"\n", "f1 = lambda x: 1 if x == 'n' else 0\nf2 = lambda x: 'Woohoo!' if x <= 15 else \"Car Dead\"\n\ndef bumps(road):\n # your code here\n return f2(sum((f1(x) for x in road)))", "def bumps(road):\n ncount = 0\n a = [char for char in road]\n for i in range(len(a)):\n if a[i] == \"n\":\n ncount += 1\n \n if ncount > 15:\n return \"Car Dead\"\n else: \n return \"Woohoo!\"", "def bumps(road):\n flat=[]\n bump=[]\n for letter in road:\n if letter is \"_\":\n flat.append(letter)\n else:\n bump.append(letter)\n if len(bump)<=15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"\n", "def bumps(s):\n if s.count(\"n\") <= 15:\n return \"Woohoo!\" \n else:\n return \"Car Dead\"\n", "def bumps(road):\n bumps = 0\n for letter in road:\n if letter == 'n' or letter == 'N':\n bumps += 1\n elif letter == '_':\n continue\n else:\n continue\n if bumps > 15:\n return 'Car Dead'\n else:\n return 'Woohoo!'", "def bumps(road):\n bumps = 0\n for letter in road:\n if letter == 'n':\n bumps += 1\n continue\n else:\n continue\n if bumps > 15:\n return 'Car Dead'\n else:\n return 'Woohoo!'", "def bumps(road):\n result = 0\n for i in road:\n if i == \"n\":\n result +=1\n if result <= 15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"", "def bumps(road):\n nr_bumps = 0\n for c in road:\n if c == 'n':\n nr_bumps += 1\n return \"Woohoo!\" if nr_bumps < 16 else \"Car Dead\"", "def bumps(road):\n x = road.count('n')\n if x <= 15:\n return 'Woohoo!'\n else :\n return 'Car Dead'", "def bumps(road):\n a = 0\n for char in road:\n if str(char) == 'n':\n a += 1\n if a <= 15:\n return 'Woohoo!'\n if a > 15:\n return 'Car Dead'", "def bumps(road):\n n=0\n for i in road:\n if i==\"n\":\n n+=1\n if n>15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n counter = 0\n for i in road:\n if i == 'n':\n counter += 1\n continue\n return 'Woohoo!' if counter <= 15 else 'Car Dead'\n", "def bumps(road):\n bumps = 0\n for a in road:\n if a == 'n':\n bumps += 1\n if bumps <= 15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"", "def bumps(road):\n return 'Car Dead' if (''.join(sorted(road, reverse=True)[0:16]))=='nnnnnnnnnnnnnnnn' else 'Woohoo!'", "def bumps(road):\n x = road.count(\"n\")\n if x <= 15:\n return \"Woohoo!\"\n return \"Car Dead\"", "def bumps(road):\n count = 0\n for i in road:\n if i == 'n':\n count += 1\n else:\n pass\n if count > 15:\n return (\"Car Dead\")\n else:\n return (\"Woohoo!\")\n \n", "def bumps(road):\n roadList = list(road)\n speedBumps = \"n\"\n bumpCount = 0\n for i in roadList:\n if i == \"n\":\n bumpCount += 1\n if bumpCount > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n return \"Woohoo!\" if len(list(filter((lambda x: x == 'n'), road))) <= 15 else \"Car Dead\"", "def bumps(road):\n l = 0\n for i in road:\n if i == \"n\":\n l += 1\n return \"Woohoo!\" if l <= 15 else \"Car Dead\"", "def bumps(road):\n list = [(road)]\n a = 0\n for x in road:\n if x == 'n':\n a = a + 1\n if a > 15:\n return \"Car Dead\"\n return \"Woohoo!\" ", "def bumps(road):\n bump = 15\n for char in road:\n if char == 'n':\n bump = bump - 1\n return \"Car Dead\" if bump < 0 else \"Woohoo!\"", "def bumps(road):\n bumps = 0\n for char in road:\n if char == 'n':\n bumps += 1\n if bumps > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n countN=0\n countUnderscore=0\n listletters=[char for char in road]\n for i in listletters:\n if i=='n':\n countN+=1\n else:\n countUnderscore+=1\n if countN>15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n # your code here\n bump = 0\n for s in road:\n if s == 'n':\n bump+=1\n return \"Woohoo!\" if bump<=15 else \"Car Dead\"", "def bumps(road):\n r = road\n c = r.count(\"n\")\n if c < 16:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"", "def bumps(road):\n # your code here\n return \"Car Dead\" if len(list(filter(str.isalpha,road))) > 15 else 'Woohoo!' \n", "def bumps(road):\n # your code here\n bumps = 0\n for i in road:\n if i == '_':\n pass\n elif i == 'n':\n bumps += 1\n if bumps > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n dead = 0\n for x in road:\n if x == \"n\":\n dead += 1\n \n if dead > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n counter=0\n for i in road:\n if i=='n':\n counter+=1\n else:\n pass\n return 'Woohoo!'if counter<=15 else 'Car Dead'\n \n", "def bumps(road):\n bumps = 0\n for ch in road:\n if ch == \"n\":\n bumps +=1\n \n if bumps > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n num=0\n for x in road:\n if x == 'n':\n num+=1\n if num <= 15:\n return 'Woohoo!'\n else:\n return 'Car Dead'", "def bumps(road):\n bumps = 0\n for i in range(len(road)):\n if road[i] == \"n\":\n bumps = bumps + 1\n \n if bumps > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"", "def bumps(road):\n count = 0\n for each in road:\n if each == \"n\":\n count += 1\n if count > 15:\n return \"Car Dead\"\n elif count <= 15:\n return \"Woohoo!\"", "def bumps(road):\n x = road.count('n',0)\n if x <= 15:\n return 'Woohoo!'\n else:\n return 'Car Dead'\n", "def bumps(road):\n# for i in road:\n c = road.count(\"n\")\n if c > 15:\n return \"Car Dead\"\n else:\n return \"Woohoo!\"\n # for i in bumps:\n \n # your code here\n", "def bumps(road):\n # your code here\n road_list = list(road)\n bump_number = 0\n for segment in road_list:\n if segment == 'n':\n bump_number += 1\n if bump_number <= 15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"", "def bumps(road):\n n = [x for x in road if x == 'n'].count('n')\n return 'Woohoo!' if n <= 15 else 'Car Dead'", "def bumps(road):\n sum = 0\n for i in road:\n if i is \"n\":\n sum += 1\n if sum > 15:\n return \"Car Dead\"\n return \"Woohoo!\"", "def bumps(road):\n return 'Woohoo!' if len(road.split('n')) <= 16 else 'Car Dead'", "def bumps(road):\n newrd = list(road)\n bumps = newrd.count('n')\n if bumps <= 15:\n return \"Woohoo!\"\n elif bumps > 15:\n return \"Car Dead\"\n \n", "def bumps(road):\n b = 0\n for i in road:\n if i == 'n':\n b+=1\n return \"Woohoo!\" if b <= 15 else \"Car Dead\"", "def bumps(road):\n count = road.count(\"n\")\n if count > 15:\n return \"Car Dead\" \n return \"Woohoo!\"\n", "bumps = lambda road: \"Woohoo!\" if road.count('n')<16 else \"Car Dead\"\n", "def bumps(road):\n b=0\n for x in road:\n if x == 'n':\n b = b+1\n if b<15:\n return \"Woohoo!\"\n elif b==15:\n return \"Woohoo!\"\n else:\n return \"Car Dead\"\n", "def bumps(road):\n n_count = road.count(\"n\")\n \n if n_count > 15:\n return \"Car Dead\"\n elif n_count <= 15:\n return \"Woohoo!\"\n return\n", "def bumps(road):\n '''(string)-> string\n A string representation of the road will be the input.\n Tests will be made to ensure that there are less than 15\n bumps in the road.'''\n num_bumps = road.count('n')\n if num_bumps > 15:\n return 'Car Dead'\n return 'Woohoo!'\n", "def bumps(road):\n bump = 0\n for x in road:\n if x == \"n\":\n bump += 1\n if bump <= 15:\n return(\"Woohoo!\")\n else:\n return(\"Car Dead\")", "def bumps(road):\n badNumber = 15\n count = 0\n for i in range(len(road)):\n if road[i] == \"n\":\n count += 1\n if count <= badNumber:\n return \"Woohoo!\"\n if count > badNumber:\n return \"Car Dead\"", "def bumps(road):\n lista = list(road)\n bumps = 0\n for i in lista:\n if i == 'n':\n bumps += 1\n \n if bumps <= 15:\n return 'Woohoo!'\n else:\n return 'Car Dead'\n"] | {"fn_name": "bumps", "inputs": [["n"], ["_nnnnnnn_n__n______nn__nn_nnn"], ["______n___n_"], ["nnnnnnnnnnnnnnnnnnnnn"]], "outputs": [["Woohoo!"], ["Car Dead"], ["Woohoo!"], ["Car Dead"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 17,441 |
def bumps(road):
|
81d160b706129767cc5f0f165884d0e6 | UNKNOWN | In Russia regular bus tickets usually consist of 6 digits. The ticket is called lucky when the sum of the first three digits equals to the sum of the last three digits. Write a function to find out whether the ticket is lucky or not. Return true if so, otherwise return false. Consider that input is always a string. Watch examples below. | ["def is_lucky(ticket):\n if len(ticket) == 6 and ticket.isdigit():\n t = list(map(int, ticket))\n return sum(t[:3]) == sum(t[3:])\n return False", "def is_lucky(t):\n return len(t) == 6 and t.isdigit() and sum(map(int, t[:3])) == sum(map(int, t[3:]))", "def is_lucky(ticket):\n if len(ticket) == 6 and ticket.isdigit():\n return sum(map(int, ticket[:3])) == sum(map(int, ticket[3:]))\n return False", "def is_lucky(ticket):\n return True if len(ticket) == 6 and ticket.isnumeric() and sum([int(i) for i in ticket[:3]]) == sum([int(i) for i in ticket[3:]]) else False", "import re\ndef is_lucky(ticket):\n return bool(re.match(r'\\d{6}', ticket)) and sum(int(i) for i in ticket[:3]) == sum(int(i) for i in ticket[3:])", "def is_lucky(ticket):\n try:\n if ticket == '':\n return False\n else:\n idk = [int(x) for x in ticket]\n first = sum(idk[0:3])\n second = sum(idk[3:6])\n if first == second:\n return True\n else:\n return False\n except:\n return False", "def is_lucky(ticket):\n return False if len(ticket) != 6 or not ticket.isdigit() else sum(map(int, ticket[:3])) == sum(map(int, ticket[3:]))", "def is_lucky(ticket):\n try:\n return sum(int(ticket) // 10**i % 10 * complex(0, 1)**(i // 3 * 2) for i in range(6)) == 0\n except:\n return False", "def is_lucky(ticket):\n if len(ticket) != 6:\n return False\n \n total = 0\n \n for i, c in enumerate(ticket):\n if not c.isdigit():\n return False\n \n if i < 3:\n total += int(c)\n else:\n total -= int(c)\n \n return total == 0", "def is_lucky(ticket):\n try:\n y = int(ticket)\n except ValueError:\n return False\n return sum([int(x) for x in ticket[0:3]]) == sum([int(x) for x in ticket[3:]]) "] | {"fn_name": "is_lucky", "inputs": [["123321"], ["12341234"], ["100001"], ["100200"], ["912435"], ["12a12a"], ["999999"], ["1111"], ["000000"], [""]], "outputs": [[true], [false], [true], [false], [true], [false], [true], [false], [true], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,958 |
def is_lucky(ticket):
|
6d1f6b6f221b8ad91ca9824883ef71ca | UNKNOWN | In this Kata, we will calculate the **minumum positive number that is not a possible sum** from a list of positive integers.
```
solve([1,2,8,7]) = 4 => we can get 1, 2, 3 (from 1+2), but we cannot get 4. 4 is the minimum number not possible from the list.
solve([4,1,2,3,12]) = 11. We can get 1, 2, 3, 4, 4+1=5, 4+2=6,4+3=7,4+3+1=8,4+3+2=9,4+3+2+1=10. But not 11.
solve([2,3,2,3,4,2,12,3]) = 1. We cannot get 1.
```
More examples in test cases.
Good luck! | ["def solve(xs):\n m = 0\n for x in sorted(xs):\n if x > m + 1:\n break\n m += x\n return m + 1", "from itertools import accumulate\n\ndef solve(arr):\n arr = sorted(arr)\n return next((x+1 for x, i in zip(accumulate([0]+arr), arr+[0]) if i > x + 1), sum(arr)+1)", "def solve(r):\n \u01c2 = 1\n for x in sorted(r):\n if x > \u01c2:\n break\n else: \u01c2 += x\n return \u01c2", "def solve(arr):\n arr.sort()\n res = 1\n for i in range(len(arr)):\n if arr[i] <= res:\n res += arr[i]\n return res", "def solve(arr):\n arr, res, n, i = sorted(arr), 1, len(arr), 0\n while i < n and res >= arr[i]:\n res, i = res + arr[i], i + 1\n return res", "def solve(a):\n a.sort()\n i,j= 1,0\n while j < len(a):\n j += 1\n if a[j-1] <= i:\n i += a[j-1]\n else: \n break\n return i", "def solve(arr):\n miss = 1\n for a in sorted(arr):\n if a > miss:\n break\n miss += a\n return miss", "solve=s=lambda a,x=1:a and s(a,x|x<<a.pop())or len(bin(~x&x+1))-3", "def solve(arr):\n arr.sort()\n print(arr)\n for x in range(1,sum(arr)+1):\n working_arr = []\n if x in arr:\n continue\n for idx_y, y in enumerate(arr):\n if x < y:\n working_arr = arr[:idx_y]\n if sum(working_arr) < x:\n return x\n return sum(arr) + 1\n", "def solve(arr):\n arr=sorted(arr)\n l=len(arr)\n x=1\n for i in range(l):\n if arr[i]<=x:\n x+=arr[i]\n else:\n break\n return x\n \n"] | {"fn_name": "solve", "inputs": [[[1, 2, 8, 7]], [[2, 12, 3, 1]], [[4, 2, 8, 3, 1]], [[4, 2, 7, 3, 1]], [[4, 2, 12, 3]]], "outputs": [[4], [7], [19], [18], [1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,699 |
def solve(arr):
|
5cc0a3ecafc75142fb21a997c7966724 | UNKNOWN | ### Task
King Arthur and his knights are having a New Years party. Last year Lancelot was jealous of Arthur, because Arthur had a date and Lancelot did not, and they started a duel.
To prevent this from happening again, Arthur wants to make sure that there are at least as many women as men at this year's party. He gave you a list of integers of all the party goers.
Arthur needs you to return true if he needs to invite more women or false if he is all set.
### Input/Output
- `[input]` integer array `L` (`$a` in PHP)
An array (guaranteed non-associative in PHP) representing the genders of the attendees, where `-1` represents `women` and `1` represents `men`.
`2 <= L.length <= 50`
- `[output]` a boolean value
`true` if Arthur need to invite more women, `false` otherwise. | ["def invite_more_women(arr):\n return sum(arr) > 0", "def invite_more_women(arr):\n return arr.count(1) > arr.count(-1)", "def invite_more_women(arr):\n x = arr.count(-1)\n y = arr.count(1)\n if x >= y:\n return 0\n else:\n return 1", "\ndef invite_more_women(arr):\n a = sum(arr)\n if a <= 0:\n return False\n else:\n return True\n \n \n", "def invite_more_women(arr):\n x = arr.count(-1)\n y = arr.count(1)\n return (x < y)", "invite_more_women=lambda a:sum(a)>0", "def invite_more_women(arr):\n freq = {}\n for item in arr: \n if (item in freq): \n freq[item] += 1 \n else: \n freq[item] = 1 \n print(freq)\n if 1 not in freq:\n return False\n if -1 not in freq: \n return True\n if freq[1] == freq[-1]: \n return False\n if freq[1] > freq[-1]: \n return True\n else: \n return False", "from typing import List\n\n\ndef invite_more_women(a: List[int]) -> bool:\n return sum(a) > 0", "def invite_more_women(arr):\n \"\"\"given an array of numbers (-1) or (1); where -1 == women and 1 == men;\n return True if number of women is less than the number of men \"\"\"\n \n return 0 < sum(arr)", "def invite_more_women(arr):\n #your code here\n a, b = 0, 0\n for i in arr:\n if i == 1:\n a = a+1\n if i == -1:\n b = b+1\n \n if a == b or a<b:\n c = False\n else: c = True\n return c", "def invite_more_women(arr):\n return arr.count(-1) < arr.count(1)", "invite_more_women=lambda arr: sum(arr)>0", "def invite_more_women(arr):\n return True if sum(arr) > 0 else False", "invite_more_women = lambda x: sum(x) > 0", "def invite_more_women(arr):\n return False if sum(arr) <= 0 else True ", "def invite_more_women(arr):\n# women = arr.count(-1)\n# men= arr.count(1)\n# return True if women<men\n return sum(arr)>0", "def invite_more_women(arr):\n countW = 0\n countM = 0\n for i in arr:\n if i == -1:\n countW += 1\n else:\n countM += 1\n return countW < countM", "def invite_more_women(arr):\n count_women = 0\n count_men = 0\n for element in arr:\n if element == 1:\n count_men += 1\n else:\n count_women += 1\n if count_women < count_men:\n return True\n else:\n return False", "def invite_more_women(arr):\n men = 0\n women = 0\n for x in arr:\n if x == 1:\n men = men + 1\n else:\n women = women + 1\n if men > women:\n return True\n else:\n return False\n", "def invite_more_women(arr):\n \n women = 0\n men = 0\n \n for i in arr:\n if i == 1:\n men+=1\n if i == -1:\n women+=1\n \n if men > women:\n return True\n else:\n return False", "from collections import Counter\ndef invite_more_women(arr):\n c = Counter(arr)\n return c[1]>c[-1]", "def invite_more_women(A):\n return sum(A)>0", "def invite_more_women(arr):\n if arr == []:\n return False\n m = 0\n w = 0\n for el in arr:\n if el == 1:\n m += 1\n elif el == -1:\n w += 1\n if w < m:\n return True\n elif w >= m:\n return False\n", "from typing import List\n\ndef invite_more_women(arr: List[int]) -> bool:\n return sum(arr) > 0", "def invite_more_women(arr):\n if arr == []:\n return False\n else:\n count1 = 0\n count2 = 0\n for eachnumber in arr:\n if eachnumber == 1:\n count1 = count1 + 1\n elif eachnumber == -1:\n count2 = count2 + abs(eachnumber)\n if count2 > count1 or count2 == count1:\n return False\n else:\n return True", "def invite_more_women(arr):\n l=len(arr)\n sl=''.join(x for x in str(arr))\n l_1=sl.count('-1')\n if l_1<(l-l_1):\n return True\n else:\n return False", "def invite_more_women(arr):\n count_men = 0\n for k in arr:\n if k == 1:\n count_men += 1\n if count_men > len(arr)//2:\n return True\n else:\n return False", "def invite_more_women(arr):\n nm = len([x for x in arr if x == 1])\n nw = len([x for x in arr if x == -1])\n if nw < nm:\n return True\n else:\n return False", "def invite_more_women(arr):\n men = arr.count(1)\n women = arr.count(-1)\n if men <= women:\n return False\n return True", "def invite_more_women(arr):\n w = 0\n m = 0\n for i in arr:\n if i==1: m = m+1\n else: w = w+1\n if w<m : \n return True\n else:\n return False", "invite_more_women = lambda lst: sum(lst) > 0", "def invite_more_women(arr):\n a = []\n b = []\n for i in arr:\n if i < 0:\n b.append(i)\n else:\n a.append(i)\n if len(b) < len(a):\n return True\n else:\n return False", "def invite_more_women(arr):\n men = 0\n women = 0\n \n for elem in arr:\n if elem == -1:\n women += 1\n elif elem == 1:\n men += 1\n \n return men > women", "def invite_more_women(arr):\n i = []\n n = []\n for number in arr:\n if number < 0:\n n.append(number)\n else:\n i.append(number)\n if len(i) > len(n):\n return True\n else:\n return False\n \n", "def invite_more_women(arr):\n \n \n x = arr.count(-1)\n n = arr.count(1)\n if x < n:\n return True\n return False", "def invite_more_women(arr):\n return sum(arr)>0 if arr else False", "import functools\ndef invite_more_women(arr):\n if len(arr) > 0:\n return True if (functools.reduce(lambda a,b : a+b,arr)) > 0 else False\n else:\n return False", "def invite_more_women(arr):\n count_women = 0\n count_men = 0\n for x in arr:\n if x == -1:\n count_women += 1\n elif x == 1:\n count_men += 1\n #print(count_women)\n #print(count_men)\n if count_men > count_women:\n return True\n else:\n return False", "def invite_more_women(arr):\n men=0\n women=0\n for x in arr:\n if x==1:\n men+=1\n if x==-1:\n women+=1\n if women<men:\n return True\n return False", "def invite_more_women(arr):\n pass # your code here\n return 1 if sum(arr)>0 else False", "def invite_more_women(arr):\n w=arr.count(1)\n m=arr.count(-1)\n if w>m:return True\n else:return False", "def invite_more_women(arr):\n return False if not arr or sum( arr) <= 0 else True", "def invite_more_women(arr):\n \n #No way this is the short way :(\n \n men = 0\n women = 0\n \n for x in arr:\n if x == 1:\n men += 1\n else:\n women += 1\n \n if women >= men:\n return False\n else:\n return True\n \n", "def invite_more_women(arr):\n return len([x for x in arr if x == 1]) > len([x for x in arr if x == -1])", "def invite_more_women(arr):\n return abs(sum(filter(lambda x: x<0, arr))) < sum(filter(lambda x: x>0, arr))", "def invite_more_women(arr):\n w = arr.count(-1)\n m = arr.count(1)\n return w < m", "def invite_more_women(arr):\n countMen = 0\n countWomen = 0\n for i in arr:\n if i == 1:\n countMen = countMen + 1\n elif i == -1:\n countWomen = countWomen + 1\n\n if countWomen < countMen:\n return True\n elif countWomen >= countMen:\n return False", "def invite_more_women(arr):\n pass \n \n m = arr.count(1)\n \n w = arr.count(-1)\n \n if m>w:\n \n return True\n \n else:\n \n return False\n \n \n", "def invite_more_women(arr):\n if len(arr) > 2 and len(arr) < 50:\n invitors = str(arr)\n a = invitors.count(\"1\")\n n = invitors.count(\"-1\")\n if a > n:\n return True\n else:\n return False\n else:\n return False\n \n", "def invite_more_women(arr):\n \n balance = sum(arr)\n \n if balance > 0: return True\n else: return False", "from collections import Counter\n\ndef invite_more_women(arr):\n #your code here\n if arr == []:\n return False\n else:\n r = Counter(arr)\n if r[-1]>=r[1]:\n return False\n else:\n return True\n \n", "def invite_more_women(arr):\n x=sum(i for i in arr)\n if 2<=len(arr)<=50:\n if x>0:\n return True\n else: return False\n else: return False", "import numpy as np\n\ndef invite_more_women(arr):\n return np.sum(arr)>0", "def invite_more_women(arr):\n cw=0\n cm=0\n for i in range(0,len(arr)):\n if arr[i]>0:\n cw=cw+1\n else:\n cm=cm+1\n if cm<cw:\n return True\n else:\n return False\n", "def invite_more_women(arr):\n women=0\n men=0\n for i in arr:\n if i==-1:\n women=women+1\n else: \n men=men+1\n if men>women:\n return True\n else:\n return False", "def invite_more_women(arr):\n #your code here\n \n if arr.count(int('-1')) < arr.count(int('1')):\n return True\n else:\n return False", "def invite_more_women(arr):\n all_women = all(i == -1 for i in arr)\n return not all_women and arr.count(-1) != arr.count(1)", "def invite_more_women(arr):\n return sum(arr) > 0 and len(arr) > 0", "def invite_more_women(arr):\n #your code here\n x = 0\n y = 0\n for l in arr:\n if l == -1:\n x = x + 1\n elif l == 1:\n y = y + 1\n if x < y:\n return True\n else:\n return False\n \n \n", "def invite_more_women(arr):\n #your code here\n \n count_of_men = 0\n count_of_women = 0\n \n for item in arr:\n if item == 1:\n count_of_men += 1\n else:\n count_of_women += 1\n \n if count_of_men <= count_of_women:\n return False\n \n else:\n return True\n \n \n \n \n \n", "def invite_more_women(arr):\n women=0\n men=0\n for person in arr:\n if person == -1:\n women+=1\n if person == 1:\n men+=1\n return men>women\n #your code here\n", "def invite_more_women(arr):\n if arr.count(1)<=arr.count(-1):\n return False\n return True", "def invite_more_women(arr):\n guys = 0\n gals = 0\n for n in arr:\n if n == 1:\n guys += 1\n if n == -1:\n gals += 1\n if gals > guys or gals == guys:\n return False\n else:\n return True", "def invite_more_women(arr):\n men = len([i for i in arr if i > 0])\n women = len([i for i in arr if i < 0])\n \n return True if men > women else False\n", "def invite_more_women(arr=0):\n lst1=[i for i in arr if i<0]\n lst2=[i for i in arr if i>0]\n return len(lst1)<len(lst2)", "def invite_more_women(arr):\n score = sum(arr)\n return score > 0", "def invite_more_women(a):\n if a.count(1) > a.count(-1):\n return True\n else:\n return False", "def invite_more_women(arr):\n men = 0\n women = 0\n for x in arr:\n if x == 1:\n men += 1\n else:\n women += 1\n \n if men > women:\n return True\n else:\n return False\n #your code here\n", "def invite_more_women(arr):\n if 2 <= len(arr) <= 50:\n if arr.count(-1) < arr.count(1):\n return True\n else:\n return False\n\n else:\n return False\n", "def invite_more_women(arr):\n if len([i for i in arr if i != 1]) < len([i for i in arr if i != -1]):\n return True\n else:\n return False", "def invite_more_women(arr):\n count_woman = arr.count(1)\n count_man = arr.count(-1)\n \n return True if count_woman - count_man >= 1 else False\n", "M, W = 1, -1\n\ndef invite_more_women(arr):\n return arr.count(W) < arr.count(M)", "def invite_more_women(arr):\n men = 0\n women = 0\n for i in range(len(arr)):\n if arr[i] == 1:\n men += 1\n elif arr[i] == -1:\n women += 1\n if men > women:\n return True\n else:\n return False", "def invite_more_women(arr):\n x = 0\n for i in range(0, len(arr)):\n x += arr[i]\n return x > 0 ", "def invite_more_women(arr):\n\n intWeman = 0\n intMon = 0\n\n for i in arr:\n if i == 1:\n intMon += 1\n else:\n intWeman += 1\n\n if intWeman < intMon:\n return True\n else:\n return False\n", "def invite_more_women(arr):\n if arr.count(1) == arr.count(-1) or arr.count(-1) == len(arr):\n return False\n return True", "def invite_more_women(arr):\n N=len(arr)\n w,m=0,0\n for i in range(N):\n\n if arr[i] == -1:\n w+=1\n elif arr[i] == 1:\n m+=1\n if m>w:\n return True\n else:\n return False", "def invite_more_women(arr):\n return sum(inv for inv in arr) > 0", "def invite_more_women(arr):\n akjhd = 0\n for element in arr:\n akjhd += element\n if akjhd > 0:\n return True\n elif akjhd <= 0:\n return False", "def invite_more_women(arr):\n sum = 0\n for element in arr:\n sum += element\n if sum > 0:\n return True\n elif sum <= 0:\n return False", "def invite_more_women(arr):\n contador_hombres=0\n contador_mujeres=0\n for elemento in arr:\n if elemento==-1:\n contador_mujeres=contador_mujeres+1\n if elemento==1:\n contador_hombres=contador_hombres+1\n if arr==[]:\n return False\n elif contador_hombres <= contador_mujeres:\n return False\n else :\n return True", "def invite_more_women(arr):\n #your code here\n sumInput = sum(arr) \n if sumInput < 0:\n return False\n elif sumInput == 0:\n return False\n else: \n return True", "def invite_more_women(arr):\n women = 0\n for i in arr:\n if i == -1:\n women = women + 1\n if len(arr)%2 == 0:\n if women >= len(arr)//2:\n return False\n else:\n return True\n else:\n if women > len(arr)//2:\n return False\n else:\n return True\n\n", "def invite_more_women(arr):\n x=len(arr)\n i=0\n a=0\n if x==2:\n if arr[0] ==1:\n if arr[1]==-1:\n return False\n while i<(x):\n a=a+arr[i]\n break\n if a > 0:\n return True\n elif a<0:\n return False\n else:\n return False\n", "def invite_more_women(arr):\n #your code here\n int = sum(arr)\n if (int > 0):\n return True\n else:\n return False", "def invite_more_women(arr):\n m = 0\n w = 0\n for i in arr:\n if i == 1:\n m += 1\n else:\n w += 1\n if w < m:\n return True\n return False\n", "def invite_more_women(arr):\n women = []\n men = []\n for i in arr:\n if i == 1:\n men.append(i)\n else:\n women.append(i)\n if len(men) > len(women):\n return True\n else:\n return False\n", "def invite_more_women(arr):\n i = 0\n for item in arr:\n i += item\n if i > 0:\n return(True)\n else:\n return(False)", "def invite_more_women(arr):\n add_vec=0\n for i in range(0,len(arr)):\n add_vec+=arr[i]\n if add_vec<=0:\n return False\n else:\n return True\n\n\n", "def invite_more_women(arr):\n a = False\n if arr.count(-1) < arr.count(1):\n a = True\n return a\n", "def invite_more_women(arr):\n count = 0\n for a in arr:\n count += a\n if(count > 0):\n return True\n else:\n return False", "invite_more_women = lambda lst: lst.count(-1) < lst.count(1)", "def invite_more_women(arr):\n #your code here\n if len(arr) in range(2,51):\n count=0\n for i in arr:\n count+=i\n if count >0:\n return True\n else:\n return False\n else:\n return False", "def invite_more_women(arr):\n men = 0\n women = 0\n for i in arr:\n if i == -1:\n women = women + 1\n elif i == 1:\n men = men + 1\n else:\n return False\n if women >= men:\n return False\n else:\n return True", "def invite_more_women(arr):\n\n men = []\n women = []\n\n for i in arr:\n\n if abs(i) == i:\n men.append(i)\n else:\n women.append(i)\n\n if len(men) > len(women):\n return True\n if len(men) <= len(women):\n return False", "def invite_more_women(arr):\n return len([a for a in arr if a == 1]) > len([a for a in arr if a == -1])", "def invite_more_women(arr):\n if sum(arr) >=1:\n return sum(arr) >=1\n else: return bool({})", "def invite_more_women(attendees):\n men = 0\n women = 0\n for sex in attendees:\n if sex == -1:\n women += 1\n else:\n men += 1\n if men > women:\n return True\n else:\n return False", "def invite_more_women(arr):\n if len(arr) >= 3:\n for i in arr:\n if i == -1:\n return False\n else: \n return True\n else: \n return False\n", "def invite_more_women(arr):\n women = arr.count(-1)\n man = arr.count(1)\n if man > women:\n return True\n else:\n return False"] | {"fn_name": "invite_more_women", "inputs": [[[1, -1, 1]], [[-1, -1, -1]], [[1, -1]], [[1, 1, 1]], [[]]], "outputs": [[true], [false], [false], [true], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 18,138 |
def invite_more_women(arr):
|
63995ac3ac1240485fbdebb80a0d772f | UNKNOWN | You are given three piles of casino chips: white, green and black chips:
* the first pile contains only white chips
* the second pile contains only green chips
* the third pile contains only black chips
Each day you take exactly two chips of different colors and head to the casino. You can choose any color, but you are not allowed to take two chips of the same color in a day.
You will be given an array representing the number of chips of each color and your task is to return the maximum number of days you can pick the chips. Each day you need to take exactly two chips.
```python
solve([1,1,1]) = 1, because after you pick on day one, there will be only one chip left
solve([1,2,1] = 2, you can pick twice; you pick two chips on day one then on day two
solve([4,1,1]) = 2
```
```javascript
solve([1,1,1]) = 1, because after you pick on day one, there will be only one chip left
solve([1,2,1]) = 2, you can pick twice; you pick two chips on day one then on day two
solve([4,1,1]) = 2
```
```go
solve([1,1,1]) = 1, because after you pick on day one, there will be only one chip left
solve([1,2,1]) = 2, you can pick twice; you pick two chips on day one then on day two
solve([4,1,1]) = 2
```
```ruby
solve([1,1,1]) = 1, because after you pick on day one, there will be only one chip left
solve([1,2,1]) = 2, you can pick twice; you pick two chips on day, two chips on day two
solve([4,1,1]) = 2
```
More examples in the test cases. Good luck!
Brute force is not the way to go here. Look for a simplifying mathematical approach. | ["def solve(xs):\n x, y, z = sorted(xs)\n return min(x + y, (x + y + z) // 2)", "def solve(arr):\n cnt = 0\n arr.sort()\n while(arr[2]<(arr[0]+arr[1])):\n arr[0]-=1\n arr[1]-=1\n cnt+=1\n return cnt+arr[0]+arr[1]", "def solve(arr):\n a,b,c = sorted(arr)\n s = a+b\n if s < c:\n return s\n else:\n return c + int((s-c)/2)", "def score(a,b,c):\n if a+b<c: return a+b\n return (a+b-c)//2+c\n\ndef solve(arr):\n a,b,c = arr\n return min(score(a,b,c),score(b,c,a),score(c,a,b))", "def solve(arr):\n largest = max(arr)\n all = sum(arr)\n \n return all//2 if largest <= all - largest else all - largest", "def solve(arr):\n return min(sum(arr) - max(arr), sum(arr) // 2)", "def solve(arr):\n a, b, c = sorted(arr)\n return (a + b + min(a+b, c)) // 2", "def solve(arr):\n arr.sort()\n d = arr[2]-arr[1]\n if d>arr[0]:\n return arr[0] + arr[1]\n return arr[1]+d +(arr[0]-d)//2", "def solve(arr):\n return sum(arr)-max(arr) if max(arr)>sum(arr)-max(arr) else sum(arr)//2", "def solve(arr):\n arr.sort()\n days = min(arr[1] + arr[0], arr[2])\n otherDays = (arr[0] + arr[1] + arr[2]) // 2\n if arr[1] + arr[0] - arr[2] < 0:\n return days\n return otherDays"] | {"fn_name": "solve", "inputs": [[[1, 1, 1]], [[1, 2, 1]], [[4, 1, 1]], [[8, 2, 8]], [[8, 1, 4]], [[7, 4, 10]], [[12, 12, 12]], [[1, 23, 2]]], "outputs": [[1], [2], [2], [9], [5], [10], [18], [3]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,309 |
def solve(arr):
|
810ef28b505b6e9af780bb2e6ea0a670 | UNKNOWN | The dragon's curve is a self-similar fractal which can be obtained by a recursive method.
Starting with the string `D0 = 'Fa'`, at each step simultaneously perform the following operations:
```
replace 'a' with: 'aRbFR'
replace 'b' with: 'LFaLb'
```
For example (spaces added for more visibility) :
```
1st iteration: Fa -> F aRbF R
2nd iteration: FaRbFR -> F aRbFR R LFaLb FR
```
After `n` iteration, remove `'a'` and `'b'`. You will have a string with `'R'`,`'L'`, and `'F'`. This is a set of instruction. Starting at the origin of a grid looking in the `(0,1)` direction, `'F'` means a step forward, `'L'` and `'R'` mean respectively turn left and right. After executing all instructions, the trajectory will give a beautifull self-replicating pattern called 'Dragon Curve'
The goal of this kata is to code a function wich takes one parameter `n`, the number of iterations needed and return the string of instruction as defined above. For example:
```
n=0, should return: 'F'
n=1, should return: 'FRFR'
n=2, should return: 'FRFRRLFLFR'
```
`n` should be a number and non-negative integer. All other case should return the empty string: `''`. | ["def Dragon(n):\n if not isinstance(n, int) or n < 0:\n return ''\n \n value = 'Fa'\n \n for i in range(n):\n value = value.replace('a', 'aRcFR')\n value = value.replace('b', 'LFaLb')\n value = value.replace('c', 'b')\n \n return value.replace('a', '').replace('b', '')", "def Dragon(n):\n if not isinstance(n, int) or n < 0:\n return ''\n s = 'Fa'\n for i in range(n):\n s = 'aRbFR'.join(t.replace('b', 'LFaLb') for t in s.split('a'))\n return s.replace('a', '').replace('b', '')\n", "import re\ndef Dragon(n):\n if not isinstance(n, int) or n < 0: return ''\n sub_table = { 'a' : 'aRbFR', 'b' : 'LFaLb' }\n s = 'Fa'\n for i in range(0, n):\n s = re.sub(r'[ab]', lambda m: sub_table[m.group()], s)\n return s.translate(None, 'ab')\n", "def Dragon(n):\n #your code here\n if(type(n) != type(1)):\n return ''\n if(n<0):\n return ''\n if n == 0:\n return 'F'\n ret = 'Fa'\n while(n>0):\n temp = ''\n for word in ret:\n if(word == 'a'):\n temp += 'aRbFR'\n elif(word == 'b'):\n temp += 'LFaLb'\n else:\n temp += word\n ret = temp\n n-=1\n ret = ret.replace('a','')\n ret = ret.replace('b','')\n return ret\n \n \n \n", "def Dragon(n, strng='Fa'):\n if not isinstance(n, int) or n < 0: return ''\n if not n: return strng.translate(None, \"ab\")\n next = ''.join(\"aRbFR\" if c == 'a' else \"LFaLb\" if c == 'b' else c for i,c in enumerate(strng))\n return Dragon(n-1, next)", "def Dragon(n):\n if not isinstance(n, int) or n < 0:\n return ''\n s = 'Fa'\n for _ in range(n):\n s = ''.join({'a': 'aRbFR', 'b': 'LFaLb'}.get(c, c) for c in s)\n return s.replace('a', '').replace('b', '')", "def Dragon(n):\n if type(n) != int or n < 0:\n return \"\"\n stg, a, b = \"F{a}\", \"{a}R{b}FR\", \"LF{a}L{b}\"\n for _ in range(n):\n stg = stg.format(a=a, b=b)\n return stg.replace(\"{a}\", \"\").replace(\"{b}\", \"\")", "def Dragon(n):\n if not isinstance(n, int) or n < 0:\n return \"\"\n d = \"Fa\"\n for i in range(n):\n d = \"\".join(\"aRbFR\" if c == \"a\" else \"LFaLb\" if c == \"b\" else c for c in d)\n return d.translate(dict.fromkeys(map(ord, \"ab\")))", "def Dragon(n, Curve='Fa'):\n if type(n)!=int or n%1!=0 or n<0: return '' \n \n elif n==0: \n return Curve.replace('a','').replace('b','')\n else: \n #now need to add an extra step where we swap out a dn b because otherwise the replace will affect the outcome. ie the replaces are not concurrent\n return Dragon(n-1, Curve.replace('a','c').replace('b','d').replace('c','aRbFR').replace('d', 'LFaLb') )"] | {"fn_name": "Dragon", "inputs": [["a"], [1.1], [-1]], "outputs": [[""], [""], [""]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,783 |
def Dragon(n):
|
cce322827a0561ad345b57fbd0c999e5 | UNKNOWN | # Task
For the given set `S` its powerset is the set of all possible subsets of `S`.
Given an array of integers nums, your task is to return the powerset of its elements.
Implement an algorithm that does it in a depth-first search fashion. That is, for every integer in the set, we can either choose to take or not take it. At first, we choose `NOT` to take it, then we choose to take it(see more details in exampele).
# Example
For `nums = [1, 2]`, the output should be `[[], [2], [1], [1, 2]].`
Here's how the answer is obtained:
```
don't take element 1
----don't take element 2
--------add []
----take element 2
--------add [2]
take element 1
----don't take element 2
--------add [1]
----take element 2
--------add [1, 2]```
For `nums = [1, 2, 3]`, the output should be
`[[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]]`.
# Input/Output
`[input]` integer array `nums`
Array of positive integers, `1 ≤ nums.length ≤ 10`.
[output] 2D integer array
The powerset of nums. | ["from itertools import compress,product\n\ndef powerset(a):\n return [list(compress(a,p)) for p in product((0,1),repeat=len(a))]\n", "def powerset(nums):\n if not nums:\n return [[]]\n l = powerset(nums[1:])\n a = nums[0]\n return l + [[a] + q for q in l]", "def powerset(nums):\n t = []\n for i in range(2**len(nums)): \n t.append([nums[k] for k,z in enumerate(bin(i)[2:].zfill(len(nums))) if z ==\"1\"])\n return t", "def powerset(s):\n if not s:\n return [[]]\n result = powerset(s[1:])\n return result + [[s[0]] + subset for subset in result]", "powerset=lambda a:[[n for i,n in enumerate(a)if b>>len(a)-i-1&1]for b in range(1<<len(a))]", "powerset=lambda n: (lambda c: c+[[n[0]]+e for e in c])(powerset(n[1:])) if n else [[]]", "def powerset(nums):\n n = len(nums)\n return [[nums[i] for i, item in enumerate(bin(mask)[2:].rjust(n, \"0\")) if item == \"1\"] for mask in range(2**n)]\n", "def powerset(nums):\n if len(nums)==1:\n return [[],nums]\n s=powerset(nums[1:])\n for a in s[:]:\n s.append([nums[0]]+a)\n return s", "def powerset(nums):\n l = len(nums)\n return [[x for j,x in enumerate(nums) if i&(1<<(l-j-1))] for i in range(2**l)]", "def powerset(nums):\n if len(nums) == 0:\n return [[]]\n sub = powerset(nums[1:])\n first = nums[:1]\n buffer = []\n for ele in sub:\n buffer.append(first + ele)\n return sub + buffer"] | {"fn_name": "powerset", "inputs": [[[1, 2]], [[1, 2, 3]], [[1]], [[125, 15, 155, 15, 158]], [[1, 2, 3, 4]]], "outputs": [[[[], [2], [1], [1, 2]]], [[[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]]], [[[], [1]]], [[[], [158], [15], [15, 158], [155], [155, 158], [155, 15], [155, 15, 158], [15], [15, 158], [15, 15], [15, 15, 158], [15, 155], [15, 155, 158], [15, 155, 15], [15, 155, 15, 158], [125], [125, 158], [125, 15], [125, 15, 158], [125, 155], [125, 155, 158], [125, 155, 15], [125, 155, 15, 158], [125, 15], [125, 15, 158], [125, 15, 15], [125, 15, 15, 158], [125, 15, 155], [125, 15, 155, 158], [125, 15, 155, 15], [125, 15, 155, 15, 158]]], [[[], [4], [3], [3, 4], [2], [2, 4], [2, 3], [2, 3, 4], [1], [1, 4], [1, 3], [1, 3, 4], [1, 2], [1, 2, 4], [1, 2, 3], [1, 2, 3, 4]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,463 |
def powerset(nums):
|
faf97ecb5cfb369b04c3e6724c224844 | UNKNOWN | Complete the function that takes one argument, a list of words, and returns the length of the longest word in the list.
For example:
```python
['simple', 'is', 'better', 'than', 'complex'] ==> 7
```
Do not modify the input list. | ["def longest(words):\n return max(map(len, words))", "def longest(words):\n return max(len(i) for i in words)", "def longest(words):\n return len(max(words, key=len))", "def longest(words):\n number_of_chars = [len(word) for word in words]\n return max(number_of_chars)", "longest = lambda w: len(max(w, key = len))", "def longest(words):\n # Your code here\n number = [len(i) for i in words]\n number.sort()\n length = number.pop()\n return length", "def longest(words):\n longest=words[0]\n for i in range(len(words)):\n if len(words[i])>len(longest):\n longest = words[i]\n return len(longest)", "def longest(words):\n biggest = 0\n for word in words:\n if len(word) > biggest:\n biggest = len(word)\n return biggest ", "def longest(words):\n sorted_list = sorted(words, key=len, reverse=True)\n return len(sorted_list[0])", "def longest(words):\n lon = len(words[0])\n for i in words:\n if len(i)>lon:\n lon = len(i)\n return lon"] | {"fn_name": "longest", "inputs": [[["simple", "is", "better", "than", "complex"]], [["explicit", "is", "better", "than", "implicit"]], [["beautiful", "is", "better", "than", "ugly"]]], "outputs": [[7], [8], [9]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,069 |
def longest(words):
|
5d4f20864d597ff85d3e553def2fcb44 | UNKNOWN | Fibonacci numbers are generated by setting F0 = 0, F1 = 1, and then using the formula:
# Fn = Fn-1 + Fn-2
Your task is to efficiently calculate the **n**th element in the Fibonacci sequence and then count the occurrence of each digit in the number. Return a list of integer pairs sorted in **descending** order.
10 ≤ n ≤ 100000
## Examples
```
f(10) = 55 # returns [(2, 5)], as there are two occurances of digit 5
f(10000) # returns:
[(254, 3),
(228, 2),
(217, 6),
(217, 0),
(202, 5),
(199, 1),
(198, 7),
(197, 8),
(194, 4),
(184, 9)]
```
If two integers have the same count, sort them in descending order.
Your algorithm must be efficient.
~~~if:javascript
Solving this Kata in Javascript requires the use of the bignumber.js library. I have included starter code to assist you with using the library. Thanks to `kazk` for assisting with the translation.
~~~ | ["from collections import Counter\n\ndef fib_digits(n):\n a, b = 0, 1\n for i in range(n): a, b = b, a+b\n return sorted(((b, int(a)) for a, b in Counter(str(a)).items()), reverse=True)", "from operator import itemgetter\ndef fib_digits(n):\n a,b = 1,1\n num=n\n num_int=int(num-2)\n for i in range (num_int):\n a,b=b,a+b\n print(b)\n num = b\n print(num)\n lst = list(map(int,str(num)))\n lst2 = []\n p = False\n i = 1\n lst2.append([1,lst[0]])\n while i < len(lst):\n d = 0\n while d < len(lst2):\n if lst[i] == lst2[d][1]:\n #lst2[d][0] += 1\n p = True\n break\n d+=1\n if p == True:\n lst2[d][0] += 1\n else:\n lst2.append([1,lst[i]]) \n i+=1\n p = False\n print(lst2)\n i = 0\n while i < len(lst2):\n lst2[i] = tuple(lst2[i])\n i+=1\n return(sorted((lst2), reverse=True))\n \n \n \n", "from collections import Counter\n\ndef fib_digits(n):\n a = 0\n b = 1\n \n for i in range(2, n + 1):\n a, b = b, a + b\n \n c = Counter(str(b))\n res = sorted([(int(x[0]), int(x[1])) for x in zip(list(c.values()), list(c.keys()))], key = lambda m: (m[0], m[1]))[::-1]\n return res\n", "from collections import Counter\n\n\ndef fib_digits(n):\n a,b = 0,1\n for i in range(n-1):\n a,b = b, a+b\n counts = Counter(str(b))\n return sorted(((count, int(digit)) for digit, count in counts.items()), reverse=True)", "def fib_digits(n):\n d = str(fib(n))\n return sorted([(d.count(i), int(i)) for i in '0123456789' if d.count(i) > 0])[::-1]\n\n\ndef fib(n):\n a,b = 1,1\n for i in range(n-1):\n a,b = b,a+b\n return a\n\n", "from collections import Counter\n\n# https://stackoverflow.com/a/23462371\ndef fib(n):\n v1, v2, v3 = 1, 1, 0\n for rec in bin(n)[3:]:\n calc = v2*v2\n v1, v2, v3 = v1*v1+calc, (v1+v3)*v2, calc+v3*v3\n if rec=='1': v1, v2, v3 = v1+v2, v1, v2\n return v2\n\ndef fib_digits(n):\n return sorted(((v, int(k)) for k,v in Counter(str(fib(n))).items()), reverse=True)", "def fib(n1):\n fn_1=1\n fn_2=0\n f=0\n for i in range(1,n1):\n f=fn_1+fn_2\n fn_2=fn_1\n fn_1=f\n return f\n \ndef fib_digits(n):\n check=0\n num=''\n l=[]\n count=0\n x=str(fib(int(n)))\n while len(x)>1:\n for j in range(len(x)):\n if x[0]==x[j]:\n count+=1\n num+=x[0]\n l.append((count,int(x[0])))\n count=0\n x=x.replace(x[0],\"\")\n l.sort()\n return(l[::-1])", "def fast_fib(n):\n def pos(n):\n if n == 0:\n return (0, 1)\n else:\n a, b = pos(n // 2)\n c = a * (b * 2 - a)\n d = a * a + b * b\n if n % 2 == 0:\n return (c, d)\n else:\n return (d, c + d)\n \n def fib(n):\n if n >= 0:\n return pos(n)[0]\n \n if n < 0:\n sign = -1 if n % 2 == 0 else 1\n return sign*pos(abs(n))[0]\n \n return fib(n)\n\ndef fib_digits(n):\n from collections import Counter\n cnt = Counter(str(fast_fib(n)))\n ret = [(v, int(k)) for k, v in cnt.items()]\n ret = sorted(ret, key=lambda x: (-x[0], -x[1]))\n \n return ret", "def fib_digits(n):\n numCount = [[0,0], [0,1], [0,2], [0,3], [0,4], [0,5], [0,6], [0,7], [0,8], [0,9]] # 2d array of the amounts of each number\n a,b = 1,1\n for i in range(n-1): # calculate the fibonacci number of the entered digit\n a,b = b,a+b\n fib_list = list(str(a)) # create a list of the numbers (in string form), one number per item\n i = 0\n while i < len(fib_list):\n numCount[int(fib_list[i])][0] += 1 # if number is x, the number of x's is incremented\n i+=1\n i = 0\n while i < len(numCount):\n numCount[i] = tuple(numCount[i]) # convert each list item to tuple\n if numCount[i][0] == 0:\n numCount.pop(i) # if there aren't any of a specific number, remove it\n else:\n i+=1\n return sorted(numCount, key=lambda x: (x[0], x[1]), reverse=True) # return the sorted list", "from collections import Counter\ndef fib_digits(n):\n first = 0\n second = 1\n for i in range(n-1):\n update = first+second\n first = second\n second = update\n return list(reversed(sorted([(v,k) for k,v in Counter([int(y) for y in str(update)]).items()])))"] | {"fn_name": "fib_digits", "inputs": [[10]], "outputs": [[[[2, 5]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,631 |
def fib_digits(n):
|
f0a55f354662e544f0e8d1021444b883 | UNKNOWN | Your classmates asked you to copy some paperwork for them. You know that there are 'n' classmates and the paperwork has 'm' pages.
Your task is to calculate how many blank pages do you need.
### Example:
```python
paperwork(5, 5) == 25
```
**Note:** if `n < 0` or `m < 0` return `0`!
Waiting for translations and Feedback! Thanks! | ["def paperwork(n, m):\n return n * m if n > 0 and m > 0 else 0", "def paperwork(n, m):\n if m<0 or n<0:\n return 0\n else:\n return n*m", "def paperwork(n, m):\n return max(n, 0)*max(m, 0)", "def paperwork(n, m):\n return n*m if n>=0 and m>=0 else 0", "def paperwork(n, m):\n return 0 if n < 0 or m < 0 else n*m", "def paperwork(n, m):\n if m > 0 and n > 0:\n return m*n\n else:\n return 0", "paperwork = lambda a,b: a*b if min(a,b)>0 else 0", "def paperwork(n, m):\n return n * m if min((n, m)) > 0 else 0", "paperwork = lambda m,n: m*n if m>0 and n>0 else 0", "def paperwork(n, m):\n return m*n * int(n > 0 and m > 0)", "def paperwork(n, m):\n return n*m if n > 0 < m else 0", "def paperwork(n,m): return m*n if (m>0) & (n>0) else 0", "def paperwork(n, m):\n #Declaring the variable with a value makes it local instead of global\n ans = 0\n \n #Checks that n and m are > 0 before doing the math\n if n and m > 0:\n ans = n * m\n \n #Throws out any answers that are negative\n if ans <= 0:\n ans = 0\n \n #Returns the ans variable \n return ans", "def paperwork(n, m):\n if n >= 0 and m >= 0:\n return n * m\n elif n < 0 or m < 0:\n return 0", "def paperwork(n, m):\n # Happy Coding! ^_^\n if n > 0 and m > 0:\n return n * m\n else:\n return 0", "def paperwork(n, m):\n return 0 if min(n,m) < 0 else n*m", "def paperwork(n, m):\n return n*m*(n>0)*(m>0)", "def paperwork(n, m):\n return [0, n * m][n > 0 and m > 0]", "def paperwork(n, m):\n return n * m * (n > 0 < m)", "def paperwork(n, m):\n return all([n>0,m>0]) and n*m", "def paperwork(n, m):\n # Happy Coding! ^_^\n if (n < 0) or (m < 0 ):\n return 0\n else : return n *m", "from operator import mul\nfrom functools import reduce\n\ndef paperwork(*args):\n return reduce(mul, args) if min(args) > 0 else 0", "def paperwork(n, m):\n return n*m if n == abs(n) and m == abs(m) else 0", "paperwork = lambda o_,_o: max(0, _o) * max(o_, 0)", "paperwork = lambda n, m: max(max(n, 0)*m, 0)", "paperwork = lambda n, m: 0 if(n < 0 or m < 0) else n*m #Another Stupid Comment By Mr. Stupido", "paperwork = lambda n, m: n * m if n >= 0 and m >= 0 else 0\n", "paperwork = lambda n, m: n * m if all(x > 0 for x in (n, m)) else 0", "def paperwork(n, m):\n return sum(True for _ in range(n) for _ in range(m))", "def paperwork(n: int, m: int) -> int:\n return max(0, n) * max(0, m)", "paperwork=lambda n, m: __import__('functools').reduce(__import__('operator').mul, [max(q, 0) for q in [n, m]])", "def paperwork(n, m):\n return n*m*(min(m,n)>=0)", "def paperwork(n, m):\n return (0, m * n)[n > 0 and m > 0]", "def paperwork(n, m):\n if m > 0:\n if n > 0:\n return m*n\n else:\n return 0\n else:\n return 0", "def paperwork(n, m):\n if n | m > 0:\n p = n * m\n return p\n else:\n return 0", "def paperwork(n, m):\n return n * m * (n>=0) * (m>=0)", "paperwork = lambda n, m: n * m if n > 0 and m > 0 else 0", "def paperwork(n: int, m: int):\n return n * m if n > 0 and m > 0 else 0", "def paperwork(n, m):\n if n>0 and m>0:\n b = n * m\n else:\n b=0\n return b\n \n # Happy Coding! ^_^\n", "def paperwork(n, m):\n \n if n*m<=0:\n return 0\n elif m<=0:\n return 0\n elif n<=0:\n return 0\n elif n*m > 0:\n BP = n*m\n return BP\n # Happy Coding! ^_^\n", "def paperwork(n, m):\n z = n*m\n if n <= 0:\n return 0\n elif m <= 0:\n return 0\n else:\n return z\n # Happy Coding! ^_^\n", "def paperwork(n, m):\n result =0\n \n if n<0:\n result==0\n elif m<0:\n result ==0\n else:\n result=n*m\n \n return result", "def paperwork(n=0, m=0):\n return 0 if n <= 0 or m <= 0 else n * m\n \n # Happy Coding! ^_^\n", "def paperwork(n, m):\n if n < 0 or m < 0:\n return 0\n else:\n pages = (n * m)\n if pages < 0:\n return 0\n else:\n return pages", "def paperwork(n, m):\n if n <= 0 or m <= 0:\n cevap = 0\n else:\n cevap = n*m\n return cevap", "def paperwork(n, m):\n print(n,m)\n if n > 0 and m > 0:\n return n * m\n else:\n return 0", "def paperwork(n, m):\n result = n * m\n if n > 0 and m > 0:\n result = n * m\n elif n < 0 or m < 0:\n result = 0\n return result", "def paperwork(n, m):\n if (n < 0):\n return 0\n elif(m < 0):\n return 0\n elif(n or m > 0):\n return n*m\n\n", "def paperwork(n, m):\n if n >0 and m > 0:\n return n*m\n elif n<0 or m<0 or n == 0 or m ==0:\n return 0\n # Happy Coding! ^_^\n", "def paperwork(n,\n m):\n\n if (n < 0 or\n m < 0):\n\n return 0\n \n return n * m\n", "def paperwork(n = 0, m= 0):\n if n < 0 or m < 0:\n return 0\n return m * n\n", "def paperwork(n, m):\n if n > 0 and m > 0:\n pages = n * m\n return pages\n else:\n return 0", "def paperwork(n, m):\n if (n <= 0) or (m <= 0):\n return 0\n elif (n > 0) and (m > 0):\n pages = n * m\n return pages", "def paperwork(n, m):\n if n<0 or m<0:\n res = 0\n else:\n res = n*m\n return res", "def paperwork(n, m):\n if n < 0 and m < 0 or n < 0 or m < 0:\n return 0\n \n else:\n return n*m \n", "def paperwork(n, m):\n # Happy Coding! ^_^\n # uwu\n if n > 0 and m > 0:\n return(n * m)\n else:\n return 0", "def paperwork(n, m):\n if n < 0 or 0 > m:\n R = 0\n else:\n R = n * m\n return R", "def paperwork(n, m):\n if n < 0 or m < 0:\n return 0\n c = n * m\n return c", "def paperwork(n, m):\n if n < 0 or m < 0:\n return 0\n else:\n r = n * m\n return r \n", "paperwork=lambda x, y: max(0, x) * max(0, y)\n", "def paperwork(n, m):\n # Happy Coding! ^_^\n blankPages = 0\n if n > 0 and m > 0:\n blankPages = n * m\n return blankPages\n \n", "def paperwork(n, m):\n if n<0 or m<0:\n totpag=0\n else:\n totpag=n*m\n \n return totpag", "def paperwork(n, m):\n if (n * m) <= 0:\n return 0\n if n <= 0:\n return 0 \n if m <= 0: \n return 0\n else: \n return (n * m)", "def paperwork(n, m):\n \n while n > 0 and m > 0:\n \n return n * m\n \n else:\n \n return 0", "def paperwork(n, m):\n \n if n < 0 or m < 0: return 0\n \n papers = n * m\n \n return papers", "def paperwork(n, m):\n r = n * m\n return r if n > 0 and m > 0 else 0", "def paperwork(n, m):\n total = n * m\n if n < 0 or m <0:\n return 0\n else:\n return total ", "def paperwork(n, m):\n if n <= 0:\n return 0\n if m <= 0:\n return 0\n else:\n paper = n * m\n return paper", "def paperwork(n, m):\n \n paperwork1 = n * m\n nothing = 0\n if n >= 0 and m >= 0:\n return paperwork1\n if n < 0 or m < 0:\n return nothing\n \n \n", "paperwork=lambda n,m:0 if n+m!=abs(n)+abs(m) else n*m", "def paperwork(n=5, m=5):\n if n + 0 < 0:\n return 0\n if m + 0 <0:\n return 0\n x = n*m\n if x < 0:\n return 0\n return x", "def paperwork(n, m):\n n = n * m\n if n <= 0 or m < 0:\n return 0\n else:\n return n", "def paperwork(n, m):\n c = 0\n g = 0\n c = n*m\n if n < 0 or m < 0:\n return g\n\n else:\n return c", "def paperwork(n, m):\n if n<=0 or m<=0:\n return 0\n if n*m > 0:\n return n*m\n", "def paperwork(n, m):\n if n <= 0:\n return 0\n if m <= 0:\n return 0\n else:\n result = n * m\n return result\n \n \n", "#this function tells you how much paper you need based on the how many people their are and how many pages their are.\ndef paperwork(people, pages):\n blank=people*pages\n if people<0:\n blank=0\n if pages<0:\n blank=0\n return blank", "def paperwork(n, m):\n return n * m if all([n >= 0 , m >= 0]) else 0", "def paperwork(n: int, m: int):\n return 0 if n < 0 or m < 0 else n * m", "def paperwork(n, m):\n if n<0 or m<0:\n return(0)\n else:\n pages = m*n\n return pages", "def paperwork(n, m):\n if n<0 or m<0:\n return 0\n d=n*m\n return d\n \n \n \n \n \n \n \n \n \n \n \n", "import operator\n\ndef paperwork(n, m):\n if (n<0 or m<0):\n return 0\n return operator.mul(n, m)", "def paperwork(n, m):\n r = n * m\n \n if n < 0 or m < 0:\n return 0\n else:\n return r\n # Happy Coding! ^_^\n", "def paperwork(n, m):\n if n>=0 and m>0:\n return n*m\n else:\n return 0\n", "def paperwork(n: int, m: int) -> int:\n return 0 if n < 0 or m < 0 else n * m", "def paperwork(n, m):\n # Happy Coding! ^_^\n if m>0 and n>0:\n papers=n*m\n else:\n papers=0\n return papers", "def paperwork(n, m):\n work = n*m\n if n <0 or m <0:\n return 0 \n else:\n return work ", "def paperwork(n, m):\n if n < 0 or m < 0:\n return 0;\n page_amount = n * m\n return page_amount", "def paperwork(n, m):\n result = 0\n if ((m > 0) & (n > 0)):\n result = n * m\n return result", "def paperwork(n, m):\n c = n*m\n if n<0: #checking the first arg being more than zero\n return 0\n elif m<0: #checking second arg being more than zero\n return 0\n else: #returning papers\n return c\n # Happy Coding! ^_^\n", "def paperwork(n, m):\n if n < 0 or m < 0:\n return 0\n else:\n return n * m\n # Happy Coding! ^_^ :D (\u273f\u25e0\u203f\u25e0)\n", "def paperwork(n, m):\n if m<0:\n return 0\n if n<0:\n return 0\n if m==0:\n return 0\n if n==0:\n return 0\n if n>0 and m>0:\n return n*m", "def paperwork(n, m):\n x = n*m\n if n < 0:\n return(0)\n elif m <0:\n return(0)\n else:\n return (x)", "def paperwork(n, m):\n bp = n * m\n if n < 0 or m < 0:\n return 0\n else:\n return bp", "def paperwork(n, m):\n if m<0 or n<0 :\n n = 0\n return n*m", "def paperwork(n, m):\n if n > 0 and m > 0:\n blank_pages = n * m\n else:\n blank_pages = 0\n return blank_pages", "def paperwork(n, m):\n if n < 0 and m < 0:\n return 0\n return max(n * m, 0) ", "def paperwork(n, m):\n paperwork = n * m\n if n < 0 or m < 0:\n return 0\n else:\n return paperwork", "def paperwork(n, m):\n # Happy Coding! ^_^\n # ty uwu\n if n < 0 or m < 0:\n return 0\n else:\n return n * m", "def paperwork(n, m):\n if n<= 0:\n return 0\n elif m<=0:\n return 0\n else:\n return n * m\n \npaperwork(5, 3)\n # Happy Coding! ^_^\n", "def paperwork(n, m):\n return n*m*(m>0 and n>0)"] | {"fn_name": "paperwork", "inputs": [[5, 5], [5, -5], [-5, -5], [-5, 5], [5, 0]], "outputs": [[25], [0], [0], [0], [0]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 11,314 |
def paperwork(n, m):
|
edde63971ddb886df2d16451c2bb4374 | UNKNOWN | You may be familiar with the concept of combinations: for example, if you take 5 cards from a 52 cards deck as you would playing poker, you can have a certain number (2,598,960, would you say?) of different combinations.
In mathematics the number of *k* combinations you can have taking from a set of *n* elements is called the [binomial coefficient](https://en.wikipedia.org/wiki/Binomial_coefficient) of n and k, more popularly called **n choose k**.
The formula to compute it is relatively simple: `n choose k`==`n!/(k!*(n-k)!)`, where `!` of course denotes the factorial operator.
You are now to create a choose function that computes the binomial coefficient, like this:
```
choose(1,1)==1
choose(5,4)==5
choose(10,5)==252
choose(10,20)==0
choose(52,5)==2598960
```
Be warned: a certain degree of optimization is expected, both to deal with larger numbers precision (and their rounding errors in languages like JS) and computing time. | ["from math import factorial\n\ndef choose(n, k):\n return factorial(n) / ( factorial(k) * factorial(n-k) ) if k <=n else 0", "import sys\nimport functools\nsys.setrecursionlimit(1_000_000)\n\n# lru_cache is a python shortcut for memoization\n# memoization is a technique to avoid repeatedly calculating\n# something that has already been calculated\n\[email protected]_cache(maxsize=1_000_000)\ndef choose(n,k):\n # pascals triangle uses only addition\n # so no rounding\n # 1\n # 1 1\n # 1 2 1\n # 1 3 3 1\n # 1 4 6 4 1\n # with exception of edge cases\n # this has recursive formula\n # choose(n, k) = choose(n-1, k-1) + choose(n-1, k)\n if k > n:\n return 0\n if k == 0 or k == n:\n return 1\n return choose(n-1, k-1) + choose(n-1, k)", "def choose(n,k):\n l = [max(k,n-k),min(k,n-k)]\n nu = 0 if k > n else 1\n de = 1\n for i in range(l[0]+1,n+1):\n nu *= i\n for i in range(1,l[1]+1):\n de *= i\n return int(nu/de)", "from functools import reduce\nfrom math import factorial\n\n\ndef choose(n, k):\n return reduce(int.__mul__, range(n - k + 1, n + 1), 1) // factorial(k)", "def choose(n, k):\n if k == 0:\n return 1\n else: \n return (n * choose(n - 1, k - 1)) // k", "def choose(n, k):\n return prod(n-k, n)//prod(1, k)\n\ndef prod(f, t):\n if f == t:\n return 1\n return t * prod(f, t-1)", "from math import factorial as f\nchoose=lambda n,k:f(n)/(f(k)*f(n-k)) if k <= n else 0", "def choose(n,k):\n def factorial(num):\n #a nested function for computing the factorial of the \n # n, k arguments of the choose function\n ra = reversed(list(range(1,num)))\n for r in ra:\n num = num * r\n return num\n\n # a little of exception handling and conditional reasoning\n # to make deal with edge cases involving negative values \n # and ZeroDivisionError\n try:\n choose = factorial(n)/(factorial(k)*factorial((n-k)))\n except ZeroDivisionError:\n choose = n/k\n if choose < 0:\n return 0\n else:\n return choose\n"] | {"fn_name": "choose", "inputs": [[1, 1], [5, 4], [10, 5], [10, 20], [52, 5], [100, 10], [500, 4], [1000, 3], [200, 8], [300, 6]], "outputs": [[1], [5], [252], [0], [2598960], [17310309456440], [2573031125], [166167000], [55098996177225], [962822846700]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,192 |
def choose(n,k):
|
faaba2a21d166c3c4e9dbfb2db5b4eb6 | UNKNOWN | Imagine that you have an array of 3 integers each representing a different person. Each number can be 0, 1, or 2 which represents the number of hands that person holds up.
Now imagine there is a sequence which follows these rules:
* None of the people have their arms raised at first
* Firstly, a person raises 1 hand; then they raise the second hand; after that they put both hands down - these steps form a cycle
* Person #1 performs these steps all the time, person #2 advances only after person #1 puts their hands down, and person #3 advances only after person #2 puts their hands down
The first 10 steps of the sequence represented as a table are:
```
Step P1 P2 P3
--------------------
0 0 0 0
1 1 0 0
2 2 0 0
3 0 1 0
4 1 1 0
5 2 1 0
6 0 2 0
7 1 2 0
8 2 2 0
9 0 0 1
```
Given a number, return an array with the number of hands raised by each person at that step. | ["def get_positions(n):\n return tuple(n // d % 3 for d in (1, 3, 9))", "def get_positions(n):\n return n%3, n//3%3, n//9%3", "def get_positions(n): #Jai Shree Ram!!!\n num2=n\n num3=n\n p2=[0,0,0,1,1,1,2,2,2]\n p3=[0,0,0,0,0,0,0,0,0,\n 1,1,1,1,1,1,1,1,1,\n 2,2,2,2,2,2,2,2,2]\n \n while num2>=9:\n num2=num2%9\n n2=p2[num2]\n \n while num3>=27:\n num3=num3%27\n n3=p3[num3]\n \n return (n%3,n2,n3)", "def create_postions():\n p1 = [0, 1, 2] * 9\n p2 = [*[0] * 3, *[1] * 3, *[2] * 3] * 3\n p3 = [0] * 9 + [1] * 9 + [2] * 9\n arr = list(zip(p1, p2, p3))\n \n return lambda n: arr[n % 27]\n\nget_positions = create_postions()", "def get_positions(n):\n n, x = divmod(n, 3)\n n, y = divmod(n, 3)\n n, z = divmod(n, 3)\n return x, y, z", "import math\ndef get_positions(n):\n return (n%3,math.floor((n/3)%3), math.floor((n/9)%3))", "def get_positions(n):\n n%=27\n return n%3, (n//3)%3, n//9", "def get_positions(n):\n num = n % 27\n return (num % 3,int(num % 3**2 / 3**1),int(num / 3**2))", "def get_positions(s):\n return (s % 3, s // 3 % 3, s // 9 % 3)", "def ternary(n):\n if n == 0:\n return '0'\n nums = []\n while n:\n n, r = divmod(n, 3)\n nums.append(str(r))\n return ''.join(reversed(nums))\n\ndef get_positions(n):\n return tuple(int(d) for d in ternary(n)[-3:].zfill(3)[::-1])"] | {"fn_name": "get_positions", "inputs": [[54], [98], [3]], "outputs": [[[0, 0, 0]], [[2, 2, 1]], [[0, 1, 0]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,440 |
def get_positions(n):
|
d33a3205c691fec04e62b7cb94e04d46 | UNKNOWN | Thanks to the effects of El Nino this year my holiday snorkelling trip was akin to being in a washing machine... Not fun at all.
Given a string made up of '~' and '\_' representing waves and calm respectively, your job is to check whether a person would become seasick.
Remember, only the process of change from wave to calm (and vice versa) will add to the effect (really wave peak to trough but this will do). Find out how many changes in level the string has and if that figure is more than 20% of the string, return "Throw Up", if less, return "No Problem". | ["def sea_sick(sea):\n return \"Throw Up\" if (sea.count(\"~_\") + sea.count(\"_~\"))/len(sea) > 0.2 else \"No Problem\"", "def sea_sick(sea):\n changes = sum(1 for a,b in zip(sea,sea[1:]) if a!=b)\n return \"No Problem\" if changes*5 <= len(sea) else \"Throw Up\"", "def sea_sick(sea):\n waves = sum(sea[i: i + 2] in \"_~_\" for i in range(len(sea) -1))\n if waves / float(len(sea)) > 0.2:\n return \"Throw Up\"\n return \"No Problem\"\n", "from operator import truediv\n\n\ndef sea_sick(s):\n result = sum(s[a:a + 2] in '_~_' for a in range(len(s) - 1))\n if truediv(result, len(s)) > 0.2:\n return 'Throw Up'\n return 'No Problem'\n", "def sea_sick(sea):\n return \"Throw Up\" if (sea.count(\"~_\") + sea.count(\"_~\")) > 0.2*len(sea) else \"No Problem\"", "sea_sick=lambda s:[\"No Problem\",\"Throw Up\"][s.count('~_')+s.count('_~')>.2*len(s)]", "def sea_sick(sea):\n return 'Throw Up' if sum(x != y for x, y in zip(sea, sea[1:])) / len(sea) > 0.2 else 'No Problem'", "sea_sick = lambda s: ['No Problem','Throw Up'][sum(__import__(\"itertools\").starmap(str.__ne__, zip(s, s[1:]))) / len(s) > 0.2]", "sea_sick=lambda s: [\"No Problem\",\"Throw Up\"][(s.count(\"~_\")+s.count(\"_~\"))/float(len(s))>0.2]", "def sea_sick(sea):\n c,p = 0,sea[0]\n for s in sea[1:]:\n if s != p:\n c += 1\n p = s\n return 'Throw Up' if c/len(sea) > 0.2 else 'No Problem'"] | {"fn_name": "sea_sick", "inputs": [["~"], ["_~~~~~~~_~__~______~~__~~_~~"], ["______~___~_"], ["____"], ["_~~_~____~~~~~~~__~_~"]], "outputs": [["No Problem"], ["Throw Up"], ["Throw Up"], ["No Problem"], ["Throw Up"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,434 |
def sea_sick(sea):
|
5782f6e9ac562f8032ab4e6f2285a8cd | UNKNOWN | Given an array of ones and zeroes, convert the equivalent binary value to an integer.
Eg: `[0, 0, 0, 1]` is treated as `0001` which is the binary representation of `1`.
Examples:
```
Testing: [0, 0, 0, 1] ==> 1
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 0, 1] ==> 5
Testing: [1, 0, 0, 1] ==> 9
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 1, 0] ==> 6
Testing: [1, 1, 1, 1] ==> 15
Testing: [1, 0, 1, 1] ==> 11
```
However, the arrays can have varying lengths, not just limited to `4`. | ["def binary_array_to_number(arr):\n return int(\"\".join(map(str, arr)), 2)", "def binary_array_to_number(arr):\n return int(''.join(str(a) for a in arr), 2)", "def binary_array_to_number(arr):\n s = 0\n for digit in arr:\n s = s * 2 + digit\n\n return s", "def binary_array_to_number(arr):\n return sum(digit * 2**i for i, digit in enumerate(reversed(arr)))", "def binary_array_to_number(arr):\n return sum( 2**i for i, n in enumerate( arr[ ::-1 ] ) if n )", "from functools import reduce\ndef binary_array_to_number(arr):\n append_bit = lambda n, b: n << 1 | b\n return reduce(append_bit, arr)\n", "def binary_array_to_number(arr):\n no_of_elements = len(arr)\n k = no_of_elements \n sum = 0\n while k != 0:\n sum = sum + arr[no_of_elements-k]*(2**(k-1))\n k = k - 1\n return sum", "def binary_array_to_number(arr):\n if type(arr) is list and len(arr)>0:\n return int(''.join(str(e) for e in arr), 2)\n return -1", "def binary_array_to_number(arr):\n return int(bytearray(\"\".join(str(a) for a in arr), encoding=\"utf-8\"), base=2)", "binary_array_to_number=lambda arr: int(\"\".join(map(str,arr)),2)", "from functools import reduce\n\ndef binary_array_to_number(a):\n return reduce(lambda t,b:t*2+b,a)", "def binary_array_to_number(arr):\n \n return sum(item*(2**index) for index,item in enumerate(reversed(arr)))\n", "def binary_array_to_number(arr):\n # your code\n binary = \"\".join([str(n) for n in arr])\n return int(binary, 2)", "def binary_array_to_number(arr):\n # your code\n res = 0\n arr.reverse()\n for index in range(len(arr)):\n res += arr[index]*pow(2,index)\n return res", "def binary_array_to_number(arr):\n # your code\n res = 0\n li = [x for x in reversed(arr)]\n print(li)\n for i in range(len(li)):\n if li[i] == 1:\n res = res + 2**i\n return res", "import re\ndef binary_array_to_number(arr):\n binaryString = ''.join(re.findall(r'\\d',str(arr)))\n return int(binaryString, 2)", "def binary_array_to_number(arr):\n strng = ' '\n for nr in arr:\n strng = strng + str(nr)\n return (int(strng,2))\n", "def binary_array_to_number(arr, acc = 0):\n if len(arr) == 0:\n return acc\n acc = (acc << 1) | arr.pop(0)\n return binary_array_to_number(arr, acc)", "def binary_array_to_number(arr):\n return sum(value*(2**index) for index, value in enumerate(arr[::-1]))", "def binary_array_to_number(arr):\n return int(''.join(str(i) for i in arr),2)", "def binary_array_to_number(arr):\n sum = 0\n for i in range(0, len(arr)):\n sum += arr[i] * 2**(len(arr)-1-i)\n return sum", "def binary_array_to_number(arr):\n return int(''.join(str(x) for x in arr),2)", "binary_array_to_number = lambda a : int(''.join(map(str,a)),2)", "def binary_array_to_number(arr):\n binary = ''.join(map(str, arr))\n ans = 0\n for i in range(len(binary)):\n ans += int(binary[i]) * (2 ** (len(binary) - i - 1))\n return ans", "def binary_array_to_number(arr):\n total = 0\n \n for n in range(len(arr)):\n if arr[n] == 1:\n total += pow(2,len(arr)-1-n)\n return total\n", "def binary_array_to_number(arr):\n arr = arr[::-1]\n sumador = 0\n for i in range(len(arr)):\n if arr[i] == 1:\n sumador += 2**i\n else:\n continue\n\n \n return sumador ", "def binary_array_to_number(arr):\n a = len(arr)\n n = 0\n for i in range(len(arr)):\n a-=1\n if arr[i] == 1:\n n += 2**a\n return n\n \n", "def binary_array_to_number(arr):\n decimal = 0\n p = 0\n \n for x in reversed(arr):\n decimal += x * 2 ** p\n p+=1\n return decimal\n", "def binary_array_to_number(arr):\n arr = (\"\".join([str(x) for x in arr]))\n return int(arr, 2)\n", "def binary_array_to_number(arr):\n binarr = \"\"\n for i in arr:\n binarr = binarr + str(i)\n return int(binarr, 2)"] | {"fn_name": "binary_array_to_number", "inputs": [[[0, 0, 0, 1]], [[0, 0, 1, 0]], [[1, 1, 1, 1]], [[0, 1, 1, 0]]], "outputs": [[1], [2], [15], [6]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,966 |
def binary_array_to_number(arr):
|
6c237d3283edc9d6bbf1976532e0f4f2 | UNKNOWN | You have to write two methods to *encrypt* and *decrypt* strings.
Both methods have two parameters:
```
1. The string to encrypt/decrypt
2. The Qwerty-Encryption-Key (000-999)
```
The rules are very easy:
```
The crypting-regions are these 3 lines from your keyboard:
1. "qwertyuiop"
2. "asdfghjkl"
3. "zxcvbnm,."
If a char of the string is not in any of these regions, take the char direct in the output.
If a char of the string is in one of these regions: Move it by the part of the key in the
region and take this char at the position from the region.
If the movement is over the length of the region, continue at the beginning.
The encrypted char must have the same case like the decrypted char!
So for upperCase-chars the regions are the same, but with pressed "SHIFT"!
The Encryption-Key is an integer number from 000 to 999. E.g.: 127
The first digit of the key (e.g. 1) is the movement for the first line.
The second digit of the key (e.g. 2) is the movement for the second line.
The third digit of the key (e.g. 7) is the movement for the third line.
(Consider that the key is an integer! When you got a 0 this would mean 000. A 1 would mean 001. And so on.)
```
You do not need to do any prechecks. The strings will always be not null
and will always have a length > 0. You do not have to throw any exceptions.
An Example:
```
Encrypt "Ball" with key 134
1. "B" is in the third region line. Move per 4 places in the region. -> ">" (Also "upperCase"!)
2. "a" is in the second region line. Move per 3 places in the region. -> "f"
3. "l" is in the second region line. Move per 3 places in the region. -> "d"
4. "l" is in the second region line. Move per 3 places in the region. -> "d"
--> Output would be ">fdd"
```
*Hint: Don't forget: The regions are from an US-Keyboard!*
*In doubt google for "US Keyboard."*
This kata is part of the Simple Encryption Series:
Simple Encryption #1 - Alternating Split
Simple Encryption #2 - Index-Difference
Simple Encryption #3 - Turn The Bits Around
Simple Encryption #4 - Qwerty
Have fun coding it and please don't forget to vote and rank this kata! :-) | ["from collections import deque\nKEYBOARD = ['zxcvbnm,.', 'ZXCVBNM<>', 'asdfghjkl', 'ASDFGHJKL', 'qwertyuiop', 'QWERTYUIOP']\n\ndef encrypt(text, encryptKey): return converter(text, encryptKey, 1)\ndef decrypt(text, encryptKey): return converter(text, encryptKey, -1)\n \ndef converter(text, encryptKey, sens):\n deques = list(map(deque, KEYBOARD))\n for i, deq in enumerate(deques):\n deq.rotate(-sens * (encryptKey // 10**(i//2) % 10) )\n return text.translate(str.maketrans(''.join(KEYBOARD), ''.join(''.join(deq) for deq in deques)))", "encrypt = lambda s, k: code(s, k)\ndecrypt = lambda s, k: code(s, k, -1)\n \ndef code(text, key, m=1):\n keys, r = [int(e) * m for e in str(key).rjust(3, '0')], []\n for c in text: \n for i, a in enumerate(['qwertyuiop', 'asdfghjkl', 'zxcvbnm,.']):\n if c in a: c = a[(a.index(c) + keys[i]) % len(a)] \n for i, a in enumerate(['QWERTYUIOP', 'ASDFGHJKL', 'ZXCVBNM<>']):\n if c in a: c = a[(a.index(c) + keys[i]) % len(a)]\n r.append(c)\n return ''.join(r)", "def code(mode, text, key):\n alphabet = \"qwertyuiop asdfghjkl zxcvbnm,. QWERTYUIOP ASDFGHJKL ZXCVBNM<>\"\n idxs = [mode * int(d) for d in '%03d' % key * 2]\n table = ' '.join(w[i:] + w[:i] for i, w in zip(idxs, alphabet.split()))\n return text.translate(str.maketrans(alphabet, table))\n\nfrom functools import partial\nencrypt, decrypt = partial(code, 1), partial(code, -1)", "rs=(\"qwertyuiop\",\"asdfghjkl\",\"zxcvbnm,.\",\"QWERTYUIOP\",\"ASDFGHJKL\",\"ZXCVBNM<>\")\n\ndef encrypt(t,k):\n k=[k//100,k//10%10,k%10]\n return t.translate(str.maketrans(''.join(rs),''.join(rs[i][k[i%3]:]+rs[i][:k[i%3]] for i,r in enumerate(rs))))\n \ndef decrypt(t,k):\n k=[k//100,k//10%10,k%10]\n return t.translate(str.maketrans(''.join(rs),''.join(rs[i][-k[i%3]:]+rs[i][:-k[i%3]] for i,r in enumerate(rs))))\n", "from operator import add, sub\nfrom functools import partial\n\nkeyboard = (\"qwertyuiop\", \"asdfghjkl\", \"zxcvbnm,.\", \"QWERTYUIOP\", \"ASDFGHJKL\", \"ZXCVBNM<>\")\nD = {c:(i,j,len(row)) for i,row in enumerate(keyboard) for j,c in enumerate(row)}\nkey = \"{:03}\".format\n\ndef trans(L, f, c):\n if c in D:\n i, j, l = D[c]\n return keyboard[i][f(j, L[i%3])%l]\n return c\n\ndef encrypt(text, encryptKey, f=add):\n return ''.join(map(partial(trans, list(map(int, key(encryptKey))), f), text))\n \ndef decrypt(text, encryptKey):\n return encrypt(text, encryptKey, sub)", "def encrypt(text, key):\n r1,r2,r3 = 'qwertyuiop','asdfghjkl','zxcvbnm,.'\n R1,R2,R3 = 'QWERTYUIOP','ASDFGHJKL', 'ZXCVBNM<>' \n key = str(key).zfill(3)\n mx = ''\n for x in text:\n if x in r1:\n mx += r1[(r1.index(x)+int(key[0]))%10]\n elif x in R1:\n mx += R1[(R1.index(x)+int(key[0]))%10]\n elif x in r2:\n mx += r2[(r2.index(x)+int(key[1]))%9]\n elif x in R2:\n mx += R2[(R2.index(x)+int(key[1]))%9]\n elif x in r3:\n mx += r3[(r3.index(x)+int(key[2]))%9]\n elif x in R3:\n mx += R3[(R3.index(x)+int(key[2]))%9]\n else:\n mx += x\n return mx\ndef decrypt(text, key):\n r1,r2,r3 = 'qwertyuiop','asdfghjkl','zxcvbnm,.'\n R1,R2,R3 = 'QWERTYUIOP','ASDFGHJKL', 'ZXCVBNM<>' \n key = str(key).zfill(3)\n mx = ''\n for x in text:\n if x in r1:\n mx += r1[(r1.index(x)-int(key[0]))%10]\n elif x in R1:\n mx += R1[(R1.index(x)-int(key[0]))%10]\n elif x in r2:\n mx += r2[(r2.index(x)-int(key[1]))%9]\n elif x in R2:\n mx += R2[(R2.index(x)-int(key[1]))%9]\n elif x in r3:\n mx += r3[(r3.index(x)-int(key[2]))%9]\n elif x in R3:\n mx += R3[(R3.index(x)-int(key[2]))%9]\n else:\n mx += x\n return mx", "def crypt(s, key, to_encrypt=True):\n keys = []\n for key in '{:0>3}'.format(key):\n keys.extend([int(key)] * 2)\n rows = ('qwertyuiop', 'QWERTYUIOP',\n 'asdfghjkl', 'ASDFGHJKL',\n 'zxcvbnm,.', 'ZXCVBNM<>')\n original = ''.join(rows)\n shifted = ''.join(r[k:] + r[:k] for r, k in zip(rows, keys))\n table = str.maketrans(*(\n (original, shifted) if to_encrypt else (shifted, original)))\n return s.translate(table)\n\n\ndef decrypt(s, key):\n return crypt(s, key, to_encrypt=False)\n\n\ndef encrypt(s, key):\n return crypt(s, key, to_encrypt=True)\n", "region1=\"qwertyuiop\" #10\nregion2=\"asdfghjkl\" #9\nregion3=\"zxcvbnm,.\" #9\n\ndef encrypt(text, encryptKey):\n print(text)\n print(encryptKey)\n s=str(encryptKey)\n if len(s) == 1: s=['0', '0', encryptKey]\n elif len(s) == 2: s=['0', s[0], s[1]]\n else: s=str(encryptKey)\n \n ntext=''\n for c in text:\n if c.lower() in region1:\n ind=region1.find(c.lower())\n if c == c.lower(): ntext+=region1[(ind+int(s[0]))%10]\n else: ntext+=region1[(ind+int(s[0]))%10].upper()\n elif c.lower() in region2:\n ind=region2.find(c.lower())\n if c == c.lower(): ntext+=region2[(ind+int(s[1]))%9]\n else: ntext+=region2[(ind+int(s[1]))%9].upper()\n elif c.lower() in region3+'<>':\n if c.lower() in region3:\n ind=region3.find(c.lower())\n if c == c.lower(): ntext+=region3[(ind+int(s[2]))%9]\n else: \n if region3[(ind+int(s[2]))%9] == ',': ntext+='<' \n elif region3[(ind+int(s[2]))%9] == '.': ntext+='>'\n else: ntext+=region3[(ind+int(s[2]))%9].upper()\n if c == '<':\n ind=region3.find(',')\n q=region3[(ind+int(s[2]))%9]\n if q == ',': ntext+='<'\n elif q == '.': ntext+='>'\n else: ntext+=q.upper()\n if c == '>':\n ind=region3.find('.')\n q=region3[(ind+int(s[2]))%9]\n if q == ',': ntext+='<'\n elif q == '.': ntext+='>'\n else: ntext+=q.upper()\n \n else: ntext+=c\n print(ntext)\n return ntext\n \ndef decrypt(text, encryptKey):\n print(text)\n print(encryptKey)\n \n s=str(encryptKey)\n if len(s) == 1: s=['0', '0', encryptKey]\n elif len(s) == 2: s=['0', s[0], s[1]]\n else: s=str(encryptKey)\n \n ntext=''\n for c in text:\n if c.lower() in region1:\n ind=region1.find(c.lower())\n if c == c.lower(): ntext+=region1[(ind-int(s[0]))%10]\n else: ntext+=region1[(ind-int(s[0]))%10].upper()\n elif c.lower() in region2:\n ind=region2.find(c.lower())\n if c == c.lower(): ntext+=region2[(ind-int(s[1]))%9]\n else: ntext+=region2[(ind-int(s[1]))%9].upper()\n elif c.lower() in region3+'<>':\n if c.lower() in region3:\n ind=region3.find(c.lower())\n if c == c.lower(): ntext+=region3[(ind-int(s[2]))%9]\n else: \n if region3[(ind-int(s[2]))%9] == ',': ntext+='<' \n elif region3[(ind-int(s[2]))%9] == '.': ntext+='>'\n else: ntext+=region3[(ind-int(s[2]))%9].upper()\n if c == '<':\n ind=region3.find(',')\n q=region3[(ind-int(s[2]))%9]\n if q == ',': ntext+='<'\n elif q == '.': ntext+='>'\n else: ntext+=q.upper()\n if c == '>':\n ind=region3.find('.')\n q=region3[(ind-int(s[2]))%9]\n if q == ',': ntext+='<'\n elif q == '.': ntext+='>'\n else: ntext+=q.upper()\n \n else: ntext+=c\n print(ntext)\n return ntext", "keyboard = ['qwertyuiop', 'QWERTYUIOP', 'asdfghjkl','ASDFGHJKL','zxcvbnm,.','ZXCVBNM<>']\n\ndef encrypt(text, encryptKey): return crypt(text, encryptKey, 1)\ndef decrypt(text, encryptKey): return crypt(text, encryptKey, -1)\n \ndef crypt(text, encryptKey, dir):\n encryptKey = str(encryptKey).zfill(3)\n # rotate all rows of keyboard\n new_keyboard = [row[int(encryptKey[i//2])*dir:]+row[:int(encryptKey[i//2])*dir] for i,row in enumerate(keyboard)]\n # join the rows of keyboard together to make a full translation and translate\n return ''.join([char.translate(str.maketrans(' '.join(keyboard), ' '.join(new_keyboard))) for char in text])", "top = 'qwertyuiop'\ntop_caps = 'QWERTYUIOP'\nmid = \"asdfghjkl\"\nmid_caps = 'ASDFGHJKL'\nbot = 'zxcvbnm,.'\nbot_caps = 'ZXCVBNM<>'\n\n\ndef encrypt(text, encryptKey):\n encryptKey = str(encryptKey).zfill(3)\n res = ''\n for char in text:\n for i, row in enumerate([top, top_caps, mid, mid_caps, bot, bot_caps]): \n if char in row:\n shift = int(encryptKey[i//2])\n res += char.translate(str.maketrans(row, row[shift:]+row[:shift]))\n break\n else: res += char\n return res\n \n \ndef decrypt(text, encryptKey):\n encryptKey = str(encryptKey).zfill(3)\n res = ''\n for char in text:\n for i, row in enumerate([top, top_caps, mid, mid_caps, bot, bot_caps]): \n if char in row:\n shift = int(str(encryptKey)[i//2])\n res += char.translate(str.maketrans(row, row[-shift:]+row[:-shift]))\n break\n else: res += char\n return res"] | {"fn_name": "encrypt", "inputs": [["A", 111], ["Abc", 212], ["Ball", 134], ["Ball", 444], ["This is a test.", 348], ["Do the kata Kobayashi Maru Test. Endless fun and excitement when finding a solution.", 583]], "outputs": [["S"], ["Smb"], [">fdd"], [">gff"], ["Iaqh qh g iyhi,"], ["Sr pgi jlpl Jr,lqlage Zlow Piapc I.skiaa dw. l.s ibnepizi.p ugi. de.se.f l arkwper.c"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 9,552 |
def encrypt(text, encryptKey):
|
bc4a2026d1c3b62d964aacdd4a72f5ab | UNKNOWN | You will receive an uncertain amount of integers in a certain order ```k1, k2, ..., kn```.
You form a new number of n digits in the following way:
you take one of the possible digits of the first given number, ```k1```, then the same with the given number ```k2```, repeating the same process up to ```kn``` and you concatenate these obtained digits(in the order that were taken) obtaining the new number. As you can see, we have many possibilities.
Let's see the process above explained with three given numbers:
```
k1 = 23, k2 = 17, k3 = 89
Digits Combinations Obtained Number
('2', '1', '8') 218 <---- Minimum
('2', '1', '9') 219
('2', '7', '8') 278
('2', '7', '9') 279
('3', '1', '8') 318
('3', '1', '9') 319
('3', '7', '8') 378
('3', '7', '9') 379 <---- Maximum
Total Sum = 2388 (8 different values)
```
We need the function that may work in this way:
```python
proc_seq(23, 17, 89) == [8, 218, 379, 2388]
```
See this special case and deduce how the function should handle the cases which have many repetitions.
```python
proc_seq(22, 22, 22, 22) == [1, 2222] # we have only one obtained number, the minimum, maximum and total sum coincide
```
The sequence of numbers will have numbers of n digits only. Numbers formed by leading zeroes will be discarded.
```python
proc_seq(230, 15, 8) == [4, 218, 358, 1152]
```
Enjoy it!!
You will never receive the number 0 and all the numbers will be in valid format. | ["from itertools import product\ndef proc_seq(*args):\n nums = set(int(''.join(l)) for l in product(*(str(a) for a in args)) if l[0] != '0')\n if len(nums) == 1: return [1, nums.pop()]\n return [len(nums), min(nums), max(nums), sum(nums)]", "from itertools import product\n\ndef proc_seq(*args):\n p = set([int(''.join(e)) for e in product(*[[c for c in str(arg) if i or c != '0'] for i, arg in enumerate(args)])])\n return [len(p)] + ([min(p), max(p)] if len(p) > 1 else []) + [sum(p)]", "def proc_seq(*li):\n un = {(i,) for i in str(li[0]) if i[0] != '0'}\n for i in li[1:] : un = {k + (l,) for k in un for l in str(i)}\n un = {int(''.join(i)) for i in un} \n return [1,un.pop()] if len(un)==1 else [len(un),min(un),max(un),sum(un)]", "from itertools import product\ndef proc_seq(*li):\n un = {int(''.join(i)) for i in list(product(*map(str, li))) if i[0]!='0'}\n return [1,un.pop()] if len(un)==1 else [len(un),min(un),max(un),sum(un)]", "from itertools import product\n\ndef proc_seq(*args):\n res = [int(''.join(s)) for s in set(product(*map(str, args))) if s[0] != '0']\n if len(res) == 1: return [1, res[0]]\n return [len(res), min(res), max(res), sum(res)]", "def proc_seq(*args):\n result = []\n mems = []\n numbers = [\"\"]\n for a in args:\n mems.append(list(set(str(a)))) \n \n nnumbers = []\n for a in mems:\n nnumbers = list(map(lambda x: (list(map(lambda y: y+x, numbers))),a))\n numbers = []\n for a in nnumbers:\n for b in a:\n numbers.append(b) \n \n numbers = list(filter(lambda x: x[0] != '0', numbers))\n \n numbers = list(map(lambda x: int(x), numbers))\n numbers.sort() \n \n if(len(numbers)==1):\n return [len(numbers), sum(numbers)]\n return [len(numbers), numbers[0], numbers[len(numbers)-1],sum(numbers)]", "from itertools import product as p\ndef proc_seq(*a):\n r,s=[],[]\n for i,x in enumerate(map(str,a)):\n s+=[''.join(set(d for d in x if d!='0' or i))]\n for x in p(*[[d for d in x] for x in s]):\n r+=[int(''.join(x))]\n l,h=min(r),max(r)\n return [len(r)]+([] if l==h else [l,h])+[sum(r)]", "from functools import reduce\ndef prod(arr):\n return reduce(lambda x,y:x*y, arr)\n\ndef proc_seq(*args):\n args = [set(str(n)) for n in args]\n args[0] -= {'0'}\n minimum = int(\"\".join(min(n) for n in args))\n maximum = int(\"\".join(max(n) for n in args))\n total = get_total(args)\n number = prod(len(arg) for arg in args)\n \n return [number, minimum, maximum, total] if number > 1 else [1, minimum]\n\ndef get_total(args):\n total = 0\n args = args[::-1]\n for i, arg in enumerate(args):\n total += 10 ** i * sum(map(int, arg)) * prod(len(x) for x in args[:i] + args[i+1:])\n return total\n"] | {"fn_name": "proc_seq", "inputs": [[23, 17, 89], [22, 22, 22, 22], [230, 15, 8]], "outputs": [[[8, 218, 379, 2388]], [[1, 2222]], [[4, 218, 358, 1152]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,846 |
def proc_seq(*args):
|
fbcfef1c479688c2ac4e98ecefba67d8 | UNKNOWN | HTML Element Generator
In this kata, you will be creating a python function that will take arguments and turn them into an HTML element.
An HTML tag has three parts:
The opening tag, which consists of a tag name and potentially attributes, all in between angle brackets.
The element content, which is the data that is shown on the webpage. This is in between the opening and closing tags.
And the closing tag, which is an opening angle bracket, a forward slash, the name of the tag, and a closing angle bracket
If you were to have multiple attributes, they would each appear with a single space separating them
Some tags do not require a closing tag. These are called self-closing tags. For this kata, any tag passed into the function without 'element content' (keyword arguments) will be treated in this way: after the tag name (and any attributes), there will be a space and then a forward slash. See the picture to the right.
Data will be passed into the html function as such:
The first argument will be the tag name
Any other non-keyword arguments will be element content. If no element content is given, the return value will be expected to be a self-closing tag. If more than one argument is given as element content, you will return multiple of the same element, just with different element content, separated by one or more newline characters.
Ex:
<p class="paragraph-text" id="example">Hello World!</p>\n<p class="paragraph-text" id="example">This is HTML code!</p>
IMPORTANT: Because class is a python keyword, and class is a very important HTML attribute, you will also have to implement a keyword argument named cls, as opposed to class. This attribute will appear as class="variable" in the return value of your function
Any other keyword arguments of the function will be treated as attributes of the element. The keyword is the attribute name (left of the equals sign), and the keyword's value is the attribute's value (right of the equals sign).
Element attributes will appear in the return value of your function in the order that they appear in the function's arguments when it is called. If cls is an argument of the function, it will always appear first (before any other keyword arguments).
Several Examples are provided | ["def html(tag, *contents, **attr):\n openTag = tag + ''.join(f' {\"class\" if k==\"cls\" else k}=\"{v}\"' for k,v in attr.items())\n \n return '\\n'.join( f'<{openTag}>{c}</{tag}>' for c in contents) or f'<{openTag} />'", "def html(tag, *args, **kwargs):\n open = tag + ''.join(f' {\"class\" if k == \"cls\" else k}=\"{v}\"' for k,v in kwargs.items())\n return '\\n'.join(f\"<{open}>{a}</{tag}>\" for a in args) or f\"<{open} />\"", "def html(tag, *content, **attributes):\n attrs = ''.join(f' {\"class\" if name == \"cls\" else name}=\"{value}\"' for name, value in attributes.items())\n return '\\n'.join(f\"<{tag}{attrs}>{element}</{tag}>\" for element in content) if content else f'<{tag}{attrs} />'", "import re\ndef html(tag,*content,cls=None,**atts): \n attributes = str(atts).replace('{',\"\").replace('}',\"\")\n lst = attributes.split(',')\n lst = [i.replace(\"'\",\"\",2).replace(\"'\",'\"').replace(': ',\"=\",1) for i in lst]\n attributes = \"\".join(lst) \n if len(content) > 0:\n txt = \"\"\n for i in range(len(content)):\n if cls: \n if attributes:\n txt += \"\\n\"+f\"<{tag} class=\\\"{str(cls)}\\\" {attributes}>{content[i]}</{tag}>\"\n else:\n txt += \"\\n\"+f\"<{tag} class=\\\"{str(cls)}\\\">{content[i]}</{tag}>\"\n else:\n if attributes:\n txt += \"\\n\"+f\"<{tag} {attributes}>{content[i]}</{tag}>\" \n else:\n txt += \"\\n\"+f\"<{tag}>{content[i]}</{tag}>\"\n return txt[1:]\n else: \n if cls:\n if attributes:\n return f\"<{tag} class=\\\"{str(cls)}\\\" {attributes} />\"\n else:\n return f\"<{tag} class=\\\"{str(cls)}\\\" />\"\n else:\n if attributes:\n return f\"<{tag} {attributes} />\"\n else:\n return f\"<{tag} />\"\n", "ALIAS = {\"cls\": \"class\"}\n\n\ndef html(tag, *contents, **attribs):\n attrib_repr = (\n \" \"\n + \" \".join(f'{ALIAS.get(key, key)}=\"{value}\"' for key, value in attribs.items())\n if attribs\n else \"\"\n )\n if not contents:\n return f\"<{tag}{attrib_repr} />\"\n return \"\\n\".join(f\"<{tag}{attrib_repr}>{content}</{tag}>\" for content in contents)", "def html(tag, *content, **attributes):\n attrib_str = ''.join(\n f' {key if key != \"cls\" else \"class\"}=\"{value}\"'\n for key, value in attributes.items())\n if not content:\n return f'<{tag}{attrib_str} />'\n return '\\n'.join(\n f'<{tag}{attrib_str}>{cnt}</{tag}>'\n for cnt in content)", "def html(tag, *contents, **attrs):\n attr_ls = [f'{\"class\" if k==\"cls\" else k}=\"{v}\"' for k,v in attrs.items()]\n if not contents: return f\"<{' '.join((tag, *attr_ls))} />\"\n else: return '\\n'.join(f\"<{' '.join((tag, *attr_ls))}>{content}</{tag}>\" for content in contents)", "def html(t, *args, **kwargs):\n s = \"\".join(f' {\"class\" if x == \"cls\" else x}=\"{kwargs[x]}\"' for x in kwargs)\n return f\"<{t}{s} />\" if not args else \"\\n\".join(f\"<{t}{s}>{x}</{t}>\" for x in args)", "def html(tag, *content, **kwargs):\n # Format tag's attributes \n attributes = ''\n if kwargs:\n attribs = []\n for k, v in list(kwargs.items()):\n if k == 'cls':\n k = 'class'\n attribs.append(f'{k}=\"{v}\"')\n attributes = ' ' + ' '.join(attribs) \n \n # Process content free tags\n if not content:\n return f'<{tag}{attributes} />'\n \n # Process content filled tags\n lines = []\n for line in content:\n lines.append(f'<{tag}{attributes}>{line}</{tag}>')\n return '\\n'.join(lines)\n", "def html(tag, *contents, **attr):\n open_tag = tag + ''.join(f' {\"class\" if n == \"cls\" else n}=\"{v}\"' for n, v in attr.items())\n return '\\n'.join(f'<{open_tag}>{c}</{tag}>' for c in contents) or f'<{open_tag} />'", "def html(*args, **kwargs):\n attributes = tuple(f'{name.replace(\"cls\", \"class\")}=\"{value}\"' for name, value in kwargs.items())\n if len(args) == 1: return f'<{\" \".join(args + attributes)} />'\n return '\\n'.join(f'<{\" \".join(args[:1] + attributes)}>{content}</{args[0]}>' for content in args[1:])", "def html(A, *B, **C):\n Cs = ' '.join('{}=\"{}\"'.format(\"class\" if i == \"cls\" else i, C[i]) for i in C)\n if len(B) == 0:\n return '<{}{}{} />'.format(A,' ' if Cs else '', Cs)\n return '\\n'.join('<{}{}{}>{}</{}>'.format(A,' ' if Cs else '', Cs, i, A) for i in B)", "def html(*args, **kwargs):\n keywords, elements = [], []\n if kwargs:\n for key, value in kwargs.items():\n if key == \"cls\":\n key = 'class'\n keywords.append(f'{key}=\"{value}\"')\n if len(args) == 1:\n if kwargs:\n element = f'<{args[0]}'\n for key in keywords:\n element += ' ' + key\n element += ' />'\n return element\n else:\n return f'<{args[0]} />'\n for i, arg in enumerate(args):\n if i == 0: tag = arg\n else:\n element = f'<{tag}'\n if kwargs:\n for key in keywords:\n element += ' ' + key\n element += f'>{arg}</{tag}>' \n elements.append(element)\n return \"\\n\".join(element for element in elements)", "def html(tag_name, *args, **kwargs):\n attributes = []\n for key, value in kwargs.items():\n if key == \"cls\":\n key = \"class\"\n attributes.append(f' {key}=\"{value}\"')\n \n if len(args) == 0:\n return f\"<{tag_name}{''.join(attributes)} />\"\n \n closing_tags = []\n for arg in args:\n closing_tags.append(f\"<{tag_name}{''.join(attributes)}>{arg}</{tag_name}>\")\n \n return \"\\n\".join(closing_tags)", "def html(tag_name, *args, **kwargs):\n attributes = []\n for key, value in kwargs.items():\n if key == \"cls\":\n key = \"class\"\n attributes.append(f'{key}=\"{value}\"')\n \n if len(args) == 0:\n return f\"<{tag_name}{'' if len(attributes) == 0 else ' ' + ' '.join(attributes)} />\"\n \n closing_tags = []\n for arg in args:\n closing_tags.append(f\"<{tag_name}{'' if len(attributes) == 0 else ' ' + ' '.join(attributes)}>{arg}</{tag_name}>\")\n return \"\\n\".join(closing_tags)", "def html(tag_name, *args, **kwargs):\n print((tag_name, args, kwargs))\n \n attributes = []\n for key, value in list(kwargs.items()):\n if key == \"cls\":\n key = \"class\"\n attributes.append(f'{key}=\"{value}\"')\n \n print()\n print(attributes)\n \n if len(args) == 0:\n return f\"<{tag_name}{'' if len(attributes) == 0 else ' ' + ' '.join(attributes)} />\"\n \n closing_tags = []\n for arg in args:\n closing_tags.append(f\"<{tag_name}{'' if len(attributes) == 0 else ' ' + ' '.join(attributes)}>{arg}</{tag_name}>\")\n return \"\\n\".join(closing_tags)\n \n", "def html(xn, *args, **kwargs):\n props = ''.join(' '+('class' if p == 'cls' else p)+'=\"'+kwargs[p]+'\"' for p in kwargs)\n return '\\n'.join(f'<{xn}{props}>{v}</{xn}>' for v in args) if args else f'<{xn}{props} />'", "def html(*args, **k_args):\n attrs = []\n for k, v in list(k_args.items()):\n if k=='cls':\n k='class'\n attrs.append(k+'=\"'+v+'\"')\n attrs = ' '.join(attrs)\n args = list(args)\n tag = args.pop(0)\n opentag=' '.join(['<'+tag, attrs]).strip()\n if len(args)==0:\n return opentag + ' />'\n return '\\n'.join([opentag+'>'+txt+'</'+tag+'>' for txt in args])\n", "def stringify_attrs(attrs):\n result = ''\n for attr in attrs:\n new_attr = attrs[attr]\n if attr == 'cls':\n attr = 'class'\n result += attr + '=' + '\"' + new_attr + '\"' + ' '\n if not result:\n return ''\n return ' ' + result.strip()\n \n\ndef html(tag, *bodies, **attrs):\n if not bodies:\n result = '<' + tag + stringify_attrs(attrs) + ' />'\n return result\n result = ''\n for body in bodies:\n result += '<' + tag + stringify_attrs(attrs) + '>' + body + '</' + tag + '>' + '\\n'\n return result.strip()", "\ndef stringify_attrs(attrs):\n # {'cls': 'ds', 'name': 'val'}\n # 'class=\"ds\" name=\"val\"'\n result = ''\n for attr in attrs:\n new_attr = attrs[attr]\n if attr == 'cls':\n attr = 'class'\n result += attr + '=' + '\"' + new_attr + '\"' + ' '\n if not result:\n return ''\n return ' ' + result.strip()\n \n\ndef html(tag, *bodies, **attrs):\n if not bodies:\n result = '<' + tag + stringify_attrs(attrs) + ' />'\n return result\n result = ''\n for body in bodies:\n result += '<' + tag + stringify_attrs(attrs) + '>' + body + '</' + tag + '>' + '\\n'\n return result.strip()\n\n #<\u0442\u0435\u0433 \u0438\u043c\u044f=\"\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\">body</\u0442\u0435\u0433>\n \n\n"] | {"fn_name": "html", "inputs": [["br"], ["title", "Webpage Title"]], "outputs": [["<br />"], ["<title>Webpage Title</title>"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 9,045 |
def html(tag_name, *args, **kwargs):
|
b690a7f27f7ec35b7b215496c1a66e95 | UNKNOWN | # Task
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
```
His number is always a non strict increasing sequence
ie. "123"
He converted each digit into English words.
ie. "123"--> "ONETWOTHREE"
And then, rearrange the letters randomly.
ie. "ONETWOTHREE" --> "TTONWOHREEE"
```
John felt that his number were safe in doing so. In fact, such encryption can be easily decrypted :(
Given the encrypted string `s`, your task is to decrypt it, return the original number in string format.
Note, You can assume that the input string `s` is always valid; It contains only uppercase Letters; The decrypted numbers are arranged in ascending order; The leading zeros are allowed.
# Example
For `s = "ONE"`, the output should be `1`.
For `s = "EON"`, the output should be `1` too.
For `s = "ONETWO"`, the output should be `12`.
For `s = "OONETW"`, the output should be `12` too.
For `s = "ONETWOTHREE"`, the output should be `123`.
For `s = "TTONWOHREEE"`, the output should be `123` too. | ["from collections import Counter \n\nEXECUTIONS_ORDER = [('Z', Counter(\"ZERO\"), '0'),\n ('W', Counter(\"TWO\"), '2'),\n ('U', Counter(\"FOUR\"), '4'),\n ('X', Counter(\"SIX\"), '6'),\n ('G', Counter(\"EIGHT\"), '8'),\n ('O', Counter(\"ONE\"), '1'),\n ('H', Counter(\"THREE\"), '3'),\n ('F', Counter(\"FIVE\"), '5'),\n ('V', Counter(\"SEVEN\"), '7'),\n ('I', Counter(\"NINE\"), '9')]\n\ndef original_number(s):\n ans, count, executions = [], Counter(s), iter(EXECUTIONS_ORDER)\n while count:\n c, wordCount, value = next(executions)\n ans.extend([value]*count[c])\n for _ in range(count[c]): count -= wordCount\n return ''.join(sorted(ans))", "from collections import Counter, defaultdict \n\nNUMBERS = [\"ZERO\", \"ONE\", \"TWO\", \"THREE\", \"FOUR\", \"FIVE\", \"SIX\", \"SEVEN\", \"EIGHT\", \"NINE\"]\nVALUES = {num: str(i) for i,num in enumerate(NUMBERS)}\ncounts = Counter(''.join(NUMBERS))\n\nwordsContainningLetter = defaultdict(set)\nfor n in NUMBERS:\n for c in n: wordsContainningLetter[c].add(n)\n\nEXECUTIONS_ORDER, founds = [], set()\nwhile counts:\n for c,v in counts.copy().items():\n if v == 1:\n try: word = (wordsContainningLetter[c] - founds).pop()\n except KeyError: break\n wordCount = Counter(word)\n founds.add(word)\n EXECUTIONS_ORDER.append( (c, wordCount, VALUES[word]) )\n counts -= wordCount\n\n\ndef original_number(s):\n ans, count, executions = [], Counter(s), iter(EXECUTIONS_ORDER)\n while count:\n c, wordCount, value = next(executions)\n ans.extend([value]*count[c])\n for _ in range(count[c]): count -= wordCount\n return ''.join(sorted(ans))", "def original_number(s):\n dic = {i:0 for i in range(10)}\n dic[0] = s.count('Z')\n dic[2] = s.count('W')\n dic[4] = s.count('U')\n dic[6] = s.count('X')\n dic[8] = s.count('G')\n dic[1] = s.count('O') - dic[0] - dic[2] - dic[4]\n dic[3] = s.count('H') - dic[8]\n dic[5] = s.count('F') - dic[4]\n dic[7] = s.count('S') - dic[6]\n dic[9] = s.count('I') - dic[5] - dic[6] - dic[8]\n result = ''\n for i in range(10):\n result += str(i)*dic[i]\n return result", "def original_number(s):\n r, s = [], list(s)\n for word, n in [('ZERO', 0), ('WTO',2), ('XSI',6), ('GEIHT',8), ('THREE',3), \n ('UFOR',4), ('ONE',1), ('FIVE',5), ('VSEEN',7), ('NINE',9)]: \n while word[0] in s: \n for c in word: s.remove(c)\n r.append(n)\n return ''.join(str(e) for e in sorted(r))", "def original_number(s):\n a = s[:]\n code=[0 for _ in range(10)]\n\n book = [[0, 'Z', 'ZERO'],\n [2, 'W', 'TWO'],\n [6, 'X', 'SIX'],\n [8, 'G', 'EIGHT'],\n [7, 'S', 'SEVEN'],\n [5, 'V', 'FIVE'],\n [4, 'F', 'FOUR'],\n [3, 'T', 'THREE'],\n [1, 'O', 'ONE'],\n [9, 'E', 'NINE']]\n for i in book:\n code[i[0]] = a.count(i[1])\n for j in i[2]:\n a = a.replace(j, '', code[i[0]])\n return ''.join('0123456789'[k]*j for k,j in enumerate(code))", "from collections import Counter\n\nNUMS = {\n 'ZERO':'0','EIGHT':'8','SIX':'6','SEVEN':'7',\n 'THREE':'3','FOUR':'4','FIVE':'5','NINE':'9',\n 'TWO':'2','ONE':'1'\n }\n \nKEYS = [ 'ZERO','EIGHT','SIX','SEVEN',\n 'THREE','FOUR','FIVE','NINE',\n 'TWO','ONE' ] \n\n\ndef original_number(s):\n res = ''; counted = Counter(s)\n for key in KEYS:\n while all(counted[char]>0 for char in key):\n for char in key:\n counted[char] -= 1\n res += NUMS[key]\n return ''.join(sorted(res))", "import scipy as sc\nimport scipy.optimize as so\n\n\ndef original_number(s):\n return ''.join([str(k) * int(round(n)) for k, n in enumerate( \\\n so.nnls(sc.transpose([sc.histogram([ord(c) - 65 for c in d], list(range(27)))[0] for d in \\\n ['ZERO', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE'] \\\n ]), sc.histogram([ord(c) - 65 for c in s], list(range(27)))[0])[0])])\n\n", "def original_number(s):\n s_list = list(s)\n numbers = [(0, 'ZERO'), (2, 'TWO'), (6, 'SIX'), (4, 'FOUR'), (1, 'ONE'), (5, 'FIVE'), (7, 'SEVEN'), (9, 'NINE'), (3, 'THREE'), (8, 'EIGHT')] \n secret_number = ''\n for i, number in numbers:\n while all([c in s_list for c in number]): \n [s_list.remove(c) for c in number] \n secret_number += str(i) \n\n return ''.join(sorted(secret_number))", "import re;original_number=lambda s:''.join(n*str(i)for i,n in enumerate(eval(re.sub('([A-Z])',r's.count(\"\\1\")','[Z,O-W-U-Z,W,H-G,U,F-U,X,S-X,G,I-G-F+U-X]'))))", "def original_number(s):\n \n s = list(s)\n output = []\n nums = (('Z','ZERO','0'),\n ('W','TWO','2'),\n ('U','FOUR','4'),\n ('X','SIX','6'),\n ('G','EIGHT','8'),\n ('O','ONE','1'),\n ('H','THREE','3'),\n ('F','FIVE','5'),\n ('V','SEVEN','7'),\n ('I','NINE','9'))\n\n for n in nums:\n while n[0] in s:\n output.append(n[2])\n for c in n[1]: \n del s[s.index(c)]\n \n return ''.join(sorted(output))"] | {"fn_name": "original_number", "inputs": [["ONE"], ["OEN"], ["ONETWO"], ["OONETW"], ["TTONWOHREEE"]], "outputs": [["1"], ["1"], ["12"], ["12"], ["123"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 5,600 |
def original_number(s):
|
d1d3b466acab2695e95e3fa3a7a4e039 | UNKNOWN | In this Kata you are expected to find the coefficients of quadratic equation of the given two roots (`x1` and `x2`).
Equation will be the form of ```ax^2 + bx + c = 0```
Return type is a Vector (tuple in Rust, Array in Ruby) containing coefficients of the equations in the order `(a, b, c)`.
Since there are infinitely many solutions to this problem, we fix `a = 1`.
Remember, the roots can be written like `(x-x1) * (x-x2) = 0`
### Example
quadratic(1,2) = (1, -3, 2)
This means `(x-1) * (x-2) = 0`; when we do the multiplication this becomes `x^2 - 3x + 2 = 0`
### Example 2
quadratic(0,1) = (1, -1, 0)
This means `(x-0) * (x-1) = 0`; when we do the multiplication this becomes `x^2 - x + 0 = 0`
### Notes
* Inputs will be integers.
* When `x1 == x2`, this means the root has the multiplicity of two | ["def quadratic(x1, x2):\n return (1,-x1-x2,x1*x2)\n", "def quadratic(x1, x2):\n return (1, -(x1 + x2), x1 * x2)\n", "import numpy as np\n\ndef quadratic(*args):\n return tuple(np.poly(args))", "def quadratic(x1, x2):\n equ = 1 , - x1-x2 , x1*x2\n return equ\n", "def quadratic(x1, x2):\n a = (1, -(x1+x2), x2*x1)\n return a\n", "quadratic=lambda x,y:(1,-x-y,x*y)\n", "def quadratic(x1, x2):\n a = 1\n b = -(x1 + x2)\n c = x1 * x2\n return a, b, c\n", "def quadratic(a, b):\n return (1, 0-a-b, a*b)\n", "def quadratic(x1, x2):\n coef=[1,]\n coef.append(-x1 -x2)\n coef.append(x1 * x2)\n return tuple(coef)\n \n", "def quadratic(x1, x2):\n print(x1,x2)\n a=1\n b=-(x1+x2)\n c=x1*x2\n return (a, b, c)", "def quadratic(x1, x2):\n a = 1\n b = x1*a + x2*a\n c = x1*x2\n z = (a,-b,c)\n return z\n", "def quadratic(x1, x2):\n if x1 != x2:\n c = (x1 * x1 * x2 - x2 * x2 * x1) / (x1 - x2)\n b = (-c - x1 * x1) / x1 if x1 else (-c - x2 * x2) / x2\n return (1, b, c)\n else:\n return (1, -2 * x1, x1 * x1)", "def quadratic(x1, x2):\n if x1 or x2 >= 0:\n sum = x1 + x2\n mult = x1 * x2\n return 1, -sum, mult\n if x1 or x2 <= 0:\n sum1 = x1 + x2\n mult1 = x1 * x2\n return 1, sum1, mult1\n", "quadratic = lambda r1, r2: (1, -(r1+r2), r1*r2)", "def quadratic(x1, x2):\n f=(-x2)\n t=(-x1)\n z=f+t\n e=-x1*-x2\n return (1,z,e)\n \n \n \n", "def quadratic(x1, x2):\n output = 1\n output1 = -x1 - x2\n output2 = x1 * x2\n return output, output1, output2\n", "def quadratic(x1, x2):\n a =1\n b = -x1 + - x2\n# result.append(b)\n c = -x1 * -x2\n# result.append(c)\n return (a,b,c)\n \n \n", "def quadratic(x1, x2):\n answer = (1, (x1 + x2) * -1, x1 * x2)\n return answer\n", "def quadratic(x1, x2):\n a=1\n b = -(x1+x2)\n c = x2*x1\n return (a,b,c)\n", "def quadratic(x1, x2):\n b = -x1-x2\n c = x1*x2\n array =(1,b,c)\n return array", "def quadratic(x1, x2):\n a = 1\n b = -x1 - x2\n c = x1 * x2\n print(a, b, c)\n return a, b, c", "def quadratic(x1, x2):\n a = 1\n b = (-1 * x1) + (-1 * x2)\n c = x1 * x2\n eq = (a, b, c)\n return eq\n", "def quadratic(x1, x2):\n a = 1\n b = -(x1+x2)\n c = x1*x2\n return (1, b, c)", "def quadratic(x1, x2):\n a=1\n b= -(x1)+(x2*-1)\n c= -(x1)*(x2*-1)\n return (a, b, c)\n\n", "import numpy as np\n\ndef quadratic(x1, x2):\n b = -1 * (x1 + x2)\n c = x1 * x2\n \n return (1, b, c)\n pass\n", "def quadratic(x1, x2):\n a = 1\n b = -(x1 + x2)\n c = x1 * x2\n re= (a, b, c);\n return re", "def quadratic(x1,\n x2):\n\n return (1,\n (x1 + x2) * -1,\n x1 * x2)\n", "def quadratic(x1, x2):\n a = []\n a.append(1)\n a.append(-(x1 + x2))\n a.append(x1 * x2)\n a = tuple(a)\n return a\n", "def quadratic(x1, x2):\n a,c=1,x1*x2\n return (1,-(x1+x2),x1*x2)\n", "def quadratic(x1, x2):\n return tuple((1, -x1-x2, x1*x2))\n\n\n", "def quadratic(x1, x2):\n if x1 + x2 > 0:\n return 1,-x1-x2,x1*x2\n else:\n return 1,-x1-x2,x1*x2", "def quadratic(x1, x2):\n #(x-x1)*(x-x2)=0\n #x^2 - x2x- x1x + x1x2\n return (1,(-x1-x2),x1*x2)\n", "def quadratic(x1, x2):\n print((x1, x2))\n a = 1\n if x2 - x1 != 0:\n b = (x1 ** 2 - x2 ** 2) / (x2 - x1)\n c = - x1 ** 2 - b * x1\n else:\n c = x1 ** 2\n b = -2 * x1\n return a, b, c\n", "def quadratic(x1, x2):\n x=1\n y=x1+x2\n z=x1*x2\n return (x,-y,z)\n", "def quadratic(x1, x2):\n eq = (1, -(x1 + x2), (x1*x2))\n return eq\n", "def quadratic(x1,x2):\n a = 1 #given\n b = (a * - x2) + (a * - x1) #(x-x1) * (x-x2) = 0\n c = -x1 * -x2\n return(a,b,c)\n\nprint(quadratic(1,2))", "def quadratic(x1, x2):\n b = -x2 + -x1\n c = x1 * x2\n \n return (1, b, c)\n", "def quadratic(x1, x2):\n a = (x1 + x2) * (-1)\n b = x1 * x2 \n return (1, a, b)", "def quadratic(x1, x2):\n x = 1\n return (x,-(x1+x2),(x1*x2))\n \n", "def quadratic(x1, x2):\n a = 1\n b = (-x2) + (-x1)\n c = (-x2) * (-x1)\n coeff = (a, b, c)\n return coeff\n \n", "def quadratic(x1, x2):\n coff = [1]\n coff.append(-x2 - x1)\n coff.append(-x1 * -x2)\n return tuple(coff)", "def quadratic(x1, x2):\n b = -1*x1 - x2\n c = x1*x2\n return (1, b, c)", "def quadratic(x1, x2):\n # return 1, -(abs(x1)+abs(x2)), x1*x2\n return 1, -x1+-x2, x1*x2", "def quadratic(x1, x2):\n ans = []\n ans.append(1)\n ans.append(-(x1 + x2))\n ans.append(x1*x2)\n return tuple(ans)\n", "def quadratic(x1, x2):\n a=x1+x2\n b=x1*x2\n return (1, -a, b)\n", "def quadratic(x1, x2):\n y = (1, -(x1+x2), x2*x1)\n return y\n\n", "def quadratic(x1, x2):\n t = (1, -(x1 + x2), x1*x2 )\n return t\n", "def quadratic(x1, x2):\n a = 1\n b = -x1-x2\n c = (b**2 - (x1-x2)**2)/4\n return (a, b, c) \n \n \n\n", "def quadratic(x1, x2):\n a=1\n b=-(a*(x1+x2))\n c=(a*(x1*x2))\n return((a,b,c))\n", "def quadratic(x1, x2):\n #0=x^2-(x1+x2)*x+x1*x2\n y=-(x1+x2)\n t=(1,y,x1*x2)\n return t", "def quadratic(x1, x2):\n return (1,(-1*x2)+(-1*x1),(-1*x1)*(-1*x2))\n", "def quadratic(x1, x2):\n a = 1\n b = (x1 + x2)*(-1)\n c = x1*x2\n s = (a, b, c)\n return s", "def quadratic(x1, x2):\n a = 1\n b = -a * x1 -a * x2\n c = a * x1 * x2\n \n return (a, b, c)\n", "import math \n\n\ndef quadratic(x1, x2):\n a = 1 \n b = -x1 - x2\n c = x1 * x2\n return (a, b, c)\n \n \n \n", "def quadratic(x1, x2):\n a=1\n b=x1+x2\n c=x1*x2\n return a,-b,c", "def quadratic(x1, x2):\n co1 = 1 \n co2 = - ( x2 + x1)\n co3 = x1 * x2\n result = (co1 , co2 , co3)\n return(result)\n", "def quadratic(x1, x2):\n #quadratic (x1, x2) = (x - x1)(x - x2)\n a = 1\n b = -(x1 + x2)\n c = (x1 * x2)\n return (a, b, c)\n", "def quadratic(x1, x2):\n \"\"\"\n Returns the coefficients of the equations in the order (a, b, c)\n \n Note: Since there are infinitely many solutions to this problem, we fix a = 1.\n \"\"\"\n return (1, -(x1 + x2), x1 * x2)", "def quadratic(x1, x2):\n return (1,-x1-x2,x1*x2)\n\nx = quadratic(56,99)\nprint(x)\n", "def quadratic(x1, x2):\n eq = (1, -(x1+x2), x2*x1)\n return eq\n", "def quadratic(x1, x2):\n result = -(x1+x2)\n return 1,result,x1*x2", "def quadratic(x1, x2):\n a = 1 \n if x1 < 0:\n c = x1 * x2 \n \n else:\n c = x1 * x2\n \n if x1 > 0 or x2 > 0:\n b = -(x1 + x2) \n else:\n b = abs(x1 + x2) \n tuple = (a, b , c)\n return tuple", "def quadratic(x1, x2):\n return (1, -x2-x1, x2*x1)\n", "def quadratic(x1, x2):\n return (1, x2*-1 + x1*-1, x1*x2)\n \n", "def quadratic(x1, x2):\n b = -x1 + -x2\n c = x1 * x2\n return (1,b,c)", "def quadratic(x1, x2):\n coef = ()\n a = 1\n b = -(x1 + x2)\n c = -x1 * -x2 \n \n coef = (a, b, c)\n return coef\n", "def quadratic(x1, x2):\n #(x - x1) * (x - x2) = 0\n a = 1\n b = 1* -x2 + -x1 * 1\n c = -x1 * -x2\n return (a, b, c)\n\n", "def quadratic(x1, x2):\n a = 1\n b = x1 + x2\n c = x1 * x2\n roots = (a, -b, c)\n return roots", "def quadratic(x1, x2):\n coeff = 1 , -x1-x2 , x1*x2\n return coeff\n", "def quadratic(x1, x2):\n a=1\n if x1!=x2:\n b=(x2**2-x1**2)/(x1-x2)\n c=-x1**2-b*x1\n else:\n b=-2*x1\n c=-x1**2-b*x1\n return (a,b,c)\n", "def quadratic(x1, x2):\n answer=(1,-x1-x2,x1*x2)\n return answer\n", "def quadratic(x1, x2):\n a = 1\n b = -x1-x2\n c = x1*x2\n vector = (a,b,c)\n return vector\n", "def quadratic(x1, x2):\n x = 1\n f = (x * x ), (x * - (x2)),(-x1 * x) ,(-x1 * - (x2))\n return f[0], f[1] + f[2], f[3]\n \n \n", "def quadratic(x1, x2):\n x = 1\n formula = (x * x ), (x * - (x2)),(-x1 * x) ,(-x1 * - (x2))\n return formula[0], formula[1] + formula[2], formula[3]\n \n \n", "def quadratic(x1, x2):\n int(x1)\n int(x2)\n thisdict = {\n 'a': 1,\n 'b': (-x1) + (-x2),\n 'c': (-x1) * (-x2)\n }\n return (thisdict.get('a'), thisdict.get('b'), thisdict.get('c'))\n \n \n", "def quadratic(x1, x2):\n a=1\n c=(-x1*-x2)\n b=-(x1+x2)\n return (a,b,c)", "def quadratic(x1, x2):\n a=1\n b=-(x1+x2)\n c=(x1*x2)\n tes=(a,b,c)\n return tes\n", "x = 1\ndef quadratic(x1, x2):\n #equation = (x-x1)*(x-x2)=0\n a = (x*x)\n b = (-(x*x2))-(x1*x)\n c = (x1*x2)\n return a, b, c\n", "def quadratic(x1, x2):\n d = (x1+x2)**2-4*x1*x2\n c = x1*x2\n b = -1*(x1+x2)\n return(1,b,c)\n", "def quadratic(x1, x2):\n p = -1 * (x1 + x2) \n q = x1 * x2\n b = p\n c = q\n a = 1\n return (a, b, c)\n", "def quadratic(x1, x2):\n sum = x1 + x2\n sum = sum * -1\n mul = x1 * x2\n list = (1, sum, mul)\n return list\n", "def quadratic(x1, x2):\n a = 1\n b = (-1 * x2) + (-1 * x1)\n c = (-1 * x1) * (-1 * x2)\n return (a,b,c)", "def quadratic(a, b):\n return (1, (-a+-b), (-a*-b))\n", "def quadratic(a, b):\n return tuple([1, (-a+-b), (-a*-b)])\n", "def quadratic(x1, x2):\n if x1 == x2:\n return (1, int(-2 * x1), int(x1 ** 2))\n else:\n b = (x1 ** 2 - x2 ** 2) / (x2 - x1)\n return (1, int(b), int(-1 * (x1 ** 2) - b * x1))\n", "def quadratic(x1, x2):\n a, b, c = 1, 0, 0\n b = -1 * a * (x1 + x2)\n c = a * (x1 * x2)\n return (a, b, c)\n", "def quadratic(m, n):\n return (1, -(m+n), m*n)", "def quadratic(x1, x2):\n a, b, c = 0, -(x1 + x2), (x1 * x2)\n if x1 * x2 != 0:\n a = c / (x1 * x2)\n elif (x1 + x2) != 0:\n a = -b / (x1 + x2)\n return a, b, c", "def quadratic(x1, x2):\n a = 1\n b = x1 * (-1) + x2 * (-1)\n c = x1*x2\n \n coeff = (a, b, c)\n return coeff\n \n # (x - x1)*(x - x2)\n \n \n\n\n\n\n", "def quadratic(x1, x2):\n if x1 == 0:\n return (1, -x2, 0)\n else:\n return (1, -(x1+x2), (x2*x1))\n", "def quadratic(x1, x2):\n return tuple([1,-x1-x2,x1*x2])", "def quadratic(x1, x2):\n lst = list()\n a = 1\n lst.append(a)\n b = -(x1+x2)\n lst.append(b)\n c = x1 * x2\n lst.append(c)\n tpl = tuple(lst)\n return tpl", "def quadratic(x1, x2):\n a, b, c=1, -(x1+x2), (x1*x2) \n return(a, b, c)", "def quadratic(x1, x2):\n lst=()\n a=1\n c=x1*x2\n b=((-x1)-(x2)) \n lst=(a,b,c)\n return lst\npass\n", "def quadratic(x1, x2):\n b = -1*(x1 + x2)\n c = x1 * x2\n return (1, b, c)\n", "def quadratic(x1, x2):\n a=1\n c=x1*x2\n if x1!=x2:\n b=-(x1+x2)\n if x1==x2:\n b=-2*x1\n return (a,b,c)", "def quadratic(x1, x2):\n #(x-x1) * (x-x2) = 0\n return (1,-(x1+x2),x1*x2)\n", "def quadratic(x1, x2):\n if isinstance(x1, int) and isinstance(x2, int):\n b = - (x1 + x2)\n c = x1 * x2\n return 1, b, c\n else:\n return False\n\n\nprint(quadratic(1, 3))", "def quadratic(x1, x2):\n c = x1 * x2\n b = -(x1 + x2)\n return 1,b,c\n", "def quadratic(x1, x2):\n a, b, c = 1, (-x1 + -x2), (x1 *x2) \n return a, b, c"] | {"fn_name": "quadratic", "inputs": [[0, 1], [4, 9], [2, 6], [-5, -4]], "outputs": [[[1, -1, 0]], [[1, -13, 36]], [[1, -8, 12]], [[1, 9, 20]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 11,408 |
def quadratic(x1, x2):
|
7a5b73569f1fa7b2f29bc0d1a56f9cc6 | UNKNOWN | Make a function that receives a value, ```val``` and outputs the smallest higher number than the given value, and this number belong to a set of positive integers that have the following properties:
- their digits occur only once
- they are odd
- they are multiple of three
```python
next_numb(12) == 15
next_numb(13) == 15
next_numb(99) == 105
next_numb(999999) == 1023459
next_number(9999999999) == "There is no possible number that
fulfills those requirements"
```
Enjoy the kata!! | ["def unique_digits(n):\n return len(set(str(n))) == len(str(n))\n\ndef next_numb(val):\n val += 1\n while val % 3: val += 1\n if val % 2 == 0: val += 3\n \n while not unique_digits(val):\n val += 6\n if val > 9876543210: break\n else:\n return val\n \n return \"There is no possible number that fulfills those requirements\"\n", "def next_numb(val):\n val += 3 - val % 3\n if not val & 1: val += 3\n while val < 9999999999:\n s = str(val)\n if len(s) == len(set(s)):\n return val\n val += 6\n return \"There is no possible number that fulfills those requirements\"\n", "DEFAULT = \"There is no possible number that fulfills those requirements\"\n\ndef valid(s): return len(set(s))==len(s)\n\ndef next_numb(n):\n n += 3-n%3\n if not n&1: n += 3\n return next( (n for n in range(n,9999999999,6) if valid(str(n))), DEFAULT)", "def next_numb(val):\n i = val + 1\n while i <= 9999999999:\n if i % 3 == 0 and i % 2 and len(str(i)) == len(set(str(i))):\n return i\n i += 1\n return 'There is no possible number that fulfills those requirements'", "from itertools import count\n\n\ndef next_numb(val):\n if val >= 9999999999:\n return 'There is no possible number that fulfills those requirements'\n for i in count(val + 1):\n s = str(i)\n if i % 2 == 1 and i % 3 == 0 and len(s) == len(set(s)):\n return i", "from collections import Counter\ndef next_numb(val):\n if val >= 9876543210: return \"There is no possible number that fulfills those requirements\"\n x = val + 1\n if x % 3 != 0:\n x += (3 - x % 3)\n if x % 2 == 0: x += 3\n c = Counter(str(x))\n while max(c.values()) > 1:\n x += 6\n c = Counter(str(x))\n return x", "def next_numb(val):\n val += 3 - val % 3\n if not val & 1: val += 3\n while val <= 9876543201:\n s = str(val)\n if len(s) == len(set(s)):\n return val\n val += 6\n return \"There is no possible number that fulfills those requirements\"", "def next_numb(n):\n if n>9876543201:\n return \"There is no possible number that fulfills those requirements\"\n x=n-n%3+3\n while True:\n if x>9876543201:\n return \"There is no possible number that fulfills those requirements\"\n if x&1:\n a=[d for d in str(x)]\n s=list(set(a))\n if len(a)==len(s):\n return x\n x+=3"] | {"fn_name": "next_numb", "inputs": [[12], [13], [99], [999999], [9999999999]], "outputs": [[15], [15], [105], [1023459], ["There is no possible number that fulfills those requirements"]]}
| INTRODUCTORY | PYTHON3 | CODEWARS | 2,537 |
def next_numb(val):
|
78bf072ec426427bfb63515ee0998e8f | UNKNOWN | Given two arrays of strings, return the number of times each string of the second array appears in the first array.
#### Example
```python
array1 = ['abc', 'abc', 'xyz', 'cde', 'uvw']
array2 = ['abc', 'cde', 'uap']
```
How many times do the elements in `array2` appear in `array1`?
* `'abc'` appears twice in the first array (2)
* `'cde'` appears only once (1)
* `'uap'` does not appear in the first array (0)
Therefore, `solve(array1, array2) = [2, 1, 0]`
Good luck!
If you like this Kata, please try:
[Word values](https://www.codewars.com/kata/598d91785d4ce3ec4f000018)
[Non-even substrings](https://www.codewars.com/kata/59da47fa27ee00a8b90000b4) | ["def solve(a,b):\n return [a.count(e) for e in b]", "from collections import Counter\n\ndef solve(a,b):\n c = Counter(a)\n return [c[s] for s in b]", "def solve(a,b):\n return [a.count(x) for x in b]", "def solve(a,b):\n return list(map(a.count, b))", "def solve(haystack, needles):\n return [haystack.count(needle) for needle in needles]", "from collections import Counter\n\ndef solve(a, b):\n return list(map(Counter(a).__getitem__, b))", "def solve(first,second):\n return [first.count(word) for word in second]", "def solve(array1, array2):\n return [array1.count(e) for e in array2]\n", "solve=lambda a,b:(lambda c:[c.get(s,0)for s in b])(__import__('collections').Counter(a))", "from collections import Counter\n\n\ndef solve(arr_1, arr_2):\n cnt = Counter(arr_1)\n return [cnt[a] for a in arr_2]\n"] | {"fn_name": "solve", "inputs": [[["abc", "abc", "xyz", "abcd", "cde"], ["abc", "cde", "uap"]], [["abc", "xyz", "abc", "xyz", "cde"], ["abc", "cde", "xyz"]], [["quick", "brown", "fox", "is", "quick"], ["quick", "abc", "fox"]]], "outputs": [[[2, 1, 0]], [[2, 1, 2]], [[2, 0, 1]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 841 |
def solve(a,b):
|
0b28653778181f77b690caf26cfaf256 | UNKNOWN | Given a string and an array of integers representing indices, capitalize all letters at the given indices.
For example:
* `capitalize("abcdef",[1,2,5]) = "aBCdeF"`
* `capitalize("abcdef",[1,2,5,100]) = "aBCdeF"`. There is no index 100.
The input will be a lowercase string with no spaces and an array of digits.
Good luck!
Be sure to also try:
[Alternate capitalization](https://www.codewars.com/kata/59cfc000aeb2844d16000075)
[String array revisal](https://www.codewars.com/kata/59f08f89a5e129c543000069) | ["def capitalize(s,ind):\n ind = set(ind)\n return ''.join(c.upper() if i in ind else c for i,c in enumerate(s))", "def capitalize(s, ind):\n result = list(s)\n for index in ind:\n try:\n result[index] = result[index].upper()\n except IndexError:\n break # assumes the indexes are sorted\n return ''.join(result)\n", "def capitalize(s,ind):\n return ''.join(c.upper() if i in ind else c for i, c in enumerate(s))", "def capitalize(s,ind):\n return (\"\".join(char.upper() if i in ind else char for i,char in enumerate(s)))", "def capitalize(s,ind):\n return \"\".join(letter.upper() if index in ind\n else letter for index, letter in enumerate(s))", "def capitalize(s,ind):\n for i in ind:\n s = s[:i] + s[i:].capitalize()\n return s", "def capitalize(s,ind):\n return ''.join(j.upper() if i in ind else j for i, j in enumerate(s))", "def capitalize(s,ind):\n return \"\".join([j.upper() if i in ind else j for i,j in enumerate(s)])", "def capitalize(s,ind):\n for i in ind:\n try:\n s =s[:i] + s[i].upper() + s[i+1:] \n except:\n return s\n return s", "def capitalize(s,ind):\n return ''.join([s[x].capitalize() if x in ind else s[x] for x in range(len(s))])", "def capitalize(s, ind):\n result = \"\"\n\n for index, letter in enumerate(s):\n\n if index in ind:\n result += letter.upper()\n\n else:\n result += letter\n\n return result", "def capitalize(s,ind):\n l=list(s)\n for v in ind:\n if len(l)>=v:\n l[v]=l[v].upper()\n return ''.join(l)", "def capitalize(s,ind):\n list_s=list(s)\n cap=[]\n \n for i in range(len(list_s)):\n if i in ind:\n list_s[i]=list_s[i].upper()\n cap.append(list_s[i])\n \n cap_s=''.join(cap)\n return cap_s", "def capitalize(s,ind):\n res = \"\"\n for key, letter in enumerate(s):\n # if element in list\n if key in ind:\n res += letter.upper()\n else:\n res += letter \n return res", "def capitalize(s,ind):\n return ''.join([c,c.upper()][i in ind] for i,c in enumerate(s))", "capitalize=lambda s,a:''.join((x,x.upper())[y in a]for y,x in enumerate(s))", "def capitalize(s, ind):\n # Iterate over every character 'char' of string 's'.\n # Capitalize the char if its position 'idx' is present\n # in list 'ind'.\n # If it is not, just return the char.\n char_list = [char.upper() if idx in ind else char for (idx, char) in enumerate(s)]\n return ''.join(char_list)", "def capitalize(s,ind):\n return ''.join([s[i].upper() if i in ind else s[i] for i in range(len(s))])", "def capitalize(s,ind):\n return \"\".join(x.upper() if i in ind else x for i, x in enumerate(s))\n", "def capitalize(s,ind):\n return ''.join([m.upper() if i in ind else m for i, m in enumerate(s)])", "def capitalize(s,ind):\n s = list(s)\n for i in ind:\n if (i < len(s)):\n s[i] = s[i].upper()\n else:\n continue\n return \"\".join(s)", "def capitalize(s,ind):\n out = ''\n for i in range(len(s)) : \n if i in ind : out = out + s[i].capitalize()\n else : out = out + s[i]\n return out", "def capitalize(s,ind):\n new_word = \"\"\n for idx, val in enumerate(s):\n if idx in ind: \n new_word += val.upper()\n else:\n new_word += val\n \n return new_word", "def capitalize(s,ind):\n s1=[i for i in s]\n for indeks in range(0,len(s)):\n if indeks in ind:\n s1[indeks]=s1[indeks].upper()\n return ''.join(s1) ", "def capitalize(s,ind):\n res = ''\n for i,v in enumerate(s):\n if i in ind:\n res+=v.upper()\n else:\n res+=v.lower()\n \n return res", "def capitalize(s,ind):\n arr = []\n for i in range(len(s)):\n if i in ind:\n arr.append(s[i].upper())\n else:\n arr.append(s[i])\n return \"\".join(arr)", "def capitalize(s,arr):\n s=list(s) \n for i in arr:\n try:\n s[i]=s[i].upper()\n except IndexError:\n continue \n return \"\".join(s)\n", "def capitalize(s,ind):\n ind = set(ind)\n return ''.join(c if i not in ind else c.upper() for i,c in enumerate(s)) ", "\ndef capitalize(s,ind):\n ret, ixd = '', ind[::]\n ch = ixd.pop(0)\n for i, e in enumerate(s):\n if i == ch:\n ret += e.upper()\n if ixd:\n ch = ixd.pop(0)\n else:\n ret += e\n return ret", "def capitalize(s,ind):\n return \"\".join([x.upper() if i in ind else x.lower() for i,x in enumerate(s)])", "def capitalize(s,ind):\n s = [*s]\n for n in ind:\n if not n > len(s):\n s[n] = s[n].upper()\n \n return ''.join(s)\n \n", "def capitalize(s,ind):\n return ''.join(s[x] if x not in ind else s[x].swapcase() for x in range(len(s)))\n \n", "def capitalize(s,ind):\n a = []\n for i in range(len(s)):\n if i in ind:\n a += s[i].upper()\n else:\n a += s[i]\n return ''.join(a)", "def capitalize(s, ind):\n return ''.join(s[x] if x not in ind else s[x].upper() for x in range(len(s)))\n", "def capitalize(s,ind):\n t = \"\"\n for num,x in enumerate(s):\n if num in ind:\n t+=x.upper()\n else:\n t+=x\n return t", "def capitalize(s,ind):\n return ''.join(letter.upper() if i in ind else letter for i, letter in enumerate(s))", "def capitalize(s,ind):\n new=\"\"\n for i in range(len(s)):\n if i in ind:\n new+=s[i].upper()\n else:\n new+=s[i]\n \n return new \n", "def capitalize(s,ind): # jai shree ram!!!!\n for i in ind:\n if i<len(s):\n s=s[:i]+s[i].upper()+s[i+1:]\n return s", "def capitalize(s,ind):\n arr=list(s)\n for i in range(len(s)):\n if i in ind:\n arr[i]=arr[i].upper()\n return ''.join(arr)", "def capitalize(s,ind):\n liste=[]\n for letter in s:\n liste.append(letter)\n \n i=0\n for i in range(0,len(liste)):\n if i in ind:\n liste[i]=liste[i].capitalize()\n \n string=\"\".join([str(i) for i in liste]) \n \n return string ", "def capitalize(s,ind):\n res = []\n \n for i,v in enumerate(s):\n if i in ind:\n res.append(v.upper())\n else:\n res.append(v)\n \n \n return ''.join(res)", "def capitalize(s,ind):\n if not s: return 'aBCdeF'\n s = list(s)\n for index in ind:\n if index > len(s) - 1: continue\n cap = ord(s[index]) - 32\n s[index] = chr(cap)\n return ''.join(s)\n", "def capitalize(s,ind):\n new_string=\"\"\n for letter in range(len(s)):\n if letter in ind:\n new_string += s[letter].upper()\n else:\n new_string += s[letter]\n return new_string", "def capitalize(s,ind):\n return ''.join([i.upper() if loop in ind else i for loop, i in enumerate(s)])", "def capitalize(x,a):\n b=[]\n for i, e in enumerate(x):\n if i in a:\n b+=e.upper()\n else:\n b+=e\n return ''.join(b)", "def capitalize(s,ind):\n return ''.join([s[i].upper() if i in ind and i<len(s) else s[i] for i in range(len(s)) ])\n\n\n", "def capitalize(s,ind):\n new_s = ''\n for i, c in enumerate(s):\n if i in ind:\n new_s = new_s + c.upper()\n else:\n new_s = new_s + c\n return new_s", "def capitalize(s,ind):\n# string = [s[ind] for letter in s if letter]\n result = []\n for i, char in enumerate(s):\n if i in ind:\n result.append(char.upper())\n else:\n result.append(char)\n return ''.join(result)", "def capitalize(s,ind):\n s = list(s)\n for i in ind:\n if i <= len(s)-1:\n s[i] = s[i].upper()\n return ''.join(s)", "def capitalize(s,ind):\n s = list(s)\n return ''.join([s[i].upper() if i in ind else s[i] for i in range(0,len(s))])", "def capitalize(s,ind):\n t = [str(i) for i in s]\n a = ''\n for x in range(0, len(t)):\n if x in ind:\n t[x] = t[x].upper()\n a += t[x]\n return a", "def capitalize(s,ind):\n if ind == []:\n return s\n else:\n return capitalize (s[:ind[0]]+(s[ind[0]:]).capitalize(),ind[1:])", "def capitalize(s,ind):\n temp = list(s)\n for i in ind:\n if i > len(temp):\n return \"\".join(temp)\n temp[i] = temp[i].upper()\n return \"\".join(temp)", "def capitalize(s,ind):\n res = \"\"\n a = 0\n for i in s:\n if a in ind:\n res += i.upper()\n else:\n res += i\n a += 1\n return res", "def capitalize(s,ind):\n c = \"\"\n for i in range(len(s)):\n k = 0\n for j in range(len(ind)):\n if i == ind[j]:\n c += s[i].upper()\n k += 1\n else:\n continue\n if k == 0:\n c += s[i]\n return c\n", "def capitalize(s,ind):\n a=\"\"\n for i,c in enumerate(s):\n if i in ind:\n a=a+c.upper()\n else:\n a=a+c\n return a ", "def capitalize(s,ind):\n s = list(s)\n for i in range(len(ind)):\n if ind[i] > len(s):\n s = s\n else:\n s[ind[i]] = s[ind[i]].upper()\n return ''.join(s)", "def capitalize(s,ind):\n news = list(s)\n for i in ind:\n if i <= len(s):\n news[i] = s[i].upper()\n return ''.join(news)", "def capitalize(s,ind):\n count=0\n output = []\n for i in s:\n if ind.count(count) > 0:\n output.append(i.upper())\n count+=1\n else:\n output.append(i)\n count+=1\n return(''.join(output))\n \n", "def capitalize(s,ind):\n new_list = []\n for i, letter in enumerate(s):\n if i in ind:\n new_list.append(letter.upper())\n else:\n new_list.append(letter)\n return ''.join(new_list)\n \n \n", "def capitalize(s, ind):\n ind = set(ind)\n return ''.join(l.upper() if i in ind else l for i, l in enumerate(s))", "def capitalize(s,ind):\n return ''.join([word.upper() if i in ind else word for i, word in enumerate(s) ])", "def capitalize(s,ind):\n res = []\n for i, char in enumerate(s):\n res += char.upper() if i in ind else char\n return ''.join(res)", "def capitalize(s,ind):\n ar = list(s)\n for index, value in enumerate(ar):\n for i in ind:\n if i == index:\n ar[index] = value.upper()\n \n return ''.join(ar)\n \n", "def capitalize(s,ind):\n arr = list(s)\n for i in ind:\n if i <= len(arr):\n arr[i] = arr[i].upper()\n return ''.join(arr)", "def capitalize(s,ind):\n s = list(s)\n last_indx = len(s) - 1\n for indx in ind:\n if indx > last_indx or indx < 0:\n pass\n else:\n s[indx] = s[indx].upper()\n return ''.join(s)\n\n", "def capitalize(s,ind):\n s = list(s)\n for element in ind:\n if element <= len(s):\n s[element]=s[element].upper()\n return ''.join(s)", "def capitalize(s,ind):\n new_string = \"\"\n i = 0\n while i < len(s):\n if i in ind:\n new_string+=s[i].upper()\n else:\n new_string+=s[i]\n i+=1\n return new_string", "def capitalize(s,ind):\n a = \"\"\n for i in range(len(s)):\n if i in ind:\n a = a + s[i].upper()\n else:\n a += s[i]\n return a", "def capitalize(s,ind):\n how_about_a_list = list(s)\n for number in ind:\n if number <= len(s):\n how_about_a_list[number] = how_about_a_list[number].upper()\n return ''.join(how_about_a_list) ", "def capitalize(s,ind):\n new_string = ''\n for i in range(len(s)):\n if i in ind:\n new_string += s[i].upper()\n else:\n new_string += s[i]\n return new_string", "def capitalize(s,ind):\n for i in ind:\n if i >= len(s): break\n s = s[:i] + s[i].capitalize() + s[i+1:]\n return s", "def capitalize(s, ind):\n sy = list(s)\n for i in ind:\n try:\n sy[i] = sy[i].upper()\n except IndexError:\n print(\"Index out of range\")\n return \"\".join(sy)", "def capitalize(s,ind):\n out = \"\"\n s = list(s)\n for i in ind:\n if i < len(s):\n s[i] = s[i].upper()\n return \"\".join(s)", "def capitalize(s,ind):\n letters = list(s)\n for i in ind:\n if i >= len(letters):\n break\n letters[i] = letters[i].upper()\n \n return ''.join(letters)", "\ndef capitalize(s,ind):\n return \"\".join((list([i[1].upper() if i[0] in ind else i[1] for i in enumerate(s)])))\n", "def capitalize(s,ind):\n ret = ''\n for i, letter in enumerate(s):\n if i in ind:\n ret += letter.upper()\n else:\n ret += letter\n return ret", "def capitalize(s,ind):\n tulos = \"\"\n\n for i in range(0,len(s)):\n merkki = s[i]\n if ( i in ind):\n merkki = merkki.upper()\n tulos += merkki\n\n return tulos", "def capitalize(s,ind):\n for i in ind:\n if i > len(s):\n continue\n else:\n s = s[:i] + s[i].upper() + s[i+1:]\n\n return s ", "#You can do it!\ndef capitalize(s, ind):\n split_s = list(s)\n for i in ind:\n try:\n split_s[i] = split_s[i].upper()\n except IndexError:\n pass\n return \"\".join(split_s)", "def capitalize(s,ind):\n sl = len(s)\n ls = []\n st =''\n for i in s:\n ls.append(i)\n for i in range(sl):\n if i in ind:\n ls[i] = ls[i].upper()\n for i in ls:\n st+=i\n return st", "def capitalize(chars, indices):\n indices.sort()\n result_list = []\n next_index_to_cap = 0\n for index, char in enumerate(chars):\n if next_index_to_cap < len(indices) and index == indices[next_index_to_cap]:\n char = char.capitalize()\n next_index_to_cap += 1\n result_list.append(char)\n return ''.join(result_list)", "def capitalize(chars, indices):\n for index in indices:\n if index < len(chars):\n chars = chars[0:index] + chars[index].capitalize() + chars[index+1:]\n return chars\n", "def capitalize(s,ind):\n output = ''\n for i in range(len(s)):\n if i in ind:\n if i < len(s):\n output += s[i].upper()\n else:\n output += s[i] \n return output", "def capitalize(s,ind):\n newstring=[]\n for numero in range(len(s)):\n if numero not in ind:\n newstring.append(s[numero])\n elif numero in range(len(s)):\n newstring.append(s[numero].capitalize())\n return \"\".join(newstring)", "def capitalize(s,ind):\n s = list(s)\n ind_new = []\n \n for k in ind:\n if k < len(s):\n ind_new.append(k)\n \n for i in range(0, len(ind_new)):\n s[ind_new[i]] = s[ind_new[i]].upper()\n i += 1\n return ''.join(s)", "def capitalize(s,ind):\n j=list(s)\n for i in ind:\n if i<len(s)+1:\n j[i]=j[i].upper()\n return \"\".join(j)", "def capitalize(s,ind):\n a=''\n for i in range(len(s)):\n if i in ind:\n a+=s[i].upper()\n else:\n a+=s[i]\n return a", "def capitalize(s,ind):\n res=''\n for n,i in enumerate(s):\n if n in ind:\n res+=i.swapcase()\n else:\n res+=i\n return res", "def capitalize(s,ind):\n s = list(s)\n for e in ind:\n try:\n s[e] = s[e].capitalize()\n except:\n continue\n return ''.join(s)", "def capitalize(s,ind):\n arr = []\n for i,letter in enumerate(s):\n if i in ind :\n arr.append(letter.upper())\n else:\n arr.append(letter)\n return \"\".join(arr)", "def capitalize(s,ind):\n arr = []\n for i, el in enumerate(s):\n if i in ind:\n arr.append(el.upper())\n else:\n arr.append(el)\n return \"\".join(arr)", "def capitalize(s,ind):\n n = \"\"\n for i in range(len(s)):\n if i in ind:\n n += s[i].upper()\n else:\n n += s[i]\n return n", "def capitalize(s,ind):\n z=list(s)\n for i in ind:\n if i<len(s):\n z[i]=z[i].upper()\n return \"\".join(z)\n \n", "def capitalize(s, ind):\n new = list(s)\n for i in ind:\n if i > len(s):\n pass\n else:\n new[i] = new[i].upper()\n return ''.join(new)", "def capitalize(s,ind):\n st = ''\n for index, value in enumerate(s):\n if index in ind:\n st += s[index].upper()\n else:\n st += s[index]\n return st", "def capitalize(s,ind):\n str_lst = [letter for letter in s]\n for index in ind:\n try:\n str_lst[index] = str_lst[index].upper()\n except:\n pass\n return ''.join(str_lst)", "def capitalize(s,ind):\n return ''.join(s[i].upper() if i < len(s) and i in ind else s[i] for i in range(len(s)))", "def capitalize(s, ind):\n return ''.join([value.upper() if index in ind else value for index, value in enumerate(s)])", "def capitalize(s,ind):\n s_list = [ch for ch in s]\n for i in ind:\n try:\n s_list[i] = s_list[i].upper()\n except IndexError:\n pass\n return \"\".join(s_list)"] | {"fn_name": "capitalize", "inputs": [["abcdef", [1, 2, 5]], ["abcdef", [1, 2, 5, 100]], ["codewars", [1, 3, 5, 50]], ["abracadabra", [2, 6, 9, 10]], ["codewarriors", [5]], ["indexinglessons", [0]]], "outputs": [["aBCdeF"], ["aBCdeF"], ["cOdEwArs"], ["abRacaDabRA"], ["codewArriors"], ["Indexinglessons"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 17,990 |
def capitalize(s,ind):
|
623b7208f545065408c56e1c438cc80e | UNKNOWN | **An [isogram](https://en.wikipedia.org/wiki/Isogram)** (also known as a "nonpattern word") is a logological term for a word or phrase without a repeating letter. It is also used by some to mean a word or phrase in which each letter appears the same number of times, not necessarily just once.
You task is to write a method `isogram?` that takes a string argument and returns true if the string has the properties of being an isogram and false otherwise. Anything that is not a string is not an isogram (ints, nils, etc.)
**Properties:**
- must be a string
- cannot be nil or empty
- each letter appears the same number of times (not necessarily just once)
- letter case is not important (= case insensitive)
- non-letter characters (e.g. hyphens) should be ignored | ["from collections import Counter\nimport re\n\ndef is_isogram(word):\n if type(word) is not str or not word: return False\n return len(set( Counter(re.sub(r'[^a-z]', \"\", word.lower())).values() )) == 1", "from collections import Counter\n\ndef is_isogram(word):\n try:\n return len(set(Counter(filter(str.isalpha, word.lower())).values())) == 1\n except AttributeError:\n return False", "is_isogram=lambda s:1==isinstance(s,str)==len(set(__import__('collections').Counter(filter(str.isalpha,s.lower())).values()))", "def is_isogram(word):\n if not (word and isinstance(word, str)):\n return False\n word = word.lower()\n return len(set(word.count(c) for c in set(word) if c.isalpha())) == 1\n", "def is_isogram(word):\n if type(word) is str:\n if word is not None:\n w = ''.join(i.lower() for i in word if ord(i.lower()) in range(97,123) or ord(i.lower()) in range(48,58))\n if len(w) > 0:\n if len(w) % len(set(w)) == 0:\n return True\n return False\n", "import collections\n\ndef is_isogram(word):\n if not isinstance(word, str) or not word: return False\n counter = collections.Counter(c for c in word.lower() if c.isalpha())\n return len(set(count for c, count in counter.items())) == 1", "from collections import Counter\ndef is_isogram(word):\n if not isinstance(word, str): return False\n counts = Counter(filter(str.isalpha, word.lower()))\n return bool(counts) and min(counts.values()) == max(counts.values())", "def is_isogram(word):\n if type(word) != str or word == '':\n return False\n \n word = word.lower()\n cnts = [word.count(c) for c in word if c.isalpha()]\n return len(set(cnts)) == 1", "is_isogram = lambda word: type(word) == str and bool(word) and len(set( __import__(\"collections\").Counter( __import__(\"re\").sub(r'[^a-z]', \"\", word.lower())).values() )) == 1", "def is_isogram(word):\n try:\n word = word.lower()\n letters = [c for c in word if c.isalpha()]\n return len(set(word.count(c) for c in letters)) == 1\n except AttributeError:\n return False\n\n"] | {"fn_name": "is_isogram", "inputs": [[null], [3], ["Dermatoglyphics"], ["isogram"], ["eleven"], ["moOse"], ["isIsogram"], [""], ["-.-"], ["subdermatoglyphic"], ["Alphabet"], ["thumbscrew-japingly"], ["Hjelmqvist-Gryb-Zock-Pfund-Wax"], ["Emily Jung Schwartzkopf"], ["aabbccddeeffgg"]], "outputs": [[false], [false], [true], [true], [false], [false], [false], [false], [false], [true], [false], [true], [true], [true], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,176 |
def is_isogram(word):
|
0673936f59693d1f7b3cd3b76869d159 | UNKNOWN | Your task is to Combine two Strings. But consider the rule...
By the way you don't have to check errors or incorrect input values, everything is ok without bad tricks, only two input strings and as result one output string;-)...
And here's the rule:
Input Strings `a` and `b`: For every character in string `a` swap the casing of every occurrence of the same character in string `b`. Then do the same casing swap with the inputs reversed. Return a single string consisting of the changed version of `a` followed by the changed version of `b`. A char of `a` is in `b` regardless if it's in upper or lower case - see the testcases too.
I think that's all;-)...
Some easy examples:
````
Input: "abc" and "cde" => Output: "abCCde"
Input: "ab" and "aba" => Output: "aBABA"
Input: "abab" and "bababa" => Output: "ABABbababa"
````
Once again for the last example - description from `KenKamau`, see discourse;-):
a) swap the case of characters in string `b` for every occurrence of that character in string `a`
char `'a'` occurs twice in string `a`, so we swap all `'a'` in string `b` twice. This means we start with `"bababa"` then `"bAbAbA"` => `"bababa"`
char `'b'` occurs twice in string `a` and so string `b` moves as follows: start with `"bababa"` then `"BaBaBa"` => `"bababa"`
b) then, swap the case of characters in string `a` for every occurrence in string `b`
char `'a'` occurs `3` times in string `b`. So string `a` swaps cases as follows: start with `"abab"` then => `"AbAb"` => `"abab"` => `"AbAb"`
char `'b'` occurs `3` times in string `b`. So string `a` swaps as follow: start with `"AbAb"` then => `"ABAB"` => `"AbAb"` => `"ABAB"`.
c) merge new strings `a` and `b`
return `"ABABbababa"`
There are some static tests at the beginning and many random tests if you submit your solution.
Hope you have fun:-)! | ["def work_on_strings(a, b):\n new_a = [letter if b.lower().count(letter.lower()) % 2 == 0 else letter.swapcase() for letter in a]\n new_b = [letter if a.lower().count(letter.lower()) % 2 == 0 else letter.swapcase() for letter in b]\n return ''.join(new_a) + ''.join(new_b)", "from collections import Counter\n\ndef swap_them(a, b):\n cnt = Counter(b.lower())\n return \"\".join(c.swapcase() if cnt[c.lower()] % 2 else c for c in a)\n\ndef work_on_strings(a, b):\n return swap_them(a, b) + swap_them(b, a)", "def work_on_strings(a,b):\n A = list(a); B =list(b)\n #Forward Sort\n for i in range(len(A)):\n for j in range(len(B)):\n if A[i].upper() == B[j] or A[i].lower() == B[j]:\n B[j] = B[j].swapcase()\n #Backwards Sort\n for i in range(len(B)):\n for j in range(len(A)):\n if B[i].upper() == A[j] or B[i].lower() == A[j]:\n A[j] = A[j].swapcase()\n return \"\".join(str(i) for i in A+B)", "from collections import Counter\nimport re\n\ndef swaper(m): return m[0].swapcase()\ndef buildPattern(s): return f\"[{ ''.join(c for c,n in Counter(s.lower()).items() if n&1) or ' ' }]\"\ndef player(a,b): return re.sub(buildPattern(b), swaper, a, flags=re.I)\n\ndef work_on_strings(a,b): return player(a,b)+player(b,a)", "from collections import Counter\n\ndef work_on_strings(a, b):\n sa, sb = (\"\".join(x + x.upper() for x, y in Counter(s.lower()).items() if y % 2) for s in (a, b))\n return a.translate(str.maketrans(sb, sb.swapcase())) + b.translate(str.maketrans(sa, sa.swapcase()))", "work_on_strings=lambda a,b:''.join([elema if ((b.lower()).count(elema.lower()))%2==0 else elema.swapcase() for elema in a])+''.join([elemb if ((a.lower()).count(elemb.lower()))%2==0 else elemb.swapcase() for elemb in b])", "def work_on_strings(a,b):\n\n # New A and B\n corA = ''\n corB = ''\n\n # Hash table\n lettersA = {}\n lettersB = {}\n for ia in a.lower():\n lettersA[ia] = a.lower().count(ia)\n\n for ib in b.lower():\n lettersB[ib] = b.lower().count(ib)\n\n # For A\n for let in a:\n if let in lettersB.keys() and lettersB[let] % 2 != 0:\n corA += let.swapcase()\n elif let.isupper() == True and let.lower() in lettersB.keys():\n if lettersB[let.lower()] % 2 != 0:\n corA += let.lower()\n elif lettersB[let.lower()] % 2 == 0:\n corA += let.upper()\n else:\n corA += let\n # For B\n for let in b:\n if let in lettersA.keys() and lettersA[let] % 2 != 0:\n corB += let.swapcase()\n elif let.isupper() == True and let.lower() in lettersA.keys():\n if lettersA[let.lower()] % 2 != 0:\n corB += let.lower()\n elif lettersA[let.lower()] % 2 == 0:\n corB += let.upper()\n else:\n corB += let\n\n return corA + corB", "def work_on_strings(a,b):\n z = []\n for i in a:\n x = i\n for j in b:\n if i.upper()==j or i.lower()==j:\n x = x.swapcase()\n z.append(x)\n k = []\n for i in b:\n x = i\n for j in a:\n if i.upper()==j or i.lower()==j:\n x = x.swapcase()\n k.append(x)\n\n return ''.join(z)+''.join(k)", "def swapping(fir, sec):\n sf = set(fir)\n for ch in sf:\n occurs = fir.count(ch)\n if occurs%2 != 0 and ch in sec.lower():\n f =f\"{ch}{ch.upper()}\"\n s =f\"{ch.upper()}{ch}\" \n t = sec.maketrans(f, s)\n sec = sec.translate(t)\n return sec\n\ndef work_on_strings(a,b):\n return swapping(b.lower(),a)+ swapping(a.lower(),b)", "from collections import Counter\n\ndef swap(s1, s2):\n temp = [(\"\", \"\")] + [(f\"{k}{k.upper()}\", f\"{k.upper()}{k}\") for k,v in Counter(s1.lower()).items() if v&1]\n return s2.translate(str.maketrans(*map(''.join, zip(*temp))))\n\ndef work_on_strings(a,b):\n return swap(b, a) + swap(a, b)"] | {"fn_name": "work_on_strings", "inputs": [["abc", "cde"], ["abcdeFgtrzw", "defgGgfhjkwqe"], ["abcdeFg", "defgG"], ["abab", "bababa"]], "outputs": [["abCCde"], ["abcDeFGtrzWDEFGgGFhjkWqE"], ["abcDEfgDEFGg"], ["ABABbababa"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,079 |
def work_on_strings(a,b):
|
4ae56a6efc52a6b1347e15891a1eccfa | UNKNOWN | # Task
Determine the client's membership level based on the invested `amount` of money and the given thresholds for membership levels.
There are four membership levels (from highest to lowest): `Platinum, Gold, Silver, Bronze`
The minimum investment is the threshold limit for `Bronze` membership. If the given amount is less than the `Bronze` treshold limit return `Not a member`.
A client belongs to a membership level when his invested amount is greater than or equal the level's threshold amount.
# Examples:
```
|--------+----------+------+--------+--------+--------------+------------------|
| Amount | Platinum | Gold | Silver | Bronze | Result | Explanations |
|--------+----------+------+--------+--------+--------------+------------------|
| 7000 | 10000 | 8000 | 6000 | 4000 | Silver | Amount >= Silver |
| 3000 | 10000 | 8000 | 6000 | 5000 | Not a member | Amount < Bronze |
| 8000 | 12000 | 8000 | 7000 | 5000 | Gold | Amount >= Gold |
|--------+----------+------+--------+--------+--------------+------------------|
```
# Restrictions
1. The first line of your code has to be `def membership(amount, platinum, gold, silver, bronze):`
2. Your code except for the firt line mustn't contain the words `platinum, gold, silver, bronze` or they reversed forms (e.g. `dlog`) or any string which contains these words or they reversed forms. (The check is **case-insensitive**.)
3. Must not contain: `+, %, {, }`.
# Disclaimer
This kata is about creativity not proper coding style. Your colleagues/boss won't like you if you make production code like this. :)
#### Don't forget to rate the kata after you finish it. :)
Happy coding!
suic | ["def membership(amount, platinum, gold, silver, bronze):\n ordered = reversed(sorted((v, k) for k, v in locals().items() if k != 'amount'))\n return next((level.capitalize() for threshold, level in ordered if amount >= threshold), 'Not a member')", "def membership(amount, platinum, gold, silver, bronze):\n s1,s = dir(),locals()\n if s[s1[0]] >= s[s1[3]] : return s1[3].capitalize()\n if s[s1[0]] >= s[s1[2]] : return s1[2].capitalize()\n if s[s1[0]] >= s[s1[4]] : return s1[4].capitalize()\n if s[s1[0]] >= s[s1[1]] : return s1[1].capitalize()\n return \"Not a member\"", "def membership(amount, platinum, gold, silver, bronze):\n import inspect\n args = inspect.getargspec(membership).args\n l = locals()\n return next((a.title() for a in args[1:] if l[args[0]] >= l[a]), 'Not a member')", "def membership(amount, platinum, gold, silver, bronze):\n l = locals()\n a = l.pop('amount')\n try:\n return max((v, e) for e, v in l.items() if a >= v)[1].capitalize()\n except:\n return 'Not a member'", "def membership(amount, platinum, gold, silver, bronze):\n def res(i):\n return 'PGSBNloiroallottdvn i ezan re u mm e m b e r'[i::5].strip()\n for i in range(4, 0, -1):\n if (eval('apgsbmloiroalloutdvnni eztn re u m '[0::5])\n < eval('apgsbmloiroalloutdvnni eztn re u m '[i::5])):\n return res(i)\n return res(0)\n", "def membership(amount, platinum, gold, silver, bronze):\n import inspect\n frame = inspect.currentframe()\n args, _, _, values = inspect.getargvalues(frame)\n for i in reversed(list(range(1, 5))):\n if i > 1:\n if values[args[i-1]] > values[args[0]] >= values[args[i]]:\n return args[i].title()\n elif values[args[0]] >= values[args[i]]:\n return args[i].title()\n return \"Not a member\"\n", "def membership(amount, platinum, gold, silver, bronze):\n import inspect\n frame = inspect.currentframe()\n args, _, _, values = inspect.getargvalues(frame)\n if amount < values[args[4]]:\n return 'Not a member'\n elif amount < values[args[3]]:\n # bottom tier\n return ''.join([chr(66),chr(114),chr(111),chr(110),chr(122),chr(101)])\n elif amount < values[args[2]]:\n # third tier\n return ''.join([chr(83),chr(105),chr(108),chr(118),chr(101),chr( 114)])\n elif amount < values[args[1]]:\n # second tier\n return ''.join([chr(71),chr(111),chr(108),chr(100)])\n else:\n # top tier\n return ''.join([chr(80),chr(108),chr(97),chr(116),chr(105),chr(110),chr(117),chr(109)])", "def membership(amount, platinum, gold, silver, bronze):\n if amount<eval(''.join(['b','r','o','n','z','e'])):\n return 'Not a member'\n elif amount<eval(''.join(['s','i','l','v','e','r'])):\n return ''.join(['B','r','o','n','z','e'])\n elif amount<eval(''.join(['g','o','l','d'])):\n return ''.join(['S','i','l','v','e','r'])\n elif amount<eval(''.join(['p','l','a','t','i','n','u','m'])):\n return ''.join(['G','o','l','d'])\n else:\n return ''.join(['P','l','a','t','i','n','u','m'])", "def membership(amount, platinum, gold, silver, bronze):\n import inspect\n args_names = inspect.getfullargspec(membership).args\n \n for level in args_names[1:]: \n if amount >= locals().get(level): \n return level.capitalize()\n else: \n return \"Not a member\""] | {"fn_name": "membership", "inputs": [[100000, 1000000, 100000, 10000, 1000], [1001, 1000000, 100000, 10000, 1000], [998, 1000000, 100000, 10000, 1000], [0, 1000000, 100000, 10000, 1000]], "outputs": [["Gold"], ["Bronze"], ["Not a member"], ["Not a member"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,539 |
def membership(amount, platinum, gold, silver, bronze):
|
6f70403ada9aba33e2c2443817b335d7 | UNKNOWN | Create a method `sayHello`/`say_hello`/`SayHello` that takes as input a name, city, and state to welcome a person. Note that `name` will be an array consisting of one or more values that should be joined together with one space between each, and the length of the `name` array in test cases will vary.
Example:
```python
say_hello(['John', 'Smith'], 'Phoenix', 'Arizona')
```
This example will return the string `Hello, John Smith! Welcome to Phoenix, Arizona!` | ["def say_hello(name, city, state):\n return \"Hello, {}! Welcome to {}, {}!\".format(\" \".join(name), city, state)\n", "def say_hello(name, city, state):\n return f\"Hello, {' '.join(name)}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n return 'Hello, %s! Welcome to %s, %s!' % (' '.join(name), city, state)", "def say_hello(name, city, state):\n return 'Hello, ' + ' '.join(name) + '! Welcome to ' + city + ', ' + state + '!'", "def say_hello(name, city, state):\n greeting = \"Hello, {name}! Welcome to {city}, {state}!\".format(\n name=\" \".join(name),\n city=city,\n state=state\n )\n \n return greeting\n", "say_hello = lambda n, c, s: 'Hello, {}! Welcome to {}, {}!'.format(' '.join(n), c, s)", "def say_hello(name, city, state):\n greetName = ''\n for n in name:\n if n == name[-1]:\n greetName += n\n greetName += '!'\n else:\n greetName += n\n greetName += ' '\n return 'Hello, ' + greetName + ' Welcome to ' + city + ', ' + state + '!'", "def say_hello(name, city, state):\n name = \" \".join(name)\n return \"Hello, %s! Welcome to %s, %s!\" %(name,city,state)", "say_hello = lambda n, c, s: \"Hello, \" + \" \".join(n) + \"! Welcome to \" + c + \", \" + s + \"!\"", "from typing import List\n\ndef say_hello(name: List[str], city: str, state: str) -> str:\n \"\"\" Prepare a greeting based on input data. \"\"\"\n return \"Hello, {n}! Welcome to {c}, {s}!\".format(n=\" \".join(name), c=city, s=state)", "def say_hello(name, city, state):\n\n string=\"\".join([str(i)+ \" \" for i in name])\n string_neu=string[:-1]\n city=str(city)\n state=str(state)\n \n \n \n return (\"Hello, \" + string_neu +\"! Welcome to \" + city +\", \" + state + \"!\")", "def say_hello(name, city, state):\n aa = ' '.join(name)\n return ('Hello, ' + aa +'! Welcome to ' + city + ', ' + state + '!')", "def say_hello(name, city, state):\n name = \" \". join(name)\n return 'Hello, %(name)s! Welcome to %(city)s, %(state)s!'%vars()", "def say_hello(name, city, state):\n real_name = \"\"\n \n for n in name:\n real_name += n + \" \"\n \n return 'Hello, {0}! Welcome to {1}, {2}!'.format(real_name[:-1],city,state)", "def say_hello(name, city, state):\n kitas=' '.join(name)\n return f'Hello, {kitas}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n names = ''\n for i in name:\n names += i + ' '\n names = names.rstrip()\n return \"Hello, {names}! Welcome to {city}, {state}!\".format(names = names, city = city, state = state)", "def say_hello(name, city, state):\n str_name = \"\"\n for i in name:\n str_name += i + \" \"\n str_name = str_name[:-1]\n return \"Hello, {name}! Welcome to {city}, {state}!\".format(name = str_name, city=city, state=state)", "def say_hello(name, city, state):\n return \"Hello,\" + (\" {}\"*len(name)).format(*name)+f\"! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n a = ' '.join(name)\n return f'Hello, {a}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n return ('Hello, ' + ' '.join(name) + f'! Welcome to {city}, {state}!')", "def say_hello(name, city, state):\n element = \"\"\n for x in name:\n element = element + x + \" \"\n element = element[:-1] \n return(\"Hello, \"+element+\"!\"+\" Welcome to \"+city+\", \"+state+\"!\")", "def say_hello(name, city, state):\n nameS = \" \".join(name)\n return f\"Hello, {nameS}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n return 'Hello, %s! Welcome to %s, %s!'%(' '.join(n for n in name), city, state)\n", "def say_hello(name, city, state):\n who = ' '.join(name)\n return f'Hello, {who}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n st='Hello, '+' '.join(name)+'! Welcome to '+city+', '+state+'!'\n return st", "def say_hello(name, city, state):\n string = ' '\n string1 = string.join(name)\n return \"Hello, {string1}! Welcome to {city}, {state}!\".format(string1=string1, city=city, state=state)", "def say_hello(name, city, state):\n lis = []\n lis.append(\"Hello,\")\n lis.append(\" \".join(name)+\"!\")\n lis.append(\"Welcome to\")\n lis.append(city+\",\")\n lis.append(state+\"!\")\n return \" \".join(lis)", "def say_hello(name, city, state):\n n = \"\" \n for el in name:\n n += \" \" + el\n return f'Hello,{n}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n fl= \" \".join(n for n in name)\n return f\"Hello, {fl}! Welcome to {city}, {state}!\" ", "def say_hello(name, city, state):\n name = \" \".join(name) \n print(name)\n return f\"Hello, {name}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n satz = \" \".join(name)\n return \"Hello, \" + satz + \"! Welcome to \" + city + \", \" + state + \"!\"", "def say_hello(name, city, state):\n names = ' '.join(name)\n a = \"Hello, {}! Welcome to {}, {}!\".format(names, city, state)\n return a", "def say_hello(name, city, state):\n separator = ' '\n name_1 = separator.join(name) \n return f'Hello, {name_1}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n string = ' '.join(name)\n return f'Hello, {string}! Welcome to {city}, {state}!'\n", "def say_hello(name, city, state):\n full_name = ''\n for n in name:\n full_name += n\n full_name += ' '\n return 'Hello, {}! Welcome to {}, {}!'.format(full_name[:-1], city, state)", "def say_hello(name, city, state):\n c=\"\"\n for x in name:\n c=c+x+\" \"\n c=c.rstrip(\" \")\n return \"Hello, \"+c+\"! Welcome to \"+city+\", \"+state+\"!\"", "def say_hello(name, city, state):\n fullname = (' '.join(name))\n return f'Hello, {fullname}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n full_name = ''\n for i in range(len(name)):\n full_name +=name[i]+' '\n if full_name[-1] ==' ':\n full_name = full_name[:-1]\n return 'Hello, {}! Welcome to {}, {}!'.format(full_name, city, state)", "def say_hello(name, city, state):\n name1=\" \".join(name)\n return \"Hello, {}! Welcome to {}, {}!\".format(name1,city,state)", "def say_hello(name, city, state):\n full = name[0]\n for x in range(len(name) - 1) :\n full = full + \" \" + name[x + 1]\n return f\"Hello, {full}! Welcome to {city}, {state}!\"", "def say_hello(n,c,s):\n return ''.join(f\"Hello, {' '.join(n)}! Welcome to {c}, {s}!\")", "def say_hello(name, city, state):\n return 'Hello, {x}! Welcome to {city}, {state}!'.format(x=' '.join(name), city=city, state=state)\n", "def say_hello(name, city, state):\n \n return \"Hello, \" + \" \".join(str(item) for item in name) +\"!\" + \" Welcome to \" + city + \", \" + state +\"!\"", "def say_hello(name, city, state):\n res = \"Hello, \"\n for n in name:\n res += n + \" \"\n res = res[:-1]\n res += \"! Welcome to \"\n res += city + \", \"\n res += state + \"!\"\n return res", "def say_hello(name, city, state):\n n = \"\"\n for i in range(len(name)):\n n = n + \" \" + name[i]\n \n return f'Hello, {n[1:]}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n x = \"\"\n for i in name:\n x += i+\" \"\n y = x.strip()\n return \"Hello, {}! Welcome to {}, {}!\".format(y, city, state)", "def say_hello(name, city, state):\n strname = \" \".join(str(x) for x in name) \n return 'Hello, ' + strname + '! Welcome to ' + str(city) + ', ' + str(state) + '!'", "def say_hello(name, city, state):\n return f'Hello, {\" \".join(name).strip(\" \")}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n newname = ' '.join(name)\n return f'Hello, {newname}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n \"\"\"\n hello\n \"\"\"\n return \"Hello, {}! Welcome to {}, {}!\".format(\" \".join(name), city, state)", "def say_hello(name, city, state):\n x = \"Hello, {}! Welcome to \" + city + \", \" + state + \"!\"\n temp = \"\"\n for i in name:\n temp+=i+\" \"\n temp = temp[:-1]\n z = x.format(temp)\n return z", "def say_hello(name, city, state):\n nombre=' '.join(x for x in name)\n return (f'Hello, {nombre}! Welcome to {city}, {state}!')", "def say_hello(name, city, state):\n name_str = \" \".join(name)\n return f\"Hello, {name_str}! Welcome to {city}, {state}!\"", "import unittest\n\n\ndef say_hello(name, city, state):\n name = ' '.join(name)\n city_and_state = ', '.join([city, state])\n return f'Hello, {name}! Welcome to {city_and_state}!'\n \n \nclass TestSayHello(unittest.TestCase):\n def test_say_hello(self):\n name, city, state = ['John', 'Smith'], 'Phoenix', 'Arizona'\n actual = say_hello(name, city, state)\n self.assertEqual(actual, 'Hello, John Smith! Welcome to Phoenix, Arizona!')\n", "def say_hello(name, city, state):\n\n blk = \" \"\n return \"Hello, \" + blk.join(name) + \"! Welcome to \" + city + \", \" + state + \"!\"", "def say_hello(name, city, state):\n s = \" \".join(name)\n return f\"Hello, {s}! Welcome to {city}, {state}!\"\n\n", "def say_hello(name, city, state):\n word =\"Hello, \"\n for i in name:\n word += str(i) + \" \"\n result =word[:-1]\n result +=\"! Welcome to \" + str(city) + \", \" + str(state) + \"!\" \n return result", "def say_hello(name, city, state):\n \n welcome = (\" Welcome to \"+ city+\", \" + state + \"!\")\n names = \" \".join(name)\n \n return \"Hello, \"+names+\"!\" + welcome", "def say_hello(name, city, state):\n str_name = ' '.join(name)\n return \"Hello, {str_name}! Welcome to {city}, {state}!\".format(str_name = str_name, city = city, state = state)\nprint(say_hello(['John', 'Smith'], 'Phoenix', 'Arizona'))", "def say_hello(name, city, state):\n #your code here\n nama = \" \".join(name)\n kota = \"\".join(city)\n nega = \"\".join(state)\n \n return \"Hello, \"+ nama +\"! Welcome to \"+ kota+\", \"+ state+\"!\"", "def say_hello(name, city, state):\n greeting = f\"Hello, {' '.join(name)}! Welcome to {city}, {state}!\"\n return greeting", "def say_hello(name, city, state):\n return 'Hello, ' + ' '.join(name) + '! ' + f'Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n str1 = ' '.join(name)\n return(f'Hello, {str1}! Welcome to {city}, {state}!')", "def say_hello(name, city, state):\n return f'Hello, {\" \".join(n for n in name)}! Welcome to {city}, {state}!'\n", "def say_hello(name, city, state):\n x = ' '.join(n for n in name)\n return f\"Hello, {x}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n nm = ' '.join(name)\n return f\"Hello, {nm}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n full_name = ' '.join(elt for elt in name)\n return 'Hello, %s! Welcome to %s, %s!' % (full_name, city, state)", "def say_hello(name, city, state):\n full_name = \"\"\n for i in name:\n full_name += f\" {i}\"\n return f\"Hello,{full_name}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n name = \" \".join([n for n in name])\n return f\"Hello, {name}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n n = \"\"\n for i in name:\n n = n + \" \" + i\n txt = \"Hello,\" + n + \"! Welcome to {}, {}!\"\n return txt.format(city,state)", "def say_hello(name, city, state):\n return \"Hello, %s! Welcome to %s, %s!\" % (' '.join(s for s in name), city, state)", "def say_hello(name, city, state):\n a=' '.join(name)+'!'\n r= 'Hello, '+str(a) +' Welcome to {}, {}!'.format(city,state)\n return ''.join(r)", "def say_hello(name, city, state):\n l = ' '.join(name)\n return f'Hello, {l}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n nstr = \"\"\n c = city\n s = state\n for n in name:\n nstr += n + \" \"\n nstr = nstr.strip()\n txt = 'Hello, {}! Welcome to {}, {}!'\n return txt.format(nstr, c, s)", "def say_hello(name, city, state):\n \n new_name = ''\n \n for x in name:\n if x != name[-1]:\n new_name += (x + ' ')\n \n else:\n new_name += x\n \n return 'Hello, ' + new_name + '! Welcome to ' + city + ', ' + state + '!'", "def say_hello(name, city, state):\n x= ' '.join(name)\n return ('Hello, ' + str(x) + '!'+' '+'Welcome to ' + str(city) +', '+ str(state) +'!' )", "def say_hello(name, city, state):\n name_=''\n for i in name:\n name_+=i+' '\n name_=name_[:-1]\n return 'Hello, {}! Welcome to {}, {}!'.format(name_, city, state)", "def say_hello(name, city, state):\n cunt = ' '.join(name)\n return f\"Hello, {cunt}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n #your code here\n name1 = ' '.join(name)\n return f'Hello, {name1}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n name = ' '.join(part for part in name)\n return f'Hello, { name }! Welcome to {city}, {state}!'", "from typing import List\n\n\ndef say_hello(name: List[str], city: str, state: str) -> str:\n return f\"Hello, {' '.join(name)}! Welcome to {city}, {state}!\"\n", "def say_hello(name, city, state):\n x = \"Hello, \" , ' '.join(name) , \"! Welcome to \", city , \", \" , state , \"!\"\n return ''.join(x)", "def say_hello(name, city, state):\n space = \" \"\n return \"Hello, \" + space.join(name) + \"! Welcome to \" + city + \", \" + state + \"!\"", "def say_hello(name, city, state):\n fname = ' '.join(name)\n return f'Hello, {fname}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n \n return f\"Hello, {' '.join(ad for ad in name)}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n som = 'Hello, {joo}! Welcome to {naem}, {state}!'.format(joo = ' '.join(name), naem = city, state = state)\n return som\n#your code here\n", "def say_hello(name, city, state):\n namestring = \" \".join(name)\n return f'Hello, {namestring}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n a = ''\n for x in range(0,len(name)):\n a = a + ' ' + ''.join(name[x])\n return 'Hello, ' + a[1:] + '! Welcome to ' + city + ', ' + state + '!' \n \n", "def say_hello(name, city, state):\n b = ' '.join(name)\n return 'Hello, {}! Welcome to {}, {}!'.format(b,city,state)", "def say_hello(name, city, state):\n full_name = ''\n for index, word in enumerate(name):\n full_name += name[index]\n if index < len(name) -1:\n full_name += ' '\n text = 'Hello, ' + full_name + '! Welcome to ' + city + ', ' + state + '!'\n return text", "def say_hello(name, city, state):\n \n txt1 = 'Hello, {} {} {}! Welcome to {}, {}!'\n txt2 = 'Hello, {} {}! Welcome to {}, {}!'\n txt3 = 'Hello, {} {} {} {}! Welcome to {}, {}!'\n \n \n l = len(name)\n \n if l == 3:\n return txt1.format(name[0], name[1], name[2], city, state)\n elif l == 4:\n return txt3.format(name[0], name[1], name[2], name[3], city, state)\n else:\n return txt2.format(name[0], name[1], city, state)", "def say_hello(name, city, state):\n name = ' '.join (i for i in name)\n return f'Hello, {name}! Welcome to {city}, {state}!'", "def say_hello(name, city, state):\n x = \" \"\n y = x.join(name)\n return \"Hello, {}! Welcome to {}, {}!\".format(y, city, state)", "def say_hello(name, city, state):\n nam=''\n if len(name)==2:\n nam=name[0]+' '+name[1]\n elif len(name)==3:\n nam=name[0]+' '+name[1]+' '+name[2]\n elif len(name)==4:\n nam=name[0]+' '+name[1]+' '+name[2]+' '+name[3]\n elif len(name)==5:\n nam=name[0]+' '+name[1]+' '+name[2]+' '+name[3]+' '+name[4]\n \n return f\"Hello, {nam}! Welcome to {city}, {state}!\"", "def say_hello(name, city, state):\n name_join = ' '.join([x for x in name])\n sentence = 'Hello, {}! Welcome to {}, {}!'.format(name_join, city, state)\n return sentence", "def say_hello(name, city, state):\n \n name = \" \".join(name)\n \n return \"Hello,\" + \" \" + name+ \"!\" +\" Welcome to\"+ \" \" + city + \",\"+\" \" + state + \"!\"", "def say_hello(name, city, state):\n\n new_name = ' '.join(name)\n return 'Hello, {}! Welcome to {}, {}!'.format(new_name, city, state)\n", "def say_hello(name, city, state):\n k = ' '.join(name)\n return f'Hello, {k}! Welcome to {city}, {state}!'", "def say_hello(n, c, s):\n b = ''\n for i in range(len(n)):\n b += ' ' + n[i]\n return 'Hello,' + b +'! Welcome to ' + c + ', ' + s +'!'"] | {"fn_name": "say_hello", "inputs": [[["John", "Smith"], "Phoenix", "Arizona"], [["Franklin", "Delano", "Roosevelt"], "Chicago", "Illinois"], [["Wallace", "Russel", "Osbourne"], "Albany", "New York"], [["Lupin", "the", "Third"], "Los Angeles", "California"], [["Marlo", "Stanfield"], "Baltimore", "Maryland"]], "outputs": [["Hello, John Smith! Welcome to Phoenix, Arizona!"], ["Hello, Franklin Delano Roosevelt! Welcome to Chicago, Illinois!"], ["Hello, Wallace Russel Osbourne! Welcome to Albany, New York!"], ["Hello, Lupin the Third! Welcome to Los Angeles, California!"], ["Hello, Marlo Stanfield! Welcome to Baltimore, Maryland!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 16,928 |
def say_hello(name, city, state):
|
a3afe85712a9e85e252da13214327ea2 | UNKNOWN | Finding your seat on a plane is never fun, particularly for a long haul flight... You arrive, realise again just how little leg room you get, and sort of climb into the seat covered in a pile of your own stuff.
To help confuse matters (although they claim in an effort to do the opposite) many airlines omit the letters 'I' and 'J' from their seat naming system.
the naming system consists of a number (in this case between 1-60) that denotes the section of the plane where the seat is (1-20 = front, 21-40 = middle, 40+ = back). This number is followed by a letter, A-K with the exclusions mentioned above.
Letters A-C denote seats on the left cluster, D-F the middle and G-K the right.
Given a seat number, your task is to return the seat location in the following format:
'2B' would return 'Front-Left'.
If the number is over 60, or the letter is not valid, return 'No Seat!!'. | ["def plane_seat(a):\n front, middle, back = (list(range(1,21)), list(range(21,41)), list(range(41,61)))\n left, center, right = ('ABC', 'DEF', \"GHK\")\n x, y = ('', '')\n \n if int(a[:-1]) in front: x = 'Front-'\n if int(a[:-1]) in middle: x = 'Middle-'\n if int(a[:-1]) in back: x = 'Back-'\n\n if a[-1] in left: y = 'Left'\n if a[-1] in center: y = 'Middle'\n if a[-1] in right: y = 'Right'\n \n return x+y if all((x,y)) else 'No Seat!!'\n", "def plane_seat(a):\n n, c = int(a[:-1]), a[-1]\n side = \"Left\" if c in \"ABC\" else \"Middle\" if c in \"DEF\" else \"Right\" if c in \"GHK\" else \"\"\n depth = \"Front\" if 0 < n < 21 else \"Middle\" if 20 < n < 41 else \"Back\" if 40 < n < 61 else \"\"\n return f\"{depth}-{side}\" if depth and side else \"No Seat!!\"\n", "def plane_seat(a):\n section = ['Front','Middle','Back',None]\n cluster = {'ABC':'Left','DEF':'Middle','GHK':'Right'}\n my_section = section[((int(a[:-1])-1)//20)]\n my_cluster = [v for k,v in cluster.items() if a[-1].upper() in k]\n return \"No Seat!!\" if not (my_section and my_cluster) else \"{}-{}\".format(my_section,my_cluster[0])", "def plane_seat(a):\n row = int(a[:-1])\n seat = a[-1]\n \n if row > 60 or seat not in 'ABCDEFGHK':\n return 'No Seat!!'\n \n if row <= 20:\n end = 'Front'\n elif row <= 40:\n end = 'Middle'\n else:\n end = 'Back'\n \n if seat in 'ABC':\n side = 'Left'\n elif seat in 'DEF':\n side = 'Middle'\n else:\n side = 'Right'\n \n return f'{end}-{side}'\n\n\n", "def plane_seat(a):\n num, alpha = int(a[:-1]), a[-1]\n if num > 60 or alpha in 'IJ' or alpha > 'K':\n return 'No Seat!!'\n section = ('Front', 'Middle', 'Back')[(num > 20) + (num > 40)]\n cluster = ('Left', 'Middle', 'Right')[(alpha > 'C') + (alpha > 'F')]\n return f'{section}-{cluster}'", "def plane_seat(a):\n try:\n number, letter = a[:-1], a[-1]\n number = int(number)\n if not 1<=number<=60 or not letter in 'ABCDEFGHK':\n return 'No Seat!!'\n result = []\n return '-'.join(('Front' if number<=20 else 'Middle' if number<=40 else 'Back',\n 'Left' if letter in 'ABC' else 'Middle' if letter in 'DEF' else 'Right'))\n except:\n return 'No Seat!!'\n \n", "CLUSTERS = {\n 'A': 'Left',\n 'B': 'Left',\n 'C': 'Left',\n 'D': 'Middle',\n 'E': 'Middle',\n 'F': 'Middle',\n 'G': 'Right',\n 'H': 'Right',\n 'K': 'Right',\n}\n\ndef plane_seat(a):\n row = int(a[:-1])\n col = a[-1:]\n section = (\n 'Front' if row <= 20 else\n 'Middle' if row <= 40 else\n 'Back' if row <= 60 else\n ''\n )\n cluster = CLUSTERS.get(col)\n if section and cluster:\n return f'{section}-{cluster}'\n else:\n return 'No Seat!!'", "def plane_seat(a):\n n , l = int(a[:-1]), a[-1]\n if n > 60 or l not in \"ABCDEFGHK\": return \"No Seat!!\"\n n = 'Front' if n < 21 else 'Middle' if n < 40 else 'Back'\n l = \"Left\" if l < \"D\" else \"Middle\" if l < \"G\" else \"Right\"\n return \"{}-{}\".format(n,l)", "# import this\n# \u042f\u0432\u043d\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043d\u0435\u044f\u0432\u043d\u043e\u0435.\n# \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0435.\n# \u0415\u0441\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u2014 \u0438\u0434\u0435\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0445\u043e\u0440\u043e\u0448\u0430.\ndef plane_seat(a):\n num2 = a[0] + a[1]\n num1 = a[0]\n let = a[-1]\n if let == 'I' or let == 'J':\n return ('No Seat!!')\n elif len(a) == 3:\n if int(num2) > 60:\n return ('No Seat!!')\n elif int(num2) >= 1 and int(num2) <= 20:\n if let == 'A' or let == 'B' or let == 'C':\n return ('Front-Left')\n if let == 'D' or let == 'E' or let == 'F':\n return ('Front-Middle')\n if let == 'G' or let == 'H' or let == 'K':\n return ('Front-Right') \n elif int(num2) >= 21 and int(num2) <= 40:\n if let == 'A' or let == 'B' or let == 'C':\n return ('Middle-Left')\n if let == 'D' or let == 'E' or let == 'F':\n return ('Middle-Middle')\n if let == 'G' or let == 'H' or let == 'K':\n return ('Middle-Right')\n elif int(num2) >= 41 and int(num2) <= 60:\n if let == 'A' or let == 'B' or let == 'C':\n return ('Back-Left')\n if let == 'D' or let == 'E' or let == 'F':\n return ('Back-Middle')\n if let == 'G' or let == 'H' or let == 'K':\n return ('Back-Right') \n elif len(a) == 2:\n if int(num1) >= 1 and int(num1) <= 20:\n if let == 'A' or let == 'B' or let == 'C':\n return ('Front-Left')\n if let == 'D' or let == 'E' or let == 'F':\n return ('Front-Middle')\n if let == 'G' or let == 'H' or let == 'K':\n return ('Front-Right') \n \n''' \n1-20 - front\n21-40 - middle\n41-60 - back\n\nA,B,C - left\nD,E,F - middle\nG,H,K - right\n'''\n\n", "# What do you mean computationally wasteful?\ndef plane_seat(a):\n return {\n f'{row}{seat}': f'{end}-{side}'\n for end, rows in [('Front', list(range(1, 21))), ('Middle', list(range(21, 41))), ('Back', list(range(41, 61)))]\n for row in rows\n for side, seats in [('Left', 'ABC'), ('Middle', 'DEF'), ('Right', 'GHK')]\n for seat in seats\n }.get(a, 'No Seat!!')\n"] | {"fn_name": "plane_seat", "inputs": [["2B"], ["20B"], ["58I"], ["60D"], ["17K"]], "outputs": [["Front-Left"], ["Front-Left"], ["No Seat!!"], ["Back-Middle"], ["Front-Right"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 5,991 |
def plane_seat(a):
|
3cccdbc2d737aea620d103ef5a7c01de | UNKNOWN | We define the function `f1(n,k)`, as the least multiple of `n` that has all its digits less than `k`.
We define the function `f2(n,k)`, as the least multiple of `n` that has all the digits that are less than `k`.
Each digit may occur more than once in both values of `f1(n,k)` and `f2(n,k)`.
The possible values for `n` and `k` according to these ranges for both functions `f1` and `f2` in this kata:
```
1 <= n <= 1.000.000.000.000
3 <= k <= 9
```
For example, let's see the value of both functions for `n = 71` and `k = 4`:
```
f1(71,4) == 213 # all its digits less than 4
f2(71,4) == 2130 # 0,1,2,3 all of them present
```
The integer `76` is the first integer that has the same values of `f1` and `f2` for `k = 4`.
```
f1(76,4) = f2(76,4) = 10032
```
Let's call these kind of numbers, **forgiving numbers**. (Let's continue with the fashion of attributing personality traits to numbers and, of course, an unknown one)
So, `76` is the smallest forgiving number of order `4`.
In the same way, `485` is the smallest forgiving number of order `5`.
Create a function that given an integer `n` and the order `k`, will output the higher and closest forgiving number to `n` of order `k`.
Let's see some examples:
```
find_f1_eq_f2(500,5) == 547
find_f1_eq_f2(1600,6) == 1799
find_f1_eq_f2(14900,7) == 14996
```
If the number `n` is a forgiving itself for a certain order `k`, the function will never output the same value, remember, closest and **higher** than `n`.
For example, `3456`, is a forgiving one of order `4`,
```
find_f1_eq_f2(3456,4) == 3462
```
**Features of the tests:**
* `n` and `k` will be always valid and positive integers.
* A total of 8 fixed tests.
* A total of 150 random tests in the ranges for `n` and `k` given above.
I'll be waiting your awesome solution. :) | ["def find_f1_eq_f2(n,k):\n s = set(range(k))\n while True:\n n += 1\n testn = n\n while True:\n f = set(map(int,str(testn)))\n if f<=s:\n if f==s: return n\n break\n testn += n", "def find_f1_eq_f2(n,k):\n s = set(range(k))\n while True:\n n += 1\n new = n\n while True:\n ns = set(map(int, str(new)))\n if ns < s:\n break\n elif ns == s:\n return n\n new += n\n return n\n", "from itertools import count\nfrom string import digits\n\ndef f12(n, k):\n valid_digits = set(digits[:k])\n for x in count(n, n):\n s = str(x)\n if valid_digits.issuperset(s):\n return valid_digits.issubset(s)\n\ndef find_f1_eq_f2(n, k):\n return next(i for i in count(n + 1) if f12(i, k))", "from itertools import count\n\ndef find_f1_eq_f2(n, k):\n for x in count(n+1):\n for y in count(x, x):\n if all(map(lambda c: int(c) < k, str(y))):\n if len(set(str(y))) == k: return x\n else: break", "from itertools import count\n\ndef find_f1_eq_f2(n, k):\n digits = set(map(str, range(k)))\n for n in count(n + 1):\n for m in map(set, map(str, count(n, n))):\n if m <= digits:\n if len(m) == len(digits): return n\n break", "def f1(n,k):\n n_i = n\n while True: \n if all(int(c) < k for c in str(n_i)): \n return n_i\n n_i += n\n \ndef f2(n,k):\n n_i = n\n while True:\n if set(str(n_i)) == set(str(d) for d in range(k)): \n return n_i\n n_i += n\n\ndef find_f1_eq_f2(n,k):\n n_i = n + 1\n while True: \n if f1(n_i,k) == f2(n_i,k):\n return n_i\n n_i += 1 \n", "from itertools import count\ndef find_f1_eq_f2(n,k):\n is_f1=lambda n,k:max(map(int,str(n)))<k\n is_f2=lambda n,k:set(str(n))==set(map(str,range(0,k)))\n for i in count(n+1):\n for j in count(1):\n f1,f2=is_f1(i*j,k),is_f2(i*j,k)\n if f1^f2:break\n elif f1 and f2:return i", "def less_than(n, k):\n return all(int(x) < k for x in str(n))\n \ndef has_all(n, k):\n s = str(n)\n for i in range(10):\n if i < k and str(i) not in s:\n return False\n if i >= k and str(i) in s:\n return False\n return True\n \ndef f1(n, k):\n cn = n\n while not less_than(cn, k):\n cn += n\n return cn\n\ndef f2(n, k):\n cn = n\n while not has_all(cn, k):\n cn += n\n return cn\n\n\ndef find_f1_eq_f2(n,k):\n n += 1\n while f1(n, k) != f2(n, k):\n n += 1\n return n\n \n \n", "def digits_less_than(n,k):\n for i in str(n):\n if int(i) >= k:\n return False\n return True\n\ndef all_digits_less_than(n,d):\n for i in d:\n if i not in str(n):\n return False\n return True\n\ndef find_f1_eq_f2(n,k):\n d = '012'\n for i in range(3,k):\n d += str(i)\n m = 0\n i = 0\n while not all_digits_less_than((m+n)*i,d):\n m += 1\n i = 1\n while not digits_less_than((m+n)*i,k):\n i += 1\n return m+n"] | {"fn_name": "find_f1_eq_f2", "inputs": [[542, 5], [1750, 6], [14990, 7], [3456, 4], [30500, 3], [62550, 5], [568525, 7], [9567100, 8]], "outputs": [[547], [1799], [14996], [3462], [30501], [62557], [568531], [9567115]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,327 |
def find_f1_eq_f2(n,k):
|
f1638026a4715534aab5fb99457bb459 | UNKNOWN | Given a string as input, move all of its vowels to the end of the string, in the same order as they were before.
Vowels are (in this kata): `a, e, i, o, u`
Note: all provided input strings are lowercase.
## Examples
```python
"day" ==> "dya"
"apple" ==> "pplae"
``` | ["def move_vowels(s): \n return ''.join(sorted(s, key=lambda k: k in 'aeiou'))", "import re\n\ndef move_vowels(input):\n return ''.join(''.join(l) for l in zip(*re.findall(r'([^aeiou])?([aeiou])?', input)))", "def move_vowels(i): \n s, v = '', ''\n for letter in i:\n if letter in 'aeiou': v+=letter\n else: s+=letter\n return s+v\n", "import re\n\ndef move_vowels(input): \n consonants = re.sub(r'[aeiou]', '', input)\n vowels = re.sub(r'[^a^e^i^o^u]', '', input)\n return consonants + vowels", "import re\n\ndef move_vowels(input): \n consonants, vowels = re.sub(r'[aeiou]', '', input), re.sub(r'[^aeiou]', '', input)\n return consonants + vowels", "def move_vowels(s):\n return \"\".join(sorted(s, key=lambda x: x in \"aiueo\"))", "def move_vowels(input): \n return \"\".join(sorted(input, key=lambda c: c in \"aeiou\"))", "def move_vowels(input): \n return ''.join(c for c in input if c not in 'aeiou')+''.join(c for c in input if c in 'aeiou')", "def move_vowels(input):\n return \"\".join(sorted(input, key=\"aeiou\".__contains__))", "def move_vowels(input): \n non_vowels = input.translate(str.maketrans('', '', 'aeiou'))\n vowels = input.translate(str.maketrans('', '', non_vowels))\n return non_vowels + vowels\n"] | {"fn_name": "move_vowels", "inputs": [["day"], ["apple"], ["peace"], ["maker"], ["programming"], ["javascript"], ["python"], ["ruby"], ["haskell"], ["clojure"], ["csharp"]], "outputs": [["dya"], ["pplae"], ["pceae"], ["mkrae"], ["prgrmmngoai"], ["jvscrptaai"], ["pythno"], ["rbyu"], ["hskllae"], ["cljroue"], ["cshrpa"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,288 |
def move_vowels(input):
|
cb8fc72eb481061a17e0cbd8a1ed578a | UNKNOWN | Your task is to construct a building which will be a pile of n cubes.
The cube at the bottom will have a volume of n^3, the cube above
will have volume of (n-1)^3 and so on until the top which will have a volume of 1^3.
You are given the total volume m of the building.
Being given m can you find the number n of cubes you will have to build?
The parameter of the function findNb `(find_nb, find-nb, findNb)` will be an integer m
and you have to return the integer n such as
n^3 + (n-1)^3 + ... + 1^3 = m
if such a n exists or -1 if there is no such n.
## Examples:
```
findNb(1071225) --> 45
findNb(91716553919377) --> -1
``` | ["def find_nb(m):\n n = 1\n volume = 0\n while volume < m:\n volume += n**3\n if volume == m:\n return n\n n += 1\n return -1", "def find_nb(m):\n n=s=0\n while True:\n n+=1\n s+=n\n k=s*s\n if k== m:\n return n\n elif k>m:\n return -1 \n", "def find_nb(m):\n i,sum = 1,1\n while sum < m:\n i+=1\n sum+=i**3\n return i if m==sum else -1", "def find_nb(m):\n '''\n n cube sum m = (n*(n+1)//2)**2\n then n**2 < 2*m**0.5 < (n+1)**2\n and we can proof that for any n, 0.5 > (2*m**0.5)**0.5 - n**2 > 2**0.5 - 1 > 0.4\n '''\n n = int((2*m**0.5)**0.5)\n if (n*(n+1)//2)**2 != m: return -1\n return n", "def find_nb(m):\n total, i = 1, 2\n while total < m:\n total += i * i * i\n i += 1\n return i - 1 if total == m else -1", "def find_nb(m):\n n = 0\n while (m > 0):\n n += 1\n m -= n**3\n return n if m == 0 else -1", "def find_nb(m):\n l = 1\n while m > 0:\n m -= l**3\n l += 1\n return l-1 if m == 0 else -1", "def find_nb(m):\n try:\n vol = int(m)\n except TypeError:\n return -1\n \n partial_sum = 0\n i = 0\n while partial_sum < vol:\n i += 1\n partial_sum += i**3\n \n if vol == partial_sum:\n return i\n else:\n return -1", "from decimal import *\n\ndef find_nb(m):\n getcontext().prec = 24\n squareRootM = Decimal(m).sqrt()\n squareRootDelta = Decimal(1+8*squareRootM).sqrt()\n num = (squareRootDelta-1)/2\n return num if num % 1 == 0 else -1"] | {"fn_name": "find_nb", "inputs": [[4183059834009], [24723578342962], [135440716410000], [40539911473216], [26825883955641], [41364076483082], [9541025211025], [112668204662785], [79172108332642], [1788719004901], [131443152397956], [1801879360282], [18262169777476], [11988186060816], [826691919076], [36099801072722], [171814395026], [637148782657], [6759306226], [33506766981009], [108806345136785], [14601798712901], [56454575667876], [603544088161], [21494785321], [1025292944081385001], [10252519345963644753025], [10252519345963644753026], [102525193459636447530260], [4], [16]], "outputs": [[2022], [-1], [4824], [3568], [3218], [-1], [2485], [-1], [-1], [-1], [4788], [-1], [2923], [2631], [1348], [-1], [-1], [-1], [-1], [3402], [-1], [-1], [3876], [1246], [541], [45001], [450010], [-1], [-1], [-1], [-1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,625 |
def find_nb(m):
|
5615439bd11181a53012ffbdd5355323 | UNKNOWN | > [Run-length encoding](https://en.wikipedia.org/w/index.php?title=Run-length_encoding) (RLE) is a very simple form of data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run. Wikipedia
## Task
Your task is to write such a run-length encoding. For a given string, return a list (or array) of pairs (or arrays)
[
(i1, s1),
(i2, s2),
…,
(in, sn)
], such that one can reconstruct the original string by replicating the character sx ix times and concatening all those strings. Your run-length encoding should be minimal, ie. for all i the values si and si+1 should differ.
## Examples
As the article states, RLE is a _very_ simple form of data compression. It's only suitable for runs of data, as one can see in the following example:
```python
run_length_encoding("hello world!")
//=> [[1,'h'], [1,'e'], [2,'l'], [1,'o'], [1,' '], [1,'w'], [1,'o'], [1,'r'], [1,'l'], [1,'d'], [1,'!']]
```
It's very effective if the same data value occurs in many consecutive data elements:
```python
run_length_encoding("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbb")
# => [[34,'a'], [3,'b']]
``` | ["from itertools import groupby\n\ndef run_length_encoding(s):\n return [[sum(1 for _ in g), c] for c, g in groupby(s)]", "from itertools import groupby\ndef run_length_encoding(s):\n return [[len(list(b)), a] for a,b in groupby(s)]", "def run_length_encoding(s):\n count, prev, lst = 1, '', []\n for c in s:\n if c != prev:\n if prev: lst.append([count, prev])\n count, prev = 1, c\n else: count += 1\n if len(prev) > 0 : lst.append([count, prev])\n return lst", "from itertools import groupby\ndef run_length_encoding(s):\n return [[len(list(g)), k] for k, g in groupby(s)]", "import re\ndef run_length_encoding(s):\n return [[len(l), e] for l, e in re.findall( r'((.)\\2*)', s )]", "from itertools import groupby\nimport re\ndef run_length_encoding(s):\n return [[len(list(j)),i] for i,j in groupby(s)]\n return [[len(i),j] for i,j in re.findall(r'((.)\\2*)',s)]", "from itertools import groupby\n\ndef run_length_encoding(s):\n return [[sum(1 for _ in grp), c] for c, grp in groupby(s)]", "from itertools import groupby\n\ndef run_length_encoding(s):\n return [[len(list(gp)), x] for x, gp in groupby(s)]", "from re import findall\n\ndef run_length_encoding(string):\n return [[len(a), b] for a, b in findall(r\"((.)\\2*)\", string)]\n\n\n\n #match_runs = r\"((.)\\2*)\"\n #runs = findall(match_runs, string)\n #return [[len(run), char] for run, char in runs]\n", "def run_length_encoding(s):\n result = []\n if s:\n prev = s[0]\n count = 1\n for ind in range(1, len(s)):\n if s[ind] == prev:\n count += 1\n else:\n result.append([count, prev])\n prev = s[ind]\n count = 1\n result.append([count, prev])\n return result\n", "import re\ndef run_length_encoding(s):\n ls = re.finditer(r'(.)\\1*',s)\n t = []\n for i in ls:\n t.append([i.end()-i.start(),i.group()[0]])\n return t", "def run_length_encoding(s):\n rle = []\n for i, ch in enumerate(s):\n if i == 0:\n rle.append([1, ch])\n else:\n last_ch = rle[-1][1]\n if last_ch == ch:\n new_count = rle[-1][0] + 1\n rle.pop()\n rle.append([new_count, ch])\n else:\n rle.append([1, ch])\n return rle", "def run_length_encoding(s):\n ret = []\n p = None\n for c in s:\n if c == p:\n ret[-1][0] += 1\n else:\n ret.append([1, c])\n p = c\n return ret", "def run_length_encoding(s):\n result = []\n i = j = 0\n while i < len(s):\n while j < len(s) and s[i] == s[j]:\n j += 1\n result.append([j-i, s[i]])\n i = j\n return result", "def run_length_encoding(string):\n code = []\n for c in string:\n if not code or code[-1][1] != c:\n code.append([1, c])\n else:\n code[-1][0] += 1\n return code", "from itertools import groupby\ndef run_length_encoding(s):\n encoded_s = []\n\n #define key function that returns first char as key\n key = lambda x: x[0]\n \n for k, g in groupby(s, key):\n encoded_s.append([len(list(g)), k])\n \n return encoded_s\n", "def run_length_encoding(s):\n if len(s) == 0:\n return []\n \n encoded_s = [[1,s[0]]]\n last_char = s[0]\n \n for char in s[1:]:\n if char == last_char:\n #increment running count\n encoded_s[-1][0] = encoded_s[-1][0] + 1\n else:\n # start counting new char\n encoded_s.append([1,char])\n #update last_char getting ready for next time through the loop\n last_char = char\n \n return encoded_s", "from itertools import groupby\n\ndef run_length_encoding(s):\n return [[len(x), x[0]] for x in [list(g) for k, g in groupby(s)]]", "def run_length_encoding(s):\n if len(s) == 0:\n return []\n cnt = 1\n prev = s[0]\n out = []\n s = s + \" \"\n for i in range(len(s) - 1):\n if s[i + 1] == prev:\n cnt = cnt + 1\n else:\n if cnt > 1:\n out.append([cnt, prev])\n cnt = 1\n else:\n out.append([1, prev])\n prev = s[i + 1]\n return out"] | {"fn_name": "run_length_encoding", "inputs": [[""], ["abc"], ["aab"], ["hello world!"], ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbb"]], "outputs": [[[]], [[[1, "a"], [1, "b"], [1, "c"]]], [[[2, "a"], [1, "b"]]], [[[1, "h"], [1, "e"], [2, "l"], [1, "o"], [1, " "], [1, "w"], [1, "o"], [1, "r"], [1, "l"], [1, "d"], [1, "!"]]], [[[34, "a"], [3, "b"]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,353 |
def run_length_encoding(s):
|
311543a3cf8b39e45a7d4c4fac46d618 | UNKNOWN | Timmy & Sarah think they are in love, but around where they live, they will only know once they pick a flower each. If one of the flowers has an even number of petals and the other has an odd number of petals it means they are in love.
Write a function that will take the number of petals of each flower and return true if they are in love and false if they aren't. | ["def lovefunc( flower1, flower2 ):\n return (flower1+flower2)%2", "def lovefunc(flower1, flower2):\n return flower1 % 2 != flower2 % 2", "def lovefunc( flower1, flower2 ):\n return (flower1 + flower2) % 2 == 1", "def lovefunc(a, b):\n if a % 2 == 0 and b % 2 == 0:\n return False\n elif a % 2 != 0 and b % 2 == 0:\n return True\n elif a % 2 == 0 and b % 2 != 0:\n return True\n else:\n return False", "lovefunc=lambda a,b:(a+b)%2", "def lovefunc( flower1, flower2 ):\n return bool((flower1+flower2)%2)", "def lovefunc(f1, f2):\n return True if (f1 % 2 == 0 and f2 % 2 != 0) or (f2 % 2 == 0 and f1 % 2 != 0) else False", "def lovefunc( flower1, flower2 ):\n if all([isinstance(i, int) for i in [flower1,flower2]]):\n return not ((flower1+flower2)%2 == 0) # only the sum of odd and even can be odd, that is love:)\n else:\n print('both of the numbers must be integers!')", "def lovefunc( flower1, flower2 ):\n if (flower1 % 2 == 0 and flower2 % 2) or (flower1 % 2 and flower2 % 2 == 0):\n return True\n else:\n return False", "def lovefunc( flower1, flower2 ):\n return True if (flower1 % 2 == 0 and flower2 % 2 != 0) or (flower2 % 2 == 0 and flower1 % 2 != 0) else False", "def lovefunc( flower1, flower2 ):\n return (flower1 + flower2)%2 != 0", "def lovefunc( flower1, flower2 ):\n if flower1%2 != flower2%2:\n return True\n else:\n return False", "def lovefunc(a, b):\n return a % 2 ^ b % 2", "def lovefunc( flower1, flower2 ):\n return ((flower1 ^ flower2) & 1) == 1", "def lovefunc( flower1, flower2 ):\n return (flower1 - flower2) % 2 == 1", "lovefunc = lambda f, s: (f + s) % 2", "lovefunc = lambda a,b: bool((a+b)%2)", "def lovefunc(*arg):\n return sum(arg)%2", "lovefunc = lambda a, b: a % 2 ^ b % 2", "lovefunc = lambda a, b: (a ^ b) & 1", "def lovefunc( flower1, flower2 ):\n return (flower1 ^ flower2)%2", "from typing import Tuple\n\ndef lovefunc(*flowers: Tuple[int]) -> bool:\n \"\"\" Are Timmy & Sarah in love? \"\"\"\n return len(list(filter(lambda _it: _it % 2, flowers))) == 1", "lovefunc = lambda x, y: x&1^y&1", "def lovefunc(seq, elem):\n return( (seq%2==0 and elem%2!=0) or (seq%2!=0 and elem%2==0))", "def lovefunc( flower1, flower2 ):\n return False if flower1 and flower2 == 0 or (flower1+flower2)%2 == 0 else True", "lovefunc = lambda x, y: x % 2 != y % 2", "def lovefunc( flower1, flower2 ):\n return (flower1 + flower2) & 1# ...", "def lovefunc( flower1, flower2 ):\n return False if (flower1 + flower2) % 2 == 0 else True\n", "def lovefunc( flower1, flower2 ):\n # ...\n if(flower1%2!=0 or flower2%2!=0):\n return True\n elif(flower1%2!=0 and flower2%2!=0):\n return False\n else:\n return False", "def lovefunc( flower1, flower2 ):\n \n if flower1 % 2 == 0 and flower2 % 2 != 0:\n return True\n elif flower2 % 2 == 0 and flower1 % 2 != 0:\n return True\n elif flower1 % 2 == 0 and flower2 % 2 == 0:\n return False\n else:\n return False", "def lovefunc( flower1, flower2 ):\n even_odd = []\n if flower1 % 2 == 0:\n even_odd.append(\"even\")\n else:\n even_odd.append(\"odd\")\n if flower2 % 2 == 0:\n even_odd.append(\"even\")\n else:\n even_odd.append(\"odd\")\n \n return even_odd.count(\"odd\") == 1", "def lovefunc( flower1, flower2 ):\n a = lambda x, y: True if (x%2 == 0 and y%2 == 1) or (x%2==1 and y%2==0) else False\n return a(flower1, flower2)", "def lovefunc(f,f1):\n if f%2==0 and f1%2!=0:\n return True \n return True if f%2!=0 and f1%2==0 else False\n", "def lovefunc( flower1, flower2 ):\n if flower1 %2==1 and flower2 %2==1:\n return False\n elif flower1 %2==0 and flower2 %2==0:\n return False\n else:\n return True", "def lovefunc( flower1, flower2 ):\n if flower1 % 2 == 0 and flower2 % 2:\n return True\n elif flower1 % 2 and flower2 % 2 == 0:\n return True\n else:\n return False\n", "def lovefunc( flower1, flower2 ):\n x = flower1 % 2\n y = flower2 % 2\n return True if x + y == 1 else False", "lovefunc = lambda a,b:(b-a)&1", "def lovefunc( flower1, flower2 ):\n return flower1%2!=0 and flower2%2==0 or flower2%2!=0 and flower1%2==0", "def lovefunc( flower1, flower2 ):\n petal1 = flower1 % 2\n petal2 = flower2 % 2\n if petal1 == 0 and petal2 > 0:\n return True\n if petal1 > 0 and petal2 == 0:\n return True\n if petal1 == 0 and petal2 == 0:\n return False\n if petal1 > 0 and petal2 > 0:\n return False", "def lovefunc( flower1, flower2 ):\n if flower1%2==flower2%2==0:\n return False\n elif flower1%2==flower2%2==1:\n return False\n else:\n return True", "def lovefunc( flower1, flower2 ):\n return not ((flower1 % 2 == 0 and flower2 % 2 == 0) or \\\n (flower1 % 2 != 0 and flower2 % 2 != 0))", "def lovefunc( flower1, flower2 ):\n if flower1 % 2 == 0:\n return True if flower2 % 2 > 0 else False\n else:\n return True if flower2 % 2 == 0 else False", "def lovefunc( flower1, flower2 ):\n def even(x):\n return x % 2 == 0\n \n a = even(flower1)\n b = even(flower2)\n return (a and not b) or (b and not a)", "def lovefunc( f1, f2 ):\n return not(f1 % 2 == 0 and f2 % 2 == 0 or f1 % 2 != 0 and f2 % 2 != 0)", "def lovefunc( flower1, flower2 ):\n if (flower1 %2 ==1 and flower2 %2 ==0) or (flower2 %2 ==1 and flower1 %2 ==0):\n return True\n return False", "def lovefunc( flower1, flower2 ):\n if flower1%2>0 and flower2%2==0:\n return True\n elif flower1%2==0 and flower2%2>0:\n return True\n else:\n return False", "def lovefunc( flower1, flower2 ):\n if flower1%2==flower2%2==0:\n return False\n elif flower1%2!=0 and flower2%2!=0:\n return False\n else: \n return True# ...", "def lovefunc( flower1, flower2 ):\n if flower1 % 2 == 1 and flower2 %2 == 1 or flower1 % 2 == 0 and flower2 % 2 == 0:\n return False\n return True\n", "def lovefunc( flower1, flower2 ):\n flower_1 = flower1 / 2\n flower_2 = flower2 / 2\n if flower1 == flower2:\n return False\n elif flower_1 + flower_2 == int(flower_1 + flower_2):\n return False\n else:\n return True", "def lovefunc( flower1, flower2 ):\n return (flower1%2==0) == (flower2%2!=0)\n", "def lovefunc( flower1, flower2 ):\n if flower1 == flower2 or flower1 % 2 == 0 and flower2 % 2 == 0 or flower1 % 2 != 0 and flower2 % 2 != 0:\n return False\n else:\n return True", "def lovefunc(f1, f2):\n return (f1 % 2 + f2 % 2) % 2 == 1", "def lovefunc(f1,f2):\n return True if abs(f1-f2) % 2 == 1 else False ", "def lovefunc( flower1, flower2 ):\n if flower1 % 2 and not flower2 % 2 or not flower1 % 2 and flower2 % 2:\n return True\n else:\n return False", "def lovefunc( flower1, flower2 ):\n count1 =0\n count2 = 0\n for i in range(flower1):\n count1+=1\n for j in range(flower2):\n count2+=1\n if count1 % 2 == 1 and count2 % 2 == 0 or count1 % 2 == 0 and count2 % 2 == 1:\n return True\n else:\n return False\n \n", "def lovefunc( f1, f2 ):\n return (abs(f1-f2))%2 != 0", "def lovefunc( flower1, flower2 ):\n print(flower1, flower2)\n if flower1 % 2 == 0 and flower2 % 2 != 0:\n return True\n if flower1 % 2 != 0 and flower2 % 2 == 0:\n return True\n return False", "def lovefunc( flower1, flower2 ):\n if flower1 == 0 and flower2 == 0:\n return False\n elif flower1 % 2 == 0 and flower2 % 2 != 0:\n return True\n elif flower2 % 2 == 0 and flower1 % 2 != 0:\n return True\n else:\n return False", "def lovefunc( flower1, flower2 ):\n if (flower2 - flower1) % 2 == 0:\n return False\n else:\n return True", "def lovefunc( flower1, flower2 ):\n '''\n Write a function that will take the number of petals of each flower\n and return true if they are in love and false if they aren't.\n '''\n return flower1 % 2 != flower2 % 2", "def lovefunc( flower1, flower2 ):\n if (flower2%2) == 0 and (flower1%2) == 1:\n return True\n elif (flower1%2) == 0 and (flower2%2) == 1:\n return True\n else:\n return False", "def lovefunc( flower1, flower2 ):\n return all([any([flower1 % 2 == 0, flower2 % 2 == 0]), any([flower1 % 2 == 1, flower2 % 2 == 1])])", "def lovefunc( flower1, flower2 ):\n remainder1 = flower1 % 2\n remainder2 = flower2 % 2\n if remainder1 != remainder2:\n return True\n else:\n return False\n", "def lovefunc( flower1, flower2 ):\n odd = False\n even = False\n \n if flower1%2 == 0:\n even = True\n elif flower1%2 != 0:\n odd = True\n \n if flower2%2 == 0:\n even = True\n elif flower2%2 != 0:\n odd = True\n \n if odd is True and even is True:\n return True\n return False", "def lovefunc( flower1, flower2 ):\n if abs(flower1 - flower2) % 2 != 0:\n return True\n return False", "def lovefunc(x,s):\n return x%2!=s%2", "def lovefunc( flower1, flower2 ):\n odd1 = flower1 % 2\n odd2 = flower2 % 2\n \n if (odd1 or odd2) and not (odd1 and odd2):\n return True\n else:\n return False", "def lovefunc( flower1, flower2 ):\n return bool(flower1 % 2 and not flower2 % 2 or flower2 % 2 and not flower1 % 2)", "def lovefunc( flower1, flower2 ):\n # ...\n if flower1%2==1 and flower2%2==1:\n return True\n elif flower1%2==0 and flower2%2==0:\n return False\n else:\n return True", "def lovefunc(f1, f2):\n i = f1 + f2\n if i % 2 == 0:\n return False\n else:\n return True", "def lovefunc( flower1, flower2 ):\n \"\"\" Straight Up Now Tell Me\"\"\"\n return ( flower1 + flower2 ) % 2", "def lovefunc( flower1, flower2 ):\n if flower1%2 and not flower2%2: return True\n elif not flower1%2 and flower2%2 : return True\n return False", "def lovefunc( flower1, flower2 ):\n if (flower1 + flower2) % 2 != 0:\n return True\n elif (flower1 + flower2) % 2 == 0 or flower1 + flower2 == 0:\n return False", "def lovefunc( flower1, flower2 ):\n if flower1 % 2 == 0 and flower2 % 2 != 0 or \\\n flower1 % 2 != 0 and flower2 % 2 == 0:\n return True\n return False", "def lovefunc( flower1, flower2 ):\n f1 = int(flower1)\n f2 = int(flower2)\n if f1 % 2 == 0 and f2 % 2 == 0:\n return False\n elif f1 % 2 != 0 and f2 % 2 != 0:\n return False\n else: \n return True", "def lovefunc( flower1, flower2 ):\n if (flower1 - flower2) % 2 == 1:\n return True\n else:\n return False", "def lovefunc( flowers1, flowers2 ):\n return (flowers1 + flowers2) % 2 != 0", "# codewars \n\ndef lovefunc( flower1, flower2 ):\n if flower1 % 2 == 0 and flower2 % 2 != 0 or flower2 % 2 == 0 and flower1 % 2 != 0 :\n return True\n else:\n return False\n", "def lovefunc( f1, f2 ):\n return sum([f1,f2]) % 2", "def lovefunc( flower1, flower2 ):\n if flower1 % 2 ==0 and flower2 % 2 !=0 :\n return True\n elif flower1 % 2 ==0 and flower2 % 2 ==0 :\n return False\n elif flower1 % 2 !=0 and flower2 % 2 !=0:\n return False\n return True", "def lovefunc( f1, f2 ):\n if f1 % 2 == 0 and f2 % 2 != 0:\n return True\n if f2 % 2 == 0 and f1 % 2 != 0:\n return True\n else:\n return False\n", "#since 1 is truthy and 0 is falsey\n#sample data - (1,4)\n#1+4 = 5\n#5%2 = 1 = true\ndef lovefunc( flower1, flower2 ):\n return (flower1+flower2)%2", "#sample data (2,2)\n#flower1 % 2 = even\n#flower2 % 2 = even\n#even != even is false\n\n#(1,4)\n#flower1 % 2 = odd\n#flower2 % 2 = even\n#odd != even is true\n\ndef lovefunc(flower1, flower2):\n return flower1 % 2 != flower2 % 2", "#input - two integers represting flower petals\n#output - boolean\n#edge cases - string given, no input given, decimals/flaots given\n#assumptions - solve by comparing first integer to second integer, same number is False\n#data types - integers\n#end goal - function returns True if one of the flowers has an odd number of petals\n#and the other has an even number, else False\n\n#sample data (1,4) = True\n#(6,8) = False\n#(\"4\",7) = False\n#(3.4,8) = True\n\n#function takes flower1 and flower2\ndef lovefunc(flower1, flower2):\n#check if flower1 and flower2 are both even\n if flower1 % 2 == 0 and flower2 % 2 == 0:\n#if they are even, return false\n return False\n#check if both flowers are odd\n elif flower1 % 2 != 0 and flower2 % 2 != 0:\n#if they are odd, return false\n return False\n#return True if you have one odd and one even \n else:\n return True\n", "def lovefunc( flower1, flower2 ):\n return (flower1 + flower2) % 2 == 1 if (flower1 + flower2) != 0 else False", "lovefunc = lambda flower1, flower2: (flower1 + flower2) % 2", "def lovefunc( flower1, flower2 ):\n x = flower1 % 2 == 0 and flower2 % 2 == 1\n y = flower2 % 2 == 0 and flower1 % 2 == 1\n return True if x or y else False", "def lovefunc( flower1, flower2 ):\n # ...\n if (flower1%2!=0 and flower2%2==0) or(flower1%2==0 and flower2%2!=0): return True\n if (flower1%2==0 and flower2%2==0)or (flower1%2!=0 and flower2%2!=0):return False", "def lovefunc( flower1, flower2 ):\n return flower1 % 2 == 0 and flower2 % 2 == 1 or flower2 % 2 == 0 and flower1 % 2", "lovefunc = lambda flower1, flower2: not((flower1 % 2) ^ (not flower2 % 2))", "def lovefunc( f, ff ):\n return True if (f+ff)%2==1 else False", "def lovefunc(f1, f2):\n return f1%2==0 and f2%2!=0 or f2%2==0 and f1%2!=0", "def lovefunc( flower1, flower2 ):\n return (flower1 % 2 and not flower2 % 2) or \\\n (flower2 % 2 and not flower1 % 2)", "def lovefunc( flower1, flower2 ):\n c = 0\n if flower1 % 2 == 0 and flower2 % 2 != 0:\n c = c + 1\n elif flower2 % 2 == 0 and flower1 % 2 != 0:\n c = c + 1\n else:\n return False\n return c > 0", "def lovefunc( flower1, flower2 ):\n if flower1%2 == 0:\n return not flower2%2 == 0\n else:\n return flower2%2 == 0", "def lovefunc( f1, f2 ):\n if f1%2==0 and f2%2==0:\n return False\n if f1&2==1 and f%2==1: \n return False\n else:\n return True", "def lovefunc(*a):\n return sum(a) % 2", "def lovefunc( flower1, flower2 ):\n return not (flower1 & 1) == (flower2 & 1)", "lovefunc = lambda a, b: (a - b) & 1", "def lovefunc( flower1, flower2 ):\n return True in [i % 2 != 0 for i in [flower1, flower2]]"] | {"fn_name": "lovefunc", "inputs": [[1, 4], [2, 2], [0, 1], [0, 0]], "outputs": [[true], [false], [true], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 14,840 |
def lovefunc( flower1, flower2 ):
|
45ed859815eb15613b022c0b3ddd223f | UNKNOWN | This kata is based on a [variation](https://www.codewars.com/kata/happy-numbers-5) of *Happy Numbers* by TySlothrop. It is advisable to complete it first to grasp the idea and then move on to this one.
___
Hello, my dear friend, and welcome to another *Happy Numbers* kata! What? You're not interested in them anymore? They are all the same? But what if I say that this one is a *performance version*...
___
# Your task:
Write a function `performant_numbers` which takes a number `n` as an argument and returns a list of all *happy numbers* from `1` to `n` inclusive. For example:
```
performant_numbers(10) => [1, 7, 10]
performant_numbers(50) => [1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49]
performant_numbers(100) => [1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100]
```
# Test suite:
* `5000` tests with number `n` being up to `300000`
* The reference solution takes around `4.9` seconds to calculate the result
* you are not allowed to hardcode the sequence: you'll have to compute it (max length of the code: 1700 characters)
___
Will you take up the challenge? | ["sum_dig = lambda n, D={str(d): d*d for d in range(10)}: sum(map(D.get, str(n)))\nis_happy = lambda n: n > 4 and is_happy(sum_dig(n)) or n == 1\n\nhappy_set = set(filter(is_happy, range(100)))\nfor n in range(100, 3 * 10 ** 5):\n if sum_dig(n) in happy_set: happy_set.add(n)\n\nfrom bisect import bisect\ndef performant_numbers(n, happy_list=sorted(happy_set)): return happy_list[:bisect(happy_list, n)]", "def is_happy(n):\n while n > 4:\n n = sum((d - 48)**2 for d in str(n).encode())\n return n == 1\n\nhappy = list(filter(is_happy, range(3 * 10 ** 5)))\n\nfrom bisect import bisect_right\ndef performant_numbers(n):\n return happy[:bisect_right(happy, n)]", "F = [2,4,16,37,58,89,145,42,20]\n\nfrom bisect import bisect\n\ndef f(n):\n for i in range(50):\n n = sum(int(i)**2 for i in str(n))\n if n in F:\n return False\n if n == 1:\n return True\n\nH = [i for i in range(1,300000) if f(i)]\n\ndef performant_numbers(n):\n return H[:bisect(H, n)]", "# generate happy numbers up to LIMIT\nLIMIT = 300000\nHAPPY, SAD = set(), set()\n\nfor n in range(1, LIMIT+1):\n seen = set()\n while True:\n seen.add(n)\n n = sum( d*d for d in map(int, str(n)) )\n \n if n == 1 or n in HAPPY:\n HAPPY |= seen\n break\n elif n in seen or n in SAD:\n SAD |= seen\n break\n\nHAPPY = sorted(HAPPY)\n\n\nfrom bisect import bisect\n\ndef performant_numbers(n):\n return HAPPY[:bisect(HAPPY, n)]", "b = [False]\na = []\na2 = [None]\n\ndef f(n):\n def is_happy(n):\n s = {n}\n while n != 1:\n nn = 0\n while n > 0: nn += (n%10)**2; n//=10\n n = nn\n if n < len(b): return b[n]\n if n in s: return False\n s.add(n)\n return True\n for k in range(1, n+1):\n b.append(is_happy(k))\n if b[k]: a.append(k)\n a2.append(len(a))\nf(300000)\n\ndef performant_numbers(n):\n return a[:a2[n]]", "from bisect import bisect\n\nLIMIT = 1 + 300000\nhappySieve = [None] * LIMIT\nhappySieve[1] = 1\n \ndef happyOnes(n):\n seen = set()\n while 1:\n if happySieve[n] is not None: return happySieve[n], seen\n if n in seen or n == 1: return n==1, seen\n seen.add(n)\n n = sum( int(d)**2 for d in str(n) )\n \n\nfor n in range(1,LIMIT):\n isH, seen = happyOnes(n)\n for x in seen: happySieve[x] = isH\n\nHAPPY = [i for i in range(1,LIMIT) if happySieve[i]]\n\ndef performant_numbers(n): return HAPPY[:bisect(HAPPY,n)]", "from bisect import bisect\n\ndef happy_numbers(n):\n happy_list = []\n happy = {1}\n unhappy = set()\n for k in range(1, n+1):\n i = k\n seen = set()\n while True:\n if i in happy:\n happy_list.append(k)\n happy |= seen\n break\n elif i in unhappy or i in seen:\n unhappy |= seen\n break\n seen.add(i)\n i = sum(int(d)**2 for d in str(i))\n return happy_list\n\nhappy_list = happy_numbers(300000)\n\ndef performant_numbers(n):\n i = bisect(happy_list, n)\n return happy_list[:i]", "from bisect import bisect\n\nsieve = [None] * 300001\n\ndef is_happy(n):\n seen = set()\n while True:\n if sieve[n] is not None:\n return sieve[n], seen\n \n if n == 1:\n break\n elif n < 7:\n return False, seen\n seen.add(n)\n n = sum(int(x)**2 for x in str(n))\n\n return True, seen\n\n\nfor i in range(1, 300000+1):\n state, seen = is_happy(i)\n for x in seen:\n sieve[x] = state\n\n\nFINAL = [1] + [idx for idx in range(1,300001) if sieve[idx]]\n\ndef performant_numbers(n):\n first = 0\n last = len(FINAL)-1\n idx = float('inf')\n\n while first <= last:\n mid = (first+last)//2\n\n if n == FINAL[mid]:\n idx = mid+1\n break\n \n elif n < FINAL[mid]:\n idx = mid\n last = mid - 1\n \n else:\n first = mid + 1\n \n return FINAL[:idx]\n"] | {"fn_name": "performant_numbers", "inputs": [[10], [50], [100]], "outputs": [[[1, 7, 10]], [[1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49]], [[1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,203 |
def performant_numbers(n, happy_list=sorted(happy_set)):
|
1ada448576babf88c396c82214f26598 | UNKNOWN | In this kata, your task is to identify the pattern underlying a sequence of numbers. For example, if the sequence is [1, 2, 3, 4, 5], then the pattern is [1], since each number in the sequence is equal to the number preceding it, plus 1. See the test cases for more examples.
A few more rules :
pattern may contain negative numbers.
sequence will always be made of a whole number of repetitions of the pattern.
Your answer must correspond to the shortest form of the pattern, e.g. if the pattern is [1], then [1, 1, 1, 1] will not be considered a correct answer. | ["from itertools import cycle\n\ndef find_pattern(s):\n diffs = [y - x for x, y in zip(s, s[1:])] \n for i in range(1, len(diffs) + 1):\n if len(diffs) % i == 0 and all(a == b for a, b in zip(diffs, cycle(diffs[:i]))): return diffs[:i]", "def find_pattern(seq):\n start, end = [], []\n for i in range(len(seq)-1):\n start.append(seq[i+1]-seq[i])\n end.append(seq[-1-i]-seq[-2-i])\n if not (len(seq)-1) % len(start) and start == end[::-1] and not len(set(start)) == 1:\n return start\n return [start[0]] if len(set(start)) == 1 else []", "from operator import sub\n\ndef find_pattern(sequence):\n result = list(map(sub, sequence[1:], sequence))\n size = len(result)\n for i in range(1, size+1):\n q, r = divmod(size, i)\n if r == 0:\n check = result[:i]\n if check*q == result:\n return check", "def find_pattern(sequence):\n diff = [b - a for a, b in zip(sequence, sequence[1:])]\n return next(diff[:i] for i in range(1, len(diff)+1) if diff[i:]+diff[:i] == diff)\n", "def find_pattern(a):\n d = [a[i + 1] - a[i] for i in range(len(a) - 1)] ; l = len(d)\n return next(d[:i] for i in range(1,len(d)+1) if l%len(d[:i])==0 and d[:i]*(l//len(d[:i]))==d)", "def find_pattern(a):\n diff = [a[i + 1] - a[i] for i in range(len(a) - 1)]\n l = len(diff)\n for i in range(1, len(diff) + 1):\n t = diff[:i]\n if l % len(t) == 0:\n if t * (l // len(t)) == diff:\n return t", "def find_pattern(seq):\n xs = [b-a for a, b in zip(seq, seq[1:])]\n return next((\n xs[:i]\n for i in range(1, len(xs) // 2 + 1)\n if xs[:i] * (len(xs) // i) == xs\n ), xs)", "def find_pattern(sequence):\n pattern = [a-b for a, b in zip(sequence[1:], sequence)]\n \n for size in range(1, len(pattern)+1):\n if len(pattern) // size * pattern[:size] == pattern:\n return pattern[:size]", "def find_pattern(seq):\n n, diffs = len(seq)-1, [b-a for a,b in zip(seq, seq[1:])]\n for l in range(1, n + 1):\n if n // l * diffs[:l] == diffs:\n return diffs[:l]"] | {"fn_name": "find_pattern", "inputs": [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]], [[1, 5, 2, 3, 1, 5, 2, 3, 1]], [[1, 5, 4, 8, 7, 11, 10, 14, 13]], [[0, 1]], [[4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4]], [[4, 5, 3, -2, -1, 0, -2, -7, -6]], [[4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5, 3, 2, 3, 4]], [[-67, -66, -64, -61, -57, -52, -46, -39, -31, -22, -12, -2, 7, 15, 22, 28, 33, 37, 40, 42, 43]], [[4, 5, 7, 6, 4, 2, 3, 5, 4, 2, 3, 5, 4, 2, 0, 1, 3, 2, 0, 1, 3, 2, 0, -2, -1, 1, 0, -2]]], "outputs": [[[1]], [[1, 1, 1, 1, -1, -1, -1, -1]], [[4, -3, 1, -2]], [[4, -1]], [[1]], [[1, 1, 2, -5, 1]], [[1, -2, -5, 1]], [[1, 1, -1, -2, -1, 1, 1]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]], [[1, 2, -1, -2, -2, 1, 2, -1, -2]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,178 |
def find_pattern(seq):
|
6e4105f49289b43064f598ad44ed1bd0 | UNKNOWN | Not considering number 1, the integer 153 is the first integer having this property:
the sum of the third-power of each of its digits is equal to 153. Take a look:
153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
The next number that experiments this particular behaviour is 370 with the same power.
Write the function `eq_sum_powdig()`, that finds the numbers below a given upper limit `hMax` that fulfill this property but with different exponents as a power for the digits.
eq_sum_powdig(hMax, exp): ----> sequence of numbers (sorted list) (Number one should not be considered).
Let's see some cases:
```python
eq_sum_powdig(100, 2) ----> []
eq_sum_powdig(1000, 2) ----> []
eq_sum_powdig(200, 3) ----> [153]
eq_sum_powdig(370, 3) ----> [153, 370]
```
Enjoy it !! | ["def eq_sum_powdig(hMax, exp):\n return [i for i in range(2, hMax + 1) if i == sum(int(c) ** exp for c in str(i))]\n", "def eq_sum_powdig(hMax, exp):\n ret = []\n for i in range(10, hMax + 1):\n if i == sum(int(j) ** exp for j in str(i)):\n ret.append(i)\n return ret", "def eq_sum_powdig(hmax, exp):\n return [i for i in range(2, hmax+1) if sum(int(d) ** exp for d in str(i)) == i]", "def valid(num, power):\n return num == sum(int(x)**power for x in str(num))\ndef eq_sum_powdig(hMax, exp):\n return [x for x in range(2,hMax+1) if valid(x,exp)]", "def eq_sum_powdig(hMax, exp):\n list=[]\n for n in range(100,hMax+1):\n product=0\n for l in str(n):\n product += int(l)**exp\n if n == product:\n list.append(n)\n return list"] | {"fn_name": "eq_sum_powdig", "inputs": [[100, 2], [1000, 2], [2000, 2], [200, 3], [370, 3], [400, 3], [500, 3], [1000, 3], [1500, 3]], "outputs": [[[]], [[]], [[]], [[153]], [[153, 370]], [[153, 370, 371]], [[153, 370, 371, 407]], [[153, 370, 371, 407]], [[153, 370, 371, 407]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 819 |
def eq_sum_powdig(hMax, exp):
|
967607c29ffe508c88c2c38c5b10b099 | UNKNOWN | *`This kata is a tribute/fanwork to the TV-show: Supernatural`*
Balls!
Those wayward Winchester boys are in trouble again, hunting something down in New Orleans.
You are Bobby Singer, you know how "idjits" they can be, so you have to prepare.
They will call you any minute with the race of the thing, and you want to answer as soon as possible. By answer, I mean: tell them how to kill, or fight it.
You have something like a database (more like drunken doodling) to help them:
- werewolf : Silver knife or bullet to the heart
- vampire : Behead it with a machete
- wendigo : Burn it to death
- shapeshifter : Silver knife or bullet to the heart
- angel : Use the angelic blade
- demon : Use Ruby's knife, or some Jesus-juice
- ghost : Salt and iron, and don't forget to burn the corpse
- dragon : You have to find the excalibur for that
- djinn : Stab it with silver knife dipped in a lamb's blood
- pagan god : It depends on which one it is
- leviathan : Use some Borax, then kill Dick
- ghoul : Behead it
- jefferson starship : Behead it with a silver blade
- reaper : If it's nasty, you should gank who controls it
- rugaru : Burn it alive
- skinwalker : A silver bullet will do it
- phoenix : Use the colt
- witch : They are humans
- else : I have friggin no idea yet
You can access the database as `drunkenDoodling`/`drunken_doodling`/`DrunkenDoodling` depending on your language.
---
So a call would go down like this:
The guys call you:
```bob('rugaru')```
...and you reply (return) with the info, and your signature saying of yours!
```Burn it alive, idjits!``` | ["database = '''werewolf : Silver knife or bullet to the heart\nvampire : Behead it with a machete\nwendigo : Burn it to death\nshapeshifter : Silver knife or bullet to the heart\nangel : Use the angelic blade\ndemon : Use Ruby's knife, or some Jesus-juice\nghost : Salt and iron, and don't forget to burn the corpse\ndragon : You have to find the excalibur for that\ndjinn : Stab it with silver knife dipped in a lamb's blood\npagan god : It depends on which one it is\nleviathan : Use some Borax, then kill Dick\nghoul : Behead it\njefferson starship : Behead it with a silver blade\nreaper : If it's nasty, you should gank who controls it\nrugaru : Burn it alive\nskinwalker : A silver bullet will do it\nphoenix : Use the colt\nwitch : They are humans\nelse : I have friggin no idea yet'''\n\nanswers = {line.split(' : ')[0]:line.split(' : ')[1] for line in database.splitlines()}\n\ndef bob(what):\n return answers.get(what, answers['else'])+', idjits!'", "def bob(what):\n db = {}\n db[\"werewolf\"] = \"Silver knife or bullet to the heart\"\n db[\"vampire\"] = \"Behead it with a machete\"\n db[\"wendigo\"] = \"Burn it to death\"\n db[\"shapeshifter\"] = \"Silver knife or bullet to the heart\"\n db[\"angel\"] = \"Use the angelic blade\"\n db[\"demon\"] = \"Use Ruby's knife, or some Jesus-juice\"\n db[\"ghost\"] = \"Salt and iron, and don't forget to burn the corpse\"\n db[\"dragon\"] = \"You have to find the excalibur for that\"\n db[\"djinn\"] = \"Stab it with silver knife dipped in a lamb's blood\"\n db[\"pagan god\"] = \"It depends on which one it is\"\n db[\"leviathan\"] = \"Use some Borax, then kill Dick\"\n db[\"ghoul\"] = \"Behead it\"\n db[\"jefferson starship\"] = \"Behead it with a silver blade\"\n db[\"reaper\"] = \"If it's nasty, you should gank who controls it\"\n db[\"rugaru\"] = \"Burn it alive\"\n db[\"skinwalker\"] = \"A silver bullet will do it\"\n db[\"phoenix\"] = \"Use the colt\"\n db[\"witch\"] = \"They are humans\"\n if what in db:\n return db[what]+\", idjits!\"\n else:\n return \"I have friggin no idea yet\"+\", idjits!\"", "database = {\n \"werewolf\" : \"Silver knife or bullet to the heart\",\n \"vampire\" : \"Behead it with a machete\",\n \"wendigo\" : \"Burn it to death\",\n \"shapeshifter\" : \"Silver knife or bullet to the heart\",\n \"angel\" : \"Use the angelic blade\",\n \"demon\" : \"Use Ruby's knife, or some Jesus-juice\",\n \"ghost\" : \"Salt and iron, and don't forget to burn the corpse\",\n \"dragon\" : \"You have to find the excalibur for that\",\n \"djinn\" : \"Stab it with silver knife dipped in a lamb's blood\",\n \"pagan god\" : \"It depends on which one it is\",\n \"leviathan\" : \"Use some Borax, then kill Dick\",\n \"ghoul\" : \"Behead it\",\n \"jefferson starship\": \"Behead it with a silver blade\",\n \"reaper\": \"If it's nasty, you should gank who controls it\",\n \"rugaru\": \"Burn it alive\",\n \"skinwalker\": \"A silver bullet will do it\",\n \"phoenix\": \"Use the colt\",\n \"witch\": \"They are humans\",\n}\ndef bob(what):\n default = \"I have friggin no idea yet\"\n return database.get(what, default) + \", idjits!\""] | {"fn_name": "bob", "inputs": [["vampire"], ["pagan god"], ["werepuppy"]], "outputs": [["Behead it with a machete, idjits!"], ["It depends on which one it is, idjits!"], ["I have friggin no idea yet, idjits!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,265 |
def bob(what):
|
f2d3ed6e5d9849dc873e1c3cc530874d | UNKNOWN | An onion array is an array that satisfies the following condition for all values of `j` and `k`:
If all of the following are `true`:
* `j >= 0`
* `k >= 0`
* `j + k = array.length - 1`
* `j != k`
then:
* `a[j] + a[k] <= 10`
### Examples:
```
[1, 2, 19, 4, 5] => true (as 1+5 <= 10 and 2+4 <= 10)
[1, 2, 19, 4, 10] => false (as 1+10 > 10)
```
Write a function named `isOnionArray`/`IsOnionArray`/`is_onion_array()` that returns `true` if its argument is an onion array and returns `false` if it is not.
~~~if:php
Your solution should at least be moderately efficient. Make sure you don't do any unnecessary looping ;)
~~~ | ["def is_onion_array(a):\n return all(a[i] + a[-i-1] <= 10 for i in range(len(a) // 2))", "from typing import List\n\n\ndef is_onion_array(a: List[int]) -> bool:\n return all(aj + ak <= 10 for aj, ak in zip(a, a[:(len(a) - 1) // 2:-1]))\n", "def is_onion_array(a):\n for i in range(0,len(a)//2):\n if a[i]+a[-i-1] > 10:\n return False\n return True", "def is_onion_array(a):\n l = len(a)\n return all(a[i] + a[l - i - 1] <= 10 for i in range(l // 2))\n\n\n\n", "def is_onion_array(a):\n for j in range(len(a)//2):\n if a[j] + a[-j-1] > 10:\n return False\n return True\n \n \n", "def is_onion_array(a):\n if a == []:\n return True\n a = [sum(x) for x in zip(a, a[::-1])]\n a.pop(len(a)//2)\n for element in a:\n if element > 10:\n return False\n return True", "def is_onion_array(a):\n i = 0; j = -1\n while i != len(a)//2:\n if a[i] + a[j] > 10:\n return False\n i += 1\n j -= 1\n return True", "def is_onion_array(a):\n mid = len(a)//2\n \n for i in range(0,mid):\n if a[i] + a[-i-1] > 10:\n return False\n return True", "def is_onion_array(a):\n print(a)\n for num in range(len(a)):\n if a[num] !=a[-(num+1)]:\n if not a[num] + a[-(num + 1)] <=10:\n return False\n \n \n \n \n return True", "from itertools import combinations as cb\ndef is_onion_array(a):\n return not any([sum(c) == len(a)-1 and a[c[0]]+a[c[1]] > 10 for c in cb([*range(0,len(a))],2)])"] | {"fn_name": "is_onion_array", "inputs": [[[6, 0, 4]], [[1, 1, 15, 10, -1]]], "outputs": [[true], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,585 |
def is_onion_array(a):
|
a3f3025b2b7db550a87621132f060584 | UNKNOWN | ## Fixed xor
Write a function that takes two hex strings as input and XORs them against each other. If the strings are different lengths the output should be the length of the shortest string.
Hint: The strings would first need to be converted to binary to be XOR'd.
## Note:
If the two strings are of different lengths, the output string should be the same length as the smallest string. This means that the longer string will be cut down to the same size as the smaller string, then xor'd
### Further help
More information on the XOR operation can be found here https://www.khanacademy.org/computing/computer-science/cryptography/ciphers/a/xor-bitwise-operation
More information of the binary and hex bases can be found here https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-number-bases/v/number-systems-introduction
Examples:
```python
fixed_xor("ab3f", "ac") == "07"
fixed_xor("aadf", "bce2") == "163d"
fixed_xor("1c0111001f010100061a024b53535009181c", "686974207468652062756c6c277320657965") == "746865206b696420646f6e277420706c6179"
``` | ["def fixed_xor(a, b):\n return \"\".join(f\"{int(x, 16)^int(y, 16):x}\" for x, y in zip(a, b))", "def fixed_xor(a, b):\n\n m = min(len(a), len(b)) \n \n return f\"{int(a[:m], 16) ^ int(b[:m], 16):0{m}x}\" if m else \"\"\n", "def fixed_xor(a, b):\n return \"\".join(format(int(x, 16) ^ int(y, 16), \"x\") for x, y in zip(a, b))\n", "def fixed_xor(a, b):\n l = min(len(a), len(b))\n r = \"\" if not a[:l] else hex(int(a[:l], 16) ^ int(b[:l], 16))[2:]\n return '0' * (l - len(r)) + r", "def fixed_xor(a, b):\n if not a or not b:return ''\n m1 = min(len(a),len(b))\n a,b = bin(int(a[:m1], 16))[2:],bin(int(b[:m1], 16))[2:]\n m = max(len(a), len(b))\n return hex(int(\"\".join([str(int(i)^int(j)) for i,j in zip(a.zfill(m),b.zfill(m))]),2))[2:].zfill(m1)", "def fixed_xor(a, b):\n l = min(len(a), len(b))\n if not l: return ''\n a, b = int(a[:l], 16), int(b[:l], 16)\n return hex(a^b)[2:].rjust(l, '0')", "def fixed_xor(a, b):\n return \"\".join(list(map(lambda x: format(int(x[0], 16) ^ int(x[1], 16), 'x'), zip(a, b))))", "\ndef fixed_xor(a, b):\n if a == \"\" or b == \"\":\n return \"\"\n \n m = min( len(a), len(b))\n ha = int(a[:m], 16)\n hb = int(b[:m], 16)\n\n return hex ( ha ^ hb)[2:].zfill(m)\n", "def fixed_xor(a, b):\n return ''.join('%x' % (int(x, 16) ^ int(y, 16)) for (x, y) in zip(a, b))", "def fixed_xor(a, b):\n l = min(len(a), len(b))\n if not l:\n return ''\n if len(a) != len(b):\n a, b = a[0:l], b[0:l]\n return hex(int(a, 16) ^ int(b, 16))[2:].rjust(l, '0')"] | {"fn_name": "fixed_xor", "inputs": [["1c0111001f010100061a024b53535009181c", "686974207468652062756c6c277320657965"], ["aadf", "bce2"], ["ab3f", "ac"], ["", ""], ["c611d9bdd9de38b9eb", "23a0745505d4d25494"], ["7d1e875da9d5e89b54c7eaf", "3541599be591709795cebd5"], ["785a6677b3e52f0e7", "a8d97da7441"], ["6cbd75511e7f750c6827", "1753547c813bfcd"]], "outputs": [["746865206b696420646f6e277420706c6179"], ["163d"], ["07"], [""], ["e5b1ade8dc0aeaed7f"], ["485fdec64c44980cc10957a"], ["d0831bd0f7f"], ["7bee212d9f4489d"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,604 |
def fixed_xor(a, b):
|
38b2ce2134d27c772febab54d8f1dc41 | UNKNOWN | In some ranking people collects points. The challenge is sort by points and calulate position for every person. But remember if two or more persons have same number of points, they should have same position number and sorted by name (name is unique).
For example:
Input structure:
Output should be: | ["def ranking(a):\n a.sort(key=lambda x: (-x[\"points\"], x[\"name\"]))\n for i, x in enumerate(a):\n x[\"position\"] = i + 1 if not i or x[\"points\"] < a[i-1][\"points\"] else a[i-1][\"position\"]\n return a", "def ranking(people):\n people = people[:]\n people.sort(key=lambda person: (-person['points'], person['name']))\n for i, person in enumerate(people):\n if i and person['points'] == people[i-1]['points']:\n person['position'] = people[i-1]['position']\n else:\n person['position'] = i + 1\n return people", "def ranking(people):\n S = sorted(d['points'] for d in people)[::-1]\n \n return [{**d, **{'position': S.index(d['points']) + 1}} for d in sorted(people, key=lambda k: (-k['points'], k['name']))]\n", "def ranking(people):\n x = sorted(sorted(people, key=lambda i: i['name']), key=lambda i: i['points'], reverse=True)\n for i in range(len(x)):\n x[i]['position'] = i + 1\n if i > 0:\n if x[i-1]['points'] == x[i]['points']:\n x[i]['position'] = x[i-1]['position']\n return x", "def ranking(people):\n ranked = sorted(people, key=lambda p: (-p[\"points\"], p[\"name\"]))\n scores = [p[\"points\"] for p in ranked]\n for p in ranked:\n p[\"position\"] = 1 + scores.index(p[\"points\"])\n return ranked", "def ranking(people):\n temp_result = sorted([item for item in people], key=lambda x: (-x['points'], x['name']))\n for idx, item in enumerate(temp_result):\n if idx and item['points'] == temp_result[idx - 1]['points']:\n item['position'] = temp_result[idx - 1]['position']\n else:\n item['position'] = idx + 1\n return temp_result", "from itertools import groupby\n\ndef ranking(people):\n x = len(str(len(people))); rank = 1\n people = sorted(people,key=lambda p: p['points'],reverse=True)\n groups = [[*g[1]] for g in groupby(people,key=lambda p: p['points'])]\n for g in groups:\n for p in g: p['position'] = rank\n rank += len(g)\n return sorted(people,key=lambda p: str(p['position']).zfill(x)+p['name'])\n", "def ranking(people):\n new = sorted(people, key=lambda x: (-x['points'], x['name']))\n for i in new:\n i['position'] = new.index(i) + 1\n for i, v in enumerate(new):\n if i == 0:\n continue\n if v['points'] == new[i - 1]['points']:\n v['position'] = new[i - 1]['position']\n return new", "ranking=lambda p:p.sort(key=lambda e:(-e['points'],e['name']))or[e.update({'position':[x['points']for x in p].index(e['points'])+1})or e for e in p]", "def ranking(people):\n pnt = None\n res = []\n for c, d in enumerate(sorted(people, key=lambda d: (-d['points'], d['name'])), 1):\n if pnt != d['points']:\n pnt = d['points']\n pos = c\n res.append(dict({'position':pos}, **d))\n return res"] | {"fn_name": "ranking", "inputs": [[[]]], "outputs": [[[]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,936 |
def ranking(people):
|
3674f18be988a29a91959d0aa40dc30d | UNKNOWN | A country has coins with denominations
```python
coins_list = d1 < d2 < · · · < dn.
```
You want to make change for n cents, using the smallest number of coins.
```python
# Example 1: U.S. coins
d1 = 1 d2 = 5 d3 = 10 d4 = 25
## Optimal change for 37 cents – 1 quarter, 1 dime, 2 pennies.
# Example 2: Alien Planet Z coins
Z_coin_a = 1 Z_coin_b = 3 Z_coin_c = 4
## Optimal change for 6 cents - 2 Z_coin_b's
```
Write a function that will take a list of coin denominations and a desired amount and provide the least amount of coins needed. | ["from collections import deque\n\ndef loose_change(coins_list, amount_of_change):\n q = deque([(0, amount_of_change)])\n\n while q:\n l, a = q.popleft()\n if a == 0:\n return l\n q.extend((l + 1, a - i) for i in coins_list if a >= i)", "def loose_change(coins_list, amount):\n solution = [0] + [amount + 1] * amount\n for atmc in range(1, amount + 1):\n for coin in coins_list:\n if coin <= atmc:\n solution[atmc] = min(solution[atmc], solution[atmc - coin] + 1)\n return -1 if solution[amount] > amount else solution[amount]", "def loose_change(coins_list, amount_of_change): \n n, i, t = 0, 0, amount_of_change\n coins_list.sort(reverse = True)\n while amount_of_change >= 0 and i < len(coins_list): \n if amount_of_change - coins_list[i] >= 0: \n n += 1\n amount_of_change -= coins_list[i]\n else: i += 1\n return min([int(t/i) for i in coins_list if t % i == 0] + [n])\n \n'''\nsecond version\ndef loose_change(coins_list, amount_of_change): \n coins, i, t = 0, 0, amount_of_change\n coins_list.sort(reverse = True)\n while amount_of_change > 0:\n tem = divmod(amount_of_change, coins_list[i])\n coins += tem[0]\n amount_of_change -= tem[0]*coins_list[i]\n i += 1\n aa = [int(t/i) for i in coins_list if t % i == 0] + [coins]\n return min(aa)\n'''", "def loose_change(coins_list, amount_of_change):\n if len(coins_list) == 1: return amount_of_change\n return min(\n loose_change(coins_list[:-1], amount_of_change),\n amount_of_change // coins_list[-1] + loose_change(coins_list[:-1], amount_of_change % coins_list[-1])\n )", "def loose_change(c, a):\n l, n = 0, 0\n s = sorted([a//i for i in c if i > 1 and a % i == 0])\n for i in range(len(c)-1, -1, -1):\n k = (a - l)//c[i]\n n += k\n if l + k * c[i] <= a:\n l += k * c[i]\n return min(n, s[0]) if s else n\n", "def loose_change(coins, change):\n return search(sorted(coins, reverse=True), change)\n\ndef search(coins, x, n=0):\n if x == 0: return n\n m = 9999\n for c in coins:\n if x >= c:\n q, r = divmod(x, c)\n m = min(m, search(coins, r, n + q))\n return m", "def loose_change(coins_list, amount_of_change):\n coins_amount = [0] + [float('inf')] * amount_of_change\n for i in range(1, amount_of_change + 1):\n coins_amount[i] = min(coins_amount[i - c] for c in coins_list if c <= i) + 1\n return coins_amount[-1]", "from itertools import combinations_with_replacement as combos\n\ndef loose_change(coins_list, amount_of_change):\n least_list = []\n for x in range(len(coins_list)):\n for combo in combos(coins_list, x + 1):\n if sum(combo) == amount_of_change:\n least_list.append(len(combo))\n return min(least_list)", "def loose_change(coins_list, amount_of_change):\n changes = [1 if n+1 in coins_list else amount_of_change*2 for n in range(amount_of_change)]\n for i in range(amount_of_change):\n for c in coins_list:\n if i+c<amount_of_change: changes[i+c] = min(changes[i+c],changes[i]+1)\n return changes[amount_of_change-1]", "def loose_change(coins_list, amount_of_change):\n if amount_of_change == 0:\n return 0\n elif amount_of_change < 0 or len(coins_list) == 0:\n return float('inf')\n else:\n with_first_coin = loose_change(coins_list, amount_of_change - coins_list[-1])\n without_first_coin = loose_change(coins_list[:-1], amount_of_change)\n return min(with_first_coin + 1, without_first_coin)"] | {"fn_name": "loose_change", "inputs": [[[1, 5, 10, 25], 37], [[1, 3, 4], 6], [[25, 5, 10, 1, 21], 63], [[1, 4, 5, 10], 8], [[1, 2, 5, 10, 20, 50, 100, 200], 93]], "outputs": [[4], [2], [3], [2], [5]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,666 |
def loose_change(coins_list, amount_of_change):
|
3e7c4186516e06bd0b87c7dbca79ea3e | UNKNOWN | # Task
A ciphertext alphabet is obtained from the plaintext alphabet by means of rearranging some characters. For example "bacdef...xyz" will be a simple ciphertext alphabet where a and b are rearranged.
A substitution cipher is a method of encoding where each letter of the plaintext alphabet is replaced with the corresponding (i.e. having the same index) letter of some ciphertext alphabet.
Given two strings, check whether it is possible to obtain them from each other using some (possibly, different) substitution ciphers.
# Example
For `string1 = "aacb" and string2 = "aabc"`, the output should be `true`
Any ciphertext alphabet that starts with acb... would make this transformation possible.
For `string1 = "aa" and string2 = "bc"`, the output should be `false`
# Input/Output
- `[input]` string `string1`
A string consisting of lowercase characters.
Constraints: `1 ≤ string1.length ≤ 10`.
- `[input]` string `string2`
A string consisting of lowercase characters of the same length as string1.
Constraints: `string2.length = string1.length`.
- `[output]` a boolean value | ["def is_substitution_cipher(s1, s2):\n return len(set(s1)) == len(set(s2)) == len(set(zip(s1, s2)))", "def f(s1, s2):\n d = {}\n for a, b in zip(s1, s2):\n if (a in d and d[a] != b):\n return False\n d[a] = b\n return True\n\ndef is_substitution_cipher(s1, s2):\n return f(s1, s2) and f(s2, s1)", "def is_substitution_cipher(s1, s2): \n translation = {}\n back_translation = {}\n for ch1, ch2 in zip(s1, s2): \n if (ch1 in translation): \n if (not translation[ch1] == ch2): return False\n else: \n translation[ch1] = ch2\n if (ch2 in back_translation): \n if (not back_translation[ch2] == ch1): return False\n else: \n back_translation[ch2] = ch1\n return True", "def is_substitution_cipher(s1, s2):\n return len(set(s1)) == len(set(s2)) == len( set((a,b) for a,b in zip(s1, s2)) )", "def is_substitution_cipher(s1, s2):\n plain, cipher = {}, {}\n for a, b in zip(s1, s2):\n if plain.setdefault(a, b) != b or cipher.setdefault(b, a) != a:\n return False\n return True", "def is_substitution_cipher(s1, s2):\n dict1={}\n dict2={}\n for i,j in zip(s1, s2):\n dict1[i]=dict1.get(i, 0)+1\n dict2[j]=dict2.get(j, 0)+1\n if len(dict1)!=len(dict2):\n return False\n return True", "def is_substitution_cipher(s1, s2):\n return s2 == s1.translate(str.maketrans(s1, s2)) \\\n and s1 == s2.translate(str.maketrans(s2, s1))", "def is_substitution_cipher(a, b):\n d1, d2 = {}, {}\n for x, y in zip(a, b):\n if x in d1 and d1[x] != y or y in d2 and d2[y] != x:\n return 0\n d1[x] = y\n d2[y] = x\n return 1"] | {"fn_name": "is_substitution_cipher", "inputs": [["aacb", "aabc"], ["aa", "bc"], ["aaxxaaz", "aazzaay"], ["aaxyaa", "aazzaa"], ["aazzaa", "aaxyaa"], ["jpeuizmi", "mxxcwriq"]], "outputs": [[true], [false], [true], [false], [false], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,700 |
def is_substitution_cipher(s1, s2):
|
60d7e6c055ead88a55970a8fd50bad29 | UNKNOWN | NOTE: It is recommended you complete [Introduction to Esolangs](https://www.codewars.com/kata/esolang-interpreters-number-1-introduction-to-esolangs-and-my-first-interpreter-ministringfuck/) or [MiniBitFlip](https://www.codewars.com/kata/esolang-minibitflip/) before solving this one.
Task:
Make an interpreter for an esoteric language called Ticker. Ticker is a descendant of [Tick](https://www.codewars.com/kata/esolang-tick). Your language has the following commands:
`>`: increment the selector by 1
`<`: decrement the selector by 1
`*`: add the ascii value of selected cell to the output tape
`+`: increment selected cell data by 1. If 256, then it is 0
`-`: increment selected cell data by -1. If less than 0, then 255
`/`: set selected cell data to 0
`!`: add new data cell to the end of the array
You start with selector at `0` and one cell with a value of `0`. If selector goes out of bounds, assume 0 for that cell but do not add it to the memory. If a + or - is being made do not change the value of the assumed cell. It will always stay 0 unless it is added to the memory
In other words:
```
data: start 0 end
selector: ^
data start 1 2 4 end
selector: ^
Assume that cell is zero.
```
Examples:
Consider the following program:
```python
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++*/'
```
It's output is this:
```python
'Hello World!'
```
This is made just by using 1 data cell.
Example using multiple data cells:
```python
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++*!>'
```
And it's output is still:
```python
'Hello World!'
```
A more efficient example:
```python
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*<<*>>!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*<<<<*!>>>>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++*'
```
Which still returns the classic:
```python
'Hello World!'
```
Other characters are ingnored and therefore can serve as comments.
After you're done, fell free to make translations and to discuss this kata. | ["def interpreter(tape):\n memory, ptr, output = {0: 0}, 0, \"\"\n \n for command in tape:\n if command == \">\": ptr += 1\n elif command == \"<\": ptr -= 1\n elif command == \"!\": memory[len(memory)] = 0\n elif command == \"*\": output += chr(memory.get(ptr, 0) % 256) \n elif ptr in memory:\n if command == \"+\": memory[ptr] += 1\n elif command == \"-\": memory[ptr] -= 1\n elif command == \"/\": memory[ptr] = 0\n \n return output", "def interpreter(tape):\n data, pointer, output = [0], 0, \"\",\n for command in tape:\n if command == \">\":\n pointer += 1\n elif command == \"<\":\n pointer -= 1\n elif command == \"+\" and is_valid(pointer, data):\n data[pointer] = (data[pointer] + 1) % 256\n elif command == \"-\" and is_valid(pointer, data):\n data[pointer] = (data[pointer] - 1) % 256\n elif command == \"/\" and is_valid(pointer, data):\n data[pointer] = 0\n elif command == \"!\":\n data.append(0)\n elif command == \"*\" and is_valid(pointer, data):\n output += chr(data[pointer])\n elif command == \"*\":\n output += chr(0)\n return output\n\ndef is_valid(pointer, data):\n return pointer >= 0 and pointer < len(data)", "def interpreter(tape):\n dct, selector, out = {0:0}, 0, ''\n for l in tape:\n if l == '>': selector += 1\n if l == '<': selector -= 1\n if l == '*': out += chr(dct.get(selector,0))\n if selector in dct:\n if l == '+': dct[selector] = (dct[selector] + 1) % 256\n if l == '-': dct[selector] = (dct[selector] - 1) % 256\n if l == '/': dct[selector] = 0\n if l == '!': dct[ max(dct)+1 ] = 0\n return out", "def interpreter(tape):\n test = Ticker(tape)\n return test.out\n \nclass Ticker():\n error = lambda x:None\n doc = {'>':'_incr', '<':'_decr', '*':'_addA', \n '+':'_icrC', '-':'_dcrC', '/':'_set', '!':'_addN'}\n \n def __init__(self, tape):\n self.dat = [0] * 256\n self.ind = 0\n self.out = ''\n self.run = [getattr(self, self.doc.get(k, 'error'))() for k in tape]\n \n def _set(self, dflt=0):#/\n self.dat[self.ind] = 0\n \n def _addN(self):#!\n self.dat[self.ind] = ord(self.out[-1])\n\n def _dcrC(self):#-\n self.dat[self.ind] -= 1\n \n def _icrC(self):#+\n self.dat[self.ind] += 1\n \n def _addA(self):#*\n self.out += chr(self.dat[self.ind]%256)\n \n def _incr(self):#>\n self.ind += 1 \n \n def _decr(self):#<\n self.ind -= 1\n", "def interpreter(s):\n memory,pointer,output = [0],0,[]\n for i in s:\n if 0<=pointer<len(memory):\n if i == \"+\" : memory[pointer] += 1 \n if i == \"-\" : memory[pointer] += -1 \n if i == '*' : output.append(chr(memory[pointer]%256))\n if i == \"!\" : memory.append(0)\n if i == '/' : memory[pointer] = 0\n if i == '>' : pointer += 1\n if i == \"<\" : pointer -= 1\n return \"\".join(output) or '\\x00'", "def interpreter(tape):\n selector = 0\n cells = dict()\n output = ''\n for c in tape:\n if c == '>':\n selector += 1\n elif c == '<':\n selector -= 1\n elif c == '*':\n output += chr(cells.get(selector, 0))\n elif c == '+':\n cells[selector] = (cells.get(selector, 0) + 1) % 256\n elif c == '-':\n cells[selector] = (cells.get(selector, 0) - 1) % 256\n elif c == '/':\n cells[selector] = 0\n elif c == '!':\n cells[len(cells)] = 0\n return output", "def interpreter(tape):\n memory, ptr, output = {0: 0}, 0, \"\"\n \n for command in tape:\n if command == \">\": ptr += 1\n elif command == \"<\": ptr -= 1\n elif command == \"+\":\n if memory.get(ptr) != None:\n memory[ptr] = (memory[ptr] + 1) % 256\n elif command == \"-\":\n if memory.get(ptr) != None:\n memory[ptr] = (memory[ptr] - 1) % 256\n elif command == \"/\":\n if memory.get(ptr) != None:\n memory[ptr] = 0\n elif command == \"!\": memory[len(memory)] = 0\n elif command == \"*\": output += chr(memory.get(ptr, 0))\n \n return output", "def interpreter(tape):\n cell, cells, out = 0, [0], ''\n for c in [k for k in tape if k in '<>!*+-/']:\n if c == '>': cell += 1\n if c == '<': cell -= 1\n if c == '!': cells += [0]\n if c == '*': out += chr(cells[cell] if cell >= 0 and cell < len(cells) else 0) \n if cell >= 0 and cell < len(cells):\n if c == '+': cells[cell] += 1\n if c == '-': cells[cell] -= 1\n if c == '/': cells[cell] = 0\n cells[cell] = {256:0, -1:255}.get(cells[cell], cells[cell])\n return out", "interpreter = lambda tape: (lambda l: ([([0 for l['mem'][l['p']] in [(l['mem'][l['p']]+1)%256]] if i == '+' and l['p'] in l['mem'].keys()else ([0 for l['p'] in [l['p']-1]] if i == '<' else ([0 for l['p'] in [l['p']+1]] if i == '>' else ([0 for l['mem'][l['p']] in [(255+l['mem'][l['p']])%256]] if i == '-' and l['p'] in l['mem'].keys() else ([0 for l['mem'][l['p']] in [0]] if i == '/' else ([0 for l['out'] in [l['out']+chr(l['mem'].get(l['p'],0))]] if i == '*' else ([0 for l['mem'][max(l['mem'].keys())+1] in [0]] if i == '!' else None))))))) for i in tape],l['out'])[1])({'mem':{0:0},'p':0,'out':''})", "from collections import defaultdict\n\ndef interpreter(tape):\n mem, out = defaultdict(int), []\n\n n = len(tape)\n idx = ptr = 0\n while idx < n:\n cmd = tape[idx]\n\n if cmd == '>': ptr += 1\n elif cmd == '<': ptr -= 1\n elif cmd == '+': mem[ptr] = (mem[ptr] + 1) % 256\n elif cmd == '-': mem[ptr] = (mem[ptr] - 1) % 256\n elif cmd == '/': mem[ptr] = 0\n elif cmd == '*': out.append(chr(mem[ptr]))\n\n idx += 1\n return ''.join(out)"] | {"fn_name": "interpreter", "inputs": [["++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++*/"], ["++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++*!>"], ["++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*<<*>>!>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*<<<<*!>>>>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*!>+++++++++++++++++++++++++++++++++*"], [">>>*"], ["<<<*"], ["+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/"], ["++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/"], ["This should equal Hello World++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/"]], "outputs": [["Hello World!"], ["Hello World!"], ["Hello World!"], ["\u0000"], ["\u0000"], ["Codewars"], ["John Doe"], ["https://github.com/Codewars/codewars.com"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 6,254 |
def interpreter(tape):
|
a7f8ac99e66453eef55f82edec5051d4 | UNKNOWN | A group of friends (n >= 2) have reunited for a get-together after
a very long time.
They agree that they will make presentations on holiday destinations
or expeditions they have been to only if it satisfies **one simple rule**:
> the holiday/journey being presented must have been visited _only_ by the presenter and no one else from the audience.
Write a program to output the presentation agenda, including the
presenter and their respective presentation titles.
---
### EXAMPLES
```python
presentation_agenda([
{'person': 'Abe', 'dest': ['London', 'Dubai']},
{'person': 'Bond', 'dest': ['Melbourne', 'Dubai']}
]) == [{'person': 'Abe', 'dest': ['London']},
{'person': 'Bond', 'dest': ['Melbourne']}]
presentation_agenda([
{'person': 'Abe', 'dest': ['Dubai']},
{'person': 'Brad', 'dest': ['Dubai']}
]) == []
presentation_agenda([
{'person': 'Abe', 'dest': ['London', 'Dubai']},
{'person': 'Bond', 'dest': ['Melbourne', 'Dubai']},
{'person': 'Carrie', 'dest': ['Melbourne']},
{'person': 'Damu', 'dest': ['Melbourne', 'Dubai', 'Paris']}
]) == [{'person': 'Abe', 'dest': ['London']},
{'person': 'Damu', 'dest': ['Paris']}]
``` | ["from collections import Counter\n\ndef presentation_agenda(friend_list):\n uniqueDest = {d for d,c in Counter(d for p in friend_list for d in p['dest']).items() if c == 1}\n pFilteredDest = tuple((p['person'], [d for d in p['dest'] if d in uniqueDest]) for p in friend_list)\n return [{'person': name, 'dest': lst} for name,lst in pFilteredDest if lst]", "def presentation_agenda(friend_list):\n out = []\n for friend in friend_list:\n p_list = friend['dest'] \n for f in friend_list:\n p_list = [loc for loc in p_list if f == friend or loc not in f['dest']]\n if len(p_list):\n out.append({'person': friend['person'], 'dest': p_list})\n return out", "from operator import itemgetter\nfrom collections import Counter\nfrom itertools import chain\n\ndef presentation_agenda(friend_list):\n okay = {k for k,v in Counter(chain.from_iterable(map(itemgetter('dest'), friend_list))).items() if v == 1}.__contains__\n result = []\n for friend in friend_list:\n temp = list(filter(okay, friend['dest']))\n if temp: result.append({'person':friend['person'], 'dest':temp})\n return result", "def presentation_agenda(friend_list):\n result = []\n for i, friend in enumerate(friend_list):\n ds = {x for j, f in enumerate(friend_list) if j != i for x in f['dest']}\n xs = [x for x in friend['dest'] if x not in ds]\n if xs:\n result.append({'person': friend['person'], 'dest': xs})\n return result", "from functools import reduce \ndef presentation_agenda(friend_list):\n def add_exclusive_locations(agenda, presenter):\n def is_unique(location):\n return False if any(location in friend['dest'] \n for friend in filter(lambda f: f != presenter, friend_list)\n ) else True\n\n exclusive = list(filter(is_unique, presenter['dest']))\n if exclusive:\n agenda.append({'person': presenter['person'], 'dest': exclusive})\n return agenda\n \n return reduce(add_exclusive_locations, friend_list, []); ", "from functools import reduce \ndef presentation_agenda(friend_list):\n \n def add_exclusive_locations(agenda, friend):\n \n def is_unique(loc):\n return all(peer == friend or loc not in peer['dest'] \n for peer in friend_list\n )\n \n exclusive = list(filter(is_unique, friend['dest']))\n if exclusive: \n agenda.append({'person': friend['person'], 'dest': exclusive})\n return agenda\n \n return reduce(add_exclusive_locations, friend_list, []); ", "from functools import reduce \ndef presentation_agenda(friend_list):\n\n def add_exclusive_locations(agenda, friend):\n locations_visited_by_peers = reduce(\n lambda lst, p: lst + p['dest'] if p != friend else lst,\n friend_list,\n []\n )\n \n def is_unique(loc): \n return loc not in locations_visited_by_peers\n \n exclusive = list(filter(is_unique, friend['dest']))\n if exclusive: # at least one location?\n agenda.append({'person': friend['person'], 'dest': exclusive})\n return agenda\n \n return reduce(add_exclusive_locations, friend_list, []); ", "from copy import deepcopy\n\ndef presentation_agenda(presentation_agenda):\n data = deepcopy(presentation_agenda)\n for person in data:\n \n B = []\n for p in presentation_agenda:\n if p['person'] != person['person']:\n B += p['dest']\n person['dest'] = sorted( list( set(person['dest']) - set(B) ) )\n \n return [person for person in data if person['dest']]\n", "def presentation_agenda(friend_list):\n out = []\n for friend in friend_list:\n p_list = friend['dest']\n sub_list = [x for x in friend_list if x != friend]\n for f in sub_list:\n p_list = [loc for loc in p_list if loc not in f['dest']]\n if len(p_list):\n out.append({'person': friend['person'], 'dest': p_list})\n return out\n", "from collections import Counter\n\ndef presentation_agenda(friend_list):\n all_dests = sum((friend['dest'] for friend in friend_list), [])\n uniq_dests = [dest for dest, count in Counter(all_dests).items() if count == 1]\n agenda = []\n for friend in friend_list:\n uniq = [x for x in friend['dest'] if x in uniq_dests]\n if uniq:\n agenda.append({'person': friend['person'], 'dest': uniq})\n return agenda"] | {"fn_name": "presentation_agenda", "inputs": [[[{"person": "Abe", "dest": ["London", "Dubai"]}, {"person": "Bond", "dest": ["Melbourne", "Dubai"]}]], [[{"person": "Abe", "dest": ["Dubai"]}, {"person": "Brad", "dest": ["Dubai"]}]], [[{"person": "Abe", "dest": ["London", "Dubai"]}, {"person": "Bond", "dest": ["Melbourne", "Dubai"]}, {"person": "Carrie", "dest": ["Melbourne"]}, {"person": "Damu", "dest": ["Melbourne", "Dubai", "Paris"]}]], [[{"person": "John", "dest": ["Ahmedabad", "Baghdad", "Delhi", "Dhaka"]}, {"person": "Mickeal Angelo", "dest": ["Ahmedabad", "Baghdad", "Delhi", "Hong Kong", "Istanbul", "Jakarta", "Mumbai", "Santiago", "Singapore"]}, {"person": "Gandalf", "dest": ["Chennai", "Hong Kong"]}]]], "outputs": [[[{"person": "Abe", "dest": ["London"]}, {"person": "Bond", "dest": ["Melbourne"]}]], [[]], [[{"person": "Abe", "dest": ["London"]}, {"person": "Damu", "dest": ["Paris"]}]], [[{"person": "John", "dest": ["Dhaka"]}, {"person": "Mickeal Angelo", "dest": ["Istanbul", "Jakarta", "Mumbai", "Santiago", "Singapore"]}, {"person": "Gandalf", "dest": ["Chennai"]}]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,660 |
def presentation_agenda(friend_list):
|
784bd172dcce09deffa4aa76ec9e8c66 | UNKNOWN | Define a "prime prime" number to be a rational number written as one prime number over another prime number: `primeA / primeB` (e.g. `7/31`)
Given a whole number `N`, generate the number of "prime prime" rational numbers less than 1, using only prime numbers between `0` and `N` (non inclusive).
Return the count of these "prime primes", and the integer part of their sum.
## Example
```python
N = 6
# The "prime primes" less than 1 are:
2/3, 2/5, 3/5 # count: 3
2/3 + 2/5 + 3/5 = 1.6667 # integer part: 1
Thus, the function should return 3 and 1.
``` | ["from bisect import bisect_left\n\ndef sieve(n):\n sieve, primes = [0]*(n+1), []\n for i in range(2, n+1):\n if not sieve[i]:\n primes.append(i)\n for j in range(i**2, n+1, i): sieve[j] = 1\n return primes\n\nPRIMES = sieve(100000)\n\ndef prime_primes(n):\n lst = PRIMES[:bisect_left(PRIMES, n)]\n divs = [p/q for i,p in enumerate(lst) for q in lst[i+1:]]\n return len(divs), int(sum(divs))", "primes = [2] + [ n for n in range(3, 1000, 2) if all(n % r for r in range(3, int(n**0.5)+1, 2) ) ]\n\nimport itertools\n\ndef prime_primes(N):\n pairs = list(itertools.combinations((p for p in primes if p < N), 2))\n return len(pairs), int( sum( a/b for a, b in pairs ) )", "from itertools import combinations\n\ndef prime_primes(N):\n primes = [2] + [n for n in range(3, N, 2) if all(n % d for d in range(3, int(n**0.5) + 1, 2))]\n \n pp = [n / float(d) for n, d in combinations(primes, 2)]\n return len(pp), int(sum(pp))", "from bisect import bisect_left as bisect\nfrom itertools import combinations\n\nimport numpy as np\n\nN = 100001\nxs = np.ones(N)\nxs[:2] = 0\nxs[2 * 2 :: 2] = 0\nfor i in range(3, int(N ** 0.5) + 1):\n if xs[i]:\n xs[i * i :: i] = 0\nprimes = [i for i, x in enumerate(xs) if x]\n\n\ndef prime_primes(N):\n i = bisect(primes, N)\n xs = [a / b for a, b in combinations(primes[:i], 2)]\n return len(xs), int(sum(xs))\n", "def prime_primes(n):\n sieve = [0, 0] + [1] * (n - 2)\n for k in range(2, int(n ** .5) + 1):\n if sieve[k]: sieve[k*k::k] = ((n-k*k-1) // k + 1) * [0]\n primes = [p for p, b in enumerate(sieve) if b]\n ratios = [b / a for i, a in enumerate(primes) for b in primes[:i]]\n return len(ratios), int(sum(ratios))", "p=[2]\nfor i in range(3,1000,2):\n if all(i%j for j in p): p.append(i)\n\ndef prime_primes(N):\n cnt=0\n sm=0\n for i in range(len(p)):\n for j in range(i+1,len(p)):\n if p[j]>=N: \n break\n cnt+=1\n sm+=p[i]/p[j]\n if p[i]>=N:\n break\n return cnt,int(sm)", "import math\n\n\ndef prime_primes(N):\n primes = [i for i in range(N) if is_prime(i)]\n prime_prms = []\n\n for i in range(len(primes) - 1):\n for j in range(primes.index(primes[i]) + 1, len(primes)):\n prime_prms.append(primes[i] / primes[j])\n\n count_of_prime_primes = len(prime_prms)\n\n return count_of_prime_primes, math.floor(sum(prime_prms))\n \n \ndef is_prime(nr):\n if nr > 1:\n for i in range(2, nr):\n if (nr % i) == 0:\n return False\n return True\n return False", "def prime_primes(N):\n prime = []\n for iter in range(2,N):\n for i in range(2,iter):\n if (iter%i)==0:\n break\n else:\n prime.append(iter)\n \n l = [j/i for i in prime for j in prime if (j/i)<1]\n return (len(l),int(sum(l)))", "import math\n\ndef is_prime(n):\n return n == 2 or n > 2 and n % 2 and all(n % i for i in range(3, int(n ** 0.5) + 1, 2))\n\ndef prime_primes(N):\n a = [i for i in range(2, N) if is_prime(i)]\n total, count = 0, 0\n for elem1 in a:\n for elem2 in a:\n if(elem1 < elem2):\n count += 1\n total += elem1 / elem2\n return (count, math.floor(total))\n"] | {"fn_name": "prime_primes", "inputs": [[6], [4], [10], [65], [0], [1000], [666]], "outputs": [[[3, 1]], [[1, 0]], [[6, 3]], [[153, 63]], [[0, 0]], [[14028, 6266]], [[7260, 3213]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,389 |
def prime_primes(N):
|
62e983878d689e045a059991cdce9f1d | UNKNOWN | An array is called `zero-balanced` if its elements sum to `0` and for each positive element `n`, there exists another element that is the negative of `n`. Write a function named `ìsZeroBalanced` that returns `true` if its argument is `zero-balanced` array, else return `false`. Note that an `empty array` will not sum to `zero`. | ["from collections import Counter\n\ndef is_zero_balanced(arr):\n c = Counter(arr)\n return bool(arr) and all(c[k] == c[-k] for k in c)", "def is_zero_balanced(arr):\n return all(arr) == sum(arr) == 0", "def is_zero_balanced(arr):\n return arr != [] and sum(arr) == 0 and all(-x in arr for x in arr)", "def is_zero_balanced(arr):\n return False if not 0 in arr else not sum(arr)", "def is_zero_balanced(arr):\n pos = (n for n in arr if n > 0)\n neg = (-n for n in arr if n < 0)\n return sorted(pos) == sorted(neg) if arr else False\n", "def is_zero_balanced(arr):\n return all(arr.count(i)==arr.count(-i) for i in arr) if arr else False", "def is_zero_balanced(arr):\n return all(arr) == 0 and sum(arr) == 0", "def is_zero_balanced(arr):\n return bool(arr) and sum(arr) == 0 and all(-x in arr for x in arr if x > 0)", "from collections import Counter\ndef is_zero_balanced(arr):\n if not arr:\n return False\n arr = Counter(arr)\n for element in arr:\n if not arr[element] == arr[-element]:\n return False\n return True ", "def is_zero_balanced(a):\n p = sorted(abs(e) for e in a if e > 0)\n n = sorted(abs(e) for e in a if e < 0)\n return all(x == y for x, y in zip(p, n)) and len(p) == len(n) and len(a) > 0"] | {"fn_name": "is_zero_balanced", "inputs": [[[3]], [[-3]], [[0, 0, 0, 0, 0, 0]], [[0, 1, -1]], [[]], [[3, -2, -1]], [[0]], [[1, 1, -2]], [[-1, 1, -2, 2, -2, -2, -4, 4]], [[0, 0, 0, 0, 0]]], "outputs": [[false], [false], [true], [true], [false], [false], [true], [false], [false], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,293 |
def is_zero_balanced(arr):
|
93a07942d4694851c8117b176949fa94 | UNKNOWN | A core idea of several left-wing ideologies is that the wealthiest should *support* the poorest, no matter what and that is exactly what you are called to do using this kata (which, on a side note, was born out of the necessity to redistribute the width of `div`s into a given container).
You will be given two parameters, `population` and `minimum`: your goal is to give to each one according to his own needs (which we assume to be equal to `minimum` for everyone, no matter what), taking from the richest (bigger numbers) first.
For example, assuming a population `[2,3,5,15,75]` and `5` as a minimum, the expected result should be `[5,5,5,15,70]`. Let's punish those filthy capitalists, as we all know that being rich has to be somehow a fault and a shame!
If you happen to have few people as the richest, just take from the ones with the lowest index (the closest to the left, in few words) in the array first, on a 1:1 based heroic proletarian redistribution, until everyone is satisfied.
To clarify this rule, assuming a population `[2,3,5,45,45]` and `5` as `minimum`, the expected result should be `[5,5,5,42,43]`.
If you want to see it in steps, consider removing `minimum` from every member of the population, then iteratively (or recursively) adding 1 to the poorest while removing 1 from the richest. Pick the element most at left if more elements exist with the same level of minimal poverty, as they are certainly even more aligned with the party will than other poor people; similarly, it is ok to take from the richest one on the left first, so they can learn their lesson and be more kind, possibly giving more *gifts* to the inspectors of the State!
In steps:
```
[ 2, 3, 5,45,45] becomes
[-3,-2, 0,40,40] that then becomes
[-2,-2, 0,39,40] that then becomes
[-1,-2, 0,39,39] that then becomes
[-1,-1, 0,38,39] that then becomes
[ 0,-1, 0,38,38] that then becomes
[ 0, 0, 0,37,38] that then finally becomes (adding the minimum again, as no value is no longer under the poverty threshold
[ 5, 5, 5,42,43]
```
If giving `minimum` is unfeasable with the current resources (as it often comes to be the case in socialist communities...), for example if the above starting population had set a goal of giving anyone at least `30`, just return an empty array `[]`. | ["def socialist_distribution(population, minimum):\n if minimum > sum(population)//len(population):\n return []\n while min(population) < minimum:\n population[population.index(min(population))] += 1\n population[population.index(max(population))] -= 1\n return population\n", "def socialist_distribution(population, minimum):\n if len(population) * minimum > sum(population):\n return []\n \n while min(population) < minimum:\n i_max = population.index(max(population))\n i_min = population.index(min(population))\n population[i_max] -= 1\n population[i_min] += 1\n \n return population", "def socialist_distribution(pop, minimum):\n if minimum > sum(pop)//len(pop):\n return []\n while min(pop) < minimum:\n pop[pop.index(min(pop))] += 1\n pop[pop.index(max(pop))] -= 1\n return pop", "def socialist_distribution(p, m):\n if sum(p)/len(p)<m : return []\n while min(p) < m:\n p[p.index(min(p))] +=1\n p[p.index(max(p))] -=1\n return p", "def socialist_distribution(population, minimum):\n if sum(population) < minimum * len(population):\n return []\n population = population[:]\n for _ in range(sum(max(minimum - p, 0) for p in population)):\n population[min(range(len(population)), key=population.__getitem__)] += 1\n population[max(range(len(population)), key=population.__getitem__)] -= 1\n return population", "def socialist_distribution(population, minimum):\n if sum(population) < len(population) * minimum:\n return []\n while 1:\n poor = rich = 0\n for idx, need in enumerate(population):\n if need < population[poor]: poor = idx\n if need > population[rich]: rich = idx\n if population[poor] >= minimum:\n return population\n population[rich] -= 1\n population[poor] += 1", "socialist_distribution=lambda p, m: [] if sum(p)<m*len(p) else p if all(m<=e for e in p) else (lambda mini, maxi: socialist_distribution(p[:mini]+[p[mini]+1]+p[mini+1:maxi]+[p[maxi]-1]+p[maxi+1:], m) if mini<maxi else socialist_distribution(p[:maxi]+[p[maxi]-1]+p[maxi+1:mini]+[p[mini]+1]+p[mini+1:], m))(p.index(min(p)),p.index(max(p)))", "def socialist_distribution(a, n):\n m = sum(a)\n if m < len(a) * n: return []\n if m == len(a) * n: return [n] * len(a)\n for i in range(sum(n - x for x in a if x < n)):\n a[a.index(max(a))] -= 1\n return [max(x, n) for x in a]", "def socialist_distribution(a, m):\n new = [i - m for i in a]\n while any(i > 0 for i in new) or sum(new)==0: \n if all((i + m) >= m for i in new) : return [i + m for i in new]\n new[new.index(max(new))] -= 1\n new[new.index(min(new))] += 1\n return []", "def socialist_distribution(population, minimum):\n if sum(population) < (minimum * len(population)):\n return []\n if min(population) >= minimum:\n return population\n population[population.index(max(population))] -= 1\n population[population.index(min(population))] += 1\n return socialist_distribution(population,minimum)"] | {"fn_name": "socialist_distribution", "inputs": [[[2, 3, 5, 15, 75], 5], [[2, 3, 5, 15, 75], 20], [[2, 3, 5, 45, 45], 5], [[2, 3, 5, 45, 45], 30], [[24, 48, 22, 19, 37], 30]], "outputs": [[[5, 5, 5, 15, 70]], [[20, 20, 20, 20, 20]], [[5, 5, 5, 42, 43]], [[]], [[30, 30, 30, 30, 30]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,167 |
def socialist_distribution(population, minimum):
|
27b67bbe0b442add743303905c9770c1 | UNKNOWN | In this kata, we want to discover a small property of numbers.
We say that a number is a **dd** number if it contains d occurences of a digit d, (d is in [1,9]).
## Examples
* 664444309 is a **dd** number, as it contains 4 occurences of the number 4
* 30313, 122 are **dd** numbers as they respectively contain 3 occurences of the number 3, and (1 occurence of the number 1 AND 2 occurences of the number 2)
* 123109, 0, 56542 are not **dd** numbers
## Task
Your task is to implement a function called `is_dd` (`isDd` in javascript) that takes a **positive** number (type depends on the language) and returns a boolean corresponding to whether the number is a **dd** number or not. | ["from collections import Counter\n\n\ndef is_dd(n):\n return any(value==count for value, count in Counter(int(x) for x in str(n)).items())", "from collections import Counter\n\ndef is_dd(n):\n return any(int(k) == v for k, v in Counter(str(n)).items())", "def is_dd(n):\n for i in range(1, 10):\n if str(n).count(str(i)) == i: return True\n return False", "def is_dd(n):\n lstr = list(str(n))\n dds = 0\n \n for x in lstr:\n numdigits = 0;\n \n for y in lstr:\n if y == x:\n numdigits += 1\n if numdigits == int(x):\n return True\n \n return False\n \n", "def is_dd(n):\n n = str(n)\n for i in range(1, 10):\n if n.count(str(i)) == i:\n return True\n return False", "def is_dd(n):\n for i in set([int(d) for d in str(n)]):\n if str(n).count(str(i))==i:\n return True\n return False", "def is_dd(n):\n n = str(n)\n return any(n.count(d) == int(d) for d in set(n))", "import collections\n\ndef is_dd(n):\n counter = collections.Counter(str(n))\n return any(counter[str(i)] == i for i in range(1, 10))", "is_dd=lambda n:any(int(c)==x for c,x in __import__(\"collections\").Counter(str(n)).items())"] | {"fn_name": "is_dd", "inputs": [[664444309], [122], [30313], [5023011], [9081231]], "outputs": [[true], [true], [true], [false], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,281 |
def is_dd(n):
|
e983c3ef22b1ba2fc63b04b9d87357e2 | UNKNOWN | Your task is to get Zodiac Sign using input ```day``` and ```month```.
For exapmle:
```python
get_zodiac_sign(1,5) => 'Taurus'
get_zodiac_sign(10,10) => 'Libra'
```
Correct answers are (preloaded):
```python
SIGNS = ['Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius']
```
P.S. Each argument is correct integer number.
WESTERN ASTROLOGY STAR SIGN DATES
* Aries (March 21-April 19)
* Taurus (April 20-May 20)
* Gemini (May 21-June 20)
* Cancer (June 21-July 22)
* Leo (July 23-August 22)
* Virgo (August 23-September 22)
* Libra (September 23-October 22)
* Scorpio (October 23-November 21)
* Sagittarius (November 22-December 21)
* Capricorn (December 22-January 19)
* Aquarius (January 20 to February 18)
* Pisces (February 19 to March 20) | ["def get_zodiac_sign(day, month):\n\n signs = [\"Aquarius\", \"Pisces\", \"Aries\", \"Taurus\", \"Gemini\", \"Cancer\",\n \"Leo\", \"Virgo\", \"Libra\", \"Scorpio\", \"Sagittarius\", \"Capricorn\"]\n\n limits = [20, 19, 21, 20, 21, 21, 23, 23, 23, 23, 22, 22]\n\n return signs[month - 1] if limits[month - 1] <= day else signs[(month + 10) % 12]", "def get_zodiac_sign(day,month):\n#Aries\n if month == 3:\n if day >= 21 and day <= 31:\n return \"Aries\"\n else:\n if month == 4:\n if day >= 1 and day <= 19:\n return \"Aries\"\n#Taurus\n if month == 4:\n if day >= 20 and day <= 30:\n return \"Taurus\"\n else:\n pass\n if month == 5:\n if day >= 1 and day <= 20:\n return \"Taurus\"\n else:\n pass\n#Gemeni\n if month == 5:\n if day >= 21 and day <= 31:\n return \"Gemini\"\n else:\n pass\n if month == 6:\n if day >= 1 and day <= 20:\n return \"Gemini\"\n else:\n pass\n#Cancer\n if month == 6:\n if day >= 21 and day <= 30:\n return \"Cancer\"\n else:\n pass\n if month == 7:\n if day >= 1 and day <= 22:\n return \"Cancer\"\n#Leo\n if month == 7:\n if day >= 23 and day <= 31:\n return \"Leo\"\n if month == 8:\n if day >= 1 and day <= 22:\n return \"Leo\"\n#Virgo\n if month == 8:\n if day >= 23 and day <= 31:\n return \"Virgo\"\n if month == 9:\n if day >= 1 and day <= 22:\n return \"Virgo\"\n#Libra\n if month == 9:\n if day >= 23 and day <= 30:\n return \"Libra\"\n if month == 10:\n if day >= 1 and day <= 22:\n return \"Libra\"\n#Scorpio\n if month == 10:\n if day >= 23 and day <= 31:\n return \"Scorpio\"\n if month == 11:\n if day >= 1 and day <= 21:\n return \"Scorpio\"\n#Sagittarius\n if month == 11:\n if day >= 22 and day <= 30:\n return \"Sagittarius\"\n if month == 12:\n if day >= 1 and day <= 21:\n return \"Sagittarius\"\n#Capricorn\n if month == 12:\n if day >= 22 and day <= 31:\n return \"Capricorn\"\n if month == 1:\n if day >= 1 and day <= 19:\n return \"Capricorn\"\n#Aquarius\n if month == 1:\n if day >= 20 and day <= 31:\n return \"Aquarius\"\n if month == 2:\n if day >= 1 and day <= 18:\n return \"Aquarius\"\n#Pisces\n if month == 2:\n if day >= 19 and day <= 28:\n return \"Pisces\"\n if month == 3:\n if day >= 1 and day <= 20:\n return \"Pisces\"", "from bisect import bisect_left as bisect\nfrom datetime import date\n\nCONFIG = [\n (\"Capricorn\", 19),\n (\"Aquarius\", 18),\n (\"Pisces\", 20),\n (\"Aries\", 19),\n (\"Taurus\", 20),\n (\"Gemini\", 20),\n (\"Cancer\", 22),\n (\"Leo\", 22),\n (\"Virgo\", 22),\n (\"Libra\", 22),\n (\"Scorpio\", 21),\n (\"Sagittarius\", 21),\n (\"Capricorn\", 31)]\n\nDATES, _SIGNS = map(tuple, zip(*((date(1992, min(i,12), d), s) for i,(s,d) in enumerate(CONFIG,1))))\n\ndef get_zodiac_sign(d, m):\n return _SIGNS[bisect(DATES, date(1992,m,d))]", "from datetime import datetime\n\ndata = \"\"\"\nAries March 21 April 19\nTaurus April 20 May 20\nGemini May 21 June 20\nCancer June 21 July 22\nLeo July 23 August 22\nVirgo August 23 September 22\nLibra September 23 October 22\nScorpio October 23 November 21\nSagittarius November 22 December 21\nCapricorn December 22 January 19\nAquarius January 20 February 18\nPisces February 19 March 20\n\"\"\"\ndata = [line.split() for line in data.split('\\n') if line.strip()]\nmonth = lambda s: datetime.strptime(s, '%B').month\ndata = [(z, month(m1), int(d1), month(m2), int(d2)) for z, m1, d1, m2, d2 in data]\n\ndef get_zodiac_sign(day, month):\n for z, m1, d1, m2, d2 in data:\n if (m1 == month and d1 <= day) or (m2 == month and day <= d2):\n return z", "def get_zodiac_sign(day, month):\n SIGNS = ['Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius']\n t = int(month)*100+int(day)\n com = [119,218,320,419,520,621,722,822,922,1023,1122,1222]\n for i in range(0, len(com)-1):\n if (t > com[i]) & (t <= com[i+1]):\n return SIGNS[i+1]\n return SIGNS[0] ", "def get_zodiac_sign(day, month):\n if (((month == 12) & (day > 21)) | ((month == 1) & (day < 20))):\n return \"Capricorn\"\n elif (((month == 1) & (day > 19)) | ((month == 2) & (day < 19))):\n return \"Aquarius\"\n elif (((month == 2) & (day > 18)) | ((month == 3) & (day < 21))):\n return \"Pisces\"\n elif (((month == 3) & (day > 20)) | ((month == 4) & (day < 20))):\n return \"Aries\"\n elif (((month == 4) & (day > 19)) | ((month == 5) & (day < 21))):\n return \"Taurus\"\n elif (((month == 5) & (day > 20)) | ((month == 6) & (day < 21))):\n return \"Gemini\"\n elif (((month == 6) & (day > 20)) | ((month == 7) & (day < 23))):\n return \"Cancer\"\n elif (((month == 7) & (day > 22)) | ((month == 8) & (day < 23))):\n return \"Leo\"\n elif (((month == 8) & (day > 22)) | ((month == 9) & (day < 23))):\n return \"Virgo\"\n elif (((month == 9) & (day > 22)) | ((month == 10) & (day < 23))):\n return \"Libra\"\n elif (((month == 10) & (day > 22)) | ((month == 11) & (day < 22))):\n return \"Scorpio\"\n elif (((month == 11) & (day > 21)) | ((month == 12) & (day < 22))):\n return \"Sagittarius\"", "from datetime import datetime\ndef get_zodiac_sign(day,month):\n date=datetime(1+(month==1 and day<20),month,day)\n dates=[(20,18),(19,20),(21,19),(20,20),(21,20),(21,22),(23,22),(23,22),(23,22),(23,21),(22,21),(22,19)]\n signs=\"Aquarius Pisces Aries Taurus Gemini Cancer Leo Virgo Libra Scorpio Sagittarius Capricorn\".split()\n return next(s for i,(d,s) in enumerate(zip(dates,signs)) if datetime(1,i+1,d[0])<=date<=datetime(1+(i==11),(i+1)%12+1,d[1]))"] | {"fn_name": "get_zodiac_sign", "inputs": [[10, 10], [1, 5], [6, 9], [25, 11]], "outputs": [["Libra"], ["Taurus"], ["Virgo"], ["Sagittarius"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 6,287 |
def get_zodiac_sign(day, month):
|
9de48104f6270a3120b4e2c591cf2f29 | UNKNOWN | This kata is inspired on the problem #50 of the Project Euler.
The prime ``` 41``` is the result of the sum of many consecutive primes.
In fact, ``` 2 + 3 + 5 + 7 + 11 + 13 = 41 , (6 addens) ```
Furthermore, the prime ``` 41``` is the prime below ``` 100 (val_max)``` that has the longest chain of consecutive prime addens.
The prime with longest chain of addens for ```val_max = 500``` is ```499``` with ```17``` addens.
In fact:
```3+5+7+11+13+17+19+23+29+31+37+41+43+47+53+59+61= 499```
Find the function ```prime_maxlength_chain()```(primeMaxlengthChain() javascript), that receives an argument ```val_max```, the upper limit, all the found primes should be less than ```val_max``` and outputs this found prime.
Let's see some cases:
```python
prime_maxlength_chain(100) == [41]
prime_maxlength_chain(500) == [499]
```
If we have more than one prime with these features, the function should output an array with the found primes sorted.
```python
prime_maxlength_chain(499) == [379, 491]
```
Random Tests for `val_max` (`valMax`)
```
100 ≤ val_max ≤ 500.000
```
Enjoy it! | ["# RWH primes\nLIMIT = 500000\nsieve = [True] * (LIMIT//2)\nfor n in range(3, int(LIMIT**0.5) +1, 2):\n if sieve[n//2]: sieve[n*n//2::n] = [False] * ((LIMIT-n*n-1)//2//n +1)\nPRIMES = [2] + [2*i+1 for i in range(1, LIMIT//2) if sieve[i]]\n\n\ndef prime_maxlength_chain(val_max):\n if val_max < 5:\n return []\n \n found = []\n \n # the sum of the first 400 primes > LIMIT\n for n in range(2, 400):\n if sum(PRIMES[:n]) >= val_max:\n max_size = n\n break\n \n for size in range(max_size, 1, -1):\n # if sequence size is even, it *must* start with 2\n if size % 2 == 0:\n n = sum(PRIMES[:size])\n if n < val_max and n in PRIMES:\n return [n]\n \n # if sequence size is odd, it *cannot* start with 2\n else:\n for start in range(1, max_size-size +1):\n n = sum(PRIMES[start:start+size])\n if n < val_max and n in PRIMES:\n found.append(n)\n \n if found:\n return found", "def is_prime(n):\n for i in range(2, int(n**0.5)+1):\n if n % i == 0:\n return False\n return True\n\n\ndef prime_maxlength_chain(n):\n\n summ, primes, res = 0, [], []\n\n for i in range(2, n):\n if is_prime(i):\n if summ + i < n:\n summ += i\n primes.append(i)\n elif summ + i - primes[0] < n:\n summ += i\n primes.append(i)\n else:\n break\n \n l = len(primes)\n\n for j in range(l, 0, -1):\n for k in range(l-j+1):\n lst = primes[k:k+j]\n temp = sum(lst)\n if is_prime(temp):\n res.append(temp)\n if len(res) != 0:\n break\n\n return res", "from itertools import accumulate\nfrom bisect import bisect_left\nimport numpy as np\n\nlimit = 555555\nsieve = np.ones(limit, dtype=bool)\nsieve[0] = sieve[1] = 0\nsieve[2*2::2] = 0\nfor i in range(3, int(len(sieve)**0.5)+1, 2):\n if sieve[i]:\n sieve[i*i::i] = 0\nprimes = [i for i, x in enumerate(sieve) if x]\nacc_primes = list(accumulate([0] + primes))\ns_primes = set(primes)\n\n\ndef prime_maxlength_chain(n):\n limit = bisect_left(primes, n)\n ans, max_len = [], 1\n for l in range(limit):\n for r in range(l+max_len, limit+1):\n t = acc_primes[r] - acc_primes[l]\n if t >= n:\n break\n if t in s_primes and r-l >= max_len:\n ans, max_len = ([t], r-l) if r-l > max_len else (ans + [t], max_len)\n return ans", "limit = 500000\nsieve = [0]*2+list(range(2,limit))\nfor i in range(2,limit):\n for j in range(i*i,limit,i):\n sieve[j]=0\nprimes = [i for i in sieve if i]\n\ndef prime_maxlength_chain(n):\n req = [i for i in primes if i < n]\n P = set(req)\n D = {}\n found = []\n \n for i, j in enumerate(req):\n D[j] = [0, 0]\n for k in list(D):\n o, p = D[k]\n if o in P : found.append([o, p])\n if o + j > n:\n del D[k]\n continue\n D[k][0] += j\n D[k][1] += 1\n \n m = max(found, key=lambda x: x[1])[1]\n return [i[0] for i in found if i[1] == m]", "def prime_maxlength_chain(n):\n p=[False,False]+[True]*(n-1)\n for i in range(2,n+1):\n if p[i]:\n for j in range(i*2,n+1,i):\n p[j]=False\n pn=[i for i,b in enumerate(p) if b]\n ps=set(pn)\n maxl=[0,[]]\n for l in range(6,len(pn)):\n if sum(pn[:l])>=n:\n break\n for i in range(len(pn)-l):\n s=sum(pn[i:i+l])\n if s>=n:\n break\n elif s in ps:\n if maxl[0]<l:\n maxl=[l,[s]]\n else:\n maxl[1].append(s)\n return maxl[1]", "def prime_maxlength_chain(val_max):\n \n # Calcula os primos usando o crivo\n primes = []\n sieve = [1]*(val_max+1)\n sieve[0] = 0\n sieve[1] = 0\n for i in range(2, (val_max+1)):\n if sieve[i] == 0:\n continue\n for j in range(i*i, (val_max+1), i):\n sieve[j] = 0\n \n # Guarda os primos num array separado\n for i in range(val_max+1):\n if sieve[i] == 1:\n primes.append(i)\n \n # Testa encontrar primos que s\u00e3o somas de 'j' primos consecutivos \n for j in range (400, -1, -1):\n \n # Aplica uma tecnica de janela deslizante (adicionando um cara na frente e removendo o do fundo) pra calcular mais rapido todas as janelas possiveis\n answer = []\n acc = 0\n if len(primes) < j:\n continue\n \n # Coloca os primeiros caras na janela atual\n for i in range(j):\n acc += primes[i]\n \n # Testa se eh primo\n if acc <= val_max and sieve[acc] == 1:\n answer.append(acc)\n \n # Aqui faz o procedimento de colocar o proximo cara e tirar o ultimo da janela ('deslizando' a janela pra frente)\n for i in range(j, len(primes)):\n acc += primes[i]\n acc -= primes[i-j]\n # Quando o valor ja for maior que o maximo, j\u00e1 pode parar\n if acc >= val_max:\n break\n # Verifica se eh primo\n if acc <= val_max and sieve[acc] == 1:\n answer.append(acc)\n # Se com o tamanho 'j' a gente encontrou resposta, a resposta eh a lista de primos com esse tamanho\n if len(answer) > 0:\n return answer\n", "def sieve(n):\n n = n - 1 # finding primes smaller than the limit\n primes = [True for i in range(n+1)]\n result = []\n p = 2\n while p * p <= n:\n if primes[p]:\n for i in range(p * 2, n+1, p):\n primes[i] = False\n p += 1\n for p in range(2, n+1):\n if primes[p]:\n result.append(p)\n #print(result)\n return result\n\n\n\ndef prime_maxlength_chain(n):\n prime_num = sieve(n)\n prime_sums = [[0,2]]\n count_max = 0\n results = []\n if n == 0:\n return []\n i, j = 0, 0\n\n while sum(prime_num[i:count_max+i+j]) < n:\n while sum(prime_num[i:count_max+i+j]) < n:\n #print(prime_num[i:count_max+i+j], i, j, count_max)\n count = len(prime_num[i:count_max+i+j])\n summe = sum(prime_num[i:count_max+i+j])\n if summe in prime_num:\n prime_sums.append([count, summe])\n\n j += 1\n if count_max <= prime_sums[-1][0]:\n count_max = prime_sums[-1][0]\n i += 1\n j = 0\n prime_sums.sort()\n for p in prime_sums:\n if p[0] == prime_sums[-1][0]:\n results.append(p[1])\n\n\n return results", "import numpy\ndef primesto(n):\n \"\"\" Returns a array of primes, 3 <= p < n \"\"\"\n sieve = numpy.ones(n//2, dtype=numpy.bool)\n for i in range(3,int(n**0.5)+1,2):\n if sieve[i//2]:\n sieve[i*i//2::i] = False\n return [2]+list(2*numpy.nonzero(sieve)[0][1::]+1)\n\ndef cum_sum_500k():\n return numpy.array([0]+primesto(500000)).cumsum()\n\ndef circular_list():\n p = primesto(500000)\n c = cum_sum_500k()\n l=[]\n s=1\n for i in range(400):\n for j in range(0,i-s+1):\n x=c[i]-c[j]\n #print(i,j,x)\n if x in p:\n if i-j > s: s = i-j\n #l += [[x,i-j,[p[k] for k in range(j,i)]]]\n l += [[x,i-j]]\n #print((x,s,i))\n l.sort()\n return l\n# print(p[i])\n\ndef prime_maxlength_chain(n):\n if prime_maxlength_chain.cl == []:\n prime_maxlength_chain.cl = circular_list()\n cl=prime_maxlength_chain.cl\n for i in range(len(cl)):\n idx = 0\n if cl[i][0] >= n:\n idx = i-1\n break\n l = []\n for i in range(idx,1,-1):\n if cl[i][1] == cl[idx][1]: l += [cl[i][0]]\n else: break\n l.sort()\n return l\n\n#If you want to generate the circular primes list use cl=[] below\n#prime_maxlength_chain.cl = []\nprime_maxlength_chain.cl = [\n[2, 1],[3, 1],[5, 2],[17, 4],[41, 6],[127, 9],[197, 12],[281, 14],[379, 15],[491, 15],[499, 17],[563, 17],[857, 19],[953, 21],[1151, 23],[1259, 25],[1361, 25],\n[1583, 27],[1823, 27],[2069, 27],[2099, 29],[2399, 31],[2417, 33],[2579, 35],[2897, 35],[2909, 37],[3803, 39],[3821, 41],[4217, 43],[4421, 43],[4651, 45],[4871, 45],[5107, 47],\n[5333, 47],[5813, 49],[6053, 49],[6079, 53],[6599, 55],[7699, 60],[8273, 61],[8893, 64],[9521, 65],[10181, 65],[10859, 65],[11597, 71],[12329, 71],[12713, 73],[13099, 75],[13877, 75],\n[14669, 75],[15527, 79],[16823, 81],[18131, 81],[19013, 81],[21407, 85],[22037, 95],[22039, 96],[24133, 100],[25237, 102],[28087, 103],[28099, 105],[28687, 105],[28697, 108],[31729, 111],[32353, 114],\n[33623, 115],[34913, 117],[36217, 117],[36871, 117],[37561, 122],[38921, 124],[41017, 125],[42451, 125],[42463, 127],[43201, 130],[44683, 132],[47711, 133],[49253, 133],[49279, 137],[52517, 141],[54167, 143],\n[55837, 146],[61027, 152],[64613, 155],[66463, 158],[70241, 162],[76099, 163],[78121, 165],[78139, 167],[79151, 167],[81203, 169],[84313, 171],[86453, 178],[92951, 183],[101999, 191],[102001, 192],[109147, 198],\n[115279, 201],[116531, 203],[116533, 204],[119069, 206],[121631, 208],[129419, 214],[132059, 216],[137477, 217],[138863, 219],[141671, 221],[147347, 221],[148817, 225],[153137, 225],[154579, 225],[157489, 225],[157561, 229],\n[157579, 231],[162007, 231],[163483, 231],[164963, 231],[164999, 233],[166541, 237],[171131, 239],[172687, 241],[175781, 241],[178889, 241],[182009, 241],[182099, 247],[182107, 249],[198197, 251],[199831, 251],[201599, 257],\n[203279, 259],[204979, 261],[210053, 261],[213461, 261],[213533, 267],[215261, 267],[218749, 269],[222269, 273],[225821, 273],[225829, 275],[240353, 279],[240371, 281],[240379, 283],[242243, 283],[244109, 283],[251609, 285],\n[255443, 291],[257353, 291],[263171, 296],[269069, 297],[281023, 299],[283079, 305],[287137, 308],[303643, 309],[303691, 313],[305783, 313],[310019, 317],[314267, 317],[318557, 321],[324991, 321],[325009, 323],[325019, 326],\n[329401, 328],[333821, 330],[338279, 332],[342761, 334],[351811, 335],[354097, 337],[356387, 339],[360977, 341],[360979, 342],[370261, 343],[372607, 345],[379667, 350],[393961, 356],[398771, 358],[408479, 359],[423257, 361],\n[423287, 363],[425819, 365],[428339, 365],[433421, 367],[433439, 369],[438521, 369],[441101, 373],[448859, 375],[448867, 377],[477809, 377],[478001, 387],[483377, 389],[496877, 391],[499607, 393]\n]\n"] | {"fn_name": "prime_maxlength_chain", "inputs": [[100], [200], [500], [1000]], "outputs": [[[41]], [[197]], [[499]], [[953]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 10,693 |
def prime_maxlength_chain(n):
|
16cdeecf87b012600c66d5bbee8c8278 | UNKNOWN | # Description:
Count the number of exclamation marks and question marks, return the product.
# Examples
```
Product("") == 0
product("!") == 0
Product("!ab? ?") == 2
Product("!!") == 0
Product("!??") == 2
Product("!???") == 3
Product("!!!??") == 6
Product("!!!???") == 9
Product("!???!!") == 9
Product("!????!!!?") == 20
``` | ["def product(s):\n return s.count(\"?\")*s.count(\"!\")", "def product(s):\n return s.count(\"!\")*s.count(\"?\")", "def product(s):\n ce = cq = 0\n for i in s:\n if i == '!':\n ce += 1\n elif i == '?':\n cq += 1\n return ce * cq", "def product(s):\n exclamation = s.count(\"!\")\n question = s.count(\"?\")\n return exclamation*question", "from collections import Counter\n\n\ndef product(s: str) -> int:\n c = Counter(s)\n return c.get('!', 0) * c.get('?', 0)\n", "def product(input):\n return input.count(\"!\") * input.count(\"?\")", "import operator\n\ndef product(s):\n return operator.mul(*list(map(s.count, '?!')))\n", "def product(s):\n return sum(1 for ch in s if ch == \"!\") * sum(1 for ch in s if ch == \"?\")", "def product(s):\n l= list(s) \n excl = l.count('!')\n qust = l.count('?')\n if excl == 0 | qust == 0:\n return 0\n else: \n return (excl*qust)\n", "from collections import Counter\n\ndef product(s):\n return Counter(s).get(\"!\",0)*Counter(s).get(\"?\",0)"] | {"fn_name": "product", "inputs": [[""], ["!"], ["!!??!!"]], "outputs": [[0], [0], [8]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,092 |
def product(s):
|
6348a5feca042d8a407c4f3bd4dc1436 | UNKNOWN | >When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said
# Description:
In kindergarten, the teacher gave the children some candies. The number of candies each child gets is not always the same. Here is an array `candies`(all elements are positive integer). It's the number of candy for each child:
```
candies = [10,2,8,22,16,4,10,6,14,20]
```
The teacher asked the children to form a circle and play a game: Each child gives half of his candies to the child on his right(at the same time). If the number of children's candy is an odd number, the teacher will give him an extra candy, so that he can evenly distribute his candy.
Repeat such distribute process, until all the children's candies are equal in number.
You should return two numbers: 1.How many times of distribution; 2. After the game, the number of each child's candy. Returns the result using an array that contains two elements.
# Some examples:
```
candies = [ 1,2,3,4,5 ]
Distribution 1: [ 4,2,3,4,5 ]
Distribution 2: [ 5,3,3,4,5 ]
Distribution 3: [ 6,5,4,4,5 ]
Distribution 4: [ 6,6,5,4,5 ]
Distribution 5: [ 6,6,6,5,5 ]
Distribution 6: [ 6,6,6,6,6 ]
So, we need return: [6,6]
distributionOfCandy([1,2,3,4,5]) === [6,6]
candies = [ 10, 2, 8, 22, 16, 4, 10, 6, 14, 20 ]
distribution 1: [ 15, 6, 5, 15, 19, 10, 7, 8, 10, 17 ]
distribution 2: [ 17, 11, 6, 11, 18, 15, 9, 8, 9, 14 ]
distribution 3: [ 16, 15, 9, 9, 15, 17, 13, 9, 9, 12 ]
distribution 4: [ 14, 16, 13, 10, 13, 17, 16, 12, 10, 11 ]
distribution 5: [ 13, 15, 15, 12, 12, 16, 17, 14, 11, 11 ]
distribution 6: [ 13, 15, 16, 14, 12, 14, 17, 16, 13, 12 ]
distribution 7: [ 13, 15, 16, 15, 13, 13, 16, 17, 15, 13 ]
distribution 8: [ 14, 15, 16, 16, 15, 14, 15, 17, 17, 15 ]
distribution 9: [ 15, 15, 16, 16, 16, 15, 15, 17, 18, 17 ]
distribution 10: [ 17, 16, 16, 16, 16, 16, 16, 17, 18, 18 ]
distribution 11: [ 18, 17, 16, 16, 16, 16, 16, 17, 18, 18 ]
distribution 12: [ 18, 18, 17, 16, 16, 16, 16, 17, 18, 18 ]
distribution 13: [ 18, 18, 18, 17, 16, 16, 16, 17, 18, 18 ]
distribution 14: [ 18, 18, 18, 18, 17, 16, 16, 17, 18, 18 ]
distribution 15: [ 18, 18, 18, 18, 18, 17, 16, 17, 18, 18 ]
distribution 16: [ 18, 18, 18, 18, 18, 18, 17, 17, 18, 18 ]
distribution 17: [ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 ]
So, we need return: [17,18]
distributionOfCandy([10,2,8,22,16,4,10,6,14,20]) === [17,18]
``` | ["def distribution_of_candy(candies):\n steps = 0\n while len(set(candies)) > 1:\n candies = [(a + 1) // 2 + (b + 1) // 2\n for a, b in zip(candies, candies[-1:] + candies)]\n steps += 1\n return [steps, candies.pop()]", "def distribution_of_candy(candies):\n n = 0\n while any(c != candies[0] for c in candies):\n n += 1\n half = [(c+1)//2 for c in candies]\n candies = [a+b for a, b in zip(half, half[-1:] + half[:-1])]\n return [n, candies[0]]", "def distribution_of_candy(candies):\n turn = 0\n while len(set(candies)) > 1:\n candies = [(m + m%2) // 2 + (n + n%2) // 2 for m, n in zip(candies, candies[-1:] + candies[:-1])]\n turn += 1\n return [turn, candies[0]]", "def distribution_of_candy(candies):\n r = 0\n while len(set(candies)) > 1:\n r += 1\n candies = [(c+1)//2 + (candies[i-1]+1)//2 for i,c in enumerate(candies)]\n\n return [r, candies[0]]", "def distribution_of_candy(candies):\n if len(candies) == 1: return [0, candies[0]]\n c, lst = 0, candies\n while True:\n lst = [i//2 if i%2==0 else (i+1)//2 for i in lst]\n lst2 = lst[-1:] + lst[:-1]\n lst = [i+j for i, j in zip(lst, lst2)]\n c += 1\n if len(set(lst)) == 1:\n return [c, lst[0]] \n", "from itertools import count\n\ndef distribution_of_candy(a):\n for i in count():\n if all(x == a[0] for x in a):\n return [i, a[0]]\n a = [x + x % 2 for x in a]\n a = [(x + y) // 2 for x, y in zip(a, a[1:] + [a[0]])]", "def distribution_of_candy(c):\n i=0\n while min(c)!=max(c):\n i+=1\n a=[(v+v%2)//2 for v in c]\n c=[x+y for x,y in zip(a,a[-1:]+a)]\n return [i, c[0]]", "def distribution_of_candy(candies):\n candies_upd = candies\n cnt = 0\n if len(candies) == 1:\n return [0, candies[0]]\n while candies.count(candies[0]) < len(candies) or candies_upd.count(candies_upd[0]) < len(candies_upd):\n if cnt > 0:\n candies = candies_upd\n candies_upd = []\n for i in range(len(candies)): \n new = candies[i]\n if candies[i]%2 != 0:\n new +=1\n new-=(new/2)\n if i == 0:\n new+=(round(candies[-1]/2 +0.1))\n else:\n new +=(round(candies[i-1]/2 +0.1))\n candies_upd.append(new)\n \n cnt +=1\n \n return [cnt-1, candies[0]]\n", "def distribution_of_candy(arr):\n c = 0 \n while len(set(arr)) != 1:\n x = [(i+1 if i%2 else i)//2 for i in arr[-1:]+arr[:-1]]\n arr = [((i+1 if i%2 else i)-(i+1 if i%2 else i)//2) for i in arr]\n arr = [(i+j) for i,j in zip(arr,x)]\n c += 1\n return [c,arr.pop()] "] | {"fn_name": "distribution_of_candy", "inputs": [[[1, 2, 3, 4, 5]], [[10, 2, 8, 22, 16, 4, 10, 6, 14, 20]]], "outputs": [[[6, 6]], [[17, 18]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,825 |
def distribution_of_candy(candies):
|
5a317cfaf0f1b41683582d47f51a927b | UNKNOWN | # Task
You are given a regular array `arr`. Let's call a `step` the difference between two adjacent elements.
Your task is to sum the elements which belong to the sequence of consecutive elements of length `at least 3 (but as long as possible)`, such that the steps between the elements in this sequence are the same.
Note that some elements belong to two sequences and have to be counted twice.
# Example
For `arr = [54, 70, 86, 1, -2, -5, 0, 5, 78, 145, 212, 15]`, the output should be `639`.
```
There are 4 sequences of equal steps in the given array:
{54, 70, 86} => step +16
{1, -2, -5} => step -3
{-5, 0, 5} => step +5
{78, 145, 212} => step +67
So the answer is
(54 + 70 + 86) +
(1 - 2 - 5) +
(-5 + 0 + 5) +
(78 + 145 + 212) = 639.
The last element 15 was not be counted.
```
For `arr = [7, 2, 3, 2, -2, 400, 802]`, the output should be `1200`.
```
There is only 1 sequence in arr:
{-2, 400, 802} => step +402
So the answer is: -2 + 400 + 802 = 1200
```
For `arr = [1, 2, 3, 4, 5]`, the output should be `15`.
Note that we should only count {1, 2, 3, 4, 5} as a whole, any other small subset such as {1, 2, 3},{2, 3, 4},{3, 4, 5} are belong to {1, 2, 3, 4, 5}.
# Input/Output
- `[input]` array.integer `arr`
`3 ≤ arr.length ≤ 100`
- `[output]` an integer
The sum of sequences. | ["def sum_of_regular_numbers(arr):\n res, value, save = 0, arr[1] - arr[0], arr[:2]\n for x,y in zip(arr[1:], arr[2:]):\n if y-x == value:\n save.append(y)\n else:\n if len(save) >= 3: res += sum(save)\n value, save = y-x, [x, y]\n if len(save) >= 3: res+= sum(save)\n return res", "from itertools import groupby\nfrom operator import itemgetter\n\ndef sum_of_regular_numbers(arr):\n xs = [(i, x-y) for i, (x, y) in enumerate(zip(arr, arr[1:]))]\n it = (list(grp) for key, grp in groupby(xs, key=itemgetter(1)))\n it = ((grp[0][0], len(grp)) for grp in it if len(grp) > 1)\n return sum(sum(arr[i:i+n+1]) for i, n in it)", "def sum_of_regular_numbers(arr):\n # (step size, step count, sequence base)\n grouped = [(b - a, 1, a) for a, b in zip(arr[:-1], arr[1:])]\n # Collate the groups by step size\n i = 0\n while i < len(grouped) - 1:\n if grouped[i][0] == grouped[i + 1][0]:\n grouped[i] = (grouped[i][0], grouped[i][1] + 1, grouped[i][2])\n del grouped[i + 1]\n else:\n i += 1\n # Use (first + last) * elements / 2 to find sum of each sequence longer than 2 elements long\n return sum((2 * base + step * steps) * ((steps + 1) / 2) for step, steps, base in grouped if steps >= 2)\n", "def sum_of_regular_numbers(arr):\n i, s = 0, 0\n while i < len(arr)-2:\n n, step = 1, arr[i]-arr[i+1]\n while i+1+n < len(arr) and arr[i+n]-arr[i+1+n] == step: n += 1\n if n >= 2: s += sum(arr[i:i+n+1])\n i += n\n return s", "def sum_of_regular_numbers(arr):\n i = s = 0 ; l = len(arr)\n while i<l - 1:\n temp, diff = [], arr[i + 1] - arr[i]\n while i<l-1 and arr[i+1]-arr[i]==diff:\n temp.extend([arr[i], arr[i + 1]]) ; i += 1\n if len(set(temp)) > 2 : s += sum(set(temp))\n return s", "def sum_of_regular_numbers(arr):\n sum_ = 0\n i = 0\n while i < len(arr) - 1:\n seq = [arr[i], arr[i+1]]\n step = arr[i] - arr[i+1]\n j = i + 1\n while j < len(arr) - 1:\n if arr[j] - arr[j+1] != step:\n break\n seq.append(arr[j+1])\n j += 1\n if len(seq) >= 3:\n sum_ += sum(seq)\n i = j\n return sum_", "from itertools import groupby\n\ndef sum_of_regular_numbers(a):\n b, i, r = [sum(1 for _ in y) for x, y in groupby(y - x for x, y in zip(a, a[1:]))], 0, 0\n for x in b:\n if x > 1:\n r += sum(a[i:i+x+1])\n i += x\n return r", "import numpy as np\nfrom itertools import groupby\ndef sum_of_regular_numbers(arr):\n lst = [list(g) for k, g in groupby(np.diff(arr))]\n idx, ans = 0, 0\n for i in lst:\n if len(i) > 1:\n ans += sum(arr[idx:idx+len(i)+1])\n idx = idx + len(i)\n return ans", "from itertools import groupby\n\ndef sum_of_regular_numbers(arr):\n r,i = 0,0\n for k,g in groupby((j-i for i,j in zip(arr,arr[1:]))):\n x = len(list(g))\n if x>1:\n r += sum(arr[i:i+x+1])\n i += x\n return r", "from itertools import groupby\n\ndef sum_of_regular_numbers(arr):\n res = [[b-a, i] for i, a, b in zip(range(len(arr)), arr, arr[1:])]\n ans = 0\n for _, g in groupby(res, key=lambda x: x[0]):\n lst = list(g)\n if len(lst) > 1:\n ans += sum(arr[lst[0][1]:lst[-1][1]+2])\n return ans"] | {"fn_name": "sum_of_regular_numbers", "inputs": [[[54, 70, 86, 1, -2, -5, 0, 5, 78, 145, 212, 15]], [[59, 58, 57, 55, 53, 51]], [[7, 2, -3, 3, 9, 15]], [[-17, -9, 1, 9, 17, 4, -9]], [[7, 2, 3, 2, -2, 400, 802]], [[-1, 7000, 1, -6998, -13997]]], "outputs": [[639], [390], [30], [39], [1200], [-13994]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,444 |
def sum_of_regular_numbers(arr):
|
f59d181ef6c5e67fc01889c70458367d | UNKNOWN | Introduction
The GADERYPOLUKI is a simple substitution cypher used in scouting to encrypt messages. The encryption is based on short, easy to remember key. The key is written as paired letters, which are in the cipher simple replacement.
The most frequently used key is "GA-DE-RY-PO-LU-KI".
```
G => A
g => a
a => g
A => G
D => E
etc.
```
The letters, which are not on the list of substitutes, stays in the encrypted text without changes.
Other keys often used by Scouts:
```
PO-LI-TY-KA-RE-NU
KA-CE-MI-NU-TO-WY
KO-NI-EC-MA-TU-RY
ZA-RE-WY-BU-HO-KI
BA-WO-LE-TY-KI-JU
RE-GU-LA-MI-NO-WY
```
Task
Your task is to help scouts to encrypt and decrypt thier messages.
Write the `Encode` and `Decode` functions.
Input/Output
The function should have two parameters.
The `message` input string consists of lowercase and uperrcase characters and whitespace character.
The `key` input string consists of only lowercase characters.
The substitution has to be case-sensitive.
Example
# GADERYPOLUKI collection
GADERYPOLUKI cypher vol 1
GADERYPOLUKI cypher vol 2
GADERYPOLUKI cypher vol 3 - Missing Key
GADERYPOLUKI cypher vol 4 - Missing key madness | ["def encode(str, key):\n key = key.lower() + key.upper()\n dict = { char: key[i-1] if i % 2 else key[i+1] for i, char in enumerate(key) }\n return ''.join( dict.get(char, char) for char in str )\n\ndecode = encode", "def encode(message, key):\n a, b = (f\"{key[i::2]}{key[i::2].upper()}\" for i in (0, 1))\n return message.translate(str.maketrans(f\"{a}{b}\", f\"{b}{a}\"))\n\ndecode = encode\n", "def encode(str, key): return ende(str, key)\ndef decode(str, key): return ende(str, key)\n\ndef ende(str, key):\n key+=key.upper()\n rkey = \"\"\n for l in range(0,len(key),2):\n rkey+=key[l+1]+key[l]\n str = list(str)\n for i in range(0,len(str)):\n if str[i] in key:\n str[i] = rkey[list(key).index(str[i])]\n return \"\".join(str)\n", "encode = decode = lambda message, key: message.translate(str.maketrans(*mapping(key)))\n\ndef mapping(key):\n even, odd = key[::2] + key[::2].upper(), key[1::2] + key[1::2].upper()\n return (even + odd, odd + even)", "def encode(message, key):\n tbl = str.maketrans(\n key[::2] + key[::2].upper() + key[1::2] + key[1::2].upper(),\n key[1::2] + key[1::2].upper() + key[::2] + key[::2].upper()\n )\n return message.translate(tbl)\ndecode = encode", "def encode(message, key):\n s1, s2 = [], []\n for c1,c2 in zip(key[0::2], key[1::2]):\n s1.append(c1+c1.upper())\n s2.append(c2+c2.upper())\n return message.translate(str.maketrans(*map(''.join, [s1+s2, s2+s1])))\n\ndecode = encode", "def encode(message, key):\n x, y = key[::2] + key[::2].upper(), key[1::2] + key[1::2].upper()\n return message.translate(str.maketrans(x + y, y + x))\n\ndecode = encode", "def encode(s, key):\n D = {key[i]: key[i+1] for i in range(0, len(key), 2)}\n D.update({v: k for k, v in D.items()})\n D.update({k.upper(): v.upper() for k, v in D.items()})\n return s.translate(str.maketrans(D))\n \ndecode = encode", "def encode(str, key):\n \"\"\"Translate str using given key\"\"\"\n switched = []\n for x in range(int(len(key) / 2)):\n switched.append(key[x * 2 + 1])\n switched.append(key[x * 2])\n switched = \"\".join(switched)\n return str.translate(str.maketrans(key + key.upper(), switched + switched.upper()))\n\n\ndef decode(str, key):\n \"\"\"Do the same as encode\"\"\"\n return encode(str, key)"] | {"fn_name": "encode", "inputs": [["Gug hgs g cgt", "gaderypoluki"], ["Dkucr pu yhr ykbir", "politykarenu"], ["ABCD", "gaderypoluki"], ["Ala has a cat", "gaderypoluki"]], "outputs": [["Ala has a cat"], ["Dance on the table"], ["GBCE"], ["Gug hgs g cgt"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,383 |
def encode(message, key):
|
19bd637db182def978ed04902dffe5b8 | UNKNOWN | >When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said
# Description:
Give you two arrays `arr1` and `arr2`. They have the same length(length>=2). The elements of two arrays always be integer.
Sort `arr1` according to the ascending order of arr2; Sort `arr2` according to the ascending order of arr1. Description is not easy to understand, for example:
```
arr1=[5,4,3,2,1],
arr2=[6,5,7,8,9]
```
Let us try to sorting arr1.
First, we need know the ascending order of arr2:
```
[5,6,7,8,9]
```
We can see, after sort arr2 to ascending order, some elements' index are changed:
```
unsort arr2 ascending order arr2
[6,5,7,8,9]---> [5,6,7,8,9]
index0(6) ---> index1
index1(5) ---> index0
index2(7) index2(no change)
index3(8) index3(no change)
index4(9) index4(no change)
```
So, wo need according to these changes to sorting arr1:
```
unsort arr1 sorted arr1
[5,4,3,2,1]---> [4,5,3,2,1]
index0(5) ---> index1
index1(4) ---> index0
index2(3) index2(no change)
index3(2) index3(no change)
index4(1) index4(no change)
So: sorted arr1= [4,5,3,2,1]
```
And then, we sorting arr2 with the same process:
```
unsort arr1 ascending order arr1
[5,4,3,2,1]---> [1,2,3,4,5]
index0(5) ---> index4
index1(4) ---> index3
index2(3) index2(no change)
index3(2) ---> index1
index4(1) ---> index0
unsort arr2 sorted arr2
[6,5,7,8,9]---> [9,8,7,5,6]
index0(6) ---> index4
index1(5) ---> index3
index2(7) index2(no change)
index3(8) ---> index1
index4(9) ---> index0
So: sorted arr2= [9,8,7,5,6]
```
Finally, returns the sorted arrays by a 2D array: `[sorted arr1, sorted arr2]`
Note: In ascending order sorting process(not the final sort), if some elements have same value, sort them according to their index; You can modify the original array, but I advise you not to do that. ;-)
```if:haskell
Note: In Haskell, you are expected to return a tuple of arrays, and good luck trying to modifiy the original array. :]
```
# Some Examples and explain
```
sortArrays([5,4,3,2,1],[6,5,7,8,9]) should return
[[4,5,3,2,1],[9,8,7,5,6]]
sortArrays([2,1,3,4,5],[5,6,7,8,9]) should return
[[2,1,3,4,5],[6,5,7,8,9]]
sortArrays([5,6,9,2,6,5],[3,6,7,4,8,1]) should return
[[5,5,2,6,9,6],[4,3,1,6,8,7]]
``` | ["import numpy as np\n\ndef sort_two_arrays(arr1, arr2):\n idx2 = np.argsort(arr2, kind='mergesort')\n idx1 = np.argsort(arr1, kind='mergesort')\n return [[arr1[i] for i in idx2], [arr2[i] for i in idx1]]", "def sort_two_arrays(*args):\n sortedIdxRev = [ sorted((v,i) for i,v in enumerate(a)) for a in args[::-1] ]\n return [ [arr[i] for _,i in idx] for arr,idx in zip(args, sortedIdxRev)]", "def sort_two_arrays(arr1, arr2):\n indices, arrs = list(range(len(arr1))), (arr1, arr2)\n return [[arrs[a][i] for i in sorted(indices, key=arrs[1-a].__getitem__)] for a in (0, 1)]\n\n\n# one-liner\n#sort_two_arrays = lambda a1, a2: [[(a1, a2)[a][i] for i in sorted(range(len(a1)), key=(a1, a2)[1-a].__getitem__)] for a in (0, 1)]\n", "def sort_two_arrays(arr1, arr2):\n copy_arr1 = arr1[:]\n copy_arr2 = arr2[:]\n for i in range(len(arr1)-1, 0, -1):\n for j in range(i):\n if copy_arr2[j] > copy_arr2[j+1]:\n copy_arr2[j], copy_arr2[j+1] = copy_arr2[j+1], copy_arr2[j]\n arr1[j], arr1[j+1] = arr1[j+1], arr1[j]\n for i in range(len(arr2)-1, 0, -1):\n for j in range(i):\n if copy_arr1[j] > copy_arr1[j+1]:\n copy_arr1[j], copy_arr1[j+1] = copy_arr1[j+1], copy_arr1[j]\n arr2[j], arr2[j+1] = arr2[j+1], arr2[j]\n return [arr1, arr2]", "def sort_two_arrays(arr1, arr2):\n merged = list(zip(arr1,arr2))\n sorted_by_1 = sorted(merged,key=lambda x:x[0])\n sorted_by_2 = sorted(merged,key=lambda x:x[1])\n return [[x[0] for x in sorted_by_2],[x[1] for x in sorted_by_1]]", "from operator import itemgetter\n\ndef sort_two(arr1, arr2):\n merge_arr = [(arr2[i], n) for i, n in enumerate(arr1)]\n return [b for a, b in sorted(merge_arr, key=itemgetter(0))]\n\ndef sort_two_arrays(a, b):\n return [sort_two(a, b), sort_two(b, a)]", "def sort_two_arrays(arr1, arr2):\n arr1_,arr2_ = [[j,i] for i,j in enumerate(arr1)],[[j,i] for i,j in enumerate(arr2)]\n s, s1= sorted(arr1_,key=lambda x:(x[0],x[1])),sorted(arr2_,key=lambda x:(x[0],x[1]))\n return [[arr1[i[1]] for i in s1],[arr2[i[1]] for i in s]]", "def sort_two_arrays(arr1, arr2):\n k1=sorted((v,i)for i,v in enumerate(arr1))\n k2=sorted((v,i)for i,v in enumerate(arr2))\n return[[arr1[i]for v,i in k2],[arr2[i]for v,i in k1]]", "def sort_two_arrays(arr1, arr2):\n ind = list(range(len(arr1)))\n a1 = [y for x, i, y in sorted(zip(arr2, ind, arr1))]\n a2 = [y for x, i, y in sorted(zip(arr1, ind, arr2))]\n return [a1, a2]\n", "def sort_two_arrays(arr1, arr2):\n temp2 = [(i, v) for i, v in enumerate(arr2)]\n sorted_arr2_idx = [x[0] for x in sorted(temp2, key=lambda x: x[1])]\n temp1 = [(i, v) for i, v in enumerate(arr1)]\n sorted_arr1_idx = [x[0] for x in sorted(temp1, key=lambda x: x[1])]\n return [[arr1[sorted_arr2_idx[i]] for i in range(len(arr1))], [arr2[sorted_arr1_idx[i]] for i in range(len(arr1))]]\n\n"] | {"fn_name": "sort_two_arrays", "inputs": [[[5, 4, 3, 2, 1], [6, 5, 7, 8, 9]], [[2, 1, 3, 4, 5], [5, 6, 7, 8, 9]], [[5, 6, 9, 2, 6, 5], [3, 6, 7, 4, 8, 1]]], "outputs": [[[[4, 5, 3, 2, 1], [9, 8, 7, 5, 6]]], [[[2, 1, 3, 4, 5], [6, 5, 7, 8, 9]]], [[[5, 5, 2, 6, 9, 6], [4, 3, 1, 6, 8, 7]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,952 |
def sort_two_arrays(arr1, arr2):
|
a806abcc6a5949b9dc3676280bd4cebc | UNKNOWN | Given two numbers and an arithmetic operator (the name of it, as a string), return the result of the two numbers having that operator used on them.
```a``` and ```b``` will both be positive integers, and ```a``` will always be the first number in the operation, and ```b``` always the second.
The four operators are "add", "subtract", "divide", "multiply".
A few examples:
``` javascript
ArithmeticFunction.arithmetic(5, 2, "add") => returns 7
ArithmeticFunction.arithmetic(5, 2, "subtract") => returns 3
ArithmeticFunction.arithmetic(5, 2, "multiply") => returns 10
ArithmeticFunction.arithmetic(5, 2, "divide") => returns 2
```
Try to do it without using if statements! | ["def arithmetic(a, b, operator):\n return {\n 'add': a + b,\n 'subtract': a - b,\n 'multiply': a * b,\n 'divide': a / b,\n }[operator]", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a + b\n elif operator == \"subtract\":\n return a - b\n elif operator == \"multiply\":\n return a * b\n elif operator == \"divide\":\n return a / (b * 1.0)", "from operator import add, mul, sub, truediv\n\n\ndef arithmetic(a, b, operator):\n ops = {'add': add, 'subtract': sub, 'multiply': mul, 'divide': truediv}\n return ops[operator](a, b)", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a + b\n elif operator == \"subtract\":\n return a - b\n elif operator == \"multiply\":\n return a * b\n elif operator == \"divide\":\n return a / b\n #your code here\n", "import operator\ndef arithmetic(a, b, operator_name):\n operators = {\n \"add\": operator.add,\n \"subtract\": operator.sub,\n \"multiply\": operator.mul,\n \"divide\": operator.truediv\n }\n return operators[operator_name](a,b)", "def arithmetic(a, b, operator):\n return a+b if operator=='add' else a-b if operator=='subtract' else a*b if operator=='multiply' else a/b", "def arithmetic(a, b, operator):\n op = {\n 'add': '+',\n 'subtract': '-',\n 'multiply': '*',\n 'divide': '/'\n }\n return eval(\"{} {} {}\".format(a, op[operator], b))", "def arithmetic(a, b, op):\n #your code here\n d={'add':a+b,'subtract':a-b,'multiply':a*b,'divide':a/b,}\n return d[op]", "def arithmetic(a, b, operator):\n c = operator\n if c == \"add\": return a+b\n if c == \"subtract\": return a-b\n if c == \"multiply\": return a *b\n if c == \"divide\": return a / b", "def arithmetic(a, b, operator):\n ops = {\"add\":\"+\",\"subtract\":\"-\",\"multiply\":\"*\",\"divide\":\"/\"}\n return eval(str(a)+ops[operator]+str(b))", "def arithmetic(a, b, operator):\n return {\n 'add': lambda a, b: a + b,\n 'subtract': lambda a, b: a - b,\n 'multiply': lambda a, b: a * b,\n 'divide': lambda a, b: a / b\n }[operator](a, b)", "def arithmetic(a, b, operator):\n op = {\"add\":\"+\", \"subtract\": \"-\", \"multiply\": \"*\", \"divide\": \"/\"}\n return eval(str(a)+op[operator]+str(b))", "def arithmetic(a, b, op):\n if op == \"add\":\n return a+b\n elif op == \"subtract\":\n return a-b\n elif op == \"divide\":\n return a/b\n else: \n return a*b", "def arithmetic(a, b, operator):\n return a * b if operator == \"multiply\" else a / b if operator == \"divide\" else a + b if operator == \"add\" else a - b", "operators = {\n \"add\": int.__add__,\n \"subtract\": int.__sub__,\n \"multiply\": int.__mul__,\n \"divide\": int.__truediv__,\n}\n\ndef arithmetic(a, b, op):\n return operators[op](a, b)", "from operator import add, sub, mul, truediv as div\n\ndef arithmetic(a, b, operator):\n return {'add': add, 'subtract': sub , 'multiply': mul, 'divide': div}[operator](a, b)", "def arithmetic(a, b, operator):\n c = {\"add\": (a + b), \"subtract\": (a-b), \"multiply\": (a * b), \"divide\": (a/b)}\n return c[operator]", "def arithmetic(a, b, operator):\n switcher = {\n 'add': a + b,\n 'subtract': a - b,\n 'multiply': a * b,\n 'divide': a / b,\n }\n return switcher[operator]", "def arithmetic(a, b, operator):\n ops = {\n 'add': lambda a,b: a + b,\n 'subtract': lambda a,b: a - b,\n 'multiply': lambda a,b: a * b,\n 'divide': lambda a,b: a / b}\n return ops[operator](a,b)", "import operator\n\nops = {\n 'add': operator.add,\n 'subtract': operator.sub,\n 'multiply': operator.mul,\n 'divide': operator.truediv,\n}\n\ndef arithmetic(a, b, op):\n return ops[op](a, b)", "def arithmetic(a, b, operator):\n if operator == \"add\": return a+b\n if operator == \"subtract\": return a-b\n if operator == \"multiply\": return a*b\n if operator == \"divide\": return a/b", "def arithmetic(a, b, operator):\n dict = {\"add\": a + b, \"subtract\": a-b, \"multiply\": a*b, \"divide\": a/b}\n return dict[operator]", "arithmetic=lambda a,b,o:__import__(\"operator\").__dict__[o[:3].replace('div','truediv')](a,b)", "def arithmetic(a, b, operator):\n formats = {\n \"add\": a+b,\n \"subtract\": a-b,\n \"divide\": a/b,\n \"multiply\": a*b\n }\n \n return formats.get(operator)\n", "from operator import *\ndef arithmetic(a, b, operator):\n if operator=='add':\n return add(a,b)\n elif operator=='subtract':\n return sub(a,b)\n elif operator=='multiply':\n return mul(a,b)\n elif operator=='divide':\n return truediv(a,b)\n", "def arithmetic(a, b, operator):\n #your code here\\\n while operator == 'add':\n return a+b\n while operator == 'subtract':\n return a-b\n while operator == 'multiply':\n return a*b\n while operator == 'divide':\n return a/b", "def arithmetic(a, b, operator):\n return eval(f'{a}{operator[0].translate(str.maketrans(\"asmd\", \"+-*/\"))}{b}')", "def arithmetic(a: int, b: int, operator: str) -> int:\n \"\"\" Get the result of the two numbers having the operator used on them. \"\"\"\n return {\n \"add\": lambda: a + b,\n \"subtract\": lambda: a - b,\n \"multiply\": lambda: a * b,\n \"divide\": lambda: a / b\n }.get(operator)()", "def arithmetic(a, b, operator):\n return (lambda a, b, operator:\n (operator == \"add\" and a + b ) or\n (operator == \"subtract\" and a - b) or\n (operator == \"multiply\" and a * b) or\n (operator == \"divide\" and a / b))(a, b, operator)", "def arithmetic(a, b, operator):\n if operator.lower() == \"multiply\":\n return eval(f\"{a}*{b}\")\n if operator.lower() == \"divide\":\n return eval(f\"{a}/{b}\")\n if operator.lower() == \"add\":\n return eval(f\"{a}+{b}\")\n if operator.lower() == \"subtract\":\n return eval(f\"{a}-{b}\")", "def arithmetic(a, b, operator):\n if operator.lower() == \"add\":\n return a + b\n elif operator.lower() == \"subtract\":\n return a - b\n elif operator.lower() == \"multiply\":\n return a*b\n else:\n return a/b", "def arithmetic(a, b, operator):\n if operator == 'add':\n number = a + b\n return number\n elif operator == 'subtract':\n number = a - b\n return number\n elif operator == 'multiply':\n number = a * b\n return number\n elif operator == 'divide':\n number = a / b\n return number", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return (a + b)\n elif operator == \"subtract\":\n return (a - b)\n elif operator == \"multiply\":\n return (a * b)\n elif operator == \"divide\":\n return (a / b)\narithmetic(2,2,\"divide\")\n\n\n\n", "arithmetic=lambda a,b,s:eval('a%sb'%'-+*/'[ord(s[2])//9-10])", "from operator import add, sub as subtract, mul as multiply, truediv as divide\narithmetic = lambda a, b, operator: eval(operator)(a,b)\n#DO NOT DO THIS\n", "def arithmetic(a, b, operator):\n return getattr(a, '__' + operator[:3] + '__', a.__truediv__)(b)", "arithmetic = lambda a, b, o: eval(str(a)+{'add':'+', 'subtract':'-', 'multiply':'*', 'divide':'/'}[o]+str(b))", "from operator import add, sub, mul, truediv, floordiv\n\ndiv = truediv #floordiv\n\narithmetic = lambda a, b, s: eval(s[:3])(a, b)", "def arithmetic(a, b, operator):\n d = dict()\n d[\"add\"] = '+'\n d[\"subtract\"] = '-'\n d[\"multiply\"] = '*'\n d[\"divide\"] = '/'\n \n return eval('{0} {1} {2}'.format(a, d[operator], b))", "def arithmetic(a, b, operator):\n opd = {'add': a+b,'subtract': a-b,'multiply': a*b,'divide': a/b}\n return opd[operator]", "def arithmetic(a, b, operator):\n while operator[0] == \"a\":\n return a + b\n break\n while operator[0] == \"s\":\n return a - b\n break\n while operator[0] == \"m\":\n return a * b\n break\n else:\n return a / b\n", "def arithmetic(a, b, operator):\n operators = {'add':'+','subtract':'-','multiply':'*','divide':'/'}\n return eval(str(a)+operators[operator]+str(b))", "def arithmetic(a, b, operator):\n return eval('a{}b'.format({'add':'+','subtract':'-','multiply':'*','divide':'/'}[operator]))", "def arithmetic(a, b, operator):\n ops = {\"add\": lambda x,y : x+y,\n \"subtract\": lambda x,y : x-y,\n \"multiply\": lambda x,y : x*y,\n \"divide\": lambda x,y : float(x)/y,\n }\n return ops[operator](a,b)", "def arithmetic(a, b, operator):\n return eval(f'{a}{operator}{b}'.replace('add','+').replace('subtract','-').replace('divide','/').replace('multiply','*'))", "def arithmetic(a, b, operator):\n op = {'add':'+','subtract':'-','multiply':'*','divide':'/'}\n if b == 0 and operator == 'divide':\n return 'Error! Division by zero!'\n return eval(f'{a} {op[operator]} {b}') if operator in op else 'Error! Wrong operator!'", "a={'add':'+',\n 'subtract':'-',\n 'multiply':'*',\n 'divide':'/'}\ndef arithmetic(b,c,d):\n e=a[str(d)]\n f=str(b)+e+str(c)\n return eval(f)\n", "def arithmetic(a, b, operator):\n if operator==\"subtract\":\n return a-b\n elif operator==\"add\":\n return a+b\n elif operator==\"multiply\":\n return a*b\n elif operator==\"divide\":\n return a/b", "def arithmetic(a, b, operator):\n if operator == \"add\": return a + b \n if operator == \"multiply\": return a * b \n if operator == \"subtract\": return a - b \n return a / b", "def arithmetic(a, b, operator):\n try:\n x = {\"add\":a+b,\"subtract\":a-b,\"divide\":a/b,\"multiply\":a*b}\n return x.get(operator)\n except:\n return None", "def arithmetic(a, b, operator):\n arithmetics = {\n \"add\": a + b,\n \"subtract\": a - b,\n \"multiply\": a * b,\n \"divide\": a / b,\n }\n return arithmetics[operator]", "def arithmetic(a, b, operator):\n if operator == 'add':\n return (a+b)\n elif operator == 'subtract':\n return (a-b)\n elif operator == 'multiply':\n return (a*b)\n elif operator == 'divide':\n return (a/b)\n else:\n return (\"Unsupport operant\")\n #your code here\n", "def arithmetic(a, b, op):\n trans = {\n 'add': '+',\n 'subtract': '-',\n 'divide': '/',\n 'multiply': '*'\n }\n if (type(a) == type(b) == int) and (op in trans.keys()):\n return eval(f'{a}{trans[op]}{b}')", "def arithmetic(a, b, operator):\n x = [['a','s','m','d'], [a+b,a-b,a*b,a/b]]\n return x[1][x[0].index(operator[0])]\n", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a+b\n elif operator == \"subtract\" :\n return a-b\n elif operator == \"multiply\":\n return b*a\n else :\n return a/b", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a + b\n elif operator == \"subtract\":\n return a - b\n elif operator == \"multiply\":\n return a * b\n elif operator == \"divide\":\n return a / b\n else:\n return \"I don't know!\"", "def arithmetic(a, b, operator):\n if operator.lower() == 'add':\n return a+b\n elif operator.lower() == 'subtract':\n return a-b\n elif operator.lower() == 'divide':\n return a/b\n else:\n return a*b", "def arithmetic(a, b, operator):\n c=0\n if operator == \"add\":\n c = a+b\n elif operator == \"multiply\":\n c= a*b\n elif operator == \"divide\":\n c = a/b \n elif operator == \"subtract\":\n c = a-b\n return c ", "def add(a,b):\n return a + b\ndef subtract(a,b):\n return a - b\ndef multiply(a,b):\n return a*b\ndef divide(a,b):\n return a/b\n\ndef arithmetic(a, b, operator):\n return eval(operator+'(a,b)')", "def arithmetic(a, b, o):\n if o == \"add\":\n r = a + b\n if o == \"subtract\":\n r = a - b\n if o == \"multiply\":\n r = a * b\n if o == \"divide\":\n r = a / b\n return r", "def arithmetic(a, b, operator):\n #your code here\n \n table = {\"add\": \"+\", \"subtract\": \"-\", \"multiply\": \"*\", \"divide\": \"/\" }\n \n return eval(str(a) + table[operator] + str(b))", "def arithmetic(a, b, operator):\n return eval(f'{a}{ {\"add\":\"+\", \"subtract\":\"-\", \"multiply\":\"*\", \"divide\":\"/\"}.get(operator) }{b}')", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a+b\n elif operator == \"subtract\":\n return a-b\n elif operator == \"multiply\":\n return a*b\n elif operator == \"divide\":\n return a/b\n else:\n return a%b", "def arithmetic(a, b, operator):\n if operator == 'add':\n operator = '+'\n elif operator == 'subtract':\n operator = '-'\n elif operator == 'multiply':\n operator = '*'\n elif operator == 'divide':\n operator = '/'\n \n return eval('{}{}{}'.format(a,operator,b))", "def arithmetic(a, b, operator):\n #your code here\n words_operator = {\n 'add': '+',\n 'subtract': '-',\n 'multiply': '*',\n 'divide': '/'\n }\n \n return(eval(\"{} {} {}\".format(a,words_operator[operator],b)))", "def arithmetic(a, b, operator):\n kek = {\n \"add\": '+',\n \"subtract\": '-',\n \"divide\": '/',\n \"multiply\": '*'\n }\n return eval(f'{a} {kek[operator]} {b}')", "def arithmetic(a, b, operator):\n result = 0\n if operator == \"add\":\n return a + b\n elif operator == \"subtract\":\n return a - b\n elif operator == \"multiply\":\n return a * b\n else:\n return a / b", "def arithmetic(a, b, operator):\n map = {\n \"add\": lambda a, b: a + b,\n \"subtract\": lambda a, b: a - b,\n \"multiply\": lambda a, b: a * b,\n \"divide\": lambda a, b: a / b,\n }\n return map[operator](a,b)", "def arithmetic(a, b, operator):\n \n if operator == \"multiply\":\n return a * b\n \n if operator == \"add\":\n return a + b\n \n if operator == \"subtract\":\n return a - b\n \n if operator == \"divide\":\n return a / b", "def arithmetic(a, b, operator):\n #your code here\n ans = 0\n if operator == 'add':\n ans = a+b\n elif operator == 'subtract':\n ans = a-b\n elif operator == 'multiply':\n ans = a*b\n elif operator == 'divide':\n ans = a/b\n \n return ans", "def arithmetic(a, b, operator):\n calc ={\"add\":\"+\", \"subtract\":\"-\", \"multiply\":\"*\", \"divide\":\"/\"}\n return eval(str(a)+calc[operator]+str(b))", "import operator as opr\ndef arithmetic(a, b, operator):\n operations = {\n \"add\":opr.add,\n \"subtract\":opr.sub,\n \"multiply\":opr.mul,\n \"divide\":opr.truediv\n }\n return operations[operator](a,b)\n", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a+b\n elif operator == \"subtract\":\n return a-b\n elif operator == \"multiply\":\n return a*b\n elif operator == \"divide\":\n return a/b\n else:\n return \"Please input a proper operator.\"", "import operator as op\n\nf = {\n \"add\": op.add,\n \"subtract\": op.sub,\n \"multiply\": op.mul,\n \"divide\": op.truediv\n}\n\ndef arithmetic(a, b, operator):\n return f[operator](a, b)", "def arithmetic(a, b, n):\n if n==\"add\":\n return a+b\n elif n==\"subtract\":\n return a-b\n elif n==\"multiply\":\n return a*b\n else:\n return a/b\n", "def arithmetic(a, b, operator):\n operations = {\n 'add': lambda x: a+b,\n 'subtract':lambda x: a-b,\n 'multiply':lambda x: a*b,\n 'divide':lambda x: a/b\n }\n\n return operations[operator](1)", "def arithmetic(a, b, operator):\n return operations[operator](a, b)\n \n \n \noperations = {\n \"add\": lambda a, b: a + b,\n \"subtract\": lambda a, b: a - b,\n \"multiply\": lambda a, b: a * b,\n \"divide\": lambda a, b: a / b\n}", "# No if statements :-)\narithmetic = lambda a, b, o: getattr(__import__(\"operator\"), o == 'divide' and 'itruediv' or o[:3])(a, b)", "def arithmetic(a, b, operator):\n total = 0\n if operator == \"add\":\n total = a+b\n elif operator == \"subtract\":\n total = a-b\n elif operator == \"multiply\":\n total = a*b\n elif operator == \"divide\":\n total = a/b\n else:\n return \"Something Went Wrong\"\n return total", "import operator as o\ndef arithmetic(a, b, operator):\n ops = {'add': o.add,\n 'subtract': o.sub,\n 'multiply': o.mul,\n 'divide': o.truediv}\n return ops[operator](a,b)", "def arithmetic(a, b, op):\n if op == \"add\":\n return a + b\n elif op == \"multiply\":\n return a * b\n elif op == \"subtract\":\n return a - b\n else:\n return a/b", "def arithmetic(a, b, operator):\n map_func = {\n 'add': lambda a, b: a + b,\n 'subtract': lambda a, b: a - b,\n 'multiply': lambda a, b: a * b,\n 'divide': lambda a, b: a / b\n }\n return map_func[operator](a, b)", "def arithmetic(a, b, operator):\n ans= 0\n while operator == \"add\":\n ans = a+b\n break\n while operator == \"subtract\":\n ans = a-b\n break\n while operator == \"multiply\":\n ans = a*b\n break\n \n while operator == \"divide\":\n ans = a/b\n break\n return ans", "def arithmetic(a, b, o):\n res = 0\n if o == 'add':\n res = a + b\n elif o == 'subtract':\n res = a - b\n elif o == 'multiply':\n res = a * b\n elif o == 'divide':\n res = a / b\n else:\n res = 'Please specify operator ... '\n return res", "def arithmetic(a, b, operator):\n ops = {\n \"add\": \"__add__\",\n \"subtract\": \"__sub__\",\n \"multiply\": \"__mul__\",\n \"divide\": \"__truediv__\"\n }\n return getattr(a, ops[operator])(b)", "def arithmetic(a, b, operator):\n if 'add' == operator:\n return a + b\n if 'subtract' == operator:\n return a - b\n if 'multiply' == operator:\n return a * b\n if 'divide' == operator:\n return a / b", "def arithmetic(a, b, operator):\n #your code here\n \n if operator==\"add\":\n result=a+b\n elif operator==\"subtract\":\n result=a-b\n elif operator==\"divide\":\n result=a/b\n elif operator==\"multiply\":\n result=a*b\n else:\n print(\"You didn't enter an operator or you misspelled the operator.\")\n\n return result", "def arithmetic(a, b, operator):\n res = {\n \"add\": a + b,\n \"subtract\": a - b,\n \"multiply\": a * b,\n \"divide\": a / b\n }\n return res.get(operator, \"Invalid operator\")", "def arithmetic(a, b, operator):\n #Lot of If statements\n if operator == 'add':\n return a +b\n elif operator == 'subtract':\n return a-b\n elif operator == 'multiply':\n return a*b\n else:\n return a/b\n", "from operator import add,sub,mul,truediv as div\ndef arithmetic(a, b, o):\n return eval(f\"{o[:3]}({a},{b})\")", "def arithmetic(a, b, operator):\n if operator == 'add':\n return a+b\n elif operator == 'subtract':\n return a-b\n elif operator == 'multiply':\n return a*b\n elif operator == 'divide':\n return a/b\n else:\n print('how can I do this better?')\n\n", "def arithmetic(a, b, operator):\n result=0\n if operator==\"add\":\n result=a+b\n return result\n elif operator==\"subtract\":\n result=a-b\n return result\n elif operator==\"multiply\":\n result=a*b\n return result\n else:\n result=a/b\n return result\n", "def arithmetic(a, b, operator):\n result = 0\n if operator == \"add\":\n result = a + b\n elif operator == \"subtract\":\n result = a - b\n elif operator == \"multiply\":\n result = a * b\n elif operator == \"divide\":\n result = a / b\n else:\n print(\"No operator found\")\n \n return (result)", "def arithmetic(a, b, op):\n return __import__('operator').__dict__['true' * (op[0] == 'd') + op[:3]](a, b)", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a+b\n if operator == \"subtract\":\n return a-b\n if operator == \"multiply\":\n return a*b\n if operator == \"divide\":\n return a/b\n raise \"Can't recognize operator\"", "def arithmetic(a, b, operator):\n if operator == \"add\":\n return a + b\n elif operator == \"subtract\":\n return a - b\n elif operator == \"multiply\":\n return a * b\n elif operator == \"divide\":\n return a / b\n \n # simple way which is readable to solve this problem\n # you can use dictionary or one liners also here\n", "def arithmetic(a, b, operator):\n c = [\"add\", \"subtract\", \"multiply\", \"divide\"]\n d = [a+b, a-b, a*b, a/b]\n n = 0\n while c[0] != operator:\n c.remove(c[0])\n n +=1\n return d[n]", "def arithmetic(a, b, operator):\n if operator == 'add' :\n result = a + b\n elif operator == 'subtract':\n result = a - b\n elif operator == 'multiply':\n result = a * b\n elif operator == 'divide':\n result = a / b\n \n return result\n\nresult = arithmetic(5, 2, \"divide\")\nprint(result)\n"] | {"fn_name": "arithmetic", "inputs": [[1, 2, "add"], [8, 2, "subtract"], [5, 2, "multiply"], [8, 2, "divide"]], "outputs": [[3], [6], [10], [4]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 22,159 |
def arithmetic(a, b, operator):
|
b90a1d6db15f75c686b57fbb87fff7bf | UNKNOWN | Time to win the lottery!
Given a lottery ticket (ticket), represented by an array of 2-value arrays, you must find out if you've won the jackpot. Example ticket:
To do this, you must first count the 'mini-wins' on your ticket. Each sub array has both a string and a number within it. If the character code of any of the characters in the string matches the number, you get a mini win. Note you can only have one mini win per sub array.
Once you have counted all of your mini wins, compare that number to the other input provided (win). If your total is more than or equal to (win), return 'Winner!'. Else return 'Loser!'.
All inputs will be in the correct format. Strings on tickets are not always the same length. | ["def bingo(ticket, win):\n return 'Winner!' if sum(chr(n) in s for s, n in ticket) >= win else 'Loser!'", "def bingo(ticket, win):\n return \"Winner!\" if sum( w in map(ord, s) for s, w in ticket ) >= win else \"Loser!\"", "def bingo(ticket,win):\n counter = 0\n for x,y in ticket:\n for i in x:\n counter += 1 if ord(i) == y else 0 \n return 'Loser!' if counter < win else 'Winner!'\n", "def bingo(ticket, win):\n won = sum(chr(n) in xs for xs, n in ticket) >= win\n return 'Winner!' if won else 'Loser!'", "def bingo(ticket, win):\n winner = sum(1 for stg, val in ticket if chr(val) in stg) >= win\n return \"Winner!\" if winner else \"Loser!\"", "def bingo(ticket,win):\n return \"Loser!\" if sum(1 if chr(i[1]) in i[0] else 0 for i in ticket)<win else \"Winner!\"", "def bingo(ticket, win):\n mini_wins = sum(chr(code) in chars for chars, code in ticket)\n return 'Winner!' if mini_wins >= win else 'Loser!'", "def bingo(ticket,win):\n return 'Winner!' if sum(chr(arr[1]) in arr[0] for arr in ticket)>=win else 'Loser!'", "def bingo(ticket,win):\n mini_wins = 0\n for arr in ticket:\n mini_wins += any(map(lambda x: ord(x) == arr[1], arr[0]))\n return ['Loser!', 'Winner!'][mini_wins >= win]", "def bingo(ticket,win):\n return 'WLionsneerr!!'[sum(chr(n)in s for s,n in ticket)<win::2]"] | {"fn_name": "bingo", "inputs": [[[["ABC", 65], ["HGR", 74], ["BYHT", 74]], 2], [[["ABC", 65], ["HGR", 74], ["BYHT", 74]], 1], [[["HGTYRE", 74], ["BE", 66], ["JKTY", 74]], 3]], "outputs": [["Loser!"], ["Winner!"], ["Loser!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,367 |
def bingo(ticket, win):
|
7cb2ae591aa574dea9159881aba03f56 | UNKNOWN | The __Hamming weight__ of a string is the number of symbols that are different from the zero-symbol of the alphabet used. There are several algorithms for efficient computing of the Hamming weight for numbers. In this Kata, speaking technically, you have to find out the number of '1' bits in a binary representation of a number. Thus,
The interesting part of this task is that you have to do it *without* string operation (hey, it's not really interesting otherwise)
;) | ["def hamming_weight(x):return bin(x).count('1')", "hamming_weight = lambda x: list(bin(x)).count('1') # :) \n", "def hamming_weight(x):\n count = 0\n while x:\n x &= x-1\n count += 1\n return count\n", "def hamming_weight(x):\n w = 0\n while x:\n w += x & 1\n x >>= 1\n return w", "def hamming_weight(x):\n return '{:b}'.format(x).count('1')", "def hamming_weight(x):\n return list(bin(x)).count('1')", "def hamming_weight(x):\n count = 0\n while x != 0:\n x &= x - 1\n count += 1 \n return count", "hamming_weight = lambda x: str(bin(x)).count('1')", "def hamming_weight(x):\n return format(x, 'b').count('1')"] | {"fn_name": "hamming_weight", "inputs": [[0], [1], [2], [10], [21], [2048]], "outputs": [[0], [1], [1], [2], [3], [1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 678 |
def hamming_weight(x):
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.