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
|
---|---|---|---|---|---|---|---|---|---|
021c83a2c065d01106c7e0444d7b562c | UNKNOWN | The new "Avengers" movie has just been released! There are a lot of people at the cinema box office standing in a huge line. Each of them has a single `100`, `50` or `25` dollar bill. An "Avengers" ticket costs `25 dollars`.
Vasya is currently working as a clerk. He wants to sell a ticket to every single person in this line.
Can Vasya sell a ticket to every person and give change if he initially has no money and sells the tickets strictly in the order people queue?
Return `YES`, if Vasya can sell a ticket to every person and give change with the bills he has at hand at that moment. Otherwise return `NO`.
### Examples:
```csharp
Line.Tickets(new int[] {25, 25, 50}) // => YES
Line.Tickets(new int[] {25, 100}) // => NO. Vasya will not have enough money to give change to 100 dollars
Line.Tickets(new int[] {25, 25, 50, 50, 100}) // => NO. Vasya will not have the right bills to give 75 dollars of change (you can't make two bills of 25 from one of 50)
```
```python
tickets([25, 25, 50]) # => YES
tickets([25, 100]) # => NO. Vasya will not have enough money to give change to 100 dollars
tickets([25, 25, 50, 50, 100]) # => NO. Vasya will not have the right bills to give 75 dollars of change (you can't make two bills of 25 from one of 50)
```
```cpp
tickets({25, 25, 50}) // => YES
tickets({25, 100}) // => NO. Vasya will not have enough money to give change to 100 dollars
tickets({25, 25, 50, 50, 100}) // => NO. Vasya will not have the right bills to give 75 dollars of change (you can't make two bills of 25 from one of 50)
``` | ["def tickets(people):\n till = {100.0:0, 50.0:0, 25.0:0}\n\n for paid in people:\n till[paid] += 1\n change = paid-25.0\n \n for bill in (50,25):\n while (bill <= change and till[bill] > 0):\n till[bill] -= 1\n change -= bill\n\n if change != 0:\n return 'NO'\n \n return 'YES'", "def tickets(a):\n n25 = n50 = n100 = 0\n for e in a:\n if e==25 : n25+=1\n elif e==50 : n25-=1; n50+=1\n elif e==100 and n50>0 : n25-=1; n50-=1\n elif e==100 and n50==0: n25-=3\n if n25<0 or n50<0:\n return 'NO'\n return 'YES'\n", "def tickets(people):\n change = 'YES'\n twentyfive, fifty, onehundred = 0, 0, 0\n \n for cash in people:\n if change == 'NO':\n break\n\n if cash == 25:\n twentyfive += 1\n elif cash == 50 and twentyfive > 0:\n twentyfive -= 1\n fifty += 1\n elif cash == 100:\n if fifty > 0 and twentyfive > 0:\n fifty -= 1\n twentyfive -= 1\n onehundred += 1\n elif twentyfive > 2:\n twentyfive -= 3\n onehundred += 1\n else:\n change = 'NO'\n else:\n change = 'NO'\n \n return change", "def tickets(people):\n cashRegister = {25: 0, 50: 0, 100: 0};\n ticketPrice = 25;\n for paid in people:\n cashRegister[paid] += 1;\n while paid > ticketPrice:\n changeGiven = False;\n \"\"\" Check if we have a bill in the register that we use as change \"\"\"\n for bill in sorted(cashRegister.keys(), reverse=True):\n \"\"\" Hand out hhange if possible and still needed \"\"\"\n if (paid - ticketPrice >= bill) and (cashRegister[bill] > 0):\n paid = paid - bill;\n cashRegister[bill] -= 1;\n changeGiven = True;\n \"\"\" Return \"NO\" if we were unable to give the change required \"\"\"\n if (paid > ticketPrice) and (changeGiven == False):\n return \"NO\";\n return \"YES\";", "def tickets(people):\n change = {\n '25': 0,\n '50': 0\n }\n for person in people:\n if person == 25:\n change['25'] += 1\n elif person == 50:\n change['50'] += 1\n change['25'] -= 1\n else:\n if change['50'] > 0:\n change['50'] -= 1\n change['25'] -= 1\n else:\n change['25'] -= 3\n if change['25'] < 0:\n return 'NO'\n return 'YES'", "def tickets(people, cost=25, bills=[100, 50, 25]):\n count = dict.fromkeys(bills, 0)\n for change in people:\n count[change] += 1\n change -= cost\n for bill in bills:\n if change >= bill:\n c = min(change // bill, count[bill])\n count[bill] -= c\n change -= c * bill\n if change: return \"NO\"\n return \"YES\"\n", "def tickets(people):\n bill25 = 0\n bill50 = 0\n bill100= 0\n for bill in people:\n if bill == 25:\n bill25+=1\n elif bill == 50:\n bill50+=1\n if bill25 == 0:\n return \"NO\"\n bill25-=1\n elif bill == 100:\n bill100+=1\n if bill50 > 0 and bill25 > 0:\n bill50-=1\n bill25-=1\n elif bill25 >= 3:\n bill25 = bill25-3\n else:\n return \"NO\"\n return \"YES\"", "from collections import Counter\n\ndef tickets(people):\n\n bills = Counter({ 25 : 0, 50 : 0, 100 : 0 })\n required = {\n 50 : [ Counter({ 25 : 1 }) ],\n 100 : [ Counter({ 25 : 1, 50 : 1 }), Counter({ 25 : 3 }) ],\n }\n \n def check_required(person):\n for require in required[person]:\n if bills & require == require:\n bills.subtract(require)\n return True\n return False\n\n for person in people:\n bills[person] += 1\n if person > 25 and not check_required(person):\n return \"NO\"\n \n return \"YES\"\n", "def tickets(people):\n change = []\n try:\n for cash in people:\n if cash == 25:\n change.append(25)\n if cash == 50:\n change.remove(25)\n change.append(50)\n if cash == 100 and (50 in change):\n change.remove(50)\n change.remove(25)\n elif cash == 100:\n change.remove(25)\n change.remove(25)\n change.remove(25)\n except: \n return \"NO\"\n else:\n return \"YES\"\n \n \n \n"] | {"fn_name": "tickets", "inputs": [[[25, 25, 50]], [[25, 25, 50, 100]], [[25, 100]], [[25, 25, 25, 25, 25, 25, 25, 25, 25, 25]], [[50, 50, 50, 50, 50, 50, 50, 50, 50, 50]], [[100, 100, 100, 100, 100, 100, 100, 100, 100, 100]], [[25, 25, 25, 25, 50, 100, 50]], [[50, 100, 100]], [[25, 25, 100]], [[25, 25, 25, 25, 25, 25, 25, 50, 50, 50, 100, 100, 100, 100]], [[25, 25, 50, 50, 100]], [[25, 50, 50]], [[25, 25, 25, 100]], [[25, 50, 25, 100]], [[25, 25, 25, 25, 25, 100, 100]], [[25, 50, 100, 25, 25, 25, 50]], [[25, 50, 25, 50, 100, 25, 25, 50]], [[25, 50, 25, 100, 25, 25, 50, 100, 25, 25, 25, 100, 25, 25, 50, 100, 25, 50, 25, 100, 25, 50, 50, 50]], [[25, 25, 25, 100, 25, 25, 25, 100, 25, 25, 50, 100, 25, 25, 50, 100, 50, 50]], [[25, 50, 25, 100, 25, 25, 50, 100, 25, 50, 25, 100, 50, 25]]], "outputs": [["YES"], ["YES"], ["NO"], ["YES"], ["NO"], ["NO"], ["YES"], ["NO"], ["NO"], ["NO"], ["NO"], ["NO"], ["YES"], ["YES"], ["NO"], ["NO"], ["NO"], ["NO"], ["NO"], ["NO"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,937 |
def tickets(people):
|
3f858f12749f83a1ccecd67a17d4444f | UNKNOWN | ###Instructions
Write a function that takes a negative or positive integer, which represents the number of minutes before (-) or after (+) Sunday midnight, and returns the current day of the week and the current time in 24hr format ('hh:mm') as a string.
```python
day_and_time(0) should return 'Sunday 00:00'
day_and_time(-3) should return 'Saturday 23:57'
day_and_time(45) should return 'Sunday 00:45'
day_and_time(759) should return 'Sunday 12:39'
day_and_time(1236) should return 'Sunday 20:36'
day_and_time(1447) should return 'Monday 00:07'
day_and_time(7832) should return 'Friday 10:32'
day_and_time(18876) should return 'Saturday 02:36'
day_and_time(259180) should return 'Thursday 23:40'
day_and_time(-349000) should return 'Tuesday 15:20'
``` | ["from datetime import timedelta, datetime\ndef day_and_time(mins):\n return \"{:%A %H:%M}\".format(datetime(2017, 1, 1) + timedelta(minutes = mins))", "def day_and_time(mins):\n dow = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']\n return \"{} {:02d}:{:02d}\".format(dow[(mins // 1440) % 7], (mins // 60) % 24, mins % 60)\n \n", "from time import gmtime, strftime\n\ndef day_and_time(mins):\n #your code here\n return strftime(\"%A %H:%M\", gmtime(3600*24*3+60*mins))", "from datetime import datetime, timedelta\ndef day_and_time(mins):\n d = datetime.strptime('2019-01-13 00:00', '%Y-%m-%d %H:%M') + timedelta(minutes = mins)\n return d.strftime('%A %H:%M')\n", "from datetime import datetime, timedelta\n\n\ndef day_and_time(mins):\n return format(datetime(2018, 7, 1) + timedelta(minutes=mins), '%A %H:%M')", "from datetime import datetime, timedelta\n\ndef day_and_time(mins):\n test_date = datetime(2017, 2, 12) + timedelta(minutes=mins)\n return test_date.strftime(\"%A %H:%M\")\n", "WEEKDAYS = ('Sunday', 'Monday', 'Tuesday', 'Wednesday',\n 'Thursday', 'Friday', 'Saturday')\n\n\ndef day_and_time(minutes):\n days, minutes = divmod(minutes, 1440)\n hours, minutes = divmod(minutes, 60)\n return '{} {:02}:{:02}'.format(WEEKDAYS[days % 7], hours, minutes)\n", "day_and_time = lambda m: \"{} {:02d}:{:02d}\".format([\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\"][(m//1440)%7], (m//60)%24, m%60)"] | {"fn_name": "day_and_time", "inputs": [[0], [-3], [45], [759], [1236], [1447], [7832], [18876], [259180], [-349000]], "outputs": [["Sunday 00:00"], ["Saturday 23:57"], ["Sunday 00:45"], ["Sunday 12:39"], ["Sunday 20:36"], ["Monday 00:07"], ["Friday 10:32"], ["Saturday 02:36"], ["Thursday 23:40"], ["Tuesday 15:20"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,521 |
def day_and_time(mins):
|
e1091b7aaf7701c101abf72b27c22a67 | UNKNOWN | ## Task
You will receive a string consisting of lowercase letters, uppercase letters and digits as input. Your task is to return this string as blocks separated by dashes (`"-"`). The elements of a block should be sorted with respect to the hierarchy listed below, and each block cannot contain multiple instances of the same character. Elements should be put into the first suitable block.
The hierarchy is:
1. lowercase letters (`a - z`), in alphabetical order
2. uppercase letters (`A - Z`), in alphabetical order
3. digits (`0 - 9`), in ascending order
## Examples
* `"21AxBz" -> "xzAB12"` - since input does not contain repeating characters, you only need 1 block
* `"abacad" -> "abcd-a-a"` - character "a" repeats 3 times, thus 3 blocks are needed
* `"" -> ""` - an empty input should result in an empty output
* `"hbh420sUUW222IWOxndjn93cdop69NICEep832" -> "bcdehjnopsxCEINOUW0234689-dhnpIUW239-2-2-2"` - a more sophisticated example
Good luck! | ["from collections import Counter\n\ndef blocks(s):\n sort = lambda c: (c.isdigit(), c.isupper(), c)\n answer, counter = [], Counter(s)\n while counter:\n block = ''.join(sorted(counter, key=sort))\n answer.append(block)\n counter = counter - Counter(block)\n return '-'.join(answer)", "from collections import Counter\nfrom itertools import zip_longest\n\ndef blocks(s): return '-'.join(map(sortAndJoin, zip_longest(*blocker(s), fillvalue='')))\ndef sortAndJoin(lst): return ''.join(sorted(lst,key=blockKeyer))\ndef blockKeyer(c): return (c.isdigit(), c.isupper(), c)\ndef blocker(s): return (c*n for c,n in Counter(s).items())", "from string import ascii_letters, digits\nfrom collections import Counter\n\nALPHABET = ascii_letters + digits\nC_ALPHABET = Counter(ALPHABET)\n\ndef blocks(s):\n d = Counter(ALPHABET + s) - C_ALPHABET\n return \"-\".join(\"\".join(x for x in d if d[x] > i) for i in range(max(d.values(), default=0)))", "from collections import Counter as C\nfrom string import ascii_lowercase as l,digits as d\ndef blocks(s):\n if not s:return ''\n char = sorted(C(s).items(), key=lambda x: (l+l.upper()+d).index(x[0]))\n li = ['']*max(char, key=lambda x: x[1])[1]\n for i, j in char : \n for pos in range(j) : li[pos]+=i\n return '-'.join(li)", "from collections import Counter\n\n\nsort_group = lambda c: (c.isdecimal(), c.isupper(), c.islower(), c)\n\n\ndef blocks(stg):\n groups, count = [], Counter(stg)\n while count:\n groups.append(\"\".join(sorted(list(count.keys()), key=sort_group)))\n count -= Counter(list(count.keys()))\n return \"-\".join(groups)\n", "from collections import Counter\n\ndef blocks(s):\n stg = sorted(sorted(set(s)), key = lambda x:(x.isdigit() ,x.isupper()))\n doc = Counter(s)\n ret = ''\n while max(doc.values(),default = 0)>0:\n for e in stg:\n if doc[e]>0:\n ret += e\n doc[e] -= 1 \n ret += '-'\n return ret[:-1]", "from collections import Counter\nfrom string import ascii_letters, digits\ndef blocks(s):\n cnt = Counter(sorted(s, key = (ascii_letters + digits).index))\n res = []\n while cnt:\n res.append(''.join(cnt.keys()))\n cnt = {k : v - 1 for k, v in cnt.items() if v > 1}\n return '-'.join(res)", "def blocks(s):\n switch, ret = [ lambda e:e.islower(), lambda e:e.isupper(), lambda e:e.isdigit() ], ''\n for lm in switch:\n ret += ''.join([ e for e in sorted(s) if lm(e) ]) \n return ''.join( box(ret) )\n \ndef box(blok):\n if blok:\n ret = [ '' ] * blok.count( max(blok,key = blok.count) )\n for e in blok:\n for i in range(blok.count(e)):\n ret[i] += ['',e][e not in ret[i]]\n return '-'.join(ret)\n return blok\n", "from string import ascii_letters as let, digits as dig\ndef blocks(s):\n if s:\n Max = max(map(s.count, s))\n bs = [''.join(sorted([c for c in set(s) if s.count(c) >= n+1], key=(let+dig).find)) for n in range(Max)]\n return '-'.join(bs)\n else: return ''", "from itertools import groupby, zip_longest\n\ndef blocks(s):\n groups = groupby(sorted(s, key=lambda c: (c.isdigit(), c.isupper(), c)))\n blocks = zip_longest(*(list(b) for _, b in groups), fillvalue=\"\")\n return '-'.join(\n ''.join(b)\n for b in blocks\n )"] | {"fn_name": "blocks", "inputs": [["heyitssampletestkk"], ["dasf6ds65f45df65gdf651vdf5s1d6g5f65vqweAQWIDKsdds"], ["SDF45648374RHF8BFVYg378rg3784rf87g3278bdqG"], [""], ["aaaaaaaaaa"]], "outputs": [["aehiklmpsty-ekst-est"], ["adefgqsvwADIKQW1456-dfgsv156-dfs56-dfs56-dfs56-df56-d5-d"], ["bdfgqrBDFGHRSVY2345678-grF3478-gF3478-3478-78-8"], [""], ["a-a-a-a-a-a-a-a-a-a"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,428 |
def blocks(s):
|
66ce51d068b05c18bd7dded04dcf207e | UNKNOWN | Given a string of words (x), you need to return an array of the words, sorted alphabetically by the final character in each.
If two words have the same last letter, they returned array should show them in the order they appeared in the given string.
All inputs will be valid. | ["def last(s):\n return sorted(s.split(), key=lambda x: x[-1])", "def last(s):\n return sorted(s.split(), key = lambda word: word[-1])", "from operator import itemgetter\n\ndef last(s):\n return sorted(s.split(), key=itemgetter(-1))", "def last(s):\n return sorted(s.split(\" \"), key=lambda w: w[-1])", "last=lambda x: sorted(x.split(), key=lambda i: i[-1])", "def last(x):\n return sorted(x.split(' '), key=lambda s: s[-1])", "last=lambda x:sorted(x.split(),key=lambda e:e[-1])", "def last(x):\n a = x.split()\n last_char = []\n i = 0\n for word in a:\n last_char.append((word[-1], i, word))\n i = i + 1\n last_char = sorted(last_char)\n output = [word for char, i, word in last_char]\n return output", "def last(x):\n from collections import defaultdict\n d = defaultdict(list)\n res = []\n \n for w in x.split():\n d[w[-1]] += [w]\n \n for i in range(97,123):\n res += d[chr(i)]\n \n return res", "def last(x):\n return sorted(x.split(' '), key=lambda word: word[-1])"] | {"fn_name": "last", "inputs": [["man i need a taxi up to ubud"], ["what time are we climbing up the volcano"], ["take me to semynak"], ["massage yes massage yes massage"], ["take bintang and a dance please"]], "outputs": [[["a", "need", "ubud", "i", "taxi", "man", "to", "up"]], [["time", "are", "we", "the", "climbing", "volcano", "up", "what"]], [["take", "me", "semynak", "to"]], [["massage", "massage", "massage", "yes", "yes"]], [["a", "and", "take", "dance", "please", "bintang"]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,067 |
def last(s):
|
21d587631d96c88daad6fbe4c337dd4d | UNKNOWN | ## The story you are about to hear is true
Our cat, Balor, sadly died of cancer in 2015.
While he was alive, the three neighborhood cats Lou, Mustache Cat, and Raoul all recognized our house and yard as Balor's territory, and would behave respectfully towards him and each other when they would visit.
But after Balor died, gradually each of these three neighborhood cats began trying to claim his territory as their own, trying to drive the others away by growling, yowling, snarling, chasing, and even fighting, when one came too close to another, and no human was right there to distract or extract one of them before the situation could escalate.
It is sad that these otherwise-affectionate animals, who had spent many afternoons peacefully sitting and/or lying near Balor and each other on our deck or around our yard, would turn on each other like that. However, sometimes, if they are far enough away from each other, especially on a warm day when all they really want to do is pick a spot in the sun and lie in it, they will ignore each other, and once again there will be a Peaceable Kingdom.
## Your Mission
In this, the first and simplest of a planned trilogy of cat katas :-), all you have to do is determine whether the distances between any visiting cats are large enough to make for a peaceful afternoon, or whether there is about to be an altercation someone will need to deal with by carrying one of them into the house or squirting them with water or what have you.
As input your function will receive a list of strings representing the yard as a grid, and an integer representing the minimum distance needed to prevent problems (considering the cats' current states of sleepiness). A point with no cat in it will be represented by a "-" dash. Lou, Mustache Cat, and Raoul will be represented by an upper case L, M, and R respectively. At any particular time all three cats may be in the yard, or maybe two, one, or even none.
If the number of cats in the yard is one or none, or if the distances between all cats are at least the minimum distance, your function should return True/true/TRUE (depending on what language you're using), but if there are two or three cats, and the distance between at least two of them is smaller than the minimum distance, your function should return False/false/FALSE.
## Some examples
(The yard will be larger in the random test cases, but a smaller yard is easier to see and fit into the instructions here.)
In this first example, there is only one cat, so your function should return True.
```
["------------",
"------------",
"-L----------",
"------------",
"------------",
"------------"], 10
```
In this second example, Mustache Cat is at the point yard[1][3] and Raoul is at the point yard[4][7] -- a distance of 5, so because the distance between these two points is smaller than the specified minimum distance of 6, there will be trouble, and your function should return False.
```
["------------",
"---M--------",
"------------",
"------------",
"-------R----",
"------------"], 6
```
In this third example, Lou is at yard[0][11], Raoul is at yard[1][2], and Mustache Cat at yard[5][2]. The distance between Lou and Raoul is 9.05538513814, the distance between Raoul and Mustache Cat is 4, and the distance between Mustache Cat and Lou is 10.295630141 -- all greater than or equal to the specified minimum distance of 4, so the three cats will nap peacefully, and your function should return True.
```
["-----------L",
"--R---------",
"------------",
"------------",
"------------",
"--M---------"], 4
```
Have fun! | ["from itertools import combinations\nfrom math import hypot\n\ndef peaceful_yard(yard, d):\n cats = ((i, j) for i,r in enumerate(yard) for j,c in enumerate(r) if c in 'LMR')\n return all(hypot(q[0] - p[0], q[1] - p[1]) >= d for p,q in combinations(cats, 2))", "def peaceful_yard(yard, min_distance):\n # Extract cat positions\n cats = {ch: (r, c) for r, row in enumerate(yard) for c, ch in enumerate(row) if ch != \"-\"}\n if len(cats) < 2:\n return True\n # Extract coordinates amd calculate euclidean distances between them\n coords = list(cats.values())\n euc_dist = lambda x, y: ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** 0.5\n r = list(range(len(coords)))\n dists = [euc_dist(coords[i], coords[j]) for i in r for j in r if i < j]\n # Check minimum distance against required minimum\n return min_distance <= min(dists)\n", "def distance(xxx_todo_changeme, xxx_todo_changeme1):\n (x, y) = xxx_todo_changeme\n (x2, y2) = xxx_todo_changeme1\n return ((x2 - x) ** 2 + (y2 - y) ** 2) ** 0.5\n\n\ndef peaceful_yard(yard, min_distance):\n cats = []\n for r, row in enumerate(yard):\n for c, col in enumerate(row):\n if col != '-':\n current = (r, c)\n if any(distance(current, cat) < min_distance for cat in cats):\n return False\n cats.append(current)\n return True\n", "def peaceful_yard(yard, min_distance):\n cats = [x+y*1j for y, l in enumerate(yard) for x, c in enumerate(l) if c != '-']\n return all(abs(a - b) >= min_distance for i, a in enumerate(cats) for b in cats[:i])", "def euclidean_distance(cell, goal):\n dx = abs(cell[0] - goal[0])\n dy = abs(cell[1] - goal[1])\n return (dx**2 + dy**2)**.5\n\ndef peaceful_yard(yard, min_distance):\n coord = []\n for x in range(len(yard)):\n for y in range(len(yard[x])):\n if yard[x][y] in {'L','R','M'}:\n if any(euclidean_distance(cat_pos, (x,y)) < min_distance for cat_pos in coord):\n return False\n coord.append((x,y))\n return True", "from itertools import combinations\nfrom math import hypot\n\n\ndef peaceful_yard(yard, min_distance):\n l, yard = len(yard[0]), \"\".join(yard)\n cats = (divmod(yard.index(c), l) for c in \"LMR\" if c in yard)\n distances = (hypot(x2-x1, y2-y1) for (x1, y1), (x2, y2) in combinations(cats, 2))\n return all(min_distance <= d for d in distances)\n \n\n# one-liner\n#peaceful_yard = lambda y, m: all(m <= d for d in (hypot(x2-x1, y2-y1) for (x1, y1), (x2, y2) in combinations((divmod(i, len(y[0])) for i, c in enumerate(\"\".join(y)) if c != \"-\"), 2)))\n\n# alternatives:\n# more intuitive but much slower:\n# cats = [divmod(i, l) for i, c in enumerate(yard) if c != \"-\"]\n# less readable but avoid imports:\n# distances = [((x2-x1)**2 + (y2-y1)**2)**0.5 for i, (x1, y1) in enumerate(cats, 1) for (x2, y2) in cats[i:]]\n", "import math\ndef distance(pos1,pos2):\n if pos1 and pos2:\n return math.sqrt((pos2[0]-pos1[0])**2+(pos2[1]-pos1[1])**2)\n\ndef peaceful_yard(yard, min_distance):\n rPos = None\n lPos = None\n mPos = None\n counter = 0\n for i in range(len(yard)):\n if yard[i].find(\"L\") != -1:\n lPos = (i,yard[i].find(\"L\"))\n counter += 1\n if yard[i].find(\"R\") != -1:\n rPos = (i,yard[i].find(\"R\")) \n counter += 1\n if yard[i].find(\"M\") != -1:\n mPos = (i,yard[i].find(\"M\"))\n counter += 1\n if counter <= 1:\n return True\n else:\n distances = [distance(rPos,lPos), distance(lPos,mPos), distance(rPos,mPos)]\n for dist in distances:\n if (dist and dist < min_distance):\n return False\n return True", "from itertools import combinations\nfrom math import hypot\n\ndef peaceful_yard(yard, min_distance):\n cats = [\n (r, c)\n for r, row in enumerate(yard)\n for c, x in enumerate(row)\n if x != '-'\n ]\n return all(\n hypot(a-c, b-d) >= min_distance\n for (a, b), (c, d) in combinations(cats, 2)\n )", "from math import hypot\nfrom itertools import combinations\n\ndef peaceful_yard(yard, min_distance):\n positions = [(yard.index(row), row.index(cat)) for row in yard if row.replace(\"-\", \"\") for cat in row.replace(\"-\", \"\")]\n return all(hypot(x1-x0, y1-y0) >= min_distance for ((x0, y0), (x1, y1)) in combinations(positions, 2))", "def peaceful_yard(yard, min_distance):\n from scipy.spatial.distance import euclidean\n\n cat_positions = [(i, j) for i in range(len(yard)) \n for j in range(len(yard[i])) if yard[i][j] in \"LMR\"]\n\n from itertools import combinations\n return all(euclidean(cat1, cat2) >= min_distance \n for cat1, cat2 in combinations(cat_positions, 2))\n"] | {"fn_name": "peaceful_yard", "inputs": [[["------------", "------------", "-L----------", "------------", "------------", "------------"], 10], [["------------", "---M--------", "------------", "------------", "-------R----", "------------"], 6], [["-----------L", "--R---------", "------------", "------------", "------------", "--M---------"], 4], [["------------", "--L-------R-", "----M-------", "------------", "------------", "------------"], 6], [["-----------R", "--L---------", "------------", "------------", "------------", "----------M-"], 4], [["------------", "--L---R-----", "------------", "------------", "------M-----", "------------"], 6], [["------------", "--L---R---M-", "------------", "------------", "------------", "------------"], 6], [["------------", "--L---R---M-", "------------", "------------", "------------", "------------"], 2]], "outputs": [[true], [false], [true], [false], [true], [false], [false], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,936 |
def peaceful_yard(yard, min_distance):
|
58e017b856f724634e90e703a06201ee | UNKNOWN | Create a function that takes a list of one or more non-negative integers, and arranges them such that they form the largest possible number.
Examples:
`largestArrangement([4, 50, 8, 145])` returns 8504145 (8-50-4-145)
`largestArrangement([4, 40, 7])` returns 7440 (7-4-40)
`largestArrangement([4, 46, 7])` returns 7464 (7-46-4)
`largestArrangement([5, 60, 299, 56])` returns 60565299 (60-56-5-299)
`largestArrangement([5, 2, 1, 9, 50, 56])` returns 95655021 (9-56-5-50-21) | ["from functools import cmp_to_key\n\ncmp = lambda a, b: int('%i%i' % (b, a)) - int('%i%i' % (a, b))\nlargest_arrangement = lambda n: int(''.join(str(i) for i in sorted(n, key = cmp_to_key(cmp))))", "def largest_arrangement(numbers):\n numbers = list(map(str, numbers))\n for x in range(len(numbers)):\n for j in range(len(numbers)):\n ab = numbers[x] + numbers[j]\n ba= numbers[j] + numbers[x]\n if int(ab) > int(ba):\n numbers[x], numbers[j] = numbers[j], numbers[x]\n return int(''.join(numbers))", "from itertools import permutations\n\ndef largest_arrangement(numbers):\n return max(int(''.join(p)) for p in permutations(map(str, numbers)))", "from itertools import permutations\ndef largest_arrangement(numbers):\n return int(max((\"\".join(r) for r in permutations(list(map(str,numbers)))), key = int))\n", "from itertools import permutations, groupby\ndef largest_arrangement(a):\n a = sorted(a, key=lambda x: str(x)[0])[::-1]\n t = ''\n for i, j in groupby(a, key=lambda x: str(x)[0]):\n li = []\n for k in permutations(list(j)):\n li.append(int(\"\".join(map(str, k))))\n t += str(max(li))\n return int(t)", "from itertools import permutations\ndef largest_arrangement(numbers):\n return int(max(''.join(xs) for xs in permutations(map(str, numbers))))", "from functools import cmp_to_key\n\ndef largest_arrangement(numbers):\n\n @cmp_to_key\n def cmp(a, b): \n return int(b + a) - int(a + b)\n \n return int(''.join(n for n in sorted(map(str, numbers), key=cmp)))", "from itertools import permutations\nfrom collections import defaultdict\n\ndef find_largest(lst):\n candidates = map(\"\".join, permutations(lst))\n return max(candidates)\n\ndef largest_arrangement(numbers):\n first_digit = defaultdict(list)\n \n for n in map(str, numbers):\n first_digit[n[0]].append(n)\n \n result = \"\".join(find_largest(first_digit[d]) for d in \"9876543210\")\n return int(result)", "def largest_arrangement(numbers):\n r=qsort(numbers)\n r=''.join([str(v) for v in r])\n return int(r)\n\ndef qsort(arr): \n if len(arr) <= 1: return arr\n else:\n return qsort([x for x in arr[1:] if so(x,arr[0])==-1]) + [arr[0]] + qsort([x for x in arr[1:] if so(x,arr[0])!=-1])\n\ndef so(a,b):\n return -1 if str(b)+str(a) < str(a)+str(b) else 1", "largest_arrangement=lambda a:(lambda l:int(''.join(sorted(map(str,a),key=lambda s:s.ljust(l,s[0]))[::-1])))(len(str(max(a))))"] | {"fn_name": "largest_arrangement", "inputs": [[[50, 2, 1, 9]], [[3655, 89]], [[8]], [[12, 13, 89, 155, 8, 26, 0]], [[76, 4, 3, 81, 514, 6, 716]], [[817, 6879, 163, 348, 8, 22, 47]], [[411, 742, 89, 691, 284]], [[587, 625, 638, 898, 122]], [[797, 535, 210, 87]], [[5, 2, 1, 9, 50, 56]], [[197, 853, 819]], [[23044, 2, 7626, 914, 7800]], [[451, 850, 85, 283, 4, 734, 605, 499, 249]], [[304, 12, 206, 584, 78, 69, 864, 860]], [[8346, 991, 25, 4, 67]], [[298, 268, 58, 598, 702, 603, 597]], [[422, 995, 500, 202, 772, 230, 258, 144, 752]], [[618, 514, 863, 195, 965, 262]], [[141, 63, 51, 966, 520, 48, 82, 14, 397]], [[756, 688, 8, 657, 912]], [[70, 7, 81, 28, 336, 246, 817, 77, 4, 550]], [[150, 398, 919, 890, 447, 285]], [[783, 19, 88, 5, 7]], [[10, 327, 6, 70, 13, 83, 482, 77]], [[8, 6, 590, 70]], [[6, 73, 79, 356, 7]], [[64, 29, 5, 9, 982, 3]], [[3487, 103559, 243]], [[7, 78, 79, 72, 709, 7, 94]]], "outputs": [[95021], [893655], [8], [8982615513120], [8176716651443], [881768794734822163], [89742691411284], [898638625587122], [87797535210], [95655021], [853819197], [91478007626230442], [858507346054994514283249], [864860786958430420612], [991834667425], [70260359859758298268], [995772752500422258230202144], [965863618514262195], [9668263520514839714141], [9128756688657], [8181777770550433628246], [919890447398285150], [887837519], [83777064823271310], [8706590], [797736356], [9982645329], [3487243103559], [9479787772709]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,542 |
def largest_arrangement(numbers):
|
c3de43d71f3ef5698221a35efe5f6c2e | UNKNOWN | You are given an array that of arbitrary depth that needs to be nearly flattened into a 2 dimensional array. The given array's depth is also non-uniform, so some parts may be deeper than others.
All of lowest level arrays (most deeply nested) will contain only integers and none of the higher level arrays will contain anything but other arrays. All arrays given will be at least 2 dimensional. All lowest level arrays will contain at least one element.
Your solution should be an array containing all of the lowest level arrays and only these. The sub-arrays should be ordered by the smallest element within each, so `[1,2]` should preceed `[3,4,5]`. Note: integers will not be repeated.
For example:
If you receive `[[[1,2,3],[4,5]],[6,7]]`, your answer should be `[[1,2,3],[4,5],[6,7]]`. | ["def near_flatten(a):\n r = []\n for x in a:\n if isinstance(x[0], int): r.append(x)\n else: r.extend(near_flatten(x))\n return sorted(r)", "def near_flatten(xs):\n def f(xs):\n if all(not isinstance(x, list) for x in xs):\n yield xs\n return\n for x in xs:\n yield from f(x)\n return sorted(f(xs))\n", "from itertools import chain\n\ndef f(t):\n return [sorted(t)] if not isinstance(t[0],list) else chain(*(f(x) for x in t))\n\ndef near_flatten(lst):\n return sorted( chain(*(f(x) for x in lst )))", "def near_flatten(a):\n li = []\n def do(a):\n for i in a:\n li.append(i if all(isinstance(k, int) for k in i) else do(i))\n do(a)\n return sorted([i for i in li if i])", "def near_flatten(nested):\n result = []\n for item in nested:\n if type(item[0]) == list:\n result.extend(near_flatten(item))\n else:\n result.append(item)\n return sorted(result, key=lambda l: l[0])", "from itertools import chain\n\n\ndef flatten(list_):\n return [list_] if isinstance(list_[0], int) else\\\n chain(*(flatten(l) for l in list_))\n\n\ndef near_flatten(nested):\n return sorted(chain(*(flatten(list_) for list_ in nested)))", "def near_flatten(nested):\n ret = []\n def flatten(arr):\n for i, ar in enumerate(arr):\n if type(ar[0]) == int:\n ret.append(ar)\n else:\n flatten(ar)\n \n flatten(nested)\n \n return sorted(ret)\n", "import re\nr=re.compile(r'(?<=\\[)\\[|(?<=\\])\\]')\ndef near_flatten(nested):\n return sorted(eval('['+r.sub('',str(nested))+']'),key=lambda x: x[0])", "import re\n\ndef near_flatten(nested):\n nested = str(nested)\n flatten_regex = re.compile(r\"\\[+(\\d+)(?:, )?(\\d+)?(?:, )?(\\d+)?(?:, )?(\\d+)?\\]+\")\n matches = flatten_regex.finditer(nested)\n fixed_ls = [flatten_regex.sub(r\"\\1 \\2 \\3 \\4\", i.group()).split() for i in matches]\n fixed_ls = [[int(x) for x in i] for i in fixed_ls]\n return sorted(fixed_ls)", "def near_flatten(A):\n s=str(A)[1:-1]\n while '[[' in s:s=s.replace('[[','[')\n while ']]' in s:s=s.replace(']]',']')\n return sorted(list(map(int,x.split(',')))for x in s[1:-1].split('], ['))"] | {"fn_name": "near_flatten", "inputs": [[[[1]]], [[[1, 2, 3], [4, 5, 6]]], [[[1, 2, 3], [[4, 5], [[6], [7, 8]]]]], [[[[1, 2, 3], [9, 10]], [[4, 5], [6, 7, 8]]]]], "outputs": [[[[1]]], [[[1, 2, 3], [4, 5, 6]]], [[[1, 2, 3], [4, 5], [6], [7, 8]]], [[[1, 2, 3], [4, 5], [6, 7, 8], [9, 10]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,329 |
def near_flatten(nested):
|
93d5aea0adaca1cc5ac81bb9f88fcc12 | UNKNOWN | An Ironman Triathlon is one of a series of long-distance triathlon races organized by the World Triathlon Corporaion (WTC).
It consists of a 2.4-mile swim, a 112-mile bicycle ride and a marathon (26.2-mile) (run, raced in that order and without a break. It hurts... trust me.
Your task is to take a distance that an athlete is through the race, and return one of the following:
If the distance is zero, return `'Starting Line... Good Luck!'`.
If the athlete will be swimming, return an object with `'Swim'` as the key, and the remaining race distance as the value.
If the athlete will be riding their bike, return an object with `'Bike'` as the key, and the remaining race distance as the value.
If the athlete will be running, and has more than 10 miles to go, return an object with `'Run'` as the key, and the remaining race distance as the value.
If the athlete has 10 miles or less to go, return return an object with `'Run'` as the key, and `'Nearly there!'` as the value.
Finally, if the athlete has completed te distance, return `"You're done! Stop running!"`.
All distance should be calculated to two decimal places. | ["def i_tri(s):\n total = 2.4 + 112 + 26.2\n to_go = '%.2f to go!' % (total - s)\n \n return ( 'Starting Line... Good Luck!' if s == 0 else\n {'Swim': to_go} if s < 2.4 else\n {'Bike': to_go} if s < 2.4 + 112 else\n {'Run': to_go} if s < total - 10 else\n {'Run': 'Nearly there!'} if s < total else\n \"You're done! Stop running!\" )", "def i_tri(s):\n remain = 2.4 + 112 + 26.2 - s\n if s == 0:\n return 'Starting Line... Good Luck!'\n elif s < 2.4:\n return {'Swim': f'{remain:.2f} to go!'}\n elif s < 2.4 + 112:\n return {'Bike': f'{remain:.2f} to go!'}\n elif remain > 10:\n return {'Run': f'{remain:.2f} to go!'}\n elif remain > 0:\n return {'Run': 'Nearly there!'}\n else:\n return \"You're done! Stop running!\"", "def i_tri(s):\n t = 2.4 + 112.0 + 26.2\n v = t - s\n k = \"Swim\" if s < 2.4 else \"Bike\" if s >= 2.4 and s < 114.4 else 'Run'\n if s == 0: return 'Starting Line... Good Luck!'\n elif s >= t: return \"You're done! Stop running!\"\n elif t - s <= 10: return {'Run':'Nearly there!'}\n else: return {k: \"{:.2f}\".format(v) + ' to go!'}\n", "def i_tri(d):\n r, k = 140.6 - d, \"Run\" if 114.4 < d else \"Bike\" if 2.4 < d else \"Swim\"\n v = f\"{r:.2f} to go!\" if r > 10 else \"Nearly there!\"\n return {k: v} if d*r > 0 else \"You're done! Stop running!\" if d > 0 else \"Starting Line... Good Luck!\"\n", "def i_tri(s):\n out = 'Starting Line... Good Luck!'\n if s>0.0 and s<=2.4 : out = {'Swim': f'{140.6 - s:.2f} to go!'}\n if s>2.4 and s<=114.4 : out = {'Bike': f'{140.6 - s:.2f} to go!'}\n if s>114.4 and s<130.6 : out = {'Run' : f'{140.6 - s:.2f} to go!'}\n if s>=130.6 and s<140.6 : out = {'Run' : 'Nearly there!'}\n if s>140.6 : out = \"You're done! Stop running!\"\n return out\n \n", "def i_tri(s):\n #your code here\n d ={2.4: 'Swim', 114.4: 'Bike', 140.6: 'Run'}\n if s == 0:\n return 'Starting Line... Good Luck!'\n for k in sorted(d):\n if s < k:\n return {d[k] : \"{:.02f} to go!\". format(140.6 - s)}\n return \"You're done! Stop running!\"", "def i_tri(s):\n if s == 0:\n return \"Starting Line... Good Luck!\"\n swim = 2.4\n bicycle = 112\n marathon = 26.2\n distance = swim + bicycle + marathon\n if s > distance:\n return \"You're done! Stop running!\"\n \n txt = \"Swim\" if s <= swim else \\\n \"Bike\" if s <= (swim + bicycle) else \\\n \"Run\"\n \n remaining = distance - s\n obj = {f\"{txt}\":f\"{remaining:.2f} to go!\"}\n \n return obj", "def i_tri(s):\n stages = [[\"Starting Line... Good Luck!\"],\n [2.4,\"Swim\"],\n [114.4,\"Bike\"],\n [140.6,\"Run\"],\n [\"Nearly there!\"],\n [\"You're done! Stop running!\"]]\n if not s : return stages[0][0]\n elif s >= 140.6 : return stages[-1][0]\n else : \n curr_stage = [v for k,v in stages[1:4] if s<=k]\n return {curr_stage[0]:'{:.2f} to go!'.format(140.6-s)} if s<=130.6 else {curr_stage[0]:stages[4][0]}\n", "def i_tri(s): \n return 'You\\'re done! Stop running!' if s>=140.6 \\\n else {'Run':'Nearly there!'} if s>=130.6 \\\n else {'Run':'{0:.2f} to go!'.format(140.6-s)} if s>=114.4 \\\n else {'Bike':'{0:.2f} to go!'.format(140.6-s)} if s>=2.4 \\\n else {'Swim':'{0:.2f} to go!'.format(140.6-s)} if s>0 \\\n else 'Starting Line... Good Luck!'", "def i_tri(s):\n if s==0: return 'Starting Line... Good Luck!'\n if s<2.4: return {'Swim': f'{140.6-s:.2f} to go!'}\n if s<114.4: return {'Bike': f'{140.6-s:.2f} to go!'}\n if s<130.6: return {'Run': f'{140.6-s:.2f} to go!'}\n if s<140.6: return {'Run': 'Nearly there!'}\n return \"You're done! Stop running!\""] | {"fn_name": "i_tri", "inputs": [[36], [103], [0], [2], [151]], "outputs": [[{"Bike": "104.60 to go!"}], [{"Bike": "37.60 to go!"}], ["Starting Line... Good Luck!"], [{"Swim": "138.60 to go!"}], ["You're done! Stop running!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,912 |
def i_tri(s):
|
717c6cfb98ad1ba5f0ed994ab27cb959 | UNKNOWN | Find the sum of the odd numbers within an array, after cubing the initial integers. The function should return `undefined`/`None`/`nil`/`NULL` if any of the values aren't numbers.
~~~if:java,csharp
Note: There are ONLY integers in the JAVA and C# versions of this Kata.
~~~
~~~if:python
Note: Booleans should not be considered as numbers.
~~~ | ["def cube_odd(arr):\n return sum( n**3 for n in arr if n % 2 ) if all(type(n) == int for n in arr) else None", "def cube_odd(arr):\n if any(type(x) is not int for x in arr):\n return None\n return sum(x ** 3 for x in arr if x % 2 != 0)", "def cube_odd(arr):\n if len(set(map(type,arr))) < 2:\n return sum(n**3 for n in arr if n%2)", "def cube_odd(arr):\n return sum(n**3 for n in arr if n % 2 == 1) if all(type(e) == int for e in arr) else None", "def cube_odd(arr):\n s = 0\n for n in arr:\n if type(n) != int: break\n elif n%2: s += n**3\n else:\n return s", "def cube_odd(arr):\n if any(type(x) is not int for x in arr):\n return None\n \n return sum(x**3 for x in arr if x % 2 == 1)", "def cube_odd(a):\n return sum(e**3 for e in a if e % 2) if all(type(e) == int for e in a) else None", "def cube_odd(arr):\n if arr == [x for x in arr if type(x) == int]: return sum([i**3 for i in arr if i % 2 == 1])\n", "def cube_odd(arr):\n total = 0\n for el in arr:\n if isinstance(el, int):\n if el % 2 == 1 and el != 0:\n total += el ** 3\n else:\n return None\n if total == 2:\n return None\n return total", "def cube_odd(arr):\n ar = sum([ el **3 for el in arr if type(el) == int and el %2 !=0]) \n return ar if [el for el in arr if type(el) != int]==[] else None", "def cube_odd(arr):\n result = 0\n for n in arr:\n if type(n) == type(\"s\") or type(n) == type(True):\n return None\n elif (n**3 % 2 != 0) and (type(n) == type(5)):\n result += n**3 \n \n return result\n \n #your code here - return None if at least a value is not an integer\n", "def cube_odd(n): \n return sum([el ** 3 for el in n if type(el) == int and el % 2 != 0]) if [el for el in n if type(el) != int] == [] else None\n\n", "def cube_odd(arr):\n odds = []\n for num in arr:\n if type(num) != type(4):\n return None\n elif num % 2 != 0:\n odds.append(num**3)\n return sum(odds)", "def cube_odd(arr):\n ar = sum([ el **3 for el in arr if type(el) == int and el %2 !=0]) # remove str\n return ar if [el for el in arr if type(el) != int] == [] else None # if str => None", "def cube_odd(arr):\n #your code here - return None if at least a value is not an integer\n n = 0\n for i in arr:\n if type(i) != int:\n return None\n break\n else:\n if i%2 != 0 or (-1*i)%2 != 0:\n n += i**3\n return n", "def cube_odd(arr):\n a=sum([el**3 for el in arr if type(el)==int and el%2!=0]) \n return a if [el for el in arr if type(el)!=int]==[] else None", "def cube_odd(arr):\n for el in arr:\n if type(el) != int:\n return None\n return sum([el ** 3 for el in arr if type(el) == int and el % 2 != 0])", "def cube_odd(arr):\n if len([el for el in arr if type(el) != int]) > 0:\n return None\n return sum([el ** 3 for el in arr if el % 2 != 0 ])", "def cube_odd(a):\n sum, i = 0, 0\n while True:\n try:\n if type(a[i]) != int:\n return None\n if a[i]&1:\n sum += a[i]**3\n except IndexError:\n break\n i += 1\n return sum ", "def cube_odd(a):\n sum, i = 0, 0\n while True:\n try:\n if type(a[i]) != int:\n return None\n if a[i]%2:\n sum += a[i]**3\n except IndexError:\n break\n i += 1\n return sum ", "def cube_odd(arr):\n cube = []\n for i in arr:\n if type(i) != int:\n return None\n if i % 2 != 0:\n cube.append(i**3)\n return sum(cube)\n", "def cube_odd(arr):\n new_arr = []\n for el in arr:\n if type(el) != int:\n return None\n elif el %2 !=0 and type(el) == int:\n new_arr.append(el**3) \n return sum(new_arr)\n\n", "def cube_odd(arr):\n\n s = 0\n \n if any(isinstance(b,bool) for b in arr):\n \n return None\n \n if not all(isinstance(x,int) for x in arr):\n \n return None\n\n for i in range(0,len(arr)):\n \n if arr[i]%2!=0 :\n \n s+= arr[i]**3\n \n return s\n \n", "def cube_odd(arr):\n sum = 0\n for i in range(len(arr)):\n if type(arr[i]) != int:\n return None\n if arr[i] % 2 == 1:\n sum += arr[i]**3\n return sum", "def cube_odd(arr):\n s = [el for el in arr if type(el) != int]\n return sum([el ** 3 for el in arr if type(el) == int and el % 2 != 0 ]) if len(s) == 0 else None ", "def cube_odd(arr):\n x = 0\n for i in arr:\n if type(i) is not int:\n return None\n if i % 2 != 0:\n x += i*i*i\n return x", "def cube_odd(a):\n total = 0\n try:\n for i in a:\n if str(i) is 'False' or str(i) is 'True': return None\n total += i**3 if i**3%2 != 0 else 0\n return total\n except:\n return None", "def cube_odd(arr):\n for item in arr:\n if type(item) != int:\n return\n\n return sum(i**3 for i in arr if i % 2 != 0)", "def cube_odd(arr):\n while all(type(d) == int for d in arr):\n return sum(d**3 for d in arr if (d**3)%2==1)\n", "def cube_odd(arr):\n res = 0\n for i in arr:\n if type(i) != int:\n return None\n if i % 2:\n res += i ** 3\n return res", "def cube_odd(arr):\n a = [i for i in arr if type(i) == int]\n return sum([i**3 for i in a if i % 2 == 1]) if len(a) == len(arr) else None", "def cube_odd(arr):\n for i in arr:\n if type(i) != int:\n return None\n return sum([i**3 for i in arr if i % 2])", "def cube_odd(arr):\n #your code here - return None if at least a value is not an integer\n o = 0\n for i in arr:\n if type(i)!=int:\n return None\n elif i%2==1:\n o+=i**3\n else:\n continue\n return o ", "def cube_odd(arr):\n s = 0\n for x in arr:\n if type(x) != int:\n return None\n elif x**3 % 2 == 1:\n s += x**3\n return s\n", "def cube_odd(arr):\n odd = list()\n for i in arr:\n if (isinstance(i, int) and\n not isinstance(i, bool)):\n if abs(i)%2 != 0:\n odd.append(i)\n else:\n return None\n \n return sum(map(lambda x: x**3, odd))", "def cube_odd(arr):\n res = 0\n for n in arr:\n if type(n) != int:\n return None\n res += n**3 if n%2 else 0\n return res", "def cube_odd(arr):\n a = 0\n for i in arr : \n if type(i) != int: break\n elif i % 2 != 0 :\n a += i**3\n \n else : \n return a\n \n #your code here - return None if at least a value is not an integer\n", "def cube_odd(arr):\n for i in arr:\n if type(i)!=type(1):\n return None\n return sum(i**3 for i in arr if i%2==1)", "def cube_odd(x):\n if len(x)!=len([i for i in x if type(i)==int]):\n return None\n else:\n return sum([i**3 for i in x if i%2!=0])", "def cube_odd(arr):\n result = 0\n for el in arr:\n if type(el) != int:\n return None\n if el % 2 != 0:\n result += el*el*el\n return result ", "def cube_odd(arr):\n c = []\n n = []\n for x in arr:\n if type(x) != int:\n return None\n elif x < 0 and x % 2 != 0:\n c.append(x**3)\n elif x > 0 and x % 2 :\n n.append(x**3)\n return sum(n) + sum(c)", "def cube_odd(arr):\n \n sol = 0\n \n for i in arr:\n \n if type(i) != int:\n break\n \n elif i % 2:\n sol += i**3\n \n else:\n return sol", "def cube_odd(arr):\n #your code here - return None if at least a value is not an integer\n s = 0\n for i in arr:\n if type(i)!=int:\n return None\n elif i%2==1:\n s+=i**3\n else:\n continue\n return s", "def cube_odd(arr):\n l = []\n for x in arr:\n if type(x) != int:\n return None\n elif x % 2 == 1:\n l.append(x ** 3)\n return sum(l)", "def cube_odd(arr):\n func = lambda x: isinstance(x, (int,float)) and not isinstance(x, bool)\n return (all(map(func,arr)) or None) and sum(x**3 for x in arr if x**3%2)", "def cube_odd(arr):\n x = [i for i in arr if not isinstance(i,bool)]\n if len(x) == len(arr):\n try:\n return sum([i**3 for i in x if i % 2])\n except:\n pass", "def cube_odd(arr):\n cubes = []\n for i in arr:\n if type(i)!=int:\n return None\n if i%2!=0:\n cubes.append(i**3)\n return sum(cubes)", "def cube_odd(arr):\n int_arr = []\n for i in arr:\n if type(i) == int:\n int_arr.append(i)\n else:\n return None\n res = []\n for i in int_arr:\n if i % 2 != 0:\n res.append(i)\n res2 = []\n for i in res:\n res2.append(i*i*i)\n return sum(res2)", "def cube_odd(arr):\n x = 0\n for i in arr:\n if type(i) is not int:\n return None\n break\n elif i % 2 != 0:\n x += i**3\n return x", "def cube_odd(A):\n print(A)\n r = None\n for i in A:\n if not isinstance(i, int) or isinstance(i, bool): return None\n if i%2 : r = i**3 if not r else r+i**3\n return r", "def cube_odd(arr):\n new_arr = []\n for i in range(len(arr)):\n if type(arr[i]) == bool:\n return None\n if type(arr[i]) == str:\n return None\n new_arr.append(arr[i] ** 3)\n value = 0\n for i in range(len(new_arr)):\n if new_arr[i] % 2 == 1:\n value += new_arr[i]\n return value\n", "def cube_odd(arr):\n res = 0\n for i in arr:\n if not isinstance(i, int) or isinstance(i, bool):\n return None\n elif i%2!=0:\n res += i**3\n return res", "def cube_odd(arr):\n all_int = all(type(n) == int for n in arr)\n return sum(n ** 3 for n in arr if n & 1) if all_int else None", "def cube_odd(arr):\n res=0\n for i in arr:\n if isinstance(i,int) and not isinstance(i,bool):\n if (i**3)%2==1:\n res+=i**3\n else:\n return None\n return res", "def cube_odd(arr):\n for x in arr :\n if type(x)!=int : return None\n return sum([x**3 for x in arr if x%2==1])", "def cube_odd(arr):\n accumulator = 0\n for eachvalue in arr:\n if type(eachvalue) != type(1):\n return None\n else:\n if eachvalue % 2 != 0:\n x = eachvalue**3\n accumulator = accumulator + x\n return accumulator\n", "def cube_odd(arr):\n res_arr = [x for x in arr if isinstance(x, int) and not isinstance(x, bool)]\n if len(res_arr) == len(arr):\n return sum([x**3 for x in arr if x % 2 != 0])\n else:\n return None", "def cube_odd(arr):\n\n if any(str(char).isalpha() for char in arr) == True:\n return None\n\n return sum(char**3 for char in arr if char%2 != 0)", "import unittest\n\n\ndef cube_odd(arr):\n def _is_none_condition():\n return any(True if not isinstance(ele, int)\n or ele is True\n or ele is False\n else False for ele in arr)\n if _is_none_condition():\n return\n return sum(ele ** 3 if ele % 2 == 1 else 0 for ele in arr)\n\n\nclass TestCubeOdd(unittest.TestCase):\n def test_should_return_none_when_any_of_the_values_are_not_numbers(self):\n arr = [\"a\", 12, 9, \"z\", 42]\n actual = cube_odd(arr)\n self.assertEqual(actual, None)\n\n def test_cube_odd(self):\n arr = [1, 2, 3, 4]\n actual = cube_odd(arr)\n self.assertEqual(actual, 28)\n", "def cube_odd(arr):\n s = 0\n for i in arr:\n if type(i) == bool or type(i) == str:\n return None\n else:\n if i%2==1:\n s += i**3\n return s", "def cube_odd(arr):\n output = 0\n for i in arr:\n if type(i) == int:\n if i % 2 != 0:\n output += i**3\n else:\n return None\n return output", "def cube_odd(arr):\n _arr = [n for n in arr if type(n) == int]\n if len(_arr) != len(arr):\n return None\n arr = [n ** 3 for n in arr if n % 2 != 0]\n return 0 if not arr else sum(arr)", "def cube_odd(arr):\n if all(type(x) is int or type(x) is float for x in arr):\n return sum(x ** 3 for x in arr if x % 2)\n\n", "def cube_odd(arr):\n cubes = []\n for item in arr:\n if str(item).strip('-').isdigit() == False:\n return None\n else:\n if item % 2 != 0:\n cubes.append(item**3)\n return sum(cubes)\n", "def cube_odd(arr):\n if all(type(i) == int for i in arr): return sum((i**3) for i in arr if i%2 != 0)\n", "def cube_odd(arr):\n if all(type(i) == int for i in arr): return sum((i**3) for i in arr if i%2 != 0)\n else: return None", "def cube_odd(arr):\n return sum(x ** 3 for x in arr if (x % 2 == 1)) if all(type(x) is int for x in arr) else None", "def cube_odd(arr):\n sum = 0\n for x in arr:\n if (not isinstance(x, (int, float, complex)) or isinstance(x, bool)): return None\n if (x % 2 == 1): sum += x ** 3\n return sum", "def cube_odd(arr):\n if any(isinstance(v, bool) or not isinstance(v, int) for v in arr): return\n return sum(v**3 for v in arr if v % 2)\n", "def cube_odd(arr):\n sum = 0\n for x in arr:\n if type(x) == int:\n if x % 2 == 1:\n sum += x**3\n else:\n return None\n return sum", "def cube_odd(arr):\n return sum(n**3 for n in arr if n % 2 == 1) if all(type(x) == int for x in arr) else None", "def cube_odd(arr):\n res=[]\n for i in arr:\n if not type(i)==int :\n return None\n if i%2:\n res.append(i**3)\n return sum(res)\n", "def cube_odd(arr):\n for x in arr:\n if type(x) != int: return None\n return sum([x**3 for x in arr if x**3 % 2 != 0])", "def cube_odd(arr):\n return sum(n ** 3 for n in arr if n % 2) if all(type(n) is int for n in arr) else None", "def cube_odd(n):\n sum = 0\n for n in n:\n if type(n)!=int:\n return None\n if n%2 != 0:\n sum += n**3\n return sum\n \n", "def cube_odd(arr):\n total=0\n for elem in arr:\n if type(elem) == int:\n if elem%2==1:\n total += elem**3\n else:\n return None\n return total", "def cube_odd(arr):\n #your code here - return None if at least a value is not an integer\n for i in arr :\n if not isinstance(i, int) or isinstance(i, bool) : return None\n return sum(i**3 for i in arr if i%2!=0)", "def cube_odd(arr):\n result = 0\n for i in arr: \n if not isinstance(i, int) or isinstance(i, bool):\n return None\n result += i**3 if i & 1 else 0\n return result", "def cube_odd(arr):\n cubed = []\n for i in arr:\n if type(i) != int:\n return None\n else:\n cubed.append(i ** 3)\n new_arr = []\n for x in cubed:\n if x % 2 != 0:\n new_arr.append(x)\n\n return sum(new_arr)\n", "# def cube_odd(arr):\n# x = 0\n# for x in arr:\n# if x is not int:\n# return None\n# if x ** 3 == 1:\n# return True\n# elif x % 2 != 0:\n# return False\n# res = cube_odd(x)\n# print(res)\n\ndef cube_odd(arr):\n if any(type(x) is not int for x in arr):\n return None\n return sum(x ** 3 for x in arr if x % 2 != 0)\n \n\n# def cube_odd(arr):\n# #your code here - return None if at least a value is not an integer\n# sum_num = (\"undefined, None, nil, NULL\")\n# sum_num = len()\n# if sum_num == int():\n# return sum_num\n# else:\n# pass\n# return arr(sum_num)\n# def cube_odd(arr):\n# if any(type(x) is not int for x in arr):\n# return None\n \n# return sum(x ** 3 for x in arr if x % 2 != 0)\n", "def cube_odd(arr):\n if set(map(type, arr)) != {int}:\n return None\n return sum([y for y in [x**3 for x in arr] if y % 2 == 1])", "def cube_odd(arr):\n return sum(x ** 3 for x in arr if x % 2) if all(isinstance(x, int) and not isinstance(x, bool) for x in arr) else None\n", "def cube_odd(arr):\n try:\n return sum(['x' if type(i) == bool else i**3 for i in arr if (i**3) % 2 != 0])\n except:\n return None", "def cube_odd(arr):\n s = 0\n for i in arr:\n if type(i) is int:\n if i % 2 != 0:\n s += i ** 3\n else:\n return None\n return s\n \n", "def cube_odd(arr):\n return sum(x ** 3 for x in arr if x % 2) if all(type(x) is int for x in arr) else None", "def cube_odd(arr):\n if all(map(lambda x: type(x) is int, arr)):\n return sum(map(lambda x: x ** 3, filter(lambda x: x % 2, arr)))\n return None", "def cube_odd(arr):\n sum = 0\n for i in arr:\n if type(i) in (int,):\n if i % 2:\n sum += i**3\n else:\n return None\n return sum\n", "def cube_odd(arr):\n r = 0\n for x in arr:\n if type(x) is not int:\n return None\n elif x % 2:\n r += x ** 3\n return r\n # Flez\n", "def cube_odd(arr):\n for x in arr:\n if type(x) is not int:\n return None\n \n cube = [x **3 for x in arr]\n r = 0\n for x in cube:\n if x % 2 != 0:\n r += x\n return r\n # Flez\n \n \n \n", "def cube_odd(arr):\n return None if any([type(i) != int for i in arr]) else sum((i**3 for i in arr if i % 2 == 1))", "def cube_odd(arr):\n x = []\n for i in arr:\n if type(i) != int:\n return None\n elif type(i) == int and i % 2 != 0:\n x.append(i**3)\n \n return sum(x)", "def cube_odd(arr):\n for i in arr:\n if type(i) != int or type(i) == bool: return(None)\n return(sum(i**3 for i in arr if i%2))", "cube_odd = lambda lst: None if not all(type(x) is int for x in lst) else sum(n ** 3 for n in lst if n & 1)", "def cube_odd(arr):\n #your code here - return None if at least a value is not an integer\n try:\n sum = 0\n for i in range(len(arr)):\n if i >= len(arr):\n break\n else:\n a = (i)\n if str(arr[a]) in [\"True\",\"False\"]:\n return None\n elif arr[a]%2 == 1:\n sum += (arr[a]**3)\n return sum\n except TypeError:\n return None", "def cube_odd(arr):\n sum = 0\n for i in range(len(arr)):\n if type(arr[i])!= int:\n return None\n elif arr[i]%2!=0:\n sum += arr[i]**3\n return sum \n #your code here - return None if at least a value is not an integer\n", "def cube_odd(arr):\n r = 0\n for a in arr:\n if type(a) != int: return None\n if a % 2 != 0: r += a**3\n return r", "def cube_odd(arr):\n if all(isinstance(x, int) for x in arr) \\\n and not any(isinstance(x,bool) for x in arr):\n return sum([x ** 3 for x in arr if x % 2 ])\n else:\n return None", "def cube_odd(arr):\n arr1 = []\n result = 0\n try:\n for i in arr:\n if type(i) == bool:\n return None\n else:\n if i % 2 != 0:\n result = i**3\n arr1.append(result)\n return sum(arr1) \n except TypeError:\n return None\n", "def cube_odd(arr):\n arr_cubed =[]\n sum=0\n for element in arr:\n \n if not str(element).isdigit() and not str(element)[0]=='-':\n return None\n else:\n arr_cubed.append(element**3)\n for element in arr_cubed:\n if not element%2==0:\n sum +=element\n return sum\n #your code here - return None if at least a value is not an integer\n", "def cube_odd(arr):\n s=0\n arr1=[]\n for i in arr:\n if (type(i)==str or type(i)==bool):\n return None\n break\n else:\n arr1.append(i)\n for i in range(len(arr1)):\n if (arr1[i]%2==1):\n s+=arr1[i]**3\n return s"] | {"fn_name": "cube_odd", "inputs": [[[1, 2, 3, 4]], [[-3, -2, 2, 3]], [["a", 12, 9, "z", 42]], [[true, false, 2, 4, 1]]], "outputs": [[28], [0], [null], [null]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 20,942 |
def cube_odd(arr):
|
dbda2f128a8c89e9ca664b306074e4d5 | UNKNOWN | # Scenario
With **_Cereal crops_** like wheat or rice, before we can eat the grain kernel, we need to remove that inedible hull, or *to separate the wheat from the chaff*.
___
# Task
**_Given_** a *sequence of n integers* , **_separate_** *the negative numbers (chaff) from positive ones (wheat).*
___
# Notes
* **_Sequence size_** is _at least_ **_3_**
* **_Return_** *a new sequence*, such that **_negative numbers (chaff) come first, then positive ones (wheat)_**.
* In Java , *you're not allowed to modify the input Array/list/Vector*
* **_Have no fear_** , *it is guaranteed that there will be no zeroes* .
* **_Repetition_** of numbers in *the input sequence could occur* , so **_duplications are included when separating_**.
* If a misplaced *positive* number is found in the front part of the sequence, replace it with the last misplaced negative number (the one found near the end of the input). The second misplaced positive number should be swapped with the second last misplaced negative number. *Negative numbers found at the head (begining) of the sequence* , **_should be kept in place_** .
____
# Input >> Output Examples:
```
wheatFromChaff ({7, -8, 1 ,-2}) ==> return ({-2, -8, 1, 7})
```
## **_Explanation_**:
* **_Since_** `7 ` is a **_positive number_** , it should not be located at the beginnig so it needs to be swapped with the **last negative number** `-2`.
____
```
wheatFromChaff ({-31, -5, 11 , -42, -22, -46, -4, -28 }) ==> return ({-31, -5,- 28, -42, -22, -46 , -4, 11})
```
## **_Explanation_**:
* **_Since_**, `{-31, -5} ` are **_negative numbers_** *found at the head (begining) of the sequence* , *so we keep them in place* .
* Since `11` is a positive number, it's replaced by the last negative which is `-28` , and so on till sepration is complete.
____
```
wheatFromChaff ({-25, -48, -29, -25, 1, 49, -32, -19, -46, 1}) ==> return ({-25, -48, -29, -25, -46, -19, -32, 49, 1, 1})
```
## **_Explanation_**:
* **_Since_** `{-25, -48, -29, -25} ` are **_negative numbers_** *found at the head (begining) of the input* , *so we keep them in place* .
* Since `1` is a positive number, it's replaced by the last negative which is `-46` , and so on till sepration is complete.
* Remeber, *duplications are included when separating* , that's why the number `1` appeared twice at the end of the output.
____
# Tune Your Code , There are 250 Assertions , 100.000 element For Each .
# Only O(N) Complexity Solutions Will pass .
____ | ["def wheat_from_chaff(values):\n i, j = 0, len(values)-1\n while True:\n while i < j and values[i] < 0: i += 1\n while i < j and values[j] > 0: j -= 1\n if i >= j: return values\n values[i], values[j] = values[j], values[i]", "def wheat_from_chaff(values):\n i, j = 0, len(values) - 1\n vals = values[:]\n while i < j:\n if vals[i] < 0:\n i += 1\n elif vals[j] > 0:\n j -= 1\n else:\n vals[i], vals[j] = vals[j], vals[i]\n i, j = i + 1, j - 1\n return vals", "from typing import List\n\n\ndef wheat_from_chaff(values: List[int]) -> List[int]:\n i, latest_neg = 0, len(values)\n\n while i < latest_neg:\n if values[i] > 0:\n try:\n latest_neg = next(j for j in range(latest_neg - 1, i, -1) if values[j] < 0)\n except StopIteration:\n break\n values[i], values[latest_neg] = values[latest_neg], values[i]\n i += 1\n return values\n", "def wheat_from_chaff(a):\n r, i, l = [[i, j] for i, j in enumerate(a) if j < 0], 0, len(a)\n for i in range(len(a)):\n if a[i] > 0:\n if not r : break\n r_ = r.pop()\n if r_[0] < i : break\n a[i], a[r_[0]] = r_[1], a[i]\n return a", "def wheat_from_chaff(values):\n i, j = 0, len(values) - 1\n while i < j:\n a, b = values[i], values[j]\n if a > 0 and b < 0:\n values[i], values[j] = values[j], values[i]\n elif b > 0:\n j -= 1\n else:\n i += 1\n return values", "def wheat_from_chaff(values):\n values = values[:]\n i, j = 0, len(values)-1\n while i < j:\n while values[i] < 0:\n i += 1\n while values[j] > 0:\n j -= 1\n if i < j:\n values[i], values[j] = values[j], values[i]\n return values", "def wheat_from_chaff(values):\n end = len(values) - 1\n for start, n in enumerate(values):\n if start >= end: break\n if n > 0:\n while start < end and values[end] > 0: end -= 1\n values[start], values[end] = values[end], values[start]\n return values", "def wheat_from_chaff(values):\n results = values[:]\n head = 0\n tail = len(values) - 1\n while True:\n while results[head] <= 0 and head < tail:\n head += 1\n while results[tail] > 0 and tail > head:\n tail -= 1\n if head >= tail:\n break\n results[head], results[tail] = results[tail], results[head]\n return results", "def wheat_from_chaff(values):\n last_index=len(values)-1\n for i in range(0, len(values)):\n if values[i] > 0:\n negative_index = None\n negative_value = None\n for ii in range(last_index, -1, -1):\n if values[ii] < 0:\n last_index = ii\n negative_index = ii\n negative_value = values[ii]\n break\n if(negative_index == None):\n break\n elif(negative_index > i):\n values[i], values[ii] = values[ii], values[i]\n else:\n break\n return values \n \n \n \n", "def wheat_from_chaff(values):\n negative = []\n positive = []\n while len(values) > 0:\n if values[0] < 0:\n negative.append(values.pop(0))\n elif values[-1] > 0:\n positive.append(values.pop(-1))\n else:\n positive.append(values.pop(0))\n negative.append(values.pop(-1))\n return negative+positive[::-1]\n"] | {"fn_name": "wheat_from_chaff", "inputs": [[[2, -4, 6, -6]], [[7, -3, -10]], [[7, -8, 1, -2]], [[8, 10, -6, -7, 9]], [[-3, 4, -10, 2, -6]], [[2, -6, -4, 1, -8, -2]], [[16, 25, -48, -47, -37, 41, -2]], [[-30, -11, 36, 38, 34, -5, -50]], [[-31, -5, 11, -42, -22, -46, -4, -28]], [[46, 39, -45, -2, -5, -6, -17, -32, 17]], [[-9, -8, -6, -46, 1, -19, 44]], [[-37, -10, -42, 19, -31, -40, -45, 33]], [[-25, -48, -29, -25, 1, 49, -32, -19, -46, 1]], [[-7, -35, -46, -22, 46, 43, -44, -14, 34, -5, -26]], [[-46, -50, -28, -45, -27, -40, 10, 35, 34, 47, -46, -24]], [[-33, -14, 16, 31, 4, 41, -10, -3, -21, -12, -45, 41, -19]], [[-17, 7, -12, 10, 4, -8, -19, -24, 40, 31, -29, 21, -45, 1]], [[-16, 44, -7, -31, 9, -43, -44, -18, 50, 39, -46, -24, 3, -34, -27]]], "outputs": [[[-6, -4, 6, 2]], [[-10, -3, 7]], [[-2, -8, 1, 7]], [[-7, -6, 10, 8, 9]], [[-3, -6, -10, 2, 4]], [[-2, -6, -4, -8, 1, 2]], [[-2, -37, -48, -47, 25, 41, 16]], [[-30, -11, -50, -5, 34, 38, 36]], [[-31, -5, -28, -42, -22, -46, -4, 11]], [[-32, -17, -45, -2, -5, -6, 39, 46, 17]], [[-9, -8, -6, -46, -19, 1, 44]], [[-37, -10, -42, -45, -31, -40, 19, 33]], [[-25, -48, -29, -25, -46, -19, -32, 49, 1, 1]], [[-7, -35, -46, -22, -26, -5, -44, -14, 34, 43, 46]], [[-46, -50, -28, -45, -27, -40, -24, -46, 34, 47, 35, 10]], [[-33, -14, -19, -45, -12, -21, -10, -3, 41, 4, 31, 41, 16]], [[-17, -45, -12, -29, -24, -8, -19, 4, 40, 31, 10, 21, 7, 1]], [[-16, -27, -7, -31, -34, -43, -44, -18, -24, -46, 39, 50, 3, 9, 44]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,681 |
def wheat_from_chaff(values):
|
d585f0251e4c401a80ec53d0623839d8 | UNKNOWN | The "Russian Peasant Method" is an old algorithm used by Russian peasants (and before them ancient Egyptians) to perform multiplication. Consider that X and Y are two numbers. X can be any number but Y must be a positive integer. To multiply X and Y:
1. Let the product = 0
2. If Y is odd, then the product = product + X
3. X = X + X
4. Y = integer part of Y / 2
5. if Y is nonzero, repeat from step 2; otherwise the algorithm terminates and returns the product.
For example:
Let X = 10
Let Y = 5
X: 10 20 40 80
Y: 5 2 1 0
product = 10 + 40 = 50
Note: usage of multiplication is of course forbidden... | ["def russian_peasant_multiplication(x, y):\n product = 0\n while y != 0:\n if y % 2 == 1:\n product += x\n x += x\n y //= 2\n \n return product", "def russian_peasant_multiplication(x, y, product=0):\n product += x if y % 2 else 0\n x += x\n y //= 2\n if y:\n product = russian_peasant_multiplication(x, y, product)\n return product", "# Don't tell me what to do\nrussian_peasant_multiplication = getattr(__import__(\"operator\"), \"__mu\" + \"l__\")", "def russian_peasant_multiplication(x, y):\n answer = 0\n while y:\n if y % 2:\n answer += x\n x += x\n y //= 2\n return answer", "def russian_peasant_multiplication(x, y):\n p = 0\n while y:\n p, x, y = p + (x if y % 2 else 0), x + x, y // 2\n return p", "russian_peasant_multiplication = lambda x, y, p = 0: p if y == 0 else russian_peasant_multiplication(x + x, y // 2, p if y % 2 == 0 else p + x)", "def russian_peasant_multiplication(x, y):\n return eval('x.__mu' + 'l__(y)')", "def russian_peasant_multiplication(x,y):\n prod=0\n while y:\n if y%2:prod+=x\n x+=x\n y=y//2\n return prod", "def russian_peasant_multiplication(x, y):\n if x==1.001 and y==2:\n return 2.002\n sign = '-' if x < 0 else '+'\n x, y = abs(x), abs(y)\n tot = 0\n while x != 1:\n if x % 2:\n tot += y\n y += y\n x //= 2\n return (tot if not x % 2 else tot + y) if sign == '+' else -(tot if not x % 2 else tot + y)\n", "def russian_peasant_multiplication(x, y):\n pro = 0\n while y != 0:\n if y % 2:\n pro += x\n x += x\n y //= 2\n return pro\n"] | {"fn_name": "russian_peasant_multiplication", "inputs": [[10, 5], [1.001, 2], [175, 18], [-2, 2], [2500, 123]], "outputs": [[50], [2.002], [3150], [-4], [307500]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,736 |
def russian_peasant_multiplication(x, y):
|
b7e25db3f509c1c2f26677e40a41d047 | UNKNOWN | Given a string and an array of index numbers, return the characters of the string rearranged to be in the order specified by the accompanying array.
Ex:
scramble('abcd', [0,3,1,2]) -> 'acdb'
The string that you will be returning back will have: 'a' at index 0, 'b' at index 3, 'c' at index 1, 'd' at index 2, because the order of those characters maps to their corisponding numbers in the index array.
In other words, put the first character in the string at the index described by the first element of the array
You can assume that you will be given a string and array of equal length and both containing valid characters (A-Z, a-z, or 0-9). | ["def scramble(string, array):\n return \"\".join(v for _, v in sorted(zip(array, string)))", "def scramble(string, array):\n res = array[:]\n for (i,a) in enumerate(array):\n res[a]=string[i]\n return \"\".join(res)\n", "def scramble(string, lst):\n result = [None] * len(string)\n for char, index in zip(string, lst):\n result[index] = char\n return \"\".join(result)", "def scramble(string, array):\n d = dict(list(zip(array, string)))\n return ''.join(map(d.get, list(range(len(array)))))\n", "def scramble(stg, lst):\n return \"\".join(t[1] for t in sorted(enumerate(stg), key=lambda t: lst[t[0]]))\n", "def scramble(string, array):\n return \"\".join([string[array.index(i)] for i in range(len(array))])\n", "def scramble(string, array):\n return ''.join(c for _, c in sorted(zip(array, string)))", "def scramble(string, array):\n return ''.join(v for i, v in sorted(zip(array, string)))", "def scramble(string, array):\n return \"\".join(string[array.index(x)] for x in range(len(string)))\n\n", "def scramble(a, b):\n if not a or not b:\n return ''\n if len(a) != len(b):\n return ''\n s = sorted(zip(b,a))\n a,b = map(list, zip(*s))\n return ''.join(b)"] | {"fn_name": "scramble", "inputs": [["abcd", [0, 3, 1, 2]], ["sc301s", [4, 0, 3, 1, 5, 2]], ["bskl5", [2, 1, 4, 3, 0]]], "outputs": [["acdb"], ["c0s3s1"], ["5sblk"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,244 |
def scramble(string, array):
|
ceac04708a252e6392dda4d8c8fcbf24 | UNKNOWN | Program a function `sumAverage(arr)` where `arr` is an array containing arrays full of numbers, for example:
```python
sum_average([[1, 2, 2, 1], [2, 2, 2, 1]])
```
First, determine the average of each array. Then, return the sum of all the averages.
- All numbers will be less than 100 and greater than -100.
- `arr` will contain a maximum of 50 arrays.
- After calculating all the averages, add them **all** together, **then** round down, as shown in the example below:
The example given: `sumAverage([[3, 4, 1, 3, 5, 1, 4], [21, 54, 33, 21, 77]])`, the answer being 44.
1. Calculate the average of each individual array:
```
[3, 4, 1, 3, 5, 1, 4] = (3 + 4 + 1 + 3 + 5 + 1 + 4) / 7 = 3
[21, 54, 33, 21, 77] = (21 + 54 + 33 + 21 + 77) / 5 = 41.2
```
2. Add the average of each array together:
```
3 + 41.2 = 44.2
```
3. Round the final average down:
~~~if:julia
In Julia, the `Statistics` package is preloaded.
~~~
```python
import math
math.floor(44.2) = 44
``` | ["from statistics import mean\nfrom math import floor\n\ndef sum_average(arr):\n return floor(sum(map(mean, arr)))", "from statistics import mean\nfrom math import floor\n\ndef sum_average(arr):\n return floor(sum(mean(lst) for lst in arr))", "import math\n\ndef sum_average(arr):\n return math.floor(sum([sum(array)/len(array) for array in arr]))", "from math import floor\ndef sum_average(arr):\n return floor(sum(sum_average(x)/len(x) if type(x) is list else x for x in arr))", "import math\ndef sum_average(arr):\n total = 0\n for x in arr:\n total += sum(x)/len(x)\n return math.floor(total)", "import numpy as np\n\ndef sum_average(arr):\n nm = int(sum([np.mean(arr[i]) for i in range(len(arr)) ]))\n return nm-1 if nm<0 else nm", "import numpy as np\nfrom math import floor\n\ndef sum_average(arr):\n return floor(sum(map(np.average, arr)))", "import numpy\nimport math\ndef sum_average(arr):\n print(arr)\n total = 0\n for item in arr:\n print(numpy.mean(item))\n total += numpy.mean(item)\n return math.floor(total)", "import math\n\ndef sum_average(arr):\n \n x = 0\n \n for i in range(0,len(arr)):\n \n l = len(arr[i])\n \n s = sum(arr[i])\n \n v = s/l\n \n x+= v\n \n w = math.floor(x)\n \n return w\n \n", "def avg(seq):\n sum = 0\n count = 0\n for i in seq:\n sum += i\n count += 1\n return sum/count if count != 0 else 0\n\nsum_average = lambda arr: __import__('math').floor(sum(avg(i) for i in arr))"] | {"fn_name": "sum_average", "inputs": [[[[1, 2, 2, 1], [2, 2, 2, 1]]], [[[52, 64, 84, 21, 54], [44, 87, 46, 90, 43]]], [[[44, 76, 12], [96, 12, 34, 53, 76, 34, 56, 86, 21], [34, 65, 34, 76, 34, 87, 34]]], [[[41, 16, 99, 93, 59, 18, 35, 23, 55, 45, 38, 39, 74, 60, 95, 44, 59, 70, 44, 89, 90, 19, 23, 67, 65, 66, 41, 89, 49, 22, 23, 47, 60, 12, 59, 58, 25, 69, 66, 82, 53, 41, 51, 69, 78, 18, 17, 44, 74, 96, 46, 73, 22, 37, 95, 32, 62, 49, 8, 88, 59, 66, 23, 10, 61, 28, 11, 99, 27, 98, 8, 18, 73, 18, 61, 25, 60, 38, 81, 13, 36, 63, 12, 83, 57, 11, 19, 51, 41, 20, 37, 63, 79, 94, 25, 45, 24, 73, 67, 42]]], [[[3, 4, 1, 3, 5, 1, 4], [21, 54, 33, 21, 76]]], [[[-4, 3, -8, -2], [2, 9, 1, -5], [-7, -2, -6, -4]]]], "outputs": [[3], [117], [148], [50], [44], [-6]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,586 |
def sum_average(arr):
|
5dc47a5cc04de57a9348415dc9eac3f5 | UNKNOWN | Create a function that interprets code in the esoteric language **Poohbear**
## The Language
Poohbear is a stack-based language largely inspired by Brainfuck. It has a maximum integer value of 255, and 30,000 cells. The original intention of Poohbear was to be able to send messages that would, to most, be completely indecipherable:
Poohbear Wiki
* For the purposes of this kata, you will make a version of Poohbear that has **infinite** memory cells in **both directions** (so you do not need to limit cells to 30,000)
* Cells have a default value of 0
* Each cell can hold one byte of data. Once a cell's value goes above 255, it wraps around to 0. If a cell's value goes below 0, it wraps to 255.
* If the result of an operation isn't an int, round the result down to the nearest one.
* Your interpreter should ignore any non-command characters in the code.
* If you come to a `W` in the code and the current cell is equal to 0, jump to the corresponding `E`.
* If you come to an `E` in the code and the current cell is **not** 0, jump back to the corresponding `W`.
Here are the Poohbear commands:
| Command | Definition
|---| -------------------------
| + | Add 1 to the current cell
| - | Subtract 1 from the current cell
| > | Move the cell pointer 1 space to the right
| < | Move the cell pointer 1 space to the left
| c | "Copy" the current cell
| p | Paste the "copied" cell into the current cell
| W | While loop - While the current cell is not equal to 0
| E | Closing character for loops
| P | Output the current cell's value as ascii
| N | Output the current cell's value as an integer
| T | Multiply the current cell by 2
| Q | Square the current cell
| U | Square root the current cell's value
| L | Add 2 to the current cell
| I | Subtract 2 from the current cell
| V | Divide the current cell by 2
| A | Add the copied value to the current cell's value
| B | Subtract the copied value from the current cell's value
| Y | Multiply the current cell's value by the copied value
| D | Divide the current cell's value by the copied value. | ["from operator import add, mul, floordiv as fdiv, pow\n\ndef poohbear(s):\n \n def updateMem(func, v): mem[p] = func(mem.get(p, 0), v) % 256\n\n braces, stack = {}, []\n for i,c in enumerate(s):\n if c == 'W': stack.append(i)\n if c == 'E':\n braces[i] = stack[-1]\n braces[stack.pop()] = i\n \n mem, copy, output = {}, 0, []\n p, i = 0, 0\n while i < len(s):\n cmd = s[i]\n if cmd == '>': p += 1\n elif cmd == '<': p -= 1\n elif cmd == 'p': mem[p] = copy\n elif cmd == 'c': copy = mem.get(p, 0)\n elif cmd == 'W': i = i if bool(mem.get(p, 0)) else braces[i]\n elif cmd == 'E': i = braces[i] if mem.get(p, 0) else i\n elif cmd == 'P': output.append(chr(mem.get(p, 0)))\n elif cmd == 'N': output.append(str(mem.get(p, 0)))\n elif cmd == '+': updateMem(add, 1)\n elif cmd == '-': updateMem(add, -1)\n elif cmd == 'L': updateMem(add, 2)\n elif cmd == 'I': updateMem(add, -2)\n elif cmd == 'T': updateMem(mul, 2)\n elif cmd == 'V': updateMem(fdiv, 2)\n elif cmd == 'Q': updateMem(pow, 2)\n elif cmd == 'U': updateMem(lambda a,b: int(pow(a, b)), .5)\n elif cmd == 'A': updateMem(add, copy)\n elif cmd == 'B': updateMem(add, -copy)\n elif cmd == 'Y': updateMem(mul, copy)\n elif cmd == 'D': updateMem(fdiv, copy)\n i += 1\n \n return ''.join(output)", "from collections import defaultdict\n\ndef poohbear(s):\n C, k, p, copy, r = defaultdict(int), 0, 0, 0, ''\n while p < len(s):\n if s[p] == 'W' and C[k] == 0: p = s.index('E', p) \n elif s[p] == 'E' and C[k]: p = p - s[:p][::-1].index('W') - 1\n elif s[p] == '>': k += 1\n elif s[p] == '<': k -= 1\n elif s[p] == 'P': r += chr(C[k])\n elif s[p] == 'N': r += str(C[k])\n elif s[p] == 'c': copy = C[k]\n else:\n C[k] = {'+':C[k]+1, '-':C[k]-1, 'L':C[k]+2, 'I':C[k]-2, 'V':C[k]/2, 'T':C[k]*2,\n 'A':C[k]+copy, 'B':C[k]-copy, 'Y':C[k]*copy, 'D':C[k]/max(copy, 1), 'p':copy,\n 'U':C[k]**0.5, 'Q':C[k]**2}.get(s[p], C[k])\n C[k] = int(C[k]//1) % 256\n p += 1\n return r", "import re\n\ndef poohbear(code):\n # initialize variables\n data, ptr, step, clipboard, stack, loop, output = {}, 0, 0, 0, [], {}, []\n \n # break code into valid commands\n code = re.sub('[^+-><cpWEPNTQULIVABYD]', '', code)\n \n # parse loops and store start/end\n for i, command in enumerate(code):\n if command == 'W':\n stack.append(i)\n elif command == 'E':\n start = stack.pop()\n loop[start], loop[i] = i, start\n \n # execute the code\n while step < len(code):\n data[ptr] = data.get(ptr, 0)\n \n command = code[step]\n if command == '+': data[ptr] += 1\n elif command == '-': data[ptr] -= 1\n elif command == '>': ptr += 1\n elif command == '<': ptr -= 1\n elif command == 'c': clipboard = data[ptr]\n elif command == 'p': data[ptr] = clipboard\n elif command == 'W' and data[ptr] == 0: step = loop[step]\n elif command == 'E' and data[ptr] != 0: step = loop[step]\n elif command == 'P': output.append(chr(data[ptr]))\n elif command == 'N': output.append(str(data[ptr]))\n elif command == 'T': data[ptr] *= 2\n elif command == 'Q': data[ptr] **= 2\n elif command == 'U': data[ptr] = int(data[ptr] ** 0.5)\n elif command == 'L': data[ptr] += 2\n elif command == 'I': data[ptr] -= 2\n elif command == 'V': data[ptr] //= 2\n elif command == 'A': data[ptr] += clipboard\n elif command == 'B': data[ptr] -= clipboard\n elif command == 'Y': data[ptr] *= clipboard\n elif command == 'D': data[ptr] //= clipboard\n \n if ptr in data: data[ptr] %= 256\n step += 1\n\n return ''.join(output)\n", "from collections import defaultdict\n\ndef poohbear(code):\n out, jumps, mem = [], {}, defaultdict(int)\n\n for i, c in enumerate(code):\n if c == 'W': out.append(i)\n elif c == 'E': j = out.pop(); jumps[j], jumps[i] = i, j\n\n idx, ptr, c, n = 0, 0, 0, len(code)\n\n while idx < n:\n cmd = code[idx]\n\n if cmd == '>': ptr += 1\n elif cmd == '<': ptr -= 1\n elif cmd == '+': mem[ptr] += 1\n elif cmd == '-': mem[ptr] -= 1\n elif cmd == 'L': mem[ptr] += 2\n elif cmd == 'I': mem[ptr] -= 2\n elif cmd == 'T': mem[ptr] *= 2\n elif cmd == 'V': mem[ptr] //= 2\n elif cmd == 'Q': mem[ptr] **= 2\n elif cmd == 'U': mem[ptr] **= .5\n elif cmd == 'p': mem[ptr] = c\n elif cmd == 'A': mem[ptr] += c\n elif cmd == 'B': mem[ptr] -= c\n elif cmd == 'Y': mem[ptr] *= c\n elif cmd == 'D': mem[ptr] //= c\n elif cmd == 'c': c = mem[ptr]\n elif cmd == 'P': out.append(chr(mem[ptr]))\n elif cmd == 'N': out.append(str(mem[ptr])) \n elif cmd == 'W' and not mem[ptr] or cmd == 'E' and mem[ptr]: idx = jumps[idx]\n\n mem[ptr] = round(mem[ptr]) % 256\n idx += 1\n return ''.join(out)", "import re\n\nclass memory(dict):\n def __init__(self, default):\n super().__init__()\n self._def = default\n def __getitem__(self, key): return self.get(key, self._def)\n\ndef poohbear(code):\n code, output = list(re.sub(r'[^+-><cpWEPNTQULIVABYD]', '', code)), []\n data, p, = memory(0), 0\n loop, ind, ins = [], 0, None\n copy_ = 0\n while ind < len(code):\n ins = code[ind]\n if ins == '+': data[p] = (data[p] + 1) % 256\n elif ins == '-': data[p] = (data[p] - 1) % 256\n elif ins == '<': p -= 1\n elif ins == '>': p += 1\n elif ins == 'c': copy_ = data[p]\n elif ins == 'p': data[p] = copy_\n elif ins == 'W':\n if data[p]: loop.append(ind)\n else:\n depth = 1\n while depth > 0:\n ind += 1\n c = code[ind]\n if c == 'W': depth += 1\n elif c== 'E': depth -= 1 \n elif ins == 'E':\n if data[p]: ind = loop[-1]\n else: loop.pop()\n elif ins == 'P': output.append(chr(data[p]))\n elif ins == 'N': output.append(str(data[p]))\n elif ins == 'T': data[p] = (data[p] * 2) % 256\n elif ins == 'Q': data[p] = (data[p] ** 2) % 256\n elif ins == 'U': data[p] = int(data[p] ** 0.5) % 256\n elif ins == 'L': data[p] = (data[p] + 2) % 256\n elif ins == 'I': data[p] = (data[p] - 2) % 256\n elif ins == 'V': data[p] = (data[p] // 2) % 256\n elif ins == 'A': data[p] = (data[p] + copy_) % 256\n elif ins == 'B': data[p] = (data[p] - copy_) % 256\n elif ins == 'Y': data[p] = (data[p] * copy_) % 256\n elif ins == 'D': data[p] = (data[p] // copy_) % 256\n ind += 1\n return ''.join(output)", "def poohbear(s):\n st=[]\n loops=[]\n for i,c in enumerate(s):\n if c=='W':\n st.append(i)\n elif c=='E':\n loops.append((st.pop(),i))\n cells=[0]\n p=0\n m=0\n i=0\n output=''\n while(i<len(s)):\n c=s[i]\n if c=='+':\n cells[p]=(cells[p]+1)%256\n elif c=='-':\n cells[p]=(cells[p]-1)%256\n elif c=='>':\n p+=1\n if p==len(cells):\n cells.append(0)\n elif c=='<':\n if p==0:\n cells.insert(0,0)\n else:\n p-=1\n elif c=='c':\n m=cells[p]\n elif c=='p':\n cells[p]=m\n elif c=='W':\n if cells[p]==0:\n for w,e in loops:\n if i==w:\n i=e\n break\n elif c=='E':\n if cells[p]!=0:\n for w,e in loops:\n if i==e:\n i=w\n break\n elif c=='P':\n output+=chr(cells[p])\n elif c=='N':\n output+=str(cells[p])\n elif c=='T':\n cells[p]=(cells[p]*2)%256\n elif c=='Q':\n cells[p]=(cells[p]**2)%256\n elif c=='U':\n cells[p]=(int(cells[p]**0.5))%256\n elif c=='L':\n cells[p]=(cells[p]+2)%256\n elif c=='I':\n cells[p]=(cells[p]-2)%256\n elif c=='V':\n cells[p]=(cells[p]//2)%256\n elif c=='A':\n cells[p]=(cells[p]+m)%256\n elif c=='B':\n cells[p]=(cells[p]-m)%256\n elif c=='Y':\n cells[p]=(cells[p]*m)%256\n elif c=='D':\n cells[p]=(cells[p]//m)%256\n i+=1\n return output", "def Find(code, position):\n s = code[position]\n count = 0\n op = lambda x: 'E' if x == 'W' else 'W'\n step = 1 if s == 'W' else -1\n limit = len(code) if s == 'W' else -1\n for i in range(position, limit, step):\n if code[i] == s:\n count -= 1\n elif code[i] == op(s):\n count += 1\n if count == 0 and code[i] == op(s):\n return i\n\ndef poohbear(code):\n mem = [0]*100; buf = 0\n mc,i = 0,0\n output = ''\n adjust = lambda x, y: (256 - x) if y - x < 0 else y - x\n while i < len(code):\n if code[i] == '+':\n mem[mc] = (mem[mc] + 1) % 256\n elif code[i] == '-':\n mem[mc] = adjust(1, mem[mc])\n elif code[i] == '>':\n mc += 1\n elif code[i] == '<':\n mc -= 1\n elif code[i] == 'c':\n buf = mem[mc]\n elif code[i] == 'p':\n mem[mc] = buf\n elif code[i] == 'W' and mem[mc] == 0:\n i = Find(code, i)\n elif code[i] == 'E' and mem[mc] != 0:\n i = Find(code, i)\n elif code[i] == 'P':\n output += chr(mem[mc])\n elif code[i] == 'N':\n output += str(mem[mc])\n elif code[i] == 'T':\n mem[mc] = (mem[mc]*2)%256\n elif code[i] == 'U':\n mem[mc] = round(mem[mc]**.5)\n elif code[i] == 'Q':\n mem[mc] = (mem[mc]**2)%256\n elif code[i] == 'L':\n mem[mc] = (mem[mc] + 2)%256\n elif code[i] == 'I':\n mem[mc] = adjust(2, mem[mc])\n elif code[i] == 'V':\n mem[mc] = round(mem[mc]/2)\n elif code[i] == 'A':\n mem[mc] = (buf + mem[mc])%256\n elif code[i] == 'B':\n mem[mc] = adjust(buf, mem[mc])\n elif code[i] == 'Y':\n mem[mc] = (buf*mem[mc]) % 256\n elif code[i] == 'D':\n mem[mc] = round(mem[mc] / buf)\n i += 1\n return 'Hello World!' if output == 'Hello World#' else output\n\n\n", "def poohbear(s):\n mem = [0]\n clipboard = 0\n code_pos = mem_pos = 0\n output = \"\"\n while code_pos != len(s):\n instr = s[code_pos]\n current = mem[mem_pos]\n result = None\n if instr == \"+\": result = current+1\n if instr == \"-\": result = current-1\n if instr == \">\":\n mem_pos += 1\n if mem_pos == len(mem): mem = mem+[0]\n if instr == \"<\":\n mem_pos -= 1\n if mem_pos == -1:\n mem = [0]+mem\n mem_pos = 0\n if instr == \"c\": clipboard = current\n if instr == \"p\": result = clipboard\n if instr == \"W\" and current == 0:\n depth = 1\n while depth:\n code_pos += 1\n if s[code_pos] == \"W\": depth += 1\n if s[code_pos] == \"E\": depth -= 1\n if instr == \"E\" and current != 0:\n depth = 1\n while depth:\n code_pos -= 1\n if s[code_pos] == \"E\": depth += 1\n if s[code_pos] == \"W\": depth -= 1\n if instr == \"P\": output += chr(current)\n if instr == \"N\": output += str(current)\n if instr == \"T\": result = 2*current\n if instr == \"Q\": result = current**2\n if instr == \"U\": result = int(current**.5)\n if instr == \"L\": result = current+2\n if instr == \"I\": result = current-2\n if instr == \"V\": result = current//2\n if instr == \"A\": result = current + clipboard\n if instr == \"B\": result = current - clipboard\n if instr == \"Y\": result = current * clipboard\n if instr == \"D\": result = current // clipboard\n if result is not None: mem[mem_pos] = result % 256\n code_pos += 1\n return output", "from collections import defaultdict\ndef poohbear(code):\n stack = []\n while_loop = {}\n for i,c in enumerate(code):\n if c == 'W':\n stack.append(i)\n elif c == 'E':\n while_loop[i] = stack[-1]\n while_loop[stack.pop()] = i\n\n memory = defaultdict(int)\n code_pointer = 0\n cur_m = 0\n output = []\n copied_value = None\n\n while code_pointer < len(code):\n cmd = code[code_pointer]\n if cmd == '+': memory[cur_m] = (memory[cur_m] + 1) % 256\n elif cmd == '-': memory[cur_m] = (memory[cur_m] - 1) % 256\n elif cmd == '>': cur_m += 1\n elif cmd == '<': cur_m -= 1\n elif cmd == 'c': copied_value = memory[cur_m]\n elif cmd == 'p': memory[cur_m] = copied_value # ??? NONE?\n elif cmd == 'W': code_pointer = while_loop[code_pointer] if memory[cur_m] == 0 else code_pointer\n elif cmd == 'E': code_pointer = while_loop[code_pointer] if memory[cur_m] != 0 else code_pointer\n elif cmd == 'P': output.append(chr(memory[cur_m]))\n elif cmd == 'N': output.append(str(memory[cur_m]))\n elif cmd == 'T': memory[cur_m] = (memory[cur_m] * 2) % 256\n elif cmd == 'Q': memory[cur_m] = (memory[cur_m] ** 2) % 256\n elif cmd == 'U': memory[cur_m] = int(memory[cur_m] ** 0.5)\n elif cmd == 'L': memory[cur_m] = (memory[cur_m] + 2) % 256\n elif cmd == 'I': memory[cur_m] = (memory[cur_m] - 2) % 256\n elif cmd == 'V': memory[cur_m] //= 2\n elif cmd == 'A': memory[cur_m] = (memory[cur_m] + copied_value) % 256\n elif cmd == 'B': memory[cur_m] = (memory[cur_m] - copied_value) % 256\n elif cmd == 'Y': memory[cur_m] = (memory[cur_m] * copied_value) % 256\n elif cmd == 'D': memory[cur_m] //= copied_value\n code_pointer += 1\n \n return \"\".join(output)"] | {"fn_name": "poohbear", "inputs": [["LQTcQAP>pQBBTAI-PA-PPL+P<BVPAL+T+P>PL+PBLPBP<DLLLT+P"], ["LLQT+P >LLLc+QIT-P AAAP P"], ["LLQT>+WN+<P>E"], ["cW>LQQT+P<pE"], ["+W>LQQT+P<-E"], ["+LTQII>+WN<P>+E"], ["+LTQIITTIWP-E"], ["LILcABNBpYDYYYYLLL+P-+W-EQNW-ELLQUTTTT+P"], ["++W-NE"], ["W>UQLIPNPPP45vSDFJLLIPNPqwVMT<E"], ["LLILQQLcYYD"], ["NNN++-NTTTTT+PN"], ["LQQT+P+P+P+P+P+P"], ["+-<>LcIpIL+TQYDABANPAPIIIITUNNQV+++P"], ["+c BANANA BANANA BANANA BANANA BANANA"], ["L sfdg ghjk kl LQTT++++P tt W w - E wewewe N"]], "outputs": [["Hello World!"], ["!]oo"], ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 "], [""], ["!"], ["1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 "], ["~}|{zyxwvutsrqponmlkjihgfedcba`_^]\\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#\"! \u001f\u001e\u001d\u001c\u001b\u001a\u0019\u0018\u0017\u0016\u0015\u0014\u0013\u0012\u0011\u0010\u000f\u000e\r\f\u000b\n\t\b\u0007\u0006\u0005\u0004\u0003\u0002\u0001"], ["2'0A"], ["10"], [""], [""], ["0001!33"], ["!\"#$%&"], ["38&(88#"], ["12345678910"], ["D0"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 14,860 |
def poohbear(s):
|
6f5822827272f6dacddca682a0acc763 | UNKNOWN | The Tower of Hanoi problem involves 3 towers. A number of rings decreasing in size are placed on one tower. All rings must then be moved to another tower, but at no point can a larger ring be placed on a smaller ring.
Your task: Given a number of rings, return the MINIMUM number of moves needed to move all the rings from one tower to another.
Reference: Tower of Hanoi, Courtesy of Coolmath Games
NB: This problem may seem very complex, but in reality there is an amazingly simple formula to calculate the minimum number. Just Learn how to solve the problem via the above link (if you are not familiar with it), and then think hard. Your solution should be in no way extraordinarily long and complex. The Kata ranking is for figuring out the solution, but the coding skills required are minimal. | ["def tower_of_hanoi(rings):\n return 2**rings - 1", "def tower_of_hanoi(rings):\n moves = 2**rings - 1\n return moves", "def tower_of_hanoi(rings):\n answer = 1\n for i in range(rings-1):\n answer = (answer *2) +1\n return answer", "def tower_of_hanoi(r):\n return ~(-1<<r)", "def tower_of_hanoi(rings):\n return int('1' * rings, 2)", "tower_of_hanoi=lambda r: (1<<r)-1", "def tower_of_hanoi(rings):\n count = 7\n for i in range(4,rings+1):\n count = count*2 + 1\n \n return count", "def tower_of_hanoi(rings):\n def hanoi(n):\n if n==1:\n return 1\n else:\n return 2*hanoi(n-1)+1\n return hanoi(rings)\n #your code here\n", "def tower_of_hanoi(rings):\n moves = 0\n for r in range(rings):\n moves *= 2\n moves += 1\n return moves\n\n\n", "def tower_of_hanoi(rings):\n moves = 7\n r = 3\n while r < rings:\n moves = (moves * 2) + 1\n r += 1\n return moves"] | {"fn_name": "tower_of_hanoi", "inputs": [[4], [5], [10], [50]], "outputs": [[15], [31], [1023], [1125899906842623]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,006 |
def tower_of_hanoi(rings):
|
8be46c06fd9ac537471dbcbadceac9e9 | UNKNOWN | Check if it is a vowel(a, e, i, o, u,) on the ```n``` position in a string (the first argument). Don't forget about uppercase.
A few cases:
```
{
checkVowel('cat', 1) -> true // 'a' is a vowel
checkVowel('cat', 0) -> false // 'c' is not a vowel
checkVowel('cat', 4) -> false // this position doesn't exist
}
```
P.S. If n < 0, return false | ["def check_vowel(s,i):\n return 0 <= i < len(s) and s[i] in \"aieouAEIOU\"", "def check_vowel(string, position):\n return 0 <= position < len(string) and string[position].lower() in \"aeiou\"", "def check_vowel(string, position):\n if position < 0:\n return False\n try:\n return string[position].lower() in ['a', 'e', 'i', 'o', 'u']\n except IndexError:\n return False\n", "def check_vowel(s, pos):\n return 0 <= pos < len(s) and s.lower()[pos] in \"aeiou\"", "def check_vowel(string, position):\n return 0 <= position <= len(string) and string[position] in 'aeiouAEIOU'", "def check_vowel(stg, position):\n return 0 <= position < len(stg) and stg[position].lower() in \"aeiou\"", "def check_vowel(s, i):\n return s[i].lower() in 'aeiou' if len(s) > i > -1 else False", "def check_vowel(string, position):\n string = string + ' '\n vowles = ['a', 'e', 'i', 'o', 'u','A', 'E', 'I', 'O', 'U']\n if string[position] in vowles:\n return True\n else:\n return False\n", "def check_vowel(string, position):\n if position <0 or position >len(string): return False\n return string[position].lower() in \"aeiou\"", "def check_vowel(s,t):\n if t==0 and s[t] in 'aioueAEIOU':\n return True\n return True if t>0 and t<len(s) and s[t] in 'aioueAEIOU' else False\n pass"] | {"fn_name": "check_vowel", "inputs": [["cat", 1], ["cat", 0], ["cat", 4], ["Amanda", -2], ["Amanda", 0], ["Amanda", 2]], "outputs": [[true], [false], [false], [false], [true], [true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,364 |
def check_vowel(string, position):
|
18fcec2f8ec1520475c0303cf11ed342 | UNKNOWN | We are given a sequence of coplanar points and see all the possible triangles that may be generated which all combinations of three points.
We have the following list of points with the cartesian coordinates of each one:
```
Points [x, y]
A [1, 2]
B [3, 3]
C [4, 1]
D [1, 1]
E [4, -1]
```
With these points we may have the following triangles: ```ABC, ABD, ABE, ACD, ACE, ADE, BCD, BCE, BDE, CDE.``` There are three special ones: ```ABC, ACD and CDE```, that have an angle of 90°. All is shown in the picture below:
We need to count all the rectangle triangles that may be formed by a given list of points.
The case decribed above will be:
```python
count_rect_triang([[1, 2],[3, 3],[4, 1],[1, 1],[4, -1]]) == 3
```
Observe this case:
```python
count_rect_triang([[1, 2],[4, -1],[3, 3],[4, -1],[4, 1],[1, 1],[4, -1], [4, -1], [3, 3], [1, 2]]) == 3
```
If no rectangle triangles may be generated the function will output ```0```.
Enjoy it! | ["from itertools import combinations\n\n\ndef isRect(a,b,c):\n X,Y,Z = sorted( sum( (q-p)**2 for p,q in zip(p1,p2)) for p1,p2 in [(a,b), (a,c), (b,c)] )\n return X+Y == Z\n\ndef count_rect_triang(points):\n return sum( isRect(*c) for c in combinations(set(map(tuple, points)), 3) )", "from itertools import combinations\n\ndef count_rect_triang(points):\n result = 0\n for (x1,y1),(x2,y2),(x3,y3) in combinations(set(map(tuple, points)), 3):\n d1 = (x1 - x2)**2 + (y1 - y2)**2\n d2 = (x2 - x3)**2 + (y2 - y3)**2\n d3 = (x3 - x1)**2 + (y3 - y1)**2\n d1, d2, d3 = sorted((d1, d2, d3))\n result += (d1 + d2 == d3)\n return result", "from itertools import combinations\n\ndef ok(a, b, c):\n (x1,y1),(x2,y2),(x3,y3) = a,b,c\n d1,d2,d3 = (x1-x2)**2+(y1-y2)**2, (x1-x3)**2+(y1-y3)**2, (x2-x3)**2+(y2-y3)**2\n d1,d2,d3 = sorted([d1,d2,d3])\n return d1+d2 == d3\n \ndef count_rect_triang(points):\n return sum(ok(pa, pb, pc) for pa, pb, pc in combinations(set(map(tuple, points)), 3))", "f=lambda t,r=2:[sorted,iter][r-2](abs(sum(p)-2*p[-1])**2for p in map([list,f][r-2],__import__('itertools').combinations(t, r)))\ncount_rect_triang=lambda p:sum(d<1e-9for d in f({x + 1j*y for x,y in p}, 3))", "from itertools import combinations\n\ndef count_rect_triang(points):\n return sum(1\n for ps in combinations(set(map(tuple, points)), 3)\n for p0, p1, p2 in ((ps[0], ps[1], ps[2]), (ps[1], ps[2], ps[0]), (ps[2], ps[1], ps[0]))\n if (p1[0]-p0[0])*(p2[0]-p0[0]) + (p1[1]-p0[1])*(p2[1]-p0[1]) == 0)", "from itertools import product\n\ndef count_rect_triang(points):\n return sum(1\n for p0, p1, p2 in product(set(map(tuple, points)), repeat=3)\n if p0 != p1 != p2 != p0 and (p1[0]-p0[0])*(p2[0]-p0[0]) + (p1[1]-p0[1])*(p2[1]-p0[1]) == 0\n ) // 2", "def dist(ps):\n p1, p2, p3 = ps\n x = (p1[0]-p2[0])**2+(p1[1]-p2[1])**2\n y = (p1[0]-p3[0])**2+(p1[1]-p3[1])**2\n z = (p2[0]-p3[0])**2+(p2[1]-p3[1])**2\n return sorted([x, y, z])\n\nfrom itertools import combinations\ndef count_rect_triang(points):\n if len(points) < 3:\n return 0\n ps = []\n for i in points:\n if i not in ps:\n ps.append(i)\n c = 0\n for i in combinations(ps, 3):\n temp = dist(i)\n if round(temp[-1], 4) == round(temp[0]+temp[1], 4):\n c += 1\n return c", "from itertools import combinations\ndef count_rect_triang(points):\n n=0\n points_set=set()\n for p in points:\n points_set.add(tuple(p))\n for (x1,y1),(x2,y2),(x3,y3) in combinations(points_set,3):\n l1,l2,l3=sorted([(x2-x1)**2+(y2-y1)**2,(x3-x2)**2+(y3-y2)**2,(x1-x3)**2+(y1-y3)**2])\n if l1+l2==l3:\n n+=1\n return n", "from itertools import combinations\n\ndef count_rect_triang(points):\n ans = 0\n for c in combinations(set(map(tuple, points)), 3):\n dist = [(p[0][0] - p[1][0])**2 + (p[0][1] - p[1][1])**2 for p in combinations(c, 2)]\n ans += sum(dist) == max(dist) * 2\n return ans"] | {"fn_name": "count_rect_triang", "inputs": [[[[1, 2], [3, 3], [4, 1], [1, 1], [4, -1]]], [[[1, 2], [4, -1], [3, 3], [4, -1], [4, 1], [1, 1], [4, -1], [4, -1], [3, 3], [1, 2]]]], "outputs": [[3], [3]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,076 |
def count_rect_triang(points):
|
66143dd39ccd47e4f3ec466c089268a2 | UNKNOWN | Given: an array containing hashes of names
Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.
Example:
``` ruby
list([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ])
# returns 'Bart, Lisa & Maggie'
list([ {name: 'Bart'}, {name: 'Lisa'} ])
# returns 'Bart & Lisa'
list([ {name: 'Bart'} ])
# returns 'Bart'
list([])
# returns ''
```
``` elixir
list([ %{name: "Bart"}, %{name: "Lisa"}, %{name: "Maggie"} ])
# returns 'Bart, Lisa & Maggie'
list([ %{name: "Bart"}, %{name: "Lisa"} ])
# returns 'Bart & Lisa'
list([ %{name: "Bart"} ])
# returns 'Bart'
list([])
# returns ''
```
``` javascript
list([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ])
// returns 'Bart, Lisa & Maggie'
list([ {name: 'Bart'}, {name: 'Lisa'} ])
// returns 'Bart & Lisa'
list([ {name: 'Bart'} ])
// returns 'Bart'
list([])
// returns ''
```
```python
namelist([ {'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Maggie'} ])
# returns 'Bart, Lisa & Maggie'
namelist([ {'name': 'Bart'}, {'name': 'Lisa'} ])
# returns 'Bart & Lisa'
namelist([ {'name': 'Bart'} ])
# returns 'Bart'
namelist([])
# returns ''
```
Note: all the hashes are pre-validated and will only contain A-Z, a-z, '-' and '.'. | ["def namelist(names):\n if len(names) > 1:\n return '{} & {}'.format(', '.join(name['name'] for name in names[:-1]), \n names[-1]['name'])\n elif names:\n return names[0]['name']\n else:\n return ''", "def namelist(names):\n if len(names)==0: return ''\n if len(names)==1: return names[0]['name']\n return ', '.join([n['name'] for n in names[:-1]]) + ' & ' + names[-1]['name']", "def namelist(names):\n return \", \".join([name[\"name\"] for name in names])[::-1].replace(\",\", \"& \",1)[::-1]\n", "def namelist(names):\n\n names = [ hash[\"name\"] for hash in names ]\n output = names[:-2]\n output.append(\" & \".join(names[-2:]))\n return \", \".join(output)", "def namelist(names):\n nameList = [elem['name'] for elem in names]\n return ' & '.join(', '.join(nameList).rsplit(', ', 1))\n", "def namelist(names):\n l = []\n if len(names) == 0:\n return ''\n else:\n for name in names:\n l.append(''.join(list(name.values())))\n str = ', '\n if len(l) == 1:\n return l[0]\n else:\n return str.join(l[:-1]) + ' & ' + l[-1]\n", "namelist=lambda a:' & '.join(', '.join(d['name']for d in a).rsplit(', ',1))", "def namelist(names):\n return \" \".join([names[i][\"name\"] + (\" &\" if i == len(names)-2 else \"\" if i==len(names)-1 else \",\") for i in range(len(names))])", "def namelist(names):\n names_lst = []\n for i in range(len(names)):\n names_lst.append(names[i]['name'])\n names_str = ''\n for i in range(len(names_lst)):\n names_str += names_lst[i]\n if i < len(names_lst) - 2:\n names_str += ', '\n elif i == len(names_lst) - 2:\n names_str += ' & '\n return names_str", "def namelist(names):\n return \", \".join(person[\"name\"] for person in (names if len(names)<2 else names[:-1])) + (\" & \" + names[-1][\"name\"] if len(names)>1 else \"\")"] | {"fn_name": "namelist", "inputs": [[[{"name": "Bart"}, {"name": "Lisa"}, {"name": "Maggie"}, {"name": "Homer"}, {"name": "Marge"}]], [[{"name": "Bart"}, {"name": "Lisa"}, {"name": "Maggie"}]], [[{"name": "Bart"}, {"name": "Lisa"}]], [[{"name": "Bart"}]], [[]]], "outputs": [["Bart, Lisa, Maggie, Homer & Marge"], ["Bart, Lisa & Maggie"], ["Bart & Lisa"], ["Bart"], [""]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,994 |
def namelist(names):
|
1976333b1af9eaf38be3e122b8492ec1 | UNKNOWN | In this Kata, you will be given an array and your task will be to determine if an array is in ascending or descending order and if it is rotated or not.
Consider the array `[1,2,3,4,5,7,12]`. This array is sorted in `Ascending` order. If we rotate this array once to the left, we get `[12,1,2,3,4,5,7]` and twice-rotated we get `[7,12,1,2,3,4,5]`. These two rotated arrays are in `Rotated Ascending` order.
Similarly, the array `[9,6,5,3,1]` is in `Descending` order, but we can rotate it to get an array in `Rotated Descending` order: `[1,9,6,5,3]` or `[3,1,9,6,5]` etc.
Arrays will never be unsorted, except for those that are rotated as shown above. Arrays will always have an answer, as shown in the examples below.
More examples:
```Haskell
solve([1,2,3,4,5,7]) = "A" -- Ascending
solve([7,1,2,3,4,5]) = "RA" -- Rotated ascending
solve([4,5,6,1,2,3]) = "RA" -- Rotated ascending
solve([9,8,7,6]) = "D" -- Descending
solve([5,9,8,7,6]) = "RD" -- Rotated Descending
```
More examples in the test cases.
Good luck! | ["def solve(lst):\n a, b, c = lst[0] < lst[1], lst[1] < lst[2], lst[-1] < lst[0]\n m = a if a == b else c\n return ('R' if c == m else '') + ('A' if m else 'D')", "def solve(arr):\n if sorted(arr) == arr:\n return \"A\"\n if sorted(arr)[::-1] == arr:\n return \"D\"\n return \"RA\" if arr[0] > arr[-1] else \"RD\"", "solve = lambda a:'R'*([min(a),max(a)]!=sorted(a[0::len(a)-1])) + ['D','A'][a[-1]-a[-2]>0]", "def solve(arr):\n print(arr)\n if arr==sorted(arr):\n return 'A'\n if arr==sorted(arr,reverse=True):\n return 'D' \n if arr!=sorted(arr) and arr[-2]>arr[-1]:\n return 'RD'\n if arr!=sorted(arr) and arr[-2]<arr[-1]:\n return 'RA'\n\n\n \n", "def solve(arr):\n if arr == sorted(arr):\n return \"A\"\n elif arr == sorted(arr, reverse=True):\n return \"D\"\n elif arr[0]>arr[-1]:\n return \"RA\"\n else:\n return \"RD\"", "def solve(arr):\n if arr[-1] > arr[-2]:\n if sorted(arr) == arr:\n return \"A\"\n else:\n return \"RA\"\n elif arr[-1] < arr[-2]:\n if sorted(arr)[::-1] == arr:\n return \"D\"\n else:\n return \"RD\"\n", "from collections import Counter\n\ndef solve(a):\n c = Counter( (b>a)-(b<a) for a,b in zip(a, a[1:]) )\n return 'R'*(len(c)-1) + 'DA'[ (max(c, key=c.__getitem__)+1)//2 \n if len(c) == 1 or len(set(c.values())) != 1 \n else a[0] > a[-1] ]", "def solve(a):\n c = sum((b>a)-(b<a) + 1j*(b-a) for a,b in zip(a, a[1:]))\n return 'R'*(len(a)-abs(c.real)!= 1) + 'DA'[c.real>0 if c.real else c.imag<0]", "solve=lambda a:(lambda i:'R'*((a[-1]>a[0])-(a[-1]<a[0])==i)+'UDA'[i])(__import__('collections').Counter((x>y)-(x<y)for x,y in zip(a[-1:]+a,a)).most_common(1)[0][0])"] | {"fn_name": "solve", "inputs": [[[1, 2, 3, 4, 5, 7]], [[7, 1, 2, 3, 4, 5]], [[2, 3, 4, 5, 7, 12]], [[7, 12, 1, 2, 3, 4, 5]], [[4, 5, 6, 1, 2, 3]], [[9, 8, 7, 6, 5]], [[5, 9, 8, 7, 6]], [[6, 5, 9, 8, 7]], [[9, 6, 7]], [[10, 12, 11]], [[13, 10, 11]]], "outputs": [["A"], ["RA"], ["A"], ["RA"], ["RA"], ["D"], ["RD"], ["RD"], ["RA"], ["RD"], ["RA"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,870 |
def solve(arr):
|
412a52fb1e41b492f732b5fb6e5c769e | UNKNOWN | # Task
You are given a positive integer `n`. We intend to make some ascending sequences according to the following rules:
1. Make a sequence of length 1: [ n ]
2. Or, insert a number to the left side of the sequence. But this number can not exceed half of the first number of the sequence.
3. Follow rule 2, continue insert number to the left side of the sequence.
Your task is to count the number of all possible sequences, and return it.
If you do not understand the task, please read the rewritten version below:
You are given a positive integer `n`. Your task is to count the number of such sequences:
- It should be an ascending sequence;
- It should end with number `n`.
- Each number in the sequence should smaller or equals to the half of its right, except for the last number `n`.
- We define that a sequence containing only a number `n` is a valid ascending sequence.
# Examples
For `n = 6`, the output should be `6`.
All sequences we made are:
```
[6]
insert a number to the left:
[1,6]
[2,6]
[3,6]
continue insert number:
[1,2,6]
[1,3,6]
```
There are 6 sequences in total.
For `n = 10`, the output should be `14`.
All sequences we made are:
```
[10]
insert a number to the left:
[1,10]
[2,10]
[3,10]
[4,10]
[5,10]
continue insert number:
[1,2,10]
[1,3,10]
[1,4,10]
[2,4,10]
[1,5,10]
[2,5,10]
continue insert number:
[1,2,4,10]
[1,2,5,10]
```
There are 14 sequences in total.
# Note
- `1 <= n <= 1000`
- `3` fixed testcases
- `100` random testcases, testing for correctness of solution
- All inputs are valid.
- If my reference solution gives the wrong result in the random tests, please let me know(post an issue). | ["from functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef make_sequences(n):\n return 1 + sum(map(make_sequences, range(1, n//2+1)))", "RESULTS = [1,1,2,2,4,4,6,6,10,10,14,14,20,20,26,26,36,36,46,46,60,60,74,74,94,94,114,114,140,140,166,166,202,202,238,238,284,284,330,330,390,390,450,450,524,524,598,598,692,692,786,786,900,900,1014,1014,1154,1154,1294,1294,1460,1460,1626,1626,1828,1828,2030,2030,2268,2268,2506,2506,2790,2790,3074,3074,3404,3404,3734,3734,4124,4124,4514,4514,4964,4964,5414,5414,5938,5938,6462,6462,7060,7060,7658,7658,8350,8350,9042,9042,9828,9828,10614,10614,11514,11514,12414,12414,13428,13428,14442,14442,15596,15596,16750,16750,18044,18044,19338,19338,20798,20798,22258,22258,23884,23884,25510,25510,27338,27338,29166,29166,31196,31196,33226,33226,35494,35494,37762,37762,40268,40268,42774,42774,45564,45564,48354,48354,51428,51428,54502,54502,57906,57906,61310,61310,65044,65044,68778,68778,72902,72902,77026,77026,81540,81540,86054,86054,91018,91018,95982,95982,101396,101396,106810,106810,112748,112748,118686,118686,125148,125148,131610,131610,138670,138670,145730,145730,153388,153388,161046,161046,169396,169396,177746,177746,186788,186788,195830,195830,205658,205658,215486,215486,226100,226100,236714,236714,248228,248228,259742,259742,272156,272156,284570,284570,297998,297998,311426,311426,325868,325868,340310,340310,355906,355906,371502,371502,388252,388252,405002,405002,423046,423046,441090,441090,460428,460428,479766,479766,500564,500564,521362,521362,543620,543620,565878,565878,589762,589762,613646,613646,639156,639156,664666,664666,692004,692004,719342,719342,748508,748508,777674,777674,808870,808870,840066,840066,873292,873292,906518,906518,942012,942012,977506,977506,1015268,1015268,1053030,1053030,1093298,1093298,1133566,1133566,1176340,1176340,1219114,1219114,1264678,1264678,1310242,1310242,1358596,1358596,1406950,1406950,1458378,1458378,1509806,1509806,1564308,1564308,1618810,1618810,1676716,1676716,1734622,1734622,1795932,1795932,1857242,1857242,1922286,1922286,1987330,1987330,2056108,2056108,2124886,2124886,2197788,2197788,2270690,2270690,2347716,2347716,2424742,2424742,2506282,2506282,2587822,2587822,2673876,2673876,2759930,2759930,2850948,2850948,2941966,2941966,3037948,3037948,3133930,3133930,3235326,3235326,3336722,3336722,3443532,3443532,3550342,3550342,3663090,3663090,3775838,3775838,3894524,3894524,4013210,4013210,4138358,4138358,4263506,4263506,4395116,4395116,4526726,4526726,4665396,4665396,4804066,4804066,4949796,4949796,5095526,5095526,5248914,5248914,5402302,5402302,5563348,5563348,5724394,5724394,5893790,5893790,6063186,6063186,6240932,6240932,6418678,6418678,6605466,6605466,6792254,6792254,6988084,6988084,7183914,7183914,7389572,7389572,7595230,7595230,7810716,7810716,8026202,8026202,8252302,8252302,8478402,8478402,8715116,8715116,8951830,8951830,9200058,9200058,9448286,9448286,9708028,9708028,9967770,9967770,10239926,10239926,10512082,10512082,10796652,10796652,11081222,11081222,11379220,11379220,11677218,11677218,11988644,11988644,12300070,12300070,12625938,12625938,12951806,12951806,13292116,13292116,13632426,13632426,13988332,13988332,14344238,14344238,14715740,14715740,15087242,15087242,15475494,15475494,15863746,15863746,16268748,16268748,16673750,16673750,17096796,17096796,17519842,17519842,17960932,17960932,18402022,18402022,18862450,18862450,19322878,19322878,19802644,19802644,20282410,20282410,20782974,20782974,21283538,21283538,21804900,21804900,22326262,22326262,22869882,22869882,23413502,23413502,23979380,23979380,24545258,24545258,25135020,25135020,25724782,25724782,26338428,26338428,26952074,26952074,27591230,27591230,28230386,28230386,28895052,28895052,29559718,29559718,30251722,30251722,30943726,30943726,31663068,31663068,32382410,32382410,33130918,33130918,33879426,33879426,34657100,34657100,35434774,35434774,36243644,36243644,37052514,37052514,37892580,37892580,38732646,38732646,39605938,39605938,40479230,40479230,41385748,41385748,42292266,42292266,43234278,43234278,44176290,44176290,45153796,45153796,46131302,46131302,47146570,47146570,48161838,48161838,49214868,49214868,50267898,50267898,51361196,51361196,52454494,52454494,53588060,53588060,54721626,54721626,55897966,55897966,57074306,57074306,58293420,58293420,59512534,59512534,60777212,60777212,62041890,62041890,63352132,63352132,64662374,64662374,66020970,66020970,67379566,67379566,68786516,68786516,70193466,70193466,71651844,71651844,73110222,73110222,74620028,74620028,76129834,76129834,77694142,77694142,79258450,79258450,80877260,80877260,82496070,82496070,84172786,84172786,85849502,85849502,87584124,87584124,89318746,89318746,91114678,91114678,92910610,92910610,94767852,94767852,96625094,96625094,98547380,98547380,100469666,100469666,102456996,102456996,104444326,104444326,106500434,106500434,108556542,108556542,110681428,110681428,112806314,112806314,115004102,115004102,117201890,117201890,119472580,119472580,121743270,121743270,124090986,124090986,126438702,126438702,128863444,128863444,131288186,131288186,133794468,133794468,136300750,136300750,138888572,138888572,141476394,141476394,144150270,144150270,146824146,146824146,149584076,149584076,152344006,152344006,155194954,155194954,158045902,158045902,160987868,160987868,163929834,163929834,166967782,166967782,170005730,170005730,173139660,173139660,176273590,176273590,179508916,179508916,182744242,182744242,186080964,186080964,189417686,189417686,192861218,192861218,196304750,196304750,199855092,199855092,203405434,203405434,207068524,207068524,210731614,210731614,214507452,214507452,218283290,218283290,222177814,222177814,226072338,226072338,230085548,230085548,234098758,234098758,238237116,238237116,242375474,242375474,246638980,246638980,250902486,250902486,255297602,255297602,259692718,259692718,264219444,264219444,268746170,268746170,273411566,273411566,278076962,278076962,282881028,282881028,287685094,287685094,292634890,292634890,297584686,297584686,302680212,302680212,307775738,307775738,313024652,313024652,318273566,318273566,323675868,323675868,329078170,329078170,334641518,334641518,340204866,340204866,345929260,345929260,351653654,351653654,357547444,357547444,363441234,363441234,369504420,369504420,375567606,375567606,381808538,381808538,388049470,388049470,394468148,394468148,400886826,400886826,407492292,407492292,414097758,414097758,420890012,420890012,427682266,427682266,434670350,434670350,441658434,441658434,448842348,448842348,456026262,456026262,463415834,463415834,470805406,470805406,478400636,478400636,485995866,485995866,493806582,493806582,501617298,501617298,509643500,509643500,517669702,517669702,525922004,525922004,534174306,534174306,542652708,542652708,551131110,551131110,559846226,559846226,568561342,568561342,577513172,577513172,586465002,586465002,595665060,595665060,604865118,604865118,614313404,614313404,623761690,623761690,633469718,633469718,643177746,643177746,653145516,653145516,663113286,663113286,673353212,673353212,683593138,683593138,694105220,694105220,704617302,704617302,715413954,715413954,726210606,726210606,737291828,737291828,748373050,748373050,759752270,759752270,771131490,771131490,782808708,782808708,794485926,794485926,806474570,806474570,818463214,818463214,830763284,830763284,843063354,843063354,855689292,855689292,868315230,868315230,881267036,881267036,894218842,894218842,907510958,907510958,920803074,920803074,934435500,934435500,948067926,948067926,962056258,962056258,976044590,976044590,990388828,990388828,1004733066,1004733066,1019448806,1019448806,1034164546,1034164546,1049251788,1049251788,1064339030,1064339030,1079814524,1079814524,1095290018,1095290018,1111153764,1111153764,1127017510,1127017510,1143286258,1143286258,1159555006,1159555006,1176228756,1176228756,1192902506,1192902506,1209999302,1209999302,1227096098,1227096098,1244615940,1244615940,1262135782,1262135782,1280096714,1280096714,1298057646,1298057646,1316459668,1316459668,1334861690,1334861690,1353724140,1353724140,1372586590,1372586590,1391909468,1391909468,1411232346,1411232346,1431034990,1431034990,1450837634,1450837634,1471120044,1471120044,1491402454,1491402454,1512185428,1512185428,1532968402,1532968402,1554251940,1554251940,1575535478,1575535478,1597340378,1597340378,1619145278,1619145278,1641471540,1641471540,1663797802,1663797802,1686667684,1686667684,1709537566,1709537566,1732951068,1732951068,1756364570,1756364570,1780343950,1780343950,1804323330,1804323330,1828868588,1828868588,1853413846,1853413846,1878548866,1878548866,1903683886,1903683886,1929408668,1929408668,1955133450,1955133450,1981471878]\n\ndef make_sequences(n):\n return RESULTS[n]", "def make_sequences(n):\n a = [1]\n for i in range(1, n + 1):\n a.append(a[i - 1] if i % 2 else a[i // 2] + a[i - 1])\n return a.pop()", "m=[0]\nfor _ in range(1000): m.append(1+sum(m[j+1] for j in range(len(m)//2)))\n\ndef make_sequences(n):\n return m[n]", "f=[0,1,2,2]\nfor i in range(4,1001):\n f.append(1+sum(f[:i//2+1]))\ndef make_sequences(n):\n return f[n]", "D=[1,2]\nfor _ in'_'*1000:D+=[D[-1]+D[len(D)//2]]\nmake_sequences=lambda n:D[n//2]", "import requests\n\nurl = \"https://oeis.org/A018819/b018819.txt\"\nhtml = requests.get(url)\na =[int(i) for i in html.text.split()[1::2]]\n\ndef make_sequences(n):\n try:\n return a[n]\n\n except Exception:\n return", "from functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef make_sequences(n):\n if n<2: return n\n n&=~1\n return make_sequences(n>>1)+make_sequences(n-1)", "def make_sequences(n):\n memo_res = memo.get(n)\n if memo_res:\n return memo_res\n \n count = 1 + sum(make_sequences(x) for x in range(1, n // 2 + 1))\n memo[n] = count\n return count\n \nmemo = {}", "def make_sequences(n):\n seq = [0]\n for _ in range(1000):\n seq.append(1 + sum(seq[i + 1] for i in range(len(seq) // 2)))\n return seq[n]"] | {"fn_name": "make_sequences", "inputs": [[6], [10], [1000]], "outputs": [[6], [14], [1981471878]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 9,908 |
def make_sequences(n):
|
e3d8a929ca42750088e51f6b8fe67823 | UNKNOWN | Write a method that will search an array of strings for all strings that contain another string, ignoring capitalization. Then return an array of the found strings.
The method takes two parameters, the query string and the array of strings to search, and returns an array.
If the string isn't contained in any of the strings in the array, the method returns an array containing a single string: "Empty" (or `Nothing` in Haskell, or "None" in Python and C)
### Examples
If the string to search for is "me", and the array to search is ["home", "milk", "Mercury", "fish"], the method should return ["home", "Mercury"]. | ["def word_search(query, seq):\n return [x for x in seq if query.lower() in x.lower()] or [\"None\"]", "def word_search(query, seq):\n query = query.lower()\n result = [x for x in seq if query in x.lower()]\n return result if result else ['None']", "import re\n\ndef word_search(query, seq):\n return [w for w in seq if re.search(query, w, re.I)] or ['None']\n", "def word_search(query, seq):\n l = [ i for i in seq if query.lower() in i.lower()]\n return [l, ['None']] [ not l ]", "def word_search(query, seq):\n query = query.lower()\n return [word for word in seq if query in word.lower()] or [\"None\"]", "def word_search(q, l):\n return [w for w in l if q.lower() in w.lower()]or['None']", "def word_search(query, seq):\n query = query.lower()\n return [a for a in seq if query in a.lower()] or ['None']\n", "def word_search(query, seq):\n return [i for i in seq if query.lower() in i.lower()] or ['None']", "def word_search(query, seq):\n result = [word for word in seq if query.lower() in word.lower()]\n return result if result else ['None']", "def word_search(query, seq):\n array = []\n for x in seq:\n if query.lower() in x.lower():\n array.append(x)\n else:\n pass\n if array != []:\n return array\n else:\n array = ['None']\n return array"] | {"fn_name": "word_search", "inputs": [["ab", ["za", "ab", "abc", "zab", "zbc"]], ["aB", ["za", "ab", "abc", "zab", "zbc"]], ["ab", ["za", "aB", "Abc", "zAB", "zbc"]], ["abcd", ["za", "aB", "Abc", "zAB", "zbc"]]], "outputs": [[["ab", "abc", "zab"]], [["ab", "abc", "zab"]], [["aB", "Abc", "zAB"]], [["None"]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,368 |
def word_search(query, seq):
|
fba492a3e68e6bc657c429a923a33e88 | UNKNOWN | Given a sorted array of numbers, return the summary of its ranges.
## Examples
```python
summary_ranges([1, 2, 3, 4]) == ["1->4"]
summary_ranges([1, 1, 1, 1, 1]) == ["1"]
summary_ranges([0, 1, 2, 5, 6, 9]) == ["0->2", "5->6", "9"]
summary_ranges([0, 1, 2, 3, 3, 3, 4, 5, 6, 7]) == ["0->7"]
summary_ranges([0, 1, 2, 3, 3, 3, 4, 4, 5, 6, 7, 7, 9, 9, 10]) == ["0->7", "9->10"]
summary_ranges([-2, 0, 1, 2, 3, 3, 3, 4, 4, 5, 6, 7, 7, 9, 9, 10, 12]) == ["-2", "0->7", "9->10", "12"]
``` | ["def summary_ranges(nums):\n ret, s = [], float('-inf')\n for e, n in zip([s] + nums, nums + [-s]):\n if n - e > 1:\n ret.append(['{}', '{}->{}'][s<e].format(s,e))\n s = n\n return ret[1:]", "def summary_ranges(nums):\n if not nums:\n return []\n ranges = []\n first = nums[0]\n for current, previous in zip(nums[1:], nums[:-1]):\n if current - previous not in [0, 1]:\n ranges.append((first, previous))\n first = current\n ranges.append((first, nums[-1]))\n return [\"{}->{}\".format(a, b) if a!=b else str(a) for a, b in ranges]", "def summary_ranges(nums):\n nums.append(float(\"inf\"))\n i, result = nums[0], []\n for j, n in zip(nums, nums[1:]):\n if n - j > 1:\n result.append(str(i) if i == j else f\"{i}->{j}\")\n i = n\n return result", "def summary_ranges(nums):\n\n result, start = [], float('-inf')\n \n for a, b in zip( [start]+ nums, nums +[-start]):\n if b - a > 1:\n result.append((start, a))\n start = b\n \n return [[f'{a}', f'{a}->{b}'][b>a] for a,b in result[1:]]\n", "def summary_ranges(nums):\n l, index = [[]], 0\n for x in nums:\n if not l[index] or (l[index][-1] + 1) == x:\n l[index].append(x)\n else:\n if l[index] != [x]:\n l.append([x])\n index += 1\n return [] if not nums else [str(x[0]) if len(x)<2 else f\"{x[0]}->{x[-1]}\" for x in l]", "def summary_ranges(nums):\n def f():\n cur = []\n for x in nums:\n if not cur:\n cur = [x]\n elif x == cur[-1] + 1:\n cur[1:] = x,\n elif x != cur[-1]:\n yield cur\n cur = [x]\n if cur:\n yield cur\n return [str(xs[0]) if xs[0] == xs[-1] else f'{xs[0]}->{xs[-1]}' for xs in f()]", "def summary_ranges(nums):\n if not nums: return []\n \n r, s, l = [], nums[0], nums[0]\n for n in nums:\n if n - l > 1:\n r.append(str(s)+'->'+str(l) if s != l else str(s))\n s = n\n l = n\n r.append(str(s)+'->'+str(l) if s != l else str(s))\n return r", "def summary_ranges(a):\n a,i,li = sorted(set(a), key=a.index),0,[]\n while i < len(a):\n temp = [a[i]] ; i += 1\n while i < len(a) and temp[-1] + 1 == a[i] : temp.append(a[i]) ; i += 1\n li.append(temp)\n return [f\"{i[0]}->{i[-1]}\" if len(i) > 1 else f\"{i[0]}\" for i in li]", "def summary_ranges(nums):\n i, lst, nums = 0, [], sorted(set(nums))\n while i < len(nums):\n i,j = i+1, i\n while i < len(nums) and nums[i] == nums[i-1]+1: i+= 1\n lst.append( str(nums[j]) if j+1 == i else \"{}->{}\".format(nums[j], nums[i-1]) )\n return lst"] | {"fn_name": "summary_ranges", "inputs": [[[]], [[1, 1, 1, 1]], [[1, 2, 3, 4]], [[0, 1, 2, 5, 6, 9]], [[0, 1, 2, 3, 4, 5, 6, 7]], [[0, 1, 2, 3, 5, 6, 7]], [[0, 1, 2, 3, 4, 5, 6, 7, 9, 10]], [[-2, 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 12]], [[-3, -2, -1, 0, 2, 3]], [[-2]]], "outputs": [[[]], [["1"]], [["1->4"]], [["0->2", "5->6", "9"]], [["0->7"]], [["0->3", "5->7"]], [["0->7", "9->10"]], [["-2", "0->7", "9->10", "12"]], [["-3->0", "2->3"]], [["-2"]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,857 |
def summary_ranges(nums):
|
6305ee20aedd744c4e55ab21ef920dfb | UNKNOWN | KISS stands for Keep It Simple Stupid.
It is a design principle for keeping things simple rather than complex.
You are the boss of Joe.
Joe is submitting words to you to publish to a blog. He likes to complicate things.
Define a function that determines if Joe's work is simple or complex.
Input will be non emtpy strings with no punctuation.
It is simple if:
``` the length of each word does not exceed the amount of words in the string ```
(See example test cases)
Otherwise it is complex.
If complex:
```python
return "Keep It Simple Stupid"
```
or if it was kept simple:
```python
return "Good work Joe!"
```
Note: Random test are random and nonsensical. Here is a silly example of a random test:
```python
"jump always mostly is touchy dancing choice is pineapples mostly"
``` | ["def is_kiss(words):\n wordsL = words.split(' ')\n l = len(wordsL)\n for word in wordsL:\n if len(word) > l: return \"Keep It Simple Stupid\"\n return \"Good work Joe!\"", "def is_kiss(words):\n words = words.split(\" \")\n return \"Keep It Simple Stupid\" if any(len(word)>len(words) for word in words) else \"Good work Joe!\"", "def is_kiss(words):\n wo=words.split(' '); c=len(wo)\n for w in wo:\n if len(w)>c : return \"Keep It Simple Stupid\"\n return \"Good work Joe!\"", "def is_kiss(s):\n words = s.split()\n return 'Good work Joe!' if all(len(word) <= len(words) for word in words) else 'Keep It Simple Stupid'", "def is_kiss(words):\n return \"Keep It Simple Stupid\" if any(len(i) > len(words.split()) for i in words.split()) else \"Good work Joe!\"", "def is_kiss(words):\n return \"Keep It Simple Stupid\" if max(len(i) for i in words.split())>len(words.split()) else \"Good work Joe!\"", "def is_kiss(stg):\n words = stg.split()\n l = len(words)\n return \"Good work Joe!\" if all(len(word) <= l for word in words) else \"Keep It Simple Stupid\"", "def is_kiss(s):\n s = s.split()\n n = len(s)\n return \"Good work Joe!\" if all(len(x) <= n for x in s) else \"Keep It Simple Stupid\"", "def is_kiss(s):\n words = s.split()\n total_words = len(words)\n if all(len(a) <= total_words for a in words):\n return 'Good work Joe!'\n return 'Keep It Simple Stupid'\n", "def is_kiss(words):\n words = words.split()\n for w in words:\n if len(w) > len(words):\n return \"Keep It Simple Stupid\"\n return \"Good work Joe!\""] | {"fn_name": "is_kiss", "inputs": [["Joe had a bad day"], ["Joe had some bad days"], ["Joe is having no fun"], ["Sometimes joe cries for hours"], ["Joe is having lots of fun"], ["Joe is working hard a lot"], ["Joe listened to the noise and it was an onamonapia"], ["Joe listened to the noises and there were some onamonapias"]], "outputs": [["Good work Joe!"], ["Good work Joe!"], ["Keep It Simple Stupid"], ["Keep It Simple Stupid"], ["Good work Joe!"], ["Keep It Simple Stupid"], ["Good work Joe!"], ["Keep It Simple Stupid"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,645 |
def is_kiss(words):
|
84abaeeb2e152b98244892d163025422 | UNKNOWN | Oh no! You have stumbled upon a mysterious signal consisting of beeps of various lengths, and it is of utmost importance that you find out the secret message hidden in the beeps. There are long and short beeps, the longer ones roughly three times as long as the shorter ones. Hmm... that sounds familiar.
That's right: your job is to implement a decoder for the Morse alphabet. Rather than dealing with actual beeps, we will use a common string encoding of Morse. A long beep is represened by a dash (`-`) and a short beep by a dot (`.`). A series of long and short beeps make up a letter, and letters are separated by spaces (` `). Words are separated by double spaces.
You should implement the International Morse Alphabet. You need to support letters a-z and digits 0-9 as follows:
a .- h .... o --- u ..- 1 .---- 6 -....
b -... i .. p .--. v ...- 2 ..--- 7 --...
c -.-. j .--- q --.- w .-- 3 ...-- 8 ---..
d -.. k -.- r .-. x -..- 4 ....- 9 ----.
e . l .-.. s ... y -.-- 5 ..... 0 -----
f ..-. m -- t - z --..
g --. n -.
## Examples
.... . .-.. .-.. --- .-- --- .-. .-.. -.. → "hello world"
.---- ... - .- -. -.. ..--- -. -.. → "1st and 2nd"
```if:python
A dictionnary `TOME` is preloaded for you, with the information above to convert morse code to letters.
```
```if:javascrip
An object `TOME` is preloaded for you, with the information above to convert morse code to letters.
```
```if:ruby
A Hashmap `$dict` is preloaded for you, with the information above to convert morse code to letters.
``` | ["lm = ['.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', '.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-', '...-', '.--', '-..-', '-.--', '--..', '-----', '.----', '..---', '...--', '....-', '.....', '-....', '--...', '---..', '----.']\nll = \"abcdefghijklmnopqrstuvwxyz0123456789\"\nrepldict = {'.-': 'a', '-...': 'b'}\n\nfor i in range(2, len((ll))):\n repldict.update({lm[i]: ll[i]})\nprint(repldict)\n\ndef decode(encoded):\n if encoded ==\" \" or encoded ==\"\":\n return encoded\n words = encoded.split(\" \")\n engwords = []\n for word in words:\n engword = []\n letters = word.split(\" \")\n for letter in letters:\n engword.append(repldict.get(letter))\n engword.append(\" \")\n engwords.append(\"\".join(engword))\n r = \"\".join(engwords)\n return r[0:len(r)-1]"] | {"fn_name": "decode", "inputs": [[".... . .-.. .-.. --- .-- --- .-. .-.. -.."], [".---- ... - .- -. -.. ..--- -. -.."], [".. .- -- .- - . ... -"], [".- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. ----- .---- ..--- ...-- ....- ..... -.... --... ---.. ----."], [""]], "outputs": [["hello world"], ["1st and 2nd"], ["i am a test"], ["abcdefghijklmnopqrstuvwxyz0123456789"], [""]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 897 |
def decode(s):
|
f0246c9e3fc6dbd7b180b44822e3a9b9 | UNKNOWN | Return a new array consisting of elements which are multiple of their own index in input array (length > 1).
Some cases:
```
[22, -6, 32, 82, 9, 25] => [-6, 32, 25]
[68, -1, 1, -7, 10, 10] => [-1, 10]
[-56,-85,72,-26,-14,76,-27,72,35,-21,-67,87,0,21,59,27,-92,68] => [-85, 72, 0, 68]
``` | ["def multiple_of_index(l):\n return [l[i] for i in range(1, len(l)) if l[i] % i == 0]", "def multiple_of_index(arr):\n return [val for index, val in enumerate(arr) if index and val % index == 0]\n\n", "def multiple_of_index(arr):\n return [arr[i] for i in range(1,len(arr)) if arr[i] % i == 0]\n", "def multiple_of_index(arr):\n i = 1\n rst = []\n while i < len(arr):\n if arr[i] % i == 0:\n print(i)\n rst.append(arr[i])\n i += 1\n return rst", "def multiple_of_index(arr):\n return [n for i,n in enumerate(arr[1:], 1) if n%i==0]", "def multiple_of_index(arr):\n results = []; i = 0\n for elem in arr:\n if i > 0 and elem % i == 0:\n results.append(elem)\n i += 1\n return results", "def multiple_of_index(arr):\n return [e for i,e in enumerate(arr) if i and not e%i]\n", "def multiple_of_index(arr):\n return [x for y,x in enumerate(arr[1:], 1) if not abs(x)%y]", "def multiple_of_index(arr):\n new_arr = []\n \n for i in range(1, len(arr)):\n if (arr[i] % i == 0):\n new_arr.append(arr[i]) \n \n return new_arr \n\n \n \n \n \n \n\"\"\" new_arr = []\n for i in range(1,len(arr)):\n if (arr[i] % i == 0):\n new_arr = \n i = i + 1\n return new_arr\n\"\"\" \n \n", "def multiple_of_index(arr):\n return [arr[x] for x in range(1,len(arr)) if x == 0 or arr[x] % x == 0]", "def multiple_of_index(arr):\n return [x[1] for x in enumerate(arr) if x[0] != 0 and not x[1] % x[0]]", "def multiple_of_index(arr):\n return [x for i, x in enumerate(arr[1:], 1) if not x % i]", "def multiple_of_index(arr):\n return [x for i, x in enumerate(arr) if i and x % i == 0]", "def multiple_of_index(arr):\n return [a for i, a in enumerate(arr) if i > 0 and a % i == 0]", "def multiple_of_index(arr):\n return [v for i,v in enumerate(arr[1:]) if v%(i+1) == 0]", "def multiple_of_index(arr):\n return [elt for i, elt in enumerate(arr[1:]) if not elt % (i + 1)]", "def multiple_of_index(arr):\n vList = []\n for key, value in enumerate(arr):\n if key == 0: continue\n if value % key == 0:\n vList.append(value)\n\n return vList", "from typing import List\n\ndef multiple_of_index(arr: List[int]) -> List[int]:\n \"\"\" Get a new array consisting of elements which are multiple of their own index in input array. \"\"\"\n return list(dict(filter(lambda _it: _it[0] > 0 and (_it[1] / _it[0]).is_integer(), enumerate(arr))).values())", "def multiple_of_index(arr):\n return [v for i,v in enumerate(arr) if i > 0 and v % i == 0]", "def multiple_of_index(arr):\n ar = []\n for num in range(1,len(arr)):\n if arr[num]%num==0:\n ar.append(arr[num])\n return ar", "def multiple_of_index(arr):\n res = [arr[i] for i in range(1, len(arr)) if arr[i] % i == 0]\n return res", "def multiple_of_index(arr):\n return [x[1] for x in enumerate(arr) if x[0] and not x[1] % x[0]]", "def multiple_of_index(arr):\n return [i for idx, i in enumerate(arr) if idx and not i % idx]", "def multiple_of_index(a):\n return[v for i,v in enumerate(a) if i and v%i==0]", "multiple_of_index=lambda a:[n for i,n in enumerate(a)if i>=1>n%i]", "def multiple_of_index(arr):\n result = list()\n for i in range(1,len(arr)):\n if(arr[i]%i == 0):\n result.append(arr[i])\n return result", "def multiple_of_index(arr):\n result = []\n n = 0\n while n < len(arr):\n if n != 0 and arr[n] % n ==0:\n result.append(arr[n])\n n+=1\n \n return result", "def multiple_of_index(arr):\n res = []\n for c, a in enumerate(arr):\n # test if value is a multiple of the index\n if c != 0 and a % c == 0:\n res.append(a)\n return res", "def multiple_of_index(arr):\n oplst = []\n \n for i in range(1, len(arr)):\n if arr[i] % i == 0:\n oplst.append(arr[i])\n \n return oplst", "def multiple_of_index(arr):\n arr.pop(0)\n return list(b for a,b in list(enumerate(arr,start=1)) if b%a==0)\n", "def multiple_of_index(arr):\n nArr=[]\n for i in range(1,len(arr)):\n if arr[i]%i==0: nArr.append(arr[i])\n return nArr", "def multiple_of_index(arr):\n new = []\n i = 1\n while i < len(arr):\n if arr[i] % i == 0:\n new.append(arr[i])\n i += 1\n \n return new", "def multiple_of_index(arr):\n res = []\n for i in range(1, len(arr), 1):\n if arr[i] % i == 0:\n res.append(arr[i])\n return res", "def multiple_of_index(arr):\n output = []\n count = 0\n for num in arr:\n if count != 0:\n if not num % count:\n output.append(num)\n count += 1\n return output", "def multiple_of_index(arr):\n res = []\n for x in range(len(arr)):\n if((x != 0) and ((arr[x] % x) == 0)):\n res.append(arr[x])\n return res", "def multiple_of_index(arr):\n print(arr)\n res = []\n for x in range(len(arr)):\n if((x != 0) and ((arr[x] % x) == 0)):\n res.append(arr[x])\n return res", "def multiple_of_index(arr):\n output = []\n for index_, value in enumerate(arr):\n try: \n if value % index_ == 0:\n output.append(value)\n except ZeroDivisionError:\n continue\n return output", "def multiple_of_index(arr):\n new_arr = []\n i = 1\n for x in arr[1:]:\n if x % i == 0:\n new_arr.append(x)\n i += 1\n return new_arr", "def multiple_of_index(arr):\n return [v for k, v in enumerate(arr) if k > 0 and not(v % k)]\n", "def multiple_of_index(arr):\n lst = []\n for i in range(len(arr)):\n if i == 0:\n if arr[i] == 0:\n lst.append(arr[i])\n elif arr[i]%i == 0:\n lst.append(arr[i])\n \n return lst\n", "multiple_of_index = lambda a:[n for i, n in enumerate(a) if i and not n%i]", "def multiple_of_index(arr):\n mult = []\n for i in range(1, len(arr)):\n if arr[i]%i == 0:\n mult.append(arr[i])\n return mult", "def multiple_of_index(arr):\n res = []\n for i in range (len(arr)):\n if i > 0 and arr[i] % i == 0:\n res.append(arr[i])\n return res", "def multiple_of_index(arr):\n return [i for num, i in enumerate(arr[1:],1) if i % num == 0]\n", "def multiple_of_index(arr):\n return [arr[el] for el in range(1, len(arr)) if arr[el] % el == 0]\n", "def multiple_of_index(arr):\n return list(arr[i] for i in range(1, len(arr)) if arr[i] % i == 0)", "def multiple_of_index(arr):\n l = []\n for i, v in enumerate(arr):\n if i > 0 and v % i == 0:\n l.append(v)\n return l\n", "def multiple_of_index(arr):\n l = []\n for i in range(len(arr)):\n if i == 0:\n continue\n elif arr[i]%i==0:\n l.append(arr[i])\n return l", "def multiple_of_index(arr):\n lst = []\n for i, elem in enumerate(arr):\n try:\n if elem % int(i) == 0:\n lst.append(elem)\n except ZeroDivisionError:\n pass\n return(lst)", "def multiple_of_index(arr):\n result_arr = []\n for i in range(1, len(arr)):\n if arr[i] % i == 0:\n result_arr.append(arr[i])\n return result_arr", "def multiple_of_index(arr):\n temp=[]\n for n in range(1, len(arr)):\n if arr[n] % n == 0:\n temp.append(arr[n])\n return temp", "def multiple_of_index(arr):\n return [y for x,y in enumerate(arr[1:], start=1) if y % x == 0]", "def multiple_of_index(arr):\n new = []\n x = 1\n for i in arr[1:]:\n if i % x == 0:\n new.append(i)\n x += 1\n \n return new", "def multiple_of_index(arr):\n res = []\n \n if arr[0] == 0: res.append(0)\n \n for i in range(1, len(arr)):\n try:\n if arr[i] % i == 0:\n res.append(arr[i])\n except:\n res.append(0)\n \n return res", "def multiple_of_index(arr):\n bigboy = []\n index = 1\n for x in arr[1:]:\n if x%index == 0:\n bigboy.append(x)\n index += 1\n return bigboy", "def multiple_of_index(arr):\n result = []\n for i in range(1, len(arr)):\n if arr[i] % i == 0:\n result.append(arr[i])\n else:\n pass\n return result", "def multiple_of_index(arr):\n result = []\n \n for i in range(1, len(arr)):\n if not arr[i] % i:\n result.append(arr[i])\n \n return result", "def multiple_of_index(arr):\n return [k for i, k in enumerate(arr[1:]) if not k % (i + 1)]", "def multiple_of_index(arr):\n result = []\n for i in range(len(arr)):\n if i!=0:\n if arr[i]%i==0:\n result.append(arr[i])\n return result", "def multiple_of_index(arr):\n return [b for a, b in enumerate(arr[1:], 1) if b % a == 0]", "def multiple_of_index(arr):\n new_arr = []\n for i in range(len(arr)):\n if i == 0:\n continue\n elif arr[i]%i==0:\n new_arr.append(arr[i])\n return new_arr", "def multiple_of_index(arr):\n return [arr[i] for i in range(0 if arr[0]==0 else 1,len(arr)) if arr[i]%i==0]", "def multiple_of_index(arr):\n answer = []\n for i, a in enumerate(arr):\n if i!=0 and a%i==0:\n answer.append(a)\n return answer", "def multiple_of_index(arr):\n matches = []\n index = 1\n for value in arr[1:]:\n if value % index == 0:\n matches.append(value)\n index += 1\n return matches", "def multiple_of_index(arr):\n return [x for x in [arr[i] if arr[i]%i == 0 else None for i in range(1, len(arr))] if x is not None]", "def multiple_of_index(arr):\n return [i for loop, i in enumerate(arr[1:]) if i % (loop + 1) == 0]", "def multiple_of_index(arr: list) -> list:\n return [\n val\n for idx, val in enumerate(arr)\n if len(arr) > 1 and idx != 0\n if val % idx == 0\n ]", "def multiple_of_index(arr):\n return [i for j,i in enumerate(arr) if j != 0 and i%j == 0]", "def multiple_of_index(arr):\n ll = list()\n for i in range(1, len(arr)):\n if arr[i] % i == 0:\n ll.append(arr[i])\n return ll", "def multiple_of_index(a):\n l= []\n for i, v in enumerate(a):\n if i >= 1 and v%i == 0:\n l.append(v)\n return l\n", "def multiple_of_index(arr):\n x = []\n for idx, n in enumerate(arr):\n if idx >= 1 and n % idx == 0:\n x.append(n)\n return x", "def multiple_of_index(arr):\n returnArr = []\n for i in range(1,len(arr)): \n if arr[i] % i == 0: \n returnArr.append(arr[i])\n return returnArr", "def multiple_of_index(xs):\n return [i for idx, i in enumerate(xs[1:]) if i % (idx+1) == 0]", "# Return a new array consisting of elements \n# which are multiple of their own index in input array (length > 1).\n\n# Some cases:\n\n# [22, -6, 32, 82, 9, 25] => [-6, 32, 25]\n\n# [68, -1, 1, -7, 10, 10] => [-1, 10]\n\ndef multiple_of_index(arr):\n b=[]\n for i in range(1, len(arr)):\n if arr[i]%i == 0:\n b.append(arr[i])\n return b\n \n", "def multiple_of_index(arr):\n return [x for index, x in enumerate(arr) if index != 0 and x % index == 0]", "def multiple_of_index(arr):\n newA = []\n for i in range(1,len(arr)):\n if arr[i]%i==0:\n newA.append(arr[i]) \n return newA", "def multiple_of_index(arr):\n multiple_list = []\n for i in range(1,len(arr)):\n if arr[i] % i == 0:\n multiple_list.append(arr[i])\n return multiple_list", "def multiple_of_index(arr):\n \"\"\"\n Returns a list of elements which are multiple of their own index in 'arr'.\n \"\"\"\n return [element for index, element in enumerate(arr[1:], 1) if not element % index]", "def multiple_of_index(arr):\n return [i[1] for i in zip(list(range(1, len(arr))), arr[1:]) if i is 0 or i[1]%i[0]==0]\n", "def multiple_of_index(arr):\n return [case for i, case in enumerate(arr) if i > 0 and case % i == 0]", "def multiple_of_index(arr):\n index = 1\n res = []\n while index < len(arr):\n if arr[index] % index == 0:\n res.append(arr[index])\n index += 1\n return res", "def multiple_of_index(arr):\n print(arr)\n return [arr[i] for i in range(1, len(arr)) if not arr[i] % i ]", "def multiple_of_index(arr):\n arr2=[]\n for i in range(len(arr)):\n if i>0 and arr[i]%i==0:\n arr2.append(arr[i])\n return arr2\n pass", "def multiple_of_index(arr):\n num = 1\n ret = []\n for i in arr[1:]:\n if i % num == 0:\n ret.append(i)\n num = num + 1\n return ret", "def multiple_of_index(arr):\n ret = []\n for val in range(1,len(arr)):\n if arr[val] % (val) == 0:\n ret.append(arr[val])\n return ret\n", "def multiple_of_index(arr):\n ret = []\n for val in range(len(arr)-1):\n if arr[val+1] % (val+1) == 0:\n ret.append(arr[val+1])\n return ret\n", "def multiple_of_index(arr):\n return [arr for ind,arr in enumerate(arr) if (ind > 0) and (arr % ind == 0)]", "def multiple_of_index(arr):\n result = []\n for i, j in enumerate(arr):\n try:\n if j % i == 0:\n result.append(j)\n except:\n continue\n return result", "def multiple_of_index(arr):\n n_arr = []\n a1 = tuple(arr)\n n = 0\n m = 0\n for i in range(len(a1)):\n n = i\n m = a1[i]\n if n == 0:\n continue\n elif m % n == 0:\n n_arr.append(m)\n \n return n_arr", "def multiple_of_index(arr):\n new_list = []\n for i in range(1,len(arr)):\n if(not arr[i]%i): new_list.append(arr[i])\n return new_list\n", "def multiple_of_index(arr):\n new_array = []\n counter = 0\n for i in arr:\n if counter != 0: \n if i % counter == 0:\n new_array.append(i) \n counter += 1\n return(new_array)", "def multiple_of_index(arr):\n a=[]\n for i,elem in enumerate(arr):\n if i!=0 and elem%i==0:\n a.append(elem)\n return a", "def multiple_of_index(arr):\n listofmultiples = []\n index = 0\n for eachnumber in arr:\n if index == 0:\n index = index + 1\n elif eachnumber % index == 0:\n listofmultiples.append(eachnumber)\n index = index + 1\n else:\n index = index + 1\n return listofmultiples\n", "def multiple_of_index(arr):\n array=[]\n for x in range(1,len(arr),1):\n if arr[x] % x ==0:\n array.append(arr[x])\n return array", "def multiple_of_index(arr):\n lst = []\n for keys, values in enumerate(arr):\n if keys >= 1 and values % keys == 0:\n lst.append(values)\n return lst", "def multiple_of_index(arr):\n my_list = []\n array = arr[1:]\n for i,x in enumerate(array,1):\n if x % i == 0:\n my_list.append(x)\n return my_list\n", "def multiple_of_index(arr):\n ar = []\n for i in range(1,len(arr)):\n if arr[i] % i == 0:\n ar.append(arr[i])\n return ar ", "def multiple_of_index(arr):\n res = []\n for idx, elem in enumerate(arr):\n if idx != 0:\n if elem % idx == 0:\n res.append(elem)\n return res", "def multiple_of_index(arr):\n ls=[]\n for i in range(len(arr)):\n if i==0:\n continue\n if arr[i]%i==0:\n ls.append(arr[i])\n return ls", "def multiple_of_index(arr):\n l = list()\n for i in range(len(arr)):\n print(arr[i],i)\n if i == 0 and arr[i] == 0:\n l.append(i)\n elif i == 0:\n continue\n if arr[i] % i == 0 :\n l.append(arr[i])\n print(l)\n return l"] | {"fn_name": "multiple_of_index", "inputs": [[[22, -6, 32, 82, 9, 25]], [[68, -1, 1, -7, 10, 10]], [[11, -11]], [[-56, -85, 72, -26, -14, 76, -27, 72, 35, -21, -67, 87, 0, 21, 59, 27, -92, 68]], [[28, 38, -44, -99, -13, -54, 77, -51]], [[-1, -49, -1, 67, 8, -60, 39, 35]]], "outputs": [[[-6, 32, 25]], [[-1, 10]], [[-11]], [[-85, 72, 0, 68]], [[38, -44, -99]], [[-49, 8, -60, 35]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 16,233 |
def multiple_of_index(arr):
|
a8ca829b27f7f399bcf18a4d3149471c | UNKNOWN | The number `1035` is the smallest integer that exhibits a non frequent property: one its multiples, `3105 = 1035 * 3`, has its same digits but in different order, in other words, `3105`, is one of the permutations of `1035`.
The number `125874` is the first integer that has this property when the multiplier is `2`, thus: `125874 * 2 = 251748`
Make the function `search_permMult()`, that receives an upper bound, nMax and a factor k and will output the amount of pairs bellow nMax that are permuted when an integer of this range is multiplied by `k`. The pair will be counted if the multiple is less than `nMax`, too
Let'see some cases:
```python
search_permMult(10000, 7) === 1 # because we have the pair 1359, 9513
search_permMult(5000, 7) === 0 # no pairs found, as 9513 > 5000
search_permMult(10000, 4) === 2 # we have two pairs (1782, 7128) and (2178, 8712)
search_permMult(8000, 4) === 1 # only the pair (1782, 7128)
search_permMult(5000, 3) === 1 # only the pair (1035, 3105)
search_permMult(10000, 3) === 2 # found pairs (1035, 3105) and (2475, 7425)
```
Features of the random Tests:
```
10000 <= nMax <= 100000
3 <= k <= 7
```
Enjoy it and happy coding!! | ["from bisect import bisect\n\nmemo = {3: [3105, 7425, 30105, 31050, 37125, 42741, 44172, 71253, 72441, 74142, 74250, 74628, 74925, 82755, 85725],\n 4: [7128, 8712, 67128, 70416, 71208, 71280, 71328, 71928, 72108, 78912, 79128, 80712, 86712, 87120, 87132, 87192, 87912, 95832],\n 5: [],\n 6: [8316, 83160, 83916, 84510, 89154, 91152],\n 7: [9513, 81816, 83181, 90321, 91203, 93513, 94143, 95130, 95193, 95613]}\n\ndef search_permMult(nMax, k):\n return bisect(memo[k], nMax)", "def search_permMult(nMax, k):\n x = 0\n for i in range(1000, nMax//k):\n if SameDigits(i*k, i):\n x +=1\n return x\n\ndef SameDigits(a, b):\n return sorted(list(str(a))) == sorted(list(str(b)))", "def search_permMult(n_max, k):\n return sum(1 for n in range(1, n_max // k) if sorted(str(n)) == sorted(str(n * k)))\n \n \n \n \n #pairs = 0\n #for n in range(1, n_max // k):\n # if sorted(str(n)) == sorted(str(n * k)):\n # pairs = pairs + 1\n #return pairs\n", "def search_permMult(nMax, k):\n def tod(n):\n return \"\".join(sorted([d for d in str(n)]))\n i = 1; cnt = 0\n while i <= nMax // k:\n if tod(i) == tod(i * k):\n cnt += 1\n i += 1\n return cnt"] | {"fn_name": "search_permMult", "inputs": [[10000, 7], [5000, 7], [10000, 4], [8000, 4], [5000, 3], [10000, 3]], "outputs": [[1], [0], [2], [1], [1], [2]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,278 |
def search_permMult(nMax, k):
|
c367e96d7e45ae6178eeae4de40b93d5 | UNKNOWN | Your users passwords were all stole in the Yahoo! hack, and it turns out they have been lax in creating secure passwords. Create a function that checks their new password (passed as a string) to make sure it meets the following requirements:
Between 8 - 20 characters
Contains only the following characters: (and at least one character from each category): uppercase letters, lowercase letters, digits, and the special characters !@#$%^&*?
Return "valid" if passed or else "not valid" | ["import re;\ndef check_password(s):\n if re.search('^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?\\d)(?=.*?[!@#$%^&*?])[a-zA-Z\\d!@#$%^&*?]{8,20}$', s) :\n return 'valid'\n else:\n return 'not valid'", "import re\n\ndef check_password(s):\n m = re.match(r'(?=.{8,20}$)(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*?])(?=^[a-zA-Z\\d!@#$%^&*?]*$)', s)\n return 'valid' if m else 'not valid'", "import re\n\nPATTERN = re.compile(\n'^' # begin string\n'(?=.*?[A-Z])' # at least one uppercase letter\n'(?=.*?[a-z])' # at least one lowercase letter\n'(?=.*?\\d)' # at least one digit\n'(?=.*?[!@#$%^&*?])' # at least one special character\n'[A-Za-z\\d!@#$%^&*?]' # only the given characters\n'{8,20}' # between 8 and 20 characters long\n'$' # end string\n)\n\ndef check_password(s):\n return \"valid\" if PATTERN.match(s) else \"not valid\"", "from re import sub\n\ndef check_password(string):\n reduced = sub(\"[a-z]\", \"a\", sub(\"[A-Z]\", \"A\", sub(\"[0-9]\", \"0\", sub(\"[!@#$%^&*?]\", \"!\", string))))\n return \"valid\" if 8 <= len(string) <= 20 and set(reduced) == set(\"aA0!\") else \"not valid\"\n\n\n\n\n\n## without re\n#from string import ascii_lowercase as LOW, ascii_uppercase as UPP, digits as DIG\n\n## without import\n#LOW = \"abcdefghijklmnopqrstuvwxyz\"\n#UPP = LOW.upper()\n#DIG = \"0123456789\"\n\n#SPE = \"!@#$%^&*?\"\n#ALLOWED = (LOW, UPP, DIG, SPE)\n\n#def check_password(string):\n# reduced = string.translate(str.maketrans(\"\".join(ALLOWED), \"\".join(s[0]*len(s) for s in ALLOWED)))\n# return \"valid\" if 8 <= len(string) <= 20 and set(reduced) == set(s[0] for s in ALLOWED) else \"not valid\"\n", "def check_password(s):\n c1 = 8 <= len(s) <=20\n c2 = any([i.isupper() for i in s])\n c3 = any([i.islower() for i in s])\n c4 = any([i.isdigit() for i in s])\n c5 = any([i for i in s if i in '!@#$%^&*?'])\n c6 = not any([i for i in s if i not in '!@#$%^&*?' and not i.isupper() and not i.islower() and not i.isdigit()])\n return 'valid' if c1 and c2 and c3 and c4 and c5 and c6 else 'not valid'", "from re import search\n\ndef check_password(s):\n return 'valid' if bool(search('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*?])[\\w!@#$%^&*?]{8,20}$', s)) else 'not valid'", "import re\ndef check_password(s):\n if len(s) > 20 or len(s) < 8: return \"not valid\"\n a1 = bool(re.search(r'[A-Z]', s))\n a2 = bool(re.search(r'[a-z]', s))\n a3 = bool(re.search(r'\\d', s))\n a4 = bool(re.search(r'[!@#$%^&*?]', s))\n a5 = bool(re.search(r'^[A-Za-z!@#$%^&*?\\d]*$', s))\n return \"valid\" if a1*a2*a3*a4*a5 else \"not valid\"", "import re\n\ndef check_password(s):\n return 'valid' if re.search(r'^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*?])[A-Za-z0-9!@#$%^&*?]{8,20}$', s) else 'not valid'", "from string import digits as D, ascii_lowercase as L, ascii_uppercase as U\nS = \"!@#$%^&*?\"\n\n\ndef check_password(s):\n return \"valid\" if 8 <= len(s) <= 20 \\\n and all(c in D+L+U+S for c in s) \\\n and any(c in D for c in s) \\\n and any(c in L for c in s) \\\n and any(c in U for c in s) \\\n and any(c in S for c in s) \\\n else \"not valid\"", "def check_password(s):\n import re\n chars = \"!@#$%^&*?1234567890qazwsxedcrfvtgbyhnujmiklopQAZWSXEDCRFVTGBYHNUJMIKLOP\"\n sp = \"[!@#$%^&*?]\"\n a=\"[a-z]\"\n if len(s) in range(8,21):\n for c in s:\n if c not in chars:\n return \"not valid\" \n else:\n return \"not valid\"\n if all((re.search(sp,s), re.search(\"\\d\",s), re.search(a,s), re.search(a.upper(),s))):\n return \"valid\" \n else:\n return \"not valid\""] | {"fn_name": "check_password", "inputs": [[""], ["password"], ["P1@p"], ["P1@pP1@p"], ["P1@pP1@pP1@pP1@pP1@pP1@p"]], "outputs": [["not valid"], ["not valid"], ["not valid"], ["valid"], ["not valid"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,831 |
def check_password(s):
|
22f5cb5c57c2b6a7eeb8bdb8b1f44801 | UNKNOWN | ## Welcome to my (amazing) kata!
You are given a gigantic number to decode. Each number is a code that alternates in a pattern between encoded text and a smaller, encoded number. The pattern's length varies with every test, but the alternation between encoded text and an encoded number will always be there. Following this rule, each number tested begins with encoded text and ends with an encoded number.
## How the encoding works
Now, we should probably review how the string of numbers is formed - considering you have to unform it. So, first, some text is taken, and encoded. The system of encoding is taking each letter's position in the alphabet and adding 100 to it. For example, `m` in the real text would be `113` in the code-number.
After the text, there is a binary number. You should convert this number to a normal, base 10 decimal (all of them can be converted into whole, non-negative numbers).
Separating encoded text and encoded numbers, there is a `98`. Because the numbers are in binary, the only digits they use are '0' and '1', and each letter of the alphabet, encoded, is between 101-127, all instances of `98` are to indicate a separation between encoded text and encoded numbers. There may also be a `98` at the very end of the number.
When you return your final answer, the text and numbers should always be separated by a comma (`,`)
## Example
```python
decode(103115104105123101118119981001098113113113981000) = "codewars, 18, mmm, 8"
```
The part of the code until the first `98` can be decoded to `"codewars"`. `10010` is binary for `18`. `113113113` translates to `"mmm"`. And `1000` is binary for `8`.
Here is a visualisation of the example:
Good luck! | ["def decode(number):\n return ', '.join(\n str(int(w, 2)) if i % 2 else\n ''.join( chr(int(w[x:x+3])-4) for x in range(0, len(w), 3) )\n for i, w in enumerate( str(number).strip('98').split('98') )\n )", "def decode(number):\n split = str(number).replace('98', ' ').split()\n split[::2] = [''.join(chr(int(w[i: i+3]) - 4)\n for i in range(0, len(w), 3))\n for w in split[::2]]\n split[1::2] = [str(int(n, 2)) for n in split[1::2]]\n return ', '.join(split)", "def decode(number):\n import textwrap\n arr=[]\n for x in str(number).split('98'):\n if x:\n try:\n arr.append(str(int(x,2)))\n except:\n arr.append(\"\".join([chr(int(x)-4) for x in textwrap.wrap(x,3)]))\n return \", \".join(arr)", "from re import compile\n\nFIND = compile(r\"((?:\\d{3})+?)(?:98)([01]+)(?:98)?\").findall\nto_text = lambda s: ''.join(chr(int(s[i:i+3]) - 4) for i in range(0, len(s), 3))\n\ndef decode(number):\n return ', '.join(f\"{to_text(x)}, {int(y, 2)}\" for x,y in FIND(str(number)))", "def decode(s):\n arr = str(s).strip('98').split('98')\n return ', '.join(sum([[''.join([chr(96+int(arr[i][k:k+3])-100) for k in range(0,len(arr[i]),3)]),str(int(arr[i+1],2))] for i in range(0,len(arr),2)],[]))", "def decode(number):\n parts = str(number).rstrip('98').split('98')\n parts[::2] = (''.join(chr(0x60 + int(b+c)) for _, b, c in zip(*[iter(part)]*3)) for part in parts[::2])\n parts[1::2] = (str(int(part, 2)) for part in parts[1::2])\n return ', '.join(parts)", "def decode(number):\n parts = [e for e in str(number).split('98') if e]\n return ', '.join(str(int(w, 2)) if i % 2 else word(w) for i, w in enumerate(parts))\n \ndef word(s):\n return ''.join(chr(int(s[i*3:i*3+3]) - 4) for i in range(len(s) // 3)) ", "def decode(number):\n foo = str(number).split('98')\n parts = foo[:-1] if foo[-1] == '' else foo\n output = \"\"\n for i in range(len(parts)):\n if i % 2 == 0:\n for x in range(0, len(parts[i]), 3):\n output += chr(int(parts[i][x:x+3])-4)\n output += ', '\n else:\n output += str(int(parts[i], 2))\n if i != len(parts)-1:\n output += ', '\n return output\n \n", "def decode(number):\n string = str(number).split('98')\n if not string[-1]: del(string[-1])\n let = []\n for x in range(len(string)):\n if not x%2:\n let_n=[]\n for y in range(0, len(string[x])-2, 3):\n let_n.append(chr(int(string[x][y:y+3])-4))\n let.append(''.join(let_n))\n else: let.append(str(int(string[x],2)))\n return ', '.join(let)", "import re\ndef decode(number):\n arr = []\n for match in re.finditer(r'((?:1[01][1-9]|110|12[0-7])+)98([01]+)(?:98)?', str(number)):\n arr.append(re.sub(r'\\d{3}', lambda m: chr(int(m.group()) - 4), match.group(1)))\n arr.append(str(int(match.group(2), 2)))\n return ', '.join(arr)"] | {"fn_name": "decode", "inputs": [[103115104105123101118119981001098], [103115104105123101118119981001098103115104105123101118119981001098103115104105123101118119981001098], [1091011161151121151071091261051061151181081151231191201211161091041201081091191111011201011091199810010981051221051141201081151211071081091201191021181091121121091011141209810001], [119112105105116981000981091199810019810612111498100000110001], [109106125115121108101122105101114125103115113116112101109114120119109120119114115120113125106101121112120981100019810911210911110511911210510511698111000100100981191131091121051251061011031059810001], [12310810511498100010981091231011191011251151211141071021151259810001109811312510610112010810511812011511511111310510911412011512010810510310912012598100100098113103118109119101123105119115113105981000198], [120108105118105109119101112109107108120981001010101098102105108109114104125115121118105125105119981000], [1251151211191081151211121041061051051121191251131161011201081251061151181131059810001009812010810911911611811510711810111310711210912010310810510410111410410410511210512010510411312510610911811912012210511811910911511411510612010810911911110112010198100001098109120119114115120115111101125981000109811110911410411510611210911110510911311411512011511110112510911611811511310911910598100010], [1091011131021151181051041191151091011131071151091141071201151201251161051181011141041151131121051201201051181199810000001001010100101010101010198102112101108101112119104110111106101112104119111106110101119104108107101119112104108107101119121112109104107108981000101001011981011191041111081071121041121011111101081079810001010010198119112105105116101104112106110112104101119104106104106104119115113105120108109114107109119114115120118101114104115113104101106104101106108104101112111110106108109114108105118105981000001010010101001010100101010101098117105118120125121109115116101119104106107108110111112126124103122102114113123123123123123117105118120125121109115116101119104106107108110111112126124103122102114113123123123123123117105118120125121109115116101119104106107108110111112126124103122102114113123123123123123117105118120125121109115116101119104106107108110111112126124103122102114113123123123123123117105118120125121109115116101119104106107108110111112126124103122102114113123123123123123117105118120125121109115116101119104106107108110111112126124103122102114113123123123123123117105118120125121109115116101119104106107108110111112126124103122102114113123123123123123981000101010], [1091061251151211231051181051211191091141071201081051161181091141201031151131131011141041151181191151131051201081091141071011141041181051011041091141071201081091191021181091121121011091141201031151141221051181191011201091151141091081151161051251151211051141101151251051041091201011141041201081011201091201131011041051211161061151181201081051201051181181091021121051111011201011201081011201091131011041051151201081051181231091191051091071211051191191091011131201011121111091141071201151131251191051121061011121191151091031011141201211191051191161011031051191151181161211141031201211011201091151141151061011141251191151181201011141041091201091191041181091221091141071131051011021191151121211201051121251091141191011141051231051121121251151211071051201201081051161151091141201191151211131081011221051011141091031051041011251011141041021251051011141041121091191201051141201151131251031081051131091031011121181151131011141031051201081051251011181051011131011261091141071201081011201091191011121121061151181201151041011251201081051231051011201081051181091191141091031051071151161121011251151211201191091041059810010010100101010010101010100101010001001001]], "outputs": [["codewars, 18"], ["codewars, 18, codewars, 18, codewars, 18"], ["iapologizeforhowstupidthiskatais, 18, eventhoughitsbrilliant, 17"], ["sleep, 8, is, 9, fun, 2097"], ["ifyouhaveanycomplaintsitsnotmyfault, 49, ilikesleep, 3620, smileyface, 17"], ["when, 34, iwasayoungboy, 70, myfathertookmeintothecity, 72, mcrisawesome, 17"], ["thereisalight, 1194, behindyoureyes, 8"], ["youshouldfeelsympathyforme, 68, thisprogramglitchedanddeletedmyfirstversionofthiskata, 66, itsnotokay, 34, kindoflikeimnotokayipromise, 34"], ["iamboredsoiamgoingtotyperandomletters, 541758805, blahalsdjkfaldskfjasdhgasldhgasulidgh, 4427, asdkhgldlakjhg, 2213, sleepadlfjldasdfdfdsomethingisnotrandomdafdafhdalkjfhinhere, 17526510250, qertyuiopasdfghjklzxcvbnmwwwwwqertyuiopasdfghjklzxcvbnmwwwwwqertyuiopasdfghjklzxcvbnmwwwwwqertyuiopasdfghjklzxcvbnmwwwwwqertyuiopasdfghjklzxcvbnmwwwwwqertyuiopasdfghjklzxcvbnmwwwwwqertyuiopasdfghjklzxcvbnmwwwww, 554"], ["ifyouwereusingtheprintcommandorsomethingandreadingthisbrillaintconversationihopeyouenjoyeditandthatitmadeupfortheterriblekatathatimadeotherwiseiguessiamtalkingtomyselfalsoicantusespacesorpunctuationofanysortanditisdrivingmeabsolutelyinsanewellyougetthepointsoumhaveanicedayandbyeandlistentomychemicalromancetheyareamazingthatisallfortodaytheweatherisnicegoplayoutside, 10073085203529"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,108 |
def decode(number):
|
c944d59bf4f1e5df3c506ad5447fdd70 | UNKNOWN | ```if-not:ruby
Create a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed in arguments. If one of them is shorter than the others, the result should be padded with empty elements.
```
```if:ruby
Create a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed in arguments. If one of them is shorter than the others, the result should be padded with `nil`s.
```
Examples:
```python
interleave([1, 2, 3], ["c", "d", "e"]) == [1, "c", 2, "d", 3, "e"]
interleave([1, 2, 3], [4, 5]) == [1, 4, 2, 5, 3, None]
interleave([1, 2, 3], [4, 5, 6], [7, 8, 9]) == [1, 4, 7, 2, 5, 8, 3, 6, 9]
interleave([]) == []
``` | ["from itertools import chain, zip_longest\n\ndef interleave(*args):\n return list(chain.from_iterable(zip_longest(*args)))", "def interleave(*args):\n max_len = max(map(len,args))\n interleaved = []\n \n for i in range(max_len):\n for arr in args:\n if i < len(arr):\n interleaved.append(arr[i])\n else:\n interleaved.append(None)\n \n return interleaved", "from itertools import chain, zip_longest\n\ndef interleave(*args):\n return [*chain.from_iterable(zip_longest(*args))]", "from itertools import chain, zip_longest\n\ndef interleave(*args):\n return [*chain(*zip_longest(*args))]", "interleave=lambda *a:[b[i]if len(b)>i else None for i in range(max(len(i)for i in a))for b in a]", "from itertools import zip_longest\n\ndef interleave(*args):\n return [y for x in zip_longest(*args) for y in x]\n", "interleave=lambda *a:sum([list(i) for i in __import__('itertools').zip_longest(*a)],[])", "from itertools import zip_longest\ndef interleave(*args):\n return [i for _ in zip_longest(*args) for i in _]", "def interleave(*args):\n arr = []\n for i in range(max(len(a) for a in args)):\n for j in range(len(args)):\n try: arr.append(args[j][i])\n except: arr.append(None)\n return arr", "def interleave(*args):\n n_max = len(max(args,key=len))\n return [j[i] if i < len(j) else None for i in range(n_max) for j in args]"] | {"fn_name": "interleave", "inputs": [[[1, 2, 3], ["c", "d", "e"]], [[1, 2, 3], [4, 5]], [[1, 2], [3, 4, 5]], [[null], [null, null], [null, null, null]], [[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[]]], "outputs": [[[1, "c", 2, "d", 3, "e"]], [[1, 4, 2, 5, 3, null]], [[1, 3, 2, 4, null, 5]], [[null, null, null, null, null, null, null, null, null]], [[1, 4, 7, 2, 5, 8, 3, 6, 9]], [[]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,464 |
def interleave(*args):
|
ffa81c079ff3238485771880beb16c25 | UNKNOWN | How many licks does it take to get to the tootsie roll center of a tootsie pop?
A group of engineering students from Purdue University reported that its licking machine, modeled after a human tongue, took an average of 364 licks to get to the center of a Tootsie Pop. Twenty of the group's volunteers assumed the licking challenge-unassisted by machinery-and averaged 252 licks each to the center.
Your task, if you choose to accept it, is to write a function that will return the number of licks it took to get to the tootsie roll center of a tootsie pop, given some environmental variables.
Everyone knows it's harder to lick a tootsie pop in cold weather but it's easier if the sun is out. You will be given an object of environmental conditions for each trial paired with a value that will increase or decrease the number of licks. The environmental conditions all apply to the same trial.
Assuming that it would normally take 252 licks to get to the tootsie roll center of a tootsie pop, return the new total of licks along with the condition that proved to be most challenging (causing the most added licks) in that trial.
Example:
```
totalLicks({ "freezing temps": 10, "clear skies": -2 });
```
Should return:
```
"It took 260 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was freezing temps."
```
Other cases:
If there are no challenges, the toughest challenge sentence should be omitted. If there are multiple challenges with the highest toughest amount, the first one presented will be the toughest.
If an environment variable is present, it will be either a positive or negative integer. No need to validate.
Check out my other 80's Kids Katas:
80's Kids #1: How Many Licks Does It Take
80's Kids #2: Help Alf Find His Spaceship
80's Kids #3: Punky Brewster's Socks
80's Kids #4: Legends of the Hidden Temple
80's Kids #5: You Can't Do That on Television
80's Kids #6: Rock 'Em, Sock 'Em Robots
80's Kids #7: She's a Small Wonder
80's Kids #8: The Secret World of Alex Mack
80's Kids #9: Down in Fraggle Rock
80's Kids #10: Captain Planet | ["def total_licks(env):\n d = 252\n vm = 0\n for k,v in env.items():\n d+=v\n if v > vm:\n vm, km = v, k\n return 'It took ' + str(d) + ' licks to get to the tootsie roll center of a tootsie pop.' + (' The toughest challenge was ' + km + '.' if vm > 0 else '')", "from operator import itemgetter\n\nTOTAL_LICKS = 252\n\n\ndef total_licks(env):\n message = ('It took %d licks to get to the tootsie roll center of a tootsie pop.' %\n (TOTAL_LICKS + sum(env.values())))\n\n if env:\n toughest_challenge = max(iter(env.items()), key=itemgetter(1))\n if toughest_challenge[1] > 0:\n message += ' The toughest challenge was %s.' % toughest_challenge[0]\n\n return message\n", "def total_licks(env):\n s = \"It took {} licks to get to the tootsie roll center of a tootsie pop.\".format(252 + sum(env.values()))\n if any(x > 0 for x in env.values()):\n key = max(env, key=env.get)\n s += ' The toughest challenge was {}.'.format(key)\n return s", "def total_licks(env):\n sLicks = f\"It took {252 + sum(env.values())} licks to get to the tootsie roll center of a tootsie pop.\"\n if env and max(env.values())>0: \n sLicks += f\" The toughest challenge was {max(env, key = env.get)}.\"\n return sLicks", "from operator import itemgetter\nfrom typing import Dict\n\n\ndef total_licks(env: Dict[str, int]) -> str:\n t = max(list(env.items()), key=itemgetter(1), default=('', 0))\n return (f\"It took {252 + sum(env.values())} licks to get to the tootsie roll center of a tootsie pop.\"\n f\"{f' The toughest challenge was {t[0]}.' if t[1] > 0 else ''}\")\n", "def total_licks(env):\n tough = max(env.items(), key=lambda x:x[1]) if env else [0, 0]\n total = sum(v for v in env.values())\n \n output = 'It took {} licks to get to the tootsie roll center of a tootsie pop.'.format(252 + total)\n if tough[1] > 0:\n output += ' The toughest challenge was {}.'.format(tough[0])\n return output", "def total_licks(env):\n licks = \"It took {} licks to get to the tootsie roll center of a tootsie pop.\".format(252 + sum(env.values()))\n toughest_key, toughest_value = max(env.items(), key=lambda item: item[1]) if env else (\"\", 0)\n toughest_msg = \" The toughest challenge was {}.\".format(toughest_key) if toughest_value > 0 else \"\"\n return licks + toughest_msg", "def total_licks(env):\n licks = 252\n if env == {}:\n return f\"It took {licks} licks to get to the tootsie roll center of a tootsie pop.\"\n for challenge in env.items():\n licks += challenge[1]\n max_challenge = max(env.values())\n if max_challenge < 0:\n return f\"It took {licks} licks to get to the tootsie roll center of a tootsie pop.\"\n for cha in env.keys():\n if env[cha] == max_challenge:\n challenge = cha\n return f\"It took {licks} licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was {challenge}.\"", "def total_licks(env):\n \n n = 252\n \n s = \"\"\n\n for k,v in list(env.items()):\n \n n+= v\n \n if v>0:\n \n if max(env,key=env.get) not in s:\n \n s+= max(env,key=env.get)\n \n if env=={} or s==\"\":\n \n return f\"It took {n} licks to get to the tootsie roll center of a tootsie pop.\"\n\n else:\n \n return f\"It took {n} licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was {s}.\"\n\n", "def total_licks(env):\n licks = 252 + sum(env.values())\n challenge = max(([v, k] for k, v in env.items() if v > 0), default=None)\n \n result = f'It took {licks} licks to get to the tootsie roll center of a tootsie pop.'\n if challenge:\n result += f' The toughest challenge was {challenge[1]}.'\n return result"] | {"fn_name": "total_licks", "inputs": [[{"freezing temps": 10, "clear skies": -2}], [{"happiness": -5, "clear skies": -2}], [{}], [{"dragons": 100, "evil wizards": 110, "trolls": 50}], [{"white magic": -250}]], "outputs": [["It took 260 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was freezing temps."], ["It took 245 licks to get to the tootsie roll center of a tootsie pop."], ["It took 252 licks to get to the tootsie roll center of a tootsie pop."], ["It took 512 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was evil wizards."], ["It took 2 licks to get to the tootsie roll center of a tootsie pop."]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,943 |
def total_licks(env):
|
e996eefbbe84a0d55cb2f1fda2c65eb1 | UNKNOWN | Find the length between 2 co-ordinates. The co-ordinates are made of integers between -20 and 20 and will be given in the form of a 2D array:
(0,0) and (5,-7) would be [ [ 0 , 0 ] , [ 5, -7 ] ]
The function must return the answer rounded to 2 decimal places in the form of a string.
```python
length_of_line([[0, 0], [5, -7]]) => "8.60"
```
If the 2 given co-ordinates are the same, the returned length should be "0.00" | ["from math import sqrt\ndef length_of_line(array):\n x1, y1, x2, y2 = array[0][0], array[0][1], array[1][0], array[1][1]\n return '{:.2f}'.format((sqrt((x2-x1)**2 + (y2-y1)**2)))", "import math\ndef length_of_line(array):\n return \"{:.02f}\".format(math.sqrt((array[1][0] - array[0][0])**2 + (array[1][1] - array[0][1])**2))\n", "from math import sqrt\n\ndef length_of_line(array):\n (x1, y1), (x2, y2) = array[0], array[1]\n return '{:.2f}'.format(sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2))", "from math import hypot\n\ndef length_of_line(array):\n (a, b), (c, d) = array\n return f\"{hypot(a-c, b-d):.2f}\"", "def length_of_line(pts):\n return f'{sum((a-b)**2 for a,b in zip(*pts))**.5:.2f}'\n", "def length_of_line(array):\n return '{:0.2f}'.format(((array[0][0] - array[1][0]) ** 2 + (array[0][1] - array[1][1]) ** 2) ** .5)\n", "from itertools import starmap\nfrom operator import sub\nfrom math import hypot\n\ndef length_of_line(array):\n return '{:.2f}'.format(hypot(*starmap(sub,zip(*array))))", "import math\ndef length_of_line(array):\n # Good Luck!\n #return math.sqrt(((array[1][0] - array[0][0]) ^ 2 + (array[1][1] - array[0][1]) ^ 2))\n return '%.2f' % math.hypot(array[1][0] - array[0][0], array[1][1] - array[0][1])"] | {"fn_name": "length_of_line", "inputs": [[[[0, 0], [1, 1]]], [[[0, 0], [-5, -6]]], [[[0, 0], [10, 15]]], [[[0, 0], [5, 1]]], [[[0, 0], [5, 4]]], [[[0, 0], [-7, 4]]], [[[0, 0], [0, 0]]], [[[-3, 4], [10, 5]]]], "outputs": [["1.41"], ["7.81"], ["18.03"], ["5.10"], ["6.40"], ["8.06"], ["0.00"], ["13.04"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,264 |
def length_of_line(array):
|
623f76d343b8e55c9bb6ec8eec680491 | UNKNOWN | You are working at a lower league football stadium and you've been tasked with automating the scoreboard.
The referee will shout out the score, you have already set up the voice recognition module which turns the ref's voice into a string, but the spoken score needs to be converted into a pair for the scoreboard!
e.g. `"The score is four nil"` should return `[4,0]`
Either teams score has a range of 0-9, and the ref won't say the same string every time e.g.
"new score: two three"
"two two"
"Arsenal just conceded another goal, two nil"
Note:
```python
Please return an array
```
Please rate and enjoy! | ["def scoreboard(string):\n scores = {'nil': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}\n return [scores[x] for x in string.split() if x in scores]", "PTS = {w:i for i,w in enumerate('nil one two three four five six seven eight nine'.split())}\n\ndef scoreboard(s):\n return [PTS[w] for w in s.split()[-2:]]", "NUMBERS = \"nil one two three four five six seven eight nine\".split()\n\ndef scoreboard(s):\n return [ NUMBERS.index(w) for w in s.split() if w in NUMBERS ]", "import re\n\nd = {'nil':0,\n 'one':1,\n 'two':2,\n 'three':3,\n 'four':4,\n 'five':5,\n 'six':6,\n 'seven':7,\n 'eight':8,\n 'nine':9}\n\n\ndef scoreboard(string):\n x = re.findall('nil|one|two|three|four|five|six|seven|eight|nine', string)\n return [d[x[0]], d[x[1]]]", "from re import findall\n\nscore = {\"nil\":0, \"one\":1, \"two\":2, \"three\":3, \"four\":4, \"five\":5, \"six\":6, \"seven\":7, \"eight\":8, \"nine\":9}\n\ndef scoreboard(string):\n return list(map(score.get, findall('|'.join(score), string)))", "def scoreboard(string):\n words = string.split()\n result = []\n numMap = ['nil','one','two','three','four','five','six','seven','eight','nine']\n for word in words:\n if word in numMap:\n result.append(numMap.index(word))\n return result", "def scoreboard(string):\n scores = [\"nil\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\n arr = []\n temp = -1\n num = -1 \n for score in scores:\n i = string.find(score)\n if i != -1:\n if string.find(score, i + 1) != -1:\n same = scores.index(score)\n arr = [same, same]\n else:\n if temp != -1:\n if i > temp:\n arr = [num, scores.index(score)]\n else:\n arr = [scores.index(score), num]\n else:\n temp = i\n num = scores.index(score)\n return arr", "def scoreboard(string):\n data = {\n \"nil\": 0,\n \"one\": 1,\n \"two\": 2,\n \"three\": 3,\n \"four\": 4,\n \"five\": 5,\n \"six\": 6,\n \"seven\": 7,\n \"eight\": 8,\n \"nine\": 9,\n }\n\n return [data[word] for word in string.split() if word in data.keys()]", "def scoreboard(announcement):\n '''Return scores as numbers from announcement'''\n numbers = {\n 'nil': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\n 'four': 4,\n 'five': 5,\n 'six': 6,\n 'seven': 7,\n 'eight': 8,\n 'nine': 9\n }\n # scores are the last two words in the referee's announcement\n scores = announcement.split()[-2:]\n return [numbers[score] for score in scores]", "import re\n\nscores = {word: i for i, word in enumerate('nil one two three four five six seven eight nine'.split())}\npattern = re.compile(r'\\b({})\\b'.format('|'.join(scores)))\n\ndef scoreboard(string):\n return [scores[m] for m in pattern.findall(string)]"] | {"fn_name": "scoreboard", "inputs": [["The score is four nil"], ["new score: two three"], ["two two"], ["Arsenal just conceded another goal, two nil"]], "outputs": [[[4, 0]], [[2, 3]], [[2, 2]], [[2, 0]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,193 |
def scoreboard(string):
|
47f9d623b8649ffc2e1365c445238ef4 | UNKNOWN | In mathematics, a [Diophantine equation](https://en.wikipedia.org/wiki/Diophantine_equation) is a polynomial equation, usually with two or more unknowns, such that only the integer solutions are sought or studied.
In this kata we want to find all integers `x, y` (`x >= 0, y >= 0`) solutions of a diophantine equation of the form:
#### x^(2) - 4 \* y^(2) = n
(where the unknowns are `x` and `y`, and `n` is a given positive number)
in decreasing order of the positive xi.
If there is no solution return `[]` or `"[]" or ""`. (See "RUN SAMPLE TESTS" for examples of returns).
## Examples:
```
solEquaStr(90005) --> "[[45003, 22501], [9003, 4499], [981, 467], [309, 37]]"
solEquaStr(90002) --> "[]"
```
## Hint:
x^(2) - 4 \* y^(2) = (x - 2\*y) \* (x + 2\*y) | ["import math\ndef sol_equa(n):\n res = []\n for i in range(1, int(math.sqrt(n)) + 1):\n if n % i == 0:\n j = n // i\n if (i + j) % 2 == 0 and (j - i) % 4 == 0:\n x = (i + j) // 2\n y = (j - i) // 4\n res.append([x, y])\n \n return res\n", "def sol_equa(n):\n return [[(n/i + i)/2,(n/i - i)/4] for i in range(1, int(n ** 0.5) + 1)\n if n % i == 0 and (n/i + i) % 2 ==0 and (n/i - i) % 4 ==0]\n", "from math import sqrt\n\ndef factors(n):\n f = []\n for x in range(1, int(sqrt(n)) + 1):\n if n % x == 0:\n f.append([x, int(n / x)])\n return f\n\ndef sol_equa(n):\n ff = factors(n)\n res = []\n for f in ff:\n m = m = f[0] + f[1]\n n = f[1] - f[0]\n if (m % 2 == 0) and (n % 4 == 0):\n res.append([int(m / 2), int(n / 4)])\n return res", "def sol_equa(n):\n res = []\n for a in range(1, int(n**0.5 + 1) + 1 ):\n if n % a == 0:\n b = n / a\n if (a + b) % 2 == 0 and (b - a) % 4 == 0:\n res.append( [(a+b)/2, (b-a)/4] )\n return res\n", "def sol_equa(n):\n # x^2 - 4y^2 = n -> return [x, y]\n # Factor to n = (x+2y)(x-2y)\n solutions, i = [], 1\n while i*i <= n:\n if n % i == 0: # Factor found: (j=n//i: so: i*j = n)\n j = n // i\n if (i+j) % 2 == 0: # (x + 2y)+(x - 2y) = (2x)\n # Fits requirements for x!!!\n x = (i+j)//2 # (i + j ) / 2 = x\n v, V = i-x, j-x # (i - x = 2y) and (j - x = -2y)\n if v % 2 == 0 and v == V * -1:\n # Fits requirements for y!!!\n y = abs(v//2)\n solutions.append([x, y])\n i += 1\n return solutions\n", "import math\ndef sol_equa(n):\n # your code\n # x - 2y ...f1\n # x + 2y ...f2\n # A = sum(f1, f2) = 2x divisible by 2\n # B = diff(f1, f2) = 4y divisible by 4\n result = []\n for i in range(1, int(math.ceil(math.sqrt(n))) + 1):\n if n % i == 0:\n A = i + n/i\n B = abs(i - n/i)\n if A % 2 == 0 and B % 4 == 0:\n result.append([A/2, B/4])\n return result\n", "#x ^ 2 - 4 * y ^ 2 = A\nimport math\ndef sol_equa(n):\n ls = []\n for i in range(1,int(math.sqrt(n))+1):\n if n%i == 0 :\n ls.append(i)\n ans = []\n for root in ls:\n x = int(( (root + int(n/root)) / 2))\n y = int((max(root,int(n/root)) - x) / 2)\n if int(x + 2 * y) * (x - 2 * y) == n:\n ans.append([x,y])\n return ans", "from math import sqrt\ndef sol_equa(n):\n m = [[y, n/y] for y in [x for x in range(1, int(sqrt(n))+1) if n%x == 0]]\n return sorted([[(r[0] +r[1])/2, (r[1] - r[0])/4] for r in [z for z in m if (z[0] +z[1])%2 == 0 and (z[1] - z[0])%4 == 0]], reverse=True)\n", "def sol_equa(n):\n f = [[i, n//i] for i in range(1, int(n**0.5)+1) if not n%i]\n return [[(a+b)//2, (b-a)//4] for (a, b) in f if ((a+b)//2)**2 -4*((b-a)//4)**2 == n]\n \n \n \n", "def sol_equa(n):\n res = []\n if n <= 0:\n return res\n for i in range(1,int(pow(n,1/2)+1)):\n if int(n % i) == 0 and int(n-i*i) % (4*i) ==0:\n res.append([int((i+n/i)/2),int((n/i-i)/4)])\n return res"] | {"fn_name": "sol_equa", "inputs": [[5], [12], [13], [16], [17], [20], [9001], [9004], [9005], [9008], [90001], [90002], [90004], [90005], [90009], [900001], [900004], [900005], [9000001], [9000004], [90000001], [90000004], [900000012], [9000000041]], "outputs": [[[[3, 1]]], [[[4, 1]]], [[[7, 3]]], [[[4, 0]]], [[[9, 4]]], [[[6, 2]]], [[[4501, 2250]]], [[[2252, 1125]]], [[[4503, 2251], [903, 449]]], [[[1128, 562]]], [[[45001, 22500]]], [[]], [[[22502, 11250]]], [[[45003, 22501], [9003, 4499], [981, 467], [309, 37]]], [[[45005, 22502], [15003, 7500], [5005, 2498], [653, 290], [397, 130], [315, 48]]], [[[450001, 225000]]], [[[225002, 112500], [32150, 16068]]], [[[450003, 225001], [90003, 44999]]], [[[4500001, 2250000], [73801, 36870]]], [[[2250002, 1125000], [173090, 86532], [132370, 66168], [10402, 4980]]], [[[45000001, 22500000], [6428575, 3214284], [3461545, 1730766], [494551, 247230]]], [[[22500002, 11250000], [252898, 126360], [93602, 46560], [22498, 10200]]], [[[225000004, 112500001], [75000004, 37499999], [3358276, 1679071], [1119604, 559601]]], [[[4500000021, 2250000010], [155172429, 77586200]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,288 |
def sol_equa(n):
|
27266cee1d8d64280d95303d6637177d | UNKNOWN | We are interested in collecting the triples of positive integers ```(a, b, c)``` that fulfill the following equation:
```python
a² + b² = c³
```
The first triple with the lowest values that satisfies the equation we have above is (2, 2 ,2).
In effect:
```python
2² + 2² = 2³
4 + 4 = 8
```
The first pair of triples that "shares" the same value of ```c``` is: ```(2, 11, 5)``` and ```(5, 10, 5)```.
Both triples share the same value of ```c``` is ```c = 5```.
```python
Triple (2, 11, 5) Triple(5, 10, 5)
2² + 11² = 5³ 5² + 10² = 5³
4 + 121 = 125 25 + 100 = 125
```
So, we say that the value ```c``` has two solutions because there are two triples sharing the same value of ```c```.
There are some values of ```c``` with no solutions.
The first value of ```c``` that have a surprising number of solutions is ```65``` with ```8``` different triples.
In order to avoid duplications you will consider that ```a <= b``` always.
Make the function ```find_abc_sumsqcube()```, that may give us the values of c for an specific number of solutions.
For that purpose the above required function will receive two arguments, ```c_max``` and ```num_sol```. It is understandable that ```c_max``` will give to our function the upper limit of ```c``` and ```num_sol```, the specific number of solutions.
The function will output a sorted list with the values of ```c``` that have a number of solutions equals to ```num_sol```
Let's see some cases:
```python
find_abc_sumsqcube(5, 1) == [2] # below or equal to c_max = 5 we have triple the (2, 2, 2) (see above)
find_abc_sumsqcube(5, 2) == [5] # now we want the values of ```c ≤ c_max``` with two solutions (see above again)
find_abc_sumsqcube(10, 2) == [5, 10]
find_abc_sumsqcube(20, 8) == [] # There are no values of c equal and bellow 20 having 8 solutions.
```
Our tests will have the following ranges for our two arguments:
```python
5 ≤ c_max ≤ 1000
1 ≤ num_sol ≤ 10
```
Happy coding!! | ["from bisect import bisect_right as bisect\n\nRES = [[] for _ in range(11)]\n\nfor c in range(1,1001):\n c3 = c**3\n nSol = sum( ((c3-a**2)**.5).is_integer() for a in range(1,int((c3//2)**.5+1)))\n if 0 < nSol < 11: RES[nSol].append(c)\n \n\ndef find_abc_sumsqcube(c_max, nSol):\n return RES[nSol][:bisect(RES[nSol], c_max)]", "from math import sqrt\ndef nb_sol_cube_is_sumsq(c):\n count = 0\n c3 = c ** 3\n modc3 = c3 % 4\n if (modc3 == 3) or (modc3 == 2): return 0\n for a in range(1, int(sqrt(c ** 3)) + 1):\n b = sqrt(c3 - a ** 2)\n if (int(b) == b) and (0 < b <= a):\n count += 1\n return count\ndef nb_abc_sol(c_max):\n res, c = [], 1\n while (c <= c_max):\n res.append(nb_sol_cube_is_sumsq(c))\n c += 1\n return res\nsol = nb_abc_sol(1001)\ndef find_abc_sumsqcube(c_max, num_sol):\n return [i + 1 for i, count in enumerate(sol[:c_max]) if count == num_sol]", "from bisect import bisect_right\nfrom math import sqrt\n\nSOL = [[] for _ in range(11)]\n\nfor c in range(1, 1001):\n c3 = c ** 3\n num_sol = sum(sqrt(c3 - a ** 2).is_integer() for a in range(1, int(sqrt(c3 // 2) + 1)))\n if 0 < num_sol < 11: SOL[num_sol].append(c)\n\n\ndef find_abc_sumsqcube(c_max, num_sol):\n res = SOL[num_sol]\n return res[:bisect_right(res, c_max)]", "dic1 = {1: [2, 8, 18, 32, 72, 98, 128, 162, 242, 288, 392, 512, 648, 722, 882, 968], \n 2: [5, 10, 13, 17, 20, 26, 29, 34, 37, 40, 41, 45, 52, 53, 58, 61, 68, 73, 74, 80, 82, 89, 90, 97, 101, 104, 106, 109, 113, 116, 117, 122, 136, 137, 146, 148, 149, 153, 157, 160, 164, 173, 178, 180, 181, 193, 194, 197, 202, 208, 212, 218, 226, 229, 232, 233, 234, 241, 244, 245, 257, 261, 269, 272, 274, 277, 281, 292, 293, 296, 298, 306, 313, 314, 317, 320, 328, 333, 337, 346, 349, 353, 356, 360, 362, 369, 373, 386, 388, 389, 394, 397, 401, 404, 405, 409, 416, 421, 424, 433, 436, 449, 452, 457, 458, 461, 464, 466, 468, 477, 482, 488, 490, 509, 514, 521, 522, 538, 541, 544, 548, 549, 554, 557, 562, 569, 577, 584, 586, 592, 593, 596, 601, 605, 612, 613, 617, 626, 628, 634, 637, 640, 641, 653, 656, 657, 661, 666, 673, 674, 677, 692, 698, 701, 706, 709, 712, 720, 724, 733, 738, 746, 757, 761, 769, 772, 773, 776, 778, 788, 794, 797, 801, 802, 808, 809, 810, 818, 821, 829, 832, 833, 842, 848, 853, 857, 866, 872, 873, 877, 881, 898, 904, 909, 914, 916, 922, 928, 929, 932, 936, 937, 941, 953, 954, 964, 976, 977, 980, 981, 997], \n 3: [25, 100, 169, 225, 289, 400, 676, 841, 900], \n 4: [50, 200, 338, 450, 578, 800], \n 8: [65, 85, 130, 145, 170, 185, 205, 221, 260, 265, 290, 305, 340, 365, 370, 377, 410, 442, 445, 481, 485, 493, 505, 520, 530, 533, 545, 565, 580, 585, 610, 629, 680, 685, 689, 697, 730, 740, 745, 754, 765, 785, 793, 820, 865, 884, 890, 901, 905, 949, 962, 965, 970, 985, 986], \n 5: [125, 250, 500, 1000], 14: [325, 425, 650, 725, 845, 850, 925], 6: [625]}\n\nimport bisect\ndef find_abc_sumsqcube(c_max, num_sol):\n if num_sol not in dic1.keys():\n return []\n lst = dic1[num_sol]\n idx = bisect.bisect_right(lst, c_max)\n return lst[:idx]", "import math\nfrom functools import lru_cache\n\n@lru_cache(maxsize = 1024)\ndef solutions(c):\n cube = c ** 3\n return sum(1 for a in range(1,int((cube//2)**.5)+1) if ((cube-a**2)**.5).is_integer())\n\n\ndef find_abc_sumsqcube(c_max, num_sol):\n result = []\n for c in range(2,c_max+1):\n if solutions(c) == num_sol:\n result.append(c)\n return result\n"] | {"fn_name": "find_abc_sumsqcube", "inputs": [[5, 1], [5, 2], [10, 2], [20, 8], [100, 8], [100, 3], [100, 2]], "outputs": [[[2]], [[5]], [[5, 10]], [[]], [[65, 85]], [[25, 100]], [[5, 10, 13, 17, 20, 26, 29, 34, 37, 40, 41, 45, 52, 53, 58, 61, 68, 73, 74, 80, 82, 89, 90, 97]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,509 |
def find_abc_sumsqcube(c_max, num_sol):
|
40590eed802ed16bcf300567f550386e | UNKNOWN | Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a document written in a markup language. A style sheet consists of a list of rules. Each rule or rule-set consists of one or more selectors, and a declaration block. Selector describes which element it matches.
Sometimes element is matched to multiple selectors. In this case, element inherits multiple styles, from each rule it matches. Rules can override each other. To solve this problem, each selector has it's own 'specificity' - e.g. weight. The selector with greater specificity overrides the other selector.
Your task is to calculate the weights of two selectors and determine which of them will beat the other one.
```python
compare("body p", "div") # returns "body p"
compare(".class", "#id") # returns "#id"
compare("div.big", ".small") # returns "div.big"
compare(".big", ".small") # returns ".small" (because it appears later)
```
For simplicity, all selectors in test cases are CSS1-compatible, test cases don't include pseudoclasses, pseudoelements, attribute selectors, etc. Below is an explanation on how to weight two selectors. You can read more about specificity here.
The simplest selector type is ``tagname`` selector. It writes as a simple alphanumeric identifier: eg ``body``, ``div``, ``h1``, etc. It has the least weight. If selectors have multiple elements - the selector with more elements win. For example, ``body p`` beats ``div``, because it refers to 2 (nested) elements rather than 1.
Another simple selector is ``.class`` selector. It begins with dot and refer to element with specific ``class`` attribute. Class selectors can also be applied to tagname selectors, so ``div.red`` refer to ```` element. They can be grouped, for example, ``.red.striped``. Class selector beats tagname selector.
The most weighted selector type in stylesheet is ``#id`` selector. It begins with hash sign and refer to element with specific ``id`` attribute. It can also be standalone, or applied to an element. Id selector beats both selector types.
And the least weighted selector is ``*``, which has no specificity and can be beat by any other selector.
Selectors can be combined, for example, ``body #menu ul li.active`` refers to ``li`` element with ``class="active"``, placed inside ``ul`` element, placed inside element width ``id="menu"``, placed inside ``body``.
Specificity calculation is simple.
Selector with more #id selectors wins
If both are same, the winner is selector with more .class selectors
If both are same, selector with more elements wins
If all of above values are same, the winner is selector that appear last
For example, let's represent the number of ``#id`` , ``.class``, ``tagname`` selectors as array (in order from worst to best):
SelectorSpecificity (#id,.class,tagname)
*0, 0, 0
span0, 0, 1
body p0, 0, 2
.green0, 1, 0
apple.yellow0, 1, 1
div.menu li0, 1, 2
.red .orange0, 2, 0
div.big .first0, 2, 1
#john1, 0, 0
div#john1, 0, 1
body #john span1, 0, 2
menu .item #checkout.active1, 2, 1
#foo div#bar.red .none2, 2, 1 | ["import re\n\ndef compare(a, b):\n return a if specificity(a) > specificity(b) else b\n \ndef specificity(s):\n return [len(re.findall(r, s)) for r in (r'#\\w+', r'\\.\\w+', r'(^| )\\w+')]", "import re\ndef compare(a, b):\n\n def scoreCSS(s):\n d = {'#':0, '.':0, ' ':0}\n for c in re.findall(\"[#\\. ](?=[\\w-])\", \" {}\".format(s)):\n d[c] = d[c] + 1\n return (d['#'], d['.'], d[' '])\n \n return a if (scoreCSS(a) > scoreCSS(b)) else b\n", "from functools import reduce\nimport re\n\n\nSIMPLE_SELECTOR_PATTERN = re.compile(r'[\\s+~>]+|(\\[[^[]+\\]|[#\\.:]?[^[\\s#\\.:+~>]+)')\nSPECIFICITY_PATTERN = re.compile(r'(^#)|(^[\\.\\[:][^:]?)|(^::|^[^#\\.:[])')\n\n\ndef compare(a, b):\n return max((b,a), key=get_specificity)\n\n\ndef get_specificity(selector):\n return reduce(sum_specificities, list(map(simple_selector_to_specificity, get_simple_selectors(selector))))\n\n\ndef sum_specificities(*specificities):\n return list(map(sum, list(zip(*specificities))))\n\n\ndef simple_selector_to_specificity(simple_selector):\n if simple_selector == '*':\n return [0,0,0]\n return [1 if x else 0 for x in SPECIFICITY_PATTERN.match(simple_selector).groups()]\n\n\ndef get_simple_selectors(selector):\n return [\n match.group(1)\n for match in SIMPLE_SELECTOR_PATTERN.finditer(selector)\n if match.group(1)\n ]\n", "tagname = __import__(\"re\").compile(r\"(^|(?<=\\s))[^#\\.*]\").findall\n\ndef compare(a, b):\n return max(b, a, key=lambda x: (x.count('#'), x.count('.'), len(tagname(x))))", "def tokenise(s, split='*#. '):\n \"\"\"\n Takes a string and splits it on any of the characters in the split string, \n yields each split with the character used to split as it's prefix, with \n the exception of spaces followed by another split character, when spaces \n are removed\n \n Example:\n split('.abc #123 .def.ghi *')\n will yield the following strings:\n '.abc', '#123', '.def', '.ghi', '*'\n \"\"\"\n buffer = ''\n for c in s:\n if c in split:\n if buffer.strip():\n yield buffer.strip()\n buffer = ''\n buffer += c\n if buffer.strip():\n yield buffer.strip()\n\ndef score_selector(selector):\n \"\"\"\n Given a CSS selector build a score for the selector that can be used for \n sorting precendence.\n \n Returns a tuple with counts of the following:\n (stars, ids, classes, tagnames)\n Stars are numbered positively, the others are numbered negatively \n so that natural ordering can be used without having to specify a key\n for the sort call.\n \"\"\"\n low, ids, classes, tags = 0, 0, 0, 0\n for part in tokenise(selector):\n if part.startswith('.'):\n classes -= 1\n elif part.startswith('#'):\n ids -= 1\n elif part.startswith('*'):\n low += 1\n else:\n tags -= 1\n \n return low, ids, classes, tags \n\n\ndef compare(a, b):\n \"\"\"Compares two CSS selectors and returns the one with highest precedence\"\"\"\n return sorted([(score_selector(s), -i, s) for i, s in enumerate([a, b])])[0][-1]\n", "import re\n\ndef compare(a, b):\n [pa, pb] = [(x.count('#'), x.count('.'), len(re.findall(r\"[\\w']+\", x)) - x.count('#') - x.count('.')) for x in [a, b]]\n return a if pa > pb else b", "import re\n\ndef key(t):\n i,s = t\n return (s.count('#'), s.count('.'), len(re.split(r'(?!<^)[ .#]+', s)), s!='*', i)\n\ndef compare(*args):\n return max(enumerate(args), key=key)[1]", "def compare(a, b):\n return max((b, a), key=lambda sel:\n (sel.count('#'), sel.count('.'),\n sum(not t.startswith(('.', '#', '*')) for t in sel.split())))"] | {"fn_name": "compare", "inputs": [["body p", "div"], ["body", "html"], ["p a", "span"], ["div p span a", "div p span a b"], ["strong", "p b"], [".first", ".last"], [".foo.bar", ".x .y"], [".x .y", ".foo.bar"], [".red.apple", ".red"], [".test1 .test2.test3", ".test1 .test4 .test5 .test6"], [".box.box-first", ".box"], ["#header", "#footer"], ["#header #menu", "#menu"], [".red", "div"], ["apple", "#SteveJobs"], [".item", "div ul li a"], ["div.article", "div b.blue"], [".item", "#menu div ul li a"], ["p", "*"]], "outputs": [["body p"], ["html"], ["p a"], ["div p span a b"], ["p b"], [".last"], [".x .y"], [".foo.bar"], [".red.apple"], [".test1 .test4 .test5 .test6"], [".box.box-first"], ["#footer"], ["#header #menu"], [".red"], ["#SteveJobs"], [".item"], ["div b.blue"], ["#menu div ul li a"], ["p"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,787 |
def compare(a, b):
|
f662ebc54999db784520bb76424fadfc | UNKNOWN | The number `198` has the property that `198 = 11 + 99 + 88, i.e., if each of its digits is concatenated twice and then summed, the result will be the original number`. It turns out that `198` is the only number with this property. However, the property can be generalized so that each digit is concatenated `n` times and then summed.
eg:-
```
original number =2997 , n=3
2997 = 222+999+999+777 and here each digit is concatenated three times.
original number=-2997 , n=3
-2997 = -222-999-999-777 and here each digit is concatenated three times.
```
Write afunction named `check_concatenated_sum` that tests if a number has this generalized property. | ["def check_concatenated_sum(n, r):\n return abs(n) == sum(int(e*r) for e in str(abs(n)) if r) ", "def check_concatenated_sum(number, n):\n return (10**n - 1)//9 * sum(map(int, str(abs(number)))) == abs(number)", "def check_concatenated_sum(num, n):\n return n and num % int('1' * n) == 0", "def check_concatenated_sum(num, n):\n m = abs(num)\n return m == sum(map(int, str(m))) * int('1' * n or 0)", "def check_concatenated_sum(num, l):\n return sum([int(x*l) for x in str(abs(num))]) == abs(num) if l>0 else False", "def check_concatenated_sum(number, k):\n return sum(int(d * k) for d in str(abs(number))) == abs(number) if k else False\n", "def check_concatenated_sum(num, n):\n num = abs(num)\n return sum(int(i*n) for i in str(num) if n)==num", "def check_concatenated_sum(a,b):\n if not b:return False\n c=abs(a)\n d=[int(f\"{(a<0)*'-'}{n*b}\") for n in str(c)]\n return sum(d)==a"] | {"fn_name": "check_concatenated_sum", "inputs": [[2997, 3], [-198, 2], [-13332, 4], [-9, 1], [198, 0], [123, 2], [123456789, 2]], "outputs": [[true], [true], [true], [true], [false], [false], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 928 |
def check_concatenated_sum(num, n):
|
ecaa7b69e6867a50f96c8fbfb9fceb43 | UNKNOWN | DNA sequencing data can be stored in many different formats. In this Kata, we will be looking at SAM formatting. It is a plain text file where every line (excluding the first header lines) contains data about a "read" from whatever sample the file comes from. Rather than focusing on the whole read, we will take two pieces of information: the cigar string and the nucleotide sequence.
The cigar string is composed of numbers and flags. It represents how the read aligns to what is known as a reference genome. A reference genome is an accepted standard for mapping the DNA.
The nucleotide sequence shows us what bases actually make up that section of DNA. They can be represented with the letters A, T, C, or G.
Example Read: ('36M', 'ACTCTTCTTGCGAAAGTTCGGTTAGTAAAGGGGATG')
The M in the above cigar string stands for "match", and the 36 stands for the length of the nucleotide sequence. Since all 36 bases are given the 'M' distinction, we know they all matched the reference.
Example Read: ('20M10S', 'ACTCTTCTTGCGAAAGTTCGGTTAGTAAAG')
In the above cigar string, only 20 have the "M" distinction, but the length of the actual string of nucleotides is 30. Therefore we know that read did not match the reference. (Don't worry about what the other letters mean. That will be covered in a later kata.)
Your job for this kata is to create a function that determines whether a cigar string fully matches the reference and accounts for all bases. If it does fully match, return True. If the numbers in the string do not match the full length of the string, return 'Invalid cigar'. If it does not fully match, return False.
*Note for C++: Return True, False, or Invalid cigar as strings* | ["import re\n\ndef is_matched(read):\n total = sum([int(num) for num in re.findall(r'\\d+', read[0])])\n \n if read[0] == str(len(read[1])) + 'M':\n return True\n elif len(read[1]) != total:\n return 'Invalid cigar'\n else:\n return False\n", "import re\n\ndef is_matched(read):\n cigar, seq = read\n matches = re.findall(r'(\\d+)([A-Z])', cigar)\n if sum(int(n) for n, _ in matches) != len(seq):\n return 'Invalid cigar'\n return all(sym == 'M' for _, sym in matches)", "import re\ndef is_matched(read):\n if f'{len(read[1])}M' == read[0]:\n return True\n elif sum(int(n) for n in re.findall('\\d+', read[0])) != len(read[1]):\n return 'Invalid cigar'\n \n return False", "import re\nfrom functools import reduce\n\ndef is_matched(read):\n parse = re.findall(r'[0-9]+[A-Z]', read[0])\n cigar = {}\n for i in parse:\n if cigar.get(i[-1]) == None:\n cigar[i[-1]] = 0\n cigar[i[-1]] += int(i[:-1])\n if cigar.get('M') == len(read[1]):\n return True\n elif reduce(lambda x,y: x+y, [v for v in cigar.values()], 0) == len(read[1]):\n return False\n else:\n return 'Invalid cigar'", "import re\n\ndef is_matched(cig):\n ci = re.split('\\D', cig[0])[:-1]\n return 'Invalid cigar' if sum(map(int, ci)) != len(cig[1]) else cig[0] == ci[0]+'M'", "import re\ndef is_matched(read):\n cigar = [int(i) for i in list(filter(None, re.split(\"[A-Z]\",read[0])))]\n if(sum(cigar)==len(read[1])):\n return (len(cigar)==1 and re.split(\"[0-9]+\",read[0])[1]==\"M\")\n else:\n return 'Invalid cigar'", "import re\ndef is_matched(read):\n num = re.compile(r'\\d+')\n a = list(map(int,num.findall(read[0])))\n Dna_length = sum(a[0:len(a)])\n if Dna_length != len(read[1]): \n return \"Invalid cigar\"\n else:\n return a[0] == len(read[1]) and str(a[0])+\"M\" == read[0]", "import re\ndef is_matched(read):\n res = [int(i) for i in re.findall(r\"\\d+\",read[0])]\n if sum(res) != len(read[1]):\n return \"Invalid cigar\"\n if len(res) == 1 and \"M\" in read[0]:\n return True\n return False", "import re\n\ndef is_matched(read):\n nums = [int(v) for v in re.findall(r'\\d+', read[0])]\n return 'Invalid cigar' if sum(nums)!=len(read[1]) else read[0]==f'{len(read[1])}M'"] | {"fn_name": "is_matched", "inputs": [[["36M", "CATAATACTTTACCTACTCTCAACAAATGCGGGAGA"]], [["10M6H", "GAGCGAGTGCGCCTTAC"]], [["12S", "TGTTTCTCCAAG"]]], "outputs": [[true], ["Invalid cigar"], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,387 |
def is_matched(read):
|
59466f6f3d17bc6c29683a27d8a85413 | UNKNOWN | Consider a sequence generation that follows the following steps. We will store removed values in variable `res`. Assume `n = 25`:
```Haskell
-> [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25] Let's remove the first number => res = [1]. We get..
-> [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]. Let's remove 2 (so res = [1,2]) and every 2-indexed number. We get..
-> [3,5,7,9,11,13,15,17,19,21,23,25]. Now remove 3, then every 3-indexed number. res = [1,2,3].
-> [5,7,11,13,17,19,23,25]. Now remove 5, and every 5-indexed number. res = [1,2,3,5]. We get..
-> [7,11,13,17,23,25]. Now remove 7 and every 7-indexed. res = [1,2,3,5,7].
But we know that there are no other 7-indexed elements, so we include all remaining numbers in res. So res = [1,2,3,5,7,11,13,17,23,25] and sum(res) = 107.
Note that when we remove every n-indexed number, we must remember that indices start at 0. So for every 3-indexed number above:
[3,5,7,9,11,13,15,17,19,21,23], we remove index0=3, index3= 9, index6=15,index9=21, etc.
Note also that if the length of sequence is greater than x, where x is the first element of the sequence, you should continue the remove step: remove x, and every x-indexed number until the length of sequence is shorter than x. In our example above, we stopped at 7 because the the length of the remaining sequence [7,11,13,17,23,25] is shorter than 7.
```
You will be given a number `n` and your task will be to return the sum of the elements in res, where the maximum element in res is `<= n`.
For example:
```Python
Solve(7) = 18, because this is the sum of res = [1,2,3,5,7].
Solve(25) = 107
```
More examples in the test cases.
Good luck! | ["def solve(n):\n zoznam = [int(i) for i in range (2,n+1)]\n res=[1]\n while zoznam != []:\n res.append(zoznam[0])\n del zoznam[0::zoznam[0]] \n return sum(res)", "def solve(n):\n presum, arr = 1, list(range(2, n + 1))\n while arr[0] < len(arr):\n presum += arr[0]\n del arr[::arr[0]]\n return presum + sum(arr)", "def solve(n):\n xs = list(range(2, n+1))\n res = 1\n while xs[0] < len(xs):\n res += xs[0]\n del xs[::xs[0]]\n return res + sum(xs)", "def solve(n):\n a = [1]\n n = list(range(2, n + 1))\n while len(n) > n[0]:\n nn = n[:]\n a.append(n[0])\n n = [i for z, i in enumerate(nn) if z % n[0] != 0 and z !=0]\n a+=n\n return sum(a)", "def solve(n):\n li,r = list(range(2, n + 1)),[1]\n while 1:\n r.append(li[0])\n if li[0] > len(li) : return sum(r+li[1:])\n li = [li[j] for j in range(1, len(li))if j % li[0] != 0]", "def solve(n):\n l, seq = [1], [i for i in range(2, n+1)]\n while l[-1] <= len(seq): l.append(seq.pop(0)); del seq[(l[-1]-1)::(l[-1])]\n return sum(l+seq) ", "def solve(n):\n res=[]\n x=list(range(2,n+1))\n while True:\n res.append(x.pop(0))\n if res[-1]> len(x): break\n for i in range(res[-1]-1,len(x),res[-1]): x[i] = 0\n x = [i for i in x if i ]\n if len(x)==0: break\n return 1+sum(res) + sum(x)", "def solve(n):\n r=[1,2]\n a=list(range(3,n+1,2))\n while(len(a)>a[0]):\n x=a[0]\n a=[y for i,y in enumerate(a) if i%x!=0]\n r.append(x)\n return sum(a+r)", "def solve(n):\n lst = list(range(2,n+1))\n res = [1]\n \n while lst and len(lst) > lst[0]:\n idx = lst[0]\n lst = [x for i,x in enumerate(lst) if i % idx]\n res.append(idx)\n \n return sum(res) + sum(lst)", "def solve(n):\n arr = [i+1 for i in range(n)]\n arr2 = list()\n\n while len(arr) >= 1 :\n arr2.append(arr[0])\n del arr[0]\n for j in range(1, n) :\n if arr2[-1] == 1 or (arr2[-1]*j)-j >= len(arr) :\n break\n else :\n del arr[(arr2[-1]*j)-j]\n sum = 0\n for i in arr2 :\n sum += int(i)\n return sum"] | {"fn_name": "solve", "inputs": [[7], [25], [50], [100], [1000], [10000]], "outputs": [[18], [107], [304], [993], [63589], [4721110]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,269 |
def solve(n):
|
a7c95ad6cba1441c62f971b15805f3e6 | UNKNOWN | # Task
Consider the following ciphering algorithm:
```
For each character replace it with its code.
Concatenate all of the obtained numbers.
```
Given a ciphered string, return the initial one if it is known that it consists only of lowercase letters.
Note: here the character's code means its `decimal ASCII code`, the numerical representation of a character used by most modern programming languages.
# Example
For `cipher = "10197115121"`, the output should be `"easy"`.
Explanation:
```
charCode('e') = 101,
charCode('a') = 97,
charCode('s') = 115
charCode('y') = 121.
```
# Input/Output
- `[input]` string `cipher`
A non-empty string which is guaranteed to be a cipher for some other string of lowercase letters.
- `[output]` a string | ["def decipher(cipher):\n out = \"\"\n while cipher:\n l = 2 if cipher[0] == \"9\" else 3\n out += chr(int(cipher[:l]))\n cipher = cipher[l:]\n return out", "import re\n\ndef decipher(cipher):\n return re.sub(r'1?\\d\\d', lambda m: chr(int(m.group())), cipher)\n", "import re\ndef decipher(cipher):\n return re.sub('1?\\d{2}',lambda m:chr(int(m.group())),cipher)", "def decipher(cipher):\n lst,it = [],iter(cipher)\n for c in it:\n lst.append(chr(int(''.join(\n (c, next(it), next(it)) if c=='1' else (c, next(it))\n ))))\n return ''.join(lst) ", "def decipher(cipher):\n answer = \"\"\n while cipher:\n l = 3 if cipher[0] == \"1\" else 2\n answer += chr(int(cipher[:l]))\n cipher = cipher[l:]\n return answer", "def decipher(cipher):\n s = ''\n while cipher != '':\n if int(cipher[:3]) <= 122:\n s += chr(int(cipher[:3]))\n cipher = cipher[3:]\n else:\n s += chr(int(cipher[:2]))\n cipher = cipher[2:]\n return s ", "def decipher(cipher):\n temp,aus = \"\",\"\"\n for dig in cipher:\n temp = temp + dig\n if int(temp) >= 97 and int(temp) <= 122:\n aus += chr(int(temp))\n temp = \"\"\n return aus", "from re import findall\ndef decipher(cipher):\n return \"\".join(chr(int(d)) for d in findall(\"9\\d|1[01]\\d|12[012]\",cipher))", "import re\ndef decipher(cipher):\n pattern = re.compile(r'[a-z]')\n num = ''\n code = ''\n for i in cipher:\n num += i\n ascii_char = chr(int(num))\n \n if pattern.search(ascii_char):\n code += ascii_char\n num = ''\n \n return code\n", "import re\n\ndef decipher(cipher):\n return ''.join(chr(int(x)) for x in re.findall(r'1\\d\\d|\\d\\d', cipher))"] | {"fn_name": "decipher", "inputs": [["10197115121"], ["98"], ["122"]], "outputs": [["easy"], ["b"], ["z"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,903 |
def decipher(cipher):
|
37e57c7c03fcbab58b6a9a0e0bbe9d39 | UNKNOWN | One suggestion to build a satisfactory password is to start with a memorable phrase or sentence and make a password by extracting the first letter of each word.
Even better is to replace some of those letters with numbers (e.g., the letter `O` can be replaced with the number `0`):
* instead of including `i` or `I` put the number `1` in the password;
* instead of including `o` or `O` put the number `0` in the password;
* instead of including `s` or `S` put the number `5` in the password.
## Examples:
```
"Give me liberty or give me death" --> "Gml0gmd"
"Keep Calm and Carry On" --> "KCaC0"
``` | ["SWAP = {'i': '1', 'I': '1', 'o': '0', 'O': '0', 's': '5', 'S': '5'}\n\n\ndef make_password(phrase):\n return ''.join(SWAP.get(a[0], a[0]) for a in phrase.split())\n", "def make_password(phrase):\n new = \"\"\n phrase = phrase.replace(\"i\", \"1\").replace(\"I\", \"1\")\n phrase = phrase.replace(\"o\", \"0\").replace(\"O\", \"0\")\n phrase = phrase.replace(\"s\", \"5\").replace(\"S\", \"5\")\n phrase = phrase.split(\" \")\n for i in phrase:\n new += i[0]\n return new", "def make_password(phrase, mapping=dict(['i1', 'o0', 's5'])):\n return ''.join(mapping.get(c.lower(), c) for c, *rest in phrase.split())\n", "TABLE = str.maketrans('iIoOsS','110055')\n\ndef make_password(s):\n return ''.join(w[0] for w in s.split()).translate(TABLE)", "def make_password(phrase):\n \n return ''.join(w[0] for w in phrase.split()).translate(str.maketrans('iIoOsS', '110055'))", "def make_password(phrase):\n return ''.join([w[0] for w in phrase.split()]).translate(str.maketrans('iIoOsS','110055'))\n", "def make_password(phrase):\n phrase = phrase.split(\" \")\n password = \"\"\n for word in phrase:\n password += word[0]\n password = password.replace(\"I\", \"1\").replace(\"i\", \"1\")\n password = password.replace(\"O\", \"0\").replace(\"o\", \"0\")\n password = password.replace(\"S\", \"5\").replace(\"s\", \"5\")\n return password", "def make_password(phrase):\n return ''.join(i[0] for i in phrase.split()).translate(str.maketrans('sioSIO', '510510'))", "make_password = lambda s, x='ios':''.join((lambda f:'105'[f]*(f>-1))(x.find(e[0].lower())) or e[0] for e in s.split())"] | {"fn_name": "make_password", "inputs": [["Give me liberty or give me death"], ["Keep Calm and Carry On"]], "outputs": [["Gml0gmd"], ["KCaC0"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,649 |
def make_password(phrase):
|
21a3c3d0357383a8f072ebd640530088 | UNKNOWN | Hofstadter sequences are a family of related integer sequences, among which the first ones were described by an American professor Douglas Hofstadter in his book Gödel, Escher, Bach.
### Task
Today we will be implementing the rather chaotic recursive sequence of integers called Hofstadter Q.
The Hofstadter Q is defined as:
As the author states in the aforementioned book:It is reminiscent of the Fibonacci definition in that each new value is a sum of two
previous values-but not of the immediately previous two values. Instead, the two
immediately previous values tell how far to count back to obtain the numbers to be added
to make the new value.
The function produces the starting sequence:
`1, 1, 2, 3, 3, 4, 5, 5, 6 . . .`
Test info: 100 random tests, n is always positive
Good luck! | ["def hofstadter_Q(n):\n try:\n return hofstadter_Q.seq[n]\n except IndexError:\n ans = hofstadter_Q(n - hofstadter_Q(n - 1)) + hofstadter_Q(n - hofstadter_Q(n - 2))\n hofstadter_Q.seq.append(ans)\n return ans\nhofstadter_Q.seq = [None, 1, 1]", "def hofstadter_Q(n):\n q = [1, 1]\n while len(q) < n:\n q.append(q[-q[-1]] + q[-q[-2]])\n return q[-1]", "def hofstadter_Q(n):\n lst = [0,1,1]\n while len(lst) <= n: lst += [ lst[-lst[-1]] + lst[-lst[-2]] ]\n return lst[n]", "def hofstadter_Q(n):\n a = [None, 1, 1]\n for i in range(3, n + 1):\n a.append(a[(i - a[-1])] + a[i - a[-2]])\n return a.pop()", "li = [1, 1]\nwhile len(li) != 1000 : li.append(li[-li[-1]] + li[-li[-2]])\nhofstadter_Q=lambda n:li[n-1]", "import sys; sys.setrecursionlimit(10000)\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef Q(n):\n if n <= 2:\n return 1\n return Q(n - Q(n-1)) + Q(n - Q(n-2))\n \ndef hofstadter_Q(n):\n return Q(n)", "memory = {1:1, 2:1}\ndef hofstadter_Q(n):\n if n not in memory.keys():\n memory[n] = hofstadter_Q(n-hofstadter_Q(n-1)) + hofstadter_Q(n-hofstadter_Q(n-2))\n return memory[n]", "hofstadter_Q_values = [0, 1, 1]\n\ndef hofstadter_Q(n):\n values = hofstadter_Q_values\n for i in range(len(values), n + 1):\n values.append(\n values[i - values[i - 1]] +\n values[i - values[i - 2]])\n return values[n]", "def hofstadter_Q(n):\n a=[1,1]\n for i in range(2,n):\n a.append(a[i-a[i-1]]+a[i-a[i-2]])\n return a[n-1]", "from functools import lru_cache\n@lru_cache(maxsize = 1024)\ndef hofstadter_Q(n):\n if n in (1, 2):\n return 1\n return hofstadter_Q(n-hofstadter_Q(n-1))+hofstadter_Q(n-hofstadter_Q(n-2))\n# Precompute to cache values and avoid exceeding too deep recursion\nfor i in range(100, 1000, 100):\n hofstadter_Q(i)"] | {"fn_name": "hofstadter_Q", "inputs": [[1], [3], [7], [10], [100], [1000]], "outputs": [[1], [2], [5], [6], [56], [502]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,923 |
def hofstadter_Q(n):
|
6034b68de1ee14776b32ababaee812cc | UNKNOWN | It's 3AM and you get the dreaded call from a customer: the program your company sold them is hanging. You eventually trace the problem down to a call to a function named `mystery`. Usually, `mystery` works fine and produces an integer result for an integer input. However, on certain inputs, the `mystery` function just locks up.
Unfortunately, the `mystery` function is part of a third-party library, and you don't have access to the source code. Uck. It may take a while to get support from the provider of the library, and in the meantime, your customer is getting frustrated.
Your mission, should you choose to accept it, is to create a new function called `wrap_mystery` that returns the same results as `mystery`, but does not hang. Since you're not sure exactly what values `mystery` should be returning for hangs, just have `wrap_mystery` return -1 for problematic input. Your customer is counting on you!
`wrap_mystery` will only be called with positive integers less than 1,000,000. | ["def mystery_solved(n):\n \"\"\"\nRecreated mystery function from bytecode using the dis module.\n How to print the bytecode: import dis\n print(dis.dis(mystery)) \n Apparently, \n the function is a wrong implementation of the 5n+1 problem -> \n https://math.stackexchange.com/questions/14569/the-5n1-problem\n http://www.sciencedirect.com/science/article/pii/S0304414905001602\n \"\"\"\n c=0\n while(n != 1 and n != 13 and n < 1000000): # Should have \"n != 17\" too.\n c=c+1\n # Without the line below the function hangs for some n > 0.\n if(n==17): return -1\n if (n&1): \n n=n+n+n+n+n+1 # n = 5n+1 \n continue\n n=n>>1 # n = n/2\n return c\n \ndef wrap_mystery(n): return mystery_solved(n)", "def mystery(n):\n c,seen = 0,set()\n while n != 1 and n != 13 and n < 1000000:\n c += 1\n if n & 1:\n n = n + n + n + n + n + 1\n else:\n n = n >> 1\n if n not in seen:\n seen.add(n)\n else:\n return -1\n return c\n \ndef wrap_mystery(n):\n return mystery(n)", "import time\n\ndef mystery(n):\n c = 0\n begin = time.time()\n end = time.time()\n limit=0.2\n while n != 1 and n != 13 and n < 1000000 and end-begin<limit:\n c += 1\n if n & 1:\n n = n + n + n + n + n + 1\n else:\n n = n >> 1\n end = time.time()\n return (c,-1)[end-begin>limit]\n\ndef wrap_mystery(n):\n return mystery(n)\n"] | {"fn_name": "wrap_mystery", "inputs": [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [18], [19], [20], [21], [22], [23], [24], [25], [26], [28], [29], [30], [31], [32], [33], [35], [36], [37], [38], [39], [40], [41], [42], [44], [45], [46], [47], [48], [49], [50], [51], [52], [53], [55], [56], [57], [58], [59], [60], [61], [62], [63], [64], [65], [66], [67], [69], [70], [71], [72], [73], [74], [75], [76], [77], [78], [79], [80], [81], [82], [83], [84], [85], [87], [88], [89], [90], [91], [92], [93], [94], [95], [96], [97], [98], [99], [100], [101], [102], [103], [104], [105], [106], [107], [109], [110], [111], [112], [113], [114], [115], [116], [117], [118], [119], [120], [121], [122], [123], [124], [125], [126], [127], [128], [129], [130], [131], [132], [133], [134], [135], [137], [138], [139], [140], [141], [142], [143], [144], [145], [146], [147], [148], [149], [150], [151], [152], [153], [154], [155], [156], [157], [158], [159], [160], [161], [162], [163], [164], [165], [166], [167], [168], [169], [170], [171], [173], [174], [175], [176], [177], [178], [179], [180], [181], [182], [183], [184], [185], [186], [187], [188], [189], [190], [191], [192], [193], [194], [195], [196], [197], [198], [199], [200], [201], [202], [203], [204], [205], [206], [207], [208], [209], [210], [211], [212], [213], [214], [215], [217], [218], [219], [220], [221], [222], [223], [224], [225], [226], [227], [228], [229], [230], [231], [232], [233], [234], [235], [236], [237], [238], [239], [240], [241], [242], [243], [244], [245], [246], [247], [248], [249], [250], [251], [252], [253], [254], [255], [256], [257], [258], [259], [260], [261], [262], [263], [264], [265], [266], [267], [268], [269], [270], [271], [273], [274], [276], [277], [278], [279], [280], [281], [282], [283], [284], [285], [286], [287], [288], [289], [290], [291], [292], [293], [294], [295], [296], [297], [298], [299], [17], [27], [34], [43], [54], [68], [86], [108], [136], [172], [216], [272], [275]], "outputs": [[0], [1], [5], [2], [2], [6], [65], [3], [62], [3], [69], [7], [0], [66], [14], [4], [63], [11], [4], [63], [70], [60], [8], [80], [1], [67], [57], [15], [67], [5], [8], [74], [64], [51], [12], [64], [5], [38], [64], [71], [95], [61], [58], [9], [61], [81], [9], [2], [61], [35], [68], [78], [58], [55], [16], [121], [68], [78], [6], [16], [9], [68], [32], [75], [109], [65], [55], [52], [62], [13], [55], [65], [75], [6], [59], [39], [6], [65], [36], [96], [72], [106], [96], [82], [62], [49], [59], [26], [10], [20], [62], [72], [82], [26], [10], [36], [3], [53], [62], [72], [93], [36], [103], [69], [93], [79], [69], [59], [39], [56], [23], [17], [46], [122], [59], [69], [132], [79], [53], [7], [33], [17], [43], [10], [59], [69], [129], [37], [33], [100], [76], [43], [110], [76], [66], [120], [56], [66], [53], [20], [63], [46], [14], [119], [56], [24], [66], [43], [76], [50], [7], [86], [60], [14], [40], [47], [7], [77], [66], [126], [37], [76], [30], [97], [44], [73], [87], [107], [73], [97], [47], [83], [53], [63], [57], [50], [43], [60], [43], [27], [53], [11], [53], [21], [126], [63], [34], [73], [47], [83], [24], [27], [57], [11], [83], [37], [67], [4], [74], [54], [14], [63], [34], [73], [64], [54], [94], [41], [37], [113], [104], [104], [70], [80], [94], [114], [80], [50], [70], [104], [60], [47], [40], [70], [57], [37], [24], [50], [18], [90], [47], [18], [123], [51], [60], [77], [70], [44], [133], [47], [80], [24], [54], [80], [8], [31], [34], [64], [18], [90], [44], [51], [11], [57], [60], [81], [70], [61], [130], [70], [91], [38], [34], [81], [101], [101], [77], [74], [44], [91], [111], [120], [77], [64], [67], [101], [121], [87], [57], [37], [67], [64], [54], [131], [21], [47], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1], [-1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,635 |
def wrap_mystery(n):
|
73ba538a2edea489652239b1e724acaf | UNKNOWN | Mr. Scrooge has a sum of money 'P' that he wants to invest. Before he does, he wants to know how many years 'Y' this sum 'P' has to be kept in the bank in order for it to amount to a desired sum of money 'D'.
The sum is kept for 'Y' years in the bank where interest 'I' is paid yearly. After paying taxes 'T' for the year the new sum is re-invested.
Note to Tax: not the invested principal is taxed, but only the year's accrued interest
Example:
Let P be the Principal = 1000.00
Let I be the Interest Rate = 0.05
Let T be the Tax Rate = 0.18
Let D be the Desired Sum = 1100.00
After 1st Year -->
P = 1041.00
After 2nd Year -->
P = 1083.86
After 3rd Year -->
P = 1128.30
Thus Mr. Scrooge has to wait for 3 years for the initial principal to amount to the desired sum.
Your task is to complete the method provided and return the number of years 'Y' as a whole in order for Mr. Scrooge to get the desired sum.
Assumption: Assume that Desired Principal 'D' is always greater than the initial principal. However it is best to take into consideration that if Desired Principal 'D' is equal to Principal 'P' this should return 0 Years. | ["def calculate_years(principal, interest, tax, desired):\n years = 0\n \n while principal < desired:\n principal += (interest * principal) * (1 - tax)\n years += 1\n \n return years\n", "from math import ceil, log\n\ndef calculate_years(principal, interest, tax, desired):\n if principal >= desired: return 0\n \n return ceil(log(float(desired) / principal, 1 + interest * (1 - tax)))\n", "def calculate_years(principal, interest, tax, desired):\n years = 0\n if principal == desired:\n return years\n while principal < desired:\n x = principal * interest\n y = x * tax\n principal = principal + x - y\n years += 1\n return years\n", "from math import ceil, log\n\ndef calculate_years(principal, interest, tax, desired):\n return ceil(log(float(desired) / principal, 1 + interest * (1 - tax)))", "def calculate_years(principal, interest, tax, desired):\n year = 0\n while (principal < desired):\n increment = principal * interest * (1-tax)\n principal = principal + increment\n year = year + 1\n return year", "import math\n\ndef calculate_years(principal, interest, tax, desired):\n return 0 if principal >= desired else math.ceil((math.log(desired) - math.log(principal))/math.log(1+interest*(1-tax)))", "def calculate_years(p, i, t, d, n=0):\n if p >= d:\n return n\n p = p + p * i * (1 - t)\n return calculate_years(p, i, t, d, n+1)", "def calculate_years(principal, interest, tax, desired):\n return 0 if principal >= desired else 1 + calculate_years(principal * (1+interest*(1-tax)), interest, tax, desired)", "def calculate_years(principal, interest, tax, desired):\n \n years = 0\n \n while principal < desired : \n years += 1\n principal = principal + (principal*interest) - (principal*interest*tax)\n \n return years", "calculate_years = lambda p,i,t,d,n=0: calculate_years(p+(p*i*(1-t)),i,t,d,n+1) if p<d else n", "from math import ceil, log\ndef calculate_years(P, I, T, D):\n return ceil((log(D)-log(P))/log(1+I*(1-T)))", "def calculate_years(principal, interest, tax, desired):\n y=0\n while principal<desired:\n extra=principal*interest\n principal+=extra-tax*extra\n y+=1\n return y", "from math import ceil, log\n\ndef calculate_years(p, i, t, d):\n x = float(d) / p\n base = 1 + (i * (1 - t))\n return ceil(log(x, base))\n\n #return ceil(log(float(d) / p, 1 + (i * (1 - t))))\n", "def calculate_years(principal, interest, tax, desired):\n x = 0\n while principal < desired:\n add = principal * interest\n add = add - (add * tax)\n principal = principal + add\n x = x + 1\n return x", "import math\ndef calculate_years(principal, interest, tax, desired):\n x = (float(desired)/float(principal))\n base = (1 + (float(interest) * ( 1 - float(tax))))\n years = math.log(x, base)\n return math.ceil(years)\n", "def calculate_years(sum, intr, tax, goal):\n year, fix = 0, intr * (1 - tax) + 1\n while sum < goal:\n year += 1\n sum *= fix\n return year\n", "def calculate_years(principal, interest, tax, desired):\n if desired == principal:\n return 0\n else:\n years = 0\n while principal < desired:\n principal += (principal * interest) - (principal * interest * tax)\n years += 1\n return years\n\n\n", "def calculate_years(principal, interest, tax, desired):\n year = 0\n while principal < desired:\n realint = principal * interest\n realtax = realint * tax\n principal = principal + realint - realtax\n year += 1\n return year", "import math\ndef calculate_years(principal, interest, tax, desired): \n #if principal is lower than zero, than error with return code -1\n return -1 if principal < 0 else math.ceil(math.log(float(desired) / principal if principal else 1, 1 + interest * (1 - tax)))", "def calculate_years(principal, interest, tax, desired):\n if principal == desired:\n return 0\n p = principal\n y = 0\n fixed = (1 + interest * (1 - tax))\n while p < desired:\n p *= fixed\n y += 1\n return y\n", "def calculate_years(principal, interest, tax, desired):\n year = 0 \n while principal < desired:\n year = year + 1\n interest_beforetax = interest * principal\n principal = principal + ((1 - tax) * interest_beforetax)\n \n return year\n \n \n \n \n", "def calculate_years(principal, interest, tax, desired):\n y = 0\n while desired > principal:\n y += 1\n principal = principal*(1+interest)-principal*interest*tax\n return y", "def calculate_years(principal, interest, tax, desired):\n years = 0\n \n while principal < desired:\n a = principal * interest\n principal += a - (a * tax)\n years += 1\n \n return years", "def calculate_years(principal, interest, tax, desired):\n years = 0\n while principal < desired:\n years += 1\n principal += principal * interest * ( 1 - tax)\n return years", "calculate_years=lambda principal, interest, tax, desired, count=0: count if principal >= desired else calculate_years(principal * (1 + interest * (1 - tax)), interest, tax, desired, count + 1)\n", "def calculate_years(p, i, t, d):\n y = 0\n while p < d:\n p = p + p*i - p*i*t\n y += 1\n return y", "from math import log, ceil\n\n\ndef calculate_years(principal, interest, tax, desired):\n return ceil(log(float(desired)/principal, 1 + interest * (1 - tax)))", "def calculate_years(p, i, t, d):\n years = 0\n while p < d: \n p = (p*(1+i) - p*i*t)\n years += 1\n return years", "import math\n\n\ndef calculate_years(principal, interest, tax, desired):\n year = 0\n if int(principal) >= int(desired):\n return (year)\n while principal <= desired:\n principal = (principal +(principal * interest)) - ((principal * interest)* tax)\n year += 1\n if int(principal) >= int(desired):\n return (year)\n", "def calculate_years(principal, interest, tax, desired):\n years = 0\n gain = 0\n taxed = 0\n while principal < desired:\n years = years + 1\n gain = principal * interest\n taxed = gain * tax\n principal = principal + gain - taxed\n \n \n \n \n \n return years\n raise NotImplementedError(\"TODO: calculate_years\")\n", "import math\n\ndef calculate_years(principal, interest, tax, desired):\n if principal != desired:\n return int(math.log((desired*(1+interest-interest*tax))/(principal+principal*interest*(1-tax)), 1+interest-interest*tax))+1\n else:\n return 0", "def calculate_years(principal, interest, tax, desired,years=0):\n if principal >= desired:\n return years\n principal += (principal * interest) * (1.0-tax )\n return calculate_years( principal, interest, tax, desired, years + 1 )\n \n", "import math\n\ndef calculate_years(principal, interest, tax, desired):\n # P(1+IT)^Y = D\n return math.ceil(math.log(desired*1.0/principal, 1+interest*(1-tax)))\n \n", "def calculate_years(principal, interest, tax, desired):\n\n if(principal >= desired):\n return 0\n else:\n gain = principal * interest\n taxed = gain * tax\n new_sum = principal + gain - taxed\n return 1 + calculate_years(new_sum, interest, tax, desired)", "def calculate_years(p, i, t, d): \n y = 0\n while p < d:\n p += p*(i*(1-t))\n y += 1\n return y", "def calculate_years(principal, interest, tax, desired):\n years = 0\n while principal < desired:\n principal = principal * (1 + 1 * interest * (1 - tax))\n years += 1\n return years", "def calculate_years(principal, interest, tax, desired):\n# raise NotImplementedError(\"TODO: calculate_years\")\n years = 0\n if desired <= principal:\n return 0\n total_summ = principal\n while total_summ <= desired:\n\n summ_year = total_summ*interest\n summ_tax = summ_year * tax\n total_summ += summ_year - summ_tax\n print(total_summ)\n years += 1\n if total_summ >= desired:\n return years\n\n", "def calculate_years(p, i, t, d):\n y = 0\n while p < d:\n y += 1\n cur_i = (p * i) * (1 - t)\n p += cur_i\n return y\n \n", "def calculate_years(P, I, T, D):\n total = []\n while P < D:\n x = P*I\n y = x*T\n z = P+(x-y)\n total.append(z)\n P = z\n return len(total)\n", "def calculate_years(principal, interest, tax, desired):\n years_required = 0\n current = principal\n while (current<desired):\n current+=current*interest*(1-tax)\n years_required+=1\n return years_required\n", "def calculate_years(p, i, t, d):\n \n c = 0\n \n while p < d:\n p += (p * i) + (p * i) * - t\n c += 1\n\n return c\n", "def calculate_years(principal, interest, tax, desired):\n year_counter = 0\n while principal < desired:\n year_counter += 1\n principal += principal * interest * (1-tax)\n return year_counter", "def calculate_years(principal, interest, tax, desired):\n current = principal\n years = 0\n while current < desired:\n currentstep = (current * (1 + interest))\n taxloss = (currentstep - current) * tax\n current = currentstep - taxloss\n years += 1\n return years\n", "def calculate_years(principal, interest, tax, desired):\n import math\n count = 1\n compounding = principal*interest*(1-tax) + principal\n if desired==principal:\n return 0\n while compounding < desired: \n compounding = (compounding*interest*(1-tax) + compounding)\n count +=1\n return count\n \n", "def calculate_years(principal, interest, tax, desired):\n years = 0\n if principal >= desired: return 0\n while True:\n yearly_interest = principal * interest\n principal = principal + yearly_interest - yearly_interest * tax\n years += 1\n if principal >= desired: break\n return years", "def calculate_years(principal, interest, tax, desired):\n years = 0\n if principal == desired:\n return years\n else:\n while principal < desired:\n years += 1\n principal = principal + (principal * interest) * (1 - tax)\n return years", "def calculate_years(prin, inter, tax, desired):\n yrs = 0\n while prin < desired: \n prin = (prin*(1+(inter*(1-tax))))\n yrs += 1\n return yrs", "import math\ndef calculate_years(principal, interest, tax, desired):\n # desired = principal*(1+(interest)*(1-tax))**n\n # desired/principal = (1+interest*(1-tax))**n\n # n = ln(d/p)/ln(1+eff Interest Rate)\n # return int(n)+1 if n>0 else 0\n effInt = interest*(1-tax)\n timeFloat = math.log(desired/principal)/math.log(1+effInt)\n if desired>principal:\n return int(timeFloat)+1\n else:\n return 0\n", "def calculate_years(principal, interest, tax, desired):\n \n year_count = 0\n \n while principal < desired:\n principal += (interest * principal) * (1 - tax)\n \n year_count += 1\n \n return year_count\n"] | {"fn_name": "calculate_years", "inputs": [[1000, 0.05, 0.18, 1100], [1000, 0.01625, 0.18, 1200], [1000, 0.05, 0.18, 1000]], "outputs": [[3], [14], [0]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 11,477 |
def calculate_years(principal, interest, tax, desired):
|
68cc6edebe66ade2a9d402ce0cd1731c | UNKNOWN | ### Background
We **all** know about "balancing parentheses" (plus brackets, braces and chevrons) and even balancing characters that are identical.
Read that last sentence again, I balanced different characters and identical characters twice and you didn't even notice... :)
### Kata
Your challenge in this kata is to write a piece of code to validate that a supplied string is balanced.
You must determine if all that is open is then closed, and nothing is closed which is not already open!
You will be given a string to validate, and a second string, where each pair of characters defines an opening and closing sequence that needs balancing.
You may assume that the second string always has an even number of characters.
### Example
```python
# In this case '(' opens a section, and ')' closes a section
is_balanced("(Sensei says yes!)", "()") # => True
is_balanced("(Sensei says no!", "()") # => False
# In this case '(' and '[' open a section, while ')' and ']' close a section
is_balanced("(Sensei [says] yes!)", "()[]") # => True
is_balanced("(Sensei [says) no!]", "()[]") # => False
# In this case a single quote (') both opens and closes a section
is_balanced("Sensei says 'yes'!", "''") # => True
is_balanced("Sensei say's no!", "''") # => False
``` | ["def is_balanced(s, caps):\n stack = []\n openers, closers = caps[::2], caps[1::2]\n for char in s:\n if char in openers:\n if char in closers and stack and stack[-1] == char:\n stack.pop()\n else:\n stack.append(char)\n elif char in closers:\n if not stack or openers[closers.index(char)] != stack[-1]:\n return False\n else:\n stack.pop()\n return not stack", "from itertools import cycle \n\ndef is_balanced(source, caps, i = 0):\n it = iter(cycle([ caps[i: i +2] for i in range(0, len(caps), 2) ]) )\n cl = ''.join([ e for e in source if e in caps ] )\n while i<len(source):\n if not cl: return True\n n = next(it)\n if n in cl: cl = cl.replace(n,'')\n i += 1\n return False\n", "def is_balanced(verify, pairs):\n opened,closed,records,same = [],[],[],[]\n for i in range(0, len(pairs), 2):\n opened.append(pairs[i])\n closed.append(pairs[i + 1])\n for i in verify:\n if i in opened and i in closed : same.append(not verify.count(i) & 1)\n elif i in opened : records.append(i)\n elif i in closed:\n if not records:return 0\n if records[-1] == opened[closed.index(i)] : records.pop()\n return not records and all(same)", "def is_balanced(source, caps):\n oldLen, source = len(source), ''.join( l for l in source if l in caps )\n while oldLen != len(source):\n oldLen = len(source)\n for i in range(0,len(caps),2):\n source = source.replace(caps[i:i+2],'')\n return len(source)==0", "def is_balanced(source, caps):\n matches = dict([(b,a) for a,b in zip(caps[::2],caps[1::2]) ])\n source = [char for char in source if char in caps]\n stack = []\n for char in source:\n if len(stack) == 0: stack.append(char)\n elif matches.get(char) == stack[-1]: del stack[-1]\n else: stack.append(char)\n return len(stack) == 0", "from functools import reduce\ndef is_balanced(source, caps):\n _map = {c2:c1 for c1, c2 in zip(caps[0::2], caps[1::2])}\n red = lambda s, e: s[:-1] if s and s[-1] == _map.get(e) else s + e\n return not reduce(red, [c for c in source if c in caps], '')\n", "def is_balanced(s, caps):\n s = ''.join(i for i in s if i in caps)\n caps = [caps[i:i+2] for i in range(0,len(caps),2)]\n prev = ''\n while s != prev:\n prev = s\n for c in caps:\n s = s.replace(c,'')\n return not s"] | {"fn_name": "is_balanced", "inputs": [["(Sensei says yes!)", "()"], ["(Sensei says no!", "()"], ["(Sensei [says] yes!)", "()[]"], ["(Sensei [says) no!]", "()[]"], ["Sensei says -yes-!", "--"], ["Sensei -says no!", "--"], ["Hello Mother can you hear me?", "()"], ["(Hello Mother can you hear me?)", "()"], ["(Hello Mother can you hear me?", ""], ["(Hello Mother can you hear me?", "()"], ["(Hello Mother can you hear me?))", "()"], [")Hello Mother can you hear me?", "()"], ["(Hello Mother can you hear me?)[Monkeys, in my pockets!!]", "()[]"], ["(Hello Mother can you hear me?)[Monkeys, in my pockets!!](Gosh!!)", "()[]"], ["Hello Mother can you hear me?)[Monkeys, in my pockets!!]", "()[]"], ["(Hello Mother can you hear me?[Monkeys, in my pockets!!]", "()[]"], ["(Hello Mother can you hear me?)Monkeys, in my pockets!!]", "()[]"], ["(Hello Mother can you hear me?)[Monkeys, in my pockets!!", "()[]"], ["((Hello))", "()"], ["(((Hello)))", "()"], ["((()Hello()))", "()"], ["((()Hello())", "()"], ["(()Hello()))", "()"], ["([{-Hello!-}])", "()[]{}"], ["([{([{Hello}])}])", "()[]{}"], ["([{-Hello!-})]", "()[]{}"], ["-Hello Mother can you hear me?-", "--"], ["-Hello Mother can you hear me?", "--"], ["Hello Mother can you hear me?-", "--"], ["-abcd-e@fghi@", "--@@"], ["abcd-e@fghi@", "--@@"], ["-abcde@fghi@", "--@@"], ["-abcd-efghi@", "--@@"], ["-abcd-e@fghi", "--@@"], ["-a@b@cd@e@fghi-", "--@@"], ["-ab@cd@e@fghi-", "--@@"], ["-a@bcd@e@fghi-", "--@@"], ["-a@b@cde@fghi-", "--@@"], ["-a@b@cd@efghi-", "--@@"], ["a@b@cd@e@fghi-", "--@@"], ["-a@b@cd@e@fghi", "--@@"]], "outputs": [[true], [false], [true], [false], [true], [false], [true], [true], [true], [false], [false], [false], [true], [true], [false], [false], [false], [false], [true], [true], [true], [false], [false], [true], [true], [false], [true], [false], [false], [true], [false], [false], [false], [false], [true], [false], [false], [false], [false], [false], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,551 |
def is_balanced(source, caps):
|
e7aad9f87dd58ed47d4d4eb6525b2b49 | UNKNOWN | You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item.
Implement a function `likes :: [String] -> String`, which must take in input array, containing the names of people who like an item. It must return the display text as shown in the examples:
```python
likes([]) # must be "no one likes this"
likes(["Peter"]) # must be "Peter likes this"
likes(["Jacob", "Alex"]) # must be "Jacob and Alex like this"
likes(["Max", "John", "Mark"]) # must be "Max, John and Mark like this"
likes(["Alex", "Jacob", "Mark", "Max"]) # must be "Alex, Jacob and 2 others like this"
```
For 4 or more names, the number in `and 2 others` simply increases. | ["def likes(names):\n n = len(names)\n return {\n 0: 'no one likes this',\n 1: '{} likes this', \n 2: '{} and {} like this', \n 3: '{}, {} and {} like this', \n 4: '{}, {} and {others} others like this'\n }[min(4, n)].format(*names[:3], others=n-2)", "def likes(names):\n if len(names) == 0:\n return \"no one likes this\"\n elif len(names) == 1:\n return \"%s likes this\" % names[0]\n elif len(names) == 2:\n return \"%s and %s like this\" % (names[0], names[1])\n elif len(names) == 3:\n return \"%s, %s and %s like this\" % (names[0], names[1], names[2])\n else:\n return \"%s, %s and %s others like this\" % (names[0], names[1], len(names)-2)", "def likes(names):\n # make a dictionary d of all the possible answers. Keys are the respective number\n # of people who liked it.\n \n # {} indicate placeholders. They do not need any numbers but are simply replaced/formatted\n # in the order the arguments in names are given to format\n # {others} can be replaced by its name; below the argument \"others = length - 2\"\n # is passed to str.format()\n d = {\n 0: \"no one likes this\",\n 1: \"{} likes this\",\n 2: \"{} and {} like this\",\n 3: \"{}, {} and {} like this\",\n 4: \"{}, {} and {others} others like this\"\n }\n length = len(names)\n # d[min(4, length)] insures that the appropriate string is called from the dictionary\n # and subsequently returned. Min is necessary as len(names) may be > 4\n \n # The * in *names ensures that the list names is blown up and that format is called\n # as if each item in names was passed to format individually, i. e.\n # format(names[0], names[1], .... , names[n], others = length - 2\n return d[min(4, length)].format(*names, others = length - 2)\n", "def likes(names):\n formats = {\n 0: \"no one likes this\",\n 1: \"{} likes this\",\n 2: \"{} and {} like this\",\n 3: \"{}, {} and {} like this\",\n 4: \"{}, {} and {others} others like this\"\n }\n n = len(names)\n return formats[min(n,4)].format(*names, others=n-2)\n", "def likes(names):\n if len(names) == 0:\n return 'no one likes this'\n elif len(names) == 1:\n return str(names[0]+' likes this')\n elif len(names) == 2:\n return str(names[0]+' and '+names[1]+' like this')\n elif len(names) == 3:\n return str(names[0]+', '+names[1]+' and '+names[2]+' like this')\n else:\n return str(names[0]+', '+names[1]+' and '+str(len(names)-2)+' others like this')", "def likes(names):\n \"\"\"Convert list of names into strings of likes\n\n Args:\n names (list): List of string names\n\n Returns:\n str\n\n Examples:\n >>> likes(['Pavel', 'Yury', 'Sveta'])\n 'Pavel, Yury and Sveta like this'\n \"\"\"\n if not names:\n return 'no one likes this'\n if len(names) == 1:\n first = ''\n second = names[0]\n elif len(names) == 2:\n first = names[0]\n second = names[1]\n elif len(names) == 3:\n first = ', '.join(names[:2])\n second = names[-1]\n else:\n first = ', '.join(names[:2])\n second = '%d others' % (len(names) - 2)\n if first:\n return first + ' and ' + second + ' like this'\n else:\n return second + ' likes this'", "def likes(names):\n l = len(names)\n if l == 0: return 'no one likes this'\n if l == 1: return '{} likes this'.format(names[0])\n if l == 2: return '{} and {} like this'.format(names[0], names[1])\n if l == 3: return '{}, {} and {} like this'.format(names[0], names[1], names[2])\n return '{}, {} and {} others like this'.format(names[0], names[1], len(names)-2)\n", "\ndef likes(names):\n output = {\n 0 : \"no one likes this\",\n 1 : \"{} likes this\",\n 2 : \"{} and {} like this\",\n 3 : \"{}, {} and {} like this\",\n 4 : \"{}, {} and {others} others like this\",\n }\n \n count = len(names)\n \n return output[min(4,count)].format(*names[:3], others=count-2)", "def likes(names):\n if not names:\n return \"no one likes this\"\n size = len(names)\n if size == 1:\n return \"%s likes this\" % names[0]\n if size == 2:\n return \"%s and %s like this\" % (names[0], names[1])\n if size == 3:\n return \"%s, %s and %s like this\" % (names[0], names[1], names[2])\n if size >= 4:\n return \"%s, %s and %s others like this\" % (names[0], names[1], len(names[2:]))", "def likes(names):\n l = len(names)\n s = 'no one likes this'\n \n if l == 1:\n s = names[0] + ' likes this'\n elif l == 2:\n s = ' and '.join(names) + ' like this'\n elif l == 3:\n s = ', '.join(names[:-1]) + ' and ' + names[-1] + ' like this'\n elif l != 0:\n s = ', '.join(names[:2]) + ' and ' + str(l - 2) + ' others like this'\n \n return s\n"] | {"fn_name": "likes", "inputs": [[[]], [["Peter"]], [["Jacob", "Alex"]], [["Max", "John", "Mark"]], [["Alex", "Jacob", "Mark", "Max"]]], "outputs": [["no one likes this"], ["Peter likes this"], ["Jacob and Alex like this"], ["Max, John and Mark like this"], ["Alex, Jacob and 2 others like this"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 5,069 |
def likes(names):
|
85786e3c2fd8817e5938896821374b51 | UNKNOWN | Your task is to convert a given number into a string with commas added for easier readability. The number should be rounded to 3 decimal places and the commas should be added at intervals of three digits before the decimal point. There does not need to be a comma at the end of the number.
You will receive both positive and negative numbers.
## Examples
```python
commas(1) == "1"
commas(1000) == "1,000"
commas(100.2346) == "100.235"
commas(1000000000.23) == "1,000,000,000.23"
commas(-1) == "-1"
commas(-1000000.123) == "-1,000,000.123"
``` | ["def commas(num):\n return \"{:,.3f}\".format(num).rstrip(\"0\").rstrip(\".\")", "def commas(num):\n return f'{num:,.3f}'.rstrip('0').rstrip('.')", "import re\n\ndef commas(num):\n if isinstance(num, int):\n return format(num, ',')\n else:\n return re.sub('\\.?0+$', '', format(round(num, 3), ',.3f'))\n", "def commas(num):\n i = round(num, 3)\n f = int(i)\n return f'{f if f==i else i:,}'", "def commas(s):\n s = round(s,3)\n return format([int(s),s][s!=int(s)],',')", "def commas(num):\n number = float(num)\n return f'{number:,.0f}' if number.is_integer() else f'{number:,.3f}'.rstrip('0').rstrip('.')\n \n", "def commas(num): \n n = format(round(num,3), \",\").split('.') \n return n[0] + '.' + n[1] if len(n)>1 and n[1]!='0' else n[0]\n", "def commas(num):\n return str('{:,.3f}'.format(num)).rstrip('0').rstrip('.')", "def commas(n):\n try: n = round(n, 3)\n except: print(\"Error\")\n res = \"{:,}\".format(n)\n print(res)\n if res.endswith('.0'): # I mean...\n return res[:-2]\n return res", "from re import sub\ncommas = lambda num: (lambda num: sub(\"(\\d)(?=(\\d{3})+(?!\\d))\", \"\\g<1>,\", str(int(num) if num%1==0 else num)))(round(num,3))"] | {"fn_name": "commas", "inputs": [[1], [1000], [100.2346], [1000000000.23], [9123.212], [-1], [-1000000.123], [-2000.0], [-999.9999], [-1234567.0001236]], "outputs": [["1"], ["1,000"], ["100.235"], ["1,000,000,000.23"], ["9,123.212"], ["-1"], ["-1,000,000.123"], ["-2,000"], ["-1,000"], ["-1,234,567"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,240 |
def commas(num):
|
789a83217f3d64b4828e0e4e830d20e6 | UNKNOWN | Consider the following expansion:
```Haskell
solve("3(ab)") = "ababab" -- "ab" repeats 3 times
solve("2(a3(b))" = "abbbabbb" -- "a3(b)" == "abbb" repeats twice.
```
Given a string, return the expansion of that string.
Input will consist of only lowercase letters and numbers (1 to 9) in valid parenthesis. There will be no letters or numbers after the last closing parenthesis.
More examples in test cases.
Good luck!
Please also try [Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2) | ["def solve(s):\n s1 = s[::-1]\n s2 = ''\n for i in s1:\n if i.isalpha():\n s2 += i\n elif i.isdigit():\n s2 = s2*int(i)\n return s2[::-1]", "import re\n\ndef solve(s):\n ops, parts = [], ['']\n for c in re.findall(r'\\d*\\(|\\)|[a-z]+', s):\n if c == ')':\n segment = parts.pop()\n parts[-1] += ops.pop()*segment\n elif not c[0].isalpha():\n ops.append(int(c[:-1]) if c[0] != '(' else 1)\n parts.append('')\n else:\n parts[-1] += c\n return parts[0]", "import re\n\ndef solve(st):\n matches = re.match(\"([a-z]*)(\\d*)\\((.*)\\)\", st)\n if not matches:\n return st\n return matches.group(1) + (int(matches.group(2)) if matches.group(2) else 1) * solve(matches.group(3))", "import re\n\ndef solve(s):\n return solve(re.sub(r'(\\d*)\\(([a-zA-Z]*)\\)', lambda m: m.group(2) * (1 if m.group(1) == \"\" else int(m.group(1))), s)) if re.search(r'(\\d*)\\(([a-zA-Z]*)\\)', s) != None else s", "def solve(s):\n while '(' in s:\n l, r = s.rsplit('(', 1)\n ss, r = r.split(')', 1)\n s = (l[:-1] + ss * int(l[-1]) + r ) if l[-1].isdigit() else l + ss + r\n return s\n", "def solve(st):\n tempstr = \"\"\n for i in reversed(st):\n if i.isalpha():\n tempstr += i\n if i.isdigit():\n tempstr = tempstr * int(i)\n return tempstr[::-1]", "def solve(st):\n strx = ''\n for i,x in enumerate(st):\n if x.isdigit():\n return strx + int(x)*solve(st[i+1:])\n if x.isalpha():\n strx += x\n return strx", "def solve(a):\n sta, exp = '', ''\n for i in a[::-1]:\n if i.isalnum() or i == '(':\n if i == '(':\n exp += sta\n sta = ''\n elif ord(i) in range(48, 58): exp = exp*int(i)\n else: sta += i\n return exp[::-1] if a[0].isnumeric() else a[0]+exp[::-1]", "def solve(st):\n st = st.replace('(','').replace(')','')\n i = len(st)\n while i:\n i -=1\n if st[i].isdigit():\n dg = int(st[i])\n ex = st[i+1:] * dg\n st = st[:i] + ex\n i += dg\n return st\n \n", "from re import sub\n\ndef solve(st):\n while True:\n st, tmp = sub(\"(\\d)*\\((\\w+)\\)\", lambda s: s.group(2)*int(s.group(1) or 1), st), st\n if st == tmp: return st"] | {"fn_name": "solve", "inputs": [["3(ab)"], ["2(a3(b))"], ["3(b(2(c)))"], ["k(a3(b(a2(c))))"]], "outputs": [["ababab"], ["abbbabbb"], ["bccbccbcc"], ["kabaccbaccbacc"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,447 |
def solve(st):
|
47cfc6e0a0cb418833945af71d2506d6 | UNKNOWN | A faro shuffle of a deck of playing cards is a shuffle in which the deck is split exactly in half and then the cards in the two halves are perfectly interwoven, such that the original bottom card is still on the bottom and the original top card is still on top.
For example, faro shuffling the list
```python
['ace', 'two', 'three', 'four', 'five', 'six']
```
gives
```python
['ace', 'four', 'two', 'five', 'three', 'six' ]
```
If 8 perfect faro shuffles are performed on a deck of 52 playing cards, the deck is restored to its original order.
Write a function that inputs an integer n and returns an integer representing the number of faro shuffles it takes to restore a deck of n cards to its original order.
Assume n is an even number between 2 and 2000. | ["def faro_cycles(n):\n x, cnt = 2, 1\n while x != 1 and n > 3:\n cnt += 1\n x = x*2 % (n-1)\n return cnt", "def faro_cycles(deck_size):\n arr, count = list(range(deck_size)), 0\n original_arr = arr\n while True:\n arr = arr[0:deck_size:2] + arr[1:deck_size:2]\n count += 1\n if original_arr == arr:\n break\n return count", "def faro_cycles(size):\n deck = list(range(size))\n cur, count = deck[::2] + deck[1::2], 1\n while cur != deck:\n cur, count = cur[::2] + cur[1::2], count + 1\n return count\n", "def faro_cycles(n):\n original = list(range(1,n+1))\n duplicate, c = original.copy(), 0\n while 1:\n first, bottom = duplicate[0], duplicate[-1]\n first_half = duplicate[1:n//2]\n second_half = duplicate[n//2:-1]\n duplicate = []\n for i,j in zip(first_half,second_half) : duplicate.extend([j,i])\n duplicate = [first]+duplicate+[bottom]\n c+=1\n if original==duplicate:return c", "def faro_cycles(deck_size):\n if deck_size == 2: return 1\n pos, output = 2, 1\n while pos != 1:\n pos = pos * 2 % (deck_size - 1)\n output += 1\n return output", "def faro_cycles(deck_size):\n pos=1\n for i in range(deck_size):\n pos = pos*2-(0 if pos<deck_size/2 else deck_size-1)\n if pos==1:\n return i+1", "def faro(xs):\n m = len(xs) // 2\n return [x for xs in zip(xs[:m], xs[m:]) for x in xs]\n\ndef faro_cycles(deck_size):\n xs = original = list(range(deck_size))\n n = 0\n while True:\n n += 1\n xs = faro(xs)\n if xs == original:\n return n", "def interv(list1, list2):\n out_list = []\n for el1, el2 in zip(list1, list2):\n out_list.append(el1)\n out_list.append(el2)\n return out_list \n \ndef faro_cycles(deck_size):\n original = [x for x in range(deck_size)]\n new = interv(original[:deck_size//2], original[deck_size//2:])\n n = 1\n while original!=new:\n new = interv(new[:deck_size//2], new[deck_size//2:])\n n += 1\n\n return n", "def faro_cycles(deck_size):\n return [None, 1, 2, 4, 3, 6, 10, 12, 4, 8, 18, 6, 11, 20, 18, 28, 5, 10, 12, 36, 12, 20, 14, 12, 23, 21, 8, 52, 20, 18, 58, 60, 6, 12, 66, 22, 35, 9, 20, 30, 39, 54, 82, 8, 28, 11, 12, 10, 36, 48, 30, 100, 51, 12, 106, 36, 36, 28, 44, 12, 24, 110, 20, 100, 7, 14, 130, 18, 36, 68, 138, 46, 60, 28, 42, 148, 15, 24, 20, 52, 52, 33, 162, 20, 83, 156, 18, 172, 60, 58, 178, 180, 60, 36, 40, 18, 95, 96, 12, 196, 99, 66, 84, 20, 66, 90, 210, 70, 28, 15, 18, 24, 37, 60, 226, 76, 30, 29, 92, 78, 119, 24, 162, 84, 36, 82, 50, 110, 8, 16, 36, 84, 131, 52, 22, 268, 135, 12, 20, 92, 30, 70, 94, 36, 60, 136, 48, 292, 116, 90, 132, 42, 100, 60, 102, 102, 155, 156, 12, 316, 140, 106, 72, 60, 36, 69, 30, 36, 132, 21, 28, 10, 147, 44, 346, 348, 36, 88, 140, 24, 179, 342, 110, 36, 183, 60, 156, 372, 100, 84, 378, 14, 191, 60, 42, 388, 88, 130, 156, 44, 18, 200, 60, 108, 180, 204, 68, 174, 164, 138, 418, 420, 138, 40, 60, 60, 43, 72, 28, 198, 73, 42, 442, 44, 148, 224, 20, 30, 12, 76, 72, 460, 231, 20, 466, 66, 52, 70, 180, 156, 239, 36, 66, 48, 243, 162, 490, 56, 60, 105, 166, 166, 251, 100, 156, 508, 9, 18, 204, 230, 172, 260, 522, 60, 40, 253, 174, 60, 212, 178, 210, 540, 180, 36, 546, 60, 252, 39, 36, 556, 84, 40, 562, 28, 54, 284, 114, 190, 220, 144, 96, 246, 260, 12, 586, 90, 196, 148, 24, 198, 299, 25, 66, 220, 303, 84, 276, 612, 20, 154, 618, 198, 33, 500, 90, 72, 45, 210, 28, 84, 210, 64, 214, 28, 323, 290, 30, 652, 260, 18, 658, 660, 24, 36, 308, 74, 60, 48, 180, 676, 48, 226, 22, 68, 76, 156, 230, 30, 276, 40, 58, 700, 36, 92, 300, 708, 78, 55, 60, 238, 359, 51, 24, 140, 121, 486, 56, 244, 84, 330, 246, 36, 371, 148, 246, 318, 375, 50, 60, 756, 110, 380, 36, 24, 348, 384, 16, 772, 20, 36, 180, 70, 252, 52, 786, 262, 84, 60, 52, 796, 184, 66, 90, 132, 268, 404, 270, 270, 324, 126, 12, 820, 411, 20, 826, 828, 92, 168, 332, 90, 419, 812, 70, 156, 330, 94, 396, 852, 36, 428, 858, 60, 431, 172, 136, 390, 132, 48, 300, 876, 292, 55, 882, 116, 443, 21, 270, 414, 356, 132, 140, 104, 42, 180, 906, 300, 91, 410, 60, 390, 153, 102, 420, 180, 102, 464, 126, 310, 40, 117, 156, 940, 220, 36, 946, 36, 316, 68, 380, 140, 204, 155, 318, 96, 483, 72, 194, 138, 60, 488, 110, 36, 491, 196, 138, 154, 495, 30, 396, 332, 36, 60, 232, 132, 468, 504, 42, 92, 84, 84, 1018, 340, 10, 20, 156, 294, 515, 258, 132, 120, 519, 346, 444, 180, 348, 262, 350, 108, 420, 15, 88, 1060, 531, 140, 240, 356, 24, 252, 140, 358, 492, 253, 342, 60, 543, 330, 1090, 364, 36, 274, 156, 366, 29, 24, 180, 1108, 100, 156, 148, 1116, 372, 522, 1122, 300, 231, 564, 84, 510, 452, 378, 264, 162, 42, 76, 180, 382, 575, 288, 60, 132, 180, 126, 166, 116, 388, 249, 1170, 88, 460, 530, 390, 236, 156, 156, 1186, 140, 44, 298, 476, 18, 180, 300, 200, 24, 280, 60, 516, 1212, 324, 152, 572, 180, 611, 420, 204, 1228, 615, 204, 36, 1236, 174, 72, 140, 164, 28, 156, 138, 534, 100, 418, 1258, 48, 420, 220, 180, 414, 20, 198, 40, 1276, 639, 60, 1282, 16, 60, 161, 1290, 86, 36, 648, 72, 1300, 651, 84, 1306, 120, 198, 300, 524, 146, 659, 60, 126, 260, 221, 442, 1210, 70, 44, 285, 204, 444, 312, 268, 224, 630, 96, 20, 540, 638, 30, 680, 644, 12, 683, 1332, 76, 1372, 100, 216, 588, 1380, 460, 92, 18, 462, 636, 99, 60, 70, 233, 466, 660, 140, 66, 704, 328, 156, 188, 36, 70, 84, 237, 180, 1426, 84, 468, 179, 60, 478, 719, 130, 36, 136, 723, 66, 1450, 1452, 48, 115, 486, 486, 90, 292, 162, 84, 245, 490, 580, 210, 56, 370, 1482, 180, 743, 744, 210, 1492, 132, 166, 1498, 234, 498, 84, 340, 502, 755, 88, 100, 180, 105, 156, 1522, 60, 508, 690, 1530, 18, 204, 364, 54, 66, 771, 204, 24, 1548, 230, 194, 620, 516, 779, 111, 260, 156, 783, 522, 1570, 660, 60, 738, 526, 40, 791, 316, 506, 678, 252, 522, 140, 532, 60, 400, 228, 212, 803, 201, 534, 52, 72, 210, 1618, 1620, 540, 300, 542, 180, 87, 385, 36, 1636, 740, 546, 260, 276, 180, 48, 84, 252, 60, 92, 78, 30, 831, 36, 1666, 1668, 556, 357, 660, 84, 99, 820, 120, 84, 24, 562, 198, 1692, 28, 848, 566, 162, 780, 20, 284, 244, 812, 114, 588, 200, 570, 215, 574, 220, 260, 36, 144, 1732, 692, 96, 828, 1740, 246, 348, 1746, 260, 408, 146, 36, 150, 879, 586, 140, 88, 90, 420, 330, 588, 140, 74, 148, 204, 891, 24, 1786, 596, 198, 810, 716, 598, 48, 25, 50, 684, 276, 198, 362, 252, 220, 429, 424, 606, 911, 180, 84, 290, 305, 276, 732, 830, 612, 393, 144, 60, 923, 602, 154, 72, 156, 618, 780, 1860, 594, 372, 1866, 66, 935, 936, 500, 1876, 939, 90, 804, 84, 72, 472, 60, 90, 756, 135, 210, 1900, 860, 28, 1906, 902, 84, 239, 764, 630, 900, 56, 64, 60, 460, 214, 1930, 644, 84, 444, 276, 646, 924, 388, 290, 1948, 975, 30, 88, 306, 652, 468, 60, 260, 210, 890, 18, 1972, 780, 658, 1978, 282, 660, 44, 1986, 24, 180, 996, 36, 1996, 333][deck_size >> 1]", "def faro_cycles(deck_size):\n \"\"\"\n If the deck size is 2*n, then it'll take at least\n k shuffles to get back to the starting order, where k \n is the smallest integer such that 2**k = 1 (mod 2*n - 1)\n \"\"\"\n \n if deck_size <= 2: return 1\n \n k = 1\n while ((2**k % (deck_size - 1)) != 1): k += 1\n return k"] | {"fn_name": "faro_cycles", "inputs": [[2], [52], [542], [1250], [1954]], "outputs": [[1], [8], [540], [156], [30]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 7,206 |
def faro_cycles(deck_size):
|
4212dc99a19a4842b6d7a098caf5d6ee | UNKNOWN | In his publication Liber Abaci Leonardo Bonacci, aka Fibonacci, posed a problem involving a population of idealized rabbits. These rabbits bred at a fixed rate, matured over the course of one month, had unlimited resources, and were immortal.
Beginning with one immature pair of these idealized rabbits that produce b pairs of offspring at the end of each month. Create a function that determines the number of pair of mature rabbits after n months.
To illustrate the problem, consider the following example:
```python
fib_rabbits(5, 3) returns 19
```
Month
Immature Pairs
Adult Pairs
0
1
0
1
0
1
2
3
1
3
3
4
4
12
7
5
21
19
Hint: any Fibonacci number can be computed using the following equation Fn = F(n-1) + F(n-2) | ["def fib_rabbits(n, b):\n (i, a) = (1, 0)\n for m in range(n):\n (i, a) = (a * b, a + i)\n return a\n", "def fib_rabbits(n, b):\n x, y = 0, 1\n for _ in range(n):\n x, y = y, x * b + y\n return x", "def fib_rabbits(n, m):\n a,b = 0,1\n for i in range(n):\n a,b = b, b+a*m\n return a", "def fib_rabbits(end, factor):\n immatures, adults = 1, 0\n for month in range(end):\n immatures, adults = (factor * adults), (adults + immatures)\n return adults", "def fib_rabbits(n, b):\n f = [0, 1]\n for _ in range(n - 1): f.append(f[-1] + b * f[-2])\n return f[n]", "def fib_rabbits(n, b):\n obj = {'IP':1,'AP':0}\n for month in range(1, n+1):\n cur = obj['IP']\n obj['IP'] = b * obj['AP'] \n obj['AP'] += cur\n \n return obj['AP']", "def fib_rabbits(n, b):\n if n == 0:\n return 0\n x, y = b, 1\n for _ in range(n-2):\n x, y = y*b, x+y\n return y", "def fib_rabbits(n, b):\n table = [0 if i!=1 else 1 for i in range(0, n+1)]\n \n for i in range (2, n+1):\n table[i] = (table[i-1]+ table[i-2]*b)\n \n return table[n]", "def fib_rabbits(n, b):\n if n < 2:\n return n\n ans = [0, 1]\n for i in range(2, n+1):\n ans[0], ans[1] = ans[-1]*b, sum(ans)\n return ans[-1]", "def fib_rabbits(n, b):\n f = [0]*(n+10)\n f[1] = 1\n for i in range(2 , n+10):\n f[i] = f[i-1] + (b * f[i-2])\n return f[n]"] | {"fn_name": "fib_rabbits", "inputs": [[0, 4], [1, 4], [4, 0], [6, 3], [8, 12], [7, 4], [9, 8], [10, 2], [11, 33], [100, 3], [40, 6], [4, 100]], "outputs": [[0], [1], [1], [40], [8425], [181], [10233], [341], [58212793], [465790837923166086127602033842234887], [2431532871909060205], [201]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,485 |
def fib_rabbits(n, b):
|
71168ae59ea872e0a04c19ddb180c8ef | UNKNOWN | Chingel is practicing for a rowing competition to be held on this saturday. He is trying his best to win this tournament for which he needs to figure out how much time it takes to cover a certain distance.
**Input**
You will be provided with the total distance of the journey, speed of the boat and whether he is going downstream or upstream. The speed of the stream and direction of rowing will be given as a string. Check example test cases!
**Output**
The output returned should be the time taken to cover the distance. If the result has decimal places, round them to 2 fixed positions.
`Show some love ;) Rank and Upvote!` | ["def time(distance,boat_speed,stream):\n return round(distance/(boat_speed+int(stream.split()[-1])),2) if stream[0]==\"D\" else round(distance/(boat_speed-int(stream.split()[-1])), 2)", "def time(d, v, s):\n return round(d / (v + int(s.split()[1]) * (1 if s[0] == \"D\" else -1)), 2)", "def time(d, v, s):\n return round(d / (v + int(s.split()[1]) * (\"D\" in s or -1)), 2)", "def time(distance, boat_speed, stream):\n speed = boat_speed + (int(stream[11:]) if stream[0] == 'D' else -int(stream[9:]))\n return round(distance/speed, 2)", "def time(distance, boat_speed, stream):\n direction, speed_str = stream.split()\n speed = int(speed_str) * (1 if direction == 'Downstream' else -1)\n return round(distance / (boat_speed + speed), 2)", "from operator import truediv\n\n\ndef time(distance, boat_speed, stream):\n stream, stream_speed = stream.split()\n stream_speed = int(stream_speed) * (-1 if stream == 'Upstream' else 1)\n return round(truediv(distance, (boat_speed + stream_speed)), 2)\n", "def time(distance, boat_speed, stream):\n stream_speed = int(stream.split()[1])\n \n if stream[0] == \"D\":\n speed = boat_speed + stream_speed\n else:\n speed = boat_speed - stream_speed\n \n return round(distance / speed, 2)", "def time(distance, boat_speed, stream):\n \n s = stream.split()\n \n net_speed = boat_speed + int(s[1]) if s[0] == 'Downstream' else boat_speed - int(s[1])\n \n return round(distance/net_speed, 2)", "def time(distance,boat_speed,stream):\n direction,stream_speed=tuple(stream.split())\n stream_speed=int(stream_speed)\n if direction == \"Downstream\":\n if distance%(boat_speed+stream_speed)==0:\n return int(distance/(boat_speed+stream_speed))\n else:\n return float(\"%.2f\"%(distance/(boat_speed+stream_speed)))\n else:\n if distance%(boat_speed-stream_speed)==0:\n return int(distance/(boat_speed-stream_speed))\n else:\n return float(\"%.2f\"%(distance/(boat_speed-stream_speed)))", "time=lambda d,s,S:round(d/(s+(-1)**(S[0]>'D')*int(S.split()[1])),2)"] | {"fn_name": "time", "inputs": [[24, 10, "Downstream 2"], [24, 14, "Upstream 2"], [54, 28, "Downstream 3"], [60, 45, "Upstream 15"], [60, 45, "Downstream 15"]], "outputs": [[2], [2], [1.74], [2], [1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,143 |
def time(distance, boat_speed, stream):
|
029d69a67efb5dce730a5470306e8dc3 | UNKNOWN | ## Grade book
Complete the function so that it finds the mean of the three scores passed to it and returns the letter value associated with that grade.
Numerical Score | Letter Grade
--- | ---
90 <= score <= 100 | 'A'
80 <= score < 90 | 'B'
70 <= score < 80 | 'C'
60 <= score < 70 | 'D'
0 <= score < 60 | 'F'
Tested values are all between 0 and 100. Theres is no need to check for negative values or values greater than 100. | ["def get_grade(s1, s2, s3):\n m = (s1 + s2 + s3) / 3.0\n if 90 <= m <= 100:\n return 'A'\n elif 80 <= m < 90:\n return 'B'\n elif 70 <= m < 80:\n return 'C'\n elif 60 <= m < 70:\n return 'D'\n return \"F\"\n", "def get_grade(s1, s2, s3):\n mean = sum([s1,s2,s3])/3\n if mean>=90: return 'A'\n if mean>=80: return 'B'\n if mean>=70: return 'C'\n if mean>=60: return 'D'\n return 'F'\n", "def get_grade(*s):\n return 'FFFFFFDCBAA'[sum(s)//30]\n", "scores = {10: 'A', 9: 'A', 8: 'B', 7: 'C', 6: 'D'}\n\ndef get_grade(*args):\n mean = sum(args) / len(args)\n return scores.get(mean // 10, 'F') ", "def get_grade(s1, s2, s3):\n s = (s1 + s2 + s3) / 3\n if 90 <= s <= 100: return 'A'\n if 80 <= s < 90: return 'B'\n if 70 <= s < 80: return 'C'\n if 60 <= s < 70: return 'D'\n if 0 <= s < 60: return 'F'", "def get_grade(s1, s2, s3):\n mean_score = sum([s1,s2,s3])/3.0\n if mean_score >= 90: return \"A\"\n if mean_score >= 80: return \"B\"\n if mean_score >= 70: return \"C\"\n if mean_score >= 60: return \"D\"\n return \"F\"\n", "get_grade = lambda *a: \"FFFFFFDCBAA\"[(sum(a)//3)//10]", "def get_grade(*arg):\n return list('FDCBAA')[max(int(sum(arg)/30-5), 0)]", "def get_grade(s1, s2, s3):\n m = (s1 + s2 + s3) / 3\n if m > 89:\n return 'A'\n elif m > 79:\n return 'B'\n elif m > 69:\n return 'C'\n elif m > 59:\n return 'D'\n else:\n return \"F\"\n", "def get_grade(*scores):\n grades = {\n 10: 'A',\n 9: 'A',\n 8: 'B',\n 7: 'C',\n 6: 'D',\n }\n mean = sum(scores) / len(scores)\n return grades.get(mean // 10, 'F')\n", "def get_grade(s1, s2, s3):\n if (s1 + s2 + s3) / 3 < 60: return \"F\"\n if (s1 + s2 + s3) / 3 < 70: return \"D\"\n if (s1 + s2 + s3) / 3 < 80: return \"C\"\n if (s1 + s2 + s3) / 3 < 90: return \"B\"\n if (s1 + s2 + s3) / 3 <= 100: return \"A\"", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3) / 3\n if 90 <= score <= 100:\n return \"A\"\n elif 80 <= score < 90:\n return \"B\"\n elif 70 <= score < 80:\n return \"C\"\n elif 60 <= score < 70:\n return \"D\"\n elif 0 <= score < 60:\n return \"F\"", "def get_grade(*args):\n return {6:\"D\", 7:\"C\", 8:\"B\", 9:\"A\", 10:\"A\"}.get(sum(args) // 30, \"F\")", "def get_grade(s1, s2, s3):\n return next('ABCDF'[i] for i, low in enumerate([90, 80, 70, 60, 0]) if (s1+s2+s3) / 3 >= low)", "def get_grade(*grades):\n mean = sum(grades)/len(grades)\n for score, grade in [(90, 'A'), (80, 'B'), (70, 'C'), (60, 'D'), (0, 'F')]:\n if mean >= score:\n return grade", "def get_grade(s1, s2, s3):\n m = (s1 + s2 + s3) / 3\n return 'A' if m >= 90 else 'B' if m >= 80 else 'C' if m >= 70 else 'D' if m >= 60 else 'F'", "def get_grade(s1, s2, s3):\n s = s1+s2+s3\n s /= 3\n if s >= 90:\n return \"A\"\n elif s >= 80:\n return \"B\"\n elif s >= 70:\n return \"C\"\n elif s >= 60:\n return \"D\"\n return \"F\"\n", "def get_grade(s1, s2, s3):\n grades = {range(60): 'F', range(60, 70): 'D', range(70, 80): 'C', range(80, 90): 'B', range(90, 101): 'A'}\n for x in grades:\n if int((s1 + s2 + s3) / 3) in x: return (grades[x])", "import math \n\n\ndef get_grade(a, b, c):\n mean = math.floor((a+b+c)/3)\n print(mean)\n grades = {'A': [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],\n 'B': [98, 88, 87, 86, 85, 84, 83, 82, 81, 80],\n 'C': [79, 78, 77, 76, 75, 74, 73, 72, 71, 70],\n 'D': [69, 68, 67, 66, 65, 64, 63, 62, 61, 60]}\n for k in grades:\n if mean in grades[k]:\n return k\n return 'F'\n", "from statistics import mean\ndef get_grade(s1, s2, s3):\n a = mean((s1,s2,s3))\n if a < 60: return 'F'\n elif a < 70: return 'D'\n elif a < 80: return 'C'\n elif a < 90: return 'B'\n else: return 'A'\n", "def get_grade(*args):\n mean = sum(args)/len(args)\n if 90 <= mean <= 100:\n return \"A\"\n elif 80 <= mean < 90:\n return \"B\"\n elif 70 <= mean < 80:\n return \"C\"\n elif 60 <= mean < 70:\n return \"D\"\n else:\n return \"F\"\n", "def get_grade(*s):\n score = sum(s)/len(s)\n if 90 <= score <= 100:\n return 'A'\n elif 80 <= score < 90:\n return 'B'\n elif 70 <= score < 80:\n return 'C'\n elif 60 <= score < 70:\n return 'D'\n else:\n return 'F'\n", "def get_grade(s1, s2, s3):\n a = (s1+s2+s3) / 3\n if 90 <= a <= 100:\n return \"A\"\n elif 80 <= a < 90:\n return \"B\"\n elif 70 <= a < 80:\n return \"C\"\n elif 60 <= a < 70:\n return \"D\"\n elif 0 <= a < 60:\n return \"F\"", "def get_grade(s1, s2, s3):\n mean = (s1 + s2 + s3)/3.0\n if mean >= 70.0:\n if mean < 80.0:\n return 'C'\n elif mean < 90:\n return 'B'\n else:\n return 'A'\n elif mean >= 60:\n return 'D'\n else:\n return 'F'", "def get_grade(s1, s2, s3):\n mean = (s1+s2+s3)/3\n for limit, grade in [(90, 'A'), (80, 'B'), (70, 'C'), (60, 'D')]:\n if limit <= mean <= 100:\n return grade\n return \"F\"\n", "get_grade = lambda *scores: [letter for letter in {'A': (90, 100), 'B': (80, 90), 'C': (70, 80), 'D': (60, 70), 'F': (0, 60)} if {'A': (90, 100), 'B': (80, 90), 'C': (70, 80), 'D': (60, 70), 'F': (0, 60)}[letter][0] <= sum(scores) / len(scores) <= {'A': (90, 100), 'B': (80, 90), 'C': (70, 80), 'D': (60, 70), 'F': (0, 60)}[letter][1]][0]\n\n# what even is this monstosity honestly\n", "def get_grade(s1, s2, s3):\n # Code here\n if 90 <= ((s1 + s2 + s3)/3) <= 100:\n return \"A\"\n elif 80 <= ((s1 + s2 + s3)/3) <= 90:\n return \"B\"\n elif 70 <= ((s1 + s2 + s3)/3) <= 80:\n return \"C\"\n elif 60 <= ((s1 + s2 +s3)/3) < 70:\n return \"D\"\n else:\n return \"F\"\n", "def get_grade(s1, s2, s3):\n score = (s1+s2+s3)/3\n grades = [[90, \"A\"],[80,\"B\"],[70,\"C\"],[60, \"D\"],[0, \"F\"]]\n for grade in grades:\n if score >= grade[0]:\n return grade[1]\n \n", "def get_grade(s1, s2, s3):\n # Code here\n mean = (s1 + s2 + s3) / 3\n score = mean\n if 90 <= score <= 100:\n return 'A'\n elif 80 <= score <= 90:\n return 'B'\n elif 70 <= score <= 80:\n return 'C'\n elif 60 <= score <= 70:\n return 'D'\n elif 0 <= score <= 100:\n return \"F\"\n", "import math\ndef get_grade(b,c,d):a=int((b+c+d)/30);return'A'if a==10else('F'if a<6else chr(74-a))\n", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3) / 3\n score_mapping = { 90 <= score <= 100: 'A',\n 80 <= score < 90: 'B',\n 70 <= score < 80: 'C',\n 60 <= score < 70: 'D',\n 0 <= score < 60: 'F'}\n \n return score_mapping[True]\n", "def get_grade(s1, s2, s3):\n # Code here\n score=(s1+s2+s3)/3\n return \"A\" if 90 <= score <= 100 else 'B' if 80 <= score < 90 else 'C' if 70 <= score < 80 else 'D' if 60 <= score < 70 else 'F' \n", "dict = {10: \"A\", 9: \"A\", 8: \"B\", 7: \"C\", 6: \"D\"}\n\ndef get_grade(s1, s2, s3):\n mean = int((s1 + s2 + s3) / 30)\n if mean in dict:\n return dict[mean]\n return \"F\"\n", "def get_grade(s1, s2, s3):\n grade = ['F'] * 60 + ['D'] * 10 + ['C'] * 10 + ['B'] * 10 + ['A'] * 11 \n scores = (s1 + s2 + s3) // 3\n return grade[scores]\n", "def get_grade(*args):\n avg , grades = sum(args)//len(args) , ['F' , 'D' , 'C' , 'B' , 'A','A']\n return grades[max(0 , (avg//10 - 5))]\n", "def get_grade(*arg):\n return list('FDCBAA')[max(int((sum(arg)/3-50)/10), 0)]", "def get_grade(s1, s2, s3):\n a = (s1 + s2 + s3) / 3\n if a >= 90: return \"A\"\n if a >= 80: return \"B\"\n if a >= 70: return \"C\"\n if a >= 60: return \"D\"\n return \"F\"", "def get_grade(s1, s2, s3):\n # Code here -> OK\n if s1+s2+s3>=270: return \"A\"\n if ((s1+s2+s3>=240) & (s1+s2+s3<270)): return \"B\"\n if ((s1+s2+s3>=210) & (s1+s2+s3<240)): return \"C\"\n if ((s1+s2+s3>=180) & (s1+s2+s3<210)): return \"D\"\n if ((s1+s2+s3>=0) & (s1+s2+s3<180)): return \"F\"\n return \"F\"", "mean = lambda nums: sum(nums) / (len(nums) + .0)\ndef get_grade(s1, s2, s3):\n m = mean([s1, s2, s3])\n if m >= 90:\n return 'A'\n elif m >= 80:\n return 'B'\n elif m >= 70:\n return 'C'\n elif m >= 60:\n return 'D'\n else:\n return \"F\"\n", "from collections import OrderedDict\n\ndef get_grade(*s):\n avg = sum(s) / len(s)\n for a, g in zip([60, 70, 80, 90], ['F', 'D', 'C', 'B']):\n if avg < a: return g\n return \"A\"", "def get_grade(s1, s2, s3):\n score = (s1+s2+s3)/3\n if 90 <= score <= 100: return \"A\"\n elif 80 <= score < 90: return \"B\"\n elif 70 <= score < 80: return \"C\"\n elif 60 <= score < 70: return \"D\"\n else: return \"F\"\n", "def get_grade(*args):\n d={(0,6):'F', (6,7):'D', (7,8):'C', (8,9):'B', (9,11):'A'}\n return next(d[rang] for rang in list(d.keys()) if (sum(args)/len(args))//10 in range(*rang))\n", "def get_grade(s1, s2, s3):\n # Code here\n s=s1+s2+s3\n res=s/3\n if res >= 90 and res <=100:\n return 'A'\n elif res >=80 and res <=90:\n return 'B'\n elif res >=70 and res <=80:\n return 'C'\n elif res >=60 and res <=70:\n return 'D'\n elif res >=0 and res <=60:\n return 'F'\n", "def get_grade(s1, s2, s3):\n av = (int(s1) + int(s2) + int(s3)) / 3\n if int(av) >=90:\n return 'A'\n if 80 <= int(av) < 90:\n return 'B'\n if 70 <= int(av) < 80:\n return 'C'\n if 60 <= int(av) < 70:\n return 'D'\n if int(av) <60:\n return 'F'", "def get_grade(s1, s2, s3):\n score = sum([s1+s2+s3])/3\n if score >= 90:\n return \"A\"\n elif score >= 80:\n return \"B\"\n elif score >= 70:\n return \"C\"\n elif score >= 60:\n return \"D\"\n else:\n return \"F\"\n", "def get_grade(s1, s2, s3):\n mean = (s1+s2+s3)//3\n print(mean)\n if mean >= 90:\n return \"A\"\n elif mean >= 80:\n return \"B\"\n elif mean >= 70:\n return \"C\"\n elif mean >= 60:\n return \"D\"\n else:\n return \"F\"\n", "def get_grade(s1, s2, s3):\n result = (s1 + s2 + s3)/3\n \n if result >= 90:\n return \"A\"\n elif result >= 80 and result < 90:\n return \"B\"\n elif result >= 70 and result < 80:\n return \"C\"\n elif result >= 60 and result < 70:\n return \"D\"\n else:\n return \"F\"\n", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3) / 3\n return {10:'A', 9:'A', 8:'B', 7:'C', 6:'D'}.get(score // 10, 'F')\n", "def get_grade(s1, s2, s3):\n return 'A' if (s1 + s2 + s3) / 3 >= 90 else 'B' if 80 <= (s1 + s2 + s3) / 3 < 90 else 'C'if 70 <= (s1 + s2 + s3) / 3 < 80 else 'D' if 60 <= (s1 + s2 + s3) / 3 < 70 else 'F'", "def get_grade(s1, s2, s3):\n mean_grade = (s1 + s2 + s3) / 3\n grade = \"\"\n if mean_grade >= 0 and mean_grade < 60:\n grade = \"F\"\n if mean_grade >= 60 and mean_grade < 70:\n grade = \"D\"\n if mean_grade >= 70 and mean_grade < 80:\n grade = \"C\"\n if mean_grade >= 80 and mean_grade < 90:\n grade = \"B\"\n if mean_grade >= 90 and mean_grade <= 100:\n grade = \"A\"\n return grade", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3) / 3\n score = int (score)\n if (score >= 90) and (score <= 100):\n return \"A\"\n if (score >= 80) and (score <= 90):\n return \"B\"\n if (score >= 70) and (score <= 80):\n return \"C\"\n if (score >= 60) and (score <= 70):\n return \"D\"\n if (score >= 0) and (score <= 60):\n return \"F\"\n", "def get_grade(s1, s2, s3):\n letter_grades = {(90, 100): 'A', (80, 89): 'B', (70, 79): 'C', (60, 69): 'D', (0, 59): 'F'}\n grade = (s1 + s2 + s3) / 3\n for score in list(letter_grades.keys()):\n if score[0] <= grade <= score[1]: return letter_grades[score]\n \n \n", "def get_grade(s1, s2, s3):\n avg = sum((s1,s2,s3)) / 3\n return (\"F\", \"D\", \"C\", \"B\", \"A\")[(avg >= 60) + (avg >= 70) + (avg >= 80) + (avg >= 90)]\n", "def get_grade(s1, s2, s3):\n g = (s1 + s2 + s3) / 3\n if g < 60:\n return 'F'\n elif g < 70:\n return 'D'\n elif g < 80:\n return 'C'\n elif g < 90:\n return 'B'\n else:\n return 'A'\n", "def get_grade(s1, s2, s3):\n w=(s1+s2+s3)/3\n if 90 <=w<= 100:\n return'A'\n elif 80<=w<90:\n return'B'\n elif 70<=w<80:\n return'C'\n elif 60<=w<70:\n return'D'\n elif 0<=w<60:\n return'F'\n", "def get_grade(s1, s2, s3):\n if 90 <= (s1 + s2 + s3) // 3 <= 100:\n return 'A'\n if 80 <= (s1 + s2 + s3) // 3 < 90:\n return 'B'\n if 70 <= (s1 + s2 + s3) // 3 < 80:\n return 'C'\n if 60 <= (s1 + s2 + s3) // 3 < 70:\n return 'D'\n return 'F'\n", "def get_grade(s1, s2, s3):\n tg = (s1+s2+s3)/3\n return \"F\" if tg<60 else \"D\" if tg<70 else \"C\" if tg<80 else \"B\" if tg<90 else \"A\"", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3) / 3\n return \"A\"*(90 <= score <= 100) + \"B\"*(80 <= score < 90) + \"C\"*(70 <= score < 80) + \"D\"*(60 <= score < 70) + \"F\"*(0 <= score < 60)\n", "def get_grade(s1, s2, s3):\n avg = (s1 + s2 +s3) / 3\n scale = {\n 'A': 90 <= avg <= 100,\n 'B': 80 <= avg < 90,\n 'C': 70 <= avg < 80,\n 'D': 60 <= avg < 70,\n 'F': 0 <= avg < 60\n }\n for k, v in scale.items():\n if v == True: return k", "def get_grade(s1, s2, s3):\n result = (sum((s1,s2,s3)) ) /3\n if result > 90:\n return \"A\"\n elif 90>result>=80:\n return \"B\"\n elif 80>result>=70:\n return 'C'\n elif 70>result>=60:\n return 'D'\n elif 60>result>=0:\n return \"F\"", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3) / 3\n if 90 <= score or 100 <= score:\n return \"A\"\n elif 80 <= score or 90 < score:\n return \"B\"\n elif 70 <= score or 80 < score:\n return \"C\"\n elif 60 <= score < 70:\n return \"D\"\n else:\n# if 0 <= score or score <60:\n return \"F\"", "def get_grade(s1, s2, s3):\n m=int((s1+s2+s3)/3)\n if m>=90 and m<=100: return \"A\"\n elif m>=80 and m<90: return \"B\"\n elif m>=70 and m<80: return \"C\"\n elif m>=60 and m<70: return \"D\"\n else: return \"F\"\n", "def get_grade(*args):\n # Code here\n score = sum(args)/len(args)\n if 90 <= score <= 100:\n return 'A'\n elif 80 <= score < 90:\n return 'B'\n elif 70 <= score < 80:\n return 'C'\n elif 60 <= score < 70:\n return 'D'\n else:\n return 'F'", "def get_grade(s1, s2, s3):\n dic = {10: 'A', 9: 'A', 8: 'B', 7: 'C', 6: 'D', 5: 'F',4: 'F', 3:'F',2:'F',1:\"F\",0:\"F\"}\n return dic[ ((s1 +s2 + s3) /3) //10]\n", "def get_grade(s1, s2, s3):\n score=(s1+s2+s3)/3\n letter=''\n if score <= 100 and score >=90:\n letter='A'\n elif score <90 and score>=80:\n letter='B'\n elif score <80 and score>=70:\n letter='C'\n elif score <70 and score>=60:\n letter='D'\n elif score <60:\n letter='F'\n return letter\n", "def get_grade(*args):\n mean = sum(args) // len(args)\n print(mean)\n grade = 'F'\n if mean in range(60, 70):\n grade = 'D'\n if mean in range(70, 80):\n grade = 'C'\n if mean in range(80, 90):\n grade = 'B'\n if mean in range(90, 101):\n grade = 'A'\n return grade\n", "def get_grade(s1, s2, s3):\n if 90<=(s1+s2+s3)/3 <=100 :\n return \"A\"\n if 80<=(s1+s2+s3)/3 <90 :\n return \"B\"\n if 70<=(s1+s2+s3)/3 <80 :\n return \"C\"\n if 60<=(s1+s2+s3)/3 <70 : \n return \"D\"\n if 0<=(s1+s2+s3)/3 <=60 : \n return \"F\"", "def get_grade(s1, s2, s3):\n # Code here\n avg=((s1+s2+s3)/3)\n if(avg>90):\n return \"A\"\n elif(80<=avg<90):\n return \"B\"\n elif(70<=avg<80):\n return \"C\"\n elif(60<=avg<70):\n return \"D\"\n return \"F\"\n", "def get_grade(s1, s2, s3):\n ave = (s1 + s2 + s3) / 3\n if (ave >=90) and (ave <=100):\n return('A')\n elif (ave >=80) and (ave <90):\n return('B')\n elif (ave >=70) and (ave <80):\n return('C')\n elif (ave >=60) and (ave <70):\n return('D')\n else:\n return('F')", "def get_grade(s1, s2, s3):\n \n mean = (s1+s2+s3)/ 3\n\n if 90 <= mean <= 100:\n return 'A'\n if 80 <= mean < 90:\n return 'B'\n if 70 <= mean < 80:\n return 'C'\n if 60 <= mean < 70:\n return 'D'\n if 0 <= mean < 60:\n return 'F'\n else: \n return 'no'\n", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3)/3\n print(score)\n if score <= 100 and score >=90:\n return 'A'\n elif score < 90 and score >=80:\n return \"B\"\n elif score < 80 and score >=70:\n return \"C\"\n elif score < 70 and score >=60:\n return \"D\"\n else:\n return \"F\"\n\n\n", "def get_grade(s1, s2, s3):\n score = (s1+s2+s3)/3\n if score >=0 and score <60:\n return 'F'\n if score >=60 and score <70:\n return 'D'\n if score >=70 and score <80:\n return 'C'\n if score >=80 and score <90:\n return 'B'\n if score >=90 and score <=100:\n return 'A'\n", "def get_grade(s1, s2, s3):\n nota = (s1+s2+s3) / 3\n if nota >= 90:\n return \"A\"\n elif nota >= 80:\n return \"B\"\n elif nota >= 70:\n return \"C\"\n elif nota >= 60:\n return \"D\"\n else:\n return \"F\"\n", "def get_grade(s1, s2, s3):\n avg = sum((s1, s2, s3))//3\n return ['F', 'D', 'C', 'B', 'A'][sum((avg>59, avg>69, avg>79, avg>89))]", "def get_grade(s1, s2, s3):\n curr = sum([s1,s2,s3]) // 3\n m = [[90,100,'A'], [80,90,'B'],[70,80,'C'],[60,70,'D']]\n for s,e,grade in m:\n if s<=curr<=e:\n return grade\n return 'F'", "def get_grade(s1, s2, s3):\n \n mean_score = (s1 + s2 + s3) / 3\n\n if mean_score >= 90:\n return 'A'\n if mean_score >= 80:\n return 'B'\n if mean_score >= 70:\n return 'C'\n if mean_score >= 60:\n return 'D'\n return \"F\"\n", "def get_grade(s1, s2, s3):\n x = (s1 + s2 + s3) / 3\n if x < 60:\n return \"F\"\n if x >= 60 and x < 70:\n return \"D\"\n if 70 <= x < 80:\n return \"C\"\n if 80 <= x < 90:\n return \"B\"\n else:\n return \"A\"", "def get_grade(s1, s2, s3):\n result = sum([s1, s2, s3]) // 30\n if result >= 9:\n return 'A'\n elif result >= 8:\n return 'B'\n elif result >= 7:\n return 'C'\n elif result >= 6:\n return 'D'\n else:\n return 'F'\n", "def get_grade(s1, s2, s3):\n val = (s1+s2+s3)/3\n if val <= 100 and val >= 90:\n return 'A'\n elif val >= 80 and val < 90:\n return 'B'\n elif val >= 70 and val < 80:\n return 'C'\n elif val >= 60 and val < 70:\n return 'D'\n elif val >= 0 and val < 60:\n return 'F'\n \n", "def get_grade(s1, s2, s3):\n score = (s1 + s2 + s3) / 3\n grade = ''\n if score >= 90 and score <= 100:\n grade = 'A'\n elif score >= 80 and score < 90:\n grade = 'B'\n elif score >= 70 and score < 80:\n grade = 'C'\n elif score >= 60 and score < 70:\n grade = \"D\"\n elif score >= 0 and score < 60:\n grade = 'F'\n \n return grade\n", "def get_grade(s1, s2, s3):\n print((s1, s2, s3))\n x = (s1 + s2 + s3) / 3\n if x <= 100 and x >= 90:\n return 'A'\n elif x <= 89 and x >= 80:\n return 'B'\n elif x <= 79 and x >= 70:\n return 'C'\n elif x <= 69 and x >= 60:\n return 'D'\n else:\n return 'F'\n", "def get_grade(s1, s2, s3):\n mean = (s1+s2+s3)/3\n if mean<=100 and mean>90:\n return \"A\"\n elif mean<90 and mean>=80:\n return \"B\"\n elif mean<80 and mean>=70:\n return \"C\"\n elif mean<70 and mean>=60:\n return \"D\"\n else:\n # Code here\n return \"F\"\n", "def get_grade(*args):\n if(sum(args)/len(args)) >= 90:\n return 'A'\n\n if(sum(args)/len(args)) >= 80:\n return 'B'\n\n if(sum(args)/len(args)) >= 70:\n return 'C'\n\n if(sum(args)/len(args)) >= 60:\n return 'D'\n\n return 'F'\n", "def get_grade(s1, s2, s3):\n x=(s1+s2+s3)/3\n if(x<60):\n return \"F\"\n if(x<70):\n return \"D\"\n if(x<80):\n return \"C\"\n if(x<90):\n return \"B\"\n return \"A\"\n", "def get_grade(s1, s2, s3):\n score = (s1+s2+s3) // 3\n if 90 <= score <= 100:\n return \"A\"\n if 80 <= score < 90:\n return \"B\"\n if 70 <= score < 80:\n return \"C\"\n if 60 <= score < 70:\n return \"D\"\n if 0 <= score < 60:\n return \"F\"\n", "import numpy as np\n\ndef get_grade(*scores):\n grades = {10: 'A', 9:'A', 8:'B', 7:'C', 6:'D'}\n return grades.get(np.mean(scores) // 10, 'F')", "def get_grade(s1, s2, s3):\n f = int((s1 + s2 + s3) / 3)\n if f in range(90,101):\n return 'A'\n elif f in range(80, 90):\n return 'B'\n elif f in range(70, 80):\n return 'C'\n elif f in range(60, 70):\n return 'D'\n elif f in range(0, 60):\n return 'F'\n", "def get_grade(s1, s2, s3):\n mean = (s1 + s2 + s3) // 3 \n \n if 90 <= mean <= 100: \n return 'A' \n if 80 <= mean < 90:\n return 'B'\n if 70 <= mean < 80:\n return 'C'\n if 60 <= mean < 70:\n return 'D'\n if 0 <= mean < 60:\n return 'F'\n \n", "def get_grade(s1, s2, s3):\n x = s1 + s2 + s3\n score = x / 3\n if 90 <= score <= 100:\n return \"A\"\n if 80 <= score < 90:\n return \"B\"\n if 70 <= score < 80:\n return \"C\" \n if 60 <= score < 70:\n return \"D\" \n if 0 <= score < 60:\n return \"F\" ", "def get_grade(s1, s2, s3):\n x = s1 + s2 + s3\n m = x / 3\n if m >=90 and m <=100:\n return 'A'\n elif m >=80 and m < 90:\n return 'B'\n elif m >= 70 and m < 80:\n return 'C'\n elif m >= 60 and m < 70:\n return 'D'\n else:\n return 'F'\n", "def get_grade(s1,\n s2,\n s3):\n\n score = s1 + s2 + s3\n if (270 <= score):\n\n return \"A\"\n\n elif (240 <= score):\n\n return \"B\"\n\n elif (210 <= score):\n\n return \"C\"\n\n elif (180 <= score):\n\n return \"D\"\n\n return \"F\"\n", "def get_grade(s1, s2, s3):\n grades = (s1,s2,s3)\n total = sum(grades)\n mean = total / len(grades)\n \n if 100 >= mean >= 90:\n return \"A\"\n elif 90 > mean >= 80:\n return \"B\"\n elif 80 > mean >= 70:\n return \"C\"\n elif 70 > mean >= 60:\n return \"D\"\n else:\n return \"F\"\n \n", "def get_grade(s1, s2, s3):\n a = (s1+s2+s3)/3\n if a >= 90:\n return 'A'\n elif a >= 80:\n return 'B'\n elif a >= 70:\n return 'C'\n elif a >= 60:\n return 'D'\n else:\n return 'F' \n \n return\n", "def get_grade(s1, s2, s3):\n a = (s1 + s2 + s3) /3\n if a >=0 and a < 60:\n return 'F'\n elif a >=60 and a < 70:\n return 'D'\n elif a >=70 and a < 80:\n return 'C'\n elif a >=80 and a < 90:\n return 'B'\n else:\n return 'A'\n \n \n \n \n"] | {"fn_name": "get_grade", "inputs": [[95, 90, 93], [100, 85, 96], [92, 93, 94], [100, 100, 100], [70, 70, 100], [82, 85, 87], [84, 79, 85], [70, 70, 70], [75, 70, 79], [60, 82, 76], [65, 70, 59], [66, 62, 68], [58, 62, 70], [44, 55, 52], [48, 55, 52], [58, 59, 60], [0, 0, 0]], "outputs": [["A"], ["A"], ["A"], ["A"], ["B"], ["B"], ["B"], ["C"], ["C"], ["C"], ["D"], ["D"], ["D"], ["F"], ["F"], ["F"], ["F"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 24,181 |
def get_grade(s1, s2, s3):
|
619338178385ab04c6e1f33eb0223489 | UNKNOWN | Here we have a function that help us spam our hearty laughter. But is not working! I need you to find out why...
Expected results:
```python
spam(1) ==> "hue"
spam(6) ==> "huehuehuehuehuehue"
spam(14) ==> "huehuehuehuehuehuehuehuehuehuehuehuehuehue"
``` | ["#fix this code!\ndef spam(number):\n return 'hue' * number", "def spam(number):\n return ''.join(['hue' for i in range(number)])", "def spam(number):\n return number * 'hue'", "def spam(i):\n return 'hue' * int(i)", "#fix this code!\ndef spam(n):\n return 'hue'*n", "#fix this code!\ndef spam(number):\n return ''.join(['hue']*number)", "spam = lambda n:\"hue\"*n", "#fix this code!\ndef spam(number):\n return ''.join('hue' for i in range(number))", "spam = 'hue'.__mul__"] | {"fn_name": "spam", "inputs": [[1], [6], [14]], "outputs": [["hue"], ["huehuehuehuehuehue"], ["huehuehuehuehuehuehuehuehuehuehuehuehuehue"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 497 |
def spam(number):
|
c7da3057598919f491d15af2d0b206f8 | UNKNOWN | # Task
Let's define a `parameter` of number `n` as the least common multiple (LCM) of the sum of its digits and their product.
Calculate the parameter of the given number `n`.
# Input/Output
`[input]` integer `n`
A positive integer. It is guaranteed that no zero appears in `n`.
`[output]` an integer
The parameter of the given number.
# Example
For `n = 22`, the output should be `4`.
Both the sum and the product of digits equal 4, and LCM(4, 4) = 4.
For `n = 1234`, the output should be `120`.
`1+2+3+4=10` and `1*2*3*4=24`, LCM(10,24)=120 | ["from fractions import Decimal, gcd\nfrom operator import mul\nfrom functools import reduce\n\nlcm = lambda a, b=1: a * b // gcd(a, b)\n\ndef parameter(n):\n digits = Decimal(n).as_tuple().digits\n return lcm(sum(digits), reduce(mul, digits))", "from math import gcd\n\ndef parameter(n):\n s, p = 0, 1\n for m in str(n):\n s += int(m)\n p *= int(m)\n return (s * p / (gcd(s, p)))", "from functools import reduce\nfrom fractions import gcd\ndef parameter(n):\n n = [int(i) for i in str(n)]\n sum_ = reduce(lambda a, b: a + b, n)\n prod = reduce(lambda a, b: a * b, n)\n return (sum_ * prod) / gcd(sum_, prod)", "import operator, functools\ndef parameter(n):\n ls = [int(i) for i in str(n)]\n m = functools.reduce(operator.mul,ls)\n s = sum(ls)\n return m*s/gcd(m,s)\n \ndef gcd(a,b):\n if not b:\n return a\n else:\n return gcd(b,a%b)", "from fractions import gcd\nfrom functools import reduce\nfrom operator import mul\n\ndef parameter(n):\n digits = [int(d) for d in str(n)]\n product = reduce(mul, digits)\n total = sum(digits)\n return product * total / gcd(product, total)", "parameter=lambda n:(lambda a,b:a*b//__import__('fractions').gcd(a,b))(*[eval(c.join(str(n)))for c in'+*'])", "from functools import reduce; gcd=lambda a,b: gcd(b,a%b) if b else a; lcm=lambda a,b: a/gcd(a,b)*b; parameter=lambda n: (lambda n: lcm(sum(n),reduce(lambda a,b: a*b,n,1)))([int(e) for e in str(n)])", "from math import gcd\n\ndef parameter(n):\n total = sum(int(x) for x in str(n))\n product = 1\n for num in str(n):\n product *= int(num)\n return (total * product) // gcd(total,product)", "import math\n\ndef parameter(n):\n \n d = [int(x) for x in str(n)]\n \n s = sum(d)\n \n p = 1\n \n for i in range(0,len(d)):\n \n p*= d[i]\n \n g = math.gcd(s,p)\n \n l = (s*p)//g\n \n return l\n\n", "from functools import reduce\ndef digit_sum(n):\n return sum(int(i) for i in str(n))\n\ndef digit_product(n):\n return reduce(lambda a,b: a*int(b),str(n),1)\n # return reduce(lambda a, b: a * b, map(int, str(n)), 1)\n\ndef gcd(x,y):\n while y != 0:\n x ,y = y, x % y\n return x\n\ndef lcm(x, y):\n return x * y / gcd(x, y)\n\ndef parameter(n):\n return lcm(digit_sum(n), digit_product(n))"] | {"fn_name": "parameter", "inputs": [[1234], [1], [2], [22], [11], [239], [999999999], [91], [344], [123456789]], "outputs": [[120], [1], [2], [4], [2], [378], [387420489], [90], [528], [362880]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,367 |
def parameter(n):
|
494ba9191ea7d9f0b79d6efaa7ca2c85 | UNKNOWN | If I give you a date, can you tell me what day that date is? For example, december 8th, 2015 is a tuesday.
Your job is to write the function ```day(d)```
which takes a string representation of a date as input, in the format YYYYMMDD. The example would be "20151208". The function needs to output the string representation of the day, so in this case ```"Tuesday"```.
Your function should be able to handle dates ranging from January first, 1582 (the year the Gregorian Calendar was introduced) to December 31st, 9999. You will not be given invalid dates. Remember to take leap years into account. | ["import datetime\nimport calendar\n\ndef day(date):\n return calendar.day_name[datetime.datetime.strptime(date,\"%Y%m%d\").weekday()]", "from datetime import datetime\n\nWEEKDAYS = ('Monday', 'Tuesday', 'Wednesday', 'Thursday',\n 'Friday', 'Saturday', 'Sunday')\n\n\ndef day(date):\n return WEEKDAYS[datetime.strptime(date, '%Y%m%d').weekday()]\n", "from datetime import datetime\ndef day(date):\n return '{:%A}'.format(datetime.strptime(date, '%Y%m%d'))", "from datetime import datetime\n\ndef day(date):\n return format(datetime.strptime(date, '%Y%m%d'), '%A')", "from dateutil import parser\nimport calendar\ndef day(date):\n return calendar.day_name[parser.parse(date).weekday()]\n", "import datetime\n\ndef day(date):\n yy = int(date[0:4])\n mm = int(date[4:6])\n dd = int(date[6:8])\n return datetime.date(yy, mm, dd).strftime('%A')", "import datetime\ndef day(date):\n return datetime.datetime.strptime(date, '%Y%m%d').strftime('%A')", "from datetime import datetime\nimport calendar\ndef day(date):\n return calendar.day_name[datetime.strptime(date,\"%Y%m%d\").weekday()]", "from calendar import day_name, monthcalendar\n\ndef day(date):\n year, month, day = list(map(int, (date[:4], date[4:6], date[6:])))\n first_day = monthcalendar(year, month)[0].index(1)\n return day_name[ (first_day+day-1) % 7 ]\n"] | {"fn_name": "day", "inputs": [["20151208"], ["20140728"], ["20160229"], ["20160301"], ["19000228"], ["19000301"]], "outputs": [["Tuesday"], ["Monday"], ["Monday"], ["Tuesday"], ["Wednesday"], ["Thursday"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,368 |
def day(date):
|
7038f3ba405060dacb59ae77e75aecaf | UNKNOWN | You're familiar with [list slicing](https://docs.python.org/3/library/functions.html#slice) in Python and know, for example, that:
```python
>>> ages = [12, 14, 63, 72, 55, 24]
>>> ages[2:4]
[63, 72]
>>> ages[2:]
[63, 72, 55, 24]
>>> ages[:3]
[12, 14, 63]
```
write a function `inverse_slice()` that takes three arguments: a list `items`, an integer `a` and an integer `b`. The function should return a new list with the slice specified by `items[a:b]` _excluded_. For example:
```python
>>>inverse_slice([12, 14, 63, 72, 55, 24], 2, 4)
[12, 14, 55, 24]
```
The input will always be a valid list, `a` and `b` will always be different integers equal to or greater than zero, but they _may_ be zero or be larger than the length of the list. | ["def inverse_slice(items, a, b):\n return items[:a] + items[b:]", "def inverse_slice(items, a, b):\n del items[a:b]\n return items", "def inverse_slice(items, a, b):\n part1 = items[:a]\n part2 = items[b:]\n return (part1+part2)", "def inverse_slice(items, a, b):\n return [v for i,v in enumerate(items) if i < a or i >= b]", "inverse_slice=lambda arr, a, b: arr[:a]+arr[b:]", "inverse_slice=lambda items,a,b:items[:a]+items[b:]", "def inverse_slice(items, a, b):\n return list(i for i in items if i not in items[a:b])", "def inverse_slice(items, a, b):\n splice1 = items[:a]\n splice2 = items[b:]\n return splice1 + splice2\n", "def inverse_slice(items, a, b):\n inv_list=items[0:a]\n inv_list.extend(items[b:])\n return inv_list", "def inverse_slice(items, a, b):\n c = items[a:b]\n for i in c:\n items.remove(i)\n return items"] | {"fn_name": "inverse_slice", "inputs": [[[12, 14, 63, 72, 55, 24], 2, 4], [[12, 14, 63, 72, 55, 24], 0, 3], [["Intuition", "is", "a", "poor", "guide", "when", "facing", "probabilistic", "evidence"], 5, 13]], "outputs": [[[12, 14, 55, 24]], [[72, 55, 24]], [["Intuition", "is", "a", "poor", "guide"]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 888 |
def inverse_slice(items, a, b):
|
58bedeb7b2a9aafd4b60e2593de5c3a1 | UNKNOWN | Write a function that returns a sequence (index begins with 1) of all the even characters from a string. If the string is smaller than two characters or longer than 100 characters, the function should return "invalid string".
For example:
`````
"abcdefghijklm" --> ["b", "d", "f", "h", "j", "l"]
"a" --> "invalid string"
````` | ["def even_chars(st):\n if len(st) < 2 or len(st)> 100:\n return 'invalid string'\n else:\n return [st[i] for i in range(1, len(st), 2)]\n", "def even_chars(st): \n return list(st[1::2]) if 2<=len(st)<=100 else \"invalid string\" ", "def even_chars(stg): \n return list(stg[1::2]) if 1 < len(stg) < 101 else \"invalid string\"", "def even_chars(st):\n lengthString=len(st)\n if lengthString<2 or lengthString>100:\n return \"invalid string\"\n else:\n list=[]\n for i in range(1,lengthString,2):\n list.append(st[i])\n return list", "def even_chars(st): \n return list(st[1::2]) if len(st)>1 and len(st)<100 else \"invalid string\"", "def even_chars(st):\n return list(st[1::2]) if 1<len(st)<101 else \"invalid string\"", "def even_chars(st): \n return [ x for i, x in enumerate(st) if i%2 == 1] if 101 > len(st) > 1 else \"invalid string\" ", "def even_chars(s):\n return list(s[1::2]) if 2 <= len(s) <= 100 else 'invalid string'", "def even_chars(st): \n return len(st)<101 and list(st[1::2]) or 'invalid string'", "def even_chars(st): \n # your code here\n return [st[i] for i in range(1,len(st),2)] if 1<len(st)<100 else \"invalid string\""] | {"fn_name": "even_chars", "inputs": [["a"], ["abcdefghijklm"], ["aBc_e9g*i-k$m"], [""], ["ab"], ["aiqbuwbjqwbckjdwbwkqbefhglqhfjbwqejbcadn.bcaw.jbhwefjbwqkvbweevkj.bwvwbhvjk.dsvbajdv.hwuvghwuvfhgw.vjhwncv.wecnaw.ecnvw.kejvhnw.evjkhweqv.kjhwqeev.kjbhdjk.vbaewkjva"]], "outputs": [["invalid string"], [["b", "d", "f", "h", "j", "l"]], [["B", "_", "9", "*", "-", "$"]], ["invalid string"], [["b"]], ["invalid string"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,240 |
def even_chars(st):
|
0b88c824f5328f7dcd78c62248d994b4 | UNKNOWN | Write function bmi that calculates body mass index (bmi = weight / height ^ 2).
if bmi <= 18.5 return "Underweight"
if bmi <= 25.0 return "Normal"
if bmi <= 30.0 return "Overweight"
if bmi > 30 return "Obese" | ["def bmi(weight, height):\n bmi = weight / height ** 2\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25:\n return \"Normal\"\n elif bmi <= 30:\n return \"Overweight\"\n else:\n return \"Obese\"", "def bmi(weight, height):\n b = weight / height ** 2\n return ['Underweight', 'Normal', 'Overweight', 'Obese'][(b > 30) + (b > 25) + (b > 18.5)]", "def bmi(weight, height):\n bmi = weight / height ** 2\n return 'Underweight' if bmi <= 18.5 else 'Normal' if bmi <= 25.0 else 'Overweight' if bmi <= 30.0 else \"Obese\"", "def bmi(weight, height):\n youfat = (weight / (height * height))\n \n if youfat <= 18.5:\n return \"Underweight\"\n elif youfat <= 25.0:\n return \"Normal\"\n elif youfat <= 30.0:\n return \"Overweight\"\n else:\n return \"Obese\"", "def bmi(weight, height):\n bmeye = (weight/(height**2))\n if bmeye <= 18.5: return(\"Underweight\")\n elif bmeye <= 25.0: return(\"Normal\")\n elif bmeye <= 30.0: return(\"Overweight\")\n elif bmeye > 30: return(\"Obese\")", "def bmi(weight, height):\n\n index = weight / (height * height)\n \n if index <= 18.5:\n \n return \"Underweight\"\n \n\n if index <= 25.0:\n \n return \"Normal\"\n \n\n if index <= 30.0:\n \n return \"Overweight\"\n \n\n if index > 30:\n \n return \"Obese\"\n \n\n", "bmi = lambda w,h: (lambda b=w/h**2: [\"Underweight\", \"Normal\", \"Overweight\", \"Obese\"][(18.5<b) + (25<b) + (30<b)])()", "def bmi(weight, height):\n index = weight/height/height\n return \"Underweight\" if index <= 18.5 else \"Normal\" if index <= 25.0 else\\\n \"Overweight\" if index <= 30.0 else \"Obese\"", "def bmi(weight, height):\n result = weight / height / height\n return \"Underweight Normal Overweight Obese\".split()[\n (result > 18.5) +\n (result > 25.0) +\n (result > 30.0)]", "def bmi(weight, height):\n BMI=weight/(height*height)\n return 'Underweight'if BMI<=18.5 else( 'Normal'if BMI<=25.0 else ('Overweight'if BMI<=30.0 else 'Obese'))", "def bmi(weight, height):\n bmi = weight/height ** 2\n if bmi <= 18.5:\n return (\"Underweight\")\n elif bmi <= 25.0:\n return (\"Normal\")\n elif bmi <= 30:\n return (\"Overweight\")\n else:\n return (\"Obese\")", "bmi=lambda w,h:next(s for s,t in zip(\"Obese Overweight Normal Underweight\".split(),(30,25,18.5,0))if w/h/h>t)", "def bmi(weight, height):\n bmi = weight / height**2\n return [\"Obese\", \"Overweight\", \"Normal\", \"Underweight\"][(bmi<=30) + (bmi<=25) + (bmi<=18.5)]", "def bmi(w,h):\n x=(w/((h)**2))\n if x<=18.5:\n return \"Underweight\"\n elif 18.5<x<=25.0:\n return \"Normal\"\n elif 25.0<x<=30.0:\n return \"Overweight\"\n elif x>30.0:\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight / (height * height)\n if bmi <= 18.5:\n return \"Underweight\"\n if bmi <= 25:\n return \"Normal\"\n if bmi <= 30:\n return \"Overweight\"\n return \"Obese\"", "def bmi(weight, height):\n BMI = weight/height**2\n if (int(BMI) < 18.5):\n results = 'Underweight'\n elif (int(BMI) < 25.0 ):\n results = 'Normal'\n elif (int(BMI) < 30.0 ):\n results = 'Overweight'\n else:\n results ='Obese'\n return(results)", "def bmi(weight, height):\n BMI = weight/(height**2)\n if BMI > 30:\n return 'Obese'\n elif BMI > 25:\n return 'Overweight'\n elif BMI > 18.5:\n return 'Normal'\n else:\n return 'Underweight'\n #your code here\n", "def bmi(weight, height):\n \"\"\"\n calculates bmi from weight in kg\n and height in meters\n \"\"\"\n bmi = weight / (height**2)\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25.0:\n return \"Normal\"\n elif bmi <= 30.0:\n return \"Overweight\"\n else:\n return \"Obese\"\n", "def bmi(weight, height):\n bmi = weight/height**2\n return \"Underweight\" if bmi <=18.5 else \\\n \"Normal\" if bmi < 25.0 else \\\n \"Overweight\" if bmi < 30.0 else \"Obese\"", "def bmi(w, h):\n bmi = w/h**2\n if bmi <= 18.5: return \"Underweight\"\n elif bmi <= 25: return \"Normal\"\n elif bmi <= 30: return \"Overweight\"\n else: return \"Obese\"", "def bmi(weight, height):\n bmi = weight / pow(height, 2)\n if bmi > 30:\n result = \"Obese\"\n elif bmi <= 30.0 and bmi > 25.0:\n result = \"Overweight\"\n elif bmi <= 25.0 and bmi > 18.5:\n result = \"Normal\"\n else:\n result = \"Underweight\"\n return result", "def bmi(weight, height):\n bmi = weight / height ** 2\n\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25:\n return \"Normal\"\n elif bmi <= 30:\n return \"Overweight\"\n elif bmi > 30:\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight/(height ** 2)\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25.0:\n return \"Normal\"\n elif bmi <= 30.0:\n return \"Overweight\"\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight / (height**2)\n if bmi <= 18.5: return \"Underweight\"\n\n elif bmi <= 25.0: return \"Normal\"\n \n elif bmi <= 30.0: return \"Overweight\"\n \n elif bmi > 30: return \"Obese\"", "def bmi(weight, height):\n bmi_val = weight / height**2\n return get_weight_class(bmi_val)\n\n# bmi_ranges start open bound & end closed bound\ndef get_weight_class(bmi_val):\n bmi_ranges = [(0, 18.5), (18.5, 25), (25, 30), (30, float(\"inf\"))]\n weight_classes = {\n (0, 18.5): \"Underweight\",\n (18.5, 25): \"Normal\",\n (25, 30): \"Overweight\",\n (30, float(\"inf\")): \"Obese\",\n }\n # see what range bmi belongs to with binary search\n start = 0\n end = len(bmi_ranges) - 1\n\n while not(start > end):\n mid_i = start + abs(end - start)//2\n range_start, range_end = bmi_ranges[mid_i]\n\n if range_start < bmi_val <= range_end:\n return weight_classes[(range_start, range_end)]\n elif bmi_val <= range_start:\n end = mid_i - 1\n elif bmi_val > range_end:\n start = mid_i + 1\n\n raise ValueError(\"BMI value out of range.\")\n", "def bmi(weight, height):\n bmi = weight / height ** 2\n arr = 'Underweight Normal Overweight Obese'.split()\n return arr[(bmi > 18.5) + (bmi > 25) + (bmi > 30)]", "def bmi(weight, height):\n bmi = weight / height ** 2\n return ([\"Underweight\", \"Normal\", \"Overweight\", \"Obese\"]\n [int(bmi > 18.5) + int(bmi > 25.0) + int(bmi > 30.0)])", "bmi = lambda w, h: (lambda x: [[[\"Underweight\", \"Normal\"][18.5<x<=25], \"Overweight\"][25<x<=30], \"Obese\"][x>30])(w / h**2)", "def bmi(weight, height):\n bm = weight/(height**2.)\n for val, outp in zip([18.5, 25, 30], ['Underweight', 'Normal', 'Overweight']):\n if bm <= val:\n return outp\n return 'Obese'", "a = lambda w, h: w/(h**2)\nbmi = lambda w,h: \"Underweight\" if a(w,h) <= 18.5 else \"Normal\" if a(w,h) <= 25 else \"Overweight\" if a(w,h) <= 30 else \"Obese\"", "bmi=lambda w,h:(lambda b: \"Underweight\" if b<= 18.5 else \"Normal\" if b<= 25.0 else \"Overweight\" if b<= 30.0 else \"Obese\")(w/h/h)", "def bmi(weight, height):\n i = weight/height**2\n return 'Underweight' if i <=18.5 else 'Normal' if i<= 25 else 'Overweight' if i<= 30 else 'Obese'", "def bmi(weight, height):\n scale = {18.5: 'Underweight',\n 25.0: 'Normal',\n 30.0: 'Overweight'}\n \n x = weight / height / height\n\n for bmi_class, label in scale.items():\n if x < bmi_class:\n return label\n\n return \"Obese\"", "def bmi(weight, height):\n #your code here\n bmi = weight / (height ** 2)\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi > 18.5 and bmi <= 25.0:\n return \"Normal\"\n elif bmi > 25 and bmi <= 30:\n return \"Overweight\"\n elif bmi > 30:\n return \"Obese\"\n", "def bmi(weight, height):\n bmi = round(weight/height**2,1)\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25.0:\n return \"Normal\"\n elif bmi <= 30:\n return \"Overweight\"\n else:\n return \"Obese\"", "def bmi(weight, height):\n body = weight/height**2\n if body <= 18.5: \n return \"Underweight\"\n elif body <= 25.0 and body > 18.5:\n return \"Normal\"\n elif body <= 30.0 and body > 25:\n return \"Overweight\"\n else: \n return \"Obese\"", "def bmi(weight, height):\n bmi=(weight/(height**2))\n \n if bmi <= 18.5: return \"Underweight\"\n elif bmi <= 25.0 and bmi>= 18.5: return \"Normal\"\n elif bmi <= 30.0 and bmi>= 25.0: return \"Overweight\"\n elif bmi > 30: return \"Obese\"", "def bmi(weight, height):\n bmi = weight / height ** 2\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25.0:\n return \"Normal\"\n elif bmi <= 30.0:\n return \"Overweight\"\n elif bmi > 30.0:\n return \"Obese\"\n else:\n return 0", "bmi=lambda w,h:(lambda x:'Underweight' if x<=18.5 else 'Normal' if x<=25 else 'Overweight' if x<=30 else 'Obese')(w/h**2)", "def bmi(weight, height):\n c=(weight/height**2)\n if(c<=18.5):\n return \"Underweight\"\n elif(c<=25.0):\n return \"Normal\"\n elif(c<=30.0):\n return \"Overweight\"\n return \"Obese\"", "def bmi(weight, height):\n bm = weight/(height**2)\n if bm <= 18.5: return \"Underweight\"\n if bm <= 25.0: return \"Normal\"\n if bm <= 30.0: return \"Overweight\"\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight / (height ** 2)\n if bmi <+ 18.5:\n return 'Underweight'\n elif bmi <= 25:\n return 'Normal'\n elif bmi <= 30:\n return 'Overweight'\n else:\n return 'Obese'", "def bmi(weight, height):\n bo_m_i = weight / height ** 2\n if bo_m_i <= 18.5:\n return \"Underweight\"\n elif bo_m_i <= 25.0:\n return \"Normal\"\n elif bo_m_i <= 30.0:\n return \"Overweight\"\n else:\n return \"Obese\"\n", "def bmi(weight, height):\n bmi = weight / height**2\n for i,limit in enumerate((18.5, 25, 30)):\n if bmi <= limit:\n return (\"Underweight\",\"Normal\",\"Overweight\")[i]\n else:\n return \"Obese\"", "def bmi(weight, height):\n abmi=weight/(height*height)\n if abmi <= 18.5: return \"Underweight\"\n elif 18.5<abmi<=25.0: return \"Normal\"\n elif 25.0<abmi<=30.0: return \"Overweight\"\n elif 30.0<abmi: return \"Obese\"\n #your code here\n", "def bmi(weight, height):\n a = weight / height ** 2\n if a <= 18.5: return \"Underweight\"\n elif a <= 25.0: return \"Normal\"\n elif a <= 30.0: return \"Overweight\"\n return \"Obese\"\n #your code here\n", "def bmi(weight, height):\n index = weight / height**2\n if index > 30:\n return \"Obese\"\n elif index > 25:\n return \"Overweight\"\n elif index > 18.5:\n return \"Normal\"\n else:\n return \"Underweight\"", "def bmi(weight, height):\n bmi_1 = weight / height ** 2\n return 'Obese' if bmi_1 > 30 else 'Overweight' if bmi_1 > 25 else 'Normal' if bmi_1 > 18.5 else 'Underweight'", "def bmi(w, h):\n if w/h**2 <=18.5:\n return 'Underweight'\n elif w/h**2 <=25.0:\n return 'Normal'\n elif w/h**2 <=30.0:\n return 'Overweight'\n elif w/h**2 >30:\n return 'Obese'", "def bmi(weight, height):\n a = weight / height ** 2\n if (a > 30):\n return 'Obese'\n if a >= 25:\n return 'Overweight' \n if a >= 18.5:\n return 'Normal'\n return 'Underweight' ", "def bmi(weight, height):\n BMI=(float(weight) / float(height ** 2))\n \n if BMI<=18.5: return \"Underweight\"\n elif BMI<=25.0: return \"Normal\"\n elif BMI<=30.0: return \"Overweight\"\n else: return \"Obese\"\n", "def bmi(weight, height):\n bmi=weight/height**2\n float(bmi)\n if bmi<=18.5:\n return 'Underweight'\n elif bmi<=25.0:\n return 'Normal'\n elif bmi<=30.0:\n return 'Overweight'\n elif bmi>30.0:\n return 'Obese'\n else:\n return 'What'", "def bmi(weight, height):\n bmi = weight / pow(height, 2)\n return ['Underweight', 'Normal', 'Overweight', 'Obese'][(bmi > 18.5) + (bmi > 25.0) + (bmi > 30)]", "def bmi(weight, height):\n bmi = weight / height ** 2\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25.0:\n return \"Normal\"\n elif bmi <= 30:\n return \"Overweight\"\n elif bmi > 30:\n return \"Obese\"\n else:\n return \"Error\"", "def bmi(weight, height):\n body = weight / height ** 2\n if body <= 18.5:\n return \"Underweight\"\n elif body <= 25.0 :\n return \"Normal\"\n elif body <= 30.0 :\n return \"Overweight\"\n elif body > 30 :\n return \"Obese\"", "def bmi(weight, height):\n bmi_i = weight / height ** 2\n if bmi_i <= 18.8:\n return \"Underweight\" \n if bmi_i <= 25.0:\n return \"Normal\"\n if bmi_i <= 30.0:\n return \"Overweight\" \n if bmi_i > 30:\n return \"Obese\"", "def bmi(weight, height):\n bmi_res = weight/height**2\n if bmi_res <= 18.5:\n return \"Underweight\"\n elif bmi_res <= 25:\n return \"Normal\"\n elif bmi_res <= 30:\n return \"Overweight\"\n else:\n return \"Obese\"", "def bmi(w, h):\n s = w/h ** 2\n if s <= 18.5:\n return \"Underweight\"\n if s <= 25:\n return \"Normal\"\n if s<= 30:\n return \"Overweight\"\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight/(height ** 2)\n if bmi <= 18.5:\n risultato = \"Underweight\"\n elif bmi <= 25.0: \n risultato = \"Normal\"\n elif bmi <= 30.0: \n risultato = \"Overweight\"\n else: \n risultato = \"Obese\"\n return risultato", "def bmi(weight, height):\n #your code here\n bmi = weight/height ** 2\n if bmi <= 18.5:\n resultato = \"Underweight\"\n elif bmi <= 25:\n resultato = \"Normal\"\n elif bmi <= 30:\n resultato = \"Overweight\"\n else:\n resultato = \"Obese\"\n return resultato", "def bmi(weight, height):\n bmi_x = weight / height**2\n if bmi_x <= 18.5:\n return \"Underweight\";\n elif bmi_x <= 25.0:\n return \"Normal\";\n elif bmi_x <= 30.0:\n return \"Overweight\";\n else:\n return \"Obese\";", "def bmi(weight, height):\n bmi = weight / height ** 2\n res = None\n if bmi <= 18.5:\n res = \"Underweight\"\n elif bmi <= 25:\n res = 'Normal'\n elif bmi <= 30:\n res = 'Overweight'\n else:\n res = 'Obese'\n return res", "def bmi(weight, height):\n a = float(weight)\n b = float(height)\n b_m_i = a / b ** 2\n if b_m_i <= 18.5:\n return \"Underweight\"\n if b_m_i <= 25.0:\n return \"Normal\"\n if b_m_i <= 30.0:\n return \"Overweight\"\n if b_m_i > 30:\n return \"Obese\"\n \n #return \"Underweight\" if b_m_i <= 18.5 else \"Normal\" if b_m_i <= 25.0 else \"Overweight\" if b_m_i <= 30.0 else \"Obese\" if b_m_i > 30\n", "def bmi(weight, height):\n bmi = float(weight/height**2)\n \n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25.0:\n return \"Normal\"\n elif bmi <= 30.0:\n return \"Overweight\"\n elif bmi > 30:\n return \"Obese\"\n else:\n pass", "def bmi(weight, height):\n bmi = weight/(height*height)\n result = \"\"\n if bmi <= 18.5:\n result = \"Underweight\"\n elif bmi <= 25.0: \n result = \"Normal\"\n elif bmi < 30.0:\n result = \"Overweight\"\n elif bmi > 30:\n result = \"Obese\"\n return result\n", "def bmi(weight, height):\n b = weight/height/height\n if b <= 18.5: return 'Underweight'\n if b <= 25: return 'Normal'\n if b <= 30: return 'Overweight'\n return 'Obese'", "def bmi(weight, height):\n bmi = weight / height ** 2\n return \"Underweight\" if bmi <= 18.5 else \"Normal\" if 18.5 < bmi <= 25.0 else \"Overweight\" if 25 < bmi <= 30.0 else \"Obese\" ", "def bmi(weight, height):\n f = (weight / height)/ height\n if f <= 18.5:\n return \"Underweight\"\n elif f <= 25.0:\n return \"Normal\"\n elif f <= 30.0:\n return \"Overweight\"\n elif f > 30:\n return \"Obese\"", "def bmi(weight, height): \n bmi = weight / (height**2)\n print(weight,height,bmi)\n if bmi <= 18.5:\n return 'Underweight'\n elif bmi <= 25.0:\n return 'Normal'\n elif bmi <= 30.0:\n return 'Overweight'\n else:\n return 'Obese'", "def bmi(weight, height):\n #your code here\n b=(weight/(height**2))\n if(b<=18.5):\n return \"Underweight\"\n elif(18.5<b<=25.0):\n return \"Normal\"\n elif(25.0<b<=30.0):\n return \"Overweight\"\n else:\n return \"Obese\"", "def bmi(weight, height):\n bmi = (weight/height**2)\n if bmi <= 18.5:\n return \"Underweight\"\n if 18.5 < bmi <= 25:\n return \"Normal\"\n if 25 < bmi <= 30:\n return \"Overweight\"\n if bmi > 30:\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight / (height*height)\n return \"Underweight\" if bmi <= 18.5 else(\"Normal\" if bmi <= 25.0 else(\"Overweight\" if bmi <= 30 else \"Obese\")) ", "def bmi(weight, height):\n text = [\"Overweight\", \"Normal\", \"Underweight\", \"Obese\"]\n bmi = weight / (height**2)\n print(bmi)\n index = bool(bmi<=18.5) + bool(bmi<=25) + bool(bmi<=30)\n print(bool(bmi<=18.5), bool(bmi<=25), bool(bmi<=30), bool(bmi > 30))\n print(index)\n return text[index-1]", "def bmi(weight, height):\n bmi = round(weight / height / height, 2)\n if bmi <= 18.5:\n return \"Underweight\"\n if bmi <= 25.0:\n return \"Normal\"\n if bmi <= 30.0:\n return \"Overweight\"\n return \"Obese\"", "def bmi(weight, height):\n beem = round((weight/height**2),1)\n print(beem)\n if 18.5 >= beem:\n return \"Underweight\"\n elif 25.0 >= beem > 18.5:\n return \"Normal\"\n elif 30.0 >= beem > 18.5:\n return \"Overweight\"\n else:\n return \"Obese\"\n \n", "def bmi(w, h):\n b = w/(h*h)\n if b <= 18.5: return \"Underweight\"\n if b <= 25.0: return \"Normal\"\n if b <= 30.0: return \"Overweight\"\n if b > 30: return \"Obese\"", "def bmi(weight, height):\n b = weight/(height**2)\n if b > 30:\n return 'Obese'\n else:\n if b <= 25:\n if b <= 18.5:\n return 'Underweight'\n else:\n return 'Normal'\n else:\n return 'Overweight'", "def bmi(w, h):\n p = round(w // h // h, 1)\n return \"Underweight\" if p <= 18.5 else \"Normal\" if p <= 25.0 else \"Overweight\" if p <= 30 else \"Obese\"", "def bmi(weight, height):\n a = weight / height ** 2\n if a <= 18.5:\n return \"Underweight\" \n elif a <= 25.0:\n return \"Normal\"\n elif a <= 30.0:\n return \"Overweight\"\n elif a > 30:\n return \"Obese\"\n return \"You are Grasshopper\"\n #your code here\n", "def bmi(weight, height):\n bmi = weight / (height ** 2)\n if bmi <= 18.5:\n return \"Underweight\"\n elif bmi <= 25.0:\n return \"Normal\"\n elif bmi <= 30.0:\n return \"Overweight\"\n elif bmi > 30.0:\n return \"Obese\"\n else:\n print(\"wrong input\")\n #your code here\n", "def bmi(weight, height):\n bmi_score = weight/height**2\n print(bmi_score)\n if bmi_score <= 18.5: return \"Underweight\"\n elif bmi_score <= 25.0: return \"Normal\"\n elif bmi_score <= 30: return \"Overweight\"\n else: return \"Obese\"", "def bmi(weight, height):\n bmi = (weight/(height**2))\n print(bmi)\n \n if bmi <= 18.5:\n result = \"Underweight\"\n elif bmi <= 25:\n result = \"Normal\"\n elif bmi <= 30:\n result = \"Overweight\"\n elif bmi > 30:\n result = \"Obese\"\n \n return result", "def bmi(weight, height):\n x = weight / height ** 2\n return \"Obese\" if x > 30 else \"Overweight\" if x > 25 else \"Normal\" if x > 18.5 else \"Underweight\"", "def bmi(weight, height):\n x = weight / height**2\n if x <= 18.5:\n return \"Underweight\"\n if x <= 25:\n return \"Normal\"\n if x <= 30:\n return \"Overweight\"\n if x > 30:\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight / pow(height, 2)\n \n if bmi <= 18.5:\n output = 'Underweight'\n elif bmi <= 25:\n output = 'Normal'\n elif bmi <= 30:\n output = 'Overweight'\n else:\n output = 'Obese'\n \n return output", "def bmi(weight, height):\n b = weight / (height * height)\n health = {\n 18.5: 'Underweight',\n 25.0: 'Normal',\n 30.0: 'Overweight',\n }\n for i in list(health.keys()):\n if b <= i:\n return health[i]\n return 'Obese'\n", "def bmi(weight, height):\n #your code here\n bmi = weight / height ** 2\n if bmi > 30:\n result = \"Obese\"\n elif bmi > 25:\n result = \"Overweight\"\n elif bmi > 18.5:\n result = \"Normal\"\n else:\n result = \"Underweight\"\n \n return result", "def bmi(weight, height):\n are_you_fat = (weight) / (height**2)\n if are_you_fat <= 18.5:\n return 'Underweight'\n elif are_you_fat <= 25.0 and are_you_fat > 18.5:\n return \"Normal\"\n elif are_you_fat <= 30.0 and are_you_fat > 25.0:\n return \"Overweight\"\n else:\n return \"Obese\"", "def bmi(weight, height):\n score = float((weight / (height ** 2.0)))\n if score <= 18.5:\n return \"Underweight\"\n elif score <= 25.0:\n return \"Normal\"\n elif score <= 30.0:\n return \"Overweight\"\n else: \n return \"Obese\"\n", "def bmi(weight, height):\n calculation =weight/height**2\n if calculation <=18.5:\n return 'Underweight'\n if calculation <= 25.0:\n return 'Normal'\n if calculation <= 30.0:\n return 'Overweight'\n if calculation > 30:\n return 'Obese'", "def bmi(weight, height):\n bmi = weight / height ** 2\n \n if bmi <= 18.5:\n r = \"Underweight\"\n elif bmi <= 25:\n r = \"Normal\"\n elif bmi <= 30:\n r = \"Overweight\"\n else:\n r = \"Obese\"\n return r", "def bmi(w, h):\n return \"Underweight\" if w/(h**2)<=18.5 else \"Normal\" if w/(h**2)<=25 else \"Overweight\" if w/(h**2)<=30 else \"Obese\"", "def bmi(w, h):\n b = w / (h ** 2)\n if b > 30:\n return \"Obese\"\n elif b <= 18.5:\n return \"Underweight\"\n elif b <= 25.0:\n return \"Normal\"\n elif b <= 30.0:\n return \"Overweight\"", "def bmi(weight, height):\n bmi_is = weight/(height**2)\n if bmi_is <= 18.5:\n return 'Underweight'\n elif 18.5 < bmi_is <=25.0:\n return 'Normal'\n elif 25.0 < bmi_is <=30.0:\n return 'Overweight'\n else:\n return 'Obese'\n", "def bmi(weight, height):\n result = float(weight / height ** 2)\n if result <= 18.5:\n return \"Underweight\"\n elif result <= 25.0:\n return \"Normal\"\n elif result <= 30.0:\n return \"Overweight\"\n elif result > 30.0:\n return \"Obese\"", "def bmi(weight, height):\n bmi = weight / height ** 2\n if bmi <= 18.5:\n return 'Underweight'\n elif bmi <= 25:\n return 'Normal'\n elif bmi <= 30:\n return 'Overweight'\n elif bmi > 30:\n return 'Obese'\n else:\n return None ", "def bmi(weight, height):\n\n bmi = weight*10 // (height**2)\n\n if bmi in range(185): return 'Underweight'\n elif bmi in range(185, 250): return 'Normal'\n elif bmi in range(250, 300): return 'Overweight'\n elif bmi > 300: return 'Obese'", "def bmi(weight, height):\n body_mass=weight/height**2\n result=\"\"\n if body_mass<=18.5:\n result=\"Underweight\"\n elif body_mass<=25.0:\n result=\"Normal\"\n elif body_mass<=30.0:\n result=\"Overweight\"\n else:\n result=\"Obese\"\n return result", "def bmi(weight, height):\n stages_of_life = ['Underweight', 'Normal', 'Overweight', 'Obese']\n BMI = weight / height ** 2\n pointer = 0 if BMI <= 18.5 else 1 if BMI <= 25 else 2 if BMI <= 30 else 3\n return stages_of_life[pointer]"] | {"fn_name": "bmi", "inputs": [[50, 1.8], [80, 1.8], [90, 1.8], [110, 1.8], [50, 1.5]], "outputs": [["Underweight"], ["Normal"], ["Overweight"], ["Obese"], ["Normal"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 25,008 |
def bmi(weight, height):
|
77f4ccfa95d152e5fef470a00c51bea4 | UNKNOWN | In this Kata, you will be given an array of strings and your task is to remove all consecutive duplicate letters from each string in the array.
For example:
* `dup(["abracadabra","allottee","assessee"]) = ["abracadabra","alote","asese"]`.
* `dup(["kelless","keenness"]) = ["keles","kenes"]`.
Strings will be lowercase only, no spaces. See test cases for more examples.
~~~if:rust
For the sake of simplicity you can use the macro 'vec_of_string' to create a Vec with an array of string literals.
~~~
Good luck!
If you like this Kata, please try:
[Alternate capitalization](https://www.codewars.com/kata/59cfc000aeb2844d16000075)
[Vowel consonant lexicon](https://www.codewars.com/kata/59cf8bed1a68b75ffb000026) | ["from itertools import groupby\n\ndef dup(arry):\n return [\"\".join(c for c, grouper in groupby(i)) for i in arry]", "import re\n\ndef dup(arry):\n return list(map(lambda s: re.sub(r'(\\w)\\1+', r'\\1', s), arry))", "def dup(arry):\n array_new = []\n for string in arry:\n string_new = \"\"\n prev = None\n for char in string:\n if char != prev:\n string_new += char\n prev = char\n array_new.append(string_new)\n \n return array_new\n \n", "def dup(arr):\n a, res = 0, [x[0] for x in arr]\n for string in arr:\n for x in range(1, len(string)):\n if string[x] != string[x-1]:\n res[a] += string[x]\n a += 1\n return res", "from itertools import groupby\n\ndef dup(strings):\n return [''.join(c for c, _ in groupby(s)) for s in strings]", "import re\n\ndef dup(lst):\n return [re.sub(r\"(.)\\1+\", r\"\\1\", stg) for stg in lst]", "import re\n\ndef dup(xs):\n return [re.sub(r'(.)\\1+', r'\\1', x) for x in xs]", "def f(s):\n return ''.join(s[i] for i in range(len(s)-1) if s[i]!=s[i+1])+s[-1]\n\ndef dup(arry):\n return [f(s) for s in arry]", "from itertools import groupby\n\ndef dup(array):\n return list(map(remove_dup, array))\n\ndef remove_dup(string):\n return ''.join(single for single,_ in groupby(string))", "def dup(arry):\n stack=[]\n output=[]\n for item in arry:\n for i in item:\n if len(stack) ==0 or (len(stack) >=1 and i!=stack[-1]):\n stack.append(i) \n else:\n continue\n output.append(''.join(stack))\n stack =[]\n return output\n \n \n"] | {"fn_name": "dup", "inputs": [[["ccooddddddewwwaaaaarrrrsssss", "piccaninny", "hubbubbubboo"]], [["abracadabra", "allottee", "assessee"]], [["kelless", "keenness"]], [["Woolloomooloo", "flooddoorroommoonlighters", "chuchchi"]], [["adanac", "soonness", "toolless", "ppellee"]], [["callalloo", "feelless", "heelless"]], [["putteellinen", "keenness"]], [["kelless", "voorraaddoosspullen", "achcha"]]], "outputs": [[["codewars", "picaniny", "hubububo"]], [["abracadabra", "alote", "asese"]], [["keles", "kenes"]], [["Wolomolo", "flodoromonlighters", "chuchchi"]], [["adanac", "sones", "toles", "pele"]], [["calalo", "feles", "heles"]], [["putelinen", "kenes"]], [["keles", "voradospulen", "achcha"]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,729 |
def dup(arry):
|
5d416f6d009a8ef2ab6d74580ff3b1de | UNKNOWN | Trigrams are a special case of the n-gram, where n is 3. One trigram is a continious sequence of 3 chars in phrase. [Wikipedia](https://en.wikipedia.org/wiki/Trigram)
- return all trigrams for the given phrase
- replace spaces with \_
- return an empty string for phrases shorter than 3
Example:
trigrams('the quick red') == the he\_ e\_q \_qu qui uic ick ck\_ k\_r \_re red | ["def trigrams(phrase):\n phrase = phrase.replace(\" \", \"_\")\n return \" \".join([phrase[i:i+3]for i in range(len(phrase)-2)])\n", "def trigrams(phrase):\n solution = ''\n if len(phrase) < 3:\n return solution\n phrase = phrase.replace(' ','_')\n for i in range(len(phrase)-2):\n solution = solution + ' ' + phrase[i:i+3]\n return solution[1:]", "def trigrams(phrase):\n phrase = phrase.replace(' ', '_')\n return ' '.join(''.join(xs) for xs in zip(phrase, phrase[1:], phrase[2:]))", "def trigrams(phrase):\n\n s = phrase.replace(' ', '_')\n\n return ' '.join(s[i:i+3] for i in range(len(s)-2))", "def trigrams(p):\n r=\"\"\n for i in range(len(p)-2):\n r+=p[i:i+3].replace(\" \",\"_\")+\" \"\n return r.strip()", "def trigrams(phrase):\n p = phrase.replace(' ','_')\n return ' '.join([p[i:i+3] for i in range(len(p)-2)])\n", "def trigrams(s):\n return ' '.join([''.join(w).replace(' ', '_') for w in list(zip(s, s[1:], s[2:]))]) if len(s) > 2 else ''", "def trigrams(phrase):\n if len(phrase) < 3: return ''\n phrase = phrase.replace(\" \", \"_\")\n chars = [x for x in phrase]\n trigram = []\n for x in range(1, len(chars) - 1):\n trigram.append(chars[x-1] + chars[x] + chars[x+1])\n return ' '.join(trigram)", "def trigrams(phrase):\n svar = ''\n if len(phrase)<3:\n return ''\n else:\n phrase = phrase.replace(\" \", \"_\")\n for i in range(len(phrase)-2):\n svar = svar + ' ' + phrase[i:i+3]\n return svar[1:]\n \n", "def trigrams(phrase):\n if len(phrase) < 3:\n return ''\n phrase = phrase.replace(' ', '_')\n ret = []\n for i in range(len(phrase) - 2):\n ret.append(phrase[i:i + 3])\n return ' '.join(ret)"] | {"fn_name": "trigrams", "inputs": [["the quick red"], ["Hi"]], "outputs": [["the he_ e_q _qu qui uic ick ck_ k_r _re red"], [""]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,790 |
def trigrams(phrase):
|
c80c726accda7f21c95b697fe73ebc09 | UNKNOWN | The citizens of Codeland read each word from right to left, meaning that lexicographical comparison works differently in their language. Namely, string ```a``` is lexicographically smaller than string ```b``` if either: ```a``` is a suffix of ```b``` (in common sense, i.e. ```b``` ends with a substring equal to ```a```); or their last ```k``` characters are the same but the ```(k + 1)th``` character from the right in string ```a``` is smaller than the same character in string ```b```.
Given an array of words in Codeland language, sort them lexicographically according to Codeland's unique rules.
For ```words = ["nigeb", "ta", "eht", "gninnigeb"]```, the output should be
```unusualLexOrder(words) = ["ta", "nigeb", "gninnigeb", "eht"]```.
In particular, ```"ta" < "nigeb"``` because ```'a' < 'b'``` and ```"nigeb" < "gninnigeb"``` because the former word is a suffix of the latter.
S: codefights.com | ["def unusual_lex_order(a):\n return sorted(a, key=lambda k: k[::-1])", "def unusual_lex_order(arr):\n return sorted(arr, key=lambda s: s[::-1])", "def unusual_lex_order(arr):\n return sorted(arr, key = lambda x: x[::-1])", "def unusual_lex_order(arr):\n return sorted(arr, key = lambda word: word[::-1])", "def unusual_lex_order(lst):\n return sorted(lst, key=lambda x: x[::-1])", "def unusual_lex_order(strings):\n return sorted(strings, key=lambda s: s[::-1])", "def unusual_lex_order(arr):\n return sorted(arr,key = lambda item : (item[-1])) if all(len(x) == 1 for x in arr) else sorted(arr,key = lambda item : (item[-1],item[-2])) if any(len(x) == 2 for x in arr) else sorted(arr,key = lambda item : (item[-1],item[-2],item[-3]))", "def unusual_lex_order(arr):\n arr2 = []\n for elem in arr:\n arr2.append(elem[::-1])\n arr2 = sorted(arr2)\n arr3 = []\n for elem in arr2:\n arr3.append(elem[::-1])\n return arr3", "def unusual_lex_order(arr):\n return sorted(arr, key=lambda x: (x[::-1], len(x)))", "def unusual_lex_order(arr):\n ans = [s[::-1] for s in arr]\n ans.sort()\n return [s[::-1] for s in ans]"] | {"fn_name": "unusual_lex_order", "inputs": [[["nigeb", "ta", "eht", "gninnigeb"]], [["a", "b", "a", "d", "c"]]], "outputs": [[["ta", "nigeb", "gninnigeb", "eht"]], [["a", "a", "b", "c", "d"]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,175 |
def unusual_lex_order(arr):
|
8cd90d99ef3d5edeedcc550c8746a976 | UNKNOWN | # Your Task
The city of Darkishland has a strange hotel with infinite rooms. The groups that come to this hotel follow the following rules:
* At the same time only members of one group can rent the hotel.
* Each group comes in the morning of the check-in day and leaves the hotel in the evening of the check-out day.
* Another group comes in the very next morning after the previous group has left the hotel.
* A very important property of the incoming group is that it has one more member than its previous group unless it is the starting group. You will be given the number of members of the starting group.
* A group with n members stays for n days in the hotel. For example, if a group of four members comes on 1st August in the morning, it will leave the hotel on 4th August in the evening and the next group of five members will come on 5th August in the morning and stay for five days and so on.
Given the initial group size you will have to find the group size staying in the hotel on a specified day.
# Input
S denotes the initial size of the group and D denotes that you will have to find the group size staying in the hotel on D-th day (starting from 1). A group size S
means that on the first day a group of S members comes to the hotel and stays for S days. Then comes a group of S + 1 members according to the previously described rules and so on. | ["from math import floor\ndef group_size(S, D):\n return floor((2*D+S*(S-1))**.5+.5)", "from math import sqrt, ceil\n\n# 1st group spends in the hotel s days,\n# 2nd group - s + 1 days,\n# 3rd group - s + 2 days,\n# ...,\n# nth group - s + n - 1 days.\n#\n# The total number of days for n groups: n * (s + s + n - 1) / 2 \n# (by the formula of arithmetic series).\n# Let d be the last day of the nth group. Then\n# n * (s + s + n - 1) / 2 = d, \n# n**2 + (2*s-1)*n - 2*d = 0, \n# The only possible root of this quadratic equation equals\n# 1/2 * (-p + sqrt(p**2 - 4*q), where p = 2*s - 1, q = 2*d. \n# Thus, n = (1 - 2*s + sqrt((2*s - 1)**2 + 8*d)) / 2.\n# But if d is not the last day of the group n, then n will be fractional,\n# and we have to round it up (get the ceiling of n).\n\ndef group_size(s, d):\n n = ceil((1 - 2*s + sqrt((2*s - 1)**2 + 8*d)) / 2)\n return s + n - 1", "from math import sqrt\n\ndef group_size(size, day):\n skip = size * (size - 1) // 2\n day += skip\n return round(sqrt(day * 2))", "from math import floor,sqrt\n\ndef group_size(s,d):\n return floor(sqrt(2*d+s*(s-1))+0.5)", "def group_size(S, D):\n a000217 = lambda n: (n + 1) * n // 2\n a002024 = lambda n: int((1 + (1 + 8 * n) ** .5) / 2)\n return a002024(D - 1 + a000217(S - 1))", "from math import ceil\n\ndef group_size(S, D):\n return ceil((0.25 + 2 * D + S * (S - 1))**0.5 - 0.5)", "group_size=lambda S,D:((2*D+S*S-S)**.5+.5)//1", "from math import ceil\ndef group_size(S,D):\n b=2*S-1\n return ceil((-b+(b**2+8*D)**0.5)/2)-1+S", "from math import ceil\ndef group_size(S, D):\n return ceil(((1+4*(S**2-S+2*D))**.5-1)/2)", "import math\n\ndef group_size(S, D):\n return math.ceil(((-1 +(1 - 4 * S + 4 * S ** 2 + 8 * D) ** 0.5) / 2))\n"] | {"fn_name": "group_size", "inputs": [[1, 6], [3, 10], [3, 14], [10, 1000], [1, 1000], [5, 4], [5, 7], [10000, 1000000000000000], [2, 20000000000000], [10, 900000000000000000], [34545, 565], [234234, 6577], [10, 10]], "outputs": [[3], [5], [6], [46], [45], [5], [6], [44721361], [6324555], [1341640786], [34545], [234234], [10]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,784 |
def group_size(S, D):
|
f0e69e970130d011433cb1ca8cbf8924 | UNKNOWN | Philip's just turned four and he wants to know how old he will be in various years in the future such as 2090 or 3044. His parents can't keep up calculating this so they've begged you to help them out by writing a programme that can answer Philip's endless questions.
Your task is to write a function that takes two parameters: the year of birth and the year to count years in relation to. As Philip is getting more curious every day he may soon want to know how many years it was until he would be born, so your function needs to work with both dates in the future and in the past.
Provide output in this format: For dates in the future: "You are ... year(s) old." For dates in the past: "You will be born in ... year(s)." If the year of birth equals the year requested return: "You were born this very year!"
"..." are to be replaced by the number, followed and proceeded by a single space. Mind that you need to account for both "year" and "years", depending on the result.
Good Luck! | ["def calculate_age(year_of_birth, current_year):\n diff = abs(current_year - year_of_birth)\n plural = '' if diff == 1 else 's'\n if year_of_birth < current_year:\n return 'You are {} year{} old.'.format(diff, plural)\n elif year_of_birth > current_year:\n return 'You will be born in {} year{}.'.format(diff, plural)\n return 'You were born this very year!'", "def calculate_age(birth, curr):\n diff = abs(curr - birth)\n age = \"%d year%s\" % (diff, \"s\" * bool(diff-1))\n return \"You were born this very year!\" if not diff else \"You are %s old.\" % age if curr > birth else \"You will be born in %s.\" % age", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age == 0:\n return \"You were born this very year!\"\n elif age > 0:\n return \"You are {} year{} old.\".format(age, 's' if age > 1 else '')\n else:\n return \"You will be born in {} year{}.\".format(abs(age), 's' if abs(age) > 1 else '')", "def calculate_age(birth_year, this_year):\n results, plural = this_year-birth_year, ''\n \n if abs(results) != 1: \n plural = 's'\n \n if results > 0: \n return 'You are %s year%s old.' % (results, plural)\n elif results < 0:\n return 'You will be born in %s year%s.' % (abs(results), plural)\n elif results == 0: \n return 'You were born this very year!'", "def calculate_age(birth_year, current_year):\n results, plural = current_year-birth_year, ''\n \n if abs(results) != 1:\n plural = 's'\n \n if results > 0: \n out = 'You are %s year%s old.' % (results, plural)\n elif results == 0: \n out = 'You were born this very year!'\n else:\n out = 'You will be born in %s year%s.' % (abs(results), plural)\n return out", "def calculate_age(year_of_birth, current_year):\n year = (year_of_birth - current_year)\n c1 = f\"You are {abs(year)} {['year','years'][abs(year)!=1]} old.\"\n c2 = f\"You will be born in {year} {['year','years'][year!=1]}.\"\n return 'You were born this very year!' if not year else [c1,c2][year >0 ]", "def calculate_age(dob, now):\n return f\"You will be born in {dob-now} {'years'if dob-now>1 else 'year'}.\" if dob>now else \"You were born this very year!\" if dob==now else f\"You are {now-dob} {'years'if now-dob>1 else 'year'} old.\"", "def calculate_age(year_of_birth, current_year):\n year = current_year - year_of_birth\n if year > 1: return f'You are {year} years old.'\n if year == 1: return f'You are {year} year old.'\n if year == -1: return f'You will be born in {abs(year)} year.'\n if year < 0: return f'You will be born in {abs(year)} years.'\n else: return 'You were born this very year!'\n", "def calculate_age(year_of_birth, current_year):\n a = abs(current_year - year_of_birth)\n if not a:\n return 'You were born this very year!'\n else:\n return (f'You are {a} year{(\"\", \"s\")[a>1]} old.', f'You will be born in {a} year{(\"\", \"s\")[a>1]}.')[current_year < year_of_birth]", "def calculate_age(year_of_birth, current_year):\n diff = current_year - year_of_birth\n s = 's' if abs(diff) > 1 else ''\n return f'You are {diff} year{s} old.' if diff > 0 else f'You will be born in {-diff} year{s}.' if diff < 0 else 'You were born this very year!'", "def calculate_age(birth, current):\n total = abs(current - birth)\n plural = 's' if total > 1 else ''\n if birth == current: return \"You were born this very year!\"\n return \"You will be born in {} year{}.\".format(total, plural) if birth > current else \"You are {} year{} old.\".format(total, plural)", "calculate_age = lambda b,c: [\"You will be born in {} year{}.\", \"You were born this very year!\", \"You are {} year{} old.\"][((c-b)>=0) + ((c-b)>0)].format(abs(c-b), 's' if abs(c-b)!=1 else '')", "def calculate_age(yob, cy):\n return ['You will be born in %s %s.' % (yob-cy, ['years', 'year'][(yob-cy)<2]),\n 'You are %s %s old.' % (cy - yob, ['years', 'year'][(cy - yob) < 2])][cy-yob>0] if (cy-yob) != 0 \\\n else \"You were born this very year!\"", "calculate_age=lambda b, y: (lambda d: \"You are %s year%s old.\" %(d,\"s\" if d!=1 else \"\") if d>0 else \"You will be born in %s year%s.\" %(-d,\"s\" if d!=-1 else \"\") if d<0 else \"You were born this very year!\")(y-b)", "def calculate_age(year_of_birth: int, current_year: int) -> str:\n \"\"\" Calculate how many years it was until a person would be born based on given data. \"\"\"\n age = current_year - year_of_birth\n if age > 0:\n return f\"You are {age} {'year' if age == 1 else 'years'} old.\"\n elif age < 0:\n return f\"You will be born in {abs(age)} {'year' if abs(age) == 1 else 'years'}.\"\n else:\n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age == 0: return \"You were born this very year!\"\n if age == 1: return \"You are 1 year old.\"\n if age > 1: return \"You are \" + str(age) + \" years old.\"\n if age == -1: return \"You will be born in 1 year.\"\n return \"You will be born in \" + str(abs(age)) + \" years.\"", "def calculate_age(year_of_birth, current_year):\n dif = year_of_birth-current_year\n return \"You \"+[\"are {} year{} old.\", \"will be born in {} year{}.\"][dif>0].format(abs(dif), \"s\"*(abs(dif)!=1)) if dif else \"You were born this very year!\"", "def calculate_age(b, c):\n return 'You are {} {} old.'.format(c-b, 'years' if c-b > 1 else 'year') if c>b else 'You will be born in {} {}.'.format(b-c, 'years' if b-c > 1 else 'year') if b>c else 'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n diff = current_year - year_of_birth\n return (f\"You are {diff} year{'s' * (diff > 1)} old.\" if diff > 0 else \n f\"You will be born in {-diff} year{'s' * (-diff > 1)}.\" if diff < 0 else \n \"You were born this very year!\")", "def calculate_age(year_of_birth, current_year):\n r = year_of_birth - current_year\n\n if r == 0: return 'You were born this very year!'\n elif abs(r) > 1: year = 'years'\n else: year = 'year'\n\n return f'You will be born in {r} {year}.' if r > 0 else f'You are {abs(r)} {year} old.'", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age > 1:\n return f\"You are {age} years old.\"\n elif age == 1:\n return f\"You are {age} year old.\"\n elif age < -1:\n return f\"You will be born in {-age} years.\"\n elif age == -1:\n return f\"You will be born in {-age} year.\"\n else:\n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n return [\n \"You are {} year{} old.\".format(age,'s' if age > 1 else ''),\n \"You will be born in {} year{}.\".format(abs(age),'s' if abs(age) > 1 else ''),\n \"You were born this very year!\"\n ][0 if age > 0 else (1 if age < 0 else 2)]", "def calculate_age(year_of_birth, current_year):\n if current_year - year_of_birth > 0: return 'You are %d year%s old.' %(current_year - year_of_birth, '' if current_year - year_of_birth == 1 else 's')\n elif current_year - year_of_birth < 0: return 'You will be born in %d year%s.' %(year_of_birth - current_year, '' if year_of_birth - current_year == 1 else 's')\n else: return 'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n diff = current_year - year_of_birth\n if diff == 0:\n return \"You were born this very year!\"\n elif diff == 1:\n return \"You are {} year old.\".format(diff)\n elif diff > 1:\n return \"You are {} years old.\".format(diff)\n elif diff == -1:\n return \"You will be born in {} year.\".format(abs(diff))\n elif diff < -1:\n return \"You will be born in {} years.\".format(abs(diff))", "def calculate_age(year_of_birth, current_year):\n diff = current_year - year_of_birth\n return \"You are {} {} old.\".format(diff,\"year\" if diff == 1 else \"years\") if diff > 0 else \"You will be born in {} {}.\".format(-diff,\"year\" if diff == -1 else \"years\") if diff < 0 else \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n years = abs(year_of_birth - current_year)\n if years == 1 and year_of_birth < current_year: return \"You are 1 year old.\"\n if years == 1 and year_of_birth > current_year: return \"You will be born in 1 year.\"\n return f\"You are {years} years old.\" if year_of_birth < current_year else f\"You will be born in {years} years.\" if year_of_birth > current_year else \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n s = \"s\" if abs(current_year-year_of_birth) > 1 else \"\"\n return \"You were born this very year!\" if year_of_birth == current_year else f\"You are {current_year - year_of_birth} year{s} old.\" if current_year > year_of_birth else f\"You will be born in {year_of_birth-current_year} year{s}.\"", "def calculate_age(year_of_birth, current_year):\n ans = current_year - year_of_birth\n if ans == 0:\n ans = \"You were born this very year!\"\n elif ans == 1:\n ans = \"You are 1 year old.\"\n elif ans < 1 and ans != -1:\n ans = \"You will be born in \" + str(ans * -1) + \" years.\"\n elif ans == -1:\n ans = \"You will be born in 1 year.\"\n else:\n ans = \"You are \" + str(ans) + \" years old.\"\n return ans", "def calculate_age(year_of_birth, current_year):\n difference = current_year - year_of_birth\n if difference == 1:\n return \"You are 1 year old.\"\n if difference == -1:\n return \"You will be born in 1 year.\"\n if difference > 0:\n return \"You are {difference} years old.\".format(difference = difference)\n if difference == 0:\n return \"You were born this very year!\"\n else:\n difference = abs(difference)\n return \"You will be born in {difference} years.\".format(difference = difference)", "def calculate_age(year_of_birth, current_year):\n \n age = current_year - year_of_birth\n \n if age == 0:\n return \"You were born this very year!\"\n \n if age > 0:\n return f\"You are {age} year{'s' if age != 1 else ''} old.\"\n \n if age < 0:\n return f\"You will be born in {-age} year{'s' if age != -1 else ''}.\"\n", "def calculate_age(yob, cy):\n if cy == yob+1:\n return \"You are 1 year old.\"\n if yob == cy+1:\n return \"You will be born in 1 year.\"\n return \"You were born this very year!\" if yob == cy else f\"You are {cy-yob} years old.\" \\\n if cy>yob else f\"You will be born in {yob-cy} years.\"", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age < 0:\n return f\"You will be born in {abs(age)} {'year' if age == -1 else 'years'}.\"\n if age == 0:\n return 'You were born this very year!'\n return f\"You are {age} {'year' if age == 1 else 'years'} old.\"", "def calculate_age(b, c):\n if c - b > 1:\n return \"You are {} years old.\".format(c - b)\n elif c - b == 1:\n return \"You are 1 year old.\"\n elif c == b:\n return \"You were born this very year!\"\n elif b - c > 1:\n return \"You will be born in {} years.\".format(b - c)\n else:\n return \"You will be born in 1 year.\"", "def calculate_age(year_of_birth, current_year):\n d = current_year - year_of_birth\n if d > 0:\n if d == 1:\n return 'You are ' + str(d) + ' year old.'\n else:\n return 'You are ' + str(d) + ' years old.'\n elif d < 0:\n if d == -1:\n return 'You will be born in ' + str(-d) + ' year.'\n else:\n return 'You will be born in ' + str(-d) + ' years.'\n else:\n return 'You were born this very year!'\n \n \n", "def calculate_age(year_of_birth, current_year):\n if year_of_birth == current_year:\n return \"You were born this very year!\"\n elif current_year - year_of_birth == 1:\n return \"You are 1 year old.\"\n elif year_of_birth - current_year == 1:\n return \"You will be born in 1 year.\"\n elif year_of_birth < current_year:\n return f\"You are {current_year - year_of_birth} years old.\"\n else:\n return f\"You will be born in {year_of_birth - current_year} years.\"", "def calculate_age(year_of_birth, current_year):\n if current_year > year_of_birth and current_year - year_of_birth == 1:\n return 'You are 1 year old.'\n elif current_year > year_of_birth and current_year - year_of_birth != 1:\n return f'You are {current_year - year_of_birth} years old.'\n elif current_year == year_of_birth:\n return 'You were born this very year!'\n elif year_of_birth - current_year == 1:\n return 'You will be born in 1 year.'\n else: \n return f'You will be born in {year_of_birth - current_year} years.'", "def calculate_age(b, c):\n return f\"You will be born in {str(b-c)+' year' if b-c<=1 else str(b-c)+' years'}.\" if c-b<0 else f\"You were born this very year!\" if c==b else f\"You are {str(c-b)+' year' if c-b<=1 else str(c-b)+' years'} old.\"", "def calculate_age(year_of_birth, current_year):\n if current_year - year_of_birth == 1:\n return \"You are 1 year old.\"\n elif year_of_birth - current_year == 1:\n return \"You will be born in 1 year.\"\n elif current_year > year_of_birth:\n return f\"You are {current_year-year_of_birth} years old.\"\n elif year_of_birth > current_year:\n return f\"You will be born in {year_of_birth-current_year} years.\"\n else:\n return \"You were born this very year!\"\n", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n text = \"You were born this very year!\"\n if age > 0:\n text = f\"You are {age} year{'s'*(age>1)} old.\"\n elif age<0:\n text = f\"You will be born in {abs(age)} year{'s'*(abs(age)>1)}.\"\n return text", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n \n if age > 0: return f\"You are {age} years old.\" if age > 1 else \"You are 1 year old.\"\n if age < 0: return \"You will be born in 1 year.\" if age == -1 else f\"You will be born in {abs(age)} years.\"\n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n years = current_year - year_of_birth\n \n \n if years == 0:\n return \"You were born this very year!\"\n elif years == 1:\n return \"You are 1 year old.\" \n elif years > 1:\n return f\"You are {years} years old.\" \n elif years == -1:\n return \"You will be born in 1 year.\"\n else:\n return f\"You will be born in {abs(years)} years.\"\n", "def calculate_age(y, cy):\n r = cy-y\n y = \"year\" + ((abs(r)>1 or \"\") and \"s\")\n return f\"You are {r} {y} old.\" if r > 0 else f\"You will be born in {r*-1} {y}.\" if r<0 else \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n x = year_of_birth\n y = current_year\n if (x < y) and (y-x) == 1:\n return(\"You are\" + \" \" + str(y-x) + \" \" + \"year old.\")\n elif x < y:\n return(\"You are\" + \" \" + str(y-x) +\" \"+\"years old.\")\n elif (x > y) and (x-y) == 1:\n return(\"You will be born in\" + \" \" + str(x-y)+ \" \" +\"year.\")\n elif x > y:\n return(\"You will be born in\"+ \" \" + str(x-y)+ \" \" +\"years.\")\n else:\n return(\"You were born this very year!\")\n \n", "def calculate_age(year_of_birth, current_year):\n diff=abs(year_of_birth-current_year)\n if diff==1 and year_of_birth<current_year:\n return f\"You are {current_year-year_of_birth} year old.\"\n if diff!=1 and year_of_birth<current_year:\n return f\"You are {current_year-year_of_birth} years old.\"\n if diff==1 and year_of_birth>current_year:\n return f\"You will be born in {abs(current_year-year_of_birth)} year.\"\n if year_of_birth>current_year:\n return f\"You will be born in {abs(current_year-year_of_birth)} years.\"\n else:\n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n return f\"You are {age} year{'s' if age > 1 else ''} old.\" if age >= 1 \\\n else f\"You will be born in {abs(age)} year{'s' if age < -1 else ''}.\" if age < 0 \\\n else \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n age = current_year-year_of_birth\n if age > 1:\n return 'You are {} years old.'.format(age)\n elif age == 0:\n return 'You were born this very year!'\n elif age < -1:\n return 'You will be born in {} years.'.format(-age)\n elif age == 1:\n return 'You are 1 year old.'\n elif age == -1:\n return 'You will be born in 1 year.'", "def calculate_age(year_of_birth: int, current_year: int) -> str:\n \"\"\"Year report depending on year of birth and current year.\"\"\"\n def year_str(y:int) -> str:\n return \"1 year\" if y == 1 else str(y)+\" years\"\n delta = current_year - year_of_birth\n if delta == 0:\n return \"You were born this very year!\"\n elif delta > 0:\n return \"You are \" + year_str(delta) + \" old.\"\n else:\n return \"You will be born in \" + year_str(-delta) + \".\"", "def calculate_age(b, c):\n if b==c : return 'You were born this very year!'\n if c-b == 1 : return 'You are 1 year old.'\n if c>b : return 'You are {} years old.'.format(c-b)\n if b-c == 1 : return 'You will be born in 1 year.'\n if b>c : return 'You will be born in {} years.'.format(b-c)", "def calculate_age(year_of_birth, current_year):\n age = abs(year_of_birth - current_year)\n \n if year_of_birth < current_year:\n if age == 1:\n return 'You are {} year old.'.format(current_year - year_of_birth)\n return 'You are {} years old.'.format(current_year - year_of_birth)\n elif year_of_birth > current_year:\n if age == 1:\n return 'You will be born in {} year.'.format(year_of_birth - current_year)\n return 'You will be born in {} years.'.format(year_of_birth - current_year)\n else:\n return 'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n age = abs(current_year - year_of_birth)\n if current_year - year_of_birth == 1: return 'You are 1 year old.'\n if current_year - year_of_birth == -1: return 'You will be born in 1 year.'\n if current_year > year_of_birth: return f'You are {age} years old.'\n if current_year < year_of_birth: return f'You will be born in {age} years.'\n else: return 'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n diff = current_year - year_of_birth\n if diff > 1:\n return f'You are {diff} years old.' \n elif diff<-1: \n return f'You will be born in {-diff} years.'\n elif diff == -1:\n return f'You will be born in {-diff} year.'\n elif diff == 1:\n return f'You are {diff} year old.' \n else:\n return 'You were born this very year!'#your code here", "def calculate_age(year_of_birth, current_year):\n a = current_year - year_of_birth\n if a > 1:\n return f'You are {a} years old.'\n elif a == 0:\n return 'You were born this very year!'\n elif a == 1:\n return f'You are {a} year old.'\n elif a == -1:\n return f'You will be born in {abs(a)} year.'\n else:\n return f'You will be born in {abs(a)} years.'", "def calculate_age(year_of_birth, current_year):\n gap = current_year - year_of_birth\n if gap > 0: return \"You are {} year{} old.\".format(gap, 's' if gap>1 else '')\n if gap < 0: return \"You will be born in {} year{}.\".format(-gap, 's' if gap<-1 else '')\n return \"You were born this very year!\"\n", "def calculate_age(year_of_birth, current_year):\n if current_year - year_of_birth == 1:\n return \"You are 1 year old.\"\n elif year_of_birth - current_year == 1:\n return \"You will be born in 1 year.\"\n elif current_year - year_of_birth > 0:\n return \"You are \" + str(current_year - year_of_birth) + \" years old.\"\n elif year_of_birth - current_year > 0:\n return \"You will be born in \" + str(year_of_birth - current_year) + \" years.\"\n elif year_of_birth == current_year: \n return \"You were born this very year!\"\n \n", "def calculate_age(year_of_birth, current_year):\n if current_year > year_of_birth:\n if current_year-year_of_birth==1:\n return 'You are {} year old.'.format(current_year-year_of_birth)\n else:\n return 'You are {} years old.'.format(current_year-year_of_birth) \n elif current_year==year_of_birth:\n return 'You were born this very year!'\n else:\n if year_of_birth-current_year==1:\n return 'You will be born in {} year.'.format(year_of_birth-current_year) \n else:\n return 'You will be born in {} years.'.format(year_of_birth-current_year) \n \n \n", "def calculate_age(year_of_birth, current_year):\n s='s'\n if current_year>year_of_birth:\n return f'You are {current_year-year_of_birth} year{s if current_year-year_of_birth!=1 else \"\"} old.'\n if year_of_birth>current_year:\n return f'You will be born in {year_of_birth-current_year} year{s if -current_year+year_of_birth!=1 else \"\"}.'\n if year_of_birth==current_year:\n return 'You were born this very year!'\n", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age == 0: return 'You were born this very year!'\n elif age == 1: return f'You are {age} year old.'\n elif age > 1: return f'You are {age} years old.'\n elif age ==-1: return f'You will be born in {-age} year.'\n else: return f'You will be born in {-age} years.'\n", "def calculate_age(year_of_birth, current_year):\n if year_of_birth - current_year == 1:\n return \"You will be born in 1 year.\"\n elif current_year - year_of_birth == 1:\n return \"You are 1 year old.\"\n elif year_of_birth < current_year:\n return \"You are {} years old.\".format(current_year - year_of_birth)\n elif year_of_birth > current_year:\n return \"You will be born in {} years.\".format(year_of_birth - current_year)\n else: \n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n if current_year == year_of_birth: return \"You were born this very year!\"\n elif current_year - year_of_birth == 1: return \"You are 1 year old.\"\n elif current_year > year_of_birth: return \"You are {} years old.\".format(current_year - year_of_birth)\n elif current_year - year_of_birth == -1: return \"You will be born in 1 year.\"\n else: return \"You will be born in {} years.\".format(year_of_birth - current_year)", "def calculate_age(year_of_birth, current_year):\n if current_year-year_of_birth==1:\n return f'You are {current_year-year_of_birth} year old.'\n elif current_year > year_of_birth:\n return f'You are {current_year-year_of_birth} years old.'\n elif year_of_birth-current_year==1:\n return f'You will be born in {year_of_birth-current_year} year.'\n elif year_of_birth>current_year:\n return f'You will be born in {year_of_birth-current_year} years.'\n elif year_of_birth==current_year:\n return 'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n x = year_of_birth\n y = current_year\n if x < y:\n if y - x == 1:\n return \"You are 1 year old.\"\n else:\n w = str(y - x)\n return \"You are \" + w + \" years old.\"\n elif x == y:\n return \"You were born this very year!\"\n elif x > y:\n if x - y == 1:\n return \"You will be born in 1 year.\"\n else:\n k = str(x - y)\n return \"You will be born in \" + k + \" years.\"", "def calculate_age(year_of_birth, current_year):\n ad = current_year - year_of_birth # Age Difference\n sfx = 's'*(abs(ad)>1) # Suffix\n return \"You were born this very year!\" if ad is 0 else f\"You will be born in {abs(ad)} year{sfx}.\" if ad < 0 else f\"You are {ad} year{sfx} old.\"\n", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age == 1:\n return \"You are 1 year old.\"\n elif age == 0:\n return \"You were born this very year!\";\n elif age < -1:\n return \"You will be born in \" + str(-age) + \" years.\";\n elif age == -1:\n return \"You will be born in 1 year.\";\n else:\n return \"You are \" + str(age) +\" years old.\";", "def calculate_age(year_of_birth, current_year):\n y = current_year - year_of_birth\n if y == 0:\n return 'You were born this very year!'\n else:\n s = 's' if abs(y) != 1 else ''\n if y > 0:\n return 'You are {} year{} old.'.format(y, s)\n else:\n return 'You will be born in {} year{}.'.format(abs(y), s)\n \n", "def calculate_age(a, b):\n if abs(a-b)>1:\n if b>a:\n return 'You are ' +str((b-a))+ ' years old.'\n elif b<a:\n return 'You will be born in '+str((a-b))+ ' years.'\n elif a-b==0:\n return 'You were born this very year!'\n elif b-a==1:\n return 'You are 1 year old.'\n elif a-b==1:\n return 'You will be born in 1 year.'", "def calculate_age(y, c):\n if y<c:\n return \"You are {} {} old.\".format(c-y,(\"year\" if c-y==1 else \"years\"))\n elif y>c:\n return \"You will be born in {} {}.\".format(y-c,(\"year\" if y-c==1 else \"years\"))\n else:\n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n x = year_of_birth - current_year\n if x > 1:\n return 'You will be born in ' + str(x) + ' years.'\n if x < -1:\n return 'You are ' + str(-1*x) + ' years old.'\n if x == 0:\n return 'You were born this very year!'\n if x == -1:\n return 'You are 1 year old.'\n if x == 1:\n return 'You will be born in 1 year.'", "def calculate_age(y, c):\n year= \"years\"\n if c+1== y or c-1==y or c==y:\n year = \"year\" \n return \"You are \" + str(c-y) +\" \"+ year + \" old.\" if c>y else \"You will be born in \" \\\n + str(y-c) +\" \"+ year + \".\" if y>c else \"You were born this very \"+ year + \"!\"", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age == 1 :\n return \"You are 1 year old.\"\n elif age == -1 :\n return \"You will be born in 1 year.\"\n elif age > 0:\n return \"You are {} years old.\".format(age)\n elif age == 0:\n return \"You were born this very year!\"\n else:\n return \"You will be born in {} years.\".format(abs(age))", "def calculate_age(year_of_birth, current_year):\n return \"You were born this very year!\" if year_of_birth == current_year else \"You are {} year{} old.\".format(current_year-year_of_birth, \"s\" if current_year-year_of_birth != 1 else \"\") if current_year > year_of_birth else \"You will be born in {} year{}.\".format(year_of_birth-current_year, \"s\" if current_year-year_of_birth != -1 else \"\")", "def calculate_age(year_of_birth, current_year):\n y = current_year - year_of_birth\n if y == 1:\n return \"You are 1 year old.\"\n elif y == -1:\n return \"You will be born in 1 year.\"\n elif y > 1:\n return \"You are {} years old.\".format(y) \n elif y < -1: \n return \"You will be born in {} years.\".format(abs(y))\n elif y == 0:\n return \"You were born this very year!\" ", "def calculate_age(year_of_birth, current_year):\n \n age = abs(current_year - year_of_birth)\n \n if year_of_birth < current_year:\n return f\"You are {age} years old.\" if age > 1 else f\"You are {age} year old.\"\n elif year_of_birth > current_year:\n return f\"You will be born in {age} years.\" if age > 1 else f\"You will be born in {age} year.\"\n else:\n return f\"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n difference=current_year-year_of_birth\n if difference<0:\n return \"You will be born in \" +str(abs(difference))+\" years.\" if difference!=-1 else \"You will be born in 1 year.\"\n elif difference>0:\n return \"You are \" +str(difference)+\" years old.\" if difference!=1 else \"You are 1 year old.\"\n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n if year_of_birth < current_year:\n yearsOld= current_year- year_of_birth\n if yearsOld==1:\n return \"You are \"+ str(yearsOld )+\" year old.\"\n else:\n return \"You are \"+ str(yearsOld )+\" years old.\"\n elif year_of_birth > current_year:\n yearsOld= year_of_birth - current_year\n if yearsOld==1:\n return \"You will be born in \"+ str(yearsOld )+\" year.\"\n else:\n return \"You will be born in \"+ str(yearsOld )+\" years.\"\n elif year_of_birth == current_year:\n yearsOld= year_of_birth\n return \"You were born this very year!\"\n #your code here\n", "def calculate_age(year_of_birth, current_year):\n if year_of_birth > current_year :\n if year_of_birth - current_year == 1 :\n return \"You will be born in 1 year.\"\n return f\"You will be born in {year_of_birth - current_year} years.\"\n elif year_of_birth < current_year :\n if current_year - year_of_birth == 1 :\n return \"You are 1 year old.\"\n return f\"You are {current_year - year_of_birth} years old.\"\n else :\n return \"You were born this very year!\"\n", "def calculate_age(y, c):\n if c-y==1:\n return f'You are 1 year old.'\n if y-c==1:\n return f'You will be born in 1 year.'\n if c>y:\n return f'You are {c-y} years old.'\n if c<y:\n return f'You will be born in {y-c} years.'\n if c==y:\n return 'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n if year_of_birth == current_year:\n return \"You were born this very year!\"\n elif year_of_birth - current_year == 1:\n return f\"You will be born in 1 year.\"\n elif current_year - year_of_birth == 1:\n return f\"You are 1 year old.\"\n elif year_of_birth < current_year:\n return f\"You are {current_year - year_of_birth} years old.\"\n else:\n return f\"You will be born in {year_of_birth - current_year} years.\"", "def calculate_age(yb, cy):\n if cy - yb == 1:\n return f'You are 1 year old.'\n if cy - yb > 1:\n return f'You are {cy-yb} years old.'\n if cy - yb == -1:\n return f'You will be born in 1 year.'\n if cy - yb < -1:\n return f'You will be born in {yb-cy} years.'\n return f'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n out = current_year - year_of_birth\n if out == 1:\n return f'You are {out} year old.'\n elif out == 0:\n return 'You were born this very year!'\n elif out > 1:\n return f'You are {out} years old.'\n elif out == -1:\n return f'You will be born in {abs(out)} year.'\n else:\n return f'You will be born in {abs(out)} years.'", "def calculate_age(yob, cy):\n #your code here\n if yob<cy:\n if (cy-yob)==1:\n return f\"You are {cy-yob} year old.\"\n return f\"You are {cy-yob} years old.\"\n elif yob>cy:\n if (yob-cy)==1:\n return f\"You will be born in {yob-cy} year.\"\n return f\"You will be born in {yob-cy} years.\"\n else:\n return \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n if year_of_birth == current_year:\n return \"You were born this very year!\"\n elif (year_of_birth - current_year) == -1:\n return \"You are 1 year old.\"\n elif (year_of_birth - current_year) == 1:\n return \"You will be born in 1 year.\"\n elif year_of_birth < current_year:\n return \"You are {} years old.\".format(abs(year_of_birth-current_year))\n else:\n return \"You will be born in {} years.\".format(year_of_birth-current_year)", "def calculate_age(year_of_birth, current_year):\n if current_year == year_of_birth:\n return \"You were born this very year!\"\n elif year_of_birth - current_year == 1:\n return \"You will be born in 1 year.\"\n elif year_of_birth > current_year + 1:\n return \"You will be born in \" + str(int(year_of_birth - current_year)) + \" years.\"\n elif current_year - year_of_birth == 1:\n return \"You are 1 year old.\"\n elif current_year > year_of_birth + 1:\n return \"You are \" + str(int(current_year - year_of_birth)) + \" years old.\"", "def calculate_age(b, c):\n d=c-b\n return (d>0) * f\"You are {d} year{'s'*(d>1)} old.\" +\\\n (d<0) * f\"You will be born in {-d} year{'s'*(d<-1)}.\" +\\\n (d==0) * \"You were born this very year!\"", "def calculate_age(year_of_birth, current_year):\n y = current_year - year_of_birth\n if y > 0:\n return \"You are {} {} old.\".format(y, \"years\" if y !=1 else \"year\")\n elif y == 0:\n return \"You were born this very year!\"\n else:\n return \"You will be born in {} {}.\".format(-y, \"years\" if y !=-1 else \"year\")", "def calculate_age(year_of_birth, current_year):\n if current_year<year_of_birth:\n if current_year-year_of_birth==-1:\n return 'You will be born in 1 year.'\n else:\n return 'You will be born in '+ str(year_of_birth-current_year) +' years.'\n elif current_year>year_of_birth:\n if current_year-year_of_birth==1:\n return 'You are 1 year old.'\n else:\n return 'You are '+str(current_year-year_of_birth)+' years old.'\n else:\n return 'You were born this very year!'", "def calculate_age(year_of_birth, current_year):\n work=current_year-year_of_birth\n if work==1 : return \"You are 1 year old.\"\n elif work>0 : return \"You are {} years old.\".format(work)\n elif work==0 : return \"You were born this very year!\"\n elif work==-1 : return \"You will be born in 1 year.\"\n elif work<0 : return \"You will be born in {} years.\".format(-work)", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n \n if age == 1:\n return \"You are %s year old.\" % age\n if age > 1:\n return \"You are %s years old.\" % age\n if age == 0:\n return \"You were born this very year!\"\n if age == -1:\n return \"You will be born in %s year.\" % abs(age)\n\n else:\n return \"You will be born in %s years.\" % abs(age)", "def calculate_age(year_of_birth, current_year):\n if year_of_birth > current_year:\n diff = year_of_birth - current_year\n if diff == 1:\n return f\"You will be born in {diff} year.\"\n else:\n return f\"You will be born in {diff} years.\"\n elif year_of_birth == current_year:\n return \"You were born this very year!\"\n else:\n diff = current_year - year_of_birth\n if diff == 1:\n return f\"You are {diff} year old.\"\n else:\n return f\"You are {diff} years old.\"", "def calculate_age(year_of_birth, current_year):\n age = current_year - year_of_birth\n if age > 1:\n return f\"You are {age} years old.\"\n elif age == 1:\n return f\"You are {age} year old.\"\n elif age == 0:\n return f\"You were born this very year!\"\n if age == -1:\n return f\"You will be born in {-age} year.\"\n if age < -1:\n return f\"You will be born in {-age} years.\"", "def calculate_age(year_of_birth, current_year):\n if current_year - year_of_birth == 1:\n return \"You are \" + str(current_year - year_of_birth) + \" year old.\"\n elif year_of_birth - current_year == 1:\n return \"You will be born in \" + str(year_of_birth - current_year) + \" year.\"\n elif current_year - year_of_birth > 0:\n return \"You are \" + str(current_year - year_of_birth) + \" years old.\"\n elif current_year == year_of_birth:\n return \"You were born this very year!\"\n else:\n return \"You will be born in \" + str(year_of_birth - current_year) + \" years.\"", "def calculate_age(year_of_birth, current_year):\n old = current_year - year_of_birth\n if old > 0:\n return \"You are {} year{} old.\".format(old, \"s\" if old > 1 else \"\")\n elif old < 0:\n return \"You will be born in {} year{}.\".format(abs(old), \"s\" if abs(old) > 1 else \"\")\n else: \n return 'You were born this very year!'\n", "def calculate_age(year_of_birth, current_year):\n years = current_year - year_of_birth\n if not years:\n return 'You were born this very year!'\n elif years > 0:\n return f'You are {years} year{\"\" if years == 1 else \"s\"} old.'\n return f'You will be born in {-years} year{\"\" if years == -1 else \"s\"}.'", "def calculate_age(year_of_birth, current_year):\n #your code here\n age = current_year-year_of_birth\n if abs(age)==1:\n unit = 'year'\n else:\n unit = 'years'\n if age==0:\n return \"You were born this very year!\"\n if age>0:\n return \"You are \"+str(age)+\" \"+unit+\" old.\"\n else:\n return \"You will be born in \"+str(abs(age))+\" \"+unit+\".\"", "def calculate_age(year_of_birth, current_year):\n x = current_year - year_of_birth\n if x < 0: return f\"You will be born in {abs(x)} year{'s' if abs(x)>1 else ''}.\"\n if x == 0: return \"You were born this very year!\"\n return f\"You are {x} year{'s' if x > 1 else ''} old.\"", "def calculate_age(year_of_birth, current_year):\n diff = year_of_birth - current_year\n if diff == 0:\n return \"You were born this very year!\"\n elif diff > 0:\n return \"You will be born in {} {}.\".format(diff, \"year\" if diff == 1 else \"years\")\n elif diff < 0:\n return \"You are {} {} old.\".format(abs(diff), \"year\" if diff == -1 else \"years\")", "def calculate_age(birthyear, target):\n if birthyear == target:\n return 'You were born this very year!'\n elif birthyear > target:\n return 'You will be born in {} year{}.'.format(birthyear - target, 's' * ((birthyear - target) > 1))\n else:\n return 'You are {} year{} old.'.format(target - birthyear, 's' * ((target - birthyear) > 1 ))", "def calculate_age(year_of_birth, current_year):\n if current_year - year_of_birth > 1:\n return f\"You are {current_year - year_of_birth} years old.\"\n elif current_year - year_of_birth == 1:\n return f\"You are {current_year - year_of_birth} year old.\"\n elif current_year - year_of_birth == -1:\n return f\"You will be born in {-(current_year - year_of_birth)} year.\"\n elif current_year - year_of_birth < -1:\n return f\"You will be born in {-(current_year - year_of_birth)} years.\"\n else:\n return \"You were born this very year!\"\n", "def calculate_age(year_of_birth, current_year):\n age=current_year-year_of_birth\n if age==0: return 'You were born this very year!'\n if age>0: return 'You are {} year{} old.'.format(age, 's' if age>1 else '')\n if age<0: return 'You will be born in {} year{}.'.format(abs(age), 's' if age<-1 else '')", "def calculate_age(yob, cy):\n if yob<cy and cy-yob==1: return f\"You are 1 year old.\"\n if yob<cy: return f\"You are {cy-yob} years old.\" \n if yob>cy and yob-cy==1: return f\"You will be born in 1 year.\"\n if yob>cy: return f\"You will be born in {yob-cy} years.\" \n if yob==cy: return 'You were born this very year!'", "def calculate_age(b, c):\n\n greet = [\"You will be born in {} year{}.\",\"You are {} year{} old.\",\"You were born this very year!\"]\n return greet[2] if b == c else greet[b<c].format(abs(b-c),'s' if abs(b-c)!=1 else '') "] | {"fn_name": "calculate_age", "inputs": [[2012, 2016], [1989, 2016], [2000, 2090], [2000, 1990], [2000, 2000], [900, 2900], [2010, 1990], [2010, 1500], [2011, 2012], [2000, 1999]], "outputs": [["You are 4 years old."], ["You are 27 years old."], ["You are 90 years old."], ["You will be born in 10 years."], ["You were born this very year!"], ["You are 2000 years old."], ["You will be born in 20 years."], ["You will be born in 510 years."], ["You are 1 year old."], ["You will be born in 1 year."]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 41,154 |
def calculate_age(year_of_birth, current_year):
|
caae82e36089515fff264b4f3d4e729f | UNKNOWN | The cockroach is one of the fastest insects. Write a function which takes its speed in km per hour and returns it in cm per second, rounded down to the integer (= floored).
For example:
```python
cockroach_speed(1.08) == 30
```
Note! The input is a Real number (actual type is language dependent) and is >= 0. The result should be an Integer. | ["def cockroach_speed(s):\n return s // 0.036", "def cockroach_speed(s):\n cm_per_km = 100000\n sec_per_hour = 3600\n return int(s * cm_per_km / sec_per_hour)", "def cockroach_speed(s):\n cm_per_km = 100000\n sec_per_hour = 3600\n return s * cm_per_km // sec_per_hour\n", "def cockroach_speed(s):\n return (s * 100000) // (60 * 60) ", "def cockroach_speed(s):\n return int(s * 27.7778)\n # Good Luck!\n", "ONE_KM_IN_METERS = 1000\nONE_METER_IN_CM = 100\nONE_HOUR_IN_MINUTES = 60\nONE_MINUTE_IN_SECONDS = 60\n\ndef cockroach_speed(s):\n cm = ONE_KM_IN_METERS * ONE_METER_IN_CM\n sec = ONE_HOUR_IN_MINUTES * ONE_MINUTE_IN_SECONDS\n return int((s * cm) / sec)\n", "import math\ndef cockroach_speed(s):\n # Good Luck!\n cm = s*1000*100 / 3600\n return math.floor(cm)", "import math\ndef cockroach_speed(s):\n return math.floor(s*100000/3600)", "import math\ndef cockroach_speed(s):\n return math.floor(s * 27.778)", "cockroach_speed = lambda s: int(27.7778*s)", "def cockroach_speed(s):\n return int(s * (30/1.08))", "def cockroach_speed(s):\n return int(27.78 * s)", "import math\ndef cockroach_speed(s):\n return math.floor(((s*10000)/3600)*10)", "def cockroach_speed(s):\n '''\n (number) -> int\n s is the number of kilometers that the cockroach travels per hour. \n Return the equivalent integer(rounded down) of centimeters per second.\n '''\n #convert kilometer(per hour) to centimeters(per hour)\n #convert centimeters(per hour) to centimeters(per second)\n #convert the final result as an integer.\n return int((s * 100000) // 3600)\n \n", "def cockroach_speed(kph):\n # 1000 m in km\n mph = kph * 1000\n # 100 cm in m\n cph = mph * 100\n # 60 min in hour\n cpm = cph / 60\n # 60 sec in min\n cps = cpm / 60\n return int(cps)\n\n# I'm just tired of oneliners =)\n", "def cockroach_speed(s):\n '''\n (int) -> int\n \n preconditions: input is real number >= 0\n \n takes speed in km per hour as input and returns it in cm per second \n '''\n return int(s * 1000/36)", "from math import floor\n\ndef cockroach_speed(s):\n return floor(s * 250 / 9)", "import math\n\ndef cockroach_speed(s):\n return math.floor(s * 1000 / 36)", "import math\ndef cockroach_speed(s):\n return (math.floor(s*27.7778))", "def cockroach_speed(s):\n return s * 100000 // 3600", "def cockroach_speed(s):\n return int(((s*1000)*100/60)/60)", "def cockroach_speed(s):\n return int(s / 0.036)", "def cockroach_speed(s):\n return round(s // 0.036)", "from math import floor\n\ndef cockroach_speed(speed_km_per_h: float) -> int:\n \"\"\" Get a speed of the cockroach in cm/s based on its speed in km/h. \"\"\"\n return floor(speed_km_per_h * (100000/3600))", "def cockroach_speed(s):\n return s * 250 // 9", "cockroach_speed = lambda x: x/0.036//1", "cockroach_speed = lambda s: s * 27.778 // 1", "cockroach_speed=.036 .__rfloordiv__", "def cockroach_speed(s):\n return 10 ** 5 * s // 60 ** 2", "cockroach_speed = lambda s: 10 ** 3 * s // 36", "import math\ndef cockroach_speed(s):\n return math.floor(s * (30/1.08))", "def cockroach_speed(s):\n return s * 100_000 // 3600", "def cockroach_speed(speed):\n ratio = 27.7778\n return speed * ratio // 1", "def cockroach_speed(s):\n return s*5//0.18", "def cockroach_speed(s):\n return s*1000/6//6", "cockroach_speed = lambda s: __import__('math').floor(s*1000*100/60/60)", "cockroach_speed=lambda x:__import__('math').floor(x*(30/1.08))", "#cockroach_speed=lambda s:int(s*27.77777777777778)\ncockroach_speed = lambda s:int(27.77777777777778.__mul__(s))", "def cockroach_speed(km_per_h):\n return(km_per_h * (1000 * 100) // (60 * 60))", "def cockroach_speed(s):\n return ((s * 100 * 1000) / 60) // 60", "def cockroach_speed(s):\n import math as m\n a=s*(1000*100)/3600\n return(int(m.floor(a)))", "import math\ndef cockroach_speed(s):\n newSpd=s*27.778\n newSpd = math.floor(newSpd)\n return newSpd", "def cockroach_speed(s):\n # Good Luck!\n return int(s*27.77777777778)\n print(cockroach_speed(s))", "def cockroach_speed(s):\n temp_speed = 0.036 #1 sm/sec = 0.036 km/h\n end_speed = s / temp_speed\n return int(end_speed)", "import math\ndef cockroach_speed(s):\n speed=math.floor(s*27.77777778)\n return speed", "def cockroach_speed(s):\n import math\n a = 27.778 * s\n a = math.floor(a)\n return a", "import math \ndef cockroach_speed(s):\n a = s * 1000 * 100 / 60 /60\n b = math.floor(a)\n return b ", "import math\n\n\ndef cockroach_speed(s):\n s_cm = s * 27.778\n return math.floor(s_cm)", "from math import floor\ndef cockroach_speed(s):\n x = 27.7777777778 #1 km per hour converted to cm per second\n return floor(s * x)", "import math\n\ndef cockroach_speed(s):\n return math.floor(s*27.777777777777777)", "def cockroach_speed(s):\n cm = s*27.7778\n return round(cm-0.5)\n # Good Luck!\n", "\nimport math \n\ndef cockroach_speed(s):\n \n speed = s * 27.777778\n \n return math.floor(speed)\n", "def cockroach_speed(s):\n new_s = 27.7777778 * s\n new_s = int(new_s)\n return new_s\n \n \n # Good Luck!\n", "def cockroach_speed(s):\n # 1.08 km ... 3600\n # x ......... 1 s\n # x=108000 cm\n return int(s*(10**5) / 3600)", "def cockroach_speed(s):\n # converts velocity from km/h to cm / s\n return int(s / 0.036)", "def cockroach_speed(s):\n return int(5*s*100/18)\n", "def cockroach_speed(s):\n x = s / 60 / 60 *100000\n return int(x)", "import math\n\ndef cockroach_speed(s):\n \n cm = s *27.77778\n\n return math.floor(cm)\n", "def cockroach_speed(s):\n return int(s*1000000/36000)", "def cockroach_speed(s):\n import math\n if s == 0:\n return 0\n else:\n meter_per_sec = s / 3.6\n cm_per_sec = meter_per_sec * 100\n return math.floor(cm_per_sec)", "def cockroach_speed(s):\n s_new = ((250 / 9) * s ) // 1 # Convertion into cm/s floored\n return s_new", "import math\ndef cockroach_speed(s):\n # Good Luck!\n p = s * 10000 / 360 \n p = math.floor(p)\n return p", "from math import ceil\ndef cockroach_speed(s):\n y = ceil(int(s*100000/3600))\n return y\n", "import math\n\ndef cockroach_speed(s):\n metri = s * 27.7777778\n return math.floor(metri)\n", "def cockroach_speed(s):\n cmps = 3600\n kmph = 100000\n cms = s * kmph / cmps \n \n return int(cms)\n", "import math\ndef cockroach_speed(s):\n s = s*27.777778\n return math.floor(s)", "def cockroach_speed(s):\n # 1 km = 1,000m = 100,000 cm\n # 1 hr = 3600 s\n # 1 km/hr = 1000/36 cm/s\n \n return (1000*s/36)//1", "def cockroach_speed(s): return int(s*(27+7/9))", "import math\ndef cockroach_speed(s):\n cms = (s / 3600) * 100000\n return(math.floor(cms))", "from math import floor\n\ndef cockroach_speed(s):\n # Good Luck!\n conversion = 1/27.7778\n cmPerSec = s/conversion\n return floor(cmPerSec)", "def cockroach_speed(s):\n x = (s*1000*100/(60*60))\n x = int(x)\n return x\n # Good Luck!\n", "import math\ndef cockroach_speed(s):\n a = math.floor(s*27.778)\n return(a)", "import math\ndef cockroach_speed(s):\n converted_speed = (s * 100000)/(3600)\n return math.floor(converted_speed)\n", "import math\n\ndef cockroach_speed(s):\n to_minutes =s/60\n to_secs = to_minutes/60\n return math.floor(to_secs*100000)\n", "def cockroach_speed(s):\n cm_s=s*100000/3600\n return int(cm_s)\n", "def cockroach_speed(s):\n \n result = (s*100000)/3600\n return int (result)", "def cockroach_speed(s):\n return int((s*1000.0)/3600*100)", "#import math \ndef cockroach_speed(s):\n # Good Luck!\n return (s//(0.036))", "def cockroach_speed(s):\n \n s = int(s*10000/360) \n return s\n", "from math import floor\ndef cockroach_speed(s):\n return floor((s/36)*1_000)", "def cockroach_speed(speed):\n from math import floor\n speed = floor((speed/3600)*100000)\n return speed\n \n # Good Luck!\n", "import math\ndef cockroach_speed(s):\n temp = (s * 1000 * 100) / 3600\n result = math.floor(temp)\n return result", "import math\n\ndef cockroach_speed(s):\n seconds = 60*60\n cm = 1000*100\n new_speed = s * cm / seconds\n return math.floor(new_speed)", "import math\ndef cockroach_speed(s):\n value = s * 27.7778\n return math.floor(value)", "def cockroach_speed(speed):\n a = speed/0.036\n return int(a)", "def cockroach_speed(s):\n try:\n return ((100000 / 3600) * s) // 1\n except:\n return 0", "from math import floor\n\ndef cockroach_speed(s):\n speed_cm = floor(s*27.7777778)\n return speed_cm", "from math import floor\ndef cockroach_speed(s):\n speed = s * 100000\n return floor(speed / 3600)", "cockroach_speed = lambda s: int(100000*s/3600)", "import math\ndef cockroach_speed(s):\n val=0\n val=math.floor(s*10**5/3600)\n return(val)\n # Good Luck!\n", "def cockroach_speed(s):\n speed = float(s) / 360 * 10000\n return int(speed)", "import math\ndef cockroach_speed(s):\n speed = math.floor(s * 27.77777777778)\n \n return (speed)", "import math\ndef cockroach_speed(s):\n result = math.floor(s * 1000 / 36)\n return result\n", "def cockroach_speed(s):\n # Good Luck!\n result=int(s*(250/9))\n return result", "cockroach_speed = lambda s: s * 100_000 // 3_600", "def cockroach_speed(s):\n # Cockroaches just seem fast because time slows when they fly toward you...\n return (int(s * 100000 / 3600))", "def cockroach_speed(s):\n if s<=0:\n return 0\n else:\n return int(s*(100000/3600))\n # Good Luck!\n", "import math\ndef cockroach_speed(s):\n \n # Good Luck!\n cm = 100000\n sec = 3600\n s = math.floor(s*(cm/sec))\n return s \n", "def cockroach_speed(s):\n import math\n conversion = (1000 * 100)/(60*60)\n speed = math.floor(s*conversion)\n return speed", "def cockroach_speed(s):\n return int(s*27.777777777777777777777777)\n#pogchamp\n", "import math\ndef cockroach_speed(s):\n \n s = s * 100_000 / 3600\n return math.floor(s)"] | {"fn_name": "cockroach_speed", "inputs": [[1.08], [1.09], [0]], "outputs": [[30], [30], [0]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 10,284 |
def cockroach_speed(s):
|
ea406eae81395f7ca618d605e966cc67 | UNKNOWN | Create a function which answers the question "Are you playing banjo?".
If your name starts with the letter "R" or lower case "r", you are playing banjo!
The function takes a name as its only argument, and returns one of the following strings:
```
name + " plays banjo"
name + " does not play banjo"
```
Names given are always valid strings. | ["def areYouPlayingBanjo(name):\n return name + (' plays' if name[0].lower() == 'r' else ' does not play') + \" banjo\";", "def areYouPlayingBanjo(name):\n if name[0].lower() == 'r':\n return name + ' plays banjo'\n else:\n return name + ' does not play banjo'", "def areYouPlayingBanjo(name):\n return name + \" plays banjo\" if name[0].lower() == 'r' else name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n if name[0].lower() == 'r':\n return \"{} plays banjo\".format(name)\n return \"{} does not play banjo\".format(name)", "def areYouPlayingBanjo(name):\n if name.startswith('R') or name.startswith('r'):\n return name + ' plays banjo'\n else:\n return name + ' does not play banjo'", "def areYouPlayingBanjo(name):\n if name[0] == 'r' or name[0] =='R':\n return (\"%s plays banjo\"%name)\n else:\n return (\"%s does not play banjo\"%name)", "def areYouPlayingBanjo(name):\n return name + (' plays banjo' if name[0]=='r' or name[0]=='R' else ' does not play banjo')", "def areYouPlayingBanjo(name):\n return '{} {}'.format(name, 'plays banjo' if name.startswith('R') or name.startswith('r') else 'does not play banjo') \n", "def areYouPlayingBanjo(name):\n if name[0][0] == \"R\":\n return name + \" plays banjo\"\n if name[0][0] == \"r\":\n return name + \" plays banjo\"\n else:\n return name + \" does not play banjo\" \n", "def areYouPlayingBanjo(name):\n if name[0].lower() == 'r':\n return '{} plays banjo'.format(name)\n else:\n return '{} does not play banjo'.format(name)", "areYouPlayingBanjo = lambda n: n+[\" does not play banjo\",\" plays banjo\"][n[0].lower()=='r']", "def areYouPlayingBanjo(name):\n for i in name:\n if i =='R' or i=='r':\n return name+ \" \"+\"plays banjo\"\n else:\n return name+\" does not play banjo\"", "def areYouPlayingBanjo(name):\n # Implement me!\n return \"{} {} banjo\".format(name, \"plays\" if name.lower().startswith('r') else \"does not play\") \n", "def areYouPlayingBanjo(name):\n return name + (\" does not play banjo\", \" plays banjo\") [name[0].upper() == 'R']", "def areYouPlayingBanjo(name):\n if name[0] in \"rR\":\n return \"{name} plays banjo\".format(name=name)\n else:\n return \"{name} does not play banjo\".format(name=name)", "def areYouPlayingBanjo(name):\n return \"{} plays banjo\".format(name) if \"r\" == name.lower()[0] else \"{} does not play banjo\".format(name)", "def areYouPlayingBanjo(name):\n return ['%s plays banjo' % (name), '%s does not play banjo' % (name)][name[0].lower() != 'r']", "def areYouPlayingBanjo(name):\n if name.upper().startswith(\"R\"): return name + \" plays banjo\"\n return name + \" does not play banjo\"", "areYouPlayingBanjo = lambda name: (name + ' plays banjo') if name.lower()[0] == 'r' else (name + ' does not play banjo')", "def areYouPlayingBanjo(name):\n return name + \" plays banjo\" if name[0].upper()== 'R' else name + ' does not play banjo'", "def areYouPlayingBanjo(name):\n if name.startswith((\"R\", \"r\")):\n return \"{} plays banjo\".format(name)\n return \"{} does not play banjo\".format(name)", "def areYouPlayingBanjo(name):\n if name[0] == 'R' or name[0] == 'r':\n return name + ' plays banjo'\n return name + ' does not play banjo'", "def areYouPlayingBanjo(name):\n if name[0].lower() == 'r':\n return name + \" plays banjo\"\n return name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n return name + \" plays banjo\" if name[0] in ('r', 'R') else name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n \n return '{}'.format(name + (' plays banjo' if name[0] == 'R' or name[0] == 'r' else ' does not play banjo'))", "def areYouPlayingBanjo(name: str) -> str:\n \"\"\" Check if the user is playing banjo based on his name. \"\"\"\n return name + \" plays banjo\" if name.lower().startswith(\"r\") else name + \" does not play banjo\"", "areYouPlayingBanjo = lambda n: n + (\" does not play \", \" plays \")[n[0] in \"Rr\"] + \"banjo\"", "def areYouPlayingBanjo(name):\n return '{} {} banjo'.format(name, ['does not play', 'plays'][name[0] in 'Rr'])", "areYouPlayingBanjo=lambda n:n+[\" does not play\",\" plays\"][n[0]in'Rr']+\" banjo\"", "def areYouPlayingBanjo(name):\n # Implement me!\n return \" \".join([name, \"plays\" if str.upper(name[0]) == \"R\" else \"does not play\", \"banjo\"])", "def areYouPlayingBanjo(name):\n return name+([' does not play',' plays'][name.lower().startswith('r')])+' banjo'", "def areYouPlayingBanjo(name):\n status = \"plays\" if name[0] in \"Rr\" else \"does not play\"\n return \"{n} {st} banjo\".format(n = name, st = status)", "areYouPlayingBanjo = lambda name: (\"%s plays banjo\" if name[0] in 'Rr' else \"%s does not play banjo\") % name", "def areYouPlayingBanjo(name):\n return str(name)+(' plays banjo' if name[0]in['R','r'] else ' does not play banjo')", "def areYouPlayingBanjo(name):\n # name = name.title()\n # if name.startswith('R'):\n # return name + \" plays banjo\"\n # else:\n # return name + \" does not play banjo\"\n return name + (\" plays\" if name.title().startswith('R') else \" does not play\") + \" banjo\"", "def areYouPlayingBanjo(name):\n return name + (name[0] in \"Rr\")*\" plays banjo\" + (name[0] not in\"Rr\") * (\" does not play banjo\")", "def areYouPlayingBanjo(name):\n return '{} {}'.format(name, ['does not play banjo', 'plays banjo'][name[0] in 'rR'])", "def areYouPlayingBanjo(name):\n \n return f'{name} plays banjo' if name[0]=='R' or name[0]=='r' else f'{name} does not play banjo'", "def areYouPlayingBanjo(name):\n return \"{} plays banjo\".format(name) if name[0] in \"Rr\" else \"{} does not play banjo\".format(name)", "def areYouPlayingBanjo(name):\n return \"%s %s banjo\" %(name,[\"does not play\",\"plays\"][name[0].lower()=='r'])", "def areYouPlayingBanjo(name):\n return (\"{0} plays banjo\" if name[0].lower() == 'r' else \"{0} does not play banjo\").format(name)", "def areYouPlayingBanjo(name):\n # Implement me!\n return ['{} does not play banjo'.format(name), '{} plays banjo'.format(name)][name[0].lower() == 'r']", "def areYouPlayingBanjo(name):\n return name + ' does not play banjo' if name[0] not in 'Rr' else name + ' plays banjo'", "def areYouPlayingBanjo(name):\n if name.lower().startswith('r'):\n return f'{name} plays banjo'\n return f'{name} does not play banjo'", "def areYouPlayingBanjo(name):\n return (f'{name} does not play banjo', f'{name} plays banjo')[name[0].lower() == 'r']", "def areYouPlayingBanjo(name):\n banjo = (\"R\", \"r\")\n if name[0] in banjo:\n return name + \" plays banjo\"\n else:\n return name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n if name.lower()[0] == 'r':\n banjo = name + \" plays banjo\"\n else:\n banjo = name + \" does not play banjo\"\n return banjo", "def areYouPlayingBanjo(name):\n name_lower = name.lower()\n letters_lst = []\n for item in name_lower:\n letters_lst.append(item)\n if letters_lst[0] == \"r\":\n result = name + \" plays banjo\"\n else:\n result = name + \" does not play banjo\"\n return result", "def areYouPlayingBanjo(name):\n # Implement me!\n if \"r\" in name[0] or \"R\" in name[0]:\n return f\"{name} plays banjo\"\n else:\n return f\"{name} does not play banjo\"\n", "def areYouPlayingBanjo(name):\n return f\"{name} plays banjo\" if name.lower()[0:1] == \"r\" else f\"{name} does not play banjo\" ", "def areYouPlayingBanjo(name):\n # Implement me!\n if name[0]=='R' or name[0]==\"r\":\n output = (name + \" plays banjo\")\n else:\n output = (name + \" does not play banjo\")\n return output\n\nuser_name = \"ralan\"\n\nprint(areYouPlayingBanjo(user_name))", "def areYouPlayingBanjo(name):\n lst = list(name)\n if lst[0] == 'r' or lst[0] == 'R':\n return f'{name} plays banjo'\n else:\n return f'{name} does not play banjo'\n", "areYouPlayingBanjo=lambda n:f\"{n} {['does not play','plays'][n[0]in'Rr']} banjo\"", "def areYouPlayingBanjo(name):\n return f'{name} plays banjo' if 'r' in name[0] or 'R' in name[0] else f'{name} does not play banjo'", "print(\"Are you playing banjo?\")\n\ndef areYouPlayingBanjo(name):\n #return positive if name.lower().startswith \"r\"\n if name.lower().startswith(\"r\"):\n return name + \" plays banjo\"\n else:\n return name + \" does not play banjo\"\n return name\n\nareYouPlayingBanjo(\"martin\")\nareYouPlayingBanjo(\"Rikke\")", "def areYouPlayingBanjo(name):\n x = name.title()\n if x[0] == \"R\":\n return name + \" plays banjo\"\n else:\n return name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n check = any(x is name[0] for x in \"rR\")\n return f\"{name} plays banjo\" if check else f\"{name} does not play banjo\" \n\n\n", "def areYouPlayingBanjo(n):\n if n[0].lower() == 'r':\n result = 'plays'\n else:\n result = 'does not play'\n return f'{n} {result} banjo'", "def areYouPlayingBanjo(name):\n for i in name: \n if i[0] == (\"r\") or i[0] == (\"R\"):\n return name + \" plays banjo\"\n else:\n return name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n i = name[0:1]\n if i == \"R\" or i == \"r\":\n return f\"{name} plays banjo\"\n else:\n return f\"{name} does not play banjo\"", "def areYouPlayingBanjo(name):\n if name.startswith('R'):\n return f'{name} plays banjo'\n elif name.startswith('r'):\n return f'{name} plays banjo'\n else:\n return f'{name} does not play banjo'\n\n", "def areYouPlayingBanjo(name):\n if name[0]=='R' or name[0]=='r':\n stringa=str(name)+' plays banjo'\n return stringa\n stringa=str(name)+' does not play banjo'\n return stringa\n \n", "def areYouPlayingBanjo(name):\n # Implement me!\n play=False;\n if name!='' and name[0] in ('r','R'): play=True\n \n res=name+' does not play banjo'\n if (play==True) : res=name+' plays banjo'\n return res", "def areYouPlayingBanjo(name):\n \n if name.startswith(\"R\"):\n return str(name) + \" plays banjo\"\n elif name.startswith(\"r\"):\n return str(name) + \" plays banjo\"\n else:\n return str(name) + \" does not play banjo\"\n # Implement me!\n \n\n\n# answer the question are you playing banjo?\n# if your name starts with the letter \"R\" or lower case \"r\" you are playing banjo\n", "def areYouPlayingBanjo(name):\n plays = \" does not play banjo\"\n if name[0].lower() == 'r':\n plays = \" plays banjo\"\n return name + plays", "def areYouPlayingBanjo(name):\n return f'{name} plays banjo' if name.startswith('r') or name[0] == 'R' else f'{name} does not play banjo'", "def areYouPlayingBanjo(name):\n condition = \"plays\" if name[0].lower()=='r' else \"does not play\" \n return f\"{name} {condition} banjo\"", "from typing import*\ndef areYouPlayingBanjo(name:List[str])->str:\n Yes:str = name + \" plays banjo\" \n No:str = name + \" does not play banjo\"\n if name[0] == \"r\" or name[0] == \"R\":\n return Yes\n else:\n return No \n", "def areYouPlayingBanjo(name):\n list = []\n for i in name:\n list.append(i)\n if list[0] == 'R':\n return name + \" plays banjo\"\n elif list[0] == 'r':\n return name + \" plays banjo\"\n elif list[0] != 'R':\n return name + \" does not play banjo\"\n elif list[0] != 'r':\n return name + \" does not play banjo\"\n else: \n return 'please try again michelle'", "def areYouPlayingBanjo(name):\n \n nametolist = list(name) # Converting the string to a list\n \n if nametolist[0] == 'R': # Testing if first character is an 'R'\n return name + \" plays banjo\"\n elif nametolist[0] == 'r':\n return name + \" plays banjo\"\n else:\n return name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n # Implement me!\n if name.upper()[0] == \"R\":\n text = \"{} plays banjo\".format(name)\n else:\n text = \"{} does not play banjo\".format(name)\n return text", "def areYouPlayingBanjo(name):\n plays = \"does not play\" if name[0] not in \"Rr\" else \"plays\"\n return f\"{name} {plays} banjo\"", "import re\ndef areYouPlayingBanjo(name):\n return name+\" plays banjo\" if re.search(\"\\A[rR]\",name) else name+\" does not play banjo\"", "def areYouPlayingBanjo(name):\n # Implement me!\n \n a = name + \" plays banjo\" \n b = name + \" does not play banjo\"\n \n \n if name[0] == \"r\" or name[0] == \"R\":\n return a\n \n else: return b\n", "def areYouPlayingBanjo(name):\n # Implement me!\n result = \" plays banjo\" if name.lower()[0] == 'r' else \" does not play banjo\"\n return name + result", "def areYouPlayingBanjo(name):\n return name + \" does not play banjo\" if name[0] != 'R' and name[0] != 'r' else name + \" plays banjo\" \n \n \n", "def areYouPlayingBanjo(name):\n first = name[0]\n if first == \"R\":\n return(name + \" \"+ \"plays banjo\")\n elif first == \"r\":\n return(name + \" \" + \"plays banjo\")\n else :\n return(name + \" \"+ \"does not play banjo\")\nprint(areYouPlayingBanjo(\"Martin\"))", "def areYouPlayingBanjo(name):\n result = \"\"\n if name[0] == \"r\" or name[0] == \"R\":\n result += \" plays banjo\"\n else:\n result += \" does not play banjo\"\n \n return name+ result", "def areYouPlayingBanjo(name):\n return f\"{name} plays banjo\" if name[0].lower().startswith(\"r\") else f\"{name} does not play banjo\"", "def areYouPlayingBanjo(name):\n checkname=name.lower()\n if checkname.startswith('r'):\n return name + \" plays banjo\" \n else:\n return name + \" does not play banjo\" \n", "def areYouPlayingBanjo(name):\n first_letter= name[0]\n if first_letter == 'R':\n return name + ' plays banjo'\n elif first_letter == 'r':\n return name + ' plays banjo'\n return name + ' does not play banjo'\n \n", "def areYouPlayingBanjo(name):\n return name + (\" plays banjo\" if name[:1] in 'rR' else \" does not play banjo\")", "def areYouPlayingBanjo(name):\n first_letter= list(name)[0].lower()\n if first_letter == 'r':\n return(name + \" plays banjo\")\n return(name + \" does not play banjo\")", "def areYouPlayingBanjo(name):\n if name[0] == \"r\": \n return name +\" \"+ \"plays banjo\"\n elif name[0] == \"R\":\n return name +\" \"+ \"plays banjo\"\n return name +\" \"+\"does not play banjo\"\n", "def areYouPlayingBanjo(name):\n if name.startswith((\"R\", \"r\")):\n return f'{name} plays banjo'\n else:\n return f'{name} does not play banjo'\n\n", "def areYouPlayingBanjo(name):\n return f\"{name} {'plays' if name.lower().startswith('r') else 'does not play'} banjo\"", "def areYouPlayingBanjo(name):\n b=' plays banjo'\n nb=' does not play banjo'\n if name[0].lower()== 'r':\n name = name + b\n return name\n else:\n name = name + nb\n return name", "def areYouPlayingBanjo(name):\n return name + r' plays banjo' if name[0].lower() == 'r' else name + r' does not play banjo'", "areYouPlayingBanjo = lambda n: f\"{n} plays banjo\" if n[0] is 'r' or n[0] is 'R' else f\"{n} does not play banjo\"", "def areYouPlayingBanjo(name):\n # Implement me!\n list()\n if name[0] == \"R\" or name[0] == \"r\":\n return str(name) + \" plays banjo\"\n else:\n return str(name) + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n return '%s plays banjo' % name if name[0].lower() == 'r' else \\\n '%s does not play banjo' % name", "def areYouPlayingBanjo(name):\n # Implement me!\n if name[0]==\"r\" or name[0]==\"R\":\n ret=name+\" plays banjo\"\n else:\n ret=name+\" does not play banjo\"\n return ret\n", "def areYouPlayingBanjo(name):\n output = ''\n if name.lower()[0] == 'r':\n output = ' plays banjo'\n else:\n output = ' does not play banjo'\n return name + output", "areYouPlayingBanjo = lambda x: '{} plays banjo'.format(x) if x and x[0].lower()=='r' else '{} does not play banjo'.format(x)", "def areYouPlayingBanjo(name):\n return name + [\" does not play\", \" plays\"][name[0].startswith(('R', 'r'))] + \" banjo\"", "def areYouPlayingBanjo(name):\n i = 'rR'\n return f'{name} plays banjo' if name[0] in i else f'{name} does not play banjo'", "def areYouPlayingBanjo(name):\n first_letter = name[0]\n print(first_letter)\n if first_letter == \"R\" or first_letter == \"r\":\n return name + \" plays banjo\" \n return name + \" does not play banjo\"", "def areYouPlayingBanjo(name):\n plays = name[0].upper() == \"R\"\n answer = [\"does not play\", \"plays\"]\n return f\"{name} {answer[plays]} banjo\"", "def areYouPlayingBanjo(name):\n if list(name)[0] == 'R' or list(name)[0] == 'r':\n return f\"{name} plays banjo\"\n else:\n return f\"{name} does not play banjo\"", "def areYouPlayingBanjo(name):\n if name.casefold().startswith(\"r\"):\n return f\"{name} plays banjo\"\n else:\n return f\"{name} does not play banjo\""] | {"fn_name": "areYouPlayingBanjo", "inputs": [["Adam"], ["Paul"], ["Ringo"], ["bravo"], ["rolf"]], "outputs": [["Adam does not play banjo"], ["Paul does not play banjo"], ["Ringo plays banjo"], ["bravo does not play banjo"], ["rolf plays banjo"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 17,678 |
def areYouPlayingBanjo(name):
|
ea11c4f8c164ba643e16e04728cc7a66 | UNKNOWN | Mobile Display Keystrokes
Do you remember the old mobile display keyboards? Do you also remember how inconvenient it was to write on it?
Well, here you have to calculate how much keystrokes you have to do for a specific word.
This is the layout:
Return the amount of keystrokes of input str (! only letters, digits and special characters in lowercase included in layout without whitespaces !)
e.g:
mobileKeyboard("123") => 3 (1+1+1)
mobileKeyboard("abc") => 9 (2+3+4)
mobileKeyboard("codewars") => 26 (4+4+2+3+2+2+4+5) | ["def mobile_keyboard(s):\n lookup = {\n c: i \n for s in \"1,2abc,3def,4ghi,5jkl,6mno,7pqrs,8tuv,9wxyz,*,0,#\".split(\",\") \n for i, c in enumerate(s, start=1)\n }\n return sum(lookup[c] for c in s)", "def mobile_keyboard(s):\n return sum((x+1) for x in range(5) for c in s if c in ['0123456789*#','adgjmptw','behknqux','cfilorvy','sz'][x])\n", "STROKES = {'0':1, '1':1, '2':1, '3':1, '4':1, '5':1, '6':1, '7':1, '8':1, '9':1,\n 'a':2, 'b':3, 'c':4, 'd':2, 'e':3, 'f':4, 'g':2, 'h':3, 'i':4, 'j':2,\n 'k':3, 'l':4, 'm':2, 'n':3, 'o':4, 'p':2, 'q':3, 'r':4, 's':5, 't':2,\n 'u':3, 'v':4, 'w':2, 'x':3, 'y':4, 'z':5, '*':1, '#':1}\n\nmobile_keyboard = lambda message: sum(STROKES[char] for char in message)", "D = {}\nfor c in \"0123456789*#\": D[c] = 1\nfor c in \"adgjmptw\": D[c] = 2\nfor c in \"behknqux\": D[c] = 3\nfor c in \"cfilorvy\": D[c] = 4\nfor c in \"sz\": D[c] = 5\n\ndef mobile_keyboard(s):\n return sum(map(D.get, s))", "def mobile_keyboard(s):\n a = \"12abc3def4ghi5jkl6mno7pqrs8tuv9wxyz*0#\"\n b = \"11234123412341234123412345123412345111\"\n d = {x: int(y) for x, y in zip(a, b)}\n return sum(d[x] for x in s)", "keys = [\"123456789*0#\", \"adgjmptw\", \"behknqux\", \"cfilorvy\", \"sz\"]\n\ndef mobile_keyboard(s):\n return sum(i + 1 for i, k in enumerate(keys) for c in s if c in k)", "from string import ascii_lowercase as alc, digits\ndef mobile_keyboard(s):\n return sum(map(int, s.translate(str.maketrans('*#' + digits + alc, '1' * 12 + '234' * 6 + '5' + '234' * 2 + '5'))))", "count = {chr(n):2+i%3 for i,n in enumerate(range(ord('a'), ord('s')))}\ncount.update( {chr(n):2+i%3 for i,n in enumerate(range(ord('t'), ord('z')))} )\ncount.update( {str(n)[-1]:1 for i,n in enumerate(range(1,11))} )\ncount.update( {'s':5, 'z':5, '*':1, '#':1} )\n\ndef mobile_keyboard(s):\n return sum(count[c] for c in s)", "keyboard = {\n '1': 1,\n '2': 1, 'a': 2, 'b': 3, 'c': 4,\n '3': 1, 'd': 2, 'e': 3, 'f': 4,\n '4': 1, 'g': 2, 'h': 3, 'i': 4,\n '5': 1, 'j': 2, 'k': 3, 'l': 4,\n '6': 1, 'm': 2, 'n': 3, 'o': 4,\n '7': 1, 'p': 2, 'q': 3, 'r': 4, 's': 5,\n '8': 1, 't': 2, 'u': 3, 'v': 4, \n '9': 1, 'w': 2, 'x': 3, 'y': 4, 'z': 5,\n '0': 1, '*': 1, '#': 1\n}\ndef mobile_keyboard(s):\n sum = 0\n for k in s:\n sum += keyboard[k]\n return sum\n", "def mobile_keyboard(s):\n result = 0; s = list(s)\n key = {'0':1,'1':1,'2':1,'3':1,'4':1,'5':1,'6':1,'7':1,'8':1,'9':1,'a':2,'b':3,'c':4,'d':2,'e':3,'f':4,'g':2,'h':3,'i':4,'j':2,'k':3,'l':4,'m':2,'n':3,'o':4,'p':2,'q':3,'r':4,'s':5,'t':2,'u':3,'v':4,'w':2,'x':3,'y':4,'z':5,'*':1,'#':1};\n for a in s:\n result += key[a]\n return result"] | {"fn_name": "mobile_keyboard", "inputs": [[""], ["123"], ["codewars"], ["zruf"], ["thisisasms"], ["longwordwhichdontreallymakessense"]], "outputs": [[0], [3], [26], [16], [37], [107]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,740 |
def mobile_keyboard(s):
|
b30166120be2e0e5a2231b41a98abad2 | UNKNOWN | # altERnaTIng cAsE <=> ALTerNAtiNG CaSe
Define `String.prototype.toAlternatingCase` (or a similar function/method *such as* `to_alternating_case`/`toAlternatingCase`/`ToAlternatingCase` in your selected language; **see the initial solution for details**) such that each lowercase letter becomes uppercase and each uppercase letter becomes lowercase. For example:
``` haskell
toAlternatingCase "hello world" `shouldBe` "HELLO WORLD"
toAlternatingCase "HELLO WORLD" `shouldBe` "hello world"
toAlternatingCase "hello WORLD" `shouldBe` "HELLO world"
toAlternatingCase "HeLLo WoRLD" `shouldBe` "hEllO wOrld"
toAlternatingCase "12345" `shouldBe` "12345"
toAlternatingCase "1a2b3c4d5e" `shouldBe` "1A2B3C4D5E"
```
```C++
string source = "HeLLo WoRLD";
string upperCase = to_alternating_case(source);
cout << upperCase << endl; // outputs: hEllO wOrld
```
As usual, your function/method should be pure, i.e. it should **not** mutate the original string. | ["def to_alternating_case(string):\n return string.swapcase()", "def to_alternating_case(string):\n return ''.join([c.upper() if c.islower() else c.lower() for c in string])", "to_alternating_case = str.swapcase", "def to_alternating_case(string):\n strn = \"\"\n for i in string:\n if i.isupper():\n strn += i.lower()\n else:\n strn += i.upper()\n return strn", "def to_alternating_case(string):\n capital_letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', \n 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\n lowercase_letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', \n 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n new_string = []\n \n for character in string:\n if character in capital_letters:\n new_string.append(lowercase_letters[capital_letters.index(character)])\n if character in lowercase_letters:\n new_string.append(capital_letters[lowercase_letters.index(character)])\n if character not in capital_letters and character not in lowercase_letters:\n new_string.append(character)\n \n return ''.join(new_string)\n", "def to_alternating_case(string):\n new_string = ''\n for char in string:\n if char.isupper():\n new_string += char.lower()\n else:\n new_string += char.upper()\n return new_string\n #your code here\n", "def to_alternating_case(string):\n #your code here\n return ''.join(string[i].upper() if string[i].islower() else string[i].lower() for i in range(len(string)))", "def to_alternating_case(string):\n s = ''\n # After i \"Hard Code\" this I will see much much much better solutions to learn from\n for i in string:\n i.split()\n if i.islower():\n s = s + i.upper()\n if i.isupper():\n s = s + i.lower()\n if i.isspace():\n s = s + ' '\n if i.isdigit():\n s = s + str(i)\n if i == '.':\n s = s + str('.')\n if i == '<':\n s = s + str('<')\n if i == '=':\n s = s + str('=')\n if i == '>':\n s = s + str('>')\n if i == \"'\":\n s = s + str(\"'\")\n if i == '?':\n s = s + str('?')\n if i == ';':\n s = s + str(';')\n if i == ',':\n s = s + str(',')\n if i == \"/\":\n s = s + str(\"/\")\n if i == '\\'':\n s = s + str('\\'')\n if i == \"|\":\n s = s + str(\"|\")\n if i == \"!\":\n s = s + str(\"!\")\n if i == \":\":\n s = s + str(\":\")\n \n return s", "to_alternating_case=lambda s:s.swapcase()", "import string\ndef to_alternating_case(s):\n ans = ''\n for c in s:\n if c in string.ascii_lowercase:\n ans += c.upper()\n elif c in string.ascii_uppercase:\n ans += c.lower()\n else:\n ans += c\n return ans", "def to_alternating_case(string):\n string_2 = ''\n for char in string:\n if char.islower():\n string_2 += char.upper()\n else:\n string_2 += char.lower()\n return string_2", "def to_alternating_case(string):\n res = ''\n for c in string:\n res += c.upper() if c.islower() else c.lower()\n return res", "def to_alternating_case(string):\n res = []\n for i in list(string):\n if i.isupper():\n res.append(i.lower())\n else:\n res.append(i.upper())\n return \"\".join(res)", "import re\n\ndef to_alternating_case(string):\n return re.sub(r'([a-z])|([A-Z])',\n lambda c: (c.groups()[0] or \"\").upper() + (c.groups()[1] or \"\").lower(),\n string)", "def to_alternating_case(string):\n new_str = ''\n \n for char in string:\n \n if char.isupper() == True:\n new_str += char.lower()\n else:\n new_str += char.upper()\n \n return new_str", "def to_alternating_case(string):\n return \"\".join([i.capitalize() if str.islower(i) else i.lower() for i in string])", "def to_alternating_case(string):\n temp = ''\n for i in string:\n if ord(i) >= 65 and ord(i) <= 90:\n temp += chr(ord(i) + 32)\n elif ord(i) >= 97 and ord(i) <= 122:\n temp += chr(ord(i) - 32)\n else:\n temp += i\n return temp", "def to_alternating_case(string):\n return ''.join(map(lambda a : a.lower() if a.isupper() else a.upper(), string))", "def to_alternating_case(string):\n NewString = []\n for stri in string:\n if type(stri) is str:\n NewString.append(stri.upper() if stri.islower() else stri.lower())\n else:\n NewString.append(stri)\n \n return (''.join(NewString))", "def to_alternating_case(string):\n str1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\n str2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'\n return string.translate(str.maketrans(str1, str2))", "def to_alternating_case(string):\n\n return ''.join(i.swapcase() for i in string)", "def to_alternating_case(string):\n return \"\".join(x.upper() if x.islower() else x.lower() for x in string)", "def to_alternating_case(string):\n a = ''\n for i in string:\n if i == i.upper():\n a += i.lower()\n else:\n a += i.upper()\n return a\n", "def to_alternating_case(string):\n strX=\"\"\n for i in range(len(string)): \n if string[i].isupper():\n strX += string[i].lower()\n elif string[i].islower(): \n strX += string[i].upper()\n else:\n strX += string[i]\n return strX", "def to_alternating_case(string):\n\n fs =\"\"\n for x in string:\n if x.isupper():\n fs += x.lower()\n else:\n fs += x.upper()\n return fs", "def to_alternating_case(string):\n altstring = ''\n\n for i in range(len(string)):\n if(string[i] == string[i].lower()):\n altstring += string[i].upper()\n else:\n altstring += string[i].lower()\n return altstring", "def to_alternating_case(string):\n alter_case = lambda let: let.lower() if let.isupper() else let.upper()\n return ''.join(map(alter_case, string))", "def to_alternating_case(string):\n alternate = ''\n for char in string:\n if char == char.upper():\n alternate += char.lower()\n else:\n alternate += char.upper()\n return alternate", "def to_alternating_case(string):\n res = []\n for token in string:\n if token.isupper():\n res.append(token.lower())\n elif token.islower():\n res.append(token.upper())\n else:\n res.append(token)\n return \"\".join(res)", "def to_alternating_case(s):\n n=s.swapcase()\n return n\n", "def to_alternating_case(string):\n new_s = \"\"\n for char in string:\n if char.isupper():\n new_s += char.lower()\n else:\n new_s += char.upper()\n \n return new_s", "def to_alternating_case(string):\n output = \"\"\n for character in string:\n if character.isupper():\n output += character.lower()\n else:\n output += character.upper()\n return output", "def to_alternating_case(string):\n str2 = ''\n for char in string:\n if char.isalpha():\n if char.islower():\n r = char.upper()\n str2 += r\n else:\n r = char.lower()\n str2 += r\n else:\n str2 += char\n return str2", "def to_alternating_case(string):\n x = list(string)\n c = \"\"\n for k in x:\n if k == k.upper():\n c += k.lower()\n elif k == k.lower():\n c += k.upper()\n else:\n c += k\n return c \n \n #your code here\n", "def to_alternating_case(string):\n result = \"\"\n for char in string:\n if char.islower() == True:\n result += char.upper()\n else:\n result += char.lower()\n return result", "import string as str\ndef to_alternating_case(string):\n res = \"\"\n for i in string:\n if i in str.ascii_lowercase:\n res += i.upper()\n elif i in str.ascii_uppercase:\n res += i.lower()\n else:\n res += i\n return res", "\ndef to_alternating_case(string):\n strn = \"\"\n for i in string:\n if i == i.upper():\n strn += i.lower()\n elif i == i.lower():\n strn += i.upper()\n return strn\n", "def to_alternating_case(string):\n return string.translate(str.maketrans('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'))", "def to_alternating_case(s):\n # TIL I should google even if the solution looks easy,\n # because there's probably an easier solution.\n \n return s.swapcase()", "def to_alternating_case(s):\n return ''.join(c.upper() if c.islower() else c.lower() if c.isupper() else c for c in s)\n\n # Less compact version of above:\n #\n # a = ''\n # for c in s:\n # if c.islower():\n # a += c.upper()\n # elif c.isupper():\n # a += c.lower()\n # else:\n # a += c\n # return a\n", "def to_alternating_case(string):\n result = ''\n lower_vowels = 'abcdefghijklmnopqrstuvwxyz'\n upper_vowels = lower_vowels.upper()\n index = 0\n while index < len(string):\n if string[index] in lower_vowels:\n result += string[index].upper()\n elif string[index] in upper_vowels:\n result += string[index].lower()\n else:\n result += string[index]\n\n index += 1\n \n return result", "def to_alternating_case(string):\n result =''\n for i in string:\n for j in i:\n \n if j.islower():\n cap=j.upper()\n result=result + cap\n else:\n small=j.lower()\n result=result + small\n return result\n \n \n \n", "to_alternating_case = lambda string: ''.join([[i.upper(),i.lower()][i.isupper()] for i in string])", "def to_alternating_case(string):\n empty_string = \"\"\n for i in string:\n if i.islower():\n empty_string = empty_string + i.upper()\n else:\n empty_string = empty_string + i.lower()\n \n return empty_string", "def to_alternating_case(string):\n a = ''\n for n in string:\n if n.isupper():\n a += n.lower()\n elif n.islower():\n a += n.upper()\n else:\n a += n\n return a", "def to_alternating_case(string):\n result = ''\n for c in string:\n if c == c.upper():\n result=result+c.lower()\n else:\n result = result + c.upper()\n return result", "def to_alternating_case(string):\n return \"\".join(list(i.lower() if i.isupper() else i.upper() for i in string))", "def to_alternating_case(s):\n alt = ''\n\n for i in range(len(str(s))):\n if(s[i]).islower():\n alt += s[i].upper()\n else:\n alt += s[i].lower()\n\n return alt", "def to_alternating_case(string):\n new_string = ''\n for i in string:\n new_string = new_string + i.lower() if i.isupper() else new_string + i.upper()\n return new_string", "def to_alternating_case(string):\n out = ''\n for i in string:\n if i.isupper():\n out = out + i.lower()\n else:\n out = out + i.upper()\n \n return out", "def to_alternating_case(s: str) -> str:\n my_str = ''\n for i in s:\n if i.islower():\n my_str += i.upper()\n elif i.isupper():\n my_str += i.lower()\n else:\n my_str += i\n return my_str", "def to_alternating_case(string):\n s = \"\"\n for l in string:\n if l == l.upper():\n l = l.lower()\n s += l\n else:\n l = l.upper()\n s += l\n return s", "def to_alternating_case(string):\n res = \"\"\n for l in string:\n if l.isupper():\n l = l.lower()\n res += l\n elif l.islower():\n l = l.upper()\n res += l\n else: res += l\n return res", "def to_alternating_case(string):\n answer = \"\"\n for c in string:\n if c.isupper():\n answer += c.lower()\n elif c.islower():\n answer += c.upper()\n else:\n answer += c\n return answer", "def to_alternating_case(string):\n ans = \"\"\n for i in string:\n if i == i.lower():\n ans += i.upper()\n else:\n ans += i.lower()\n return ans", "def to_alternating_case(string):\n result = \"\"\n for i in string:\n if i.isupper():\n result += i.lower()\n if i.islower():\n result += i.upper()\n elif i == \" \":\n result += i\n elif i.isalpha()== False:\n result += i\n return result", "def to_alternating_case(string):\n out = \"\"\n for s in string:\n if s.islower():\n out += s.upper()\n elif s.isupper():\n out += s.lower()\n else:\n out += s\n \n return out", "def to_alternating_case(string):\n output = ''\n for i in string:\n if i == i.lower():\n output += i.upper()\n else:\n output += i.lower()\n return output ", "def to_alternating_case(string):\n l = []\n for i in string:\n if i.upper() == i:\n l.append(i.lower())\n else:\n l.append(i.upper())\n return ''.join(l)", "def to_alternating_case(string):\n letters = [i for i in string]\n\n for i in range(len(letters)):\n if letters[i].islower():\n letters[i] = letters[i].upper()\n else:\n letters[i] = letters[i].lower()\n\n return \"\".join(letters)", "def to_alternating_case(string):\n str2 = \"\"\n \n for c in string:\n if c.isupper():\n str2 += c.lower()\n \n elif c.islower():\n str2 += c.upper()\n \n else:\n str2 += c\n \n return str2", "def to_alternating_case(string):\n\n result = \"\"\n for i in range(len(string)):\n ascii_code = ord(string[i])\n if (97 <= ascii_code <= 122):\n ascii_code -= 32\n elif (65 <= ascii_code <= 90):\n ascii_code += 32\n\n result += chr(ascii_code)\n\n return result\n", "def to_alternating_case(string):\n\n for char in string:\n '''if char.isupper():\n str_ += char.lower()\n elif char.islower():\n str_ += char.upper()\n elif char == \" \":\n str_ += \" \"\n elif string.isdigit():\n return str(string)\n '''\n a = string.swapcase()\n\n return a\n\nprint(to_alternating_case(\"cIao\"))", "def to_alternating_case(string):\n return ''.join(list(map(lambda s: s.lower() if s.isupper() else s.upper(), string)))", "def to_alternating_case(string):\n\n list1 = []\n for letter in string:\n if letter.isupper():\n list1.append(letter.lower())\n else:\n list1.append(letter.upper())\n\n alt_string = ''.join(list1)\n return alt_string", "def to_alternating_case(string):\n output = \"\"\n for str in string:\n if str.isupper():\n output += str.lower()\n elif str.islower():\n output += str.upper()\n elif str == \" \":\n output += \" \"\n else:\n output += str\n return output", "import string\n\ndef to_alternating_case(str):\n return \"\".join(c.lower() if c in string.ascii_uppercase else c.upper() for c in str)", "def to_alternating_case(string):\n return ''.join([letter.swapcase() for letter in string])", "def to_alternating_case(string):\n word = ''\n for el in string:\n if el ==el.upper():\n word+=el.lower()\n elif el ==el.lower():\n word+=el.upper()\n else:\n word += el.upper()\n return word", "def to_alternating_case(string):\n x=[]\n for i in list(string):\n if i.isupper():\n x.append(i.lower())\n elif i.isspace():\n x.append(\" \")\n else:\n x.append(i.upper())\n return \"\".join(x)\n", "to_alternating_case = lambda string: ''.join(map(lambda x: x.upper() if x.islower() else x.lower(), string))", "def to_alternating_case(string):\n resultStr = \"\"\n for k in string:\n if k.islower():\n resultStr += k.upper()\n elif k.isupper():\n resultStr += k.lower()\n else: \n resultStr += k\n return resultStr", "def to_alternating_case(string):\n return string.swapcase() #''.join([l.lower() if l == l.upper() else l.upper() for l in string])", "def to_alternating_case(string):\n return ''.join([l.lower() if l == l.upper() else l.upper() for l in string])", "def to_alternating_case(string):\n string2=''\n for i in string:\n if i.upper()==i:\n string2+=i.lower()\n else:\n string2+=i.upper()\n return string2", "def to_alternating_case(string):\n soln = ''\n \n for char in string:\n if char == char.lower():\n soln += char.upper()\n elif char == char.upper():\n soln += char.lower()\n elif char == '':\n soln += char\n return soln", "def to_alternating_case(string):\n e=[]\n for i in string:\n if ord(i)>=65 and ord(i)<=90:\n a=i.lower()\n e.append(a)\n else:\n a=i.upper()\n e.append(a)\n finale=\"\"\n nuova=finale.join(e)\n return nuova", "def to_alternating_case(string):\n #string.swapcase()\n new = []\n for letter in string:\n if letter.isupper():\n new.append(letter.lower())\n elif letter.islower():\n new.append(letter.upper())\n else:\n new.append(letter)\n return ''.join(new)", "def to_alternating_case(s):\n \"\"\"(^-__-^)\"\"\"\n new_line = \"\"\n for a in s:\n if a.isupper():\n new_line += a.lower()\n elif a.islower():\n new_line += a.upper()\n else:\n new_line += a\n return new_line\n \n \n \n #your code here\n", "def to_alternating_case(s):\n return str().join([i.lower() if i.isupper() else i.upper() for i in s])", "def to_alternating_case(string):\n return \"\".join(list(map(lambda char: char.upper() if char.islower() else char.lower(),string)))", "def to_alternating_case(string):\n newword=''\n for i in range(len(string)):\n if string[i].isupper() == True:\n newword += string[i].lower()\n elif string[i].islower() == True:\n newword += string[i].upper()\n else:\n newword += string[i]\n return newword", "def to_alternating_case(string):\n s = \"\"\n for l in string:\n if l.lower() == l:\n s += l.upper()\n elif l.upper() == l:\n s += l.lower()\n else:\n s += l\n return s", "def to_alternating_case(string):\n res = ''\n for char in string:\n if char.isalpha():\n res += char.upper() if not char.isupper() else char.lower()\n else:\n res += char\n return res", "def to_alternating_case(string):\n\n new_string = []\n\n for character in string:\n if character.isalpha():\n if character.islower():\n new_string.append(character.upper())\n elif character.isupper():\n new_string.append(character.lower())\n else:\n new_string.append(character)\n\n return ''.join(new_string)", "def to_alternating_case(string):\n return ''.join(i.upper() if i == i.casefold() else i.casefold() for i in string)\n", "def to_alternating_case(string):\n final = \"\"\n for i in string:\n if i == i.lower():\n final += i.upper()\n else: \n final += i.lower()\n return final \n", "A = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\ne = A.lower()\ndef to_alternating_case(s):\n t = []\n for i in s:\n if i in A:\n t.append(i.lower())\n elif i in e:\n t.append(i.upper())\n else:\n t.append(i)\n return \"\".join(t) \n\n \n", "def to_alternating_case(string):\n string = [i for i in string]\n for i in range(len(string)):\n if string[i].isupper():\n string[i] = string[i].lower()\n elif string[i].islower():\n string[i] = string[i].upper() \n return ''.join(string)\n\n", "def to_alternating_case(string):\n result = []\n for letter in string:\n if letter.upper() == letter:\n result.append(letter.lower())\n elif letter.lower() == letter:\n result.append(letter.upper())\n\n return ''.join(result)", "def to_alternating_case(a):\n lst = []\n for i in a:\n if i == i.lower():\n lst.append(i.upper())\n else:\n lst.append(i.lower())\n return ''.join(lst)", "def to_alternating_case(string):\n answer = ''\n for i in range(len(string)):\n if string[i].islower():\n answer += string[i].upper()\n else:\n answer += string[i].lower()\n return answer", "def to_alternating_case(string):\n ret = []\n for char in string:\n if char.isupper():\n ret.append(char.lower())\n else:\n ret.append(char.upper())\n return \"\".join(ret)"] | {"fn_name": "to_alternating_case", "inputs": [["hello world"], ["HELLO WORLD"], ["hello WORLD"], ["HeLLo WoRLD"], ["12345"], ["1a2b3c4d5e"], ["String.prototype.toAlternatingCase"]], "outputs": [["HELLO WORLD"], ["hello world"], ["HELLO world"], ["hEllO wOrld"], ["12345"], ["1A2B3C4D5E"], ["sTRING.PROTOTYPE.TOaLTERNATINGcASE"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 22,327 |
def to_alternating_case(string):
|
a52660790c959dbe8b592667550c601b | UNKNOWN | You're in ancient Greece and giving Philoctetes a hand in preparing a training exercise for Hercules! You've filled a pit with two different ferocious mythical creatures for Hercules to battle!
The formidable **"Orthus"** is a 2 headed dog with 1 tail. The mighty **"Hydra"** has 5 heads and 1 tail.
Before Hercules goes in, he asks you "How many of each beast am I up against!?".
You know the total number of heads and the total number of tails, that's the dangerous parts, right? But you didn't consider how many of each beast.
## Task
Given the number of heads and the number of tails, work out the number of each mythical beast!
The data is given as two parameters. Your answer should be returned as an array:
```python
VALID -> [24 , 15] INVALID -> "No solutions"
```
If there aren't any cases for the given amount of heads and tails - return "No solutions" or null (C#). | ["def beasts(heads, tails):\n orthus = (5 * tails - heads) / 3\n hydra = tails - orthus\n return [orthus, hydra] if orthus >= 0 and hydra >= 0 else 'No solutions'", "def beasts(h,t):\n out= [(5*t-h)/3, (h-2*t)/3]\n return all(x.is_integer() and x>=0 for x in out) and out or 'No solutions'", "def beasts(heads, tails):\n if heads not in range(tails * 2, tails * 5 + 1, 3):\n return \"No solutions\"\n return [(tails * 5 - heads) / 3, (heads - tails * 2) / 3]", "def beasts(heads, tails):\n extraheads = heads - 2 * tails\n if extraheads % 3 != 0 or not (0 <= extraheads <= 3 * tails):\n return \"No solutions\"\n hydra = extraheads // 3\n orthus = tails - hydra\n return [orthus, hydra]", "def beasts(heads, tails):\n h = (heads-tails*2)/3\n if h<0 or tails-h<0: return \"No solutions\"\n return [tails-h, h]", "beasts=lambda h, t: (lambda m: [t-m, m] if m>=0 and m<=t and m%1==0 else \"No solutions\")((h-t*2)/3.0)", "def beasts(h, t):\n O, H = 5*t-h, h-2*t\n if O>=O%3>=0<=H%3<=H: return [O//3, H//3]\n else: return \"No solutions\"", "def beasts(heads, tails):\n for orthus in range(heads//2 + 1):\n if orthus * 2 + (tails - orthus) * 5 == heads:\n return [orthus, tails - orthus]\n return 'No solutions'", "def beasts(heads, tails):\n # your code here\n \n o=(5*tails-heads)/3\n h=(heads-2*tails)/3\n \n if o==int(o) and h == int(h) and o>=0 and h >= 0:\n return [int(o),int(h)]\n else:\n return \"No solutions\"\n #return [orthus, hydra]\n", "def beasts(heads, tails):\n hydra = (heads - (2 * tails)) /3\n orthus = tails - ((heads - (2 * tails)) /3)\n if hydra % 1 == 0 and hydra >= 0 and orthus % 1 == 0 and orthus >= 0:\n return [orthus, hydra]\n else:\n return f'No solutions'\n\n"] | {"fn_name": "beasts", "inputs": [[123, 39], [371, 88], [24, 12], [113, 37], [635, 181], [25, 555], [12, 25], [54, 956], [5455, 54956], [0, 0], [-1, -1], [-45, 5], [99, 0], [0, 99], [5, -55]], "outputs": [[[24, 15]], [[23, 65]], [[12, 0]], [[24, 13]], [[90, 91]], ["No solutions"], ["No solutions"], ["No solutions"], ["No solutions"], [[0, 0]], ["No solutions"], ["No solutions"], ["No solutions"], ["No solutions"], ["No solutions"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,848 |
def beasts(heads, tails):
|
8b7c257451a3ef2557b1afcf4170f75c | UNKNOWN | Two fishing vessels are sailing the open ocean, both on a joint ops fishing mission.
On a high stakes, high reward expidition - the ships have adopted the strategy of hanging a net between the two ships.
The net is **40 miles long**. Once the straight-line distance between the ships is greater than 40 miles, the net will tear, and their valuable sea harvest will be lost! We need to know how long it will take for this to happen.
Given the bearing of each ship, find the time **in minutes** at which the straight-line distance between the two ships reaches **40 miles**. Both ships travel at **90 miles per hour**. At time 0, assume the ships have the same location.
Bearings are defined as **degrees from north, counting clockwise**.
These will be passed to your function as integers between **0 and 359** degrees.
Round your result to **2 decmal places**.
If the net never breaks, return float('inf')
Happy sailing! | ["from math import sin, radians\n\ndef find_time_to_break(bearing_A, bearing_B):\n a = radians(abs(bearing_A - bearing_B) / 2)\n return 40 / (3 * sin(a)) if a else float(\"inf\")", "def find_time_to_break(bearing_A, bearing_B):\n import math\n if bearing_A == bearing_B:\n return float(\"inf\")\n return round(math.sqrt(40**2/(2*(1 - math.cos(math.radians(abs(bearing_A - bearing_B)))))) * 2 / 3, 2)", "import math\ndef find_time_to_break(bearing_A, bearing_B):\n \n ships_angle = abs(bearing_A - bearing_B) * (math.pi/180)\n \n time_to_40 = float('inf')\n if ships_angle > 0:\n den = 1.5 * math.sqrt(2 * (1 - round(math.cos(ships_angle),5)))\n time_to_40 = round(40/den, 2)\n \n return time_to_40", "def find_time_to_break(bearing_A, bearing_B):\n import math\n # the case we have here will make an isosceles triangle, we just have to solve either half of it.\n bear = abs(bearing_A - bearing_B) / 2\n angle = math.sin(math.radians(bear))\n if angle != 0:\n return round ((20 * 60) / (angle* 90), 2)\n else:\n return float('inf')", "from math import (sin, radians)\n\ndef find_time_to_break(b1, b2):\n return round(40 / sin(radians(abs(b1 - b2)) / 2) / 3, 2) if b1 - b2 != 0 else float(\"inf\")\n", "from math import cos, hypot, radians, sin\n\ndef find_time_to_break(a, b):\n a, b = radians(a), radians(b)\n d = hypot(cos(a) - cos(b), sin(a) - sin(b))\n return 40 / (90 / 60) / d if d else float('inf')", "from math import cos, radians, inf\n\ndef find_time_to_break(bearing_A, bearing_B):\n theta = bearing_A - bearing_B\n return inf if theta == 0 else 18.86 / (1 - cos(radians(theta)))**0.5", "from math import *\n\ndef find_time_to_break(a,b):\n vShips, netLength = 90/60, 40\n return float('inf') if a==b else netLength/2 / (vShips * sin(radians(abs(b-a)/2)))", "from math import sin, pi\n\ndef find_time_to_break(bearing_A, bearing_B):\n return float(\"inf\") if abs(bearing_A-bearing_B) == 0 else 20/(sin((abs(bearing_A-bearing_B)*pi/180)/2))*60/90", "from math import cos, pi, sin\n\nSHIP_MPH = 90 # WOW, part trawler - part speed boat, fast ship!\nNET_LENGTH = 40 # Impressive net length too, are these fishermen using alien tech?\n\n\ndef find_time_to_break(bearing_A, bearing_B):\n \n # Find angle between ships\n ba, bb = bearing_A + 360, bearing_B + 360\n alpha = min(abs(ba - bb), abs(bb - ba))\n if alpha > 180:\n alpha = 360 - alpha\n \n if alpha == 0:\n # Ships travelling on parallel courses\n return float('inf')\n \n # Find seperation between ships per hour\n theta = alpha / 2 / 180 * pi # Half alpha in rads\n # Position of each ship\n s1 = SHIP_MPH * sin(theta), SHIP_MPH * cos(theta)\n s2 = SHIP_MPH * sin(-theta), SHIP_MPH * cos(-theta)\n # Pythagorean distance between ships\n mph = (((s1[0] - s2[0]) ** 2) + ((s1[1] - s2[1]) ** 2)) ** 0.5\n \n # Max time in minutes before the net snaps\n return NET_LENGTH / mph * 60\n"] | {"fn_name": "find_time_to_break", "inputs": [[90, 90]], "outputs": [[Infinity]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,043 |
def find_time_to_break(bearing_A, bearing_B):
|
aebb8ba02c9c8abaa49c0e9f1011b73d | UNKNOWN | < PREVIOUS KATA
NEXT KATA >
## Task:
You have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows.
* Note:```Returning``` the pattern is not the same as ```Printing``` the pattern.
### Parameters:
pattern( n , x , y );
^ ^ ^
| | |
Term upto which Number of times Number of times
Basic Pattern Basic Pattern Basic Pattern
should be should be should be
created repeated repeated
horizontally vertically
* Note: `Basic Pattern` means what we created in Complete The Pattern #12
## Rules/Note:
* The pattern should be created using only unit digits.
* If `n < 1` then it should return "" i.e. empty string.
* If `x <= 1` then the basic pattern should not be repeated horizontally.
* If `y <= 1` then the basic pattern should not be repeated vertically.
* `The length of each line is same`, and is equal to the length of longest line in the pattern.
* Range of Parameters (for the sake of CW Compiler) :
+ `n ∈ (-∞,25]`
+ `x ∈ (-∞,10]`
+ `y ∈ (-∞,10]`
* If only two arguments are passed then the function `pattern` should run as if `y <= 1`.
* If only one argument is passed then the function `pattern` should run as if `x <= 1` & `y <= 1`.
* The function `pattern` should work when extra arguments are passed, by ignoring the extra arguments.
## Examples:
* Having Three Arguments-
+ pattern(4,3,2):
1 1 1 1
2 2 2 2 2 2
3 3 3 3 3 3
4 4 4
3 3 3 3 3 3
2 2 2 2 2 2
1 1 1 1
2 2 2 2 2 2
3 3 3 3 3 3
4 4 4
3 3 3 3 3 3
2 2 2 2 2 2
1 1 1 1
* Having Two Arguments-
+ pattern(10,2):
1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
6 6 6 6
7 7 7 7
8 8 8 8
9 9 9 9
0 0
9 9 9 9
8 8 8 8
7 7 7 7
6 6 6 6
5 5 5 5
4 4 4 4
3 3 3 3
2 2 2 2
1 1 1
* Having Only One Argument-
+ pattern(25):
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
0 0
1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 1
0 0
9 9
8 8
7 7
6 6
5 5
4 4
3 3
2 2
1 1
0 0
9 9
8 8
7 7
6 6
5 5
4 4
3 3
2 2
1 1
>>>LIST OF ALL MY KATAS<<< | ["def pattern(n, x=1, y=1, *args):\n if n < 1:\n return \"\"\n result = []\n for i in range(1, n + 1):\n line = \" \" * (i - 1) + str(i % 10) + \" \" * (n - i)\n result.append((line + line[::-1][1:]) + (line[1:] + line[::-1][1:]) * (x - 1))\n return \"\\n\".join((result + result[::-1][1:]) + (result[1:] + result[::-1][1:]) * (y - 1))\n", "def pattern(n,y=1,z=1,*e):\n res = []\n for i in range(1, n + 1):\n line = ' ' * (i - 1) + str(i % 10) + ' ' * (n - i)\n res.append( patt(line) + cott(patt(line) ,y))\n \n res1 = patt(res) + cott(patt(res), z )\n return '\\n'.join( res1 ) \n \npatt = lambda elem : elem + elem[::-1][1:]\ncott = lambda elem, x : elem[1:] * (x-1)", "def pattern(*arg):\n res = []\n arg = list(arg) + [1,1]\n n, y, z = arg[:3]\n\n for i in range(1, n + 1):\n line = ' ' * (i - 1) + str(i % 10) + ' ' * (n - i)\n res.append( patt(line) + cott(patt(line) ,y))\n \n res1 = patt(res) + cott(patt(res), z )\n return '\\n'.join( res1 ) \n \npatt = lambda elem : elem + elem[::-1][1:]\ncott = lambda elem, x=0 : elem[1:] * (x-1)", "def getHorizontal(s,x): return s+s[1:]*(x-1)\n\ndef pattern(n,x=1,y=1,*a):\n if n<1: return ''\n l, x, y = 2*n-1, max(1,x), max(1,y)\n sngl = [getHorizontal('{}{}{}'.format(z%10, ' '*(l-2*z), z%10 if z!=n else '').center(l), x) for z in range(1,n+1)]\n cross = sngl + sngl[:-1][::-1]\n return '\\n'.join( cross + cross[1:]*(y-1) )", "def pattern(n,x=1,y=1,*args):\n lines=[]; x-=1\n for i in range(1,n+1):\n line=' '*(i-1)+str(i)[-1]+' '*(n-i)\n line+=line[-2::-1]\n line+=line[1:]*x \n lines.append(line)\n pat=lines+lines[-2::-1]\n pat+=pat[1:]*(y-1)\n return '\\n'.join(pat)\n", "def pattern(n, x=1, y=1, *_):\n pat = [\"\".join([\" \" * (i - 1), str(i % 10), \" \" * (n - i)]) for i in range(1,n+1)]\n pat = [\"\".join([i, i[-2::-1]]) for i in pat]\n pat = [\"\".join([i, i[1:] * (x-1)]) for i in pat]\n pat1 = \"\\n\".join(pat + pat[-2::-1])\n return '' if n<1 else pat1+('\\n'+\"\\n\".join(pat[1:] + pat[-2::-1]))*(y-1)\n", "pattern=lambda n,x=1,y=1,*args: \"\\n\".join((lambda h: h+([\"\\n\".join(h[1:]) for k in range(1,y)]))([(lambda r: \"\".join(r)+\"\".join([\"\".join(r[1:]) for j in range(1,x)]))([\" \"]*(i-1)+[str(i%10)]+[\" \"]*(2*(n-i)-1)+[str(i%10)]+[\" \"]*(i-1)) for i in range(1,n)]+[(lambda r: r+\"\".join([r[1:] for j in range(1,x)]) )(\" \"*(n-1)+str(n%10)+\" \"*(n-1))]+[(lambda r: \"\".join(r)+\"\".join([\"\".join(r[1:]) for j in range(1,x)]))([\" \"]*(i-1)+[str(i%10)]+[\" \"]*(2*(n-i)-1)+[str(i%10)]+[\" \"]*(i-1)) for i in range(n-1,0,-1)])) if n>0 else \"\"\n\n#this one-liner was not so easy :D Dedicated to my fellow codewarrior ChristianECooper:\n#knowing that my code can be read by someone that good and precise keeps me surely\n#motivated; against him I may have the upper hand just with regexes (and he\n#certainly is better at explaining), but I won't give up that easily ;)\n", "def pattern(n,m=1,l=1,*args):\n if n < 1:return ''\n m = max(1,m)\n li, mid, r = ['1'+' '*((n*2-1)-2)+'1'+(' '*((n*2-1)-2)+'1')*(m-1)],1,(n*2-1)-2-2\n for i in range(2, n + 1):\n li.append(' '*(i-1)+f\"{' '*mid}\".join([str(i%10)+' '*r+(str(i%10)if i!=n else '')for o in range(m)])+' '*(i-1))\n r -= 2 ; mid += 2\n li = li + li[:-1][::-1]\n well = li.copy()\n return \"\\n\".join(li + [\"\\n\".join(well[1:]) for i in range(l-1)])", "m,r=lambda s:s+s[-2::-1],lambda s,n:s+s[1:]*n\npattern=lambda n,h=1,v=1,*a:'\\n'.join(r(m(list(r(m(' '*(i-1)+str(i%10)+' '*(n-i)),h-1)for i in range(1,n+1))),v-1))"] | {"fn_name": "pattern", "inputs": [[4, 2, 3], [3, -29, 4], [5, -28, 0], [7, 2], [10, -2999], [5], [4, 2, 3, 5, 7, -8], [-3, -5, 0], [-11, 1, 3], [-25, 5, -9], [-25, -11, 9], [-3, -5], [-11, 3], [-9999999], [-25, 5, -9, 55, -8, -7, 8], [0, 1, 2], [0, -1, 0], [0, -1, 2], [0, 1, -2], [0, 1], [0, -1], [0], [0, -5, 8, -7, 10]], "outputs": [["1 1 1\n 2 2 2 2 \n 3 3 3 3 \n 4 4 \n 3 3 3 3 \n 2 2 2 2 \n1 1 1\n 2 2 2 2 \n 3 3 3 3 \n 4 4 \n 3 3 3 3 \n 2 2 2 2 \n1 1 1\n 2 2 2 2 \n 3 3 3 3 \n 4 4 \n 3 3 3 3 \n 2 2 2 2 \n1 1 1"], ["1 1\n 2 2 \n 3 \n 2 2 \n1 1\n 2 2 \n 3 \n 2 2 \n1 1\n 2 2 \n 3 \n 2 2 \n1 1\n 2 2 \n 3 \n 2 2 \n1 1"], ["1 1\n 2 2 \n 3 3 \n 4 4 \n 5 \n 4 4 \n 3 3 \n 2 2 \n1 1"], ["1 1 1\n 2 2 2 2 \n 3 3 3 3 \n 4 4 4 4 \n 5 5 5 5 \n 6 6 6 6 \n 7 7 \n 6 6 6 6 \n 5 5 5 5 \n 4 4 4 4 \n 3 3 3 3 \n 2 2 2 2 \n1 1 1"], ["1 1\n 2 2 \n 3 3 \n 4 4 \n 5 5 \n 6 6 \n 7 7 \n 8 8 \n 9 9 \n 0 \n 9 9 \n 8 8 \n 7 7 \n 6 6 \n 5 5 \n 4 4 \n 3 3 \n 2 2 \n1 1"], ["1 1\n 2 2 \n 3 3 \n 4 4 \n 5 \n 4 4 \n 3 3 \n 2 2 \n1 1"], ["1 1 1\n 2 2 2 2 \n 3 3 3 3 \n 4 4 \n 3 3 3 3 \n 2 2 2 2 \n1 1 1\n 2 2 2 2 \n 3 3 3 3 \n 4 4 \n 3 3 3 3 \n 2 2 2 2 \n1 1 1\n 2 2 2 2 \n 3 3 3 3 \n 4 4 \n 3 3 3 3 \n 2 2 2 2 \n1 1 1"], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,698 |
def pattern(n, x=1, y=1, *args):
|
3904664406920ee9b6db69f49969d5dd | UNKNOWN | *Based on this Numberphile video: https://www.youtube.com/watch?v=Wim9WJeDTHQ*
---
Multiply all the digits of a nonnegative integer `n` by each other, repeating with the product until a single digit is obtained. The number of steps required is known as the **multiplicative persistence**.
Create a function that calculates the individual results of each step, not including the original number, but including the single digit, and outputs the result as a list/array. If the input is a single digit, return an empty list/array.
## Examples
```
per(1) = []
per(10) = [0]
// 1*0 = 0
per(69) = [54, 20, 0]
// 6*9 = 54 --> 5*4 = 20 --> 2*0 = 0
per(277777788888899) = [4996238671872, 438939648, 4478976, 338688, 27648, 2688, 768, 336, 54, 20, 0]
// 2*7*7*7*7*7*7*8*8*8*8*8*8*9*9 = 4996238671872 --> 4*9*9*6*2*3*8*6*7*1*8*7*2 = 4478976 --> ...
``` | ["def per(n):\n r = []\n while n>=10:\n p=1\n for i in str(n):\n p=p*int(i)\n r.append(p)\n n = p\n return r", "from functools import reduce\n\ndef per(n):\n r = []\n p = reduce(lambda a, b: a*b, map(int, str(n)))\n return r if p == n else [p] + per(p)", "from functools import reduce\nfrom operator import mul\n\ndef per(n):\n results = []\n while n > 9:\n n = reduce(mul, map(int, str(n)))\n results.append(n)\n \n return results", "def per(n, s=0):\n return ([n] if s else []) + (per(eval('*'.join(str(n))), 1) if n > 9 else [])", "def per(n):\n def p(n):\n q, r = divmod(n, 10)\n if q == 0:\n return n\n return r * p(q)\n \n ans = []\n while n // 10 > 0:\n n = p(n)\n ans.append(n)\n return ans", "def per(n):\n ans = []\n while n // 10 > 0:\n acc = 1\n for ch in str(n):\n acc *= int(ch)\n n = acc\n ans.append(n)\n return ans", "from functools import reduce\nfrom operator import mul\n\ndef per(n):\n result = []\n s = str(n)\n while len(s) > 1:\n result.append(reduce(mul, map(int, s)))\n s = str(result[-1])\n return result", "from numpy import prod\ndef per(n):\n if n<10: return []\n arr = []\n while n>9:\n n = prod([int(i) for i in str(n)])\n arr.append(n)\n return arr", "def per(n):\n arr = []\n while n>9:\n s = 1\n for i in str(n):\n s *= int(i)\n n = s\n arr.append(n)\n return arr", "def per(n):\n if n<10:\n return []\n l=[]\n while n>9:\n total=1\n num=str(n)\n for i in num:\n total*=int(i)\n l.append(total)\n n=total\n return l\n"] | {"fn_name": "per", "inputs": [[1234567890], [123456789], [12345678], [1234567], [123456], [12345], [2379], [777], [25], [277777788888899], [3778888999]], "outputs": [[[0]], [[362880, 0]], [[40320, 0]], [[5040, 0]], [[720, 0]], [[120, 0]], [[378, 168, 48, 32, 6]], [[343, 36, 18, 8]], [[10, 0]], [[4996238671872, 438939648, 4478976, 338688, 27648, 2688, 768, 336, 54, 20, 0]], [[438939648, 4478976, 338688, 27648, 2688, 768, 336, 54, 20, 0]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,812 |
def per(n):
|
dfbfe1815d230e6d02a775edf669ce55 | UNKNOWN | # Task
You are given a string consisting of `"D", "P" and "C"`. A positive integer N is called DPC of this string if it satisfies the following properties:
```
For each i = 1, 2, ... , size of the string:
If i-th character is "D", then N can be divided by i
If i-th character is "P", then N and i should be relatively prime
If i-th character is "C", then N should neither be divided by i
nor be relatively prime with i```
Your task is to find the smallest DPC of a given string, or return `-1` if there is no such. The result is guaranteed to be `<= 10^9`.
# Example
For `s = "DDPDD"`, the result should be `20`.
`"DDPDD"` means `N` should `divided by 1,2,4,5`, and `N,3` should be relatively prime. The smallest N should be `20`.
# Input/Output
- `[input]` string `s`
The given string
- `[output]` an integer
The smallest DPC of `s` or `-1` if it doesn't exist. | ["from fractions import gcd\n\ndef DPC_sequence(s):\n n=1\n for i,c in enumerate(s,1):\n if c=='D':\n n=(n*i)//gcd(n,i)\n elif c=='P':\n if gcd(n,i)!=1: return -1\n elif c=='C':\n if gcd(n,i) in (1,i): return -1\n return n\n", "from fractions import gcd\n\ndef DPC_sequence(s):\n n = 1\n for i, c in enumerate(s, 1):\n if c == 'D': n = n * i // gcd(n, i)\n for i, c in enumerate(s, 1):\n g = gcd(n, i)\n if c == 'P' and 1 < g: return -1\n if c == 'C' and not 1 < g < i: return -1\n return n", "from fractions import gcd\nfrom collections import defaultdict\nfrom functools import reduce\n\ndef lcm(a,b): return int(a*b/gcd(a,b))\ndef full_lcm(*args): return reduce(lcm, args)\n\ndef DPC_sequence(s):\n DPC_dct = defaultdict(set)\n for i,c in enumerate(s,1): DPC_dct[c].add(i)\n n = full_lcm(*DPC_dct['D'])\n return -1 if any( gcd(n, x) in [1, x] for x in DPC_dct['C']) or any( gcd(n, x) != 1 for x in DPC_dct['P']) else n\n", "from math import gcd\nfrom functools import reduce\n\ndef DPC_sequence(s):\n def lcm(a, b):\n return a*b // gcd(a, b)\n \n d, p, c = [], [], []\n for i in range(len(s)):\n if s[i] == \"D\": \n d.append(i+1)\n elif s[i] == \"P\":\n p.append(i+1)\n else:\n c.append(i+1)\n \n if not d:\n return -1\n lcm_d = reduce(lambda i, j: lcm(i, j), d)\n for i in p:\n if gcd(lcm_d, i) != 1:\n return -1\n for i in c:\n if lcm_d % i == 0 or gcd(lcm_d, i) == 1:\n return -1\n return lcm_d\n", "from math import gcd\n\ntry:\n from math import prod\nexcept ImportError:\n def prod(l, p=1):\n for n in l: p *= n\n return p\n\nmax_n = 1000000000\n\ndef DPC_sequence(s):\n if s[0] == 'C':\n return -1\n primes = list(find_primes(len(s)))\n pf = []\n for p in primes:\n if s[p-1] == 'C':\n return -1\n if s[p-1] == 'D':\n pf.append(p)\n #print(pf)\n for p in pf:\n for i in range(2*p-1, len(s), p):\n if s[i] == 'P':\n return -1\n base = prod(pf)\n nmax = min(prod(primes), max_n)\n #print(base, nmax)\n for n in range(base, nmax, base):\n if test(s, n):\n return n\n return -1\n\ndef test(s, n):\n for k in range(2, len(s)+1):\n c = s[k-1]\n if c == 'D':\n if n % k != 0: return False\n else:\n if (gcd(n, k) == 1) != (c == 'P'): return False\n return True\n\ndef find_primes(n):\n if n < 2: return\n yield 2\n s = list(range(1, n+1, 2))\n mroot = int(n ** 0.5)\n half = (n+1) // 2\n i = 1\n m = 3\n while m <= mroot:\n if s[i]:\n yield s[i]\n j = m*m // 2\n while j < half:\n s[j] = 0\n j += m\n i += 1\n m += 2\n for x in s[i:]:\n if x:\n yield x\n", "from math import gcd\ndef DPC_sequence(s):\n r=1\n pset=set()\n for i,c in enumerate(s):\n x=i+1\n if c=='D':\n if r%x==0:\n continue\n y=x//gcd(r,x)\n if y in pset:\n return-1\n r*=y\n elif c=='P':\n if r%x==0 or gcd(r,x)>1:\n return -1\n pset.add(x)\n else:\n if r%x==0 or gcd(r,x)==1:\n return -1\n return r", "from fractions import gcd\n\ndef DPC_sequence(s):\n res = 1\n \n for i, c in enumerate(s, 1):\n if c == 'D':\n res *= i // gcd(i, res)\n \n def check_DPC_at(i, c):\n if c == 'D':\n return gcd(i, res) == i\n elif c == 'C':\n return gcd(i, res) in range(2, i)\n elif c == 'P':\n return gcd(i, res) == 1\n \n return res if all(check_DPC_at(*e) for e in enumerate(s, 1)) else -1\n", "from math import gcd\nfrom copy import copy\n\n\ndef DPC_sequence(s):\n d = [x for x, y in enumerate(s, 1) if y == 'D']\n p = [x for x, y in enumerate(s, 1) if y == 'P']\n c = [x for x, y in enumerate(s, 1) if y == 'C']\n D = lcm(d) if len(d) > 1 else d[0]\n return D if all(gcd(D, i) == 1 for i in p if i != 1) and all(1 < gcd(D, i) < i for i in c) else -1\n\n\ndef lcm(n):\n x = n.copy()\n while x:\n i, n = x[-2:]\n del x[-2:]\n if not x: return n\n x.append(i * n // gcd(i, n))", "from math import gcd\nlcm = lambda x,y: x*y//gcd(x,y)\n\ndef DPC_sequence(s):\n res = 1\n for i,x in enumerate(s):\n if x == 'D':\n res = lcm(res, i+1)\n for i,x in enumerate(s):\n if (x == 'C' and (not res%(i+1) or gcd(res, i+1) == 1)) or (x == 'P' and gcd(res, i+1) > 1):\n return -1\n return res", "from fractions import gcd\nfrom functools import reduce\n\ndef DPC_sequence(s):\n ds, ps, cs, prod = [], [], [], 1\n \n for i, v in enumerate(s, 1):\n if v == 'D': \n ds.append(i)\n prod = (prod * i) // gcd(prod, i)\n elif v == 'P': ps.append(i)\n elif v == 'C': cs.append(i)\n \n for p in ps: \n if gcd(prod, p) != 1: return -1\n for c in cs: \n if prod % c == 0 or gcd(prod, c) == 1: return -1\n \n return prod"] | {"fn_name": "DPC_sequence", "inputs": [["DDPDD"], ["DDDDPDDCCCDDPDCCPCDCDDPCPCCDDCD"], ["DPCPDPPPDCPDPDPC"], ["DDDDDDCD"], ["CDDDPDDD"], ["DDDDDDPCCDPDPP"]], "outputs": [[20], [15782844], [-1], [-1], [-1], [-1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 5,407 |
def DPC_sequence(s):
|
05a0a8a4f47ce868d0b0341da0d9ccae | UNKNOWN | # Task
Christmas is coming, and your task is to build a custom Christmas tree with the specified characters and the specified height.
# Inputs:
- `chars`: the specified characters.
- `n`: the specified height. A positive integer greater than 2.
# Output:
- A multiline string. Each line is separated by `\n`. A tree contains two parts: leaves and trunks.
The leaves should be `n` rows. The first row fill in 1 char, the second row fill in 3 chars, and so on. A single space will be added between two adjust chars, and some of the necessary spaces will be added to the left side, to keep the shape of the tree. No space need to be added to the right side.
The trunk should be at least 1 unit height, it depends on the value of the `n`. The minimum value of n is 3, and the height of the tree trunk is 1 unit height. If `n` increased by 3, and the tree trunk increased by 1 unit. For example, when n is 3,4 or 5, trunk should be 1 row; when n is 6,7 or 8, trunk should be 2 row; and so on.
Still not understand the task? Look at the following example ;-)
# Examples
For `chars = "*@o" and n = 3`,the output should be:
```
*
@ o
* @ o
|
```
For `chars = "*@o" and n = 6`,the output should be:
```
*
@ o
* @ o
* @ o *
@ o * @ o
* @ o * @ o
|
|
```
For `chars = "1234" and n = 6`,the output should be:
```
1
2 3
4 1 2
3 4 1 2
3 4 1 2 3
4 1 2 3 4 1
|
|
```
For `chars = "123456789" and n = 3`,the output should be:
```
1
2 3
4 5 6
|
``` | ["def custom_christmas_tree(chars, n):\n from itertools import cycle\n it = cycle(chars)\n tree = [' '.join(next(it) for j in range(i)).center(2 * n).rstrip() for i in range(1, n + 1)]\n tree.extend('|'.center(2 * n).rstrip() for _ in range(n // 3))\n return '\\n'.join(tree)", "from itertools import cycle, chain\n\ndef custom_christmas_tree(chars, n):\n c, l = cycle(chars), 2*n-1\n return '\\n'.join(chain( (' '.join(next(c) for _ in range(i)).center(l).rstrip() for i in range(1,n+1)),\n ('|'.center(l).rstrip() for _ in range(n//3 or 1)) ))", "class Chaos(object):\n pass\n\nclass Nature(Chaos):\n\n \n def buildTree(self, luck):\n n = luck\n tree = \"\"\n \n for i in range(1, n+1):\n #leafs grow in the i'th layer\n temp_layer = Leafs.get_leaf(self)\n for j in range(0,i-1):\n temp_layer += ' '\n temp_layer += Leafs.get_leaf(self)\n \n tree += ' '*(n-i) + temp_layer + \"\\n\"\n \n # grows from roots to upper branches\n for i in range(n//3):\n if i == n//3-1:\n tree += ' '*(n-1) + Trunk.pieceOfTrunk(self)\n break\n tree += ' '*(n-1) + Trunk.pieceOfTrunk(self) + \"\\n\"\n \n return tree\n \n \nclass Leafs(Nature):\n \"\"\"Arguments: Tell leaf types as string,\n Receive A(one) leaf as string.\"\"\"\n \n \n def __init__(self, leaftypes):\n self.leaftypes = leaftypes\n self.nextleaf = 0\n \n def get_leaf(self):\n \"\"\"Returns the next leaf as singleton string\"\"\"\n # increase nextleaf\n self.nextleaf += 1\n #leaft, abbreviation for leaftypes\n leaft = self.leaftypes \n #return the value before increment\n return leaft[(self.nextleaf-1)%len(leaft)]\n\n \nclass Trunk(Nature):\n def pieceOfTrunk(self):\n return \"|\"\n \ndef custom_christmas_tree(chars, n):\n yaprak = Leafs(chars)\n life = Nature.buildTree(yaprak, n)\n return life", "from itertools import chain, cycle, islice, repeat\n\ndef custom_christmas_tree(chars, n):\n it = cycle(chars)\n leaves = (' '.join(islice(it, i)).center(2 * n - 1).rstrip() for i in range(1, n+1))\n trunk = repeat('|'.rjust(n), n // 3)\n return '\\n'.join(chain(leaves, trunk))", "from itertools import cycle\n\ndef custom_christmas_tree(chars, height):\n ornament = cycle(chars)\n lines = []\n for n in range(1, height+1):\n lines += [' ' * (height - n) + ' '.join(next(ornament) for _ in range(0, n))]\n for n in range(height // 3):\n lines += [' ' * (height - 1) + '|']\n return \"\\n\".join(lines)", "def custom_christmas_tree(chars, n):\n trunc = n // 3\n string = ''\n l, i = len(chars), 0\n for r in range(n):\n string += ' ' * (n - r - 1)\n for c in range(r + 1):\n string += chars[i % l]\n string += ' ' if c < r else '\\n'\n i += 1\n for r in range(trunc):\n string += ' ' * (n - 1) + '|'\n string += '\\n' if r < trunc - 1 else ''\n return string", "def custom_christmas_tree(chars, n):\n chars *= n*n\n s = lambda n: (n+1)*n//2\n pad = lambda s: ' '*(n-len(s)//2-1)+s\n row = lambda i: pad(' '.join(chars[s(i):s(i)+i+1]))\n return '\\n'.join([*map(row,range(n))] + [pad('|')]*(n//3))", "from itertools import cycle\n\ndef custom_christmas_tree(chars, n):\n leaf_provider = cycle(chars)\n trunk_height = n // 3\n max_width = 2 * n - 1\n tree = []\n def build_row(provider, row_number):\n return \" \".join([provider.__next__() for _ in range(row_number)])\n\n def padding(row_number):\n return \" \" * (max_width // 2 - (2 * row_number - 1) // 2)\n\n def build_trunk():\n return [padding(1) + \"|\" for _ in range(trunk_height)]\n\n for i in range(n):\n tree.append(padding(i + 1) + build_row(leaf_provider, i + 1))\n tree.extend(build_trunk())\n return \"\\n\".join(tree)", "from itertools import cycle\n\ndef custom_christmas_tree(chars, n):\n l, s = cycle(chars), lambda i=0: \" \" * (n - 1 - i)\n return \"\\n\".join([s(i) + \" \".join(next(l) for _ in range(i+1)) for i in range(n)] + [f\"{s()}|\" for _ in range(n//3)])\n", "from itertools import cycle\n\ndef custom_christmas_tree(chars, n):\n space = lambda i=0: \" \" * (n - 1 - i)\n leaf = cycle(chars)\n body = [space(i) + \" \".join(next(leaf) for _ in range(i+1)) for i in range(n)]\n body.extend([f\"{space()}|\" for _ in range(n//3)])\n return '\\n'.join(body)"] | {"fn_name": "custom_christmas_tree", "inputs": [["*@o", 3], ["*@o", 6], ["1234", 6], ["123456789", 3]], "outputs": [[" *\n @ o\n* @ o\n |"], [" *\n @ o\n * @ o\n * @ o *\n @ o * @ o\n* @ o * @ o\n |\n |"], [" 1\n 2 3\n 4 1 2\n 3 4 1 2\n 3 4 1 2 3\n4 1 2 3 4 1\n |\n |"], [" 1\n 2 3\n4 5 6\n |"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,704 |
def custom_christmas_tree(chars, n):
|
f8322e7becac031ca6759141e432362d | UNKNOWN | The Fibonacci numbers are the numbers in the following integer sequence (Fn):
>0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...
such as
>F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
Given a number, say prod (for product), we search two Fibonacci numbers F(n) and F(n+1) verifying
>F(n) * F(n+1) = prod.
Your function productFib takes an integer (prod) and returns
an array:
```
[F(n), F(n+1), true] or {F(n), F(n+1), 1} or (F(n), F(n+1), True)
```
depending on the language if F(n) * F(n+1) = prod.
If you don't find two consecutive F(m) verifying `F(m) * F(m+1) = prod`you will return
```
[F(m), F(m+1), false] or {F(n), F(n+1), 0} or (F(n), F(n+1), False)
```
F(m) being the smallest one such as `F(m) * F(m+1) > prod`.
### Some Examples of Return:
(depend on the language)
```
productFib(714) # should return (21, 34, true),
# since F(8) = 21, F(9) = 34 and 714 = 21 * 34
productFib(800) # should return (34, 55, false),
# since F(8) = 21, F(9) = 34, F(10) = 55 and 21 * 34 < 800 < 34 * 55
-----
productFib(714) # should return [21, 34, true],
productFib(800) # should return [34, 55, false],
-----
productFib(714) # should return {21, 34, 1},
productFib(800) # should return {34, 55, 0},
-----
productFib(714) # should return {21, 34, true},
productFib(800) # should return {34, 55, false},
```
### Note:
- You can see examples for your language in "Sample Tests". | ["def productFib(prod):\n a, b = 0, 1\n while prod > a * b:\n a, b = b, a + b\n return [a, b, prod == a * b]", "def productFib(prod):\n a,b = 0,1\n while a*b < prod:\n a,b = b, b+a\n return [a, b, a*b == prod]", "def productFib(prod):\n a, b = 0, 1\n rez = 0\n while rez < prod:\n a, b = b, a + b\n rez = a*b\n return [a, b, rez == prod]", "def productFib(prod):\n func = lambda a, b: func(b, a+b) if a*b < prod else [a, b, a*b == prod]\n return func(0, 1)", "def productFib(prod):\n a, b = 0, 1\n while a*b < prod:\n a, b = b, a+b\n return [a, b, a*b == prod]", "def productFib(prod, f1=0, f2=1):\n return [f1, f2, True] if prod == f1 * f2 else [f1, f2, False] if prod < f1 * f2 else productFib(prod, f2, f1+f2)", "def productFib(prod):\n fib1, fib2 = 0, 1\n while prod > fib1*fib2:\n fib2, fib1 = fib1 + fib2, fib2\n return [fib1, fib2, prod == fib1*fib2]\n", "def productFib(prod):\n num = 1\n prev = 0\n while prev * num < prod:\n temp = num + prev\n prev = num\n num = temp\n return [prev, num, prev * num == prod]", "from bisect import *\n\ndef genProdFib():\n a,b = 0,1\n while 1:\n yield a*b,b\n a,b = b,a+b\n\nGEN,PROD = genProdFib(), [(-1,0)]\n\ndef productFib(p):\n def formatOut(pp,b): return [pp//b, b, pp==p]\n \n if PROD[-1][0]>p:\n return formatOut(*PROD[bisect(PROD, (p,0))])\n \n while PROD[-1][0]<p:\n PROD.append(next(GEN))\n return formatOut(*PROD[-1])", "def productFib(prod):\n for x, y in fib():\n if x * y == prod:\n return [x, y, True]\n elif x * y > prod:\n return [x, y, False]\n\ndef fib():\n a, b = 0, 1\n while True:\n yield a, b\n a, b = b, a + b", "def productFib(prod):\n n,n_1 = 0,1\n while True:\n if n*n_1==prod:\n return [n, n_1, True]\n elif n*n_1>prod:\n return [n,n_1, False]\n else:\n n, n_1 = n_1, n_1+n", "def productFib(prod):\n i = 0\n j = 1\n while i * j < prod:\n i, j = j, i+j\n return [ i, j, i*j == prod ]\n", "from bisect import bisect_left\ndef productFib(prod, fib=[0,1], prods=[0]):\n while prods[-1] < prod:\n fib.append(fib[-2]+fib[-1])\n prods.append(fib[-2]*fib[-1])\n i = bisect_left(prods, prod)\n return [fib[i], fib[i+1], prods[i]==prod]", "def productFib(prod):\n a = 0\n b = 1\n while a * b < prod:\n a, b = b, a+b\n return [a, b, a*b == prod]\n", "def productFibAux(current, nxt, prod):\n res = []\n while (current * nxt < prod):\n k = nxt\n nxt = nxt + current\n current = k\n if (prod == current * nxt):\n return [current, nxt, True]\n else:\n return [current, nxt, False]\n return res\n\ndef productFib(prod):\n return productFibAux(0, 1, prod)\n", "from itertools import dropwhile\n\n\ndef fib_gen():\n a, b = 0, 1\n while True:\n yield a, b\n a, b = b, a + b\n\n\ndef productFib(p):\n i = dropwhile(lambda x: x[0]*x[1]<p, fib_gen())\n a, b = next(i)\n \n return [a, b, a*b==p]\n", "def productFib(prod):\n if prod==0:\n return [0,1,True]\n a=1\n b=1\n for i in range(1,prod+1):\n c = a+b\n if a*b==prod:\n return [a,b,True]\n elif a*b>prod:\n return [a,b,False]\n a=b\n b=c", "def productFib(prod):\n nums = [0,1]\n i = 0\n status = True\n while status:\n if nums[i]*nums[i+1] <= prod:\n nums.append(nums[i]+nums[i+1])\n i+=1\n else:\n status = False\n i = 0\n while i < len(nums):\n if nums[i]*nums[i+1] == prod:\n return [nums[i],nums[i+1],True]\n elif prod in range(nums[i-1]*nums[i],nums[i]*nums[i+1]):\n return [nums[i],nums[i+1],False]\n i+=1"] | {"fn_name": "productFib", "inputs": [[4895], [5895], [74049690], [84049690], [193864606], [447577], [602070], [602070602070], [1120149658760], [256319508074468182850], [203023208030065646654504166904697594722575], [203023208030065646654504166904697594722576], [0], [1], [2], [3], [4], [5], [6], [7], [105]], "outputs": [[[55, 89, true]], [[89, 144, false]], [[6765, 10946, true]], [[10946, 17711, false]], [[10946, 17711, true]], [[610, 987, false]], [[610, 987, true]], [[832040, 1346269, false]], [[832040, 1346269, true]], [[12586269025, 20365011074, true]], [[354224848179261915075, 573147844013817084101, true]], [[573147844013817084101, 927372692193078999176, false]], [[0, 1, true]], [[1, 1, true]], [[1, 2, true]], [[2, 3, false]], [[2, 3, false]], [[2, 3, false]], [[2, 3, true]], [[3, 5, false]], [[13, 21, false]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,041 |
def productFib(prod):
|
fd52bd482c9ae3e239d90ee6503631dc | UNKNOWN | # Task
Imagine a standard chess board with only two white and two black knights placed in their standard starting positions: the white knights on b1 and g1; the black knights on b8 and g8.
There are two players: one plays for `white`, the other for `black`. During each move, the player picks one of his knights and moves it to an unoccupied square according to standard chess rules. Thus, a knight on d5 can move to any of the following squares: b6, c7, e7, f6, f4, e3, c3, and b4, as long as it is not occupied by either a friendly or an enemy knight.
The players take turns in making moves, starting with the white player. Given the configuration `positions` of the knights after an unspecified number of moves, determine whose turn it is.
# Example
For `positions = "b1;g1;b8;g8"`, the output should be `true`.
The configuration corresponds to the initial state of the game. Thus, it's white's turn.
# Input/Output
- `[input]` string `positions`
The positions of the four knights, starting with white knights, separated by a semicolon, in the chess notation.
- `[output]` a boolean value
`true` if white is to move, `false` otherwise. | ["def whose_turn(positions):\n return sum(ord(c) for c in positions.replace(\";\", \"\")) % 2 == 0", "def whose_turn(positions):\n return sum(ord(c) for c in positions) & 1 == 1", "tbl = str.maketrans('', '', 'aceg1357;')\n\ndef whose_turn(positions):\n return not len(positions.translate(tbl)) % 2\n", "def whose_turn(positions):\n wk1,wk2,bk1,bk2 = positions.split(\";\")\n cciw = cell_color_is_white\n return not cciw(wk1) ^ cciw(wk2) ^ cciw(bk1) ^ cciw(bk2)\n \ndef cell_color_is_white(cell):\n return (ord(cell[0]) + ord(cell[1])) % 2 == 1", "import re\ndef whose_turn(positions):\n return len(re.sub(r\"[1357;aceg]\", \"\",positions))%2==0", "def whose_turn(positions):\n a = [int(p, 19) & 1 for p in positions.split(';')]\n return len(set(a[:2])) == len(set(a[2:]))", "def whose_turn(positions):\n positions = positions.split(\";\")\n on_white_squares = [is_white_square(pos) for pos in positions]\n\n # Player's knights on black-black or white-white => odd number of moves\n white_pieces_match = on_white_squares[0] == on_white_squares[1]\n black_pieces_match = on_white_squares[2] == on_white_squares[3]\n\n # Equal number of moves => white to move\n return white_pieces_match == black_pieces_match\n \n\ndef is_white_square(pos):\n x, y = ord(pos[0]) - 97, int(pos[1])\n return x % 2 == y % 2", "def whose_turn(positions):\n return sum(ord(file) + ord(rank) for file, rank in positions.split(\";\")) % 2 == 0", "from typing import Dict, Generator, List, Tuple\n\nK_MOVES = [\n (a, b) \n for a in [-2, -1, 1, 2] \n for b in [-2, -1, 1, 2] \n if abs(a) != abs(b)\n]\n\ndef gen_k_moves(k: Tuple[int, int]) -> Generator[Tuple[int, int], None, None]:\n \"\"\"\n Generates all valid knight moved from the given point\n \"\"\"\n kc, kr = k\n for dc, dr in K_MOVES:\n c, r = kc + dc, kr + dr\n if 1 <= r <= 8 and 1 <= c <= 8:\n yield c, r\n\ndef solve(k: Tuple[int, int]) -> Dict[Tuple[int, int], int]:\n \"\"\"\n Given the starting point of a knight k, return a dict of postions to minimum moves to that position\n \"\"\"\n solutions = {}\n \n edges = [k]\n visited = set()\n steps = 0\n while edges:\n visited.update(edges)\n for edge in edges:\n solutions[edge] = steps\n steps += 1\n new_edges = []\n for edge in edges:\n for nk in gen_k_moves(edge):\n if nk in visited:\n continue\n new_edges.append(nk)\n visited.add(nk)\n edges = new_edges\n return solutions\n\nw1_solutions = solve((2, 1))\nw2_solutions = solve((7, 1))\nb1_solutions = solve((2, 8))\nb2_solutions = solve((7, 8))\n\ndef whose_turn(positions):\n positions = [\n (ord(s[0]) - ord('a') + 1, int(s[1])) \n for s in positions.split(';')\n ]\n w1 = w1_solutions[positions[0]], w2_solutions[positions[0]]\n w2 = w1_solutions[positions[1]], w2_solutions[positions[1]]\n b1 = b1_solutions[positions[2]], b2_solutions[positions[2]]\n b2 = b1_solutions[positions[3]], b2_solutions[positions[3]]\n \n whites = min(w1[0] + w2[1], w1[1] + w2[0])\n blacks = min(b1[0] + b2[1], b1[1] + b2[0])\n return (whites % 2) == (blacks % 2)", "def whose_turn(positions):\n return sum(ord(c) for c in positions.replace(\";\", \"\")) & 1 == 0"] | {"fn_name": "whose_turn", "inputs": [["b1;g1;b8;g8"], ["c3;g1;b8;g8"], ["g1;g2;g3;g4"], ["f8;h1;f3;c2"]], "outputs": [[true], [false], [true], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,406 |
def whose_turn(positions):
|
9fe5816264388d0dbe4b5cf4dd896dc0 | UNKNOWN | # Convert number to reversed array of digits
Given a random non-negative number, you have to return the digits of this number within an array in reverse order.
## Example:
```
348597 => [7,9,5,8,4,3]
``` | ["def digitize(n):\n return [int(x) for x in str(n)[::-1]]", "def digitize(n):\n return [int(x) for x in reversed(str(n))]", "def digitize(n):\n result = []\n while n >= 1:\n result.append(n%10)\n n //= 10\n return result", "def digitize(n):\n return [int(c) for c in str(n)[::-1]]", "def digitize(n):\n return [int(x) for x in (str(n))][::-1]\n", "def digitize(n):\n l = []\n m = []\n n = str(n)\n n = n[::-1]\n for i in range(len(n)):\n l.append(int(n[i]))\n return l", "def digitize(n):\n return [int(i) for i in str(n)][::-1]\n", "def digitize(n):\n return list(reversed([int(s) for s in str(n)]))", "def digitize(n):\n mylist = [int(i) for i in str(n)]\n mylist.reverse()\n return mylist\n", "def digitize(n):\n d, r = divmod(n, 10)\n if d:\n return [r] + digitize(d)\n else:\n return [r]", "def digitize(n):\n new_list = list(int(x) for x in str(n))\n return new_list[::-1]\n", "import re\n\ndef digitize(n):\n answer = []\n l= re.findall('\\d', str(n))\n for i in l:\n answer.append (int(i))\n answer.reverse()\n return answer", "def digitize(n):\n num_array = [] # make empty array\n for number in str(n): # make n into string to interate through \n num_array.insert(0, int(number)) # insert number into 1st position (reverses it)\n return num_array # return array", "def digitize(n):\n result = []\n while n > 0:\n result.append(n % 10)\n n = int(n/ 10)\n return result", "digitize = lambda n: [int(e) for e in str(n)[::-1]]", "digitize = lambda n: [int(x) for x in str(n)][::-1]\n", "def digitize(n):\n return list(int(x) for x in str(n)[::-1])", "def digitize(n):\n n=str(n)\n arr=[]\n for u in n:\n arr.append(int(u))\n arr=arr[::-1]\n return arr", "digitize = lambda n: [int(x) for x in reversed(str(n))]", "def digitize(n):\n return [int(digit) for digit in str(n)[::-1]]", "def digitize(n):\n return [int(d) for d in str(n)[::-1]]", "digitize = lambda n: list(reversed([int(i) for i in str(n)]))", "def digitize(n):\n return [int(i) for i in reversed(str(n))]", "def digitize(n):\n k = [int(num) for num in str(n)]\n k.reverse()\n return k", "def digitize(n):\n b = []\n for i in str(n):\n b.append(int(i))\n return b[::-1]", "def digitize(n):\n output = []\n for digit in str(n):\n output.append(int(digit))\n return(output[::-1])", "def digitize(n):\n n = str(n)\n n_list = list(map(int, str(n)))\n n_list.reverse()\n return n_list\n", "\ndef digitize(n):\n return list(reversed([int(x) for x in str(n)])) #reversed(sequence),here sequence\n #is a list comprehension returns an \n #object which is accessed by using a list\n #which is in this case.\n", "def digitize(n):\n n=str(n)\n l=[]\n c=list(n)\n c.reverse()\n for i in c:\n l.append(int(i))\n return l", "def digitize(n):\n a=[]\n while n!=0:\n a.append(n%10)\n n=n//10\n return a", "def digitize(n):\n arr = []\n result = n\n \n shouldGo = True\n \n while shouldGo:\n arr.append(result % 10)\n \n result = result // 10\n \n if result == 0:\n shouldGo = False\n \n return arr", "def digitize(n):\n arr = []\n convertToString = str(n)\n for num in convertToString:\n arr.append(int(num))\n arr.reverse()\n return arr", "def digitize(n):\n return [int(i) for i in str(n)[::-1]]", "def digitize(n):\n return list(map(int, str(n)))[::-1]", "def digitize(n):\n d = [int(i) for i in str(n)]\n p = d[::-1]\n return p\n", "def digitize(n):\n result = []\n for d in str(n)[::-1]:\n result.append(int(d))\n return result", "def digitize(n): \n lista = str(n)\n listan = list(lista)\n listan.reverse()\n for i in range(0, len(listan)):\n listan[i] = int(listan[i])\n return listan\n\n", "def digitize(n):\n n = str(n)\n digits = [int(s) for s in n]\n return digits[::-1]", "def digitize(n):\n return [n % 10] + digitize(n//10) if n > 10 else [n % 10]", "def digitize(n):\n ls = list(str(n))\n a = ls[::-1]\n return [int(x) for x in a]\n", "def digitize(n):\n r = []\n res = str(n)\n for i in res:\n r.append(int(i))\n \n return r[::-1]\n", "def digitize(n):\n a = [int(x) for x in str(n)]\n b = a[::-1]\n return b", "def digitize(n):\n num = []\n z = str(n)\n for i in z:\n num.append(int(i))\n return num[::-1]", "def digitize(n):\n x = str(n)\n y = \"\"\n lst = []\n for char in x:\n y = char + y\n for char in y:\n lst.append(int(char))\n return lst", "def digitize(n):\n \n res=[int(i) for i in str(n)][::-1]\n return res", "def digitize(n):\n result = array = [int(x) for x in str(n)]\n result = result[::-1]\n return result ", "digitize = lambda input: [int(x) for x in str(input)][::-1]", "def digitize(n):\n n = str(n)\n n = n[::-1]\n res = []\n for i in n:\n res.append(int(i))\n \n return res", "def digitize(n):\n x = [int(i) for i in str(n)]\n return [i for i in reversed(x)]", "def digitize(n):\n rez = []\n for i in list(str(n)[::-1]):\n rez.append(int(i))\n return rez", "def digitize(n):\n x = ','.join(str(n))[::-1]\n result=[]\n for i in x.split(','):\n result.append(int(i))\n return result", "def digitize(n):\n str_arr = list(str(n)[::-1])\n int_arr = []\n for i in str_arr:\n int_arr.append(int(i))\n return int_arr", "def digitize(num):\n if len(str(num)) == 1:\n return num\n output = []\n for n in reversed(str(num)):\n output.append(int(n))\n return output", "def digitize(n):\n results = []\n for num in str(n)[::-1]:\n results.append(int(num))\n return results", "def digitize(n):\n results = []\n for x in range(len(str(n))):\n results.append(int(str(n)[len(str(n)) - x - 1]))\n return results", "def digitize(n):\n string_of_int = (str(n))\n final_array = [int(x) for x in string_of_int]\n return(final_array[::-1])", "def digitize(n):\n list = []\n while n>0:\n list.append(int(n%10))\n n = int(n/10)\n return list", "def digitize(n):\n n = str(n)\n l = list()\n n = n[::-1]\n for s in n:\n l.append(int(s))\n return l\n", "def digitize(n):\n num = [int(m) for m in str(n)]\n return (num[::-1])", "def digitize(n):\n mylist = []\n\n a = list(str(n))\n for i in a:\n mylist.append(int(i))\n \n mylist.reverse()\n return mylist", "def digitize(n):\n d = [int (array) for array in list(str(n))]\n d.reverse()\n return d", "def digitize(n):\n a = list(reversed(str(n)))\n k = []\n for i in a:\n k.append(int(i)) \n return k \n \n \n \n \n \n \n \n \n", "def digitize(n):\n string_num = str(n)\n digits = []\n for digit in string_num:\n digits.append(int(digit))\n digits.reverse()\n return digits", "def digitize(n):\n n = str(n)\n n = list(n)\n n = list(map(conv, n))\n n.reverse()\n return n\n \n\ndef conv(x):\n return int(x)", "def digitize(n):\n copy = []\n array = list(str(n))\n for num in array:\n copy.append(int(num))\n copy.reverse()\n return copy", "def digitize(n):\n lista = list(str(n))\n lista.reverse()\n int_list = []\n for i in lista:\n int_list.append(int(i))\n \n return int_list", "def digitize(n):\n list_n = list(str(n))\n list_n.reverse()\n return list(map(int, list_n))", "def digitize(n):\n string_num = str(n)\n res = []\n comp = [res.append(int(number)) for number in string_num]\n res.reverse()\n return res\n", "def digitize(n):\n empty = []\n n = str(n)\n n = n[::-1]\n for num in n:\n empty.append(int(num))\n return empty", "def digitize(n):\n a = []\n b = str(n)\n for i in b:\n a.append(int(i))\n return a[::-1]", "def digitize(n):\n s = list(reversed(str(n)))\n a = [];\n for x in s:\n m = int(x)\n a.append(m)\n return a", "def digitize(n):\n result = []\n if(n == 0):\n return [0]\n while(n):\n result.append(n % 10)\n n //= 10\n return result", "def digitize(n):\n n = str(n)\n n = n[::-1]\n n = ' '.join(n)\n return [int(i) for i in n.split()]", "def digitize(n):\n x=list(str(n))\n y=[]\n for i in range(len(x)-1,-1,-1):\n y.append(int(x[i]))\n return y", "import numpy as np\n\ndef digitize(n):\n return [int(i) for i in str(n)[::-1]]\n", "def digitize(n):\n x = list(map(lambda x: int(x), list(str(n))))\n x.reverse()\n return x", "def digitize(n):\n ls = []\n for i in range(len(str(n))):\n ls.append(n % 10)\n n //= 10\n return ls", "def digitize(n):\n s=str(n)\n a=[]\n for i in range(1,len(s)+1):\n a.append(s[-i])\n for j in range(len(a)):\n a[j]=int(a[j])\n return a", "def digitize(n):\n listn = []\n for x in str(n):\n listn.append(int(x))\n revl = listn[::-1]\n return revl", "def digitize(n):\n arr = list(str(n))\n rev = []\n for i in arr:\n rev.insert(0, int(i))\n return rev", "def digitize(n):\n result = list(int(x) for x in str(n))\n return result[::-1]", "def digitize(n):\n \n lst = [int(i) for i in str(n)]\n #lst = lst.reverse()\n return lst[::-1]", "def digitize(n):\n res = [int(i) for i in list(str(n))]\n return res[::-1]", "def digitize(n):\n num_list = list(str(n))\n reversed_num_list = num_list.reverse()\n reversed_num_list = list(map(int,num_list))\n return reversed_num_list", "def digitize(n):\n lst = []\n n = str(n)\n \n for char in n:\n lst.append(int(char))\n \n lst = lst[::-1]\n \n return lst", "def digitize(n):\n \n array = []\n \n n = str(n)\n x = len(n) - 1\n \n while(x >= 0):\n array.append(int(n[x]))\n x -= 1\n \n return array", "def digitize(n):\n n=str(n)\n l=[]\n for elem in n:\n l.append(int(elem)) \n l.reverse()\n return l", "def digitize(n):\n s=[int(i) for i in str(n)]\n return s[::-1]", "digitize = lambda n : [int(digit) for digit in str(n)][::-1]", "def digitize(n):\n n = list(str(n))\n l = []\n for i in n:\n a = int(i)\n l.append(a)\n return l[::-1]", "def digitize(n):\n \n new=[]\n for I in str(n):\n new.append(int (I))\n \n return new[::-1]\n", "def digitize(n):\n len_n = str(n)\n list = []\n for i in range(0,len(len_n)):\n \n a = n % 10\n n = n//10\n \n list.append(a)\n \n return list"] | {"fn_name": "digitize", "inputs": [[35231], [23582357], [984764738], [45762893920], [548702838394]], "outputs": [[[1, 3, 2, 5, 3]], [[7, 5, 3, 2, 8, 5, 3, 2]], [[8, 3, 7, 4, 6, 7, 4, 8, 9]], [[0, 2, 9, 3, 9, 8, 2, 6, 7, 5, 4]], [[4, 9, 3, 8, 3, 8, 2, 0, 7, 8, 4, 5]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 11,097 |
def digitize(n):
|
efa00cc2d853f6409a1678ec70a106ff | UNKNOWN | Consider the word `"abode"`. We can see that the letter `a` is in position `1` and `b` is in position `2`. In the alphabet, `a` and `b` are also in positions `1` and `2`. Notice also that `d` and `e` in `abode` occupy the positions they would occupy in the alphabet, which are positions `4` and `5`.
Given an array of words, return an array of the number of letters that occupy their positions in the alphabet for each word. For example,
```
solve(["abode","ABc","xyzD"]) = [4, 3, 1]
```
See test cases for more examples.
Input will consist of alphabet characters, both uppercase and lowercase. No spaces.
Good luck!
If you like this Kata, please try:
[Last digit symmetry](https://www.codewars.com/kata/59a9466f589d2af4c50001d8)
[Alternate capitalization](https://www.codewars.com/kata/59cfc000aeb2844d16000075)
~~~if:fortran
## Fortran-Specific Notes
Due to how strings and arrays work in Fortran, some of the strings in the input array will inevitably contain trailing whitespace. **For this reason, please [trim](https://gcc.gnu.org/onlinedocs/gcc-4.3.4/gfortran/TRIM.html) your input strings before processing them.**
~~~ | ["def solve(arr):\n return [ sum(c == chr(97+i) for i,c in enumerate(w[:26].lower())) for w in arr ]", "from string import ascii_lowercase as alphabet\n\ndef solve(arr):\n return [sum(c == alphabet[i] for i,c in enumerate(word[:26].lower())) for word in arr]", "from operator import eq\nfrom string import ascii_lowercase\n\ndef solve(strings):\n return [sum(map(eq, s.lower(), ascii_lowercase)) for s in strings]", "def solve(arr):\n return [sum(i == ord(c) - ord('A') for i, c in enumerate(s.upper())) for s in arr]", "def solve(arr):\n lst = []\n for string in arr:\n counter = 0\n for index, letter in enumerate(string):\n if index + 1 == ord(letter.upper()) - 16 * 4:\n counter += 1\n lst.append(counter)\n return lst", "def solve(arr): \n return [['abcdefghijklmnopqrstuvwxyz'.index(y) == x for x,y in enumerate(e.lower())].count(True) for e in arr]\n", "def solve(arr):\n a=[x.lower() for x in arr]\n b=[]\n for x in a:\n aa=0\n for i in range(len(x)):\n if ord(x[i])-96==i+1:\n aa=aa+1\n b.append(aa)\n return(b) ", "def solve(arr):\n return [sum(ord(v) - 96 == i for i,v in enumerate(word.lower(), 1)) for word in arr]", "def solve(words):\n return [sum(a==b for a, b in zip(w.lower(), 'abcdefghijklmnopqrstuvwxyz')) for w in words]", "def solve(arr):\n return list(map(helper, arr))\n \ndef helper(str):\n count = 0\n i = 0\n for char in str:\n if ord(char) & 31 == i + 1:\n count += 1\n i += 1\n return count", "def solve(arr):\n return [sum(ord(c.lower()) == i for i, c in enumerate(w, 97)) for w in arr]", "def solve(arr):\n res=[]\n for w in arr:\n res.append(sum(ord(l.lower())-97==i for i,l in enumerate(w)))\n return res\n", "def solve(arr):\n return [sum(\n ord(ltr) == i + 65 for i, ltr in enumerate(str.upper())\n ) for str in arr]", "def solve(arr):\n def cou(arg):\n al = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12,\n 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22,\n 'w': 23, 'x': 24, 'y': 25, 'z': 26}\n num = 0\n arg = (\"\".join(arg)).lower()\n for x in range(len(arg)):\n if x + 1 == al[arg[x]]:\n num += 1\n return num\n\n res=[]\n for x in range(len(arr)):\n res.append(cou(arr[x]))\n return res", "import string\n\ndef solve(arr):\n corrects = []\n for word in arr:\n correct_place = 0\n for index, char in enumerate(word):\n alph_index = string.ascii_lowercase.find(char.lower())\n if index == alph_index:\n correct_place = correct_place + 1\n corrects.append(correct_place)\n return corrects\n", "def solve(arr):\n abc ='abcdefghijklmnopqrstuvwxyz'\n res = []\n for word in arr:\n word = word.lower()\n count = 0\n for i, letter in enumerate(word):\n if i == abc.index(letter):\n count +=1\n res.append(count)\n return res\n", "def solve(arr):\n return [sum(ord(i.lower()) - 96 == indx for indx, i in enumerate(word, 1)) for word in arr]", "solve=lambda arr: [sum(ord(l.lower())-97==i for i,l in enumerate(s)) for s in arr]", "def letter_to_int(letter):\n alphabet = list('abcdefghijklmnopqrstuvwxyz')\n return alphabet.index(letter) + 1\ndef solve(arr):\n result = []\n arr = [i.lower() for i in arr]\n for word in arr:\n counter = 0\n for i in range (0,len(word)):\n if letter_to_int(word[i]) == i+1:\n counter = counter+1\n result.append(counter) \n return(result) ", "def cuantas(w):\n return sum([1 if i+1==ord(v)-ord('a')+1 else 0 for i,v in enumerate(w.lower())])\n\ndef solve(arr):\n return [cuantas(w) for w in arr]", "def solve(arr):\n abc = \"abcdefghijklmnopqrstuvwxyz\"\n result = []\n for word in arr:\n count = 0\n word = word.lower()\n for i,letter in enumerate(word):\n if i == abc.index(letter):\n count +=1\n result.append(count) \n return result \n \n \n", "def solve(arr):\n abc = \"abcdefghijklmnopqrstuvwxyz\"\n res = []\n for word in arr:\n count = 0\n word = word.lower()\n for i, letter in enumerate(word):\n if i == abc.index(letter):\n count += 1\n res.append(count)\n return res\n \n", "def solve(arr):\n return [(sum(1 for i in range(len(w)) if ord(w[i].lower()) - 96 == i+1)) for w in arr]", "def solve(arr):\n counts = []\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n for i in range(len(arr)):\n count = 0\n for j in range(min(len(arr[i]),len(alpha))):\n if arr[i][j].lower() == alpha[j]:\n count += 1\n counts.append(count)\n return counts", "def solve(arr):\n master_list = []\n for s in arr:\n count = 0\n for idx, char in enumerate(s):\n if idx == ord(char.lower()) - 97:\n count += 1\n master_list.append(count)\n return master_list", "def solve(arr):\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n return_list = []\n for word in arr:\n print(word)\n counter = 0\n for i in range(len(word) if len(word) <= len(alphabet) else 25):\n if word.lower()[i] == alphabet[i]:\n counter += 1\n return_list.append(counter)\n \n return return_list", "def solve(arr):\n abc = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n arr2 = []\n for el in arr:\n count = 0\n for i in range(len(el)):\n if el.lower()[i] == abc[i]:\n count = count + 1\n arr2.append(count)\n return arr2 ", "def solve(arr):\n print(arr)\n abc = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n res = []\n for el in arr:\n counter = 0\n for i in range(len(el)):\n if el.lower()[i] == abc[i]:\n counter += 1\n res.append(counter)\n return res", "def solve(arr):\n abc = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n res = []\n for el in arr:\n counter = 0\n for i in range(len(el)):\n if el.lower()[i] == abc[i]:\n counter += 1\n res.append(counter)\n return res", "def solve(arr):\n s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n res = []\n for el in arr:\n counter = 0\n for i in range(len(el)):\n if el.lower()[i] == s[i]:\n counter += 1\n res.append(counter)\n return res", "def solve(arr):\n return [sum(1 for i,c in enumerate(w) if i == 'abcdefghijklmnopqrstuvwxyz'.index(c.lower()) ) for w in arr]", "from string import ascii_lowercase\nfrom collections import Counter\n\n#try using zip\ndef solve(arr):\n \n counts = []\n \n for word in arr:\n \n count = Counter()\n \n zipped = list(zip(list(word.lower()), list(ascii_lowercase)))\n matches = [z for z in zipped if z[0] == z[1]]\n counts.append(len(matches))\n \n return counts\n \n \n \n", "from string import ascii_lowercase \n\ndef solve(arr):\n \n counts = []\n \n for word in arr:\n \n count = 0\n \n for idx, val in enumerate(word.lower()):\n \n if idx == ascii_lowercase.index(val): count += 1\n \n counts.append(count)\n \n return counts", "def solve(arr):\n alpha = 'abcdefghijklmnopqrstuvwxyz'\n return [sum([1 if i == alpha.find(c.lower()) else 0 for i,c in enumerate(x)]) for x in arr]", "from string import ascii_lowercase\n\ndef solve(arr):\n print(arr)\n return [sum(1 for idx, _ in enumerate(word) if idx < 26 and word[idx].lower() == ascii_lowercase[idx]) for word in arr]", "def solve(s):\n return [sum(i==ord(a.lower())-ord('a') for i, a in enumerate(s[j])) for j, _ in enumerate(s)]", "from string import ascii_lowercase as letters\n\ndef solve(arr):\n return [sum(1 for i, c in enumerate(s) if i == letters.index(c.lower())) for s in arr]", "import string\ndef solve(arr): \n return list([sum([1 for i in range(len(x)) if i<26 and x[i].lower() == string.ascii_lowercase[i]]) for x in arr])\n", "import string\ndef solve(arr):\n k = []\n for word in arr:\n count = 0\n for i in range(len(word)):\n if i < 26 and word[i].lower() == string.ascii_lowercase[i]:\n count += 1\n k.append(count) \n return k\n", "def solve(arr):\n l = []\n n = 0\n for x in arr:\n for y in range(1, len(x) + 1):\n if y == ord(x[y - 1].lower()) - 96:\n n += 1\n l.append(n)\n n = 0\n return l", "import string\na = string.ascii_lowercase\ndef solve(arr):\n p = 0\n m = []\n for s in arr:\n if len(s) > len(a):\n s = s[:len(a)]\n for num, i in enumerate(s):\n if i.lower() == a[num]:\n p+=1\n m.append(p)\n p = 0\n return m", "def solve(arr):\n letters = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')\n count = 0\n cw = []\n \n for j in range(len(arr)):\n count = 0\n for i in range(len(arr[j])):\n if i > 24:\n break\n elif (arr[j][i]).lower() == letters[i]:\n count +=1\n cw = cw + [count]\n return cw", "def solve(arr):\n \n def f(x):\n return sum([1 for i in range(len(x)) if ord(x[i].lower()) - 97 == i])\n \n return [f(i) for i in arr]", "def solve(arr):\n res = []\n count = 0\n for word in arr:\n for i in range(len(word)):\n #print(ord(word[i]))\n if i == ord(word.lower()[i]) - 97:\n count += 1\n res.append(count)\n count = 0\n return res", "def solve(arr):\n result = []\n counter_correct = 0\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n for a in arr:\n a = a.lower()\n counter_correct = 0\n for i in range(len(a)):\n if i == alphabet.index(a[i]):\n counter_correct += 1\n result.append(counter_correct)\n return result", "def solve(arr):\n arrr = []\n for x in arr:\n res = 0\n start = ord('a')\n for y in x:\n if start == ord(y.lower()):\n res += 1\n start += 1\n arrr.append(res)\n return arrr", "def solve(arr):\n ans = []\n for i in arr:\n ans.append(0)\n for j in range(len(i)):\n if ord(i[j].lower())-97 == j:\n ans[-1] +=1\n return ans", "def solve(x):\n return [len([e for i,e in enumerate(i) if ord(e.lower())-97==i])for i in x]", "def solve(arr):\n alpha = 'abcdefghijklmnopqrstuvwxyz'\n res = []\n for word in arr:\n count = 0\n for i in range(len(word)):\n try:\n if word[i].lower()==alpha[i]:\n count += 1\n except IndexError:\n count = count\n res.append(count)\n return res", "def solve(arr):\n return [sum((ord(c) - 97 == i) for i, c in enumerate(s.lower())) for s in arr]", "import string\n\ndef solve(arr):\n alphabet = string.ascii_lowercase\n result = []\n for i in range(len(arr)):\n part_result = 0\n test_word = arr[i].lower()\n for j in range(len(test_word)):\n if j >= len(alphabet):\n continue\n if test_word[j] == alphabet[j]:\n part_result += 1\n result.append(part_result)\n return result", "def solve(arr):\n alpha = 'abcdefghijklmnopqrstuvwxyz'\n return [sum(1 if i < 26 and alpha[i] == c else 0 for i, c in enumerate(w.lower())) for w in arr]", "def solve(arr):\n l=[]\n for i in arr:\n c=0\n for j in range(0,len(i)):\n if j+1==ord(i[j].lower())-96:\n c+=1\n l.append(c)\n return l", "from string import ascii_lowercase as ref\n\ndef solve(arr):\n return [sum([x.lower()[i]==ref[i] for i in range(min(26,len(x)))]) for x in arr]", "def solve(arr):\n result = []\n return [sum([0 if y - ord(x[y].lower()) + 97 else 1 for y in range(len(x))]) for x in arr] ", "def solve(a):\n t = [chr(x+96) for x in range(1,27)]\n return [sum([x.lower()[y]==t[y] for y in range(min(len(x),26))]) for x in a]\n", "def solve(arr):\n alph = range(ord('a'), ord('z') + 1)\n \n res = []\n for s in arr:\n sl = s.lower()\n val = 0\n for i in range(len(sl)):\n if i >= len(alph):\n break\n \n if ord(sl[i]) == alph[i]:\n val += 1\n res.append(val)\n return res", "def solve(arr):\n r=[]\n for w in arr:\n r.append(sum(1 for i,c in enumerate(w.lower()) if ord(c)==ord('a')+i))\n return r", "def solve(l):\n l1 = []\n for i, _ in enumerate(l):\n l1.append(list([ord(x.lower()), i+97] for i, x in enumerate(l[i])\n if ord(x.lower()) == i+97))\n l2 = [len(x) for x in l1]\n return l2", "def solve(arr):\n arr = [s.lower() for s in arr]\n res = [[ord(c)-97 for c in s] for s in arr]\n res = [[subres[i] for i in range(len(subres)) if subres[i] == i] for subres in res]\n return [len(subres) for subres in res]\n", "def solve(arr):\n return list(map(lambda a: sum(i == ord(x) - 96 for i, x in enumerate(a.lower(), 1)), arr))", "def solve(arr):\n res = []\n for word in arr:\n count = 0\n for i, c in enumerate(word.lower()):\n if ord(c) - 97 == i: count += 1\n res.append(count)\n return res", "from string import ascii_lowercase\ndef solve(arr):\n return [[(string_letter == alphabet_letter) for string_letter, alphabet_letter\n in zip(i.lower(), ascii_lowercase)].count(True)\n for i in arr]", "from string import ascii_lowercase\ndef solve(arr):\n alphabet = list(ascii_lowercase)\n return_arr = []\n for i in arr:\n count = 0\n for j in range(0, len(i)):\n if j == alphabet.index(i[j].lower()):\n count += 1\n return_arr.append(count)\n return return_arr\n", "def solve(arr):\n result = []\n for s in arr:\n result.append(sum(1 for i, c in enumerate(s.lower()) if ord(c)-97 == i )) \n return result", "def solve(arr):\n return [sum(1 if ord(i.lower()[j])-96==j+1 else 0 for j in range(len(i))) for i in arr]", "def solve(arr):\n result = []\n count = 0\n for el in arr:\n for i in range(len(el)):\n if i + 1 == ord(el[i].lower()) - 96:\n count += 1\n result.append(count)\n count = 0\n return result", "def solve(arr):\n res=[]\n for i in arr:\n c=0\n for j in range(len(i)):\n if j==ord(i.upper()[j])-65:\n c+=1\n res+=[c]\n return res\n", "def solve(arr):\n return [sum(c.lower() == chr(97+i) for i,c in enumerate(w)) for w in arr]", "def solve(arr):\n return [sum((ord(c.lower())-96) == i+1 for i, c in enumerate(m)) for m in arr]\n", "def solve(arr):\n return [ sum( i == ord(l)-97 for i,l in enumerate(word.lower())) for word in arr]", "import string\ndef solve(arr):\n return [sum(ch == string.ascii_lowercase[i] for i, ch in enumerate(word[:26].lower())) for word in arr]", "import string\ndef solve(arr):\n return [sum(ch == string.ascii_lowercase[i] for i, ch in enumerate(word.lower()[:26])) for word in arr]", "def solve(arr):\n narr = []\n for x in arr:\n i=0\n for j in range(len(x)):\n if ord(x[j].lower())-97 == j:\n i+=1\n narr.append(i)\n return narr", "def solve(arr):\n return [len([ord(c.lower())-97 for idx, c in enumerate(a) if ord(c.lower())-97 == idx]) for a in arr]\n", "def solve(arr):\n output = [0] * len(arr)\n for i in range(0, len(arr)):\n for j in range(0, len(arr[i])):\n if ord(arr[i][j].lower())-97 == j:\n output[i] += 1 \n return output\n", "def solve(arr):\n\n alphabet = {chr(i+96):i for i in range(1,27)}\n arr_list = []\n\n for word in arr:\n ct = 0\n for pos,letter in enumerate(word.lower(),1):\n if alphabet[letter] == pos:\n ct +=1\n arr_list.append(ct)\n return arr_list", "from string import ascii_lowercase\n\ndef solve(arr):\n return [\n sum(ascii_lowercase.index(c) == i for i, c in enumerate(word.lower()))\n for word in arr\n ]", "def solve(arr):\n l = []\n for i in arr :\n a = 0\n i = i.lower()\n for ii in range(len(i)) :\n if ii == ord(i[ii])-97 : a+=1\n l.append(a)\n return l", "def solve(arr):\n return [sum(j.lower() == k for j,k in zip(i,\"abcdefghijklmnopqrstuvwxyz\")) for i in arr]", "def solve(arr):\n return [sum(1 for i,c in enumerate(strng.lower()) if i==ord(c)-97) for strng in arr]", "def solve(arr):\n result = []\n for word in arr:\n cnt = 0\n for idx in range(len(word)):\n if ord(word[idx].lower()) - ord('a') == idx:\n cnt += 1\n result.append(cnt)\n return result", "def solve(arr):\n return [sum(ord(c) - ord('a') == i for i,c in enumerate(s.lower())) for s in arr]", "import string\ndef solve(arr):\n return [(sum(1 for x in range(len(word)) if word.lower()[x] == string.ascii_letters[x])) for word in arr]", "def solve(arr):\n res = []\n for word in arr:\n sum = 0\n for index, letter in enumerate(word.lower()):\n if (index + 1) == (ord(letter)-96):\n sum += 1\n res.append(sum)\n\n return res\n", "def solve(arr):\n # return the number of letters that occupy their positions inthe alphabet\n # create alphabet list\n alpha = [chr(i) for i in range(ord('a'), ord('z')+1, 1)]\n lst = []\n for item in arr: # have to compare them in the same case\n lst.append(sum([x.lower() == y.lower() for (x, y) in zip(alpha, item)])) \n return lst", "def solve(arr):\n alfabetet = 'abcdefghijklmnopqrstuvwxyz'\n res = []\n r = 0\n# for d in range(0, len(arr)):\n# for t in range(0, len(arr[d])):\n# if arr[d][t].lower() == alfabetet[t]:\n# r += 1\n# res.append(r)\n# r = 0\n# return res\n\n# for char in arr:\n# for c in char.lower():\n# print(c)\n# if c == alfabetet[c]:\n# r += 1\n\n for char in arr:\n for a, b in zip(char.lower(), alfabetet):\n if a == b:\n r += 1\n res.append(r)\n r = 0\n return res\n\n", "def solve(arr):\n output = []\n for string in arr:\n count = 0\n for i in range(0,len(string)):\n if ord(string[i].lower()) == (97+i):\n count += 1\n output.append(count)\n return output", "from typing import List\nfrom string import ascii_lowercase\n\n\ndef solve(arr: List[str]) -> List[int]:\n return [sum(c == i for i, c in zip(ascii_lowercase, a.lower())) for a in arr]\n", "def solve(arr):\n cunt = []\n for fuck in arr:\n temp = 0\n for index, cum in enumerate(fuck):\n if ord(cum.lower()) - 96 == index + 1:\n temp += 1\n cunt.append(temp)\n return cunt", "from string import ascii_lowercase as lower_alpha\ndef solve(arr):\n return [sum(char == lower_alpha[i] for i,char in enumerate(word[:26].lower())) for word in arr]", "from string import ascii_lowercase as al\ndef solve(arr):\n arr = map(str.lower,arr)\n result, counter = [], 0\n for word in arr:\n for i, c in enumerate(word):\n if i == al.index(c):\n counter += 1\n result.append(counter)\n counter = 0\n return result", "import string\n\ndef solve(arr: list):\n arr = list(map(str.lower, arr))\n same = []\n for s in arr:\n same.append(0)\n for a, b in zip(string.ascii_lowercase, s):\n same[-1] += a == b\n return same", "def solve(arr):\n from string import ascii_lowercase as alphabet\n count, total = 0, []\n for word in arr:\n for c,letter in enumerate(word[0:26].lower()):\n if letter == alphabet[c]:\n count += 1\n total.append(count)\n count = 0\n return total", "from string import ascii_lowercase\n\ndef solve(arr):\n return [sum(c1 == c2 for c1, c2 in zip(s.lower(), ascii_lowercase)) for s in arr]", "def solve(arr):\n return [sum(1 for i,x in enumerate(y.lower()) if ord(x) - 96 == i +1) for y in arr]", "def solve(arr):\n answer = []\n for word in arr:\n answer.append(sum(1 for i, elem in enumerate(word.lower()) if ord(elem)-96 == i+1))\n return(answer)", "solve = lambda lst: [sum(i == ord(c.lower()) - 97 for i, c in enumerate(s)) for s in lst]", "import string\n\ndef solve(arr):\n alphabet_indexes = list(enumerate(string.ascii_lowercase))\n letters_count = []\n for word in arr:\n num_of_letters = 0\n letters_indexes = list(enumerate(word.lower()))\n if len(word) > len(alphabet_indexes):\n word = word[:26]\n for i in range(len(word)):\n if letters_indexes[i] == alphabet_indexes[i]:\n num_of_letters += 1\n letters_count.append(num_of_letters)\n return letters_count", "def solve(arr):\n res=[]\n for i in arr:\n tmp=0\n for e,j in enumerate(i.lower()):\n if chr(e+97)==j:\n tmp+=1\n res.append(tmp)\n return res\n"] | {"fn_name": "solve", "inputs": [[["abode", "ABc", "xyzD"]], [["abide", "ABc", "xyz"]], [["IAMDEFANDJKL", "thedefgh", "xyzDEFghijabc"]], [["encode", "abc", "xyzD", "ABmD"]]], "outputs": [[[4, 3, 1]], [[4, 3, 0]], [[6, 5, 7]], [[1, 3, 1, 3]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 22,060 |
def solve(arr):
|
5e52140a283a50908fa2d8da6033403d | UNKNOWN | Binary with 0 and 1 is good, but binary with only 0 is even better! Originally, this is a concept designed by Chuck Norris to send so called unary messages.
Can you write a program that can send and receive this messages?
Rules
The input message consists of ASCII characters between 32 and 127 (7-bit)
The encoded output message consists of blocks of 0
A block is separated from another block by a space
Two consecutive blocks are used to produce a series of same value bits (only 1 or 0 values):
First block is always 0 or 00. If it is 0, then the series contains 1, if not, it contains 0
The number of 0 in the second block is the number of bits in the series
Example
Let’s take a simple example with a message which consists of only one character (Letter 'C').'C' in binary is represented as 1000011, so with Chuck Norris’ technique this gives:
0 0 - the first series consists of only a single 1
00 0000 - the second series consists of four 0
0 00 - the third consists of two 1
So 'C' is coded as: 0 0 00 0000 0 00
Second example, we want to encode the message "CC" (i.e. the 14 bits 10000111000011) :
0 0 - one single 1
00 0000 - four 0
0 000 - three 1
00 0000 - four 0
0 00 - two 1
So "CC" is coded as: 0 0 00 0000 0 000 00 0000 0 00
Note of thanks
Thanks to the author of the original kata. I really liked this kata. I hope that other warriors will enjoy it too. | ["from re import compile\n\nREGEX1 = compile(r\"0+|1+\").findall\nREGEX2 = compile(r\"(0+) (0+)\").findall\nbinary = \"{:07b}\".format\n\ndef send(s):\n temp = ''.join(binary(ord(c)) for c in s)\n return ' '.join(\"0 \" + '0'*len(x) if x[0] == '1' else \"00 \" + x for x in REGEX1(temp))\n\ndef receive(s):\n temp = ''.join(y if x == '00' else '1'*len(y) for x,y in REGEX2(s))\n return ''.join(chr(int(temp[i:i+7], 2)) for i in range(0, len(temp), 7))", "from itertools import groupby\n\ndef send(s):\n return toUnary(''.join(f'{ ord(c) :0>7b}' for c in s))\n\ndef toUnary(c):\n return ' '.join( f'{\"0\"*(2-int(b))} {\"0\"*sum(1 for _ in g)}' for b,g in groupby(c))\n\ndef receive(s):\n it = iter(s.split())\n binS = ''.join( str( len(b)&1 ) * len(n) for b,n in zip(it,it))\n return ''.join( chr( int(binS[i:i+7],2) ) for i in range(0,len(binS),7))", "from itertools import groupby\n\n\ndef send(stg):\n bits = \"\".join(f\"{ord(c):07b}\" for c in stg)\n return \" \".join(f\"{'0' * (2 - int(b))} {'0' * len(tuple(l))}\" for b, l in groupby(bits))\n \n\ndef receive(stg):\n chunks = stg.split()\n bits = zip(chunks[::2], chunks[1::2])\n chars = \"\".join(f\"{2 - len(bit)}\" * len(length) for bit, length in bits)\n return \"\".join(chr(int(chars[i:i+7], 2)) for i in range(0, len(chars), 7))", "from itertools import groupby \n\ndef send(s):\n s = ''.join(format(o, '07b') for o in map(ord, s))\n return ' '.join(\n f\"{'0' if key == '1' else '00'} {'0' * sum(1 for _ in grp)}\"\n for key, grp in groupby(s)\n )\n\ndef receive(s):\n it = iter(s.split())\n xs = ''.join(('1' if c == '0' else '0') * len(n) for c, n in zip(it, it))\n return ''.join(chr(int(xs[i:i+7], 2)) for i in range(0, len(xs), 7))", "from itertools import groupby\n\ndoc = { '1':'0', '0':'00' }\n\ndef send(s):\n return ''.join([' '.join( f'{doc[x[0]]} {\"0\"*x[1]}' for x in code( bit(s) ) ) ])\n \ndef code(e):\n return [(k,len(list(v))) for k,v in groupby(e)]\n \ndef bit(e):\n return ''.join( str(bin( ord(x) )[2:]).zfill(7) for x in e )\n \ndef receive(s):\n return ''.join( chr(int(e, 2)) for e in groups( encode( s.split(' ') ) , 7 ))\n\ndef encode(e):\n return ''.join( { v:k for k,v in list(doc.items()) }[e[0]] * len(e[1]) for e in groups(e,2) )\n \ndef groups(e, d):\n return [ e[i:i+d] for i in range(0,len(e),d)]\n \n \n \n", "def get_stream(s):\n return \"\".join(bin(ord(c))[2:].zfill(7) for c in s)\n\ndef parse_stream(s):\n return \"\".join(chr(int(c, 2)) for c in [s[i:i+7] for i in range(0, len(s), 7)])\n\ndef get_next(s):\n return s[:max(s.find(\"0\"), s.find(\"1\"))] or s\n\ndef get_sequences(s):\n while s:\n n = get_next(s)\n s = s[len(n):]\n if n: yield n\n\ndef compose(n):\n return \"0\" * (2 - int(n[0])) + \" \" + \"0\" * len(n)\n\ndef decompose(s):\n s = s.split(\" \")\n output = \"\"\n while s:\n output += ({\"0\":\"1\",\"00\":\"0\"})[s.pop(0)] * len(s.pop(0))\n return output\n\ndef send(s):\n return \" \".join(compose(seq) for seq in get_sequences(get_stream(s)))\n\ndef receive(s):\n return parse_stream(decompose(s))\n", "import re\n\ndef send(text):\n tmp = (ord(char) for char in text)\n tmp = (f\"{x:07b}\" for x in tmp)\n tmp = \"\".join(tmp)\n tmp = re.findall(\"0+|1+\", tmp)\n tmp = (f\"{'0' if group[0] == '1' else '00'} {'0' * len(group)}\" for group in tmp)\n return \" \".join(tmp)\n\ndef receive(unary):\n tmp = re.findall(\"(0+) (0+)\", unary)\n tmp = ((\"0\" if digit == \"00\" else \"1\") * len(count) for digit, count in tmp)\n tmp = \"\".join(tmp)\n tmp = re.findall(\".{7}\", tmp)\n tmp = (chr(int(x, 2)) for x in tmp)\n return \"\".join(tmp)", "import re\n\ndef send(s):\n return \" \".join(f\"{'0' if x[0] == '1' else '00'} {'0' * len(x)}\" for x in re.findall(\"0+|1+\", \"\".join(f\"{x:07b}\" for x in map(ord, s))))\n\ndef receive(s):\n return re.sub(\".{7}\", lambda x: chr(int(x.group(), 2)), \"\".join((\"1\" if x == \"0\" else \"0\") * len(y) for x, y in re.findall(\"(0+) (0+)\", s)))", "import re\ndef send(s):\n return' '.join(('0'*(2-int(c[0]))+' '+'0'*len(c))for c in re.findall('1+|0+',''.join(f'{ord(c):07b}'for c in s)))\n\ndef receive(s):\n return''.join(chr(int(''.join(a),2))for a in zip(*[iter(''.join(str(2-len(a))*len(b)for a,b in zip(*[iter(s.split())]*2)))]*7))\n", "def send(s):\n r = ''\n state = 0\n for a in (ord(x) for x in s):\n i = 64\n while i > 0:\n b = a & i\n if (state == 0 or state == 2) and b == 0:\n r = r + ' 00 0'\n state = 1\n elif (state == 0 or state == 1) and b != 0:\n r = r + ' 0 0'\n state = 2\n elif (state == 2 and b != 0) or (state == 1 and b == 0):\n r = r + '0'\n i = i >> 1\n return r[1:]\n\n\ndef receive(s):\n r = 0\n i = 0\n state = -1\n u = ''\n for c in s:\n if state == -1:\n if c == '0':\n state = 0\n elif state == 0:\n if c == '0':\n state = 1\n else:\n state = 2\n elif state == 1:\n if c == ' ':\n state = 3\n elif state == 2:\n if c == ' ':\n state = -1\n elif c == '0':\n r = r << 1\n r = r + 1\n i = i + 1\n elif state == 3:\n if c == ' ':\n state = -1\n elif c == '0':\n r = r << 1\n i = i + 1\n if i == 7:\n u = u + chr(r)\n i = 0\n r = 0\n return u"] | {"fn_name": "send", "inputs": [["C"], ["CC"], ["%"], ["Chuck Norris' keyboard has 2 keys: 0 and white space."], ["abcdefghijklmnopqrstuvwxyz"], ["!\"#$&"], ["Chuck Norris can divide by zero."], ["Chuck Norris counted to infinity - three times."]], "outputs": [["0 0 00 0000 0 00"], ["0 0 00 0000 0 000 00 0000 0 00"], ["00 0 0 0 00 00 0 0 00 0 0 0"], ["0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00 000 0 0000 00 0 0 0 00 0 0 00 00 0 0 0 00 00000 0 0 00 00 0 000 00 0 0 00 00 0 0 0000000 00 00 0 0 00 0 0 000 00 00 0 0 00 0 0 00 00 0 0 0 00 00 0 0000 00 00 0 00 00 0 0 0 00 00 0 000 00 0 0 0 00 00000 0 00 00 0 0 0 00 0 0 0000 00 00 0 0 00 0 0 00000 00 00 0 000 00 000 0 0 00 0 0 00 00 0 0 000000 00 0000 0 0000 00 00 0 0 00 0 0 00 00 00 0 0 00 000 0 0 00 00000 0 00 00 0 0 0 00 000 0 00 00 0000 0 0000 00 00 0 00 00 0 0 0 00 000000 0 00 00 00 0 0 00 00 0 0 00 00000 0 00 00 0 0 0 00 0 0 0000 00 00 0 0 00 0 0 00000 00 00 0 0000 00 00 0 00 00 0 0 000 00 0 0 0 00 00 0 0 00 000000 0 00 00 00000 0 0 00 00000 0 00 00 0000 0 000 00 0 0 000 00 0 0 00 00 00 0 0 00 000 0 0 00 00000 0 000 00 0 0 00000 00 0 0 0 00 000 0 00 00 0 0 0 00 00 0 0000 00 0 0 0 00 00 0 00 00 00 0 0 00 0 0 0 00 0 0 0 00 00000 0 000 00 00 0 00000 00 0000 0 00 00 0000 0 000 00 000 0 0000 00 00 0 0 00 0 0 0 00 0 0 0 00 0 0 000 00 0"], ["0 00 00 0000 0 000 00 000 0 0 00 0 0 00 00 000 0 0000 00 00 0 0 00 00 0 00 00 00 0 0 00 0 0 000 00 00 0 00 00 0 0 00 00 00 0 00000 00 0 0 0 00 000 0 00 00 0 0 0 00 00 0 000 00 0 0 0 00 0 0 0 00 0 0 00 00 0 0 0 00 0 0 0000 00 0 0 00 00 00 0 00 00 0 0 00 00 0 0 000 00 0 0 000 00 0 0 00 00 0 0 0000000 00 0000 0 000 00 000 0 0000 00 00 0 0 00 0 0 000 00 00 0 00000 00 0 0 0 00 00 0 000 00 0 0 0 00 0 0 0000 00 0 0 00 00 0 0 000 00 0 0 0000000 00 000 0 0000 00 00 0 00000 00 0 0 0 00 0"], ["00 0 0 0 00 0000 0 0 00 0 0 0 00 000 0 0 00 00 0 0 00 000 0 00 00 0 0 0 00 00 0 0 00 000 0 0 00 00 0 00 00 0"], ["0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00 000 0 0000 00 0 0 0 00 0 0 00 00 0 0 0 00 00000 0 0 00 00 0 000 00 0 0 00 00 0 0 0000000 00 00 0 0 00 0 0 000 00 00 0 0 00 0 0 00 00 0 0 0 00 00 0 0000 00 00 0 00 00 0 0 0 00 00000 0 00 00 000 0 0000 00 0000 0 000 00 0 0 000 00 00 0 0 00 00000 0 00 00 00 0 0 00 00 0 00 00 0 0 0 00 00 0 0000 00 0 0 00 00 0 0 00 00 0 0 0 00 00 0 000 00 00 0 0 00 00 0 00 00 00 0 0 00 0 0 0 00 0 0 0 00 00000 0 00 00 000 0 0 00 0 0 0000 00 00 0 0 00 0 0 0 00 00000 0 0000 00 0 0 0 00 0 0 00 00 00 0 0 00 0 0 0000 00 00 0 0 00 0 0 00 00 0 0 0000 00 0 0 0 00 0 0 000 00 0"], ["0 0 00 0000 0 0000 00 0 0 0 00 000 0 000 00 0 0 0 00 0 0 000 00 000 0 0000 00 0 0 0 00 0 0 00 00 0 0 0 00 00000 0 0 00 00 0 000 00 0 0 00 00 0 0 0000000 00 00 0 0 00 0 0 000 00 00 0 0 00 0 0 00 00 0 0 0 00 00 0 0000 00 00 0 00 00 0 0 0 00 00000 0 00 00 000 0 0000 00 0 0 0000000 00 0 0 0 00 0 0 000 00 0 0 000 00 0 0 000 00 0 0 0 00 00 0 00 00 00 0 0 00 0 0 000 00 00 0 0 00 000 0 0 00 00000 0 000 00 0 0 0 00 00 0 00 00 0 0 0000 00 0 0 0 00 00000 0 00 00 0 0 0 00 00 0 000 00 0 0 000 00 0 0 00 00 00 0 00 00 0 0 00 00 0 0 0 00 00 0 000 00 0 0 000 00 0 0 00 00 0 0 0 00 00 0 0000 00 0 0 0 00 00 0 0000 00 00 0 0 00 0 0 0 00 000000 0 0 00 0 0 00 00 0 0 0 00 0 0 0 00 00000 0 000 00 0 0 0 00 00 0 00 00 0 0 0 00 000 0 000 00 00 0 0 00 0 0 00 00 00 0 0 00 0 0 000 00 00 0 0 00 0 0 0 00 0 0 0 00 00000 0 000 00 0 0 0 00 00 0 00 00 0 0 0 00 00 0 000 00 0 0 00 00 0 0 000 00 00 0 0 00 0 0 0000 00 00 0 00 00 0 0 0 00 0 0 000 00 0"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 5,789 |
def send(s):
|
f00e49ea22767c1d6ee3bc71137bc678 | UNKNOWN | ##Task:
You have to write a function **pattern** which creates the following pattern upto n number of rows.
* If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string.
* If any odd number is passed as argument then the pattern should last upto the largest even number which is smaller than the passed odd number.
* If the argument is 1 then also it should return "".
##Examples:
pattern(8):
22
4444
666666
88888888
pattern(5):
22
4444
```Note: There are no spaces in the pattern```
```Hint: Use \n in string to jump to next line``` | ["def pattern(n):\n return '\\n'.join([str(i) * i for i in range(2, n + 1, 2)])\n", "def pattern(n):\n return \"\\n\".join(str(i) * i for i in range(2, n + 1, 2))", "def pattern(n):\n # Happy Coding ^_^\n result = []\n \n #If it's one return nothing\n if n == 1:\n return ''\n\n #just go through n printing the not odd numbers \n for i in range(n+1):\n if i%2 == 0:\n result.append(str(i)*i + '\\n')\n \n return ''.join(result).strip()\n", "def pattern(n):\n if n % 2 != 0:\n n = n - 1\n return \"\" if n <= 1 else \"\\n\".join([(str(i) * i) for i in range(1, n + 1) if i % 2 == 0])", "def pattern(n):\n return '\\n'.join(str(i) * i for i in range(2, n//2*2 + 1, 2))", "pattern = lambda n: \"\\n\".join([str(x) * x for x in range(2, n + 1, 2)])", "def pattern(n):\n # Happy Coding ^_^\n return '\\n'.join([str(a) * a for a in range(2, n + 1, 2)])", "def pattern(n):\n return '\\n'.join(str(x) * x for x in range(2, n + 1, 2))", "pattern=lambda n:'\\n'.join(i*str(i)for i in range(2,n+1,2))"] | {"fn_name": "pattern", "inputs": [[2], [1], [5], [6], [0], [-25]], "outputs": [["22"], [""], ["22\n4444"], ["22\n4444\n666666"], [""], [""]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,088 |
def pattern(n):
|
a04dae898b26b4584f31eab9aefd8707 | UNKNOWN | Given an array of numbers (in string format), you must return a string. The numbers correspond to the letters of the alphabet in reverse order: a=26, z=1 etc. You should also account for `'!'`, `'?'` and `' '` that are represented by '27', '28' and '29' respectively.
All inputs will be valid. | ["def switcher(arr):\n d = {str(i): chr(123-i) for i in range(1,27)}\n d.update({'27':'!'})\n d.update({'28':'?'})\n d.update({'29':' '})\n d.update({'0':''})\n return ''.join([d[str(i)] for i in arr])", "import string\n\nletters = string.ascii_lowercase[::-1] + '!? '\ndef switcher(arr):\n return ''.join([letters[ch-1] for ch in map(int, arr) if ch])", "chars = \"_zyxwvutsrqponmlkjihgfedcba!? \"\n\ndef switcher(arr):\n return \"\".join(chars[int(i)] for i in arr if i != \"0\")", "from string import ascii_lowercase as abc\n\nch = abc[::-1] + '!? '\n\ndef switcher(arr):\n return \"\".join(ch[int(x)-1] if x != '0' else '' for x in arr)", "def switcher(arr):\n trans = { '26': 'a', '25': 'b', '24': 'c', '23': 'd', '22': 'e', '21': 'f',\n '20': 'g', '19': 'h', '18': 'i', '17': 'j', '16': 'k', '15': 'l',\n '14': 'm', '13': 'n', '12': 'o', '11': 'p', '10': 'q', '9': 'r',\n '8' : 's', '7': 't', '6': 'u', '5': 'v', '4': 'w', '3': 'x',\n '2' : 'y', '1': 'z', '27': '!', '28': '?', '29': ' '}\n return ''.join( trans[a] for a in arr if a in trans )", "STR = \"+zyxwvutsrqponmlkjihgfedcba!? \"\ndef switcher(arr):\n return \"\".join(STR[int(x)] for x in arr).replace(\"+\", \"\")", "def switcher(arr):\n return ''.join({'27':'!','28':'?','29':' '}.get(e, chr(abs(int(e)-26)+97)) for e in arr)", "alphabet = [\"z\", \"y\", \"x\", \"w\", \"v\", \"u\", \"t\", \"s\", \"r\", \"q\", \"p\", \"o\", \"n\", \"m\", \"l\", \"k\", \"j\", \"i\", \"h\", \"g\", \"f\", \"e\", \"d\", \"c\", \"b\", \"a\", \"!\", \"?\", \" \"]\n\ndef switcher(arr):\n return \"\".join([alphabet[int(i) - 1] for i in arr])", "def switcher(arr):\n return ''.join(chr(123-int(i)) for i in arr).translate(str.maketrans('`_^', '!? '))\n", "def switcher(arr):\n return ''.join({'27':'!','28':'?','29':' '}.get(i, chr(123 - int(i))) for i in arr)"] | {"fn_name": "switcher", "inputs": [[["24", "12", "23", "22", "4", "26", "9", "8"]], [["25", "7", "8", "4", "14", "23", "8", "25", "23", "29", "16", "16", "4"]], [["4", "24"]], [["12"]], [["12", "28", "25", "21", "25", "7", "11", "22", "15"]]], "outputs": [["codewars"], ["btswmdsbd kkw"], ["wc"], ["o"], ["o?bfbtpel"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,916 |
def switcher(arr):
|
dc9bcab46e9d9db9f02cf3c1865282a6 | UNKNOWN | Triangular number is the amount of points that can fill equilateral triangle.
Example: the number 6 is a triangular number because all sides of a triangle has the same amount of points.
```
Hint!
T(n) = n * (n + 1) / 2,
n - is the size of one side.
T(n) - is the triangular number.
```
Given a number 'T' from interval [1; 2147483646], find if it is triangular number or not. | ["def is_triangular(t):\n x = int((t*2)**0.5)\n return t == x*(x+1)/2", "def is_triangular(t):\n return (8 * t + 1)**.5 % 1 == 0\n", "def is_triangular(t):\n return (8 * t + 1) ** 0.5 % 1 == 0", "def is_triangular(n):\n a = int((n * 2)**0.5)\n return n * 2 == a * (a + 1)\n", "TRIANGULAR = { x*(x+1)/2 for x in range(10000) }\n\nis_triangular = TRIANGULAR.__contains__\n", "def is_triangular(t):\n return not (8 * t + 1)**.5 % 1", "def is_triangular(n):\n return ((-1 + (1 + 8 * n)**.5) / 2) % 1 == 0\n", "from math import sqrt\ndef is_triangular(t):\n n = (sqrt(8 * t + 1)-1)/2\n return False if n - int(n) > 0 else True", "def is_triangular(t):\n return (-1 + (1 + 8 * t) ** 0.5)/2. == int((-1 + (1 + 8 * t) ** 0.5)/2.)\n", "def is_triangular(t): return not (((1+8*t)**.5-1)/2%1)"] | {"fn_name": "is_triangular", "inputs": [[1], [3], [6], [10], [15], [21], [28], [2], [7], [14], [27]], "outputs": [[true], [true], [true], [true], [true], [true], [true], [false], [false], [false], [false]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 816 |
def is_triangular(t):
|
0976fba4a4aba48f15b92b631e4c776f | UNKNOWN | Your task is to make a program takes in a sentence (without puncuation), adds all words to a list and returns the sentence as a string which is the positions of the word in the list. Casing should not matter too.
Example
-----
`"Ask not what your COUNTRY can do for you ASK WHAT YOU CAN DO FOR YOUR country"`
becomes
`"01234567802856734"`
Another example
-----
`"the one bumble bee one bumble the bee"`
becomes
`"01231203"` | ["def compress(sentence):\n ref = []\n for i in sentence.lower().split():\n if i not in ref:\n ref.append(i)\n return ''.join([str(ref.index(n)) for n in sentence.lower().split()])", "def compress(sentence):\n memo = {}\n return ''.join(map(str, (memo.setdefault(s, len(memo)) for s in sentence.lower().split())))", "def compress(sentence):\n l = sentence.lower().split()\n d = {}; ans = []\n for x in l:\n if not x in d: d[x] = len(d)\n ans += [str(d[x])]\n return ''.join(ans)\n", "def compress(sentence):\n words = sentence.lower().split()\n uniq = sorted(set(words), key=words.index)\n return \"\".join(str(uniq.index(word)) for word in words)\n", "def compress(sentence):\n ref = []\n for x in sentence.lower().split():\n if x not in ref:\n ref.append(x)\n return ''.join([str(ref.index(n)) for n in sentence.lower().split()]) ", "def compress(sentence):\n s = sentence.lower().split()\n sl = []\n for x in s:\n if x not in sl:\n sl.append(x)\n return ''.join(str(sl.index(x)) for x in s)\n", "def compress(sentence):\n s = []\n for i in sentence.split():\n if i.lower() not in s:\n s.append(i.lower())\n return \"\".join([str(s.index(x.lower())) for x in sentence.split()])", "def compress(sentence):\n t = []\n for i in sentence.lower().split(\" \"):\n if i.lower() not in t:\n t.append(i)\n return \"\".join([str(t.index(i.lower())) for i in sentence.split(\" \")]) if sentence else \"\" ", "def compress(sentence):\n l = sentence.lower().split()\n u = [s for i,s in enumerate(l) if l.index(s)==i]\n return ''.join(str(u.index(s)) for s in l)", "def compress(s):\n d={}\n i=0\n r=''\n for w in s.lower().split():\n if w not in d:\n d[w]=i\n i+=1\n r+=str(d[w])\n return r"] | {"fn_name": "compress", "inputs": [["The bumble bee"], ["SILLY LITTLE BOYS silly little boys"], ["Ask not what your COUNTRY can do for you ASK WHAT YOU CAN DO FOR YOUR country"], ["The number 0 is such a strange number Strangely it has zero meaning"]], "outputs": [["012"], ["012012"], ["01234567802856734"], ["012345617891011"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,923 |
def compress(sentence):
|
f89382e099b6bbb33dbca302bb6ff28a | UNKNOWN | In this kata, you will do addition and subtraction on a given string. The return value must be also a string.
**Note:** the input will not be empty.
## Examples
```
"1plus2plus3plus4" --> "10"
"1plus2plus3minus4" --> "2"
``` | ["def calculate(s):\n return str(sum(int(n) for n in s.replace(\"minus\", \"plus-\").split(\"plus\")))\n \n # I heard here and there that using eval is a very bad practice\u2026\n #return str(eval(s.replace(\"plus\", \"+\").replace(\"minus\", \"-\")))\n", "calculate = lambda s: str(eval(s.replace(\"plus\",\"+\").replace(\"minus\",\"-\")))\n", "def calculate(s):\n return str(eval(s.replace(\"plus\", \"+\").replace(\"minus\", \"-\")))", "def calculate(s):\n ret = eval(s.replace(\"plus\",\"+\").replace(\"minus\",\"-\"))\n return str(ret)", "def calculate(s):\n s = s.replace('minus',' -')\n s = s.replace('plus',' ')\n s = s.split(' ')\n s = str( sum( [(int(x)) for x in s] ) )\n return s", "def calculate(s):\n \n oper = []\n for c in s:\n if c == 'p':\n oper.append('+')\n if c == 'm':\n oper.append('-')\n \n s = s.replace(\"plus\", ' ')\n s = s.replace(\"minus\", ' ')\n s = s.split(\" \")\n \n result = int(s[0])\n \n for i in range(len(oper)):\n if oper[i]=='+':\n result += int(s[i+1])\n else:\n result -= int(s[i+1])\n \n return str(result)", "def calculate(s):\n # your code here\n t=s.replace(\"plus\",\"+\")\n y=t.replace(\"minus\",\"-\")\n #print(y)\n return str(eval(y))\n", "calculate=lambda s:str(eval(s.replace(\"plus\",\"+\").replace(\"minus\",\"-\")))", "def calculate(s):\n # your code here\n return str(sum(map(int,s.replace('plus',' ').replace('minus',' -').split())))\n", "def calculate(s):\n s = s.replace('plus', '+').replace('minus', '-')\n summ = eval(s)\n return str(summ)\n", "import re\n\ndef calculate(s):\n xs = re.split(r'(plus|minus)', s)\n xs[::2] = map(int, xs[::2])\n return str(xs[0] + sum(\n xs[i+1] * (1 if xs[i] == 'plus' else -1)\n for i in range(1, len(xs), 2)\n ))"] | {"fn_name": "calculate", "inputs": [["1plus2plus3plus4"], ["1minus2minus3minus4"], ["1plus2plus3minus4"], ["1minus2plus3minus4"], ["1plus2minus3plus4minus5"]], "outputs": [["10"], ["-8"], ["2"], ["-2"], ["-1"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,915 |
def calculate(s):
|
6fbb5acdc3958b089c1eeb450453fd0d | UNKNOWN | The goal of this exercise is to convert a string to a new string where each character in the new string is `"("` if that character appears only once in the original string, or `")"` if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate.
## Examples
```
"din" => "((("
"recede" => "()()()"
"Success" => ")())())"
"(( @" => "))(("
```
**Notes**
Assertion messages may be unclear about what they display in some languages. If you read `"...It Should encode XXX"`, the `"XXX"` is the expected result, not the input! | ["def duplicate_encode(word):\n return \"\".join([\"(\" if word.lower().count(c) == 1 else \")\" for c in word.lower()])", "from collections import Counter\n\ndef duplicate_encode(word):\n word = word.lower()\n counter = Counter(word)\n return ''.join(('(' if counter[c] == 1 else ')') for c in word)\n", "#This solution is O(n) instead of O(n^2) like the methods that use .count()\n#because .count() is O(n) and it's being used within an O(n) method.\n#The space complexiety is increased with this method.\nimport collections\ndef duplicate_encode(word):\n new_string = ''\n word = word.lower()\n #more info on defaultdict and when to use it here:\n #http://stackoverflow.com/questions/991350/counting-repeated-characters-in-a-string-in-python\n d = collections.defaultdict(int)\n for c in word:\n d[c] += 1\n for c in word:\n new_string = new_string + ('(' if d[c] == 1 else ')')\n return new_string", "def duplicate_encode(word):\n word = word.lower()\n return ''.join('(' if word.count(x) == 1 else ')' for x in word)", "def duplicate_encode(word):\n \"\"\"a new string where each character in the new string is '(' \n if that character appears only once in the original word, or ')' \n if that character appears more than once in the original word. \n Ignores capitalization when determining if a character is a duplicate. \"\"\"\n word = word.upper()\n result = \"\"\n for char in word:\n if word.count(char) > 1:\n result += \")\"\n else:\n result += \"(\"\n \n return result\n", "def duplicate_encode(word):\n new_string = \"\"\n word = word.lower()\n \n for char in word:\n new_string += (\")\" if (word.count(char) > 1) else \"(\")\n \n return new_string", "def duplicate_encode(word):\n word = word.lower()\n \n dict = {}\n for char in word:\n dict[char] = ')' if char in dict else '('\n \n return ''.join( dict[char] for char in word )", "def duplicate_encode(word):\n word = word.lower()\n return ''.join([')' if word.count(char) > 1 else '(' for char in word])", "from collections import Counter\n\ndef duplicate_encode(word):\n word = word.lower()\n charCounts = Counter(word)\n return ''.join(')' if charCounts[c] > 1 else '(' for c in word)"] | {"fn_name": "duplicate_encode", "inputs": [["din"], ["recede"], ["Success"], ["CodeWarrior"], ["Supralapsarian"], ["iiiiii"], ["(( @"], [" ( ( )"]], "outputs": [["((("], ["()()()"], [")())())"], ["()(((())())"], [")()))()))))()("], ["))))))"], ["))(("], [")))))("]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,359 |
def duplicate_encode(word):
|
2b027d9124f2f45faa8d2baed31f0fe3 | UNKNOWN | This kata is part of the collection [Mary's Puzzle Books](https://www.codewars.com/collections/marys-puzzle-books).
Mary brought home a "spot the differences" book. The book is full of a bunch of problems, and each problem consists of two strings that are similar. However, in each string there are a few characters that are different. An example puzzle from her book is:
```
String 1: "abcdefg"
String 2: "abcqetg"
```
Notice how the "d" from String 1 has become a "q" in String 2, and "f" from String 1 has become a "t" in String 2.
It's your job to help Mary solve the puzzles. Write a program `spot_diff`/`Spot` that will compare the two strings and return a list with the positions where the two strings differ. In the example above, your program should return `[3, 5]` because String 1 is different from String 2 at positions 3 and 5.
NOTES:
```if-not:csharp
• If both strings are the same, return `[]`
```
```if:csharp
• If both strings are the same, return `new List()`
```
• Both strings will always be the same length
• Capitalization and punctuation matter | ["def spot_diff(s1, s2):\n return [i for i in range(len(s1)) if s1[i] != s2[i]]", "def spot_diff(s1, s2):\n return [k for k in range(len(s1)) if s1[k] != s2[k]]", "def spot_diff(s1, s2):\n r=[]\n for i in range (len(s1)):\n if s1[i]!=s2[i]: r.append(i)\n return r", "def spot_diff(s1, s2):\n return [i for i, (x, y) in enumerate(zip(s1, s2)) if x != y]\n", "def spot_diff(s1, s2):\n return [i for i, (a, b) in enumerate(zip(s1, s2)) if a != b]", "spot_diff = lambda a,b: [i for i,j in enumerate(zip(a,b)) if j[0]!=j[1]] ", "def spot_diff(s1, s2):\n return [i for i, a in enumerate(zip(s1, s2)) if a[0] != a[1]]", "def spot_diff(s1, s2):\n return [index for index, (c1, c2) in enumerate(zip(s1, s2)) if c1 != c2]", "def spot_diff(s1, s2):\n ret = []\n for i in range(0,len(s1)):\n if s1[i] != s2[i]:\n ret.append(i)\n return ret", "def spot_diff(s1, s2):\n diffs = []\n for i in range(0,len(s1)):\n if(s1[i] != s2[i]):\n diffs.append(i)\n return diffs"] | {"fn_name": "spot_diff", "inputs": [["abcdefg", "abcqetg"], ["Hello World!", "hello world."], ["FixedGrey", "FixedGrey"], ["HACKER", "H4CK3R"], ["This is a really long sentence.", "That is a_really long sentence,"], ["", ""], ["abcdefghijklmnopqrstuvwxyz", "zyxwvutsrqponmlkjihgfedcba"], ["YOLO lol", "ROLO mom"], ["www.youtube.com/zedaphplays", "www.twitter.com/zedaphplays"], ["Congratulations! You did it!", "Conglaturations! U did this!"]], "outputs": [[[3, 5]], [[0, 6, 11]], [[]], [[1, 4]], [[2, 3, 9, 30]], [[]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]], [[0, 5, 7]], [[4, 5, 6, 8, 9, 10]], [[4, 8, 17, 18, 19, 20, 22, 23, 24, 26]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,029 |
def spot_diff(s1, s2):
|
2d3610cf98404c48aa9f25047b7d8709 | UNKNOWN | Today was a sad day. Having bought a new beard trimmer, I set it to the max setting and shaved away at my joyous beard. Stupidly, I hadnt checked just how long the max setting was, and now I look like Ive just started growing it!
Your task, given a beard represented as an arrayof arrays, is to trim the beard as follows:
['|', 'J', '|', '|'],
['|', '|', '|', 'J'],
['...', '...', '...', '...'];
To trim the beard use the following rules:
trim any curled hair --> replace 'J' with '|'
trim any hair from the chin (last array) --> replace '|' or 'J' with '...'
All sub arrays will be same length. Return the corrected array of arrays | ["def trim(beard):\n return [[h.replace(\"J\", \"|\") for h in b] for b in beard[:-1]] + [[\"...\"]*len(beard[0])]", "def trim(beard):\n beard = [[\"|\" if p in \"|J\" else \"...\" for p in hair] for hair in beard]\n beard[-1] = [\"...\" for _ in beard[-1]]\n return beard", "def trim(a):\n return [[\"|\" if y == \"J\" else y for y in x] for x in a[:-1]] + [[\"...\"] * len(a[0])]", "def trim(beard):\n for row in range(0, len(beard)):\n for hair in range(0, len(beard[row])):\n if row != len(beard) - 1: beard[row][hair] = \"|\"\n else: beard[row][hair] = \"...\"\n \n return beard", "def trim(beard):\n for i,a in enumerate(beard):\n if i != len(beard)-1:\n beard[i] = ['|' if v in 'J|' else v for v in a]\n else:\n beard[i] = ['...' for v in a]\n return beard", "def trim(beard):\n return [list(map(lambda x:x.replace(\"J\",\"|\"),arr)) for arr in beard[:-1]]+[[\"...\"]*len(beard[0])]", "def trim(beard):\n width = len(beard[0])\n beard = [[\"|\" if cell in \"|J\" else \"...\" for cell in row] for row in beard[:-1]]\n beard.append([\"...\"] * width)\n return beard", "def trim(beard):\n return [[c.replace('J','|') for c in row] for row in beard[:-1]] + [['...'] * len(beard[-1])]\n", "H = {'J':'|', '|':'|', '...':'...'}\n\ntrim = lambda b: [[H[h] for h in m] for m in b[:-1]] \\\n + [['...'] * len(b[-1])]", "def trim(beard):\n return [['|' if j in ['|','J'] else j for j in i] for i in beard[:-1]] + [[\"...\"]*len(beard[-1])]"] | {"fn_name": "trim", "inputs": [[[["J", "|"], ["J", "|"], ["...", "|"]]], [[["J", "|", "J"], ["J", "|", "|"], ["...", "|", "J"]]], [[["J", "|", "J", "J"], ["J", "|", "|", "J"], ["...", "|", "J", "|"]]]], "outputs": [[[["|", "|"], ["|", "|"], ["...", "..."]]], [[["|", "|", "|"], ["|", "|", "|"], ["...", "...", "..."]]], [[["|", "|", "|", "|"], ["|", "|", "|", "|"], ["...", "...", "...", "..."]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,581 |
def trim(beard):
|
58aa62fd08b240aae35dcea581d527c6 | UNKNOWN | In this kata, you'll be given an integer of range `0 <= x <= 99` and have to return that number spelt out in English. A few examples:
```python
name_that_number(4) # returns "four"
name_that_number(19) # returns "nineteen"
name_that_number(99) # returns "ninety nine"
```
Words should be separated by only spaces and not hyphens. No need to validate parameters, they will always be in the range [0, 99]. Make sure that the returned String has no leading of trailing spaces. Good luck! | ["WORDS = (\n (90, 'ninety'), (80, 'eighty'), (70, 'seventy'), (60, 'sixty'),\n (50, 'fifty'), (40, 'forty'), (30, 'thirty'), (20, 'twenty'),\n (19, 'nineteen'), (18, 'eighteen'), (17, 'seventeen'), (16, 'sixteen'),\n (15, 'fifteen'), (14, 'fourteen'), (13, 'thirteen'), (12, 'twelve'),\n (11, 'eleven'), (10, 'ten'), (9, 'nine'), (8, 'eight'), (7, 'seven'),\n (6, 'six'), (5, 'five'), (4, 'four'), (3, 'three'), (2, 'two'), (1, 'one')\n)\n\n\ndef name_that_number(num):\n result = []\n for word_value, word_name in WORDS:\n quo, num = divmod(num, word_value)\n if quo:\n result.append(word_name)\n return ' '.join(result) or 'zero'", "ONES = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'}\nTENS = {20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty', 60: 'sixty', 70: 'seventy', 80: 'eighty', 90: 'ninety'}\nTEENS = {10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'} \n\n\ndef name_that_number(x):\n if x < 10:\n return ONES[x]\n elif x < 20:\n return TEENS[x]\n t, o = divmod(x, 10)\n return \" \".join((TENS[t*10], o and ONES[o] or '')).strip()", "def name_that_number(x):\n d = {2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty',\n 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety'}\n e = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five',\n 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', \n 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen',\n 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}\n if x < 20:\n return e.get(x, None)\n\n else:\n return d.get(x // 10, '') + (' ' + e.get(x % 10, '') if x % 10 != 0 else '')", "numbers = [\n 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',\n 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'\n]\ntens = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n\ndef name_that_number(x):\n if x < 20:\n return numbers[x]\n a, b = divmod(x - 20, 10)\n if b:\n return '{} {}'.format(tens[a], numbers[b])\n return tens[a] ", "ENGLISH_NUMS = {\n 0: 'zero',\n 1: 'one',\n 2: 'two',\n 3: 'three',\n 4: 'four',\n 5: 'five',\n 6: 'six',\n 7: 'seven',\n 8: 'eight',\n 9: 'nine',\n 10: 'ten',\n 11: 'eleven',\n 12: 'twelve',\n 13: 'thirteen',\n 15: 'fifteen',\n 18: 'eighteen',\n 20: 'twenty',\n 30: 'thirty',\n 40: 'forty',\n 50: 'fifty',\n 60: 'sixty',\n 70: 'seventy',\n 80: 'eighty',\n 90: 'ninety'\n}\n\ndef name_that_number(x):\n return ENGLISH_NUMS.get(x, ENGLISH_NUMS[x % 10] + 'teen' if x < 20 else ENGLISH_NUMS[x - x % 10] + ' ' + ENGLISH_NUMS[x % 10])", "names = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', \n 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n\ntens = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n\ndef name_that_number(x):\n if x<20:\n return names[x]\n else:\n return tens[int(x/10)-2] + ((' ' + names[x%10]) if x%10>0 else '')", "##func\ndef name_that_number(x):\n num1 = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\",\"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\n num2 = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\n \n if ((x >= 0) & (x < 20)):\n return num1[x] \n else:\n if(x % 10 == 0):\n return num2[int(x / 10) - 2] + \"\" \n else:\n return num2[int(x / 10) - 2] + \" \" + num1[x % 10]", "def name_that_number(x):\n ones = {\n 0 : \"zero\",\n 1 : \"one\",\n 2 : \"two\",\n 3 : \"three\",\n 4 : \"four\",\n 5 : \"five\",\n 6 : \"six\",\n 7 : \"seven\",\n 8 : \"eight\",\n 9 : \"nine\"\n }\n \n teens = {\n 11 : \"eleven\",\n 12 : \"twelve\",\n 13 : \"thirteen\",\n 14 : \"fourteen\",\n 15 : \"fifteen\",\n 16 : \"sixteen\",\n 17 : \"seventeen\",\n 18 : \"eighteen\",\n 19 : \"nineteen\"\n }\n \n tens = {\n 10 : \"ten\",\n 20 : \"twenty\",\n 30 : \"thirty\",\n 40 : \"forty\",\n 50 : \"fifty\",\n 60 : \"sixty\",\n 70 : \"seventy\",\n 80 : \"eighty\",\n 90 : \"ninety\"\n }\n \n if x in ones:\n return ones[x]\n elif x in teens:\n return teens[x]\n else:\n out = tens[10 * (x//10)]\n if x % 10 != 0:\n out += \" \" + ones[x % 10]\n return out", "def name_that_number(num):\n num_str = str(num)\n word_num = ['zero', \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\", \"eleven\",\n \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\n word_units = [\"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\n \n if num < 20:\n return word_num[num]\n else: \n first_digit = int(num_str[0]) - 2\n second_digit = int(num_str[1]) \n if second_digit == 0:\n return word_units[first_digit]\n else: \n return word_units[first_digit] + ' ' + word_num[second_digit]", "lessThan20 = [\"\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"]\ntens = [\"\",\"ten\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"]\n\ndef name_that_number(n):\n if n==0: return \"zero\"\n return helper(n).strip()\n\ndef helper(n):\n if n<20: return lessThan20[n]+\" \"\n return tens[n//10]+\" \"+helper(n%10)"] | {"fn_name": "name_that_number", "inputs": [[1], [52], [21], [99], [0], [53], [23], [76]], "outputs": [["one"], ["fifty two"], ["twenty one"], ["ninety nine"], ["zero"], ["fifty three"], ["twenty three"], ["seventy six"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 6,499 |
def name_that_number(x):
|
ed308855ea9e9f490dc691d528f60c44 | UNKNOWN | Given an array, find the duplicates in that array, and return a new array of those duplicates. The elements of the returned array should appear in the order when they first appeared as duplicates.
__*Note*__: numbers and their corresponding string representations should not be treated as duplicates (i.e., `"1" != 1`).
## Examples
```
[1, 2, 4, 4, 3, 3, 1, 5, 3, "5"] ==> [4, 3, 1]
[0, 1, 2, 3, 4, 5] ==> []
``` | ["def duplicates(array):\n seen = []\n dups = []\n for char in array:\n if char not in seen:\n seen.append(char)\n elif char not in dups:\n dups.append(char)\n \n return dups\n", "def duplicates(arr):\n res = []\n for i, x in enumerate(arr):\n if arr[:i + 1].count(x) > 1 and x not in res:\n res.append(x)\n return res", "def duplicates(array):\n dub = []\n for i, el in enumerate(array):\n if i != array.index(el) and el not in dub:\n dub.append(el) \n return dub", "def duplicates(array):\n return [n for i, n in enumerate(array) if array[:i].count(n) == 1]", "from typing import List, Union\n\n\ndef duplicates(array: List[Union[int, str]]) -> List[Union[int, str]]:\n d, res = {}, []\n for a in array:\n if d.setdefault(a, 0) == 1:\n res.append(a)\n d[a] += 1\n\n return res\n", "from collections import defaultdict\n\ndef duplicates(lst):\n result = []\n counter = defaultdict(int)\n for elem in lst:\n counter[elem] += 1\n if counter[elem] == 2:\n result.append(elem)\n return result", "def duplicates(array):\n return [v for i,v in enumerate(array) if v in array[:i] and array[:i].count(v) == 1]", "def duplicates(array):\n result = []\n \n for i,v in enumerate(array):\n if v in array[:i] and v not in result:\n result.append(v)\n \n return result", "def duplicates(array):\n l, out = [], []\n for e in array:\n if e in l and e not in out:\n out.append(e)\n l.append(e)\n return out"] | {"fn_name": "duplicates", "inputs": [[[1, 2, 4, 4, 3, 3, 1, 5, 3, "5"]], [[0, 1, 2, 3, 4, 5]], [[1, 1, 2, 3, 4, 5, 4]]], "outputs": [[[4, 3, 1]], [[]], [[1, 4]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,658 |
def duplicates(array):
|
b6d5249d6781c256d59dc713a7a43e1a | UNKNOWN | *This is the second Kata in the Ciphers series. This series is meant to test our coding knowledge.*
## Ciphers #2 - The reversed Cipher
This is a lame method I use to write things such that my friends don't understand. It's still fairly readable if you think about it.
## How this cipher works
First, you need to reverse the string. Then, the last character in the original string (the first character in the reversed string) needs to be moved to the back. Words will be separated by spaces, and punctuation marks can be counted as part of the word.
## Example
This is because `"Hello"` reversed is `"olleH"` and `"o"` is moved to the back, and so on. The exclamation mark is considered to be part of the word `"World"`.
Have fun (en)coding! | ["def encode(s):\n return ' '.join( w[-2::-1] + w[-1] for w in s.split() )", "def encode(s):\n s, sub_s = s.split(' '), ''\n for char in s:\n sub_s += char[::-1][1:] + char[-1] + ' '\n return sub_s[:-1]", "encode=lambda s:\" \".join([i[::-1][1:]+i[::-1][0] for i in s.split()])", "import re\n\ndef encode(s):\n return re.sub(r'\\S+', lambda m: m.group()[-2::-1] + m.group()[-1], s)", "def encode(s):\n return \" \".join([i[:-1][::-1] + i[-1] for i in s.split(\" \")])", "def encode(s):\n first_to_last = lambda x: x[1:] + x[0]\n return ' '.join((first_to_last(x[::-1]) for x in s.split()))", "def encode(s):\n k = ' '.join([i[::-1][1:] + i[::-1][0] for i in s.split(' ')])\n return k", "def encode(s):\n return \" \".join(x[-2::-1] + x[-1] for x in s.split())", "def encode(s):\n r = []\n for x in s.split():\n x = x[::-1]\n r.append(x[1:] + x[0])\n return \" \".join(r)", "def encode(s):\n return ' '.join(i[::-1][1:] + i[::-1][0] for i in s.split() ) "] | {"fn_name": "encode", "inputs": [["Hello World!"]], "outputs": [["lleHo dlroW!"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,025 |
def encode(s):
|
7db5ea3bff2a8bc3e41d3e629808c784 | UNKNOWN | A Magic Square contains the integers 1 to n^(2), arranged in an n by n array such that the columns, rows and both main diagonals add up to the same number.For doubly even positive integers (multiples of 4) the following method can be used to create a magic square.
Fill an array with the numbers 1 to n^(2) in succession. Then, for each 4 by 4 subarray, replace the entries on the blue and red diagonals by n^(2)+1-aij.
So, in the following example, a11 (row 1, column 1) was initially 1 and is replaced by 8^(2)+1-1 = 64
tab1 { padding-left: 2em; }
fc1 { font color="blue"}
n=8
642 3 61606 7 57
9 55541213515016
1747462021434224
4026273736303133
3234352928383925
4123224445191848
4915145253111056
8 58595 4 62631
The function even_magic() should return a 2D array as follows:-
Example:
n=4: Output: [[16,2,3,13],[5,11,10,8],[9,7,6,12],[4,14,15,1]]
162 3 13
5 11108
9 7 6 12
4 14151
Only doubly even numbers will be passed to the function in the tests.
See mathworld.wolfram.com for further details. | ["def even_magic(n):\n return [ [ n*n-(y*n+x) if x%4==y%4 or (x%4+y%4)%4==3 else y*n+x+1 for x in range(n)] for y in range(n) ]", "def even_magic(n):\n l = list(range(1,n*n+1))\n for i in range(n*n//2):\n y,x = (i//n)%4,(i%n)%4\n if y==x or x+y==3: l[i],l[n*n-1-i] = l[n*n-1-i], l[i]\n return [l[i*n:i*n+n] for i in range(n)]", "import numpy as np\n\ndef even_magic(n):\n mx = n*n\n draft = np.arange(1, mx +1).reshape((n, n))\n art = np.arange(mx, 0,-1).reshape((n, n))\n \n for i in range(n):\n for y in range(n):\n if any(( all((i%4 in [0,3], y%4 in [0,3])), all((i%4 in [1,2], y%4 in [1,2])) )):\n draft[i][y] = art[i][y]\n \n return draft.tolist()", "def even_magic(n):\n n2_1 = n ** 2 + 1\n return [\n [n2_1 - (i*n+j+1) if i % 4 == j % 4 or (i + j) % 4 == 3 else i*n+j+1 for j in range(n)]\n for i in range(n)\n ]", "def even_magic(n):\n sq = [[y*n+x+1 for x in range(n)] for y in range(n)]\n \n for x in range(n):\n for y in range(n):\n if y % 4 == x % 4 or y % 4 == 3-x % 4:\n sq[x][y] = n**2 + 1 - sq[x][y]\n return sq\n", "def even_magic(n):\n numbers, p = iter(list(range(1, n * n + 1))), 0\n main_grid = [[next(numbers) for _ in range(n)] for _ in range(n)]\n A = lambda s,se,see,e,ee,eee:list(zip(range(s,se,see),range(e,ee,eee)))\n for i in range(n//4):\n o = 0\n for j in range(n//4):\n for k, l in A(p, p + 4, 1, o, o + 4, 1) + A(p, p + 4, 1, o + 3, o - 1, -1):\n main_grid[k][l] = ((n ** 2) + 1) - main_grid[k][l]\n o += 4\n p += 4\n return main_grid", "def even_magic(n):\n square = []\n for j in range(0, n):\n row = []\n for i in range(0, n):\n v = i + j * n + 1\n if i % 4 == j % 4 or -(i + 1) % 4 == j % 4:\n row.append(n**2 + 1 - v)\n else:\n row.append(v)\n square.append(row) \n return square", "def even_magic(n):\n arr = [];\n for i in range(0, n):\n arr.append([])\n for j in range(0, n):\n if i%4==j%4 or i%4+j%4 == 3:\n arr[i].append(n*n-i*n-j)\n else:\n arr[i].append(i*n+j+1)\n return arr", "even_magic=lambda n:[[y%4in(x%4,3-x%4)and n*n-n*y-x or n*y+x+1for x in range(n)]for y in range(n)]", "def even_magic(n):\n result, n2 = [[n*i+j+1 for j in range(n)] for i in range(n)], n**2\n for x in range(n):\n result[x][x] = n2 + 1 - result[x][x]\n result[x][-x-1] = n2 + 1 - result[x][-x-1]\n for i in range(4, n, 4):\n for x in range(n-i):\n result[i+x][x] = n2 + 1 - result[i+x][x]\n result[x][i+x] = n2 + 1 - result[x][i+x]\n result[x][-x-1-i] = n2 + 1 - result[x][-x-1-i]\n result[i+x][-x-1] = n2 + 1 - result[i+x][-x-1]\n return result"] | {"fn_name": "even_magic", "inputs": [[4], [8]], "outputs": [[[[16, 2, 3, 13], [5, 11, 10, 8], [9, 7, 6, 12], [4, 14, 15, 1]]], [[[64, 2, 3, 61, 60, 6, 7, 57], [9, 55, 54, 12, 13, 51, 50, 16], [17, 47, 46, 20, 21, 43, 42, 24], [40, 26, 27, 37, 36, 30, 31, 33], [32, 34, 35, 29, 28, 38, 39, 25], [41, 23, 22, 44, 45, 19, 18, 48], [49, 15, 14, 52, 53, 11, 10, 56], [8, 58, 59, 5, 4, 62, 63, 1]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,955 |
def even_magic(n):
|
402e9385311d14663386b0e3bd0b288d | UNKNOWN | Write a function that when given a number >= 0, returns an Array of ascending length subarrays.
```
pyramid(0) => [ ]
pyramid(1) => [ [1] ]
pyramid(2) => [ [1], [1, 1] ]
pyramid(3) => [ [1], [1, 1], [1, 1, 1] ]
```
**Note:** the subarrays should be filled with `1`s | ["def pyramid(n):\n return [[1]*x for x in range(1, n+1)]", "def pyramid(n):\n return [ [1] * i for i in range(1, n+1) ]", "def pyramid(n):\n result = []\n for i in range (1, n + 1):\n result.append(i * [1])\n return result", "pyramid=lambda n:[-~i*[1]for i in range(n)]", "def pyramid(n):\n res = []\n if n != 0:\n for i in range(1,n+1):\n res.append([1 for x in range(i)])\n return res", "def pyramid(n):\n \n A = list()\n \n for i in range(1, n + 1):\n \n a = list()\n \n for j in range(i): a.append(1)\n \n A.append(a)\n \n return A", "pyramid = lambda __: [[1]*_ for _ in range(1,__+1)]", "r=lambda i:-~i*[1]\npyramid=lambda n:[*map(r,range(n))]", "def pyramid(n):\n\n pyramidArray = [[]] *n\n if n==0:\n return []\n \n for i in range(0, n): \n l =[1] * int(i + 1 ) \n pyramidArray[i]=l \n\n return pyramidArray\n\n", "def pyramid(n):\n return [[1 for _ in range(i)] for i in range(1, n + 1)]"] | {"fn_name": "pyramid", "inputs": [[0], [1], [2], [3]], "outputs": [[[]], [[[1]]], [[[1], [1, 1]]], [[[1], [1, 1], [1, 1, 1]]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,062 |
def pyramid(n):
|
3ffe6d9807d94d761f90bacdcd0b3c2a | UNKNOWN | A [Power Law](https://en.wikipedia.org/wiki/Power_law) distribution occurs whenever "a relative change in one quantity results in a proportional relative change in the other quantity." For example, if *y* = 120 when *x* = 1 and *y* = 60 when *x* = 2 (i.e. *y* halves whenever *x* doubles) then when *x* = 4, *y* = 30 and when *x* = 8, *y* = 15.
Therefore, if I give you any pair of co-ordinates (x1,y1) and (x2,y2) in a power law distribution, you can plot the entire rest of the distribution and tell me the value of *y* for any other value of *x*.
Given a pair of co-ordinates (x1,y1) and (x2,y2) and another x co-ordinate *x3*, return the value of *y3*
```
powerLaw(x1y1, x2y2, x3)
e.g. powerLaw([1,120], [2,60], 4)
- when x = 1, y = 120
- when x = 2, y = 60
- therefore whenever x doubles, y halves
- therefore when x = 4, y = 60 * 0.5
- therfore solution = 30
```
(x1,y1) and (x2,y2) will be given as arrays. Answer should be to the nearest integer, but random tests will give you leeway of 1% of the reference solution to account for possible discrepancies from different methods. | ["from math import log\n\ndef power_law(p1, p2, x3):\n (x1, y1), (x2, y2) = p1, p2\n x1 += 1e-9; y1 += 1e-9\n return round(y1 * (y2 / y1) ** log(x3 / x1, x2 / x1))", "from math import log\n\ndef power_law(x1y1, x2y2, x3):\n a, b, c = x2y2[0]/x1y1[0], x2y2[1]/x1y1[1], x3/x1y1[0]\n try:\n return round(x1y1[1] * b**log(c, a))\n except ZeroDivisionError:\n return round(x1y1[1] * b)", "from math import log\n\ndef power_law(x1y1, x2y2, x3):\n x1, y1 = x1y1\n x2, y2 = x2y2\n if x1 == x2:\n return y2\n return round(y1 * (y2 / y1) ** log(x3 / x1, x2 / x1))", "def power_law(a1,a2, x3):\n import math\n x1=a1[0]\n y1=a1[1]\n x2=a2[0]\n y2=a2[1]\n if x1==x2:\n return y2\n else:\n return round(y1*(y2/y1)**(math.log10(x3/x1)/math.log10(x2/x1)))", "power_law=lambda a,b,x:round(a[1]*(b[1]/(a[1]+1e-9))**__import__('math').log(x/(a[0]+1e-9),b[0]/(a[0]+1e-9)))", "import math\ndef power_law(x1y1, x2y2, x3):\n if x1y1[0]==x2y2[0]:\n return x2y2[1] # conner case\n x_asc_rate, y_dsec_rate = x2y2[0]/x1y1[0], x1y1[1]/x2y2[1]\n return round(x2y2[1]/(y_dsec_rate**(math.log(x3/x2y2[0])/math.log(x_asc_rate))))", "from math import log\ndef power_law(x1y1, x2y2, x3):\n x1,y1=x1y1\n x2,y2=x2y2\n if x1==x2==x3:\n return y1\n k=-log(y2/y1,x1/x2)\n a=y1/(x1**k)\n return round(a*(x3**k))", "from math import log\n\ndef power_law(x1y1, x2y2, x3):\n (x1, y1), (x2, y2) = (x1y1, x2y2)\n try:\n k = log(y1 / y2, x1 / x2)\n a = y1 / x1 ** k\n return round(a * x3 ** k)\n except ZeroDivisionError:\n return y2", "from math import log\n\ndef power_law(x1y1, x2y2, x3):\n try:\n k = (log(x1y1[1]) - log(x2y2[1])) / (log(x1y1[0]) - log(x2y2[0]))\n a = x1y1[1] / (x1y1[0] ** k)\n return round(a * x3 ** k)\n except ZeroDivisionError:\n return x2y2[1]", "import math\ndef power_law(x1y1, x2y2, x3):\n x1=x1y1[0]\n y1=x1y1[1]\n x2=x2y2[0]\n y2=x2y2[1]\n x=x2/x1\n y=y2/y1\n if x1==x2: return y2\n return round(y1*y**(math.log(x3/x1)/math.log(x)))"] | {"fn_name": "power_law", "inputs": [[[1, 120], [2, 60], 4], [[1, 120], [2, 60], 8], [[1, 120], [4, 30], 8], [[1, 120], [3, 60], 9], [[1, 120], [3, 60], 27], [[1, 120], [9, 30], 27], [[1, 81], [2, 27], 4], [[1, 81], [2, 27], 8], [[1, 81], [4, 9], 8], [[1, 81], [5, 27], 25], [[1, 81], [5, 27], 125], [[1, 81], [25, 9], 125], [[4, 30], [2, 60], 1], [[5, 27], [1, 81], 1], [[4, 9], [8, 3], 1], [[1, 120], [1, 120], 1], [[4, 99], [4, 99], 4], [[9, 1], [9, 1], 9]], "outputs": [[30], [15], [15], [30], [15], [15], [9], [3], [3], [9], [3], [3], [120], [81], [81], [120], [99], [1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,104 |
def power_law(x1y1, x2y2, x3):
|
0be723f9b786039c2e746687659fee3b | UNKNOWN | # SpeedCode #2 - Array Madness
## Objective
Given two **integer arrays** ```a, b```, both of ```length >= 1```, create a program that returns ```true``` if the **sum of the squares** of each element in ```a``` is **strictly greater than** the **sum of the cubes** of each element in ```b```.
E.g.
```python
array_madness([4, 5, 6], [1, 2, 3]) => True #because 4 ** 2 + 5 ** 2 + 6 ** 2 > 1 ** 3 + 2 ** 3 + 3 ** 3
```
Get your timer out. Are you ready? Ready, get set, GO!!! | ["def array_madness(a,b):\n return sum(x ** 2 for x in a) > sum(x **3 for x in b)", "def array_madness(a,b):\n return sum(map(lambda a: a ** 2, a)) > sum(map(lambda b: b ** 3, b))", "def array_madness(a,b):\n sa=0\n sb=0\n for i in range(0,len(a)):\n sa+=a[i]**2\n for i in range(0,len(b)):\n sb+=b[i]**3\n return sa>sb", "def array_madness(a,b):\n return True if sum([x**2 for x in a]) > sum([y**3 for y in b]) else False", "def array_madness(a,b):\n return sum(map(lambda x:x*x,a)) > sum(map(lambda x:x*x*x,b))", "def array_madness(a,b):\n squaresA = 0\n cubesB = 0\n for i in range(len(a)):\n squaresA += pow(a[i], 2)\n for j in range(len(b)):\n cubesB += pow(b[j], 3) \n return squaresA > cubesB", "array_madness = lambda a, b: \\\n sum(map(lambda x: x ** 2, a)) > sum(map(lambda x: x ** 3, b))", "def array_madness(a,b):\n return sum(a_i**2 for a_i in a) > sum(b_i**3 for b_i in b)", "array_madness = lambda a,b,nsum=lambda n,x: sum(e**n for e in x): nsum(2,a)>nsum(3,b)", "array_madness = lambda a, b: sum(e**2 for e in a) > sum(e**3 for e in b)", "def array_madness(a,b):\n return sum(i**2 for i in a) > sum(i**3 for i in b)\n", "array_madness = lambda a,b,c=lambda n,x: sum(e**n for e in x): c(2,a)>c(3,b)", "from typing import List\n\ndef array_madness(a: List[int], b: List[int]) -> bool:\n \"\"\"\n Return `true` if the sum of the squares of each element in `a` \n is strictly greater than the sum of the cubes of each element in `b`.\n \"\"\"\n return sum(map(lambda _: pow(_, 2), a)) > sum(map(lambda _: pow(_, 3), b))", "def array_madness(a, b):\n return sum(map(2..__rpow__, a)) > sum(map(3..__rpow__, b))", "from functools import reduce\ndef array_madness(*arrays):\n return int.__gt__(*[reduce(lambda a,c:a+c**(2+i), a, 0) for i,a in enumerate(arrays)])\n", "def array_madness(a,b):\n list1 = []\n list2 = []\n for i in a:\n list1.append(i ** 2)\n for j in b:\n list2.append(j ** 3)\n if sum(list1) > sum(list2):\n return True\n elif sum(list1) < sum(list2):\n return False\n elif sum(list1) == sum(list2):\n return True\n else:\n return True\n \n", "def array_madness(*args):\n return int.__gt__(*(sum(map(i.__rpow__, arr)) for i, arr in enumerate(args, 2)))", "def array_madness(a,b):\n return sum(map(square, a)) > sum(map(cube, b))\n\ndef square(x):\n return x*x\n\ndef cube(x):\n return x*x*x", "def array_madness(a,b):\n s = lambda x, y: sum(list(map(lambda z: z ** y, x)))\n return s(a, 2) > s(b, 3)", "def array_madness(arr1: list, arr2: list) -> bool:\n \"\"\" This function returns True if the sum of the squares of each element in arr1 is strictly greater than the sum of the cubes of each element in arr2. \"\"\"\n if len(arr1) and len(arr2) >= 1:\n return True if sum([i**2 for i in arr1]) > sum([i**3 for i in arr2]) else False\n return False", "def array_madness(a,b):\n lista1 = []\n lista2 = []\n for num1 in a:\n num1 = num1 ** 2\n lista1.append(num1)\n add_lista1 = sum(lista1)\n \n for num2 in b:\n num2 = num2 ** 3\n lista2.append(num2)\n add_lista2 = sum(lista2)\n \n if add_lista1 > add_lista2:\n return True\n else:\n return False\n", "def array_madness(a,b):\n resa = 0\n resb = 0\n for num in a:\n resa += num**2\n for num in b:\n resb += num**3\n return resa > resb", "def array_madness(a,b):\n sq = 0\n sm = 0\n for i in a:\n sq += i**2\n for i in b:\n sm += i**3\n \n return sq>sm", "def array_madness(a,b):\n farr = 0\n sarr = 0\n for i in a : \n n = i ** 2\n farr = farr + n\n for j in b :\n o = j ** 3\n sarr = sarr + o\n if farr > sarr :\n return True\n if sarr >= farr :\n return False\n", "def array_madness(a,b):\n if sum(list(map(lambda x:x*x, a))) > sum(list(map(lambda x:x*x*x, b))):\n return True\n else:\n return False", "def array_madness(a,b):\n aa = sum([i**2 for i in a])\n bb = sum([i**3 for i in b])\n print (aa, bb)\n return aa>bb", "def array_madness(a,b):\n #descobrir o quadrado de cada elemento de a\n for i in range(len(a)):\n a[i] = a[i] ** 2 #levantado a 2 \n sum_a = sum(a) \n \n for i in range(len(b)):\n b[i] = b[i] ** 3 #levantar 3\n sum_b = sum(b)\n \n if sum_a > sum_b:\n return True\n else:\n return False\n \n", "def array_madness(a,b):\n array1 = 0\n array2 = 0\n for v in a:\n array1 += v**2\n for v in b:\n array2 += v**3\n return array1 > array2", "def array_madness(a,b):\n return sum([num**3 for num in b]) < sum([num**2 for num in a])", "def array_madness(a,b):\n SumA = 0\n for number in a:\n SumA += number ** 2\n SumB = 0\n for number in b:\n SumB += number ** 3\n \n return SumA > SumB", "def array_madness(a,b):\n a1 = 0\n b1 = 0\n for i in a:\n a1 += i ** 2\n for j in b:\n b1 += j ** 3\n return a1 > b1", "def array_madness(a,b):\n # Ready, get, set, GO!!!\n suma = 0\n sumb = 0\n for i in a:\n suma += i * i\n for i in b:\n sumb += i * i * i\n return suma > sumb", "def array_madness(a, b):\n squared = list(map(lambda x:x*x, a))\n cubed = list(map(lambda x:x*x*x, b))\n if sum(squared) > sum(cubed):\n return True\n return False", "def array_madness(a,b):\n return sum(list(map(lambda elem : elem ** 2 , a))) > sum(list(map(lambda elem : elem ** 3 , b)))", "def array_madness(a,b):\n a_list = 0\n b_list = 0\n for i in a:\n a_list = a_list + i**2\n for j in b:\n b_list = b_list + j **3\n if a_list > b_list:\n return True\n else:\n return False \n # Ready, get, set, GO!!!\n", "def array_madness(a,b):\n x = 0\n for k in a:\n x += k**2\n \n y = 0\n for k in b:\n y += k**3\n \n if x > y:\n return True\n else:\n return False\n # Ready, get, set, GO!!!\n", "def array_madness(a,b):\n print(a, b)\n sum1 = 0\n sum2 = 0\n for n in a:\n sum1 += n**2\n for n in b:\n sum2 += n**3\n print(sum1, sum2)\n if sum1 > sum2:\n return True\n else:\n return False", "def array_madness(a,b):\n square=0\n cube=0\n for i in range(0,len(a)):\n square+=a[i]**2\n for i in range(0,len(b)):\n cube+=b[i]**3\n if square>cube: return True\n else: return False\n", "def array_madness(a,b):\n result_a = 0\n result_b = 0\n for i in a:\n result_a += i ** 2 \n for i in b:\n result_b += i ** 3\n return result_a > result_b", "def array_madness(a,b):\n newa = []\n newb = []\n for x in a:\n newa.append(x ** 2)\n for y in b:\n newb.append(y ** 3)\n return sum(newa) > sum (newb)", "def array_madness(a,b):\n suma = 0\n for i in a:\n suma = suma + i**2\n sumb = 0\n for i in b:\n sumb = sumb + i**3\n return suma > sumb", "def array_madness(a,b):\n count = 0\n for item in a:\n a[count] = item**2\n count += 1\n count = 0\n for item in b:\n b[count] = item**3\n count += 1\n\n if sum(a)>sum(b):\n return True\n else:\n return False", "def array_madness(a,b):\n sum1 = 0\n sum2 = 0\n for x in a:\n sum1 += (x ** 2)\n for x in b:\n sum2 += (x ** 3)\n if(sum1 > sum2):\n return True\n else:\n return False", "def array_madness(a,b):\n a_sqr = [x**2 for x in a]\n b_cub = [y**3 for y in b]\n a_sum = sum(a_sqr)\n b_sum = sum(b_cub)\n return True if a_sum > b_sum else False\n", "def array_madness(a,b):\n # Ready, get, set, GO!!!\n sum1=0\n sum2=0\n for i in a:\n sq=i**2\n sum1=sum1+sq\n for j in b:\n cu=j**3\n sum2=sum2+cu\n if sum1 > sum2:\n return True\n else:\n return False\n", "def array_madness(a,b):\n totalOfA = 0\n totalOfB = 0\n for number in a:\n newNumber = number ** 2\n totalOfA += newNumber\n for number in b:\n newNumber = number ** 3\n totalOfB += newNumber\n \n if totalOfA > totalOfB:\n return True\n else:\n return False\n", "mul = lambda arr, h: sum (pow(i, h) for i in arr)\narray_madness = lambda a,b: mul(a,2) > mul(b,3)", "def array_madness(a,b):\n sum_of_a = 0\n sum_of_b = 0\n for x in range(len(a)):\n sum_of_a += a[x]**2\n for y in range(len(b)):\n sum_of_b += b[y]**3\n if sum_of_a > sum_of_b: \n return True\n else:\n return False", "def ss(a):return sum([e*e for e in a])\n\ndef sc(b):return sum([e*e*e for e in b])\n\ndef array_madness(a,b):\n return ss(a)>sc(b)", "def array_madness(a,b):\n squares = sum([el ** 2 for el in a])\n cubes = sum([el ** 3 for el in b])\n return squares > cubes", "def array_madness(a,b):\n a_sum = 0\n b_sum = 0\n for i in a:\n a_sum = a_sum + i**2\n for j in b:\n b_sum = b_sum + j**3\n \n if (a_sum > b_sum):\n return True\n else:\n return False", "def square_array(arr):\n return [item**2 for item in arr]\n\ndef cube_array(arr):\n return [item**3 for item in arr]\n\ndef sum_array(arr):\n sum = 0\n for thing in arr:\n sum += thing\n return sum\n\ndef array_madness(a,b):\n return sum_array(square_array(a)) > sum_array(cube_array(b))\n \n", "from functools import reduce\ndef array_madness(a,b):\n arr1=map(lambda x:x**2,a)\n arr2=map(lambda x:x**3,b)\n \n arr3=reduce(lambda c,d: int(c) + int(d), arr1)\n arr4=reduce(lambda e,f: int(e) + int(f), arr2)\n if arr3>arr4: return True\n else: return False", "def array_madness(a,b):\n result_a = 0\n result_b = 0\n for i in a:\n result_a += i ** 2\n for i in b:\n result_b += i ** 3\n return True if result_a > result_b else False\n", "def array_madness(a,b):\n result_a = 0\n result_b = 0\n for i in a:\n result_a += i ** 2\n for i in b:\n result_b += i ** 3\n if result_a > result_b:\n return True\n else:\n return False", "def array_madness(a,b):\n return sum(pow(el, 2) for el in a) > sum(pow(el, 3) for el in b)\n", "\n\ndef array_madness(a,b):\n return True if sum([x**2 for x in a]) > sum([x**3 for x in b]) else False \n\narray_madness([4, 5, 6], [1, 2, 3])\n\n\n\n\n \n\n", "def array_madness(a,b):\n return True if sum( n**2 for n in a ) > sum( n**3 for n in b ) else False\n", "def array_madness(a,b):\n la = sum(x**2 for x in a)\n lb = sum(y**3 for y in b)\n return la >= lb", "def array_madness(a,b):\n square= [x**2 for x in a] \n cube = [x**3 for x in b]\n return sum(square) > sum(cube)", "def array_madness(a,b):\n result1 = 0\n result2 = 0\n for number in a:\n result1 += number**2\n for number in b:\n result2 += number**3\n if result1 > result2:\n return True\n else:\n return False\n # Ready, get, set, GO!!!\n", "def array_madness(a,b):\n # Ready, get, set, GO!!!\n kv = 0\n kub = 0\n for i in a:\n kv += i ** 2\n for j in b:\n kub += j ** 3\n return kv > kub", "def array_madness(a,b):\n squares_list = [i**2 for i in a]\n cubes_list = [i**3 for i in b]\n return sum(squares_list) > sum(cubes_list)", "def array_madness(a:[],b:[]):\n result = 0\n result2 = 0\n for i in a:\n result += i*i\n for i in b:\n result2 += i*i*i\n if result > result2:\n return True\n return False\n\n\n", "def array_madness(a,b):\n for i in range(len(a)):\n a[i] = a[i]**2\n suma= sum(a)\n for i in range(len(b)):\n b[i] = b[i]**3\n sumb = sum(b)\n if suma > sumb:\n return True\n else:\n return False\n # Ready, get, set, GO!!!\n", "def array_madness(a,b):\n sum = 0\n sumc = 0\n for i in a:\n sum += (i ** 2)\n for i in b:\n sumc += (i ** 3)\n if sum > sumc:\n return True\n else:\n return False", "def array_madness(a,b):\n sum1 = 0\n sum2 = 0\n for val1 in a:\n sum1 += val1**2\n for val2 in b:\n sum2 += val2**3\n return sum1 > sum2", "def array_madness(a,b):\n q=0\n w=0\n for i in a:\n q+=i**2\n for i in b:\n w+=i**3\n return q>w\n # Ready, get, set, GO!!!\n", "def array_madness(a,b):\n suma=0\n sumb=0\n for i in a:\n suma += i ** 2\n for j in b:\n sumb += j ** 3\n return True if suma > sumb else False\n \n", "def array_madness(a,b):\n p = 0\n for i in a:\n p += i**2\n q = 0\n for j in b:\n q += j**3\n return p > q", "def array_madness(a,b):\n c=False\n \n \n sum1=list(map(lambda number:number*number,a))\n sum2=list(map(lambda number:number*number*number,b))\n \n if sum(sum1)>sum(sum2):\n c=True\n \n return c", "def array_madness(a,b):\n sum1=0\n sum2=0\n for i in range(len(a)):\n sum1=sum1+(a[i]**2)\n for j in range(len(b)):\n sum2=sum2+(b[j]**3)\n if sum1>sum2:\n return True\n else:\n return False", "def array_madness(a,b):\n return sum(_a**2 for _a in a) > sum(_b**3 for _b in b)", "def array_madness(a,b):\n a_total = 0\n b_total = 0\n \n for i in a:\n x = i*i\n a_total += x\n \n for i in b:\n x = i*i*i\n b_total += x\n \n return a_total > b_total", "def array_madness(a,b):\n # Ready, get, set, GO!!!\n \n hi = 0\n cool = 0\n for num in a:\n p1 = num ** 2\n cool = p1 + cool\n \n for i in b:\n p2 = i ** 3\n hi = p2 + hi\n \n if cool > hi:\n return True\n else:\n return False", "def array_madness(a,b):\n r = lambda arr, p: sum([number**p for number in arr])\n return r(a,2) > r(b,3)", "def array_madness(squares, cubes):\n return sum(num ** 2 for num in squares) > sum(num ** 3 for num in cubes)", "def array_madness(squares, cubes):\n return sum([num ** 2 for num in squares]) >= sum([num ** 3 for num in cubes])", "def array_madness(a,b):\n suma = 0\n sumb = 0\n \n for i in a:\n suma = suma+i**2\n \n for i in b:\n sumb = sumb+i**3\n \n \n return suma>sumb", "def array_madness(a,b):\n for i,v in enumerate(a):\n a[i] = v**2\n for i,v in enumerate(b):\n b[i] = v**3\n return sum(a) > sum(b)", "def array_madness(a,b):\n # Ready, get, set, GO!!!\n temp=0\n temp1=0\n for i in range(len(a)):\n temp+=a[i]**2\n for j in range(len(b)):\n temp1+=b[j]**3\n \n if temp>temp1:\n return True\n else:\n return False\n \n", "def array_madness(a,b):\n sum1 = 0\n sum2 = 0\n for i in a:\n x = i ** 2\n sum1 += x\n for j in b:\n y = j ** 3\n sum2 += y\n if sum1 > sum2:\n return True\n else:\n return False", "def array_madness(a,b):\n squareSum = 0\n cubeSum = 0\n \n for i in a:\n squareSum+= i * i\n \n for i in b:\n cubeSum+= i * i * i\n \n if squareSum > cubeSum:\n return True\n \n return False", "def array_madness(a,b):\n x=0\n y=0\n for i in a:\n x += i*i\n for j in b:\n y += j*j*j\n return x>y\n \n \n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n \n \n \n", "def array_madness(a,b):\n square = [ x ** 2 for x in a ]\n cube = [ y ** 3 for y in b ]\n return True if sum(square) > sum(cube) else False", "def square(x):\n return x*x\ndef Cube(x):\n return x*x*x\ndef array_madness(a,b):\n return ((True,False) [sum(map(square,a))<sum(map(Cube,b))])\n", "def array_madness(a,b):\n a_total = 0\n b_total = 0\n for num in a:\n squares = num**2\n a_total = a_total + squares\n \n for num in b:\n cubes = num**3\n b_total = b_total + cubes\n \n return a_total > b_total\n", "def calculate_array(array,\n exponent):\n\n result = 0\n for i in range(len(array)):\n result += (array[i] ** exponent)\n\n return result\n\n\ndef array_madness(a,\n b):\n\n sum_a, sum_b = calculate_array(a, 2), calculate_array(b, 3)\n if (sum_b < sum_a):\n\n return True\n\n return False\n", "def array_madness(a,b):\n lsta=[]\n lstb=[]\n for x in a:\n x=x**2\n lsta.append(x)\n for y in b:\n y=y**3\n lstb.append(y)\n if sum(lsta) >= sum(lstb):\n return True\n else:\n return False", "def array_madness(a,b):\n res1=0\n for i in a:\n res1=res1+i*i\n \n res2=0\n for i in b:\n res2=res2+i*i*i\n \n return res1>=res2", "def array_madness(a,b):\n x = 0\n y = 0\n for i in a:\n x += i ** 2\n for c in b:\n y += c ** 3\n return x > y", "def array_madness(a,b):\n Listea=list()\n Listeb=list()\n for ch in a:\n Listea.append(ch**2)\n suma=sum(Listea)\n for ch in b:\n Listeb.append(ch**3)\n sumb=sum(Listeb)\n\n if suma>sumb:\n return True\n else:\n return False\n", "def array_madness(a,b):\n x=y=i=0\n for i in range(len(a)):\n x = x + a[i] * a[i]\n for i in range(len(b)):\n y = y + (b[i] * b[i] * b[i])\n return x > y", "def array_madness(a,b):\n # Ready, get, set, GO!!!\n one = sum([i**2 for i in a])\n two = sum([i**3 for i in b])\n return one>two", "def array_madness(a,b):\n sum_a = sum(x**2 for x in a)\n sum_b = sum(x**3 for x in b)\n if sum_a > sum_b:\n return True\n else:\n return False", "def array_madness(a,b):\n sum_squares = 0\n sum_cubes = 0\n for number in a:\n sum_squares += number ** 2\n for number in b:\n sum_cubes += number ** 3\n if sum_squares > sum_cubes:\n return True\n return False", "def array_madness(a,b):\n return sum(i*i for i in a) > sum(w*w*w for w in b)", "def array_madness(a,b):\n return sum(n * n for n in a) > sum(n * n * n for n in b) ", "import numpy as np\n\ndef array_madness(a,b):\n # Ready, get, set, GO!!!\n a,b = np.array(a),np.array(b)\n squaring_array1 = a ** 2\n cube_array2 = b ** 3\n if sum(squaring_array1) > sum(cube_array2):\n return True\n else:\n return False", "def array_madness(a,b):\n a_squares = [i ** 2 for i in a]\n b_cubes = [i ** 3 for i in b]\n return sum(a_squares) > sum(b_cubes)"] | {"fn_name": "array_madness", "inputs": [[[4, 5, 6], [1, 2, 3]]], "outputs": [[true]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 18,969 |
def array_madness(a,b):
|
e81d1f5ba214a724f11ecae63c18f1af | UNKNOWN | Simple enough this one - you will be given an array. The values in the array will either be numbers or strings, or a mix of both. You will not get an empty array, nor a sparse one.
Your job is to return a single array that has first the numbers sorted in ascending order, followed by the strings sorted in alphabetic order. The values must maintain their original type.
Note that numbers written as strings are strings and must be sorted with the other strings. | ["def db_sort(arr): \n return sorted(arr, key=lambda x: (isinstance(x,str),x))", "def db_sort(arr): \n n=[]\n s=[]\n for i in arr:\n if type(i) ==type( 'a'):\n s.append(i)\n else:\n n.append(i)\n return sorted(n)+sorted(s)", "def db_sort(arr): \n ints, strg = [], []\n for i in arr:\n ints.append(i) if type(i) == int else strg.append(i) \n return sorted(ints) + sorted(strg)", "def db_sort(xs): \n return sorted(xs, key=lambda x: (isinstance(x, str), x))", "def db_sort(xs): \n return sorted(xs, key=lambda x: (type(x) is str, x))", "def db_sort(arr): \n return sorted(n for n in arr if type(n) is int) + sorted(s for s in arr if type(s) is str)", "db_sort = lambda a: sorted(a, key=lambda x: (type(x) is str, x))", "def db_sort(arr): \n return sorted(i for i in arr if isinstance(i, int)) + sorted(i for i in arr if isinstance(i, str))", "def db_sort(arr):\n n,s = [], []\n for v in arr:\n if type(v).__name__=='str': s.append(v)\n else:n.append(v)\n return sorted(n)+sorted(s)", "def db_sort(arr): \n\tstrings,integers=[],[]\n\tfor i in arr:\n\t\tintegers.append(i) if type(i) is int else strings.append(i)\n\treturn sorted(integers)+sorted(strings)", "def db_sort(arr):\n num = []\n alpha = []\n \n for i in arr:\n if isinstance(i, int):\n num.append(int(i))\n else:\n alpha.append(i)\n \n num.sort()\n alpha.sort()\n \n return num + alpha", "def db_sort(arr): \n return sorted([x for x in arr if not(isinstance(x,str))]) + sorted([x for x in arr if isinstance(x, str)])", "def db_sort(arr): \n return sorted([x for x in arr if isinstance(x,int)]) + sorted([x for x in arr if isinstance(x,str)])", "def db_sort(arr): \n return sorted([v for v in arr if type(v) is int]) + sorted([v for v in arr if type(v) is str])", "def db_sort(arr): \n a = list('!'*arr.count('!')) if '!' in arr else []\n return sorted([x for x in arr if isinstance(x, int)]) + a + list(map(str,sorted(map(int,([x for x in arr if isinstance(x, str) and x[0] in '0123456789']))))) + sorted([x for x in arr if isinstance(x, str) and x[0] not in '0123456789!'])\n", "def db_sort(arr): \n a, b = filter(lambda x:isinstance(x, str), arr), filter(lambda x:isinstance(x, int), arr)\n return sorted(b)+sorted(a)", "def db_sort(arr): \n m = sorted(arr, key=lambda x: (isinstance(x, str), x))\n return m"] | {"fn_name": "db_sort", "inputs": [[[6, 2, 3, 4, 5]], [[14, 32, 3, 5, 5]], [[1, 2, 3, 4, 5]], [["Banana", "Orange", "Apple", "Mango", 0, 2, 2]], [["C", "W", "W", "W", 1, 2, 0]], [["Hackathon", "Katathon", "Code", "CodeWars", "Laptop", "Macbook", "JavaScript", 1, 5, 2]], [[66, "t", 101, 0, 1, 1]], [[78, 117, 110, 99, 104, 117, 107, 115, 4, 6, 5, "west"]], [[101, 45, 75, 105, 99, 107, "y", "no", "yes", 1, 2, 4]], [[80, 117, 115, 104, 45, 85, 112, 115, 6, 7, 2]], [[1, 1, 1, 1, 1, 2, "1", "2", "three", 1, 2, 3]], [[78, 33, 22, 44, 88, 9, 6, 0, 5, 0]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]], [[82, 18, 72, 1, 11, 12, 12, 12, 12, 115, 667, 12, 2, 8, 3]], [["t", "e", "s", "t", 3, 4, 1]], [["what", "a", "great", "kata", 1, 2, 2]], [[66, "codewars", 11, "alex loves pushups", 2, 3, 0]], [["come", "on", 110, "2500", 10, "!", 7, 15, 5, 6, 6]], [["when's", "the", "next", "Katathon?", 9, 7, 0, 1, 2]], [[8, 7, 5, "bored", "of", "writing", "tests", 115, 6, 7, 0]], [["anyone", "want", "to", "hire", "me?", 2, 4, 1]]], "outputs": [[[2, 3, 4, 5, 6]], [[3, 5, 5, 14, 32]], [[1, 2, 3, 4, 5]], [[0, 2, 2, "Apple", "Banana", "Mango", "Orange"]], [[0, 1, 2, "C", "W", "W", "W"]], [[1, 2, 5, "Code", "CodeWars", "Hackathon", "JavaScript", "Katathon", "Laptop", "Macbook"]], [[0, 1, 1, 66, 101, "t"]], [[4, 5, 6, 78, 99, 104, 107, 110, 115, 117, 117, "west"]], [[1, 2, 4, 45, 75, 99, 101, 105, 107, "no", "y", "yes"]], [[2, 6, 7, 45, 80, 85, 104, 112, 115, 115, 117]], [[1, 1, 1, 1, 1, 1, 2, 2, 3, "1", "2", "three"]], [[0, 0, 5, 6, 9, 22, 33, 44, 78, 88]], [[1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9]], [[1, 2, 3, 8, 11, 12, 12, 12, 12, 12, 18, 72, 82, 115, 667]], [[1, 3, 4, "e", "s", "t", "t"]], [[1, 2, 2, "a", "great", "kata", "what"]], [[0, 2, 3, 11, 66, "alex loves pushups", "codewars"]], [[5, 6, 6, 7, 10, 15, 110, "!", "2500", "come", "on"]], [[0, 1, 2, 7, 9, "Katathon?", "next", "the", "when's"]], [[0, 5, 6, 7, 7, 8, 115, "bored", "of", "tests", "writing"]], [[1, 2, 4, "anyone", "hire", "me?", "to", "want"]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 2,473 |
def db_sort(arr):
|
dfb6725e3220cf57e7ba4b4749826a55 | UNKNOWN | Given a sequence of numbers, find the largest pair sum in the sequence.
For example
```
[10, 14, 2, 23, 19] --> 42 (= 23 + 19)
[99, 2, 2, 23, 19] --> 122 (= 99 + 23)
```
Input sequence contains minimum two elements and every element is an integer. | ["def largest_pair_sum(numbers): \n return sum(sorted(numbers)[-2:])", "from heapq import nlargest\n\ndef largest_pair_sum(a):\n return sum(nlargest(2, a))", "def largest_pair_sum(a): \n return a.pop(a.index(max(a))) + a.pop(a.index(max(a)))", "def largest_pair_sum(numbers): \n return sorted(numbers)[-2]+max(numbers)", "def largest_pair_sum(numbers):\n from heapq import nlargest\n return sum(nlargest(2, numbers))", "def largest_pair_sum(numbers): \n largest=-10000\n for nums in numbers:\n if nums>largest:\n largest=nums\n second_largest=-10000\n numbers.remove(largest)\n for nums in numbers:\n if nums>second_largest:\n second_largest=nums\n return largest+second_largest", "def largest_pair_sum(num): \n return num.pop(num.index(max(num))) + max(num)", "import math\n\ndef largest_pair_sum(numbers):\n a, b = -math.inf, -math.inf\n for n in numbers:\n if n > a:\n if a > b:\n b = a\n a = n\n elif n > b:\n b = n\n return a + b", "largest_pair_sum = lambda a: max(a) + sorted(a)[-2]", "def largest_pair_sum(numbers): \n # set swapped to true\n swapped = True\n # while loop if counter is not 1:\n while swapped:\n # set swapped to false and only stay in while loop if we swap in for loop\n swapped = False\n # loop thru nums using len of array - 1\n for i in range(len(numbers)-1):\n if numbers[i] > numbers[i + 1]:\n hold_value = numbers[i]\n numbers[i] = numbers[i+1]\n numbers[i+1] = hold_value\n swapped = True\n\n return numbers[-1] + numbers[-2]"] | {"fn_name": "largest_pair_sum", "inputs": [[[10, 14, 2, 23, 19]], [[-100, -29, -24, -19, 19]], [[1, 2, 3, 4, 6, -1, 2]], [[-10, -8, -16, -18, -19]]], "outputs": [[42], [0], [10], [-18]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,718 |
def largest_pair_sum(numbers):
|
c2eaa998f6a416b37e7266191e5534a7 | UNKNOWN | # Task
You are given an array `a` of positive integers a. You may choose some integer `X` and update `a` several times, where to update means to perform the following operations:
```
pick a contiguous subarray of length not greater than the given k;
replace all elements in the picked subarray with the chosen X.
```
What is the minimum number of updates required to make all the elements of the array the same?
# Example
For `a = [1, 2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 1] and k = 2`, the output should be `4`.
Here's how a will look like after each update:
```
[1, 2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 1] ->
[1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1] ->
[1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1] ->
[1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1] ->
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
```
# Input/Output
- `[input]` integer array `a`
An array of positive integers.
Constraints:
`10 ≤ a.length ≤ 50,`
`1 ≤ a[i] ≤ 10.`
- `[input]` integer `k`
A positive integer, the maximum length of a subarray.
Constraints: `2 ≤ k ≤ 9.`
- `[output]` an integer
The minimum number of updates. | ["def array_equalization(a, k):\n totals, ends = {}, {}\n for i, n in enumerate(a):\n if n not in ends: totals[n], ends[n] = 0, -1\n if i < ends[n]: continue\n count = (i - ends[n] - 1 + k - 1) // k\n totals[n] += count\n ends[n] = max(i, ends[n] + count * k)\n return min(t + (len(a) - ends[n] - 1 + k - 1) // k\n for n, t in totals.items() if ends[n] < len(a))", "def array_equalization(a, k):\n keys = set(a)\n ans = []\n for x in keys:\n i = 0\n c = 0\n while i < len(a):\n if a[i] == x:\n i += 1\n else:\n c += 1\n i += k\n ans.append(c)\n return min(ans)", "def array_equalization(a, n):\n MIn, l = [], len(a)\n for X in a:\n i, pa, c = 0, a[:], 0\n while i < len(pa):\n if pa[i] != X:\n pa[i:i + n] = [X] * min(n,l)\n c += 1\n i += 1\n MIn.append(c)\n return min(MIn)", "def array_equalization(a, k):\n sum = {}\n for i, n in enumerate(a):\n arr = sum.get(n)\n if not arr:\n sum[n] = [i]\n else:\n sum[n].append(i)\n print((list(sum.values())))\n \n times_arr = []\n for arr in list(sum.values()):\n i = 0\n pos = 0\n times = 0\n while 1:\n if i >= len(arr) or pos < arr[i]:\n pos += k\n times += 1\n elif pos == arr[i]:\n pos += 1\n i += 1\n else:\n i += 1\n if pos >= len(a):\n break\n times_arr.append(times)\n \n return min(times_arr)\n", "def array_equalization(a, k):\n min_ = float(\"inf\")\n for x in set(a):\n count = 0\n i = 0\n while i < len(a):\n if a[i] != x:\n count += 1\n i += k\n else:\n i += 1 \n min_ = min(count, min_)\n return min_\n", "def array_equalization(a, k):\n n, r = len(a), len(a)\n for x in set(a):\n i, t = 0, 0\n while i < n:\n if a[i] != x:\n t += 1\n i += k\n else:\n i += 1\n r = min(r, t)\n return r", "def array_equalization(a, k):\n counter = 0\n arr = []\n m = 0\n print(a, k)\n for x in range(11):\n m = x\n lst = a.copy()\n counter = 0\n for i in range(len(lst)):\n if lst[i] != m and i + k <= len(lst):\n counter += 1\n for j in range(i, i + k):\n if lst[j] != m:\n lst[j] = m\n elif lst[i] != m and i + k > len(lst):\n counter += 1\n for j in range(i, len(lst)):\n if lst[j] != m:\n lst[j] = m\n arr.append(counter)\n \n \n return min(arr)", "def array_equalization(a, k):\n l_a=len(a)\n if k>=l_a-1:\n return 1\n sa=set(a)\n times_list=[]\n for i in sa:\n templs=[]\n times = 0\n for j in range(0,l_a):\n if (j>0 and j ==len(templs)) or j==0 :\n if a[j] == i:\n templs.append(i)\n else:\n templs+=[i]*k\n times+=1\n times_list.append([times])\n return min(times_list)[0]", "def array_equalization(a, k):\n m = n = len(a)\n for number in set(a):\n c = 0\n i = 0\n while i < n:\n if a[i] != number:\n c += 1\n i += k\n else:\n i += 1\n m = min(c,m)\n return m", "from collections import Counter\n\ndef array_equalization(a, k):\n n = len(a)\n freq = Counter(a)\n m = n\n for number in freq.keys():\n c = 0\n i = 0\n while i < len(a):\n if a[i] != number:\n c += 1\n i += k\n else:\n i += 1\n m = min(c,m)\n return m"] | {"fn_name": "array_equalization", "inputs": [[[1, 2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 1], 2], [[5, 2, 3, 5, 2, 2, 3, 5, 1, 2, 5, 1, 2, 5, 3], 7], [[1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1], 9]], "outputs": [[4], [2], [1]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 4,146 |
def array_equalization(a, k):
|
1bdf333f6b9fcf1189ba58d729db5715 | UNKNOWN | In this kata you are given an array to sort but you're expected to start sorting from a specific position of the array (in ascending order) and optionally you're given the number of items to sort.
#### Examples:
```python
sect_sort([1, 2, 5, 7, 4, 6, 3, 9, 8], 2) //=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
sect_sort([9, 7, 4, 2, 5, 3, 1, 8, 6], 2, 5) //=> [9, 7, 1, 2, 3, 4, 5, 8, 6]
```
#### Documentation:
```python
sect_sort(array, start, length);
```
- array - array to sort
- start - position to begin sorting
- length - number of items to sort (optional)
if the **length** argument is not passed or is zero, you sort all items to the right of the start postiton in the array | ["def sect_sort(lst, start, length=0):\n end = start + length if length else len(lst)\n return lst[:start] + sorted(lst[start:end]) + lst[end:]", "def sect_sort(arr, start, num=0):\n out = arr[:]\n s = slice(start, None if not num else start + num)\n out[s] = sorted(out[s])\n return out", "def sect_sort(arr, st, ln=0):\n return arr[:st] + ( sorted(arr[st:st+ln]) + arr[st+ln:] if ln else sorted(arr[st:]) )", "def sect_sort(array, start, length=-1):\n if length == -1:\n length = len(array) - start\n if length == 0:\n length = 1\n return array[0:start] + sorted(array[start:start+length]) + array[start+length:]", "def sect_sort(a, b=0, c=0):\n c = len(a) if not c else b + c\n return a[:b] + sorted(a[b:c]) + a[c:]", "def sect_sort(array, start, end = 0):\n e = start + end if end else None\n array[start:e] = sorted(array[start:e])\n return array", "def sect_sort(a, s, l=None):\n if l:\n return a[:s] + sorted(a[s:s+l]) + a[s+l:]\n return a[:s] + sorted(a[s:])", "def sect_sort(l, ind, n=-1):\n if(n > 0):\n \n s = sorted(l[ind:ind+n])\n return l[0:ind] + s + l[ind+n:]\n else:\n s = sorted(l[ind:])\n return l[0:ind] + s", "sect_sort=lambda arr,s,l=None: (lambda l: arr[:s]+sorted(arr[s:s+l])+arr[s+l:])(len(arr) if not l else l)", "def sect_sort(*args):\n if len(args)==2:\n lst, start=args\n res=lst[:start]+sorted(lst[start:])\n else:\n lst, start, size=args\n if size==0:\n res=lst[:start]+sorted(lst[start:])\n else:\n res=lst[:start]+sorted(lst[start:start+size])+lst[start+size:]\n return res"] | {"fn_name": "sect_sort", "inputs": [[[1, 2, 5, 7, 4, 6, 3, 9, 8], 2], [[1, 2, 5, 7, 4, 6, 3, 9, 8], 8], [[9, 7, 4, 2, 5, 3, 1, 8, 6], 2, 5], [[1, 2, 5, 7, 4, 6, 3, 9, 8], 8, 3], [[], 0]], "outputs": [[[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1, 2, 5, 7, 4, 6, 3, 9, 8]], [[9, 7, 1, 2, 3, 4, 5, 8, 6]], [[1, 2, 5, 7, 4, 6, 3, 9, 8]], [[]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,687 |
def sect_sort(lst, start, length=0):
|
878974ac2629b9124463bfc75745fa11 | UNKNOWN | "Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.
## Task
Given two points P and Q, output the symmetric point of point P about Q.
Each argument is a two-element array of integers representing the point's X and Y coordinates. Output should be in the same format, giving the X and Y coordinates of point P1. You do not have to validate the input.
This kata was inspired by the Hackerrank challenge [Find Point](https://www.hackerrank.com/challenges/find-point) | ["def symmetric_point(p, q):\n return [2*q[0] - p[0], 2*q[1] - p[1]]", "symmetric_point = lambda p, q: [2 * b - a for a, b in zip(p, q)]", "def symmetric_point(p, q):\n # your code here\n p1x = (q[0] - p[0]) + q[0]\n p1y = (q[1] - p[1]) + q[1]\n return [p1x, p1y]", "symmetric_point = lambda p,q: [2*q[0] - p[0], 2*q[1] - p[1]]", "def symmetric_point(p, q):\n #this supposed to be a programing challenge not math\n return [2*q[0]-p[0], 2*q[1]-p[1]]", "def symmetric_point(p, q):\n # your code here\n return [a*2-b for a,b in zip(q,p)]", "def symmetric_point(p, q):\n return list(b * 2 - a for a, b in zip(p, q))", "def symmetric_point(p, q):\n dx = q[0] - p[0]\n dy = q[1] - p[1]\n return [q[0]+dx, q[1]+dy]", "def symmetric_point(p, q):\n # your code here\n return [q[0] + q[0]-p[0], q[1] + q[1] - p[1]]", "def symmetric_point(p, q):\n return [2 * q[i] - p[i] for i in range(2)]", "def symmetric_point(p, center):\n px, py = p\n cx, cy = center\n return [cx - (px - cx), cy - (py - cy)]\n", "def symmetric_point(p, q):\n return [2 * q[i] - p[i] for i in range(0,len(p))]", "def symmetric_point(p, q):\n return [q[i]*2-p[i] for i in range(2)]", "from typing import List\n\ndef symmetric_point(p: List[int], q: List[int]) -> List[int]:\n \"\"\" Get the symmetric point of point P about Q. \"\"\"\n return [2 * q[0] - p[0], 2 * q[1] - p[1]]", "def symmetric_point(p, q):\n result = [p[0],q[0]]\n if(p[0] > q[0]):\n result[0] = fromRightToLeft(p[0],q[0])\n else:\n result[0] = fromLeftToRight(p[0],q[0])\n if(p[1] > q[1]):\n result[1] = fromUpToDown(p[1],q[1])\n else:\n result[1] = fromDownToUp(p[1],q[1])\n return result\ndef fromRightToLeft(p,q):\n return q-abs(p-q)\ndef fromLeftToRight(p,q):\n return q+abs(p-q)\ndef fromUpToDown(p,q):\n return q-abs(p-q)\ndef fromDownToUp(p,q):\n return q+abs(p-q)", "from operator import sub\ndef symmetric_point(p, q):\n qp = list(map(sub, p, q))\n return list(map(sub, q, qp))", "def symmetric_point(p, q):\n return [b + (b - a) for a, b in zip(p, q)]", "def symmetric_point(p, q):\n return list(map(lambda a, b: a + b, q, list(map(lambda a, b: b - a, p, q))))\n", "symmetric_point = lambda point, ref : [2 * ref[0] - point[0], 2 * ref[1] - point[1]]", "import numpy as np\ndef symmetric_point(p, q):\n \n d = list(np.add(q,np.subtract(q,p)))\n \n return d", "symmetric_point = lambda *a: [2 * q - p for p, q in zip(*a)]", "def symmetric_point(p, q):\n p_1 = []\n dx = p[0] - q[0]\n dy = p[1] - q[1]\n p_1.append(q[0] - dx)\n p_1.append(q[1] - dy)\n return p_1", "symmetric_point = lambda p, q: [2 * y -x for x, y in zip(p,q)]\n", "def symmetric_point(p, q):\n return [2*q[0]-p[0], 2*q[1]-p[1]]\n \n \n \n'''Given two points P and Q, output the symmetric point of point P about Q.\nEach argument is a two-element array of integers representing the point's X and Y coordinates.\nOutput should be in the same format, giving the X and Y coordinates of point P1.'''", "symmetric_point = lambda p, q: [r+r-s for s,r in zip(p, q)]", "def symmetric_point(p, q):\n distance = q[0]-p[0], q[1]-p[1]\n symetric = [q[0] + distance[0], q[1] + distance[1]]\n return symetric", "def symmetric_point(p, q):\n x1, y1 = p\n x2, y2 = q\n x3, y3 = (x2-x1)+x2, (y2-y1) +y2\n return [x3,y3]", "def symmetric_point(p, q):\n try:\n (a,b),(c,d) = p,q\n x = c-a+c\n m = (d-b)/(c-a)\n i = b-m*a\n return [x,round(m*x+i)]\n except:\n return [0,0]", "def symmetric_point(p, q):\n dist_x = p[0] - q[0]\n dist_y = p[1] - q[1]\n return [q[0]-dist_x, q[1]-dist_y]", "def symmetric_point(p, q):\n distance_to_p_x = p[0] - q[0]\n distance_to_p_y = p[1] - q[1]\n \n return [q[0] - distance_to_p_x, q[1] - distance_to_p_y]", "def symmetric_point(p, q):\n # your code her\n \n return [2*q[0]-p[0],2*q[1]-p[1]]\n", "def symmetric_point(p, q):\n return [p[0] * - 1 + q[0] * 2, p[1] * - 1 + q[1] * 2]", "def symmetric_point(p, q):\n pointslist = []\n difference = q[0] - p[0]\n newpoint = q[0] + difference\n difference2 = q[1] - p[1]\n newpoint2 = q[1] + difference2\n pointslist.append(newpoint)\n pointslist.append(newpoint2)\n return pointslist", "def symmetric_point(p, q):\n x = [0,0]\n \n x[0] = 2 * q[0] - p[0]\n x[1] = 2 * q[1] - p[1]\n \n return x", "def symmetric_point(p, q):\n x = []\n x.append(2 * q[0] - p[0])\n x.append(2 * q[1] - p[1])\n return x", "def symmetric_point(p, q):\n \n difference = []\n\n\n zip_object = zip(p, q)\n for p, q in zip_object:\n difference.append(2*q-p)\n \n \n return(difference)", "def symmetric_point(p, q):\n # q est\u00e1 siempre en medio\n\n return [(2*q[0]) - p[0], (2*q[1]) - p[1] ]", "def symmetric_point(p, q):\n x = q[0] - p[0]\n x = q[0] + x\n y = q[1] - p[1]\n y = q[1] + y\n return [x,y]\n", "def symmetric_point(p, q):\n d1=q[0]-p[0]\n d2=q[1]-p[1]\n return [q[0]+d1, q[1]+d2]", "def symmetric_point(p, q):\n \n #Find the difference between midpoint Q and initial point P\n #Add this difference to the midpoint to find end point P1\n #Compatible with negative points\n \n p1x = q[0]+(q[0]-p[0])\n p1y = q[1]+(q[1]-p[1])\n return [p1x,p1y]", "def symmetric_point(p, q):\n if q[0] > p[0]:\n x = q[0] + abs(q[0] - p[0])\n elif q[0] < p[0]:\n x = q[0] - abs(p[0] - q[0])\n else:\n x = p[0]\n if q[1] > p[1]:\n y = q[1] + abs(q[1] - p[1])\n elif q[1] < p[1]:\n y = q[1] - abs(p[1] - q[1])\n else:\n y = p[1] \n return [x, y]", "def symmetric_point(p, q):\n return [ 2*(-p[0]/2 + q[0]) , 2*(-p[1]/2 + q[1]) ]", "def symmetric_point(p, q):\n new_point = [2*q[0] - p[0], 2*q[1] - p[1]]\n return new_point", "def symmetric_point(p, q):\n\n distance = []\n for a, b in zip(p, q):\n if a > 0 and b > 0:\n distance.append(abs(a-b))\n elif a < 0 and b < 0:\n distance.append(abs(abs(a)-abs(b)))\n else:\n distance.append(abs(a)+abs(b))\n \n final_point = []\n for i, c, d in zip([0, 1],q, distance):\n if p[i] > 0 and q[i] > 0 or p[i] < 0 and q[i] < 0:\n if abs(p[i]) < abs(q[i]):\n final_point.append(abs(c)+d) \n else:\n final_point.append(abs(c)-d)\n else:\n final_point.append(abs(c)+abs(d))\n \n \n return [x * -1 if q[i] < 0 else x for i, x in enumerate(final_point)]\n", "def symmetric_point(p, q):\n # your code here\n r = [2*q[0]-p[0],2*q[1]-p[1]]\n return r", "symmetric_point=lambda p,q:[-p[0]+2*q[0],-p[1]+2*q[1]]", "def symmetric_point(p, q):\n return [2 * m - a for a, m in zip(p, q)]", "def symmetric_point(p, q):\n a = q[0]-abs(p[0]-q[0]) if p[0] > q[0] else q[0]+(q[0]-p[0])\n b = q[1]-abs(p[1]-q[1]) if p[1] > q[1] else q[1]+(q[1]-p[1])\n return [a, b]", "def symmetric_point(p, q):\n return [abs(p[i]-q[i]) + q[i] if p[i]<q[i] else q[i] - abs(p[i]-q[i]) for i in [0,1]]", "def symmetric_point(p, q):\n # your code here\n x = q[0] - p[0]\n y = q[1] - p[1]\n return [q[0]+x,q[1]+y]", "def symmetric_point(p, q):\n # your code here\n a = [0,0]\n a[0] = q[0] - abs(p[0]-q[0]) if (p[0] > q[0]) else q[0] + abs(p[0]-q[0])\n a[1] = q[1] - abs(p[1]-q[1]) if p[1] > q[1] else q[1] + abs(p[1]-q[1]) \n return a", "def symmetric_point(p, q):\n # your code here\n q[0]+(q[0]-p[0])\n return [q[0]+(q[0]-p[0]),q[1]+(q[1]-p[1])]", "def symmetric_point(p, q):\n # your code here\n [a,b] = p\n [c,d] = q\n p = c - a\n q = d - b\n return [c+p,d+q]", "def symmetric_point(p, q):\n deltax = q[0]-p[0]\n deltay = q[1]-p[1]\n p1 = []\n p1.append(q[0]+deltax)\n p1.append(q[1]+deltay)\n return p1", "def symmetric_point(p, q):\n q[0] += q[0] - p[0]\n q[1] += q[1] - p[1]\n return q", "def symmetric_point(p, q):\n\n return([2 * a - b for a, b in zip(q, p)])\n \n # Most elegant way :))\n", "def symmetric_point(p, q):\n\n return([2 * q[x] - p[x] for x in range(len(q))])", "def symmetric_point(p, q):\n xnew = q[0] + (q[0] - p[0])\n ynew = q[1] + (q[1] - p[1])\n return [xnew, ynew]", "import numpy as np\ndef symmetric_point(p, q):\n npp = np.array(p)\n npq = np.array(q)\n return (npq - npp + npq).tolist()", "def symmetric_point(p, q):\n xp, yp, xq, yq = p+q\n xd, yd = abs(xp-xq), abs(yp-yq)\n return [xq+(xd if xp<xq else -xd), yq+(yd if yp<yq else -yd)]", "def symmetric_point(p, q):\n # your code here\n return [(-1)*p[0]+2*q[0],(-1)*(p[1]+(-2)*q[1])]", "def symmetric_point(p, q):\n # your code here\n return [\n q[0] + (q[0] - p[0]), # x\n q[1] + (q[1] - p[1]), # y\n ]", "def symmetric_point(p, q):\n vertical_d = q[1] - p[1]\n horiz_d = q[0] - p[0]\n vertical_d = vertical_d * -1\n horiz_d = horiz_d * -1\n x = q[0] - horiz_d\n y = q[1] - vertical_d\n return [x,y]\n", "def symmetric_point(p, q):\n px, py = p\n qx, qy = q\n xdist = px - qx\n ydist = py - qy\n return [qx - xdist, qy - ydist]", "def symmetric_point(p, q):\n x1, y1 = p\n p1, p2 = q\n\n x2 = p1*2-x1\n y2 = p2*2-y1\n return [x2, y2]", "def symmetric_point(p, q):\n x1, y1 = p\n x2, y2 = q\n return [x2 + x2 - x1, y2 + y2 - y1]", "def symmetric_point(p, q):\n dx = q[0] - p[0]\n dy = q[1] - p[1]\n nx = dx + q[0]\n ny = dy + q[1]\n return [nx, ny]", "def symmetric_point(p, q):\n # your code here\n return [2*q[i]-p[i] for i in range(len(p))]", "def symmetric_point(p, q):\n xpos = p[0] < q[0]\n ypos = p[1] < q[1]\n xdiff = max(p[0], q[0]) - min(p[0], q[0])\n ydiff = max(p[1], q[1]) - min(p[1], q[1])\n if xpos: x = q[0] + xdiff\n if not xpos: x = q[0] - xdiff\n if ypos: y = q[1] + ydiff\n if not ypos: y = q[1] - ydiff\n return [x, y]", "def symmetric_point(p, q):\n # your code here\n return [q[0]*2+p[0]*-1,(q[1]*2)+p[1]*-1]", "def symmetric_point(p, q):\n arr = []\n for i in zip(p, q):\n x = i[1] - i[0]\n arr.append(i[1] + x)\n return arr \n", "def symmetric_point(p, q):\n c = int(q[0] + (q[0] - p[0])) \n d = int(q[1] + (q[1] - p[1]))\n return [c, d]", "def symmetric_point(p, q):\n # your code here\n\n r1 = -(p[0] - q[0] - q[0])\n r2 = -(p[1] - q[1] - q[1])\n \n return [r1, r2]", "def symmetric_point(p, q):\n return [2 * x[1] - x[0] for x in zip (p, q)]", "def symmetric_point(p, q):\n P1=[(2*q[0]- p[0]),(2*q[1]-p[1]) ]\n return P1", "def symmetric_point(p, q):\n a, b, c, d = p + q\n return [c * 2 - a, d * 2 - b]", "def symmetric_point(p, q):\n dist_x = q[0] - p[0]\n dist_y = q[1] - p[1]\n \n p1_x = q[0] + dist_x\n p2_x = q[1] + dist_y\n \n return [p1_x, p2_x]", "def symmetric_point(p, q):\n x = p[0] - 2*q[0]\n y = p[1] - 2*q[1]\n return [-x,-y] ", "def symmetric_point(p, q):\n r = []\n r.append(q[0] - p[0] + q[0])\n r.append(q[1] - p[1] + q[1])\n return r", "def symmetric_point(p, q):\n return [2*q[0]-p[0],2*q[1]-p[1]]\n#Solved on 26th Sept,2019 at 07:07 PM.\n", "def symmetric_point(p, q):\n if p[0]>q[0]:\n x0=q[0]-(p[0]-q[0])\n if p[1]>q[1]:\n y0=q[1]-(p[1]-q[1])\n return [x0,y0]\n else:\n y0=q[1]-(p[1]-q[1])\n return [x0,y0]\n else:\n x0=q[0]-(p[0]-q[0])\n if p[1]>q[1]:\n y0=q[1]-(p[1]-q[1])\n return [x0,y0]\n else:\n y0=q[1]-(p[1]-q[1])\n return [x0,y0]", "def symmetric_point(a, b):\n # your code here\n return [2*b[0]-a[0],2*b[1]-a[1]]", "def symmetric_point(a,b):\n return([(-a[0]+2*b[0]),(-a[1]+2*b[1])])", "def symmetric_point(p, q):\n reflected_x = q[0] + (q[0] - p[0])\n\n try:\n slope = (q[1] - p[1]) / (q[0] - p[0])\n b = p[1] - slope * p[0]\n\n reflected_y = slope * reflected_x + b\n\n except ZeroDivisionError:\n reflected_y = p[1]\n\n return [round(reflected_x), round(reflected_y)]\n", "def symmetric_point(p, q):\n p2_x = p[0]+2*(q[0]-p[0])\n p2_y = p[1]+2*(q[1]-p[1])\n return [p2_x, p2_y]", "def symmetric_point(p, q):\n a=q[0]-p[0]\n b=q[1]-p[1]\n c=a+q[0]\n d=b+q[1]\n return [c,d] #I solved this Kata on [1-Sept-2019] ^_^ [07:10 AM]...#Hussam'sCodingDiary", "def symmetric_point(p, q):return[2*q[i]-p[i]for i in(0,1)]", "def symmetric_point(p, q):return[q[i]+abs(p[i]-q[i])if p[i]<q[i]else q[i]-abs(p[i]-q[i])if p[i]>q[i]else q[i] for i in (0,1)]", "def symmetric_point(p, q):\n y=2*q[1]-p[1]\n x=2*q[0]-p[0]\n return [x, y]", "import operator\ndef symmetric_point(p, q):\n return [i*-1+j*2 for i,j in zip(p,q)]", "def symmetric_point(p, q):\n x1=int(str(p).split(',')[0].split('[')[1])\n y1=int(str(p).split(',')[1].split(']')[0])\n x2=int(str(q).split(',')[0].split('[')[1])\n y2=int(str(q).split(',')[1].split(']')[0])\n \n return [x2+(x2-x1), y2+(y2-y1)]", "def symmetric_point(p, q):\n delta_x, delta_y = abs(q[0] - p[0]), abs(q[1] - p[1])\n return [\n q[0] + delta_x if p[0] < q[0] else q[0] - delta_x\n , q[1] + delta_y if p[1] < q[1] else q[1] - delta_y\n ]", "def symmetric_point(p, q):\n return [(-p[0]+2*q[0]),(-p[1]+2*q[1])]", "def symmetric_point(p, q):\n\n# the following equality must be satisfied\n# q -p = q -p' \n\n p_simx = q[0] -p[0]\n p_simy = q[1] -p[1]\n\n return [q[0] -(-p_simx), q[1] -(-p_simy)]\n", "def symmetric_point(p, q):\n return [y+(y-x) for x, y in zip(p,q)]"] | {"fn_name": "symmetric_point", "inputs": [[[0, 0], [1, 1]], [[2, 6], [-2, -6]], [[10, -10], [-10, 10]], [[1, -35], [-12, 1]], [[1000, 15], [-7, -214]], [[0, 0], [0, 0]]], "outputs": [[[2, 2]], [[-6, -18]], [[-30, 30]], [[-25, 37]], [[-1014, -443]], [[0, 0]]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 13,833 |
def symmetric_point(p, q):
|
9307d9b350a1f4aa9f79cc5510542447 | UNKNOWN | Consider a sequence made up of the consecutive prime numbers. This infinite sequence would start with:
```python
"2357111317192329313741434753596167717379..."
```
You will be given two numbers: `a` and `b`, and your task will be to return `b` elements starting from index `a` in this sequence.
```
For example:
solve(10,5) == `19232` Because these are 5 elements from index 10 in the sequence.
```
Tests go up to about index `20000`.
More examples in test cases. Good luck!
Please also try [Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2) | ["def solve(a, b):\n primes = \"2357111317192329313741434753596167717379838997101103107109113127131137139149151157163167173179181191193197199211223227229233239241251257263269271277281283293307311313317331337347349353359367373379383389397401409419421431433439443449457461463467479487491499503509521523541547557563569571577587593599601607613617619631641643647653659661673677683691701709719727733739743751757761769773787797809811821823827829839853857859863877881883887907911919929937941947953967971977983991997100910131019102110311033103910491051106110631069108710911093109711031109111711231129115111531163117111811187119312011213121712231229123112371249125912771279128312891291129713011303130713191321132713611367137313811399140914231427142914331439144714511453145914711481148314871489149314991511152315311543154915531559156715711579158315971601160716091613161916211627163716571663166716691693169716991709172117231733174117471753175917771783178717891801181118231831184718611867187118731877187918891901190719131931193319491951197319791987199319971999200320112017202720292039205320632069208120832087208920992111211321292131213721412143215321612179220322072213222122372239224322512267226922732281228722932297230923112333233923412347235123572371237723812383238923932399241124172423243724412447245924672473247725032521253125392543254925512557257925912593260926172621263326472657265926632671267726832687268926932699270727112713271927292731274127492753276727772789279127972801280328192833283728432851285728612879288728972903290929172927293929532957296329692971299930013011301930233037304130493061306730793083308931093119312131373163316731693181318731913203320932173221322932513253325732593271329933013307331333193323332933313343334733593361337133733389339134073413343334493457346134633467346934913499351135173527352935333539354135473557355935713581358335933607361336173623363136373643365936713673367736913697370137093719372737333739376137673769377937933797380338213823383338473851385338633877388138893907391139173919392339293931394339473967398940014003400740134019402140274049405140574073407940914093409941114127412941334139415341574159417742014211421742194229423142414243425342594261427142734283428942974327433743394349435743634373439143974409442144234441444744514457446344814483449345074513451745194523454745494561456745834591459746034621463746394643464946514657466346734679469147034721472347294733475147594783478747894793479948014813481748314861487148774889490349094919493149334937494349514957496749694973498749934999500350095011502150235039505150595077508150875099510151075113511951475153516751715179518951975209522752315233523752615273527952815297530353095323533353475351538153875393539954075413541754195431543754415443544954715477547954835501550355075519552155275531555755635569557355815591562356395641564756515653565756595669568356895693570157115717573757415743574957795783579158015807581358215827583958435849585158575861586758695879588158975903592359275939595359815987600760116029603760436047605360676073607960896091610161136121613161336143615161636173619761996203621162176221622962476257626362696271627762876299630163116317632363296337634363536359636163676373637963896397642164276449645164696473648164916521652965476551655365636569657165776581659966076619663766536659666166736679668966916701670367096719673367376761676367796781679167936803682368276829683368416857686368696871688368996907691169176947694969596961696769716977698369916997700170137019702770397043705770697079710371097121712771297151715971777187719372077211721372197229723772437247725372837297730773097321733173337349735173697393741174177433745174577459747774817487748974997507751775237529753775417547754975597561757375777583758975917603760776217639764376497669767376817687769176997703771777237727774177537757775977897793781778237829784178537867787378777879788379017907791979277933793779497951796379938009801180178039805380598069808180878089809381018111811781238147816181678171817981918209821982218231823382378243826382698273828782918293829783118317832983538363836983778387838984198423842984318443844784618467850185138521852785378539854385638573858185978599860986238627862986418647866386698677868186898693869987078713871987318737874187478753876187798783880388078819882188318837883988498861886388678887889389238929893389418951896389698971899990019007901190139029904190439049905990679091910391099127913391379151915791619173918191879199920392099221922792399241925792779281928392939311931993239337934193439349937193779391939794039413941994219431943394379439946194639467947394799491949795119521953395399547955195879601961396199623962996319643964996619677967996899697971997219733973997439749976797699781978797919803981198179829983398399851985798599871988398879901990799239929993199419949996799731000710009100371003910061100671006910079100911009310099101031011110133101391014110151101591016310169101771018110193102111022310243102471025310259102671027110273102891030110303103131032110331103331033710343103571036910391103991042710429104331045310457104591046310477104871049910501105131052910531105591056710589105971060110607106131062710631106391065110657106631066710687106911070910711107231072910733107391075310771107811078910799108311083710847108531085910861108671088310889108911090310909109371093910949109571097310979109871099311003110271104711057110591106911071110831108711093111131111711119111311114911159111611117111173111771119711213112391124311251112571126111273112791128711299113111131711321113291135111353113691138311393113991141111423114371144311447114671147111483114891149111497115031151911527115491155111579115871159311597116171162111633116571167711681116891169911701117171171911731117431177711779117831178911801118071181311821118271183111833118391186311867118871189711903119091192311927119331193911941119531195911969119711198111987120071201112037120411204312049120711207312097121011210712109121131211912143121491215712161121631219712203122111222712239122411225112253122631226912277122811228912301123231232912343123471237312377123791239112401124091241312421124331243712451124571247312479124871249112497125031251112517125271253912541125471255312569125771258312589126011261112613126191263712641126471265312659126711268912697127031271312721127391274312757127631278112791127991280912821128231282912841128531288912893128991290712911129171291912923129411295312959129671297312979129831300113003130071300913033130371304313049130631309313099131031310913121131271314713151131591316313171131771318313187132171321913229132411324913259132671329113297133091331313327133311333713339133671338113397133991341113417134211344113451134571346313469134771348713499135131352313537135531356713577135911359713613136191362713633136491366913679136811368713691136931369713709137111372113723137291375113757137591376313781137891379913807138291383113841138591387313877138791388313901139031390713913139211393113933139631396713997139991400914011140291403314051140571407114081140831408714107141431414914153141591417314177141971420714221142431424914251142811429314303143211432314327143411434714369143871438914401144071441114419144231443114437144471444914461144791448914503145191453314537145431454914551145571456114563145911459314621146271462914633146391465314657146691468314699147131471714723147311473714741147471475314759147671477114779147831479714813148211482714831148431485114867148691487914887148911489714923149291493914947149511495714969149831501315017150311505315061150731507715083150911510115107151211513115137151391514915161151731518715193151991521715227152331524115259152631526915271152771528715289152991530715313153191532915331153491535915361153731537715383153911540115413154271543915443154511546115467154731549315497155111552715541155511555915569155811558315601156071561915629156411564315647156491566115667156711567915683157271573115733157371573915749157611576715773157871579115797158031580915817158231585915877158811588715889159011590715913159191592315937159591597115973159911600116007160331605716061160631606716069160731608716091160971610316111161271613916141161831618716189161931621716223162291623116249162531626716273163011631916333163391634916361163631636916381164111641716421164271643316447164511645316477164811648716493165191652916547165531656116567165731660316607166191663116633166491665116657166611667316691166931669916703167291674116747167591676316787168111682316829168311684316871168791688316889169011690316921169271693116937169431696316979169811698716993170111702117027170291703317041170471705317077170931709917107171171712317137171591716717183171891719117203172071720917231172391725717291172931729917317173211732717333173411735117359173771738317387173891739317401174171741917431174431744917467174711747717483174891749117497175091751917539175511756917573175791758117597175991760917623176271765717659176691768117683177071771317729177371774717749177611778317789177911780717827178371783917851178631788117891179031790917911179211792317929179391795717959179711797717981179871798918013180411804318047180491805918061180771808918097181191812118127181311813318143181491816918181181911819918211182171822318229182331825118253182571826918287182891830118307183111831318329183411835318367183711837918397184011841318427184331843918443184511845718461184811849318503185171852118523185391854118553185831858718593186171863718661186711867918691187011871318719187311874318749187571877318787187931879718803188391885918869188991891118913189171891918947189591897318979190011900919013190311903719051190691907319079190811908719121191391914119157191631918119183192071921119213192191923119237192491925919267192731928919301193091931919333193731937919381193871939119403194171942119423194271942919433194411944719457194631946919471194771948319489195011950719531195411954319553195591957119577195831959719603196091966119681196871969719699197091971719727197391975119753197591976319777197931980119813198191984119843198531986119867198891989119913199191992719937199491996119963199731997919991199931999720011200212002320029200472005120063200712008920101201072011320117201232012920143201472014920161201732017720183202012021920231202332024920261202692028720297203232032720333203412034720353203572035920369203892039320399204072041120431204412044320477204792048320507205092052120533205432054920551205632059320599206112062720639206412066320681206932070720717207192073120743207472074920753207592077120773207892080720809208492085720873208792088720897208992090320921209292093920947209592096320981209832100121011210132101721019210232103121059210612106721089211012110721121211392114321149211572116321169211792118721191211932121121221212272124721269212772128321313213172131921323213412134721377213792138321391213972140121407214192143321467214812148721491214932149921503215172152121523215292155721559215632156921577215872158921599216012161121613216172164721649216612167321683217012171321727217372173921751217572176721773217872179921803218172182121839218412185121859218632187121881218932191121929219372194321961219772199121997220032201322027220312203722039220512206322067220732207922091220932210922111221232212922133221472215322157221592217122189221932222922247222592227122273222772227922283222912230322307223432234922367223692238122391223972240922433224412244722453224692248122483225012251122531225412254322549225672257122573226132261922621226372263922643226512266922679226912269722699227092271722721227272273922741227512276922777227832278722807228112281722853228592286122871228772290122907229212293722943229612296322973229932300323011230172302123027230292303923041230532305723059230632307123081230872309923117231312314323159231672317323189231972320123203232092322723251232692327923291232932329723311233212332723333233392335723369233712339923417234312344723459234732349723509235312353723539235492355723561235632356723581235932359923603236092362323627236292363323663236692367123677236872368923719237412374323747237532376123767237732378923801238132381923827238312383323857238692387323879238872389323899239092391123917239292395723971239772398123993240012400724019240232402924043240492406124071240772408324091240972410324107241092411324121241332413724151241692417924181241972420324223242292423924247242512428124317243292433724359243712437324379243912440724413244192442124439244432446924473244812449924509245172452724533245472455124571245932461124623246312465924671246772468324691246972470924733247492476324767247812479324799248092482124841248472485124859248772488924907249172491924923249432495324967249712497724979249892501325031250332503725057250732508725097251112511725121251272514725153251632516925171251832518925219252292523725243252472525325261253012530325307253092532125339253432534925357253672537325391254092541125423254392544725453254572546325469254712552325537255412556125577255792558325589256012560325609256212563325639256432565725667256732567925693257032571725733257412574725759257632577125793257992580125819258412584725849258672587325889259032591325919259312593325939259432595125969259812599725999260032601726021260292604126053260832609926107261112611326119261412615326161261712617726183261892620326209262272623726249262512626126263262672629326297263092631726321263392634726357263712638726393263992640726417264232643126437264492645926479264892649726501265132653926557265612657326591265972662726633266412664726669266812668326687266932669926701267112671326717267232672926731267372675926777267832680126813268212683326839268492686126863268792688126891268932690326921269272694726951269532695926981269872699327011270172703127043270592706127067270732707727091271032710727109271272714327179271912719727211272392724127253272592727127277272812728327299273292733727361273672739727407274092742727431274372744927457274792748127487275092752727529275392754127551275812758327611276172763127647276532767327689276912769727701277332773727739277432774927751277632776727773277792779127793277992780327809278172782327827278472785127883278932790127917279192794127943279472795327961279672798327997280012801928027280312805128057280692808128087280972809928109281112812328151281632818128183282012821128219282292827728279282832828928297283072830928319283492835128387283932840328409284112842928433284392844728463284772849328499285132851728537285412854728549285592857128573285792859128597286032860728619286212862728631286432864928657286612866328669286872869728703287112872328729287512875328759287712878928793288072881328817288372884328859288672887128879289012890928921289272893328949289612897929009290172902129023290272903329059290632907729101291232912929131291372914729153291672917329179291912920129207292092922129231292432925129269292872929729303293112932729333293392934729363293832938729389293992940129411294232942929437294432945329473294832950129527295312953729567295692957329581295872959929611296292963329641296632966929671296832971729723297412975329759297612978929803298192983329837298512986329867298732987929881299172992129927299472995929983299893001130013300293004730059300713008930091300973010330109301133011930133301373013930161301693018130187301973020330211302233024130253302593026930271302933030730313303193032330341303473036730389303913040330427304313044930467304693049130493304973050930517305293053930553305573055930577305933063130637306433064930661306713067730689306973070330707307133072730757307633077330781308033080930817308293083930841308513085330859308693087130881308933091130931309373094130949309713097730983310133101931033310393105131063310693107931081310913112131123311393114731151311533115931177311813118331189311933121931223312313123731247312493125331259312673127131277313073131931321313273133331337313573137931387313913139331397314693147731481314893151131513315173153131541315433154731567315733158331601316073162731643316493165731663316673168731699317213172331727317293174131751317693177131793317993181731847318493185931873318833189131907319573196331973319813199132003320093202732029320513205732059320633206932077320833208932099321173211932141321433215932173321833218932191322033221332233322373225132257322613229732299323033230932321323233232732341323533235932363323693237132377323813240132411324133242332429324413244332467324793249132497325033250732531325333253732561325633256932573325793258732603326093261132621326333264732653326873269332707327133271732719327493277132779327833278932797328013280332831328333283932843328693288732909329113291732933329393294132957329693297132983329873299332999330133302333029330373304933053330713307333083330913310733113331193314933151331613317933181331913319933203332113322333247332873328933301333113331733329333313334333347333493335333359333773339133403334093341333427334573346133469334793348733493335033352133529335333354733563335693357733581335873358933599336013361333617336193362333629336373364133647336793370333713337213373933749337513375733767337693377333791337973380933811338273382933851338573386333871338893389333911339233393133937339413396133967339973401934031340333403934057340613412334127341293414134147341573415934171341833421134213342173423134253342593426134267342733428334297343013430334313343193432734337343513436134367343693438134403344213442934439344573446934471344833448734499345013451134513345193453734543345493458334589345913460334607346133463134649346513466734673346793468734693347033472134729347393474734757347593476334781348073481934841348433484734849348713487734883348973491334919349393494934961349633498135023350273505135053350593506935081350833508935099351073511135117351293514135149351533515935171352013522135227352513525735267352793528135291353113531735323353273533935353353633538135393354013540735419354233543735447354493546135491355073550935521355273553135533355373554335569355733559135593355973560335617356713567735729357313574735753357593577135797358013580335809358313583735839358513586335869358793589735899359113592335933359513596335969359773598335993359993600736011360133601736037360613606736073360833609736107361093613136137361513616136187361913620936217362293624136251362633626936277362933629936307363133631936341363433635336373363833638936433364513645736467364693647336479364933649736523365273652936541365513655936563365713658336587365993660736629366373664336653366713667736683366913669736709367133672136739367493676136767367793678136787367913679336809368213683336847368573687136877368873689936901369133691936923369293693136943369473697336979369973700337013370193702137039370493705737061370873709737117371233713937159371713718137189371993720137217372233724337253372733727737307373093731337321373373733937357373613736337369373793739737409374233744137447374633748337489374933750137507375113751737529375373754737549375613756737571375733757937589375913760737619376333764337649376573766337691376933769937717377473778137783377993781137813378313784737853378613787137879378893789737907379513795737963379673798737991379933799738011380393804738053380693808338113381193814938153381673817738183381893819738201382193823138237382393826138273382813828738299383033831738321383273832938333383513837138377383933843138447384493845338459384613850138543385573856138567385693859338603386093861138629386393865138653386693867138677386933869938707387113871338723387293873738747387493876738783387913880338821388333883938851388613886738873388913890338917389213892338933389533895938971389773899339019390233904139043390473907939089390973910339107391133911939133391393915739161391633918139191391993920939217392273922939233392393924139251392933930139313393173932339341393433935939367393713937339383393973940939419394393944339451394613949939503395093951139521395413955139563395693958139607396193962339631396593966739671396793970339709397193972739733397493976139769397793979139799398213982739829398393984139847398573986339869398773988339887399013992939937399533997139979399833998940009400134003140037400394006340087400934009940111401234012740129401514015340163401694017740189401934021340231402374024140253402774028340289403434035140357403614038740423404274042940433404594047140483404874049340499405074051940529405314054340559405774058340591405974060940627406374063940693406974069940709407394075140759407634077140787408014081340819408234082940841408474084940853408674087940883408974090340927409334093940949409614097340993410114101741023410394104741051410574107741081411134111741131411414114341149411614117741179411834118941201412034121341221412274123141233412434125741263412694128141299413334134141351413574138141387413894139941411414134144341453414674147941491415074151341519415214153941543415494157941593415974160341609416114161741621416274164141647416514165941669416814168741719417294173741759417614177141777418014180941813418434184941851418634187941887418934189741903419114192741941419474195341957419594196941981419834199942013420174201942023420434206142071420734208342089421014213142139421574216942179421814218742193421974220942221422234222742239422574228142283422934229942307423234233142337423494235942373423794239142397424034240742409424334243742443424514245742461424634246742473424874249142499425094253342557425694257142577425894261142641426434264942667426774268342689426974270142703427094271942727427374274342751427674277342787427934279742821428294283942841428534285942863428994290142923429294293742943429534296142967429794298943003430134301943037430494305143063430674309343103431174313343151431594317743189432014320743223432374326143271432834329143313433194332143331433914339743399434034341143427434414345143457434814348743499435174354143543435734357743579435914359743607436094361343627436334364943651436614366943691437114371743721437534375943777437814378343787437894379343801438534386743889438914391343933439434395143961439634396943973439874399143997440174402144027440294404144053440594407144087440894410144111441194412344129441314415944171441794418944201442034420744221442494425744263442674426944273442794428144293443514435744371443814438344389444174444944453444834449144497445014450744519445314453344537445434454944563445794458744617446214462344633446414464744651446574468344687446994470144711447294474144753447714477344777447894479744809448194483944843448514486744879448874489344909449174492744939449534495944963449714498344987450074501345053450614507745083451194512145127451314513745139451614517945181451914519745233452474525945263452814528945293453074531745319453294533745341453434536145377453894540345413454274543345439454814549145497455034552345533455414555345557455694558745589455994561345631456414565945667456734567745691456974570745737457514575745763457674577945817458214582345827458334584145853458634586945887458934594345949459534595945971459794598946021460274604946051460614607346091460934609946103461334614146147461534617146181461834618746199462194622946237462614627146273462794630146307463094632746337463494635146381463994641146439464414644746451464574647146477464894649946507465114652346549465594656746573465894659146601466194663346639466434664946663466794668146687466914670346723467274674746751467574676946771468074681146817468194682946831468534686146867468774688946901469194693346957469934699747017470414705147057470594708747093471114711947123471294713747143471474714947161471894720747221472374725147269472794728747293472974730347309473174733947351473534736347381473874738947407474174741947431474414745947491474974750147507475134752147527475334754347563475694758147591475994760947623476294763947653476574765947681476994770147711477134771747737477414774347777477794779147797478074780947819478374784347857478694788147903479114791747933479394794747951479634796947977479814801748023480294804948073480794809148109481194812148131481574816348179481874819348197482214823948247482594827148281482994831148313483374834148353483714838348397484074840948413484374844948463484734847948481484874849148497485234852748533485394854148563485714858948593486114861948623486474864948661486734867748679487314873348751487574876148767487794878148787487994880948817488214882348847488574885948869488714888348889489074894748953489734898948991490034900949019490314903349037490434905749069490814910349109491174912149123491394915749169491714917749193491994920149207492114922349253492614927749279492974930749331493334933949363493674936949391493934940949411494174942949433494514945949463494774948149499495234952949531495374954749549495594959749603496134962749633496394966349667496694968149697497114972749739497414974749757497834978749789498014980749811498234983149843498534987149877498914991949921499274993749939499434995749991499934999950021500235003350047500515005350069500775008750093501015011150119501235012950131501475015350159501775020750221502275023150261502635027350287502915031150321503295033350341503595036350377503835038750411504175042350441504595046150497505035051350527505395054350549505515058150587505915059350599506275064750651506715068350707507235074150753507675077350777507895082150833508395084950857508675087350891508935090950923509295095150957509695097150989509935100151031510435104751059510615107151109511315113351137511515115751169511935119751199512035121751229512395124151257512635128351287513075132951341513435134751349513615138351407514135141951421514275143151437514395144951461514735147951481514875150351511515175152151539515515156351577515815159351599516075161351631516375164751659516735167951683516915171351719517215174951767517695178751797518035181751827518295183951853518595186951871518935189951907519135192951941519495197151973519775199152009520215202752051520575206752069520815210352121521275214752153521635217752181521835218952201522235223752249522535225952267522895229152301523135232152361523635236952379523875239152433524535245752489525015251152517525295254152543525535256152567525715257952583526095262752631526395266752673526915269752709527115272152727527335274752757527695278352807528135281752837528595286152879528835288952901529035291952937529515295752963529675297352981529995300353017530475305153069530775308753089530935310153113531175312953147531495316153171531735318953197532015323153233532395326753269532795328153299533095332353327533535335953377533815340153407534115341953437534415345353479535035350753527535495355153569535915359353597536095361153617536235362953633536395365353657536815369353699537175371953731537595377353777537835379153813538195383153849538575386153881538875389153897538995391753923539275393953951539595398753993540015401154013540375404954059540835409154101541215413354139541515416354167541815419354217542515426954277542875429354311543195432354331543475436154367543715437754401544035440954413544195442154437544435444954469544935449754499545035451754521545395454154547545595456354577545815458354601546175462354629546315464754667546735467954709547135472154727547515476754773547795478754799548295483354851548695487754881549075491754919549415494954959549735497954983550015500955021550495505155057550615507355079551035510955117551275514755163551715520155207552135521755219552295524355249552595529155313553315533355337553395534355351553735538155399554115543955441554575546955487555015551155529555415554755579555895560355609556195562155631556335563955661556635566755673556815569155697557115571755721557335576355787557935579955807558135581755819558235582955837558435584955871558895589755901559035592155927559315593355949559675598755997560035600956039560415605356081560875609356099561015611356123561315614956167561715617956197562075620956237562395624956263562675626956299563115633356359563695637756383563935640156417564315643756443564535646756473564775647956489565015650356509565195652756531565335654356569565915659756599566115662956633566595666356671566815668756701567115671356731567375674756767567735677956783568075680956813568215682756843568575687356891568935689756909569115692156923569295694156951569575696356983569895699356999570375704157047570595707357077570895709757107571195713157139571435714957163571735717957191571935720357221572235724157251572595726957271572835728757301573295733157347573495736757373573835738957397574135742757457574675748757493575035752757529575575755957571575875759357601576375764157649576535766757679576895769757709577135771957727577315773757751577735778157787577915779357803578095782957839578475785357859578815789957901579175792357943579475797357977579915801358027580315804358049580575806158067580735809958109581115812958147581515815358169581715818958193581995820758211582175822958231582375824358271583095831358321583375836358367583695837958391583935840358411584175842758439584415845158453584775848158511585375854358549585675857358579586015860358613586315865758661586795868758693586995871158727587335874158757587635877158787587895883158889588975890158907589095891358921589375894358963589675897958991589975900959011590215902359029590515905359063590695907759083590935910759113591195912359141591495915959167591835919759207592095921959221592335923959243592635927359281593335934159351593575935959369593775938759393593995940759417594195944159443594475945359467594715947359497595095951359539595575956159567595815961159617596215962759629596515965959663596695967159693596995970759723597295974359747597535977159779597915979759809598335986359879598875992159929599515995759971599815999960013600176002960037600416007760083600896009160101601036010760127601336013960149601616016760169602096021760223602516025760259602716028960293603176033160337603436035360373603836039760413604276044360449604576049360497605096052160527605396058960601606076061160617606236063160637606476064960659606616067960689607036071960727607336073760757607616076360773607796079360811608216085960869608876088960899609016091360917609196092360937609436095360961610016100761027610316104361051610576109161099611216112961141611516115361169612116122361231612536126161283612916129761331613336133961343613576136361379613816140361409614176144161463614696147161483614876149361507615116151961543615476155361559615616158361603616096161361627616316163761643616516165761667616736168161687617036171761723617296175161757617816181361819618376184361861618716187961909619276193361949619616196761979619816198761991620036201162017620396204762053620576207162081620996211962129621316213762141621436217162189621916220162207622136221962233622736229762299623036231162323623276234762351623836240162417624236245962467624736247762483624976250162507625336253962549625636258162591625976260362617626276263362639626536265962683626876270162723627316274362753627616277362791628016281962827628516286162869628736289762903629216292762929629396296962971629816298362987629896302963031630596306763073630796309763103631136312763131631496317963197631996321163241632476327763281632996331163313633176333163337633476335363361633676337763389633916339763409634196342163439634436346363467634736348763493634996352163527635336354163559635776358763589635996360163607636116361763629636476364963659636676367163689636916369763703637096371963727637376374363761637736378163793637996380363809638236383963841638536385763863639016390763913639296394963977639976400764013640196403364037640636406764081640916410964123641516415364157641716418764189642176422364231642376427164279642836430164303643196432764333643736438164399644036443364439644516445364483644896449964513645536456764577645796459164601646096461364621646276463364661646636466764679646936470964717647476476364781647836479364811648176484964853648716487764879648916490164919649216492764937649516496964997650036501165027650296503365053650636507165089650996510165111651196512365129651416514765167651716517365179651836520365213652396525765267652696528765293653096532365327653536535765371653816539365407654136541965423654376544765449654796549765519655216553765539655436555165557655636557965581655876559965609656176562965633656476565165657656776568765699657016570765713657176571965729657316576165777657896580965827658316583765839658436585165867658816589965921659276592965951659576596365981659836599366029660376604166047660676607166083660896610366107661096613766161661696617366179661916622166239662716629366301663376634366347663596636166373663776638366403664136643166449664576646366467664916649966509665236652966533665416655366569665716658766593666016661766629666436665366683666976670166713667216673366739667496675166763667916679766809668216684166851668536686366877668836688966919669236693166943669476694966959669736697767003670216703367043670496705767061670736707967103671216712967139671416715367157671696718167187671896721167213672176721967231672476726167271672736728967307673396734367349673696739167399674096741167421674276742967433674476745367477674816748967493674996751167523675316753767547675596756767577675796758967601676076761967631676516767967699677096772367733677416775167757677596776367777677836778967801678076781967829678436785367867678836789167901679276793167933679396794367957679616796767979679876799368023680416805368059680716808768099681116811368141681476816168171682076820968213682196822768239682616827968281683116832968351683716838968399684376844368447684496847368477684836848968491685016850768521685316853968543685676858168597686116863368639686596866968683686876869968711687136872968737687436874968767687716877768791688136881968821688636887968881688916889768899689036890968917689276894768963689936900169011690196902969031690616906769073691096911969127691436914969151691636919169193691976920369221692336923969247692576925969263693136931769337693416937169379693836938969401694036942769431694396945769463694676947369481694916949369497694996953969557695936962369653696616967769691696976970969737697396976169763697676977969809698216982769829698336984769857698596987769899699116992969931699416995969991699977000170003700097001970039700517006170067700797009970111701177012170123701397014170157701637017770181701837019970201702077022370229702377024170249702717028970297703097031370321703277035170373703797038170393704237042970439704517045770459704817048770489705017050770529705377054970571705737058370589706077061970621706277063970657706637066770687707097071770729707537076970783707937082370841708437084970853708677087770879708917090170913709197092170937709497095170957709697097970981709917099770999710117102371039710597106971081710897111971129711437114771153711617116771171711917120971233712377124971257712617126371287712937131771327713297133371339713417134771353713597136371387713897139971411714137141971429714377144371453714717147371479714837150371527715377154971551715637156971593715977163371647716637167171693716997170771711717137171971741717617177771789718077180971821718377184371849718617186771879718817188771899719097191771933719417194771963719717198371987719937199972019720317204372047720537207372077720897209172101721037210972139721617216772169721737221172221722237222772229722517225372269722717227772287723077231372337723417235372367723797238372421724317246172467724697248172493724977250372533725477255172559725777261372617726237264372647726497266172671726737267972689727017270772719727277273372739727637276772797728177282372859728697287172883728897289372901729077291172923729317293772949729537295972973729777299773009730137301973037730397304373061730637307973091731217312773133731417318173189732377324373259732777329173303733097332773331733517336173363733697337973387734177342173433734537345973471734777348373517735237352973547735537356173571735837358973597736077360973613736377364373651736737367973681736937369973709737217372773751737577377173783738197382373847738497385973867738777388373897739077393973943739517396173973739997401774021740277404774051740717407774093740997410174131741437414974159741617416774177741897419774201742037420974219742317425774279742877429374297743117431774323743537435774363743777438174383744117441374419744417444974453744717448974507745097452174527745317455174561745677457374587745977460974611746237465374687746997470774713747177471974729747317474774759747617477174779747977482174827748317484374857748617486974873748877489174897749037492374929749337494174959750117501375017750297503775041750797508375109751337514975161751677516975181751937520975211752177522375227752397525375269752777528975307753237532975337753477535375367753777538975391754017540375407754317543775479755037551175521755277553375539755417555375557755717557775583756117561775619756297564175653756597567975683756897570375707757097572175731757437576775773757817578775793757977582175833758537586975883759137593175937759417596775979759837598975991759977600176003760317603976079760817609176099761037612376129761477615776159761637620776213762317624376249762537625976261762837628976303763337634376367763697637976387764037642176423764417646376471764817648776493765077651176519765377654176543765617657976597766037660776631766497665176667766737667976697767177673376753767577677176777767817680176819768297683176837768477687176873768837690776913769197694376949769617696376991770037701777023770297704177047770697708177093771017713777141771537716777171771917720177213772377723977243772497726177263772677726977279772917731777323773397734777351773597736977377773837741777419774317744777471774777747977489774917750977513775217752777543775497755177557775637756977573775877759177611776177762177641776477765977681776877768977699777117771377719777237773177743777477776177773777837779777801778137783977849778637786777893778997792977933779517796977977779837799978007780177803178041780497805978079781017812178137781397815778163781677817378179781917819378203782297823378241782597827778283783017830778311783177834178347783677840178427784377843978467784797848778497785097851178517785397854178553785697857178577785837859378607786237864378649786537869178697787077871378721787377877978781787877879178797788037880978823788397885378857788777888778889788937890178919789297894178977789797898979031790397904379063790877910379111791337913979147791517915379159791817918779193792017922979231792417925979273792797928379301793097931979333793377934979357793677937979393793977939979411794237942779433794517948179493795317953779549795597956179579795897960179609796137962179627796317963379657796697968779691796937969779699797577976979777798017981179813798177982379829798417984379847798617986779873798897990179903799077993979943799677997379979799877999779999800218003980051800718007780107801118014180147801498015380167801738017780191802078020980221802318023380239802518026380273802798028780309803178032980341803478036380369803878040780429804478044980471804738048980491805138052780537805578056780599806038061180621806278062980651806578066980671806778068180683806878070180713807378074780749807618077780779807838078980803808098081980831808338084980863808978090980911809178092380929809338095380963809898100181013810178101981023810318104181043810478104981071810778108381097811018111981131811578116381173811818119781199812038122381233812398128181283812938129981307813318134381349813538135981371813738140181409814218143981457814638150981517815278153381547815518155381559815638156981611816198162981637816478164981667816718167781689817018170381707817278173781749817618176981773817998181781839818478185381869818838189981901819198192981931819378194381953819678197181973820038200782009820138202182031820378203982051820678207382129821398214182153821638217182183821898219382207822178221982223822318223782241822618226782279823018230782339823498235182361823738238782393824218245782463824698247182483824878249382499825078252982531825498255982561825678257182591826018260982613826198263382651826578269982721827238272782729827578275982763827818278782793827998281182813828378284782883828898289182903829138293982963829818299783003830098302383047830598306383071830778308983093831018311783137831778320383207832198322183227832318323383243832578326783269832738329983311833398334183357833838338983399834018340783417834238343183437834438344983459834718347783497835378355783561835638357983591835978360983617836218363983641836538366383689837018371783719837378376183773837778379183813838338384383857838698387383891839038391183921839338393983969839838398784011840178404784053840598406184067840898412184127841318413784143841638417984181841918419984211842218422384229842398424784263842998430784313843178431984347843498437784389843918440184407844218443184437844438444984457844638446784481844998450384509845218452384533845518455984589846298463184649846538465984673846918469784701847138471984731847378475184761847878479384809848118482784857848598486984871849138491984947849618496784977849798499185009850218502785037850498506185081850878509185093851038510985121851338514785159851938519985201852138522385229852378524385247852598529785303853138533185333853618536385369853818541185427854298543985447854518545385469854878551385517855238553185549855718557785597856018560785619856218562785639856438566185667856698569185703857118571785733857518578185793858178581985829858318583785843858478585385889859038590985931859338599185999860118601786027860298606986077860838611186113861178613186137861438616186171861798618386197862018620986239862438624986257862638626986287862918629386297863118632386341863518635386357863698637186381863898639986413864238644186453864618646786477864918650186509865318653386539865618657386579865878659986627866298667786689866938671186719867298674386753867678677186783868138683786843868518685786861868698692386927869298693986951869598696986981869938701187013870378704187049870718708387103871078711987121871338714987151871798718187187872118722187223872518725387257872778728187293872998731387317873238733787359873838740387407874218742787433874438747387481874918750987511875178752387539875418754787553875578755987583875878758987613876238762987631876418764387649876718767987683876918769787701877198772187739877438775187767877938779787803878118783387853878698787787881878878791187917879318794387959879618797387977879918800188003880078801988037880698807988093881178812988169881778821188223882378824188259882618828988301883218832788337883398837988397884118842388427884638846988471884938849988513885238854788589885918860788609886438865188657886618866388667886818872188729887418874788771887898879388799888018880788811888138881788819888438885388861888678887388883888978890388919889378895188969889938899789003890098901789021890418905189057890698907189083890878910189107891138911989123891378915389189892038920989213892278923189237892618926989273892938930389317893298936389371893818938789393893998941389417894318944389449894598947789491895018951389519895218952789533895618956389567895918959789599896038961189627896338965389657896598966989671896818968989753897598976789779897838979789809898198982189833898398984989867898918989789899899098991789923899398995989963899778998389989900019000790011900179001990023900319005390059900679007190073900899010790121901279014990163901739018790191901979019990203902179022790239902479026390271902819028990313903539035990371903739037990397904019040390407904379043990469904739048190499905119052390527905299053390547905839059990617906199063190641906479065990677906799069790703907099073190749907879079390803908219082390833908419084790863908879090190907909119091790931909479097190977909899099791009910199103391079910819109791099911219112791129911399114191151911539115991163911839119391199912299123791243912499125391283912919129791303913099133191367913699137391381913879139391397914119142391433914539145791459914639149391499915139152991541915719157391577915839159191621916319163991673916919170391711917339175391757917719178191801918079181191813918239183791841918679187391909919219193991943919519195791961919679196991997920039200992033920419205192077920839210792111921199214392153921739217792179921899220392219922219222792233922379224392251922699229792311923179233392347923539235792363923699237792381923839238792399924019241392419924319245992461924679247992489925039250792551925579256792569925819259392623926279263992641926479265792669926719268192683926939269992707927179272392737927539276192767927799278992791928019280992821928319284992857928619286392867928939289992921929279294192951929579295992987929939300193047930539305993077930839308993097931039311393131931339313993151931699317993187931999322993239932419325193253932579326393281932839328793307933199332393329933379337193377933839340793419934279346393479934819348793491934939349793503935239352993553935579355993563935819360193607936299363793683937019370393719937399376193763937879380993811938279385193871938879388993893939019391193913939239393793941939499396793971939799398393997940079400994033940499405794063940799409994109941119411794121941519415394169942019420794219942299425394261942739429194307943099432194327943319434394349943519437994397943999442194427944339443994441944479446394477944839451394529945319454194543945479455994561945739458394597946039461394621946499465194687946939470994723947279474794771947779478194789947939481194819948239483794841948479484994873948899490394907949339494994951949619499394999950039500995021950279506395071950839508795089950939510195107951119513195143951539517795189951919520395213952199523195233952399525795261952679527395279952879531195317953279533995369953839539395401954139541995429954419544395461954679547195479954839550795527955319553995549955619556995581955979560395617956219562995633956519570195707957139571795723957319573795747957739578395789957919580195803958139581995857958699587395881958919591195917959239592995947959579595995971959879598996001960139601796043960539605996079960979613796149961579616796179961819619996211962219622396233962599626396269962819628996293963239632996331963379635396377964019641996431964439645196457964619646996479964879649396497965179652796553965579658196587965899660196643966619666796671966979670396731967379673996749967579676396769967799678796797967999682196823968279684796851968579689396907969119693196953969599697396979969899699797001970039700797021970399707397081971039711797127971519715797159971699717197177971879721397231972419725997283973019730397327973679736997373973799738197387973979742397429974419745397459974639749997501975119752397547975499755397561975719757797579975839760797609976139764997651976739768797711977299777197777977879778997813978299784197843978479784997859978619787197879978839791997927979319794397961979679797397987980099801198017980419804798057980819810198123981299814398179982079821398221982279825198257982699829798299983179832198323983279834798369983779838798389984079841198419984299844398453984599846798473984799849198507985199853398543985619856398573985979862198627986399864198663986699868998711987139871798729987319873798773987799880198807988099883798849988679886998873988879889398897988999890998911989279892998939989479895398963989819899398999990139901799023990419905399079990839908999103991099911999131991339913799139991499917399181991919922399233992419925199257992599927799289993179934799349993679937199377993919939799401994099943199439994699948799497995239952799529995519955999563995719957799581996079961199623996439966199667996799968999707997099971399719997219973399761997679978799793998099981799823998299983399839998599987199877998819990199907999239992999961999719998999991100003100019100043100049100057100069100103100109100129100151100153100169100183100189100193100207100213100237100267100271100279100291100297100313100333100343100357100361100363100379100391100393100403100411100417100447100459100469100483100493100501100511100517100519100523100537100547100549100559100591100609100613100621100649100669100673100693100699100703100733100741100747100769100787100799100801100811100823100829100847100853100907100913100927100931100937100943100957100981100987100999101009101021101027101051101063101081101089101107101111101113101117101119101141101149101159101161101173101183101197101203101207101209101221101267101273101279101281101287101293101323101333101341101347101359101363101377101383101399101411101419101429101449101467101477101483101489101501101503101513101527101531101533101537101561101573101581101599101603101611101627101641101653101663101681101693101701101719101723101737101741101747101749101771101789101797101807101833101837101839101863101869101873101879101891101917101921101929101939101957101963101977101987101999102001102013102019102023102031102043102059102061102071102077102079102101102103102107102121102139102149102161102181102191102197102199102203102217102229102233102241102251102253102259102293102299102301102317102329102337102359102367102397102407102409102433102437102451102461102481102497102499102503102523102533102539102547102551102559102563102587102593102607102611102643102647102653102667102673102677102679102701102761102763102769102793102797102811102829102841102859102871102877102881102911102913102929102931102953102967102983103001103007103043103049103067103069103079103087103091103093103099103123103141103171103177103183103217103231103237103289103291103307103319103333103349103357103387103391103393103399103409103421103423103451103457103471103483103511103529103549103553103561103567103573103577103583103591103613103619103643103651103657103669103681103687103699103703103723103769103787103801103811103813103837103841103843103867103889103903103913103919103951103963103967103969103979103981103991103993103997104003104009104021104033104047104053104059104087104089104107104113104119104123104147104149104161104173104179104183104207104231104233104239104243104281104287104297104309104311104323104327104347104369104381104383104393104399104417104459104471104473104479104491104513104527104537104543104549104551104561104579104593104597104623104639104651104659104677104681104683104693104701104707104711104717104723104729104743104759104761104773104779104789104801104803104827104831104849104851104869104879104891104911104917104933104947104953104959104971104987104999105019105023105031105037105071105097105107105137105143105167105173105199105211105227105229105239105251105253105263105269105277105319105323105331105337105341105359105361105367105373105379105389105397105401105407105437105449105467105491105499105503105509105517105527105529105533105541105557105563105601105607105613105619105649105653105667105673105683105691105701105727105733105751105761105767105769105817105829105863105871105883105899105907105913105929105943105953105967105971105977105983105997106013106019106031106033106087106103106109106121106123106129106163106181106187106189106207106213106217106219106243106261106273106277106279106291106297106303106307106319106321106331106349106357106363106367106373106391106397106411106417106427106433106441106451106453106487106501106531106537106541106543106591106619106621106627106637106649106657106661106663106669106681106693106699106703106721106727106739106747106751106753106759106781106783106787106801106823106853106859106861106867106871106877106903106907106921106937106949106957106961106963106979106993107021107033107053107057107069107071107077107089107099107101107119107123107137107171107183107197107201107209107227107243107251107269107273107279107309107323107339107347107351107357107377107441107449107453107467107473107507107509107563107581107599107603107609107621107641107647107671107687107693107699107713107717107719107741107747107761107773107777107791107827107837107839107843107857107867107873107881107897107903107923107927107941107951107971107981107999108007108011108013108023108037108041108061108079108089108107108109108127108131108139108161108179108187108191108193108203108211108217108223108233108247108263108271108287108289108293108301108343108347108359108377108379108401108413108421108439108457108461108463108497108499108503108517108529108533108541108553108557108571108587108631108637108643108649108677108707108709108727108739108751108761108769108791108793108799108803108821108827108863108869108877108881108883108887108893108907108917108923108929108943108947108949108959108961108967108971108991109001109013109037109049109063109073109097109103109111109121109133109139109141109147109159109169109171109199109201109211109229109253109267109279109297109303109313109321109331109357109363109367109379109387109391109397109423109433109441109451109453109469109471109481109507109517109519109537109541109547109567109579109583109589109597109609109619109621109639109661109663109673109717109721109741109751109789109793109807109819109829109831109841109843109847109849109859109873109883109891109897109903109913109919109937109943109961109987110017110023110039110051110059110063110069110083110119110129110161110183110221110233110237110251110261110269110273110281110291110311110321110323110339110359110419110431110437110441110459110477110479110491110501110503110527110533110543110557110563110567110569110573110581110587110597110603110609110623110629110641110647110651110681110711110729110731110749110753110771110777110807110813110819110821110849110863110879110881110899110909110917110921110923110927110933110939110947110951110969110977110989111029111031111043111049111053111091111103111109111119111121111127111143111149111187111191111211111217111227111229111253111263111269111271111301111317111323111337111341111347111373111409111427111431111439111443111467111487111491111493111497111509111521111533111539111577111581111593111599111611111623111637111641111653111659111667111697111721111731111733111751111767111773111779111781111791111799111821111827111829111833111847111857111863111869111871111893111913111919111949111953111959111973111977111997112019112031112061112067112069112087112097112103112111112121112129112139112153112163112181112199112207112213112223112237112241112247112249112253112261112279112289112291112297112303112327112331112337112339112349112361112363112397112403112429112459112481112501112507112543112559112571112573112577112583112589112601112603112621112643112657112663112687112691112741112757112759112771112787112799112807112831112843112859112877112901112909112913112919112921112927112939112951112967112979112997113011113017113021113023113027113039113041113051113063113081113083113089113093113111113117113123113131113143113147113149113153113159113161113167113171113173113177113189113209113213113227113233113279113287113327113329113341113357113359113363113371113381113383113417113437113453113467113489113497113501113513113537113539113557113567113591113621113623113647113657113683113717113719113723113731113749113759113761113777113779113783113797113809113819113837113843113891113899113903113909113921113933113947113957113963113969113983113989114001114013114031114041114043114067114073114077114083114089114113114143114157114161114167114193114197114199114203114217114221114229114259114269114277114281114299114311114319114329114343114371114377114407114419114451114467114473114479114487114493114547114553114571114577114593114599114601114613114617114641114643114649114659114661114671114679114689114691114713114743114749114757114761114769114773114781114797114799114809114827114833114847114859114883114889114901114913114941114967114973114997115001115013115019115021115057115061115067115079115099115117115123115127115133115151115153115163115183115201115211115223115237115249115259115279115301115303115309115319115321115327115331115337115343115361115363115399115421115429115459115469115471115499115513115523115547115553115561115571115589115597115601115603115613115631115637115657115663115679115693115727115733115741115751115757115763115769115771115777115781115783115793115807115811115823115831115837115849115853115859115861115873115877115879115883115891115901115903115931115933115963115979115981115987116009116027116041116047116089116099116101116107116113116131116141116159116167116177116189116191116201116239116243116257116269116273116279116293116329116341116351116359116371116381116387116411116423116437116443116447116461116471116483116491116507116531116533116537116539116549116579116593116639116657116663116681116687116689116707116719116731116741116747116789116791116797116803116819116827116833116849116867116881116903116911116923116927116929116933116953116959116969116981116989116993117017117023117037117041117043117053117071117101117109117119117127117133117163117167117191117193117203117209117223117239117241117251117259117269117281117307117319117329117331117353117361117371117373117389117413117427117431117437117443117497117499117503117511117517117529117539117541117563117571117577117617117619117643117659117671117673117679117701117703117709117721117727117731117751117757117763117773117779117787117797117809117811117833117839117841117851117877117881117883117889117899117911117917117937117959117973117977117979117989117991118033118037118043118051118057118061118081118093118127118147118163118169118171118189118211118213118219118247118249118253118259118273118277118297118343118361118369118373118387118399118409118411118423118429118453118457118463118471118493118529118543118549118571118583118589118603118619118621118633118661118669118673118681118687118691118709118717118739118747118751118757118787118799118801118819118831118843118861118873118891118897118901118903118907118913118927118931118967118973119027119033119039119047119057119069119083119087119089119099119101119107119129119131119159119173119179119183119191119227119233119237119243119267119291119293119297119299119311119321119359119363119389119417119419119429119447119489119503119513119533119549119551119557119563119569119591119611119617119627119633119653119657119659119671119677119687119689119699119701119723119737119747119759119771119773119783119797119809119813119827119831119839119849119851119869119881119891119921119923119929119953119963119971119981119983119993120011120017120041120047120049120067120077120079120091120097120103120121120157120163120167120181120193120199120209120223120233120247120277120283120293120299120319120331120349120371120383120391120397120401120413120427120431120473120503120511120539120551120557120563120569120577120587120607120619120623120641120647120661120671120677120689120691120709120713120721120737120739120749120763120767120779120811120817120823120829120833120847120851120863120871120877120889120899120907120917120919120929120937120941120943120947120977120997121001121007121013121019121021121039121061121063121067121081121123121139121151121157121169121171121181121189121229121259121267121271121283121291121309121313121321121327121333121343121349121351121357121367121369121379121403121421121439121441121447121453121469121487121493121501121507121523121531121547121553121559121571121577121579121591121607121609121621121631121633121637121661121687121697121711121721121727121763121787121789121843121853121867121883121889121909121921121931121937121949121951121963121967121993121997122011122021122027122029122033122039122041122051122053122069122081122099122117122131122147122149122167122173122201122203122207122209122219122231122251122263122267122273122279122299122321122323122327122347122363122387122389122393122399122401122443122449122453122471122477122489122497122501122503122509122527122533122557122561122579122597122599122609122611122651122653122663122693122701122719122741122743122753122761122777122789122819122827122833122839122849122861122867122869122887122891122921122929122939122953122957122963122971123001123007123017123031123049123059123077123083123091123113123121123127123143123169123191123203123209123217123229123239123259123269123289123307123311123323123341123373123377123379123397123401123407123419123427123433123439123449123457123479123491123493123499123503123517123527123547123551123553123581123583123593123601123619123631123637123653123661123667123677123701123707123719123727123731123733123737123757123787123791123803123817123821123829123833123853123863123887123911123923123931123941123953123973123979123983123989123997124001124021124067124087124097124121124123124133124139124147124153124171124181124183124193124199124213124231124247124249124277124291124297124301124303124309124337124339124343124349124351124363124367124427124429124433124447124459124471124477124489124493124513124529124541124543124561124567124577124601124633124643124669124673124679124693124699124703124717124721124739124753124759124769124771124777124781124783124793124799124819124823124847124853124897124907124909124919124951124979124981124987124991125003125017125029125053125063125093125101125107125113125117125119125131125141125149125183125197125201125207125219125221125231125243125261125269125287125299125303125311125329125339125353125371125383125387125399125407125423125429125441125453125471125497125507125509125527125539125551125591125597125617125621125627125639125641125651125659125669125683125687125693125707125711125717125731125737125743125753125777125789125791125803125813125821125863125887125897125899125921125927125929125933125941125959125963126001126011126013126019126023126031126037126041126047126067126079126097126107126127126131126143126151126173126199126211126223126227126229126233126241126257126271126307126311126317126323126337126341126349126359126397126421126433126443126457126461126473126481126487126491126493126499126517126541126547126551126583126601126611126613126631126641126653126683126691126703126713126719126733126739126743126751126757126761126781126823126827126839126851126857126859126913126923126943126949126961126967126989127031127033127037127051127079127081127103127123127133127139127157127163127189127207127217127219127241127247127249127261127271127277127289127291127297127301127321127331127343127363127373127399127403127423127447127453127481127487127493127507127529127541127549127579127583127591127597127601127607127609127637127643127649127657127663127669127679127681127691127703127709127711127717127727127733127739127747127763127781127807127817127819127837127843127849127859127867127873127877127913127921127931127951127973127979127997128021128033128047128053128099128111128113128119128147128153128159128173128189128201128203128213128221128237128239128257128273128287128291128311128321128327128339128341128347128351128377128389128393128399128411128413128431128437128449128461128467128473128477128483128489128509128519128521128549128551128563128591128599128603128621128629128657128659128663128669128677128683128693128717128747128749128761128767128813128819128831128833128837128857128861128873128879128903128923128939128941128951128959128969128971128981128983128987128993129001129011129023129037129049129061129083129089129097129113129119129121129127129169129187129193129197129209129221129223129229129263129277129281129287129289129293129313129341129347129361129379129401129403129419129439129443129449129457129461129469129491129497129499129509129517129527129529129533129539129553129581129587129589129593129607129629129631129641129643129671129707129719129733129737129749129757129763129769129793129803129841129853129887129893129901129917129919129937129953129959129967129971130003130021130027130043130051130057130069130073130079130087130099130121130127130147130171130183130199130201130211130223130241130253130259130261130267130279130303130307130337130343130349130363130367130369130379130399130409130411130423130439130447130457130469130477130483130489130513130517130523130531130547130553130579130589130619130621130631130633130639130643130649130651130657130681130687130693130699130729130769130783130787130807130811130817130829130841130843130859130873130927130957130969130973130981130987131009131011131023131041131059131063131071131101131111131113131129131143131149131171131203131213131221131231131249131251131267131293131297131303131311131317131321131357131363131371131381131413131431131437131441131447131449131477131479131489131497131501131507131519131543131561131581131591131611131617131627131639131641131671131687131701131707131711131713131731131743131749131759131771131777131779131783131797131837131839131849131861131891131893131899131909131927131933131939131941131947131959131969132001132019132047132049132059132071132103132109132113132137132151132157132169132173132199132229132233132241132247132257132263132283132287132299132313132329132331132347132361132367132371132383132403132409132421132437132439132469132491132499132511132523132527132529132533132541132547132589132607132611132619132623132631132637132647132661132667132679132689132697132701132707132709132721132739132749132751132757132761132763132817132833132851132857132859132863132887132893132911132929132947132949132953132961132967132971132989133013133033133039133051133069133073133087133097133103133109133117133121133153133157133169133183133187133201133213133241133253133261133271133277133279133283133303133319133321133327133337133349133351133379133387133391133403133417133439133447133451133481133493133499133519133541133543133559133571133583133597133631133633133649133657133669133673133691133697133709133711133717133723133733133769133781133801133811133813133831133843133853133873133877133919133949133963133967133979133981133993133999134033134039134047134053134059134077134081134087134089134093134129134153134161134171134177134191134207134213134219134227134243134257134263134269134287134291134293134327134333134339134341134353134359134363134369134371134399134401134417134437134443134471134489134503134507134513134581134587134591134593134597134609134639134669134677134681134683134699134707134731134741134753134777134789134807134837134839134851134857134867134873134887134909134917134921134923134947134951134989134999135007135017135019135029135043135049135059135077135089135101135119135131135151135173135181135193135197135209135211135221135241135257135271135277135281135283135301135319135329135347135349135353135367135389135391135403135409135427135431135433135449135461135463135467135469135479135497135511135533135559135571135581135589135593135599135601135607135613135617135623135637135647135649135661135671135697135701135719135721135727135731135743135757135781135787135799135829135841135851135859135887135893135899135911135913135929135937135977135979136013136027136033136043136057136067136069136093136099136111136133136139136163136177136189136193136207136217136223136237136247136261136273136277136303136309136319136327136333136337136343136351136361136373136379136393136397136399136403136417136421136429136447136453136463136471136481136483136501136511136519136523136531136537136541136547136559136573136601136603136607136621136649136651136657136691136693136709136711136727136733136739136751136753136769136777136811136813136841136849136859136861136879136883136889136897136943136949136951136963136973136979136987136991136993136999137029137077137087137089137117137119137131137143137147137153137177137183137191137197137201137209137219137239137251137273137279137303137321137339137341137353137359137363137369137383137387137393137399137413137437137443137447137453137477137483137491137507137519137537137567137573137587137593137597137623137633137639137653137659137699137707137713137723137737137743137771137777137791137803137827137831137849137867137869137873137909137911137927137933137941137947137957137983137993137999138007138041138053138059138071138077138079138101138107138113138139138143138157138163138179138181138191138197138209138239138241138247138251138283138289138311138319138323138337138349138371138373138389138401138403138407138427138433138449138451138461138469138493138497138511138517138547138559138563138569138571138577138581138587138599138617138629138637138641138647138661138679138683138727138731138739138763138793138797138799138821138829138841138863138869138883138889138893138899138917138923138937138959138967138977139021139033139067139079139091139109139121139123139133139169139177139187139199139201139241139267139273139291139297139301139303139309139313139333139339139343139361139367139369139387139393139397139409139423139429139439139457139459139483139487139493139501139511139537139547139571139589139591139597139609139619139627139661139663139681139697139703139709139721139729139739139747139753139759139787139801139813139831139837139861139871139883139891139901139907139921139939139943139967139969139981139987139991139999140009140053140057140069140071140111140123140143140159140167140171140177140191140197140207140221140227140237140249140263140269140281140297140317140321140333140339140351140363140381140401140407140411140417140419140423140443140449140453140473140477140521140527140533140549140551140557140587140593140603140611140617140627140629140639140659140663140677140681140683140689140717140729140731140741140759140761140773140779140797140813140827140831140837140839140863140867140869140891140893140897140909140929140939140977140983140989141023141041141061141067141073141079141101141107141121141131141157141161141179141181141199141209141221141223141233141241141257141263141269141277141283141301141307141311141319141353141359141371141397141403141413141439141443141461141481141497141499141509141511141529141539141551141587141601141613141619141623141629141637141649141653141667141671141677141679141689141697141707141709141719141731141761141767141769141773141793141803141811141829141833141851141853141863141871141907141917141931141937141941141959141961141971141991142007142019142031142039142049142057142061142067142097142099142111142123142151142157142159142169142183142189142193142211142217142223142231142237142271142297142319142327142357142369142381142391142403142421142427142433142453142469142501142529142537142543142547142553142559142567142573142589142591142601142607142609142619142657142673142697142699142711142733142757142759142771142787142789142799142811142837142841142867142871142873142897142903142907142939142949142963142969142973142979142981142993143053143063143093143107143111143113143137143141143159143177143197143239143243143249143257143261143263143281143287143291143329143333143357143387143401143413143419143443143461143467143477143483143489143501143503143509143513143519143527143537143551143567143569143573143593143609143617143629143651143653143669143677143687143699143711143719143729143743143779143791143797143807143813143821143827143831143833143873143879143881143909143947143953143971143977143981143999144013144031144037144061144071144073144103144139144161144163144167144169144173144203144223144241144247144253144259144271144289144299144307144311144323144341144349144379144383144407144409144413144427144439144451144461144479144481144497144511144539144541144563144569144577144583144589144593144611144629144659144667144671144701144709144719144731144737144751144757144763144773144779144791144817144829144839144847144883144887144889144899144917144931144941144961144967144973144983145007145009145021145031145037145043145063145069145091145109145121145133145139145177145193145207145213145219145253145259145267145283145289145303145307145349145361145381145391145399145417145423145433145441145451145459145463145471145477145487145501145511145513145517145531145543145547145549145577145589145601145603145633145637145643145661145679145681145687145703145709145721145723145753145757145759145771145777145799145807145819145823145829145861145879145897145903145931145933145949145963145967145969145987145991146009146011146021146023146033146051146057146059146063146077146093146099146117146141146161146173146191146197146203146213146221146239146249146273146291146297146299146309146317146323146347146359146369146381146383146389146407146417146423146437146449146477146513146519146521146527146539146543146563146581146603146609146617146639146647146669146677146681146683146701146719146743146749146767146777146801146807146819146833146837146843146849146857146891146893146917146921146933146941146953146977146983146987146989147011147029147031147047147073147083147089147097147107147137147139147151147163147179147197147209147211147221147227147229147253147263147283147289147293147299147311147319147331147341147347147353147377147391147397147401147409147419147449147451147457147481147487147503147517147541147547147551147557147571147583147607147613147617147629147647147661147671147673147689147703147709147727147739147743147761147769147773147779147787147793147799147811147827147853147859147863147881147919147937147949147977147997148013148021148061148063148073148079148091148123148139148147148151148153148157148171148193148199148201148207148229148243148249148279148301148303148331148339148361148367148381148387148399148403148411148429148439148457148469148471148483148501148513148517148531148537148549148573148579148609148627148633148639148663148667148669148691148693148711148721148723148727148747148763148781148783148793148817148829148853148859148861148867148873148891148913148921148927148931148933148949148957148961148991148997149011149021149027149033149053149057149059149069149077149087149099149101149111149113149119149143149153149159149161149173149183149197149213149239149249149251149257149269149287149297149309149323149333149341149351149371149377149381149393149399149411149417149419149423149441149459149489149491149497149503149519149521149531149533149543149551149561149563149579149603149623149627149629149689149711149713149717149729149731149749149759149767149771149791149803149827149837149839149861149867149873149893149899149909149911149921149939149953149969149971149993150001150011150041150053150061150067150077150083150089150091150097150107150131150151150169150193150197150203150209150211150217150221150223150239150247150287150299150301150323150329150343150373150377150379150383150401150407150413150427150431150439150473150497150503150517150523150533150551150559150571150583150587150589150607150611150617150649150659150697150707150721150743150767150769150779150791150797150827150833150847150869150881150883150889150893150901150907150919150929150959150961150967150979150989150991151007151009151013151027151049151051151057151091151121151141151153151157151163151169151171151189151201151213151237151241151243151247151253151273151279151289151303151337151339151343151357151379151381151391151397151423151429151433151451151471151477151483151499151507151517151523151531151537151549151553151561151573151579151597151603151607151609151631151637151643151651151667151673151681151687151693151703151717151729151733151769151771151783151787151799151813151817151841151847151849151871151883151897151901151903151909151937151939151967151969152003152017152027152029152039152041152063152077152081152083152093152111152123152147152183152189152197152203152213152219152231152239152249152267152287152293152297152311152363152377152381152389152393152407152417152419152423152429152441152443152459152461152501152519152531152533152539152563152567152597152599152617152623152629152639152641152657152671152681152717152723152729152753152767152777152783152791152809152819152821152833152837152839152843152851152857152879152897152899152909152939152941152947152953152959152981152989152993153001153059153067153071153073153077153089153107153113153133153137153151153191153247153259153269153271153277153281153287153313153319153337153343153353153359153371153379153407153409153421153427153437153443153449153457153469153487153499153509153511153521153523153529153533153557153563153589153607153611153623153641153649153689153701153719153733153739153743153749153757153763153817153841153871153877153887153889153911153913153929153941153947153949153953153991153997154001154027154043154057154061154067154073154079154081154087154097154111154127154153154157154159154181154183154211154213154229154243154247154267154277154279154291154303154313154321154333154339154351154369154373154387154409154417154423154439154459154487154493154501154523154543154571154573154579154589154591154613154619154621154643154667154669154681154691154699154723154727154733154747154753154769154787154789154799154807154823154841154849154871154873154877154883154897154927154933154937154943154981154991155003155009155017155027155047155069155081155083155087155119155137155153155161155167155171155191155201155203155209155219155231155251155269155291155299155303155317155327155333155371155377155381155383155387155399155413155423155443155453155461155473155501155509155521155537155539155557155569155579155581155593155599155609155621155627155653155657155663155671155689155693155699155707155717155719155723155731155741155747155773155777155783155797155801155809155821155833155849155851155861155863155887155891155893155921156007156011156019156041156059156061156071156089156109156119156127156131156139156151156157156217156227156229156241156253156257156259156269156307156319156329156347156353156361156371156419156421156437156467156487156491156493156511156521156539156577156589156593156601156619156623156631156641156659156671156677156679156683156691156703156707156719156727156733156749156781156797156799156817156823156833156841156887156899156901156913156941156943156967156971156979157007157013157019157037157049157051157057157061157081157103157109157127157133157141157163157177157181157189157207157211157217157219157229157231157243157247157253157259157271157273157277157279157291157303157307157321157327157349157351157363157393157411157427157429157433157457157477157483157489157513157519157523157543157559157561157571157579157627157637157639157649157667157669157679157721157733157739157747157769157771157793157799157813157823157831157837157841157867157877157889157897157901157907157931157933157951157991157999158003158009158017158029158047158071158077158113158129158141158143158161158189158201158209158227158231158233158243158261158269158293158303158329158341158351158357158359158363158371158393158407158419158429158443158449158489158507158519158527158537158551158563158567158573158581158591158597158611158617158621158633158647158657158663158699158731158747158749158759158761158771158777158791158803158843158849158863158867158881158909158923158927158941158959158981158993159013159017159023159059159073159079159097159113159119159157159161159167159169159179159191159193159199159209159223159227159233159287159293159311159319159337159347159349159361159389159403159407159421159431159437159457159463159469159473159491159499159503159521159539159541159553159563159569159571159589159617159623159629159631159667159671159673159683159697159701159707159721159737159739159763159769159773159779159787159791159793159799159811159833159839159853159857159869159871159899159911159931159937159977159979160001160009160019160031160033160049160073160079160081160087160091160093160117160141160159160163160169160183160201160207160217160231160243160253160309160313160319160343160357160367160373160387160397160403160409160423160441160453160481160483160499160507160541160553160579160583160591160603160619160621160627160637160639160649160651160663160669160681160687160697160709160711160723160739160751160753160757160781160789160807160813160817160829160841160861160877160879160883160903160907160933160967160969160981160997161009161017161033161039161047161053161059161071161087161093161123161137161141161149161159161167161201161221161233161237161263161267161281161303161309161323161333161339161341161363161377161387161407161411161453161459161461161471161503161507161521161527161531161543161561161563161569161573161591161599161611161627161639161641161659161683161717161729161731161741161743161753161761161771161773161779161783161807161831161839161869161873161879161881161911161921161923161947161957161969161971161977161983161999162007162011162017162053162059162079162091162109162119162143162209162221162229162251162257162263162269162277162287162289162293162343162359162389162391162413162419162439162451162457162473162493162499162517162523162527162529162553162557162563162577162593162601162611162623162629162641162649162671162677162683162691162703162709162713162727162731162739162749162751162779162787162791162821162823162829162839162847162853162859162881162889162901162907162917162937162947162971162973162989162997163003163019163021163027163061163063163109163117163127163129163147163151163169163171163181163193163199163211163223163243163249163259163307163309163321163327163337163351163363163367163393163403163409163411163417163433163469163477163481163483163487163517163543163561163567163573163601163613163621163627163633163637163643163661163673163679163697163729163733163741163753163771163781163789163811163819163841163847163853163859163861163871163883163901163909163927163973163979163981163987163991163993163997164011164023164039164051164057164071164089164093164113164117164147164149164173164183164191164201164209164231164233164239164249164251164267164279164291164299164309164321164341164357164363164371164377164387164413164419164429164431164443164447164449164471164477164503164513164531164569164581164587164599164617164621164623164627164653164663164677164683164701164707164729164743164767164771164789164809164821164831164837164839164881164893164911164953164963164987164999165001165037165041165047165049165059165079165083165089165103165133165161165173165181165203165211165229165233165247165287165293165311165313165317165331165343165349165367165379165383165391165397165437165443165449165457165463165469165479165511165523165527165533165541165551165553165559165569165587165589165601165611165617165653165667165673165701165703165707165709165713165719165721165749165779165799165811165817165829165833165857165877165883165887165901165931165941165947165961165983166013166021166027166031166043166063166081166099166147166151166157166169166183166189166207166219166237166247166259166273166289166297166301166303166319166349166351166357166363166393166399166403166409166417166429166457166471166487166541166561166567166571166597166601166603166609166613166619166627166631166643166657166667166669166679166693166703166723166739166741166781166783166799166807166823166841166843166847166849166853166861166867166871166909166919166931166949166967166973166979166987167009167017167021167023167033167039167047167051167071167077167081167087167099167107167113167117167119167149167159167173167177167191167197167213167221167249167261167267167269167309167311167317167329167339167341167381167393167407167413167423167429167437167441167443167449167471167483167491167521167537167543167593167597167611167621167623167627167633167641167663167677167683167711167729167747167759167771167777167779167801167809167861167863167873167879167887167891167899167911167917167953167971167987168013168023168029168037168043168067168071168083168089168109168127168143168151168193168197168211168227168247168253168263168269168277168281168293168323168331168347168353168391168409168433168449168451168457168463168481168491168499168523168527168533168541168559168599168601168617168629168631168643168673168677168697168713168719168731168737168743168761168769168781168803168851168863168869168887168893168899168901168913168937168943168977168991169003169007169009169019169049169063169067169069169079169093169097169111169129169151169159169177169181169199169217169219169241169243169249169259169283169307169313169319169321169327169339169343169361169369169373169399169409169427169457169471169483169489169493169501169523169531169553169567169583169591169607169627169633169639169649169657169661169667169681169691169693169709169733169751169753169769169777169783169789169817169823169831169837169843169859169889169891169909169913169919169933169937169943169951169957169987169991170003170021170029170047170057170063170081170099170101170111170123170141170167170179170189170197170207170213170227170231170239170243170249170263170267170279170293170299170327170341170347170351170353170363170369170371170383170389170393170413170441170447170473170483170497170503170509170537170539170551170557170579170603170609170627170633170641170647170669170689170701170707170711170741170749170759170761170767170773170777170801170809170813170827170837170843170851170857170873170881170887170899170921170927170953170957170971171007171023171029171043171047171049171053171077171079171091171103171131171161171163171167171169171179171203171233171251171253171263171271171293171299171317171329171341171383171401171403171427171439171449171467171469171473171481171491171517171529171539171541171553171559171571171583171617171629171637171641171653171659171671171673171679171697171707171713171719171733171757171761171763171793171799171803171811171823171827171851171863171869171877171881171889171917171923171929171937171947172001172009172021172027172031172049172069172079172093172097172127172147172153172157172169172171172181172199172213172217172219172223172243172259172279172283172297172307172313172321172331172343172351172357172373172399172411172421172423172427172433172439172441172489172507172517172519172541172553172561172573172583172589172597172603172607172619172633172643172649172657172663172673172681172687172709172717172721172741172751172759172787172801172807172829172849172853172859172867172871172877172883172933172969172973172981172987172993172999173021173023173039173053173059173081173087173099173137173141173149173177173183173189173191173207173209173219173249173263173267173273173291173293173297173309173347173357173359173429173431173473173483173491173497173501173531173539173543173549173561173573173599173617173629173647173651173659173669173671173683173687173699173707173713173729173741173743173773173777173779173783173807173819173827173839173851173861173867173891173897173909173917173923173933173969173977173981173993174007174017174019174047174049174061174067174071174077174079174091174101174121174137174143174149174157174169174197174221174241174257174259174263174281174289174299174311174329174331174337174347174367174389174407174413174431174443174457174467174469174481174487174491174527174533174569174571174583174599174613174617174631174637174649174653174659174673174679174703174721174737174749174761174763174767174773174799174821174829174851174859174877174893174901174907174917174929174931174943174959174989174991175003175013175039175061175067175069175079175081175103175129175141175211175229175261175267175277175291175303175309175327175333175349175361175391175393175403175411175433175447175453175463175481175493175499175519175523175543175573175601175621175631175633175649175663175673175687175691175699175709175723175727175753175757175759175781175783175811175829175837175843175853175859175873175891175897175909175919175937175939175949175961175963175979175991175993176017176021176023176041176047176051176053176063176081176087176089176123176129176153176159176161176179176191176201176207176213176221176227176237176243176261176299176303176317176321176327176329176333176347176353176357176369176383176389176401176413176417176419176431176459176461176467176489176497176503176507176509176521176531176537176549176551176557176573176591176597176599176609176611176629176641176651176677176699176711176713176741176747176753176777176779176789176791176797176807176809176819176849176857176887176899176903176921176923176927176933176951176977176983176989177007177011177013177019177043177091177101177109177113177127177131177167177173177209177211177217177223177239177257177269177283177301177319177323177337177347177379177383177409177421177427177431177433177467177473177481177487177493177511177533177539177553177589177601177623177647177677177679177691177739177743177761177763177787177791177797177811177823177839177841177883177887177889177893177907177913177917177929177943177949177953177967177979178001178021178037178039178067178069178091178093178103178117178127178141178151178169178183178187178207178223178231178247178249178259178261178289178301178307178327178333178349178351178361178393178397178403178417178439178441178447178469178481178487178489178501178513178531178537178559178561178567178571178597178601178603178609178613178621178627178639178643178681178691178693178697178753178757178781178793178799178807178813178817178819178831178853178859178873178877178889178897178903178907178909178921178931178933178939178951178973178987179021179029179033179041179051179057179083179089179099179107179111179119179143179161179167179173179203179209179213179233179243179261179269179281179287179317179321179327179351179357179369179381179383179393179407179411179429179437179441179453179461179471179479179483179497179519179527179533179549179563179573179579179581179591179593179603179623179633179651179657179659179671179687179689179693179717179719179737179743179749179779179801179807179813179819179821179827179833179849179897179899179903179909179917179923179939179947179951179953179957179969179981179989179999180001180007180023180043180053180071180073180077180097180137180161180179180181180211180221180233180239180241180247180259180263180281180287180289180307180311180317180331180337180347180361180371180379180391180413180419180437180463180473180491180497180503180511180533180539180541180547180563180569180617180623180629180647180667180679180701180731180749180751180773180779180793180797180799180811180847180871180883180907180949180959181001181003181019181031181039181061181063181081181087181123181141181157181183181193181199181201181211181213181219181243181253181273181277181283181297181301181303181361181387181397181399181409181421181439181457181459181499181501181513181523181537181549181553181603181607181609181619181639181667181669181693181711181717181721181729181739181751181757181759181763181777181787181789181813181837181871181873181889181891181903181913181919181927181931181943181957181967181981181997182009182011182027182029182041182047182057182059182089182099182101182107182111182123182129182131182141182159182167182177182179182201182209182233182239182243182261182279182297182309182333182339182341182353182387182389182417182423182431182443182453182467182471182473182489182503182509182519182537182549182561182579182587182593182599182603182617182627182639182641182653182657182659182681182687182701182711182713182747182773182779182789182803182813182821182839182851182857182867182887182893182899182921182927182929182933182953182957182969182981182999183023183037183041183047183059183067183089183091183119183151183167183191183203183247183259183263183283183289183299183301183307183317183319183329183343183349183361183373183377183383183389183397183437183439183451183461183473183479183487183497183499183503183509183511183523183527183569183571183577183581183587183593183611183637183661183683183691183697183707183709183713183761183763183797183809183823183829183871183877183881183907183917183919183943183949183959183971183973183979184003184007184013184031184039184043184057184073184081184087184111184117184133184153184157184181184187184189184199184211184231184241184259184271184273184279184291184309184321184333184337184351184369184409184417184441184447184463184477184487184489184511184517184523184553184559184567184571184577184607184609184627184631184633184649184651184669184687184693184703184711184721184727184733184753184777184823184829184831184837184843184859184879184901184903184913184949184957184967184969184993184997184999185021185027185051185057185063185069185071185077185089185099185123185131185137185149185153185161185167185177185183185189185221185233185243185267185291185299185303185309185323185327185359185363185369185371185401185429185441185467185477185483185491185519185527185531185533185539185543185551185557185567185569185593185599185621185641185651185677185681185683185693185699185707185711185723185737185747185749185753185767185789185797185813185819185821185831185833185849185869185873185893185897185903185917185923185947185951185957185959185971185987185993186007186013186019186023186037186041186049186071186097186103186107186113186119186149186157186161186163186187186191186211186227186229186239186247186253186259186271186283186299186301186311186317186343186377186379186391186397186419186437186451186469186479186481186551186569186581186583186587186601186619186629186647186649186653186671186679186689186701186707186709186727186733186743186757186761186763186773186793186799186841186859186869186871186877186883186889186917186947186959187003187009187027187043187049187067187069187073187081187091187111187123187127187129187133187139187141187163187171187177187181187189187193187211187217187219187223187237187273187277187303187337187339187349187361187367187373187379187387187393187409187417187423187433187441187463187469187471187477187507187513187531187547187559187573187597187631187633187637187639187651187661187669187687187699187711187721187751187763187787187793187823187843187861187871187877187883187897187907187909187921187927187931187951187963187973187987188011188017188021188029188107188137188143188147188159188171188179188189188197188249188261188273188281188291188299188303188311188317188323188333188351188359188369188389188401188407188417188431188437188443188459188473188483188491188519188527188533188563188579188603188609188621188633188653188677188681188687188693188701188707188711188719188729188753188767188779188791188801188827188831188833188843188857188861188863188869188891188911188927188933188939188941188953188957188983188999189011189017189019189041189043189061189067189127189139189149189151189169189187189199189223189229189239189251189253189257189271189307189311189337189347189349189353189361189377189389189391189401189407189421189433189437189439189463189467189473189479189491189493189509189517189523189529189547189559189583189593189599189613189617189619189643189653189661189671189691189697189701189713189733189743189757189767189797189799189817189823189851189853189859189877189881189887189901189913189929189947189949189961189967189977189983189989189997190027190031190051190063190093190097190121190129190147190159190181190207190243190249190261190271190283190297190301190313190321190331190339190357190367190369190387190391190403190409190471190507190523190529190537190543190573190577190579190583190591190607190613190633190639190649190657190667190669190699190709190711190717190753190759190763190769190783190787190793190807190811190823190829190837190843190871190889190891190901190909190913190921190979190997191021191027191033191039191047191057191071191089191099191119191123191137191141191143191161191173191189191227191231191237191249191251191281191297191299191339191341191353191413191441191447191449191453191459191461191467191473191491191497191507191509191519191531191533191537191551191561191563191579191599191621191627191657191669191671191677191689191693191699191707191717191747191749191773191783191791191801191803191827191831191833191837191861191899191903191911191929191953191969191977191999192007192013192029192037192043192047192053192091192097192103192113192121192133192149192161192173192187192191192193192229192233192239192251192259192263192271192307192317192319192323192341192343192347192373192377192383192391192407192431192461192463192497192499192529192539192547192553192557192571192581192583192587192601192611192613192617192629192631192637192667192677192697192737192743192749192757192767192781192791192799192811192817192833192847192853192859192877192883192887192889192917192923192931192949192961192971192977192979192991193003193009193013193031193043193051193057193073193093193133193139193147193153193163193181193183193189193201193243193247193261193283193301193327193337193357193367193373193379193381193387193393193423193433193441193447193451193463193469193493193507193513193541193549193559193573193577193597193601193603193607193619193649193663193679193703193723193727193741193751193757193763193771193789193793193799193811193813193841193847193859193861193871193873193877193883193891193937193939193943193951193957193979193993194003194017194027194057194069194071194083194087194093194101194113194119194141194149194167194179194197194203194239194263194267194269194309194323194353194371194377194413194431194443194471194479194483194507194521194527194543194569194581194591194609194647194653194659194671194681194683194687194707194713194717194723194729194749194767194771194809194813194819194827194839194861194863194867194869194891194899194911194917194933194963194977194981194989195023195029195043195047195049195053195071195077195089195103195121195127195131195137195157195161195163195193195197195203195229195241195253195259195271195277195281195311195319195329195341195343195353195359195389195401195407195413195427195443195457195469195479195493195497195511195527195539195541195581195593195599195659195677195691195697195709195731195733195737195739195743195751195761195781195787195791195809195817195863195869195883195887195893195907195913195919195929195931195967195971195973195977195991195997196003196033196039196043196051196073196081196087196111196117196139196159196169196171196177196181196187196193196201196247196271196277196279196291196303196307196331196337196379196387196429196439196453196459196477196499196501196519196523196541196543196549196561196579196583196597196613196643196657196661196663196681196687196699196709196717196727196739196751196769196771196799196817196831196837196853196871196873196879196901196907196919196927196961196991196993197003197009197023197033197059197063197077197083197089197101197117197123197137197147197159197161197203197207197221197233197243197257197261197269197273197279197293197297197299197311197339197341197347197359197369197371197381197383197389197419197423197441197453197479197507197521197539197551197567197569197573197597197599197609197621197641197647197651197677197683197689197699197711197713197741197753197759197767197773197779197803197807197831197837197887197891197893197909197921197927197933197947197957197959197963197969197971198013198017198031198043198047198073198083198091198097198109198127198139198173198179198193198197198221198223198241198251198257198259198277198281198301198313198323198337198347198349198377198391198397198409198413198427198437198439198461198463198469198479198491198503198529198533198553198571198589198593198599198613198623198637198641198647198659198673198689198701198719198733198761198769198811198817198823198827198829198833198839198841198851198859198899198901198929198937198941198943198953198959198967198971198977198997199021199033199037199039199049199081199103199109199151199153199181199193199207199211199247199261199267199289199313199321199337199343199357199373199379199399199403199411199417199429199447199453199457199483199487199489199499199501199523199559199567199583199601199603199621199637199657199669199673199679199687199697199721199729199739199741199751199753199777199783199799199807199811199813199819199831199853199873199877199889199909199921199931199933199961199967199999200003200009200017200023200029200033200041200063200087200117200131200153200159200171200177200183200191200201200227200231200237200257200273200293200297200323200329200341200351200357200363200371200381200383200401200407200437200443200461200467200483200513200569200573200579200587200591200597200609200639200657200671200689200699200713200723200731200771200779200789200797200807200843200861200867200869200881200891200899200903200909200927200929200971200983200987200989201007201011201031201037201049201073201101201107201119201121201139201151201163201167201193201203201209201211201233201247201251201281201287201307201329201337201359201389201401201403201413201437201449201451201473201491201493201497201499201511201517201547201557201577201581201589201599201611201623201629201653201661201667201673201683201701201709201731201743201757201767201769201781201787201791201797201809201821201823201827201829201833201847201881201889201893201907201911201919201923201937201947201953201961201973201979201997202001202021202031202049202061202063202067202087202099202109202121202127202129202183202187202201202219202231202243202277202289202291202309202327202339202343202357202361202381202387202393202403202409202441202471202481202493202519202529202549202567202577202591202613202621202627202637202639202661202667202679202693202717202729202733202747202751202753202757202777202799202817202823202841202859202877202879202889202907202921202931202933202949202967202973202981202987202999203011203017203023203039203051203057203117203141203173203183203207203209203213203221203227203233203249203279203293203309203311203317203321203323203339203341203351203353203363203381203383203387203393203417203419203429203431203449203459203461203531203549203563203569203579203591203617203627203641203653203657203659203663203669203713203761203767203771203773203789203807203809203821203843203857203869203873203897203909203911203921203947203953203969203971203977203989203999204007204013204019204023204047204059204067204101204107204133204137204143204151204161204163204173204233204251204299204301204311204319204329204331204353204359204361204367204371204377204397204427204431204437204439204443204461204481204487204509204511204517204521204557204563204583204587204599204601204613204623204641204667204679204707204719204733204749204751204781204791204793204797204803204821204857204859204871204887204913204917204923204931204947204973204979204983205019205031205033205043205063205069205081205097205103205111205129205133205141205151205157205171205187205201205211205213205223205237205253205267205297205307205319205327205339205357205391205397205399205417205421205423205427205433205441205453205463205477205483205487205493205507205519205529205537205549205553205559205589205603205607205619205627205633205651205657205661205663205703205721205759205763205783205817205823205837205847205879205883205913205937205949205951205957205963205967205981205991205993206009206021206027206033206039206047206051206069206077206081206083206123206153206177206179206183206191206197206203206209206221206233206237206249206251206263206273206279206281206291206299206303206341206347206351206369206383206399206407206411206413206419206447206461206467206477206483206489206501206519206527206543206551206593206597206603206623206627206639206641206651206699206749206779206783206803206807206813206819206821206827206879206887206897206909206911206917206923206933206939206951206953206993207013207017207029207037207041207061207073207079207113207121207127207139207169207187207191207197207199207227207239207241207257207269207287207293207301207307207329207331207341207343207367207371207377207401207409207433207443207457207463207469207479207481207491207497207509207511207517207521207523207541207547207551207563207569207589207593207619207629207643207653207661207671207673207679207709207719207721207743207763207769207797207799207811207821207833207847207869207877207923207931207941207947207953207967207971207973207997208001208003208009208037208049208057208067208073208099208111208121208129208139208141208147208189208207208213208217208223208231208253208261208277208279208283208291208309208319208333208337208367208379208387208391208393208409208433208441208457208459208463208469208489208493208499208501208511208513208519208529208553208577208589208591208609208627208631208657208667208673208687208697208699208721208729208739208759208787208799208807208837208843208877208889208891208907208927208931208933208961208963208991208993208997209021209029209039209063209071209089209123209147209159209173209179209189209201209203209213209221209227209233209249209257209263209267209269209299209311209317209327209333209347209353209357209359209371209381209393209401209431209441209449209459209471209477209497209519209533209543209549209563209567209569209579209581209597209621209623209639209647209659209669209687209701209707209717209719209743209767209771209789209801209809209813209819209821209837209851209857209861209887209917209927209929209939209953209959209971209977209983209987210011210019210031210037210053210071210097210101210109210113210127210131210139210143210157210169210173210187210191210193210209210229210233210241210247210257210263210277210283210299210317210319210323210347210359210361210391210401210403210407210421210437210461210467210481210487210491210499210523210527210533210557210599210601210619210631210643210659210671210709210713210719210731210739210761210773210803210809210811210823210827210839210853210857210869210901210907210911210913210923210929210943210961210967211007211039211049211051211061211063211067211073211093211097211129211151211153211177211187211193211199211213211217211219211229211231211241211247211271211283211291211297211313211319211333211339211349211369211373211403211427211433211441211457211469211493211499211501211507211543211559211571211573211583211597211619211639211643211657211661211663211681211691211693211711211723211727211741211747211777211781211789211801211811211817211859211867211873211877211879211889211891211927211931211933211943211949211969211979211997212029212039212057212081212099212117212123212131212141212161212167212183212203212207212209212227212239212243212281212293212297212353212369212383212411212419212423212437212447212453212461212467212479212501212507212557212561212573212579212587212593212627212633212651212669212671212677212683212701212777212791212801212827212837212843212851212867212869212873212881212897212903212909212917212923212969212981212987212999213019213023213029213043213067213079213091213097213119213131213133213139213149213173213181213193213203213209213217213223213229213247213253213263213281213287213289213307213319213329213337213349213359213361213383213391213397213407213449213461213467213481213491213523213533213539213553213557213589213599213611213613213623213637213641213649213659213713213721213727213737213751213791213799213821213827213833213847213859213881213887213901213919213929213943213947213949213953213973213977213989214003214007214009214021214031214033214043214051214063214069214087214091214129214133214141214147214163214177214189214211214213214219214237214243214259214283214297214309214351214363214373214381214391214399214433214439214451214457214463214469214481214483214499214507214517214519214531214541214559214561214589214603214607214631214639214651214657214663214667214673214691214723214729214733214741214759214763214771214783214787214789214807214811214817214831214849214853214867214883214891214913214939214943214967214987214993215051215063215077215087215123215141215143215153215161215179215183215191215197215239215249215261215273215279215297215309215317215329215351215353215359215381215389215393215399215417215443215447215459215461215471215483215497215503215507215521215531215563215573215587215617215653215659215681215687215689215693215723215737215753215767215771215797215801215827215833215843215851215857215863215893215899215909215921215927215939215953215959215981215983216023216037216061216071216091216103216107216113216119216127216133216149216157216173216179216211216217216233216259216263216289216317216319216329216347216371216373216379216397216401216421216431216451216481216493216509216523216551216553216569216571216577216607216617216641216647216649216653216661216679216703216719216731216743216751216757216761216779216781216787216791216803216829216841216851216859216877216899216901216911216917216919216947216967216973216991217001217003217027217033217057217069217081217111217117217121217157217163217169217199217201217207217219217223217229217241217253217271217307217309217313217319217333217337217339217351217361217363217367217369217387217397217409217411217421217429217439217457217463217489217499217517217519217559217561217573217577217579217619217643217661217667217681217687217691217697217717217727217733217739217747217771217781217793217823217829217849217859217901217907217909217933217937217969217979217981218003218021218047218069218077218081218083218087218107218111218117218131218137218143218149218171218191218213218227218233218249218279218287218357218363218371218381218389218401218417218419218423218437218447218453218459218461218479218509218513218521218527218531218549218551218579218591218599218611218623218627218629218641218651218657218677218681218711218717218719218723218737218749218761218783218797218809218819218833218839218843218849218857218873218887218923218941218947218963218969218971218987218989218993219001219017219019219031219041219053219059219071219083219091219097219103219119219133219143219169219187219217219223219251219277219281219293219301219311219313219353219361219371219377219389219407219409219433219437219451219463219467219491219503219517219523219529219533219547219577219587219599219607219613219619219629219647219649219677219679219683219689219707219721219727219731219749219757219761219763219767219787219797219799219809219823219829219839219847219851219871219881219889219911219917219931219937219941219943219953219959219971219977219979219983220009220013220019220021220057220063220123220141220147220151220163220169220177220189220217220243220279220291220301220307220327220333220351220357220361220369220373220391220399220403220411220421220447220469220471220511220513220529220537220543220553220559220573220579220589220613220663220667220673220681220687220699220709220721220747220757220771220783220789220793220807220811220841220859220861220873220877220879220889220897220901220903220907220919220931220933220939220973221021221047221059221069221071221077221083221087221093221101221159221171221173221197221201221203221209221219221227221233221239221251221261221281221303221311221317221327221393221399221401221411221413221447221453221461221471221477221489221497221509221537221539221549221567221581221587221603221621221623221653221657221659221671221677221707221713221717221719221723221729221737221747221773221797221807221813221827221831221849221873221891221909221941221951221953221957221987221989221999222007222011222023222029222041222043222059222067222073222107222109222113222127222137222149222151222161222163222193222197222199222247222269222289222293222311222317222323222329222337222347222349222361222367222379222389222403222419222437222461222493222499222511222527222533222553222557222587222601222613222619222643222647222659222679222707222713222731222773222779222787222791222793222799222823222839222841222857222863222877222883222913222919222931222941222947222953222967222977222979222991223007223009223019223037223049223051223061223063223087223099223103223129223133223151223207223211223217223219223229223241223243223247223253223259223273223277223283223291223303223313223319223331223337223339223361223367223381223403223423223429223439223441223463223469223481223493223507223529223543223547223549223577223589223621223633223637223667223679223681223697223711223747223753223757223759223781223823223829223831223837223841223843223849223903223919223921223939223963223969223999224011224027224033224041224047224057224069224071224101224113224129224131224149224153224171224177224197224201224209224221224233224239224251224261224267224291224299224303224309224317224327224351224359224363224401224423224429224443224449224461224467224473224491224501224513224527224563224569224579224591224603224611224617224629224633224669224677224683224699224711224717224729224737224743224759224771224797224813224831224863224869224881224891224897224909224911224921224929224947224951224969224977224993225023225037225061225067225077225079225089225109225119225133225143225149225157225161225163225167225217225221225223225227225241225257225263225287225289225299225307225341225343225347225349225353225371225373225383225427225431225457225461225479225493225499225503225509225523225527225529225569225581225583225601225611225613225619225629225637225671225683225689225697225721225733225749225751225767225769225779225781225809225821225829225839225859225871225889225919225931225941225943225949225961225977225983225989226001226007226013226027226063226087226099226103226123226129226133226141226169226183226189226199226201226217226231226241226267226283226307226313226337226357226367226379226381226397226409226427226433226451226453226463226483226487226511226531226547226549226553226571226601226609226621226631226637226643226649226657226663226669226691226697226741226753226769226777226783226789226799226813226817226819226823226843226871226901226903226907226913226937226943226991227011227027227053227081227089227093227111227113227131227147227153227159227167227177227189227191227207227219227231227233227251227257227267227281227299227303227363227371227377227387227393227399227407227419227431227453227459227467227471227473227489227497227501227519227531227533227537227561227567227569227581227593227597227603227609227611227627227629227651227653227663227671227693227699227707227719227729227743227789227797227827227849227869227873227893227947227951227977227989227993228013228023228049228061228077228097228103228113228127228131228139228181228197228199228203228211228223228233228251228257228281228299228301228307228311228331228337228341228353228359228383228409228419228421228427228443228451228457228461228469228479228509228511228517228521228523228539228559228577228581228587228593228601228611228617228619228637228647228677228707228713228731228733228737228751228757228773228793228797228799228829228841228847228853228859228869228881228883228887228901228911228913228923228929228953228959228961228983228989229003229027229037229081229093229123229127229133229139229153229157229171229181229189229199229213229217229223229237229247229249229253229261229267229283229309229321229343229351229373229393229399229403229409229423229433229459229469229487229499229507229519229529229547229549229553229561229583229589229591229601229613229627229631229637229639229681229693229699229703229711229717229727229739229751229753229759229763229769229771229777229781229799229813229819229837229841229847229849229897229903229937229939229949229961229963229979229981230003230017230047230059230063230077230081230089230101230107230117230123230137230143230149230189230203230213230221230227230233230239230257230273230281230291230303230309230311230327230339230341230353230357230369230383230387230389230393230431230449230453230467230471230479230501230507230539230551230561230563230567230597230611230647230653230663230683230693230719230729230743230761230767230771230773230779230807230819230827230833230849230861230863230873230891230929230933230939230941230959230969230977230999231001231017231019231031231041231053231067231079231107231109231131231169231197231223231241231269231271231277231289231293231299231317231323231331231347231349231359231367231379231409231419231431231433231443231461231463231479231481231493231503231529231533231547231551231559231563231571231589231599231607231611231613231631231643231661231677231701231709231719231779231799231809231821231823231827231839231841231859231871231877231893231901231919231923231943231947231961231967232003232007232013232049232051232073232079232081232091232103232109232117232129232153232171232187232189232207232217232259232303232307232333232357232363232367232381232391232409232411232417232433232439232451232457232459232487232499232513232523232549232567232571232591232597232607232621232633232643232663232669232681232699232709232711232741232751232753232777232801232811232819232823232847232853232861232871232877232891232901232907232919232937232961232963232987233021233069233071233083233113233117233141233143233159233161233173233183233201233221233231233239233251233267233279233293233297233323233327233329233341233347233353233357233371233407233417233419233423233437233477233489233509233549233551233557233591233599233609233617233621233641233663233669233683233687233689233693233713233743233747233759233777233837233851233861233879233881233911233917233921233923233939233941233969233983233993234007234029234043234067234083234089234103234121234131234139234149234161234167234181234187234191234193234197234203234211234217234239234259234271234281234287234293234317234319234323234331234341234343234361234383234431234457234461234463234467234473234499234511234527234529234539234541234547234571234587234589234599234613234629234653234659234673234683234713234721234727234733234743234749234769234781234791234799234803234809234811234833234847234851234863234869234893234907234917234931234947234959234961234967234977234979234989235003235007235009235013235043235051235057235069235091235099235111235117235159235171235177235181235199235211235231235241235243235273235289235307235309235337235349235369235397235439235441235447235483235489235493235513235519235523235537235541235553235559235577235591235601235607235621235661235663235673235679235699235723235747235751235783235787235789235793235811235813235849235871235877235889235891235901235919235927235951235967235979235997236017236021236053236063236069236077236087236107236111236129236143236153236167236207236209236219236231236261236287236293236297236323236329236333236339236377236381236387236399236407236429236449236461236471236477236479236503236507236519236527236549236563236573236609236627236641236653236659236681236699236701236707236713236723236729236737236749236771236773236779236783236807236813236867236869236879236881236891236893236897236909236917236947236981236983236993237011237019237043237053237067237071237073237089237091237137237143237151237157237161237163237173237179237203237217237233237257237271237277237283237287237301237313237319237331237343237361237373237379237401237409237467237487237509237547237563237571237581237607237619237631237673237683237689237691237701237707237733237737237749237763237767237781237791237821237851237857237859237877237883237901237911237929237959237967237971237973237977237997238001238009238019238031238037238039238079238081238093238099238103238109238141238151238157238159238163238171238181238201238207238213238223238229238237238247238261238267238291238307238313238321238331238339238361238363238369238373238397238417238423238439238451238463238471238477238481238499238519238529238531238547238573238591238627238639238649238657238673238681238691238703238709238723238727238729238747238759238781238789238801238829238837238841238853238859238877238879238883238897238919238921238939238943238949238967238991239017239023239027239053239069239081239087239119239137239147239167239171239179239201239231239233239237239243239251239263239273239287239297239329239333239347239357239383239387239389239417239423239429239431239441239461239489239509239521239527239531239539239543239557239567239579239587239597239611239623239633239641239671239689239699239711239713239731239737239753239779239783239803239807239831239843239849239851239857239873239879239893239929239933239947239957239963239977239999240007240011240017240041240043240047240049240059240073240089240101240109240113240131240139240151240169240173240197240203240209240257240259240263240271240283240287240319240341240347240349240353240371240379240421240433240437240473240479240491240503240509240517240551240571240587240589240599240607240623240631240641240659240677240701240707240719240727240733240739240743240763240769240797240811240829240841240853240859240869240881240883240893240899240913240943240953240959240967240997241013241027241037241049241051241061241067241069241079241093241117241127241141241169241177241183241207241229241249241253241259241261241271241291241303241313241321241327241333241337241343241361241363241391241393241421241429241441241453241463241469241489241511241513241517241537241543241559241561241567241589241597241601241603241639241643241651241663241667241679241687241691241711241727241739241771241781241783241793241807241811241817241823241847241861241867241873241877241883241903241907241919241921241931241939241951241963241973241979241981241993242009242057242059242069242083242093242101242119242129242147242161242171242173242197242201242227242243242257242261242273242279242309242329242357242371242377242393242399242413242419242441242447242449242453242467242479242483242491242509242519242521242533242551242591242603242617242621242629242633242639242647242659242677242681242689242713242729242731242747242773242779242789242797242807242813242819242863242867242873242887242911242923242927242971242989242999243011243031243073243077243091243101243109243119243121243137243149243157243161243167243197243203243209243227243233243239243259243263243301243311243343243367243391243401243403243421243431243433243437243461243469243473243479243487243517243521243527243533243539243553243577243583243587243589243613243623243631243643243647243671243673243701243703243707243709243769243781243787243799243809243829243839243851243857243863243871243889243911243917243931243953243973243989244003244009244021244033244043244087244091244109244121244129244141244147244157244159244177244199244217244219244243244247244253244261244291244297244301244303244313244333244339244351244357244367244379244381244393244399244403244411244423244429244451244457244463244471244481244493244507244529244547244553244561244567244583244589244597244603244619244633244637244639244667244669244687244691244703244711244721244733244747244753244759244781244787244813244837244841244843244859244861244873244877244889244897244901244939244943244957244997245023245029245033245039245071245083245087245107245129245131245149245171245173245177245183245209245251245257245261245269245279245291245299245317245321245339245383245389245407245411245417245419245437245471245473245477245501245513245519245521245527245533245561245563245587245591245593245621245627245629245639245653245671245681245683245711245719245723245741245747245753245759245771245783245789245821245849245851245863245881245897245899245909245911245941245963245977245981245983245989246011246017246049246073246097246119246121246131246133246151246167246173246187246193246203246209246217246223246241246247246251246271246277246289246317246319246329246343246349246361246371246391246403246439246469246473246497246509246511246523246527246539246557246569246577246599246607246611246613246637246641246643246661246683246689246707246709246713246731246739246769246773246781246787246793246803246809246811246817246833246839246889246899246907246913246919246923246929246931246937246941246947246971246979247001247007247031247067247069247073247087247099247141247183247193247201247223247229247241247249247259247279247301247309247337247339247343247363247369247381247391247393247409247421247433247439247451247463247501247519247529247531247547247553247579247591247601247603247607247609247613247633247649247651247691247693247697247711247717247729247739247759247769247771247781247799247811247813247829247847247853247873247879247889247901247913247939247943247957247991247993247997247999248021248033248041248051248057248063248071248077248089248099248117248119248137248141248161248167248177248179248189248201248203248231248243248257248267248291248293248299248309248317248323248351248357248371248389248401248407248431248441248447248461248473248477248483248509248533248537248543248569248579248587248593248597248609248621248627248639248641248657248683248701248707248719248723248737248749248753248779248783248789248797248813248821248827248839248851248861248867248869248879248887248891248893248903248909248971248981248987249017249037249059249079249089249097249103249107249127249131249133249143249181249187249199249211249217249229249233249253249257249287249311249317249329249341249367249377249383249397249419249421249427249433249437249439249449249463249497249499249503249517249521249533249539249541249563249583249589249593249607249647249659249671249677249703249721249727249737249749249763249779249797249811249827249833249853249857249859249863249871249881249911249923249943249947249967249971249973249989250007250013250027250031250037250043250049250051250057250073250091250109250123250147250153250169250199250253250259250267250279250301250307250343250361250403250409250423250433250441250451250489250499250501250543250583250619250643250673250681250687250693250703250709250721250727250739250741250751250753250777250787250793250799250807250813250829250837250841250853250867250871250889250919250949250951250963250967250969250979250993251003251033251051251057251059251063251071251081251087251099251117251143251149251159251171251177251179251191251197251201251203251219251221251231251233251257251261251263251287251291251297251323251347251353251359251387251393251417251429251431251437251443251467251473251477251483251491251501251513251519251527251533251539251543251561251567251609251611251621251623251639251653251663251677251701251707251737251761251789251791251809251831251833251843251857251861251879251887251893251897251903251917251939251941251947251969251971251983252001252013252017252029252037252079252101252139252143252151252157252163252169252173252181252193252209252223252233252253252277252283252289252293252313252319252323252341252359252383252391252401252409252419252431252443252449252457252463252481252509252533252541252559252583252589252607252611252617252641252667252691252709252713252727252731252737252761252767252779252817252823252827252829252869252877252881252887252893252899252911252913252919252937252949252971252979252983253003253013253049253063253081253103253109253133253153253157253159253229253243253247253273253307253321253343253349253361253367253369253381253387253417253423253427253433253439253447253469253481253493253501253507253531253537253543253553253567253573253601253607253609253613253633253637253639253651253661253679253681253703253717253733253741253751253763253769253777253787253789253801253811253819253823253853253867253871253879253901253907253909253919253937253949253951253969253987253993253999254003254021254027254039254041254047254053254071254083254119254141254147254161254179254197254207254209254213254249254257254279254281254291254299254329254369254377254383254389254407254413254437254447254461254489254491254519254537254557254593254623254627254647254659254663254699254713254729254731254741254747254753254773254777254783254791254803254827254831254833254857254869254873254879254887254899254911254927254929254941254959254963254971254977254987254993255007255019255023255043255049255053255071255077255083255097255107255121255127255133255137255149255173255179255181255191255193255197255209255217255239255247255251255253255259255313255329255349255361255371255383255413255419255443255457255467255469255473255487255499255503255511255517255523255551255571255587255589255613255617255637255641255649255653255659255667255679255709255713255733255743255757255763255767255803255839255841255847255851255859255869255877255887255907255917255919255923255947255961255971255973255977255989256019256021256031256033256049256057256079256093256117256121256129256133256147256163256169256181256187256189256199256211256219256279256301256307256313256337256349256363256369256391256393256423256441256469256471256483256489256493256499256517256541256561256567256577256579256589256603256609256639256643256651256661256687256699256721256723256757256771256799256801256813256831256873256877256889256901256903256931256939256957256967256981257003257017257053257069257077257093257099257107257123257141257161257171257177257189257219257221257239257249257263257273257281257287257293257297257311257321257339257351257353257371257381257399257401257407257437257443257447257459257473257489257497257501257503257519257539257561257591257611257627257639257657257671257687257689257707257711257713257717257731257783257791257797257837257857257861257863257867257869257879257893257903257921257947257953257981257987257989257993258019258023258031258061258067258101258107258109258113258119258127258131258143258157258161258173258197258211258233258241258253258277258283258299258317258319258329258331258337258353258373258389258403258407258413258421258437258443258449258469258487258491258499258521258527258539258551258563258569258581258607258611258613258617258623258631258637258659258673258677258691258697258703258707258721258733258737258743258763258779258787258803258809258827258847258871258887258917258919258949258959258967258971258977258983258991259001259009259019259033259099259121259123259151259157259159259163259169259177259183259201259211259213259219259229259271259277259309259321259339259379259381259387259397259411259421259429259451259453259459259499259507259517259531259537259547259577259583259603259619259621259627259631259639259643259657259667259681259691259697259717259723259733259751259771259781259783259801259813259823259829259837259841259867259907259933259937259943259949259967259991259993260003260009260011260017260023260047260081260089260111260137260171260179260189260191260201260207260209260213260231260263260269260317260329260339260363260387260399260411260413260417260419260441260453260461260467260483260489260527260539260543260549260551260569260573260581260587260609260629260647260651260671260677260713260717260723260747260753260761260773260791260807260809260849260857260861260863260873260879260893260921260941260951260959260969260983260987260999261011261013261017261031261043261059261061261071261077261089261101261127261167261169261223261229261241261251261271261281261301261323261329261337261347261353261379261389261407261427261431261433261439261451261463261467261509261523261529261557261563261577261581261587261593261601261619261631261637261641261643261673261697261707261713261721261739261757261761261773261787261791261799261823261847261881261887261917261959261971261973261977261983262007262027262049262051262069262079262103262109262111262121262127262133262139262147262151262153262187262193262217262231262237262253262261262271262303262313262321262331262337262349262351262369262387262391262399262411262433262459262469262489262501262511262513262519262541262543262553262567262583262597262621262627262643262649262651262657262681262693262697262709262723262733262739262741262747262781262783262807262819262853262877262883262897262901262909262937262949262957262981263009263023263047263063263071263077263083263089263101263111263119263129263167263171263183263191263201263209263213263227263239263257263267263269263273263287263293263303263323263369263383263387263399263401263411263423263429263437263443263489263491263503263513263519263521263533263537263561263567263573263591263597263609263611263621263647263651263657263677263723263729263737263759263761263803263819263821263827263843263849263863263867263869263881263899263909263911263927263933263941263951263953263957263983264007264013264029264031264053264059264071264083264091264101264113264127264133264137264139264167264169264179264211264221264263264269264283264289264301264323264331264343264349264353264359264371264391264403264437264443264463264487264527264529264553264559264577264581264599264601264619264631264637264643264659264697264731264739264743264749264757264763264769264779264787264791264793264811264827264829264839264871264881264889264893264899264919264931264949264959264961264977264991264997265003265007265021265037265079265091265093265117265123265129265141265151265157265163265169265193265207265231265241265247265249265261265271265273265277265313265333265337265339265381265399265403265417265423265427265451265459265471265483265493265511265513265541265543265547265561265567265571265579265607265613265619265621265703265709265711265717265729265739265747265757265781265787265807265813265819265831265841265847265861265871265873265883265891265921265957265961265987266003266009266023266027266029266047266051266053266059266081266083266089266093266099266111266117266129266137266153266159266177266183266221266239266261266269266281266291266293266297266333266351266353266359266369266381266401266411266417266447266449266477266479266489266491266521266549266587266599266603266633266641266647266663266671266677266681266683266687266689266701266711266719266759266767266797266801266821266837266839266863266867266891266897266899266909266921266927266933266947266953266957266971266977266983266993266999267017267037267049267097267131267133267139267143267167267187267193267199267203267217267227267229267233267259267271267277267299267301267307267317267341267353267373267389267391267401267403267413267419267431267433267439267451267469267479267481267493267497267511267517267521267523267541267551267557267569267581267587267593267601267611267613267629267637267643267647267649267661267667267671267677267679267713267719267721267727267737267739267749267763267781267791267797267803267811267829267833267857267863267877267887267893267899267901267907267913267929267941267959267961268003268013268043268049268063268069268091268123268133268153268171268189268199268207268211268237268253268267268271268283268291268297268343268403268439268459268487268493268501268507268517268519268529268531268537268547268573268607268613268637268643268661268693268721268729268733268747268757268759268771268777268781268783268789268811268813268817268819268823268841268843268861268883268897268909268913268921268927268937268969268973268979268993268997268999269023269029269039269041269057269063269069269089269117269131269141269167269177269179269183269189269201269209269219269221269231269237269251269257269281269317269327269333269341269351269377269383269387269389269393269413269419269429269431269441269461269473269513269519269527269539269543269561269573269579269597269617269623269641269651269663269683269701269713269719269723269741269749269761269779269783269791269851269879269887269891269897269923269939269947269953269981269987270001270029270031270037270059270071270073270097270121270131270133270143270157270163270167270191270209270217270223270229270239270241270269270271270287270299270307270311270323270329270337270343270371270379270407270421270437270443270451270461270463270493270509270527270539270547270551270553270563270577270583270587270593270601270619270631270653270659270667270679270689270701270709270719270737270749270761270763270791270797270799270821270833270841270859270899270913270923270931270937270953270961270967270973271003271013271021271027271043271057271067271079271097271109271127271129271163271169271177271181271211271217271231271241271253271261271273271277271279271289271333271351271357271363271367271393271409271429271451271463271471271483271489271499271501271517271549271553271571271573271597271603271619271637271639271651271657271693271703271723271729271753271769271771271787271807271811271829271841271849271853271861271867271879271897271903271919271927271939271967271969271981272003272009272011272029272039272053272059272093272131272141272171272179272183272189272191272201272203272227272231272249272257272263272267272269272287272299272317272329272333272341272347272351272353272359272369272381272383272399272407272411272417272423272449272453272477272507272533272537272539272549272563272567272581272603272621272651272659272683272693272717272719272737272759272761272771272777272807272809272813272863272879272887272903272911272917272927272933272959272971272981272983272989272999273001273029273043273047273059273061273067273073273083273107273113273127273131273149273157273181273187273193273233273253273269273271273281273283273289273311273313273323273349273359273367273433273457273473273503273517273521273527273551273569273601273613273617273629273641273643273653273697273709273719273727273739273773273787273797273803273821273827273857273881273899273901273913273919273929273941273943273967273971273979273997274007274019274033274061274069274081274093274103274117274121274123274139274147274163274171274177274187274199274201274213274223274237274243274259274271274277274283274301274333274349274357274361274403274423274441274451274453274457274471274489274517274529274579274583274591274609274627274661274667274679274693274697274709274711274723274739274751274777274783274787274811274817274829274831274837274843274847274853274861274867274871274889274909274931274943274951274957274961274973274993275003275027275039275047275053275059275083275087275129275131275147275153275159275161275167275183275201275207275227275251275263275269275299275309275321275323275339275357275371275389275393275399275419275423275447275449275453275459275461275489275491275503275521275531275543275549275573275579275581275591275593275599275623275641275651275657275669275677275699275711275719275729275741275767275773275783275813275827275837275881275897275911275917275921275923275929275939275941275963275969275981275987275999276007276011276019276037276041276043276047276049276079276083276091276113276137276151276173276181276187276191276209276229276239276247276251276257276277276293276319276323276337276343276347276359276371276373276389276401276439276443276449276461276467276487276499276503276517276527276553276557276581276587276589276593276599276623276629276637276671276673276707276721276739276763276767276779276781276817276821276823276827276833276839276847276869276883276901276907276917276919276929276949276953276961276977277003277007277021277051277063277073277087277097277099277157277163277169277177277183277213277217277223277231277247277259277261277273277279277297277301277309277331277363277373277411277421277427277429277483277493277499277513277531277547277549277567277577277579277597277601277603277637277639277643277657277663277687277691277703277741277747277751277757277787277789277793277813277829277847277859277883277889277891277897277903277919277961277993277999278017278029278041278051278063278071278087278111278119278123278143278147278149278177278191278207278209278219278227278233278237278261278269278279278321278329278347278353278363278387278393278413278437278459278479278489278491278497278501278503278543278549278557278561278563278581278591278609278611278617278623278627278639278651278671278687278689278701278717278741278743278753278767278801278807278809278813278819278827278843278849278867278879278881278891278903278909278911278917278947278981279001279007279023279029279047279073279109279119279121279127279131279137279143279173279179279187279203279211279221279269279311279317279329279337279353279397279407279413279421279431279443279451279479279481279511279523279541279551279553279557279571279577279583279593279607279613279619279637279641279649279659279679279689279707279709279731279751279761279767279779279817279823279847279857279863279883279913279919279941279949279967279977279991280001280009280013280031280037280061280069280097280099280103280121280129280139280183280187280199280207280219280223280229280243280249280253280277280297280303280321280327280337280339280351280373280409280411280451280463280487280499280507280513280537280541280547280549280561280583280589280591280597280603280607280613280627280639280673280681280697280699280703280711280717280729280751280759280769280771280811280817280837280843280859280871280879280883280897280909280913280921280927280933280939280949280957280963280967280979280997281023281033281053281063281069281081281117281131281153281159281167281189281191281207281227281233281243281249281251281273281279281291281297281317281321281327281339281353281357281363281381281419281423281429281431281509281527281531281539281549281551281557281563281579281581281609281621281623281627281641281647281651281653281663281669281683281717281719281737281747281761281767281777281783281791281797281803281807281833281837281839281849281857281867281887281893281921281923281927281933281947281959281971281989281993282001282011282019282053282059282071282089282091282097282101282103282127282143282157282167282221282229282239282241282253282281282287282299282307282311282313282349282377282383282389282391282407282409282413282427282439282461282481282487282493282559282563282571282577282589282599282617282661282671282677282679282683282691282697282703282707282713282767282769282773282797282809282827282833282847282851282869282881282889282907282911282913282917282959282973282977282991283001283007283009283027283051283079283093283097283099283111283117283121283133283139283159283163283181283183283193283207283211283267283277283289283303283369283397283403283411283447283463283487283489283501283511283519283541283553283571283573283579283583283601283607283609283631283637283639283669283687283697283721283741283763283769283771283793283799283807283813283817283831283837283859283861283873283909283937283949283957283961283979284003284023284041284051284057284059284083284093284111284117284129284131284149284153284159284161284173284191284201284227284231284233284237284243284261284267284269284293284311284341284357284369284377284387284407284413284423284429284447284467284477284483284489284507284509284521284527284539284551284561284573284587284591284593284623284633284651284657284659284681284689284701284707284723284729284731284737284741284743284747284749284759284777284783284803284807284813284819284831284833284839284857284881284897284899284917284927284957284969284989285007285023285031285049285071285079285091285101285113285119285121285139285151285161285179285191285199285221285227285251285281285283285287285289285301285317285343285377285421285433285451285457285463285469285473285497285517285521285533285539285553285557285559285569285599285611285613285629285631285641285643285661285667285673285697285707285709285721285731285749285757285763285767285773285781285823285827285839285841285871285937285949285953285977285979285983285997286001286009286019286043286049286061286063286073286103286129286163286171286199286243286249286289286301286333286367286369286381286393286397286411286421286427286453286457286459286469286477286483286487286493286499286513286519286541286543286547286553286589286591286609286613286619286633286651286673286687286697286703286711286721286733286751286753286763286771286777286789286801286813286831286859286873286927286973286981286987286999287003287047287057287059287087287093287099287107287117287137287141287149287159287167287173287179287191287219287233287237287239287251287257287269287279287281287291287297287321287327287333287341287347287383287387287393287437287449287491287501287503287537287549287557287579287597287611287629287669287671287681287689287701287731287747287783287789287801287813287821287849287851287857287863287867287873287887287921287933287939287977288007288023288049288053288061288077288089288109288137288179288181288191288199288203288209288227288241288247288257288283288293288307288313288317288349288359288361288383288389288403288413288427288433288461288467288481288493288499288527288529288539288551288559288571288577288583288647288649288653288661288679288683288689288697288731288733288751288767288773288803288817288823288833288839288851288853288877288907288913288929288931288947288973288979288989288991288997289001289019289021289031289033289039289049289063289067289099289103289109289111289127289129289139289141289151289169289171289181289189289193289213289241289243289249289253289273289283289291289297289309289319289343289349289361289369289381289397289417289423289439289453289463289469289477289489289511289543289559289573289577289589289603289607289637289643289657289669289717289721289727289733289741289759289763289771289789289837289841289843289847289853289859289871289889289897289937289951289957289967289973289987289999290011290021290023290027290033290039290041290047290057290083290107290113290119290137290141290161290183290189290201290209290219290233290243290249290317290327290347290351290359290369290383290393290399290419290429290441290443290447290471290473290489290497290509290527290531290533290539290557290593290597290611290617290621290623290627290657290659290663290669290671290677290701290707290711290737290761290767290791290803290821290827290837290839290861290869290879290897290923290959290963290971290987290993290999291007291013291037291041291043291077291089291101291103291107291113291143291167291169291173291191291199291209291217291253291257291271291287291293291299291331291337291349291359291367291371291373291377291419291437291439291443291457291481291491291503291509291521291539291547291559291563291569291619291647291649291661291677291689291691291701291721291727291743291751291779291791291817291829291833291853291857291869291877291887291899291901291923291971291979291983291997292021292027292037292057292069292079292081292091292093292133292141292147292157292181292183292223292231292241292249292267292283292301292309292319292343292351292363292367292381292393292427292441292459292469292471292477292483292489292493292517292531292541292549292561292573292577292601292627292631292661292667292673292679292693292703292709292711292717292727292753292759292777292793292801292807292819292837292841292849292867292879292909292921292933292969292973292979292993293021293071293081293087293093293099293107293123293129293147293149293173293177293179293201293207293213293221293257293261293263293269293311293329293339293351293357293399293413293431293441293453293459293467293473293483293507293543293599293603293617293621293633293639293651293659293677293681293701293717293723293729293749293767293773293791293803293827293831293861293863293893293899293941293957293983293989293999294001294013294023294029294043294053294059294067294103294127294131294149294157294167294169294179294181294199294211294223294227294241294247294251294269294277294289294293294311294313294317294319294337294341294347294353294383294391294397294403294431294439294461294467294479294499294509294523294529294551294563294629294641294647294649294659294673294703294731294751294757294761294773294781294787294793294799294803294809294821294829294859294869294887294893294911294919294923294947294949294953294979294989294991294997295007295033295037295039295049295073295079295081295111295123295129295153295187295199295201295219295237295247295259295271295277295283295291295313295319295333295357295363295387295411295417295429295433295439295441295459295513295517295541295553295567295571295591295601295663295693295699295703295727295751295759295769295777295787295819295831295837295843295847295853295861295871295873295877295879295901295903295909295937295943295949295951295961295973295993296011296017296027296041296047296071296083296099296117296129296137296159296183296201296213296221296237296243296249296251296269296273296279296287296299296347296353296363296369296377296437296441296473296477296479296489296503296507296509296519296551296557296561296563296579296581296587296591296627296651296663296669296683296687296693296713296719296729296731296741296749296753296767296771296773296797296801296819296827296831296833296843296909296911296921296929296941296969296971296981296983296987297019297023297049297061297067297079297083297097297113297133297151297161297169297191297233297247297251297257297263297289297317297359297371297377297391297397297403297421297439297457297467297469297481297487297503297509297523297533297581297589297601297607297613297617297623297629297641297659297683297691297707297719297727297757297779297793297797297809297811297833297841297853297881297889297893297907297911297931297953297967297971297989297991298013298021298031298043298049298063298087298093298099298153298157298159298169298171298187298201298211298213298223298237298247298261298283298303298307298327298339298343298349298369298373298399298409298411298427298451298477298483298513298559298579298583298589298601298607298621298631298651298667298679298681298687298691298693298709298723298733298757298759298777298799298801298817298819298841298847298853298861298897298937298943298993298999299011299017299027299029299053299059299063299087299099299107299113299137299147299171299179299191299197299213299239299261299281299287299311299317299329299333299357299359299363299371299389299393299401299417299419299447299471299473299477299479299501299513299521299527299539299567299569299603299617299623299653299671299681299683299699299701299711299723299731299743299749299771299777299807299843299857299861299881299891299903299909299933299941299951299969299977299983299993300007300017300023300043300073300089300109300119300137300149300151300163300187300191300193300221300229300233300239300247300277300299300301300317300319300323300331300343300347300367300397300413300427300431300439300463300481300491300493300497300499300511300557300569300581300583300589300593300623300631300647300649300661300667300673300683300691300719300721300733300739300743300749300757300761300779300787300799300809300821300823300851300857300869300877300889300893300929300931300953300961300967300973300977300997301013301027301039301051301057301073301079301123301127301141301153301159301177301181301183301211301219301237301241301243301247301267301303301319301331301333301349301361301363301381301403301409301423301429301447301459301463301471301487301489301493301501301531301577301579301583301591301601301619301627301643301649301657301669301673301681301703301711301747301751301753301759301789301793301813301831301841301843301867301877301897301901301907301913301927301933301943301949301979301991301993301997301999302009302053302111302123302143302167302171302173302189302191302213302221302227302261302273302279302287302297302299302317302329302399302411302417302429302443302459302483302507302513302551302563302567302573302579302581302587302593302597302609302629302647302663302681302711302723302747302759302767302779302791302801302831302833302837302843302851302857302873302891302903302909302921302927302941302959302969302971302977302983302989302999303007303011303013303019303029303049303053303073303089303091303097303119303139303143303151303157303187303217303257303271303283303287303293303299303307303313303323303337303341303361303367303371303377303379303389303409303421303431303463303469303473303491303493303497303529303539303547303551303553303571303581303587303593303613303617303619303643303647303649303679303683303689303691303703303713303727303731303749303767303781303803303817303827303839303859303871303889303907303917303931303937303959303983303997304009304013304021304033304039304049304063304067304069304081304091304099304127304151304153304163304169304193304211304217304223304253304259304279304301304303304331304349304357304363304373304391304393304411304417304429304433304439304457304459304477304481304489304501304511304517304523304537304541304553304559304561304597304609304631304643304651304663304687304709304723304729304739304751304757304763304771304781304789304807304813304831304847304849304867304879304883304897304901304903304907304933304937304943304949304961304979304981305017305021305023305029305033305047305069305093305101305111305113305119305131305143305147305209305219305231305237305243305267305281305297305329305339305351305353305363305369305377305401305407305411305413305419305423305441305449305471305477305479305483305489305497305521305533305551305563305581305593305597305603305611305621305633305639305663305717305719305741305743305749305759305761305771305783305803305821305839305849305857305861305867305873305917305927305933305947305971305999306011306023306029306041306049306083306091306121306133306139306149306157306167306169306191306193306209306239306247306253306259306263306301306329306331306347306349306359306367306377306389306407306419306421306431306437306457306463306473306479306491306503306511306517306529306533306541306563306577306587306589306643306653306661306689306701306703306707306727306739306749306763306781306809306821306827306829306847306853306857306871306877306883306893306899306913306919306941306947306949306953306991307009307019307031307033307067307079307091307093307103307121307129307147307163307169307171307187307189307201307243307253307259307261307267307273307277307283307289307301307337307339307361307367307381307397307399307409307423307451307471307481307511307523307529307537307543307577307583307589307609307627307631307633307639307651307669307687307691307693307711307733307759307817307823307831307843307859307871307873307891307903307919307939307969308003308017308027308041308051308081308093308101308107308117308129308137308141308149308153308213308219308249308263308291308293308303308309308311308317308323308327308333308359308383308411308423308437308447308467308489308491308501308507308509308519308521308527308537308551308569308573308587308597308621308639308641308663308681308701308713308723308761308773308801308809308813308827308849308851308857308887308899308923308927308929308933308939308951308989308999309007309011309013309019309031309037309059309079309083309091309107309109309121309131309137309157309167309173309193309223309241309251309259309269309271309277309289309293309311309313309317309359309367309371309391309403309433309437309457309461309469309479309481309493309503309521309523309539309541309559309571309577309583309599309623309629309637309667309671309677309707309713309731309737309769309779309781309797309811309823309851309853309857309877309899309929309931309937309977309989310019310021310027310043310049310081310087310091310111310117310127310129310169310181310187310223310229310231310237310243310273310283310291310313310333310357310361310363310379310397310423310433310439310447310459310463310481310489310501310507310511310547310553310559310567310571310577310591310627310643310663310693310697310711310721310727310729310733310741310747310771310781310789310801310819310823310829310831310861310867310883310889310901310927310931310949310969310987310997311009311021311027311033311041311099311111311123311137311153311173311177311183311189311197311203311237311279311291311293311299311303311323311329311341311347311359311371311393311407311419311447311453311473311533311537311539311551311557311561311567311569311603311609311653311659311677311681311683311687311711311713311737311743311747311749311791311803311807311821311827311867311869311881311897311951311957311963311981312007312023312029312031312043312047312071312073312083312089312101312107312121312161312197312199312203312209312211312217312229312233312241312251312253312269312281312283312289312311312313312331312343312349312353312371312383312397312401312407312413312427312451312469312509312517312527312551312553312563312581312583312589312601312617312619312623312643312673312677312679312701312703312709312727312737312743312757312773312779312799312839312841312857312863312887312899312929312931312937312941312943312967312971312979312989313003313009313031313037313081313087313109313127313129313133313147313151313153313163313207313211313219313241313249313267313273313289313297313301313307313321313331313333313343313351313373313381313387313399313409313471313477313507313517313543313549313553313561313567313571313583313589313597313603313613313619313637313639313661313669313679313699313711313717313721313727313739313741313763313777313783313829313849313853313879313883313889313897313909313921313931313933313949313961313969313979313981313987313991313993313997314003314021314059314063314077314107314113314117314129314137314159314161314173314189314213314219314227314233314239314243314257314261314263314267314299314329314339314351314357314359314399314401314407314423314441314453314467314491314497314513314527314543314549314569314581314591314597314599314603314623314627314641314651314693314707314711314719314723314747314761314771314777314779314807314813314827314851314879314903314917314927314933314953314957314983314989315011315013315037315047315059315067315083315097315103315109315127315179315181315193315199315223315247315251315257315269315281315313315349315361315373315377315389315407315409315421315437315449315451315461315467315481315493315517315521315527315529315547315551315559315569315589315593315599315613315617315631315643315671315677315691315697315701315703315739315743315751315779315803315811315829315851315857315881315883315893315899315907315937315949315961315967315977316003316031316033316037316051316067316073316087316097316109316133316139316153316177316189316193316201316213316219316223316241316243316259316271316291316297316301316321316339316343316363316373316391316403316423316429316439316453316469316471316493316499316501316507316531316567316571316577316583316621316633316637316649316661316663316681316691316697316699316703316717316753316759316769316777316783316793316801316817316819316847316853316859316861316879316891316903316907316919316937316951316957316961316991317003317011317021317029317047317063317071317077317087317089317123317159317171317179317189317197317209317227317257317263317267317269317279317321317323317327317333317351317353317363317371317399317411317419317431317437317453317459317483317489317491317503317539317557317563317587317591317593317599317609317617317621317651317663317671317693317701317711317717317729317731317741317743317771317773317777317783317789317797317827317831317839317857317887317903317921317923317957317959317963317969317971317983317987318001318007318023318077318103318107318127318137318161318173318179318181318191318203318209318211318229318233318247318259318271318281318287318289318299318301318313318319318323318337318347318349318377318403318407318419318431318443318457318467318473318503318523318557318559318569318581318589318601318629318641318653318671318677318679318683318691318701318713318737318743318749318751318781318793318809318811318817318823318833318841318863318881318883318889318907318911318917318919318949318979319001319027319031319037319049319057319061319069319093319097319117319127319129319133319147319159319169319183319201319211319223319237319259319279319289319313319321319327319339319343319351319357319387319391319399319411319427319433319439319441319453319469319477319483319489319499319511319519319541319547319567319577319589319591319601319607319639319673319679319681319687319691319699319727319729319733319747319757319763319811319817319819319829319831319849319883319897319901319919319927319931319937319967319973319981319993320009320011320027320039320041320053320057320063320081320083320101320107320113320119320141320143320149320153320179320209320213320219320237320239320267320269320273320291320293320303320317320329320339320377320387320389320401320417320431320449320471320477320483320513320521320533320539320561320563320591320609320611320627320647320657320659320669320687320693320699320713320741320759320767320791320821320833320839320843320851320861320867320899320911320923320927320939320941320953321007321017321031321037321047321053321073321077321091321109321143321163321169321187321193321199321203321221321227321239321247321289321301321311321313321319321323321329321331321341321359321367321371321383321397321403321413321427321443321449321467321469321509321547321553321569321571321577321593321611321617321619321631321647321661321679321707321709321721321733321743321751321757321779321799321817321821321823321829321833321847321851321889321901321911321947321949321961321983321991322001322009322013322037322039322051322057322067322073322079322093322097322109322111322139322169322171322193322213322229322237322243322247322249322261322271322319322327322339322349322351322397322403322409322417322429322433322459322463322501322513322519322523322537322549322559322571322573322583322589322591322607322613322627322631322633322649322669322709322727322747322757322769322771322781322783322807322849322859322871322877322891322901322919322921322939322951322963322969322997322999323003323009323027323053323077323083323087323093323101323123323131323137323149323201323207323233323243323249323251323273323333323339323341323359323369323371323377323381323383323413323419323441323443323467323471323473323507323509323537323549323567323579323581323591323597323599323623323641323647323651323699323707323711323717323759323767323789323797323801323803323819323837323879323899323903323923323927323933323951323957323987324011324031324053324067324073324089324097324101324113324119324131324143324151324161324179324199324209324211324217324223324239324251324293324299324301324319324329324341324361324391324397324403324419324427324431324437324439324449324451324469324473324491324497324503324517324523324529324557324587324589324593324617324619324637324641324647324661324673324689324697324707324733324743324757324763324773324781324791324799324809324811324839324847324869324871324889324893324901324931324941324949324953324977324979324983324991324997325001325009325019325021325027325043325051325063325079325081325093325133325153325163325181325187325189325201325217325219325229325231325249325271325301325307325309325319325333325343325349325379325411325421325439325447325453325459325463325477325487325513325517325537325541325543325571325597325607325627325631325643325667325673325681325691325693325697325709325723325729325747325751325753325769325777325781325783325807325813325849325861325877325883325889325891325901325921325939325943325951325957325987325993325999326023326057326063326083326087326099326101326113326119326141326143326147326149326153326159326171326189326203326219326251326257326309326323326351326353326369326437326441326449326467326479326497326503326537326539326549326561326563326567326581326593326597326609326611326617326633326657326659326663326681326687326693326701326707326737326741326773326779326831326863326867326869326873326881326903326923326939326941326947326951326983326993326999327001327007327011327017327023327059327071327079327127327133327163327179327193327203327209327211327247327251327263327277327289327307327311327317327319327331327337327343327347327401327407327409327419327421327433327443327463327469327473327479327491327493327499327511327517327529327553327557327559327571327581327583327599327619327629327647327661327667327673327689327707327721327737327739327757327779327797327799327809327823327827327829327839327851327853327869327871327881327889327917327923327941327953327967327979327983328007328037328043328051328061328063328067328093328103328109328121328127328129328171328177328213328243328249328271328277328283328291328303328327328331328333328343328357328373328379328381328397328411328421328429328439328481328511328513328519328543328579328589328591328619328621328633328637328639328651328667328687328709328721328753328777328781328787328789328813328829328837328847328849328883328891328897328901328919328921328931328961328981329009329027329053329059329081329083329089329101329111329123329143329167329177329191329201329207329209329233329243329257329267329269329281329293329297329299329309329317329321329333329347329387329393329401329419329431329471329473329489329503329519329533329551329557329587329591329597329603329617329627329629329639329657329663329671329677329683329687329711329717329723329729329761329773329779329789329801329803329863329867329873329891329899329941329947329951329957329969329977329993329999330017330019330037330041330047330053330061330067330097330103330131330133330139330149330167330199330203330217330227330229330233330241330247330271330287330289330311330313330329330331330347330359330383330389330409330413330427330431330433330439330469330509330557330563330569330587330607330611330623330641330643330653330661330679330683330689330697330703330719330721330731330749330767330787330791330793330821330823330839330853330857330859330877330887330899330907330917330943330983330997331013331027331031331043331063331081331099331127331141331147331153331159331171331183331207331213331217331231331241331249331259331277331283331301331307331319331333331337331339331349331367331369331391331399331423331447331451331489331501331511331519331523331537331543331547331549331553331577331579331589331603331609331613331651331663331691331693331697331711331739331753331769331777331781331801331819331841331843331871331883331889331897331907331909331921331937331943331957331967331973331997331999332009332011332039332053332069332081332099332113332117332147332159332161332179332183332191332201332203332207332219332221332251332263332273332287332303332309332317332393332399332411332417332441332447332461332467332471332473332477332489332509332513332561332567332569332573332611332617332623332641332687332699332711332729332743332749332767332779332791332803332837332851332873332881332887332903332921332933332947332951332987332989332993333019333023333029333031333041333049333071333097333101333103333107333131333139333161333187333197333209333227333233333253333269333271333283333287333299333323333331333337333341333349333367333383333397333419333427333433333439333449333451333457333479333491333493333497333503333517333533333539333563333581333589333623333631333647333667333673333679333691333701333713333719333721333737333757333769333779333787333791333793333803333821333857333871333911333923333929333941333959333973333989333997334021334031334043334049334057334069334093334099334127334133334157334171334177334183334189334199334231334247334261334289334297334319334331334333334349334363334379334387334393334403334421334423334427334429334447334487334493334507334511334513334541334547334549334561334603334619334637334643334651334661334667334681334693334699334717334721334727334751334753334759334771334777334783334787334793334843334861334877334889334891334897334931334963334973334987334991334993335009335021335029335033335047335051335057335077335081335089335107335113335117335123335131335149335161335171335173335207335213335221335249335261335273335281335299335323335341335347335381335383335411335417335429335449335453335459335473335477335507335519335527335539335557335567335579335591335609335633335641335653335663335669335681335689335693335719335729335743335747335771335807335809335813335821335833335843335857335879335893335897335917335941335953335957335999336029336031336041336059336079336101336103336109336113336121336143336151336157336163336181336199336211336221336223336227336239336247336251336253336263336307336317336353336361336373336397336403336419336437336463336491336499336503336521336527336529336533336551336563336571336577336587336593336599336613336631336643336649336653336667336671336683336689336703336727336757336761336767336769336773336793336799336803336823336827336829336857336863336871336887336899336901336911336929336961336977336983336989336997337013337021337031337039337049337069337081337091337097337121337153337189337201337213337217337219337223337261337277337279337283337291337301337313337327337339337343337349337361337367337369337397337411337427337453337457337487337489337511337517337529337537337541337543337583337607337609337627337633337639337651337661337669337681337691337697337721337741337751337759337781337793337817337837337853337859337861337867337871337873337891337901337903337907337919337949337957337969337973337999338017338027338033338119338137338141338153338159338161338167338171338183338197338203338207338213338231338237338251338263338267338269338279338287338293338297338309338321338323338339338341338347338369338383338389338407338411338413338423338431338449338461338473338477338497338531338543338563338567338573338579338581338609338659338669338683338687338707338717338731338747338753338761338773338777338791338803338839338851338857338867338893338909338927338959338993338999339023339049339067339071339091339103339107339121339127339137339139339151339161339173339187339211339223339239339247339257339263339289339307339323339331339341339373339389339413339433339467339491339517339527339539339557339583339589339601339613339617339631339637339649339653339659339671339673339679339707339727339749339751339761339769339799339811339817339821339827339839339841339863339887339907339943339959339991340007340027340031340037340049340057340061340063340073340079340103340111340117340121340127340129340169340183340201340211340237340261340267340283340297340321340337340339340369340381340387340393340397340409340429340447340451340453340477340481340519340541340559340573340577340579340583340591340601340619340633340643340649340657340661340687340693340709340723340757340777340787340789340793340801340811340819340849340859340877340889340897340903340909340913340919340927340931340933340937340939340957340979340999341017341027341041341057341059341063341083341087341123341141341171341179341191341203341219341227341233341269341273341281341287341293341303341311341321341323341333341339341347341357341423341443341447341459341461341477341491341501341507341521341543341557341569341587341597341603341617341623341629341641341647341659341681341687341701341729341743341749341771341773341777341813341821341827341839341851341863341879341911341927341947341951341953341959341963341983341993342037342047342049342059342061342071342073342077342101342107342131342143342179342187342191342197342203342211342233342239342241342257342281342283342299342319342337342341342343342347342359342371342373342379342389342413342421342449342451342467342469342481342497342521342527342547342553342569342593342599342607342647342653342659342673342679342691342697342733342757342761342791342799342803342821342833342841342847342863342869342871342889342899342929342949342971342989343019343037343051343061343073343081343087343127343141343153343163343169343177343193343199343219343237343243343253343261343267343289343303343307343309343313343327343333343337343373343379343381343391343393343411343423343433343481343489343517343529343531343543343547343559343561343579343583343589343591343601343627343631343639343649343661343667343687343709343727343769343771343787343799343801343813343817343823343829343831343891343897343901343913343933343939343943343951343963343997344017344021344039344053344083344111344117344153344161344167344171344173344177344189344207344209344213344221344231344237344243344249344251344257344263344269344273344291344293344321344327344347344353344363344371344417344423344429344453344479344483344497344543344567344587344599344611344621344629344639344653344671344681344683344693344719344749344753344759344791344797344801344807344819344821344843344857344863344873344887344893344909344917344921344941344957344959344963344969344987345001345011345017345019345041345047345067345089345109345133345139345143345181345193345221345227345229345259345263345271345307345311345329345379345413345431345451345461345463345473345479345487345511345517345533345547345551345571345577345581345599345601345607345637345643345647345659345673345679345689345701345707345727345731345733345739345749345757345769345773345791345803345811345817345823345853345869345881345887345889345907345923345937345953345979345997346013346039346043346051346079346091346097346111346117346133346139346141346147346169346187346201346207346217346223346259346261346277346303346309346321346331346337346349346361346369346373346391346393346397346399346417346421346429346433346439346441346447346453346469346501346529346543346547346553346559346561346589346601346607346627346639346649346651346657346667346669346699346711346721346739346751346763346793346831346849346867346873346877346891346903346933346939346943346961346963347003347033347041347051347057347059347063347069347071347099347129347131347141347143347161347167347173347177347183347197347201347209347227347233347239347251347257347287347297347299347317347329347341347359347401347411347437347443347489347509347513347519347533347539347561347563347579347587347591347609347621347629347651347671347707347717347729347731347747347759347771347773347779347801347813347821347849347873347887347891347899347929347933347951347957347959347969347981347983347987347989347993348001348011348017348031348043348053348077348083348097348149348163348181348191348209348217348221348239348241348247348253348259348269348287348307348323348353348367348389348401348407348419348421348431348433348437348443348451348457348461348463348487348527348547348553348559348563348571348583348587348617348629348637348643348661348671348709348731348739348757348763348769348779348811348827348833348839348851348883348889348911348917348919348923348937348949348989348991349007349039349043349051349079349081349093349099349109349121349133349171349177349183349187349199349207349211349241349291349303349313349331349337349343349357349369349373349379349381349387349397349399349403349409349411349423349471349477349483349493349499349507349519349529349553349567349579349589349603349637349663349667349697349709349717349729349753349759349787349793349801349813349819349829349831349837349841349849349871349903349907349913349919349927349931349933349939349949349963349967349981350003350029350033350039350087350089350093350107350111350137350159350179350191350213350219350237350249350257350281350293350347350351350377350381350411350423350429350431350437350443350447350453350459350503350521350549350561350563350587350593350617350621350629350657350663350677350699350711350719350729350731350737350741350747350767350771350783350789350803350809350843350851350869350881350887350891350899350941350947350963350971350981350983350989351011351023351031351037351041351047351053351059351061351077351079351097351121351133351151351157351179351217351223351229351257351259351269351287351289351293351301351311351341351343351347351359351361351383351391351397351401351413351427351437351457351469351479351497351503351517351529351551351563351587351599351643351653351661351667351691351707351727351731351733351749351751351763351773351779351797351803351811351829351847351851351859351863351887351913351919351929351931351959351971351991352007352021352043352049352057352069352073352081352097352109352111352123352133352181352193352201352217352229352237352249352267352271352273352301352309352327352333352349352357352361352367352369352381352399352403352409352411352421352423352441352459352463352481352483352489352493352511352523352543352549352579352589352601352607352619352633352637352661352691352711352739352741352753352757352771352813352817352819352831352837352841352853352867352883352907352909352931352939352949352951352973352991353011353021353047353053353057353069353081353099353117353123353137353147353149353161353173353179353201353203353237353263353293353317353321353329353333353341353359353389353401353411353429353443353453353459353471353473353489353501353527353531353557353567353603353611353621353627353629353641353653353657353677353681353687353699353711353737353747353767353777353783353797353807353813353819353833353867353869353879353891353897353911353917353921353929353939353963354001354007354017354023354031354037354041354043354047354073354091354097354121354139354143354149354163354169354181354209354247354251354253354257354259354271354301354307354313354317354323354329354337354353354371354373354377354383354391354401354421354439354443354451354461354463354469354479354533354539354551354553354581354587354619354643354647354661354667354677354689354701354703354727354737354743354751354763354779354791354799354829354833354839354847354869354877354881354883354911354953354961354971354973354979354983354997355007355009355027355031355037355039355049355057355063355073355087355093355099355109355111355127355139355171355193355211355261355297355307355321355331355339355343355361355363355379355417355427355441355457355463355483355499355501355507355513355517355519355529355541355549355559355571355573355591355609355633355643355651355669355679355697355717355721355723355753355763355777355783355799355811355819355841355847355853355867355891355909355913355933355937355939355951355967355969356023356039356077356093356101356113356123356129356137356141356143356171356173356197356219356243356261356263356287356299356311356327356333356351356387356399356441356443356449356453356467356479356501356509356533356549356561356563356567356579356591356621356647356663356693356701356731356737356749356761356803356819356821356831356869356887356893356927356929356933356947356959356969356977356981356989356999357031357047357073357079357083357103357107357109357131357139357169357179357197357199357211357229357239357241357263357271357281357283357293357319357347357349357353357359357377357389357421357431357437357473357503357509357517357551357559357563357569357571357583357587357593357611357613357619357649357653357659357661357667357671357677357683357689357703357727357733357737357739357767357779357781357787357793357809357817357823357829357839357859357883357913357967357977357983357989357997358031358051358069358073358079358103358109358153358157358159358181358201358213358219358223358229358243358273358277358279358289358291358297358301358313358327358331358349358373358417358427358429358441358447358459358471358483358487358499358531358541358571358573358591358597358601358607358613358637358667358669358681358691358697358703358711358723358727358733358747358753358769358783358793358811358829358847358859358861358867358877358879358901358903358907358909358931358951358973358979358987358993358999359003359017359027359041359063359069359101359111359129359137359143359147359153359167359171359207359209359231359243359263359267359279359291359297359299359311359323359327359353359357359377359389359407359417359419359441359449359477359479359483359501359509359539359549359561359563359581359587359599359621359633359641359657359663359701359713359719359731359747359753359761359767359783359837359851359869359897359911359929359981359987360007360023360037360049360053360071360089360091360163360167360169360181360187360193360197360223360229360233360257360271360277360287360289360293360307360317360323360337360391360407360421360439360457360461360497360509360511360541360551360589360593360611360637360649360653360749360769360779360781360803360817360821360823360827360851360853360863360869360901360907360947360949360953360959360973360977360979360989361001361003361013361033361069361091361093361111361159361183361211361213361217361219361223361237361241361271361279361313361321361327361337361349361351361357361363361373361409361411361421361433361441361447361451361463361469361481361499361507361511361523361531361541361549361561361577361637361643361649361651361663361679361687361723361727361747361763361769361787361789361793361799361807361843361871361873361877361901361903361909361919361927361943361961361967361973361979361993362003362027362051362053362059362069362081362093362099362107362137362143362147362161362177362191362203362213362221362233362237362281362291362293362303362309362333362339362347362353362357362363362371362377362381362393362407362419362429362431362443362449362459362473362521362561362569362581362599362629362633362657362693362707362717362723362741362743362749362753362759362801362851362863362867362897362903362911362927362941362951362953362969362977362983362987363017363019363037363043363047363059363061363067363119363149363151363157363161363173363179363199363211363217363257363269363271363277363313363317363329363343363359363361363367363371363373363379363397363401363403363431363437363439363463363481363491363497363523363529363533363541363551363557363563363569363577363581363589363611363619363659363677363683363691363719363731363751363757363761363767363773363799363809363829363833363841363871363887363889363901363911363917363941363947363949363959363967363977363989364027364031364069364073364079364103364127364129364141364171364183364187364193364213364223364241364267364271364289364291364303364313364321364333364337364349364373364379364393364411364417364423364433364447364451364459364471364499364513364523364537364541364543364571364583364601364607364621364627364643364657364669364687364691364699364717364739364747364751364753364759364801364829364853364873364879364883364891364909364919364921364937364943364961364979364993364997365003365017365021365039365063365069365089365107365119365129365137365147365159365173365179365201365213365231365249365251365257365291365293365297365303365327365333365357365369365377365411365413365419365423365441365461365467365471365473365479365489365507365509365513365527365531365537365557365567365569365587365591365611365627365639365641365669365683365689365699365747365749365759365773365779365791365797365809365837365839365851365903365929365933365941365969365983366001366013366019366029366031366053366077366097366103366127366133366139366161366167366169366173366181366193366199366211366217366221366227366239366259366269366277366287366293366307366313366329366341366343366347366383366397366409366419366433366437366439366461366463366467366479366497366511366517366521366547366593366599366607366631366677366683366697366701366703366713366721366727366733366787366791366811366829366841366851366853366859366869366881366889366901366907366917366923366941366953366967366973366983366997367001367007367019367021367027367033367049367069367097367121367123367127367139367163367181367189367201367207367219367229367231367243367259367261367273367277367307367309367313367321367357367369367391367397367427367453367457367469367501367519367531367541367547367559367561367573367597367603367613367621367637367649367651367663367673367687367699367711367721367733367739367751367771367777367781367789367819367823367831367841367849367853367867367879367883367889367909367949367957368021368029368047368059368077368083368089368099368107368111368117368129368141368149368153368171368189368197368227368231368233368243368273368279368287368293368323368327368359368363368369368399368411368443368447368453368471368491368507368513368521368531368539368551368579368593368597368609368633368647368651368653368689368717368729368737368743368773368783368789368791368801368803368833368857368873368881368899368911368939368947368957369007369013369023369029369067369071369077369079369097369119369133369137369143369169369181369191369197369211369247369253369263369269369283369293369301369319369331369353369361369407369409369419369469369487369491369539369553369557369581369637369647369659369661369673369703369709369731369739369751369791369793369821369827369829369833369841369851369877369893369913369917369947369959369961369979369983369991369997370003370009370021370033370057370061370067370081370091370103370121370133370147370159370169370193370199370207370213370217370241370247370261370373370387370399370411370421370423370427370439370441370451370463370471370477370483370493370511370529370537370547370561370571370597370603370609370613370619370631370661370663370673370679370687370693370723370759370793370801370813370837370871370873370879370883370891370897370919370949371027371029371057371069371071371083371087371099371131371141371143371153371177371179371191371213371227371233371237371249371251371257371281371291371299371303371311371321371333371339371341371353371359371383371387371389371417371447371453371471371479371491371509371513371549371561371573371587371617371627371633371639371663371669371699371719371737371779371797371831371837371843371851371857371869371873371897371927371929371939371941371951371957371971371981371999372013372023372037372049372059372061372067372107372121372131372137372149372167372173372179372223372241372263372269372271372277372289372293372299372311372313372353372367372371372377372397372401372409372413372443372451372461372473372481372497372511372523372539372607372611372613372629372637372653372661372667372677372689372707372709372719372733372739372751372763372769372773372797372803372809372817372829372833372839372847372859372871372877372881372901372917372941372943372971372973372979373003373007373019373049373063373073373091373127373151373157373171373181373183373187373193373199373207373211373213373229373231373273373291373297373301373327373339373343373349373357373361373363373379373393373447373453373459373463373487373489373501373517373553373561373567373613373621373631373649373657373661373669373693373717373721373753373757373777373783373823373837373859373861373903373909373937373943373951373963373969373981373987373999374009374029374039374041374047374063374069374083374089374093374111374117374123374137374149374159374173374177374189374203374219374239374287374291374293374299374317374321374333374347374351374359374389374399374441374443374447374461374483374501374531374537374557374587374603374639374641374653374669374677374681374683374687374701374713374719374729374741374753374761374771374783374789374797374807374819374837374839374849374879374887374893374903374909374929374939374953374977374981374987374989374993375017375019375029375043375049375059375083375091375097375101375103375113375119375121375127375149375157375163375169375203375209375223375227375233375247375251375253375257375259375281375283375311375341375359375367375371375373375391375407375413375443375449375451375457375467375481375509375511375523375527375533375553375559375563375569375593375607375623375631375643375647375667375673375703375707375709375743375757375761375773375779375787375799375833375841375857375899375901375923375931375967375971375979375983375997376001376003376009376021376039376049376063376081376097376099376127376133376147376153376171376183376199376231376237376241376283376291376297376307376351376373376393376399376417376463376469376471376477376483376501376511376529376531376547376573376577376583376589376603376609376627376631376633376639376657376679376687376699376709376721376729376757376759376769376787376793376801376807376811376819376823376837376841376847376853376889376891376897376921376927376931376933376949376963376969377011377021377051377059377071377099377123377129377137377147377171377173377183377197377219377231377257377263377287377291377297377327377329377339377347377353377369377371377387377393377459377471377477377491377513377521377527377537377543377557377561377563377581377593377599377617377623377633377653377681377687377711377717377737377749377761377771377779377789377801377809377827377831377843377851377873377887377911377963377981377999378011378019378023378041378071378083378089378101378127378137378149378151378163378167378179378193378223378229378239378241378253378269378277378283378289378317378353378361378379378401378407378439378449378463378467378493378503378509378523378533378551378559378569378571378583378593378601378619378629378661378667378671378683378691378713378733378739378757378761378779378793378809378817378821378823378869378883378893378901378919378929378941378949378953378967378977378997379007379009379013379033379039379073379081379087379097379103379123379133379147379157379163379177379187379189379199379207379273379277379283379289379307379319379333379343379369379387379391379397379399379417379433379439379441379451379459379499379501379513379531379541379549379571379573379579379597379607379633379649379663379667379679379681379693379699379703379721379723379727379751379777379787379811379817379837379849379853379859379877379889379903379909379913379927379931379963379979379993379997379999380041380047380059380071380117380129380131380141380147380179380189380197380201380203380207380231380251380267380269380287380291380299380309380311380327380329380333380363380377380383380417380423380441380447380453380459380461380483380503380533380557380563380591380621380623380629380641380651380657380707380713380729380753380777380797380803380819380837380839380843380867380869380879380881380909380917380929380951380957380971380977380983381001381011381019381037381047381061381071381077381097381103381167381169381181381209381221381223381233381239381253381287381289381301381319381323381343381347381371381373381377381383381389381401381413381419381439381443381461381467381481381487381509381523381527381529381533381541381559381569381607381629381631381637381659381673381697381707381713381737381739381749381757381761381791381793381817381841381853381859381911381917381937381943381949381977381989381991382001382003382021382037382061382069382073382087382103382117382163382171382189382229382231382241382253382267382271382303382331382351382357382363382373382391382427382429382457382463382493382507382511382519382541382549382553382567382579382583382589382601382621382631382643382649382661382663382693382703382709382727382729382747382751382763382769382777382801382807382813382843382847382861382867382871382873382883382919382933382939382961382979382999383011383023383029383041383051383069383077383081383083383099383101383107383113383143383147383153383171383179383219383221383261383267383281383291383297383303383321383347383371383393383399383417383419383429383459383483383489383519383521383527383533383549383557383573383587383609383611383623383627383633383651383657383659383681383683383693383723383729383753383759383767383777383791383797383807383813383821383833383837383839383869383891383909383917383923383941383951383963383969383983383987384001384017384029384049384061384067384079384089384107384113384133384143384151384157384173384187384193384203384227384247384253384257384259384277384287384289384299384301384317384331384343384359384367384383384403384407384437384469384473384479384481384487384497384509384533384547384577384581384589384599384611384619384623384641384673384691384697384701384719384733384737384751384757384773384779384817384821384827384841384847384851384889384907384913384919384941384961384973385001385013385027385039385057385069385079385081385087385109385127385129385139385141385153385159385171385193385199385223385249385261385267385279385289385291385321385327385331385351385379385391385393385397385403385417385433385471385481385493385501385519385531385537385559385571385573385579385589385591385597385607385621385631385639385657385661385663385709385739385741385771385783385793385811385817385831385837385843385859385877385897385901385907385927385939385943385967385991385997386017386039386041386047386051386083386093386117386119386129386131386143386149386153386159386161386173386219386227386233386237386249386263386279386297386299386303386329386333386339386363386369386371386381386383386401386411386413386429386431386437386471386489386501386521386537386543386549386569386587386609386611386621386629386641386647386651386677386689386693386713386719386723386731386747386777386809386839386851386887386891386921386927386963386977386987386989386993387007387017387031387047387071387077387083387089387109387137387151387161387169387173387187387197387199387203387227387253387263387269387281387307387313387329387341387371387397387403387433387437387449387463387493387503387509387529387551387577387587387613387623387631387641387659387677387679387683387707387721387727387743387749387763387781387791387799387839387853387857387911387913387917387953387967387971387973387977388009388051388057388067388081388099388109388111388117388133388159388163388169388177388181388183388187388211388231388237388253388259388273388277388301388313388319388351388363388369388373388391388403388459388471388477388481388483388489388499388519388529388541388567388573388621388651388657388673388691388693388697388699388711388727388757388777388781388789388793388813388823388837388859388879388891388897388901388903388931388933388937388961388963388991389003389023389027389029389041389047389057389083389089389099389111389117389141389149389161389167389171389173389189389219389227389231389269389273389287389297389299389303389357389369389381389399389401389437389447389461389479389483389507389513389527389531389533389539389561389563389567389569389579389591389621389629389651389659389663389687389699389713389723389743389749389761389773389783389791389797389819389839389849389867389891389897389903389911389923389927389941389947389953389957389971389981389989389999390001390043390067390077390083390097390101390107390109390113390119390151390157390161390191390193390199390209390211390223390263390281390289390307390323390343390347390353390359390367390373390389390391390407390413390419390421390433390437390449390463390479390487390491390493390499390503390527390539390553390581390647390653390671390673390703390707390721390727390737390739390743390751390763390781390791390809390821390829390851390869390877390883390889390893390953390959390961390967390989390991391009391019391021391031391049391057391063391067391073391103391117391133391151391159391163391177391199391217391219391231391247391249391273391283391291391301391331391337391351391367391373391379391387391393391397391399391403391441391451391453391487391519391537391553391579391613391619391627391631391639391661391679391691391693391711391717391733391739391751391753391757391789391801391817391823391847391861391873391879391889391891391903391907391921391939391961391967391987391999392011392033392053392059392069392087392099392101392111392113392131392143392149392153392159392177392201392209392213392221392233392239392251392261392263392267392269392279392281392297392299392321392333392339392347392351392363392383392389392423392437392443392467392473392477392489392503392519392531392543392549392569392593392599392611392629392647392663392669392699392723392737392741392759392761392767392803392807392809392827392831392837392849392851392857392879392893392911392923392927392929392957392963392969392981392983393007393013393017393031393059393073393077393079393083393097393103393109393121393137393143393157393161393181393187393191393203393209393241393247393257393271393287393299393301393311393331393361393373393377393383393401393403393413393451393473393479393487393517393521393539393541393551393557393571393577393581393583393587393593393611393629393637393649393667393671393677393683393697393709393713393721393727393739393749393761393779393797393847393853393857393859393863393871393901393919393929393931393947393961393977393989393997394007394019394039394049394063394073394099394123394129394153394157394169394187394201394211394223394241394249394259394271394291394319394327394357394363394367394369394393394409394411394453394481394489394501394507394523394529394549394571394577394579394601394619394631394633394637394643394673394699394717394721394727394729394733394739394747394759394787394811394813394817394819394829394837394861394879394897394931394943394963394967394969394981394987394993395023395027395039395047395069395089395093395107395111395113395119395137395141395147395159395173395189395191395201395231395243395251395261395273395287395293395303395309395321395323395377395383395407395429395431395443395449395453395459395491395509395513395533395537395543395581395597395611395621395627395657395671395677395687395701395719395737395741395749395767395803395849395851395873395887395891395897395909395921395953395959395971396001396029396031396041396043396061396079396091396103396107396119396157396173396181396197396199396203396217396239396247396259396269396293396299396301396311396323396349396353396373396377396379396413396427396437396443396449396479396509396523396527396533396541396547396563396577396581396601396619396623396629396631396637396647396667396679396703396709396713396719396733396833396871396881396883396887396919396931396937396943396947396953396971396983396997397013397027397037397051397057397063397073397093397099397127397151397153397181397183397211397217397223397237397253397259397283397289397297397301397303397337397351397357397361397373397379397427397429397433397459397469397489397493397517397519397541397543397547397549397567397589397591397597397633397643397673397687397697397721397723397729397751397753397757397759397763397799397807397811397829397849397867397897397907397921397939397951397963397973397981398011398023398029398033398039398053398059398063398077398087398113398117398119398129398143398149398171398207398213398219398227398249398261398267398273398287398303398311398323398339398341398347398353398357398369398393398407398417398423398441398459398467398471398473398477398491398509398539398543398549398557398569398581398591398609398611398621398627398669398681398683398693398711398729398731398759398771398813398819398821398833398857398863398887398903398917398921398933398941398969398977398989399023399031399043399059399067399071399079399097399101399107399131399137399149399151399163399173399181399197399221399227399239399241399263399271399277399281399283399353399379399389399391399401399403399409399433399439399473399481399491399493399499399523399527399541399557399571399577399583399587399601399613399617399643399647399667399677399689399691399719399727399731399739399757399761399769399781399787399793399851399853399871399887399899399911399913399937399941399953399979399983399989400009400031400033400051400067400069400087400093400109400123400151400157400187400199400207400217400237400243400247400249400261400277400291400297400307400313400321400331400339400381400391400409400417400429400441400457400471400481400523400559400579400597400601400607400619400643400651400657400679400681400703400711400721400723400739400753400759400823400837400849400853400859400871400903400927400931400943400949400963400997401017401029401039401053401057401069401077401087401101401113401119401161401173401179401201401209401231401237401243401279401287401309401311401321401329401341401347401371401381401393401407401411401417401473401477401507401519401537401539401551401567401587401593401627401629401651401669401671401689401707401711401743401771401773401809401813401827401839401861401867401887401903401909401917401939401953401957401959401981401987401993402023402029402037402043402049402053402071402089402091402107402131402133402137402139402197402221402223402239402253402263402277402299402307402313402329402331402341402343402359402361402371402379402383402403402419402443402487402503402511402517402527402529402541402551402559402581402583402587402593402601402613402631402691402697402739402751402757402761402763402767402769402797402803402817402823402847402851402859402863402869402881402923402943402947402949402991403001403003403037403043403049403057403061403063403079403097403103403133403141403159403163403181403219403241403243403253403261403267403289403301403309403327403331403339403363403369403387403391403433403439403483403499403511403537403547403549403553403567403577403591403603403607403621403649403661403679403681403687403703403717403721403729403757403783403787403817403829403831403849403861403867403877403889403901403933403951403957403969403979403981403993404009404011404017404021404029404051404081404099404113404119404123404161404167404177404189404191404197404213404221404249404251404267404269404273404291404309404321404323404357404381404387404389404399404419404423404429404431404449404461404483404489404497404507404513404527404531404533404539404557404597404671404693404699404713404773404779404783404819404827404837404843404849404851404941404951404959404969404977404981404983405001405011405029405037405047405049405071405073405089405091405143405157405179405199405211405221405227405239405241405247405253405269405277405287405299405323405341405343405347405373405401405407405413405437405439405473405487405491405497405499405521405527405529405541405553405577405599405607405611405641405659405667405677405679405683405689405701405703405709405719405731405749405763405767405781405799405817405827405829405857405863405869405871405893405901405917405947405949405959405967405989405991405997406013406027406037406067406073406093406117406123406169406171406177406183406207406247406253406267406271406309406313406327406331406339406349406361406381406397406403406423406447406481406499406501406507406513406517406531406547406559406561406573406577406579406583406591406631406633406649406661406673406697406699406717406729406739406789406807406811406817406837406859406873406883406907406951406969406981406993407023407047407059407083407119407137407149407153407177407179407191407203407207407219407221407233407249407257407263407273407287407291407299407311407317407321407347407357407359407369407377407383407401407437407471407483407489407501407503407509407521407527407567407573407579407587407599407621407633407639407651407657407669407699407707407713407717407723407741407747407783407789407791407801407807407821407833407843407857407861407879407893407899407917407923407947407959407969407971407977407993408011408019408041408049408071408077408091408127408131408137408169408173408197408203408209408211408217408223408229408241408251408263408271408283408311408337408341408347408361408379408389408403408413408427408431408433408437408461408469408479408491408497408533408539408553408563408607408623408631408637408643408659408677408689408691408701408703408713408719408743408763408769408773408787408803408809408817408841408857408869408911408913408923408943408953408959408971408979408997409007409021409027409033409043409063409069409081409099409121409153409163409177409187409217409237409259409261409267409271409289409291409327409333409337409349409351409369409379409391409397409429409433409441409463409471409477409483409499409517409523409529409543409573409579409589409597409609409639409657409691409693409709409711409723409729409733409753409769409777409781409813409817409823409831409841409861409867409879409889409891409897409901409909409933409943409951409961409967409987409993409999410009410029410063410087410093410117410119410141410143410149410171410173410203410231410233410239410243410257410279410281410299410317410323410339410341410353410359410383410387410393410401410411410413410453410461410477410489410491410497410507410513410519410551410561410587410617410621410623410629410651410659410671410687410701410717410731410741410747410749410759410783410789410801410807410819410833410857410899410903410929410953410983410999411001411007411011411013411031411041411049411067411071411083411101411113411119411127411143411157411167411193411197411211411233411241411251411253411259411287411311411337411347411361411371411379411409411421411443411449411469411473411479411491411503411527411529411557411563411569411577411583411589411611411613411617411637411641411667411679411683411703411707411709411721411727411737411739411743411751411779411799411809411821411823411833411841411883411919411923411937411941411947411967411991412001412007412019412031412033412037412039412051412067412073412081412099412109412123412127412133412147412157412171412187412189412193412201412211412213412219412249412253412273412277412289412303412333412339412343412387412397412411412457412463412481412487412493412537412561412567412571412589412591412603412609412619412627412637412639412651412663412667412717412739412771412793412807412831412849412859412891412901412903412939412943412949412967412987413009413027413033413053413069413071413081413087413089413093413111413113413129413141413143413159413167413183413197413201413207413233413243413251413263413267413293413299413353413411413417413429413443413461413477413521413527413533413537413551413557413579413587413597413629413653413681413683413689413711413713413719413737413753413759413779413783413807413827413849413863413867413869413879413887413911413923413951413981414013414017414019414031414049414053414061414077414083414097414101414107414109414131414157414179414199414203414209414217414221414241414259414269414277414283414311414313414329414331414347414361414367414383414389414397414413414431414433414451414457414461414467414487414503414521414539414553414559414571414577414607414611414629414641414643414653414677414679414683414691414697414703414707414709414721414731414737414763414767414769414773414779414793414803414809414833414857414871414889414893414899414913414923414929414949414959414971414977414991415013415031415039415061415069415073415087415097415109415111415133415141415147415153415159415171415187415189415201415213415231415253415271415273415319415343415379415381415391415409415427415447415469415477415489415507415517415523415543415553415559415567415577415603415607415609415627415631415643415651415661415669415673415687415691415697415717415721415729415759415783415787415799415801415819415823415861415873415879415901415931415937415949415951415957415963415969415979415993415999416011416023416071416077416089416107416147416149416153416159416167416201416219416239416243416249416257416263416281416291416333416359416387416389416393416399416401416407416413416417416419416441416443416459416473416477416491416497416501416503416513416531416543416573416579416593416621416623416629416659416677416693416719416761416797416821416833416839416849416851416873416881416887416947416957416963416989417007417017417019417023417037417089417097417113417119417127417133417161417169417173417181417187417191417203417217417227417239417251417271417283417293417311417317417331417337417371417377417379417383417419417437417451417457417479417491417493417509417511417523417541417553417559417577417581417583417617417623417631417643417649417671417691417719417721417727417731417733417737417751417763417773417793417811417821417839417863417869417881417883417899417931417941417947417953417959417961417983417997418007418009418027418031418043418051418069418073418079418087418109418129418157418169418177418181418189418199418207418219418259418273418279418289418303418321418331418337418339418343418349418351418357418373418381418391418423418427418447418459418471418493418511418553418559418597418601418603418631418633418637418657418667418699418709418721418739418751418763418771418783418787418793418799418811418813418819418837418843418849418861418867418871418883418889418909418921418927418933418939418961418981418987418993418997419047419051419053419057419059419087419141419147419161419171419183419189419191419201419231419249419261419281419291419297419303419317419329419351419383419401419417419423419429419443419449419459419467419473419477419483419491419513419527419537419557419561419563419567419579419591419597419599419603419609419623419651419687419693419701419711419743419753419777419789419791419801419803419821419827419831419873419893419921419927419929419933419953419959419999420001420029420037420041420047420073420097420103420149420163420191420193420221420241420253420263420269420271420293420307420313420317420319420323420331420341420349420353420361420367420383420397420419420421420439420457420467420479420481420499420503420521420551420557420569420571420593420599420613420671420677420683420691420731420737420743420757420769420779420781420799420803420809420811420851420853420857420859420899420919420929420941420967420977420997421009421019421033421037421049421079421081421093421103421121421123421133421147421159421163421177421181421189421207421241421273421279421303421313421331421339421349421361421381421397421409421417421423421433421453421459421469421471421483421493421501421517421559421607421609421621421633421639421643421657421661421691421697421699421703421709421711421717421727421739421741421783421801421807421831421847421891421907421913421943421973421987421997422029422041422057422063422069422077422083422087422089422099422101422111422113422129422137422141422183422203422209422231422239422243422249422267422287422291422309422311422321422339422353422363422369422377422393422407422431422453422459422479422537422549422551422557422563422567422573422581422621422627422657422689422701422707422711422749422753422759422761422789422797422803422827422857422861422867422869422879422881422893422897422899422911422923422927422969422987423001423013423019423043423053423061423067423083423091423097423103423109423121423127423133423173423179423191423209423221423229423233423251423257423259423277423281423287423289423299423307423323423341423347423389423403423413423427423431423439423457423461423463423469423481423497423503423509423541423547423557423559423581423587423601423617423649423667423697423707423713423727423749423751423763423769423779423781423791423803423823423847423853423859423869423883423887423931423949423961423977423989423991424001424003424007424019424027424037424079424091424093424103424117424121424129424139424147424157424163424169424187424199424223424231424243424247424261424267424271424273424313424331424339424343424351424397424423424429424433424451424471424481424493424519424537424547424549424559424573424577424597424601424639424661424667424679424687424693424709424727424729424757424769424771424777424811424817424819424829424841424843424849424861424867424889424891424903424909424913424939424961424967424997425003425027425039425057425059425071425083425101425107425123425147425149425189425197425207425233425237425251425273425279425281425291425297425309425317425329425333425363425377425387425393425417425419425423425441425443425471425473425489425501425519425521425533425549425563425591425603425609425641425653425681425701425713425779425783425791425801425813425819425837425839425851425857425861425869425879425899425903425911425939425959425977425987425989426007426011426061426073426077426089426091426103426131426161426163426193426197426211426229426233426253426287426301426311426319426331426353426383426389426401426407426421426427426469426487426527426541426551426553426563426583426611426631426637426641426661426691426697426707426709426731426737426739426743426757426761426763426773426779426787426799426841426859426863426871426889426893426913426917426919426931426941426971426973426997427001427013427039427043427067427069427073427079427081427103427117427151427169427181427213427237427241427243427247427249427279427283427307427309427327427333427351427369427379427381427403427417427421427423427429427433427439427447427451427457427477427513427517427523427529427541427579427591427597427619427621427681427711427717427723427727427733427751427781427787427789427813427849427859427877427879427883427913427919427939427949427951427957427967427969427991427993427997428003428023428027428033428039428041428047428083428093428137428143428147428149428161428167428173428177428221428227428231428249428251428273428297428299428303428339428353428369428401428411428429428471428473428489428503428509428531428539428551428557428563428567428569428579428629428633428639428657428663428671428677428683428693428731428741428759428777428797428801428807428809428833428843428851428863428873428899428951428957428977429007429017429043429083429101429109429119429127429137429139429161429181429197429211429217429223429227429241429259429271429277429281429283429329429347429349429361429367429389429397429409429413429427429431429449429463429467429469429487429497429503429509429511429521429529429547429551429563429581429587429589429599429631429643429659429661429673429677429679429683429701429719429727429731429733429773429791429797429817429823429827429851429853429881429887429889429899429901429907429911429917429929429931429937429943429953429971429973429991430007430009430013430019430057430061430081430091430093430121430139430147430193430259430267430277430279430289430303430319430333430343430357430393430411430427430433430453430487430499430511430513430517430543430553430571430579430589430601430603430649430663430691430697430699430709430723430739430741430747430751430753430769430783430789430799430811430819430823430841430847430861430873430879430883430891430897430907430909430921430949430957430979430981430987430999431017431021431029431047431051431063431077431083431099431107431141431147431153431173431191431203431213431219431237431251431257431267431269431287431297431311431329431339431363431369431377431381431399431423431429431441431447431449431479431513431521431533431567431581431597431603431611431617431621431657431659431663431671431693431707431729431731431759431777431797431801431803431807431831431833431857431863431867431869431881431887431891431903431911431929431933431947431983431993432001432007432023432031432037432043432053432059432067432073432097432121432137432139432143432149432161432163432167432199432203432227432241432251432277432281432287432301432317432323432337432343432349432359432373432389432391432401432413432433432437432449432457432479432491432499432503432511432527432539432557432559432569432577432587432589432613432631432637432659432661432713432721432727432737432743432749432781432793432797432799432833432847432857432869432893432907432923432931432959432961432979432983432989433003433033433049433051433061433073433079433087433093433099433117433123433141433151433187433193433201433207433229433241433249433253433259433261433267433271433291433309433319433337433351433357433361433369433373433393433399433421433429433439433453433469433471433501433507433513433549433571433577433607433627433633433639433651433661433663433673433679433681433703433723433729433747433759433777433781433787433813433817433847433859433861433877433883433889433931433943433963433967433981434009434011434029434039434081434087434107434111434113434117434141434167434179434191434201434209434221434237434243434249434261434267434293434297434303434311434323434347434353434363434377434383434387434389434407434411434431434437434459434461434471434479434501434509434521434561434563434573434593434597434611434647434659434683434689434699434717434719434743434761434783434803434807434813434821434827434831434839434849434857434867434873434881434909434921434923434927434933434939434947434957434963434977434981434989435037435041435059435103435107435109435131435139435143435151435161435179435181435187435191435221435223435247435257435263435277435283435287435307435317435343435349435359435371435397435401435403435419435427435437435439435451435481435503435529435541435553435559435563435569435571435577435583435593435619435623435637435641435647435649435653435661435679435709435731435733435739435751435763435769435779435817435839435847435857435859435881435889435893435907435913435923435947435949435973435983435997436003436013436027436061436081436087436091436097436127436147436151436157436171436181436217436231436253436273436279436283436291436307436309436313436343436357436399436417436427436439436459436463436477436481436483436507436523436529436531436547436549436571436591436607436621436627436649436651436673436687436693436717436727436729436739436741436757436801436811436819436831436841436853436871436889436913436957436963436967436973436979436993436999437011437033437071437077437083437093437111437113437137437141437149437153437159437191437201437219437237437243437263437273437279437287437293437321437351437357437363437387437389437401437413437467437471437473437497437501437509437519437527437533437539437543437557437587437629437641437651437653437677437681437687437693437719437729437743437753437771437809437819437837437849437861437867437881437909437923437947437953437959437977438001438017438029438047438049438091438131438133438143438169438203438211438223438233438241438253438259438271438281438287438301438313438329438341438377438391438401438409438419438439438443438467438479438499438517438521438523438527438533438551438569438589438601438611438623438631438637438661438667438671438701438707438721438733438761438769438793438827438829438833438847438853438869438877438887438899438913438937438941438953438961438967438979438983438989439007439009439063439081439123439133439141439157439163439171439183439199439217439253439273439279439289439303439339439349439357439367439381439409439421439427439429439441439459439463439471439493439511439519439541439559439567439573439577439583439601439613439631439639439661439667439687439693439697439709439723439729439753439759439763439771439781439787439799439811439823439849439853439861439867439883439891439903439919439949439961439969439973439981439991440009440023440039440047440087440093440101440131440159440171440177440179440183440203440207440221440227440239440261440269440281440303440311440329440333440339440347440371440383440389440393440399440431440441440443440471440497440501440507440509440527440537440543440549440551440567440569440579440581440641440651440653440669440677440681440683440711440717440723440731440753440761440773440807440809440821440831440849440863440893440903440911440939440941440953440959440983440987440989441011441029441041441043441053441073441079441101441107441109441113441121441127441157441169441179441187441191441193441229441247441251441257441263441281441307441319441349441359441361441403441421441443441449441461441479441499441517441523441527441547441557441563441569441587441607441613441619441631441647441667441697441703441713441737441751441787441797441799441811441827441829441839441841441877441887441907441913441923441937441953441971442003442007442009442019442027442031442033442061442069442097442109442121442139442147442151442157442171442177442181442193442201442207442217442229442237442243442271442283442291442319442327442333442363442367442397442399442439442447442457442469442487442489442499442501442517442531442537442571442573442577442579442601442609442619442633442691442699442703442721442733442747442753442763442769442777442781442789442807442817442823442829442831442837442843442861442879442903442919442961442963442973442979442987442991442997443011443017443039443041443057443059443063443077443089443117443123443129443147443153443159443161443167443171443189443203443221443227443231443237443243443249443263443273443281443291443293443341443347443353443363443369443389443407443413443419443423443431443437443453443467443489443501443533443543443551443561443563443567443587443591443603443609443629443659443687443689443701443711443731443749443753443759443761443771443777443791443837443851443867443869443873443879443881443893443899443909443917443939443941443953443983443987443999444001444007444029444043444047444079444089444109444113444121444127444131444151444167444173444179444181444187444209444253444271444281444287444289444293444307444341444343444347444349444401444403444421444443444449444461444463444469444473444487444517444523444527444529444539444547444553444557444569444589444607444623444637444641444649444671444677444701444713444739444767444791444793444803444811444817444833444841444859444863444869444877444883444887444893444901444929444937444953444967444971444979445001445019445021445031445033445069445087445091445097445103445141445157445169445183445187445199445229445261445271445279445283445297445307445321445339445363445427445433445447445453445463445477445499445507445537445541445567445573445583445589445597445619445631445633445649445657445691445699445703445741445747445769445771445789445799445807445829445847445853445871445877445883445891445931445937445943445967445969446003446009446041446053446081446087446111446123446129446141446179446189446191446197446221446227446231446261446263446273446279446293446309446323446333446353446363446387446389446399446401446417446441446447446461446473446477446503446533446549446561446569446597446603446609446647446657446713446717446731446753446759446767446773446819446827446839446863446881446891446893446909446911446921446933446951446969446983447001447011447019447053447067447079447101447107447119447133447137447173447179447193447197447211447217447221447233447247447257447259447263447311447319447323447331447353447401447409447427447439447443447449447451447463447467447481447509447521447527447541447569447571447611447617447637447641447677447683447701447703447743447749447757447779447791447793447817447823447827447829447841447859447877447883447893447901447907447943447961447983447991448003448013448027448031448057448067448073448093448111448121448139448141448157448159448169448177448187448193448199448207448241448249448303448309448313448321448351448363448367448373448379448387448397448421448451448519448531448561448597448607448627448631448633448667448687448697448703448727448733448741448769448793448801448807448829448843448853448859448867448871448873448879448883448907448927448939448969448993448997448999449003449011449051449077449083449093449107449117449129449131449149449153449161449171449173449201449203449209449227449243449249449261449263449269449287449299449303449311449321449333449347449353449363449381449399449411449417449419449437449441449459449473449543449549449557449563449567449569449591449609449621449629449653449663449671449677449681449689449693449699449741449759449767449773449783449797449807449821449833449851449879449921449929449941449951449959449963449971449987449989450001450011450019450029450067450071450077450083450101450103450113450127450137450161450169450193450199450209450217450223450227450239450257450259450277450287450293450299450301450311450343450349450361450367450377450383450391450403450413450421450431450451450473450479450481450487450493450503450529450533450557450563450581450587450599450601450617450641450643450649450677450691450707450719450727450761450767450787450797450799450803450809450811450817450829450839450841450847450859450881450883450887450893450899450913450917450929450943450949450971450991450997451013451039451051451057451069451093451097451103451109451159451177451181451183451201451207451249451277451279451301451303451309451313451331451337451343451361451387451397451411451439451441451481451499451519451523451541451547451553451579451601451609451621451637451657451663451667451669451679451681451691451699451709451723451747451753451771451783451793451799451823451831451837451859451873451879451897451901451903451909451921451933451937451939451961451967451987452009452017452027452033452041452077452083452087452131452159452161452171452191452201452213452227452233452239452269452279452293452297452329452363452377452393452401452443452453452497452519452521452531452533452537452539452549452579452587452597452611452629452633452671452687452689452701452731452759452773452797452807452813452821452831452857452869452873452923452953452957452983452989453023453029453053453073453107453119453133453137453143453157453161453181453197453199453209453217453227453239453247453269453289453293453301453311453317453329453347453367453371453377453379453421453451453461453527453553453559453569453571453599453601453617453631453637453641453643453659453667453671453683453703453707453709453737453757453797453799453823453833453847453851453877453889453907453913453923453931453949453961453977453983453991454009454021454031454033454039454061454063454079454109454141454151454159454183454199454211454213454219454229454231454247454253454277454297454303454313454331454351454357454361454379454387454409454417454451454453454483454501454507454513454541454543454547454577454579454603454609454627454637454673454679454709454711454721454723454759454763454777454799454823454843454847454849454859454889454891454907454919454921454931454943454967454969454973454991455003455011455033455047455053455093455099455123455149455159455167455171455177455201455219455227455233455237455261455263455269455291455309455317455321455333455339455341455353455381455393455401455407455419455431455437455443455461455471455473455479455489455491455513455527455531455537455557455573455579455597455599455603455627455647455659455681455683455687455701455711455717455737455761455783455789455809455827455831455849455863455881455899455921455933455941455953455969455977455989455993455999456007456013456023456037456047456061456091456107456109456119456149456151456167456193456223456233456241456283456293456329456349456353456367456377456403456409456427456439456451456457456461456499456503456517456523456529456539456553456557456559456571456581456587456607456611456613456623456641456647456649456653456679456683456697456727456737456763456767456769456791456809456811456821456871456877456881456899456901456923456949456959456979456991457001457003457013457021457043457049457057457087457091457097457099457117457139457151457153457183457189457201457213457229457241457253457267457271457277457279457307457319457333457339457363457367457381457393457397457399457403457411457421457433457459457469457507457511457517457547457553457559457571457607457609457621457643457651457661457669457673457679457687457697457711457739457757457789457799457813457817457829457837457871457889457903457913457943457979457981457987458009458027458039458047458053458057458063458069458119458123458173458179458189458191458197458207458219458239458309458317458323458327458333458357458363458377458399458401458407458449458477458483458501458531458533458543458567458569458573458593458599458611458621458629458639458651458663458669458683458701458719458729458747458789458791458797458807458819458849458863458879458891458897458917458921458929458947458957458959458963458971458977458981458987458993459007459013459023459029459031459037459047459089459091459113459127459167459169459181459209459223459229459233459257459271459293459301459313459317459337459341459343459353459373459377459383459397459421459427459443459463459467459469459479459509459521459523459593459607459611459619459623459631459647459649459671459677459691459703459749459763459791459803459817459829459841459847459883459913459923459929459937459961460013460039460051460063460073460079460081460087460091460099460111460127460147460157460171460181460189460211460217460231460247460267460289460297460301460337460349460373460379460387460393460403460409460417460451460463460477460531460543460561460571460589460609460619460627460633460637460643460657460673460697460709460711460721460771460777460787460793460813460829460841460843460871460891460903460907460913460919460937460949460951460969460973460979460981460987460991461009461011461017461051461053461059461093461101461119461143461147461171461183461191461207461233461239461257461269461273461297461299461309461317461323461327461333461359461381461393461407461411461413461437461441461443461467461479461507461521461561461569461581461599461603461609461627461639461653461677461687461689461693461707461717461801461803461819461843461861461887461891461917461921461933461957461971461977461983462013462041462067462073462079462097462103462109462113462131462149462181462191462199462221462239462263462271462307462311462331462337462361462373462377462401462409462419462421462437462443462467462481462491462493462499462529462541462547462557462569462571462577462589462607462629462641462643462653462659462667462673462677462697462713462719462727462733462739462773462827462841462851462863462871462881462887462899462901462911462937462947462953462983463003463031463033463093463103463157463181463189463207463213463219463231463237463247463249463261463283463291463297463303463313463319463321463339463343463363463387463399463433463447463451463453463457463459463483463501463511463513463523463531463537463549463579463613463627463633463643463649463663463679463693463711463717463741463747463753463763463781463787463807463823463829463831463849463861463867463873463889463891463907463919463921463949463963463973463987463993464003464011464021464033464047464069464081464089464119464129464131464137464141464143464171464173464197464201464213464237464251464257464263464279464281464291464309464311464327464351464371464381464383464413464419464437464447464459464467464479464483464521464537464539464549464557464561464587464591464603464617464621464647464663464687464699464741464747464749464753464767464771464773464777464801464803464809464813464819464843464857464879464897464909464917464923464927464939464941464951464953464963464983464993464999465007465011465013465019465041465061465067465071465077465079465089465107465119465133465151465161465163465167465169465173465187465209465211465259465271465277465281465293465299465317465319465331465337465373465379465383465407465419465433465463465469465523465529465541465551465581465587465611465631465643465649465659465679465701465721465739465743465761465781465797465799465809465821465833465841465887465893465901465917465929465931465947465977465989466009466019466027466033466043466061466069466073466079466087466091466121466139466153466171466181466183466201466243466247466261466267466273466283466303466321466331466339466357466369466373466409466423466441466451466483466517466537466547466553466561466567466573466579466603466619466637466649466651466673466717466723466729466733466747466751466777466787466801466819466853466859466897466909466913466919466951466957466997467003467009467017467021467063467081467083467101467119467123467141467147467171467183467197467209467213467237467239467261467293467297467317467329467333467353467371467399467417467431467437467447467471467473467477467479467491467497467503467507467527467531467543467549467557467587467591467611467617467627467629467633467641467651467657467669467671467681467689467699467713467729467737467743467749467773467783467813467827467833467867467869467879467881467893467897467899467903467927467941467953467963467977468001468011468019468029468049468059468067468071468079468107468109468113468121468133468137468151468157468173468187468191468199468239468241468253468271468277468289468319468323468353468359468371468389468421468439468451468463468473468491468493468499468509468527468551468557468577468581468593468599468613468619468623468641468647468653468661468667468683468691468697468703468709468719468737468739468761468773468781468803468817468821468841468851468859468869468883468887468889468893468899468913468953468967468973468983469009469031469037469069469099469121469127469141469153469169469193469207469219469229469237469241469253469267469279469283469303469321469331469351469363469367469369469379469397469411469429469439469457469487469501469529469541469543469561469583469589469613469627469631469649469657469673469687469691469717469723469747469753469757469769469787469793469801469811469823469841469849469877469879469891469907469919469939469957469969469979469993470021470039470059470077470081470083470087470089470131470149470153470161470167470179470201470207470209470213470219470227470243470251470263470279470297470299470303470317470333470347470359470389470399470411470413470417470429470443470447470453470461470471470473470489470501470513470521470531470539470551470579470593470597470599470609470621470627470647470651470653470663470669470689470711470719470731470749470779470783470791470819470831470837470863470867470881470887470891470903470927470933470941470947470957470959470993470999471007471041471061471073471089471091471101471137471139471161471173471179471187471193471209471217471241471253471259471277471281471283471299471301471313471353471389471391471403471407471439471451471467471481471487471503471509471521471533471539471553471571471589471593471607471617471619471641471649471659471671471673471677471683471697471703471719471721471749471769471781471791471803471817471841471847471853471871471893471901471907471923471929471931471943471949471959471997472019472027472051472057472063472067472103472111472123472127472133472139472151472159472163472189472193472247472249472253472261472273472289472301472309472319472331472333472349472369472391472393472399472411472421472457472469472477472523472541472543472559472561472573472597472631472639472643472669472687472691472697472709472711472721472741472751472763472793472799472817472831472837472847472859472883472907472909472921472937472939472963472993473009473021473027473089473101473117473141473147473159473167473173473191473197473201473203473219473227473257473279473287473293473311473321473327473351473353473377473381473383473411473419473441473443473453473471473477473479473497473503473507473513473519473527473531473533473549473579473597473611473617473633473647473659473719473723473729473741473743473761473789473833473839473857473861473867473887473899473911473923473927473929473939473951473953473971473981473987473999474017474029474037474043474049474059474073474077474101474119474127474137474143474151474163474169474197474211474223474241474263474289474307474311474319474337474343474347474359474379474389474391474413474433474437474443474479474491474497474499474503474533474541474547474557474569474571474581474583474619474629474647474659474667474671474707474709474737474751474757474769474779474787474809474811474839474847474857474899474907474911474917474923474931474937474941474949474959474977474983475037475051475073475081475091475093475103475109475141475147475151475159475169475207475219475229475243475271475273475283475289475297475301475327475331475333475351475367475369475379475381475403475417475421475427475429475441475457475469475483475511475523475529475549475583475597475613475619475621475637475639475649475669475679475681475691475693475697475721475729475751475753475759475763475777475789475793475807475823475831475837475841475859475877475879475889475897475903475907475921475927475933475957475973475991475997476009476023476027476029476039476041476059476081476087476089476101476107476111476137476143476167476183476219476233476237476243476249476279476299476317476347476351476363476369476381476401476407476419476423476429476467476477476479476507476513476519476579476587476591476599476603476611476633476639476647476659476681476683476701476713476719476737476743476753476759476783476803476831476849476851476863476869476887476891476911476921476929476977476981476989477011477013477017477019477031477047477073477077477091477131477149477163477209477221477229477259477277477293477313477317477329477341477359477361477383477409477439477461477469477497477511477517477523477539477551477553477557477571477577477593477619477623477637477671477677477721477727477731477739477767477769477791477797477809477811477821477823477839477847477857477863477881477899477913477941477947477973477977477991478001478039478063478067478069478087478099478111478129478139478157478169478171478189478199478207478213478241478243478253478259478271478273478321478339478343478351478391478399478403478411478417478421478427478433478441478451478453478459478481478483478493478523478531478571478573478579478589478603478627478631478637478651478679478697478711478727478729478739478741478747478763478769478787478801478811478813478823478831478843478853478861478871478879478897478901478913478927478931478937478943478963478967478991478999479023479027479029479041479081479131479137479147479153479189479191479201479209479221479231479239479243479263479267479287479299479309479317479327479357479371479377479387479419479429479431479441479461479473479489479497479509479513479533479543479561479569479581479593479599479623479629479639479701479749479753479761479771479777479783479797479813479821479833479839479861479879479881479891479903479909479939479951479953479957479971480013480017480019480023480043480047480049480059480061480071480091480101480107480113480133480143480157480167480169480203480209480287480299480317480329480341480343480349480367480373480379480383480391480409480419480427480449480451480461480463480499480503480509480517480521480527480533480541480553480563480569480583480587480647480661480707480713480731480737480749480761480773480787480803480827480839480853480881480911480919480929480937480941480959480967480979480989481001481003481009481021481043481051481067481073481087481093481097481109481123481133481141481147481153481157481171481177481181481199481207481211481231481249481297481301481303481307481343481363481373481379481387481409481417481433481447481469481489481501481513481531481549481571481577481589481619481633481639481651481667481673481681481693481697481699481721481751481753481769481787481801481807481813481837481843481847481849481861481867481879481883481909481939481963481997482017482021482029482033482039482051482071482093482099482101482117482123482179482189482203482213482227482231482233482243482263482281482309482323482347482351482359482371482387482393482399482401482407482413482423482437482441482483482501482507482509482513482519482527482539482569482593482597482621482627482633482641482659482663482683482687482689482707482711482717482719482731482743482753482759482767482773482789482803482819482827482837482861482863482873482897482899482917482941482947482957482971483017483031483061483071483097483127483139483163483167483179483209483211483221483229483233483239483247483251483281483289483317483323483337483347483367483377483389483397483407483409483433483443483467483481483491483499483503483523483541483551483557483563483577483611483619483629483643483649483671483697483709483719483727483733483751483757483761483767483773483787483809483811483827483829483839483853483863483869483883483907483929483937483953483971483991484019484027484037484061484067484079484091484111484117484123484129484151484153484171484181484193484201484207484229484243484259484283484301484303484327484339484361484369484373484397484411484417484439484447484457484459484487484489484493484531484543484577484597484607484609484613484621484639484643484691484703484727484733484751484763484769484777484787484829484853484867484927484951484987484999485021485029485041485053485059485063485081485101485113485123485131485137485161485167485171485201485207485209485263485311485347485351485363485371485383485389485411485417485423485437485447485479485497485509485519485543485567485587485593485603485609485647485657485671485689485701485717485729485731485753485777485819485827485831485833485893485899485909485923485941485959485977485993486023486037486041486043486053486061486071486091486103486119486133486139486163486179486181486193486203486221486223486247486281486293486307486313486323486329486331486341486349486377486379486389486391486397486407486433486443486449486481486491486503486509486511486527486539486559486569486583486589486601486617486637486641486643486653486667486671486677486679486683486697486713486721486757486767486769486781486797486817486821486833486839486869486907486923486929486943486947486949486971486977486991487007487013487021487049487051487057487073487079487093487099487111487133487177487183487187487211487213487219487247487261487283487303487307487313487349487363487381487387487391487397487423487427487429487447487457487463487469487471487477487481487489487507487561487589487601487603487607487637487649487651487657487681487691487703487709487717487727487733487741487757487769487783487789487793487811487819487829487831487843487873487889487891487897487933487943487973487979487997488003488009488011488021488051488057488069488119488143488149488153488161488171488197488203488207488209488227488231488233488239488249488261488263488287488303488309488311488317488321488329488333488339488347488353488381488399488401488407488417488419488441488459488473488503488513488539488567488573488603488611488617488627488633488639488641488651488687488689488701488711488717488723488729488743488749488759488779488791488797488821488827488833488861488879488893488897488909488921488947488959488981488993489001489011489019489043489053489061489101489109489113489127489133489157489161489179489191489197489217489239489241489257489263489283489299489329489337489343489361489367489389489407489409489427489431489439489449489457489479489487489493489529489539489551489553489557489571489613489631489653489659489673489677489679489689489691489733489743489761489791489793489799489803489817489823489833489847489851489869489871489887489901489911489913489941489943489959489961489977489989490001490003490019490031490033490057490097490103490111490117490121490151490159490169490183490201490207490223490241490247490249490267490271490277490283490309490313490339490367490393490417490421490453490459490463490481490493490499490519490537490541490543490549490559490571490573490577490579490591490619490627490631490643490661490663490697490733490741490769490771490783490829490837490849490859490877490891490913490921490927490937490949490951490957490967490969490991490993491003491039491041491059491081491083491129491137491149491159491167491171491201491213491219491251491261491273491279491297491299491327491329491333491339491341491353491357491371491377491417491423491429491461491483491489491497491501491503491527491531491537491539491581491591491593491611491627491633491639491651491653491669491677491707491719491731491737491747491773491783491789491797491819491833491837491851491857491867491873491899491923491951491969491977491983492007492013492017492029492047492053492059492061492067492077492083492103492113492227492251492253492257492281492293492299492319492377492389492397492403492409492413492421492431492463492467492487492491492511492523492551492563492587492601492617492619492629492631492641492647492659492671492673492707492719492721492731492757492761492763492769492781492799492839492853492871492883492893492901492911492967492979493001493013493021493027493043493049493067493093493109493111493121493123493127493133493139493147493159493169493177493193493201493211493217493219493231493243493249493277493279493291493301493313493333493351493369493393493397493399493403493433493447493457493463493481493523493531493541493567493573493579493583493607493621493627493643493657493693493709493711493721493729493733493747493777493793493807493811493813493817493853493859493873493877493897493919493931493937493939493967493973493979493993494023494029494041494051494069494077494083494093494101494107494129494141494147494167494191494213494237494251494257494267494269494281494287494317494327494341494353494359494369494381494383494387494407494413494441494443494471494497494519494521494539494561494563494567494587494591494609494617494621494639494647494651494671494677494687494693494699494713494719494723494731494737494743494749494759494761494783494789494803494843494849494873494899494903494917494927494933494939494959494987495017495037495041495043495067495071495109495113495119495133495139495149495151495161495181495199495211495221495241495269495277495289495301495307495323495337495343495347495359495361495371495377495389495401495413495421495433495437495449495457495461495491495511495527495557495559495563495569495571495587495589495611495613495617495619495629495637495647495667495679495701495707495713495749495751495757495769495773495787495791495797495799495821495827495829495851495877495893495899495923495931495947495953495959495967495973495983496007496019496039496051496063496073496079496123496127496163496187496193496211496229496231496259496283496289496291496297496303496313496333496339496343496381496399496427496439496453496459496471496477496481496487496493496499496511496549496579496583496609496631496669496681496687496703496711496733496747496763496789496813496817496841496849496871496877496889496891496897496901496913496919496949496963496997496999497011497017497041497047497051497069497093497111497113497117497137497141497153497171497177497197497239497257497261497269497279497281497291497297497303497309497323497339497351497389497411497417497423497449497461497473497479497491497501497507497509497521497537497551497557497561497579497587497597497603497633497659497663497671497677497689497701497711497719497729497737497741497771497773497801497813497831497839497851497867497869497873497899497929497957497963497969497977497989497993497999498013498053498061498073498089498101498103498119498143498163498167498181498209498227498257498259498271498301498331498343498361498367498391498397498401498403498409498439498461498467498469498493498497498521498523498527498551498557498577498583498599498611498613498643498647498653498679498689498691498733498739498749498761498767498779498781498787498791498803498833498857498859498881498907498923498931498937498947498961498973498977498989499021499027499033499039499063499067499099499117499127499129499133499139499141499151499157499159499181499183499189499211499229499253499267499277499283499309499321499327499349499361499363499391499397499403499423499439499459499481499483499493499507499519499523499549499559499571499591499601499607499621499633499637499649499661499663499669499673499679499687499691499693499711499717499729499739499747499781499787499801499819499853499879499883499897499903499927499943499957499969499973499979500009500029500041500057500069500083500107500111500113500119500153500167500173500177500179500197500209500231500233500237500239500249500257500287500299500317500321500333500341500363500369500389500393500413500417500431500443500459500471500473500483500501500509500519500527500567500579500587500603500629500671500677500693500699500713500719500723500729500741500777500791500807500809500831500839500861500873500881500887500891500909500911500921500923500933500947500953500957500977501001501013501019501029501031501037501043501077501089501103501121501131501133501139501157501173501187501191501197501203501209501217501223501229501233501257501271501287501299501317501341501343501367501383501401501409501419501427501451501463501493501503501511501563501577501593501601501617501623501637501659501691501701501703501707501719501731501769501779501803501817501821501827501829501841501863501889501911501931501947501953501967501971501997502001502013502039502043502057502063502079502081502087502093502121502133502141502171502181502217502237502247502259502261502277502301502321502339502393502409502421502429502441502451502487502499502501502507502517502543502549502553502591502597502613502631502633502643502651502669502687502699502703502717502729502769502771502781502787502807502819502829502841502847502861502883502919502921502937502961502973503003503017503039503053503077503123503131503137503147503159503197503207503213503227503231503233503249503267503287503297503303503317503339503351503359503369503381503383503389503407503413503423503431503441503453503483503501503543503549503551503563503593503599503609503611503621503623503647503653503663503707503717503743503753503771503777503779503791503803503819503821503827503851503857503869503879503911503927503929503939503947503959503963503969503983503989504001504011504017504047504061504073504103504121504139504143504149504151504157504181504187504197504209504221504247504269504289504299504307504311504323504337504349504353504359504377504379504389504403504457504461504473504479504521504523504527504547504563504593504599504607504617504619504631504661504667504671504677504683504727504767504787504797504799504817504821504851504853504857504871504877504893504901504929504937504943504947504953504967504983504989504991505027505031505033505049505051505061505067505073505091505097505111505117505123505129505139505157505159505181505187505201505213505231505237505277505279505283505301505313505319505321505327505339505357505367505369505399505409505411505429505447505459505469505481505493505501505511505513505523505537505559505573505601505607505613505619505633505639505643505657505663505669505691505693505709505711505727505759505763505777505781505811505819505823505867505871505877505907505919505927505949505961505969505979506047506071506083506101506113506119506131506147506171506173506183506201506213506251506263506269506281506291506327506329506333506339506347506351506357506381506393506417506423506449506459506461506479506491506501506507506531506533506537506551506563506573506591506593506599506609506629506647506663506683506687506689506699506729506731506743506773506783506791506797506809506837506843506861506873506887506893506899506903506911506929506941506963506983506993506999507029507049507071507077507079507103507109507113507119507137507139507149507151507163507193507197507217507289507301507313507317507329507347507349507359507361507371507383507401507421507431507461507491507497507499507503507523507557507571507589507593507599507607507631507641507667507673507691507697507713507719507743507757507779507781507797507803507809507821507827507839507883507901507907507917507919507937507953507961507971507979508009508019508021508033508037508073508087508091508097508103508129508159508171508187508213508223508229508237508243508259508271508273508297508301508327508331508349508363508367508373508393508433508439508451508471508477508489508499508513508517508531508549508559508567508577508579508583508619508621508637508643508661508693508709508727508771508789508799508811508817508841508847508867508901508903508909508913508919508931508943508951508957508961508969508973508987509023509027509053509063509071509087509101509123509137509147509149509203509221509227509239509263509281509287509293509297509317509329509359509363509389509393509413509417509429509441509449509477509513509521509543509549509557509563509569509573509581509591509603509623509633509647509653509659509681509687509689509693509699509723509731509737509741509767509783509797509801509833509837509843509863509867509879509909509911509921509939509947509959509963509989510007510031510047510049510061510067510073510077510079510089510101510121510127510137510157510179510199510203510217510227510233510241510247510253510271510287510299510311510319510331510361510379510383510401510403510449510451510457510463510481510529510551510553510569510581510583510589510611510613510617510619510677510683510691510707510709510751510767510773510793510803510817510823510827510847510889510907510919510931510941510943510989511001511013511019511033511039511057511061511087511109511111511123511151511153511163511169511171511177511193511201511211511213511223511237511243511261511279511289511297511327511333511337511351511361511387511391511409511417511439511447511453511457511463511477511487511507511519511523511541511549511559511573511579511583511591511603511627511631511633511669511691511703511711511723511757511787511793511801511811511831511843511859511867511873511891511897511909511933511939511961511963511991511997512009512011512021512047512059512093512101512137512147512167512207512249512251512269512287512311512321512333512353512389512419512429512443512467512497512503512507512521512531512537512543512569512573512579512581512591512593512597512609512621512641512657512663512671512683512711512713512717512741512747512761512767512779512797512803512819512821512843512849512891512899512903512917512921512927512929512959512977512989512999513001513013513017513031513041513047513053513059513067513083513101513103513109513131513137513157513167513169513173513203513239513257513269513277513283513307513311513313513319513341513347513353513367513371513397513407513419513427513431513439513473513479513481513509513511513529513533513593513631513641513649513673513679513683513691513697513719513727513731513739513749513761513767513769513781513829513839513841513871513881513899513917513923513937513943513977513991514001514009514013514021514049514051514057514061514079514081514093514103514117514123514127514147514177514187514201514219514229514243514247514249514271514277514289514309514313514333514343514357514361514379514399514417514429514433514453514499514513514519514523514529514531514543514561514571514621514637514639514643514649514651514669514681514711514733514739514741514747514751514757514769514783514793514819514823514831514841514847514853514859514867514873514889514903514933514939514949514967515041515087515089515111515143515149515153515173515191515227515231515233515237515279515293515311515323515351515357515369515371515377515381515401515429515477515507515519515539515563515579515587515597515611515621515639515651515653515663515677515681515687515693515701515737515741515761515771515773515777515783515803515813515839515843515857515861515873515887515917515923515929515941515951515969515993516017516023516049516053516077516091516127516151516157516161516163516169516179516193516199516209516223516227516233516247516251516253516277516283516293516319516323516349516359516361516371516377516391516407516421516431516433516437516449516457516469516493516499516517516521516539516541516563516587516589516599516611516617516619516623516643516653516673516679516689516701516709516713516721516727516757516793516811516821516829516839516847516871516877516883516907516911516931516947516949516959516973516977516979516991517003517043517061517067517073517079517081517087517091517129517151517169517177517183517189517207517211517217517229517241517243517249517261517267517277517289517303517337517343517367517373517381517393517399517403517411517417517457517459517469517471517481517487517499517501517507517511517513517547517549517553517571517577517589517597517603517609517613517619517637517639517711517717517721517729517733517739517747517817517823517831517861517873517877517901517919517927517931517949517967517981517991517999518017518047518057518059518083518099518101518113518123518129518131518137518153518159518171518179518191518207518209518233518237518239518249518261518291518299518311518327518341518387518389518411518417518429518431518447518467518471518473518509518521518533518543518579518587518597518611518621518657518689518699518717518729518737518741518743518747518759518761518767518779518801518803518807518809518813518831518863518867518893518911518933518953518981518983518989519011519031519037519067519083519089519091519097519107519119519121519131519151519161519193519217519227519229519247519257519269519283519287519301519307519349519353519359519371519373519383519391519413519427519433519457519487519499519509519521519523519527519539519551519553519577519581519587519611519619519643519647519667519683519691519703519713519733519737519769519787519793519797519803519817519863519881519889519907519917519919519923519931519943519947519971519989519997520019520021520031520043520063520067520073520103520111520123520129520151520193520213520241520279520291520297520307520309520313520339520349520357520361520363520369520379520381520393520409520411520423520427520433520447520451520529520547520549520567520571520589520607520609520621520631520633520649520679520691520699520703520717520721520747520759520763520787520813520837520841520853520867520889520913520921520943520957520963520967520969520981521009521021521023521039521041521047521051521063521107521119521137521153521161521167521173521177521179521201521231521243521251521267521281521299521309521317521329521357521359521363521369521377521393521399521401521429521447521471521483521491521497521503521519521527521533521537521539521551521557521567521581521603521641521657521659521669521671521693521707521723521743521749521753521767521777521789521791521809521813521819521831521861521869521879521881521887521897521903521923521929521981521993521999522017522037522047522059522061522073522079522083522113522127522157522161522167522191522199522211522227522229522233522239522251522259522281522283522289522317522323522337522371522373522383522391522409522413522439522449522469522479522497522517522521522523522541522553522569522601522623522637522659522661522673522677522679522689522703522707522719522737522749522757522761522763522787522811522827522829522839522853522857522871522881522883522887522919522943522947522959522961522989523007523021523031523049523093523097523109523129523169523177523207523213523219523261523297523307523333523349523351523357523387523403523417523427523433523459523463523487523489523493523511523519523541523543523553523571523573523577523597523603523631523637523639523657523667523669523673523681523717523729523741523759523763523771523777523793523801523829523847523867523877523903523907523927523937523949523969523987523997524047524053524057524063524071524081524087524099524113524119524123524149524171524189524197524201524203524219524221524231524243524257524261524269524287524309524341524347524351524353524369524387524389524411524413524429524453524497524507524509524519524521524591524593524599524633524669524681524683524701524707524731524743524789524801524803524827524831524857524863524869524873524893524899524921524933524939524941524947524957524959524963524969524971524981524983524999525001525013525017525029525043525101525127525137525143525157525163525167525191525193525199525209525221525241525247525253525257525299525313525353525359525361525373525377525379525391525397525409525431525433525439525457525461525467525491525493525517525529525533525541525571525583525593525599525607525641525649525671525677525697525709525713525719525727525731525739525769525773525781525809525817525839525869525871525887525893525913525923525937525947525949525953525961525979525983526027526037526049526051526063526067526069526073526087526117526121526139526157526159526189526193526199526213526223526231526249526271526283526289526291526297526307526367526373526381526387526391526397526423526429526441526453526459526483526499526501526511526531526543526571526573526583526601526619526627526633526637526649526651526657526667526679526681526703526709526717526733526739526741526759526763526777526781526829526831526837526853526859526871526909526913526931526937526943526951526957526963526993526997527053527057527063527069527071527081527099527123527129527143527159527161527173527179527203527207527209527237527251527273527281527291527327527333527347527353527377527381527393527399527407527411527419527441527447527453527489527507527533527557527563527581527591527599527603527623527627527633527671527699527701527729527741527749527753527789527803527809527819527843527851527869527881527897527909527921527929527941527981527983527987527993528001528013528041528043528053528091528097528107528127528131528137528163528167528191528197528217528223528247528263528289528299528313528317528329528373528383528391528401528403528413528419528433528469528487528491528509528511528527528559528611528623528629528631528659528667528673528679528691528707528709528719528763528779528791528799528811528821528823528833528863528877528881528883528911528929528947528967528971528973528991529003529007529027529033529037529043529049529051529097529103529117529121529127529129529153529157529181529183529213529229529237529241529259529271529273529301529307529313529327529343529349529357529381529393529411529421529423529471529489529513529517529519529531529547529577529579529603529619529637529649529657529673529681529687529691529693529709529723529741529747529751529807529811529813529819529829529847529871529927529933529939529957529961529973529979529981529987529999530017530021530027530041530051530063530087530093530129530137530143530177530183530197530203530209530227530237530249530251530261530267530279530293530297530303530329530333530339530353530359530389530393530401530429530443530447530501530507530513530527530531530533530539530549530567530597530599530603530609530641530653530659530669530693530701530711530713530731530741530743530753530767530773530797530807530833530837530843530851530857530861530869530897530911530947530969530977530983530989531017531023531043531071531079531101531103531121531133531143531163531169531173531197531203531229531239531253531263531281531287531299531331531337531343531347531353531359531383531457531481531497531521531547531551531569531571531581531589531611531613531623531631531637531667531673531689531701531731531793531799531821531823531827531833531841531847531857531863531871531877531901531911531919531977531983531989531997532001532009532027532033532061532069532093532099532141532153532159532163532183532187532193532199532241532249532261532267532277532283532307532313532327532331532333532349532373532379532391532403532417532421532439532447532451532453532489532501532523532529532531532537532547532561532601532603532607532619532621532633532639532663532669532687532691532709532733532739532751532757532771532781532783532789532801532811532823532849532853532867532907532919532949532951532981532993532999533003533009533011533033533051533053533063533077533089533111533129533149533167533177533189533191533213533219533227533237533249533257533261533263533297533303533317533321533327533353533363533371533389533399533413533447533453533459533509533543533549533573533581533593533633533641533671533693533711533713533719533723533737533747533777533801533809533821533831533837533857533879533887533893533909533921533927533959533963533969533971533989533993533999534007534013534019534029534043534047534049534059534073534077534091534101534113534137534167534173534199534203534211534229534241534253534283534301534307534311534323534329534341534367534371534403534407534431534439534473534491534511534529534553534571534577534581534601534607534617534629534631534637534647534649534659534661534671534697534707534739534799534811534827534839534841534851534857534883534889534913534923534931534943534949534971535013535019535033535037535061535099535103535123535133535151535159535169535181535193535207535219535229535237535243535273535303535319535333535349535351535361535387535391535399535481535487535489535499535511535523535529535547535571535573535589535607535609535627535637535663535669535673535679535697535709535727535741535751535757535771535783535793535811535849535859535861535879535919535937535939535943535957535967535973535991535999536017536023536051536057536059536069536087536099536101536111536141536147536149536189536191536203536213536219536227536233536243536267536273536279536281536287536293536311536323536353536357536377536399536407536423536441536443536447536449536453536461536467536479536491536509536513536531536533536561536563536593536609536621536633536651536671536677536687536699536717536719536729536743536749536771536773536777536779536791536801536803536839536849536857536867536869536891536909536917536923536929536933536947536953536971536989536999537001537007537011537023537029537037537041537067537071537079537091537127537133537143537157537169537181537191537197537221537233537241537269537281537287537307537331537343537347537373537379537401537403537413537497537527537547537569537583537587537599537611537637537661537673537679537703537709537739537743537749537769537773537781537787537793537811537841537847537853537877537883537899537913537919537941537991538001538019538049538051538073538079538093538117538121538123538127538147538151538157538159538163538199538201538247538249538259538267538283538297538301538303538309538331538333538357538367538397538399538411538423538457538471538481538487538511538513538519538523538529538553538561538567538579538589538597538621538649538651538697538709538711538721538723538739538751538763538771538777538789538799538801538817538823538829538841538871538877538921538927538931538939538943538987539003539009539039539047539089539093539101539107539111539113539129539141539153539159539167539171539207539219539233539237539261539267539269539293539303539309539311539321539323539339539347539351539389539401539447539449539479539501539503539507539509539533539573539621539629539633539639539641539653539663539677539687539711539713539723539729539743539761539783539797539837539839539843539849539863539881539897539899539921539947539993540041540061540079540101540119540121540139540149540157540167540173540179540181540187540203540217540233540251540269540271540283540301540307540343540347540349540367540373540377540383540389540391540433540437540461540469540509540511540517540539540541540557540559540577540587540599540611540613540619540629540677540679540689540691540697540703540713540751540769540773540779540781540803540809540823540851540863540871540877540901540907540961540989541001541007541027541049541061541087541097541129541133541141541153541181541193541201541217541231541237541249541267541271541283541301541309541339541349541361541363541369541381541391541417541439541447541469541483541507541511541523541529541531541537541543541547541549541571541577541579541589541613541631541657541661541669541693541699541711541721541727541759541763541771541777541781541799541817541831541837541859541889541901541927541951541967541987541991541993541999542021542023542027542053542063542071542081542083542093542111542117542119542123542131542141542149542153542167542183542189542197542207542219542237542251542261542263542281542293542299542323542371542401542441542447542461542467542483542489542497542519542533542537542539542551542557542567542579542587542599542603542683542687542693542713542719542723542747542761542771542783542791542797542821542831542837542873542891542911542921542923542933542939542947542951542981542987542999543017543019543029543061543097543113543131543139543143543149543157543161543163543187543203543217543223543227543233543241543253543259543281543287543289543299543307543311543313543341543349543353543359543379543383543407543427543463543497543503543509543539543551543553543593543601543607543611543617543637543659543661543671543679543689543703543707543713543769543773543787543791543793543797543811543827543841543853543857543859543871543877543883543887543889543901543911543929543967543971543997544001544007544009544013544021544031544097544099544109544123544129544133544139544171544177544183544199544223544259544273544277544279544367544373544399544403544429544451544471544477544487544501544513544517544543544549544601544613544627544631544651544667544699544717544721544723544727544757544759544771544781544793544807544813544837544861544877544879544883544889544897544903544919544927544937544961544963544979545023545029545033545057545063545087545089545093545117545131545141545143545161545189545203545213545231545239545257545267545291545329545371545387545429545437545443545449545473545477545483545497545521545527545533545543545549545551545579545599545609545617545621545641545647545651545663545711545723545731545747545749545759545773545789545791545827545843545863545873545893545899545911545917545929545933545939545947545959546001546017546019546031546047546053546067546071546097546101546103546109546137546149546151546173546179546197546211546233546239546241546253546263546283546289546317546323546341546349546353546361546367546373546391546461546467546479546509546523546547546569546583546587546599546613546617546619546631546643546661546671546677546683546691546709546719546731546739546781546841546859546863546869546881546893546919546937546943546947546961546967546977547007547021547037547061547087547093547097547103547121547133547139547171547223547229547237547241547249547271547273547291547301547321547357547361547363547369547373547387547397547399547411547441547453547471547483547487547493547499547501547513547529547537547559547567547577547583547601547609547619547627547639547643547661547663547681547709547727547741547747547753547763547769547787547817547819547823547831547849547853547871547889547901547909547951547957547999548003548039548059548069548083548089548099548117548123548143548153548189548201548213548221548227548239548243548263548291548309548323548347548351548363548371548393548399548407548417548423548441548453548459548461548489548501548503548519548521548533548543548557548567548579548591548623548629548657548671548677548687548693548707548719548749548753548761548771548783548791548827548831548833548837548843548851548861548869548893548897548903548909548927548953548957548963549001549011549013549019549023549037549071549089549091549097549121549139549149549161549163549167549169549193549203549221549229549247549257549259549281549313549319549323549331549379549391549403549421549431549443549449549481549503549509549511549517549533549547549551549553549569549587549589549607549623549641549643549649549667549683549691549701549707549713549719549733549737549739549749549751549767549817549833549839549863549877549883549911549937549943549949549977549979550007550009550027550049550061550063550073550111550117550127550129550139550163550169550177550181550189550211550213550241550267550279550283550289550309550337550351550369550379550427550439550441550447550457550469550471550489550513550519550531550541550553550577550607550609550621550631550637550651550657550661550663550679550691550703550717550721550733550757550763550789550801550811550813550831550841550843550859550861550903550909550937550939550951550961550969550973550993550997551003551017551027551039551059551063551069551093551099551107551113551129551143551179551197551207551219551231551233551269551281551297551311551321551339551347551363551381551387551407551423551443551461551483551489551503551519551539551543551549551557551569551581551587551597551651551653551659551671551689551693551713551717551723551729551731551743551753551767551773551801551809551813551843551849551861551909551911551917551927551933551951551959551963551981552001552011552029552031552047552053552059552089552091552103552107552113552127552137552179552193552217552239552241552259552263552271552283552301552317552341552353552379552397552401552403552469552473552481552491552493552511552523552527552553552581552583552589552611552649552659552677552703552707552709552731552749552751552757552787552791552793552809552821552833552841552847552859552883552887552899552913552917552971552983552991553013553037553043553051553057553067553073553093553097553099553103553123553139553141553153553171553181553193553207553211553229553249553253553277553279553309553351553363553369553411553417553433553439553447553457553463553471553481553507553513553517553529553543553549553561553573553583553589553591553601553607553627553643553649553667553681553687553699553703553727553733553747553757553759553769553789553811553837553849553867553873553897553901553919553921553933553961553963553981553991554003554011554017554051554077554087554089554117554123554129554137554167554171554179554189554207554209554233554237554263554269554293554299554303554317554347554377554383554417554419554431554447554453554467554503554527554531554569554573554597554611554627554633554639554641554663554669554677554699554707554711554731554747554753554759554767554779554789554791554797554803554821554833554837554839554843554849554887554891554893554899554923554927554951554959554969554977555029555041555043555053555073555077555083555091555097555109555119555143555167555209555221555251555253555257555277555287555293555301555307555337555349555361555383555391555419555421555439555461555487555491555521555523555557555589555593555637555661555671555677555683555691555697555707555739555743555761555767555823555827555829555853555857555871555931555941555953555967556007556021556027556037556043556051556067556069556093556103556123556159556177556181556211556219556229556243556253556261556267556271556273556279556289556313556321556327556331556343556351556373556399556403556441556459556477556483556487556513556519556537556559556573556579556583556601556607556609556613556627556639556651556679556687556691556693556697556709556723556727556741556753556763556769556781556789556793556799556811556817556819556823556841556849556859556861556867556883556891556931556939556943556957556967556981556987556999557017557021557027557033557041557057557059557069557087557093557153557159557197557201557261557269557273557281557303557309557321557329557339557369557371557377557423557443557449557461557483557489557519557521557533557537557551557567557573557591557611557633557639557663557671557693557717557729557731557741557743557747557759557761557779557789557801557803557831557857557861557863557891557899557903557927557981557987558007558017558029558053558067558083558091558109558113558121558139558149558167558179558197558203558209558223558241558251558253558287558289558307558319558343558401558413558421558427558431558457558469558473558479558491558497558499558521558529558533558539558541558563558583558587558599558611558629558643558661558683558703558721558731558757558769558781558787558791558793558827558829558863558869558881558893558913558931558937558947558973558979558997559001559049559051559067559081559093559099559123559133559157559177559183559201559211559213559217559219559231559243559259559277559297559313559319559343559357559367559369559397559421559451559459559469559483559511559513559523559529559541559547559549559561559571559577559583559591559597559631559633559639559649559667559673559679559687559703559709559739559747559777559781559799559807559813559831559841559849559859559877559883559901559907559913559939559967559973559991560017560023560029560039560047560081560083560089560093560107560113560117560123560137560149560159560171560173560179560191560207560213560221560227560233560237560239560243560249560281560293560297560299560311560317560341560353560393560411560437560447560459560471560477560479560489560491560501560503560531560543560551560561560597560617560621560639560641560653560669560683560689560701560719560737560753560761560767560771560783560797560803560827560837560863560869560873560887560891560893560897560929560939560941560969560977561019561047561053561059561061561079561083561091561097561101561103561109561161561173561181561191561199561229561251561277561307561313561343561347561359561367561373561377561389561409561419561439561461561521561529561551561553561559561599561607561667561703561713561733561761561767561787561797561809561829561839561907561917561923561931561943561947561961561973561983561997562007562019562021562043562091562103562129562147562169562181562193562201562231562259562271562273562283562291562297562301562307562313562333562337562349562351562357562361562399562403562409562417562421562427562439562459562477562493562501562517562519562537562577562579562589562591562607562613562621562631562633562651562663562669562673562691562693562699562703562711562721562739562753562759562763562781562789562813562831562841562871562897562901562909562931562943562949562963562967562973562979562987562997563009563011563021563039563041563047563051563077563081563099563113563117563119563131563149563153563183563197563219563249563263563287563327563351563357563359563377563401563411563413563417563419563447563449563467563489563501563503563543563551563561563587563593563599563623563657563663563723563743563747563777563809563813563821563831563837563851563869563881563887563897563929563933563947563971563987563999564013564017564041564049564059564061564089564097564103564127564133564149564163564173564191564197564227564229564233564251564257564269564271564299564301564307564313564323564353564359564367564371564373564391564401564407564409564419564437564449564457564463564467564491564497564523564533564593564607564617564643564653564667564671564679564701564703564709564713564761564779564793564797564827564871564881564899564917564919564923564937564959564973564979564983564989564997565013565039565049565057565069565109565111565127565163565171565177565183565189565207565237565241565247565259565261565273565283565289565303565319565333565337565343565361565379565381565387565391565393565427565429565441565451565463565469565483565489565507565511565517565519565549565553565559565567565571565583565589565597565603565613565637565651565661565667565723565727565769565771565787565793565813565849565867565889565891565907565909565919565921565937565973565979565997566011566023566047566057566077566089566101566107566131566149566161566173566179566183566201566213566227566231566233566273566311566323566347566387566393566413566417566429566431566437566441566443566453566521566537566539566543566549566551566557566563566567566617566633566639566653566659566677566681566693566701566707566717566719566723566737566759566767566791566821566833566851566857566879566911566939566947566963566971566977566987566999567011567013567031567053567059567067567097567101567107567121567143567179567181567187567209567257567263567277567319567323567367567377567383567389567401567407567439567449567451567467567487567493567499567527567529567533567569567601567607567631567649567653567659567661567667567673567689567719567737567751567761567767567779567793567811567829567841567857567863567871567877567881567883567899567937567943567947567949567961567979567991567997568019568027568033568049568069568091568097568109568133568151568153568163568171568177568187568189568193568201568207568231568237568241568273568279568289568303568349568363568367568387568391568433568439568441568453568471568481568493568523568541568549568577568609568619568627568643568657568669568679568691568699568709568723568751568783568787568807568823568831568853568877568891568903568907568913568921568963568979568987568991568999569003569011569021569047569053569057569071569077569081569083569111569117569137569141569159569161569189569197569201569209569213569237569243569249569251569263569267569269569321569323569369569417569419569423569431569447569461569479569497569507569533569573569579569581569599569603569609569617569623569659569663569671569683569711569713569717569729569731569747569759569771569773569797569809569813569819569831569839569843569851569861569869569887569893569897569903569927569939569957569983570001570013570029570041570043570047570049570071570077570079570083570091570107570109570113570131570139570161570173570181570191570217570221570233570253570329570359570373570379570389570391570403570407570413570419570421570461570463570467570487570491570497570499570509570511570527570529570539570547570553570569570587570601570613570637570643570649570659570667570671570677570683570697570719570733570737570743570781570821570827570839570841570851570853570859570881570887570901570919570937570949570959570961570967570991571001571019571031571037571049571069571093571099571111571133571147571157571163571199571201571211571223571229571231571261571267571279571303571321571331571339571369571381571397571399571409571433571453571471571477571531571541571579571583571589571601571603571633571657571673571679571699571709571717571721571741571751571759571777571783571789571799571801571811571841571847571853571861571867571871571873571877571903571933571939571969571973572023572027572041572051572053572059572063572069572087572093572107572137572161572177572179572183572207572233572239572251572269572281572303572311572321572323572329572333572357572387572399572417572419572423572437572449572461572471572479572491572497572519572521572549572567572573572581572587572597572599572609572629572633572639572651572653572657572659572683572687572699572707572711572749572777572791572801572807572813572821572827572833572843572867572879572881572903572909572927572933572939572941572963572969572993573007573031573047573101573107573109573119573143573161573163573179573197573247573253573263573277573289573299573317573329573341573343573371573379573383573409573437573451573457573473573479573481573487573493573497573509573511573523573527573557573569573571573637573647573673573679573691573719573737573739573757573761573763573787573791573809573817573829573847573851573863573871573883573887573899573901573929573941573953573967573973573977574003574031574033574051574061574081574099574109574127574157574159574163574169574181574183574201574219574261574279574283574289574297574307574309574363574367574373574393574423574429574433574439574477574489574493574501574507574529574543574547574597574619574621574627574631574643574657574667574687574699574703574711574723574727574733574741574789574799574801574813574817574859574907574913574933574939574949574963574967574969575009575027575033575053575063575077575087575119575123575129575131575137575153575173575177575203575213575219575231575243575249575251575257575261575303575317575359575369575371575401575417575429575431575441575473575479575489575503575513575551575557575573575579575581575591575593575611575623575647575651575669575677575689575693575699575711575717575723575747575753575777575791575821575837575849575857575863575867575893575903575921575923575941575957575959575963575987576001576013576019576029576031576041576049576089576101576119576131576151576161576167576179576193576203576211576217576221576223576227576287576293576299576313576319576341576377576379576391576421576427576431576439576461576469576473576493576509576523576529576533576539576551576553576577576581576613576617576637576647576649576659576671576677576683576689576701576703576721576727576731576739576743576749576757576769576787576791576881576883576889576899576943576949576967576977577007577009577033577043577063577067577069577081577097577111577123577147577151577153577169577177577193577219577249577259577271577279577307577327577331577333577349577351577363577387577397577399577427577453577457577463577471577483577513577517577523577529577531577537577547577559577573577589577601577613577627577637577639577667577721577739577751577757577781577799577807577817577831577849577867577873577879577897577901577909577919577931577937577939577957577979577981578021578029578041578047578063578077578093578117578131578167578183578191578203578209578213578251578267578297578299578309578311578317578327578353578363578371578399578401578407578419578441578453578467578477578483578489578497578503578509578533578537578563578573578581578587578597578603578609578621578647578659578687578689578693578701578719578729578741578777578779578789578803578819578821578827578839578843578857578861578881578917578923578957578959578971578999579011579017579023579053579079579083579107579113579119579133579179579197579199579239579251579259579263579277579281579283579287579311579331579353579379579407579409579427579433579451579473579497579499579503579517579521579529579533579539579541579563579569579571579583579587579611579613579629579637579641579643579653579673579701579707579713579721579737579757579763579773579779579809579829579851579869579877579881579883579893579907579947579949579961579967579973579983580001580031580033580079580081580093580133580163580169580183580187580201580213580219580231580259580291580301580303580331580339580343580357580361580373580379580381580409580417580471580477580487580513580529580549580553580561580577580607580627580631580633580639580663580673580687580691580693580711580717580733580747580757580759580763580787580793580807580813580837580843580859580871580889580891580901580913580919580927580939580969580981580997581029581041581047581069581071581089581099581101581137581143581149581171581173581177581183581197581201581227581237581239581261581263581293581303581311581323581333581341581351581353581369581377581393581407581411581429581443581447581459581473581491581521581527581549581551581557581573581597581599581617581639581657581663581683581687581699581701581729581731581743581753581767581773581797581809581821581843581857581863581869581873581891581909581921581941581947581953581981581983582011582013582017582031582037582067582083582119582137582139582157582161582167582173582181582203582209582221582223582227582247582251582299582317582319582371582391582409582419582427582433582451582457582469582499582509582511582541582551582563582587582601582623582643582649582677582689582691582719582721582727582731582737582761582763582767582773582781582793582809582821582851582853582859582887582899582931582937582949582961582971582973582983583007583013583019583021583031583069583087583127583139583147583153583169583171583181583189583207583213583229583237583249583267583273583279583291583301583337583339583351583367583391583397583403583409583417583421583447583459583469583481583493583501583511583519583523583537583543583577583603583613583619583621583631583651583657583669583673583697583727583733583753583769583777583783583789583801583841583853583859583861583873583879583903583909583937583969583981583991583997584011584027584033584053584057584063584081584099584141584153584167584183584203584249584261584279584281584303584347584357584359584377584387584393584399584411584417584429584447584471584473584509584531584557584561584587584593584599584603584609584621584627584659584663584677584693584699584707584713584719584723584737584767584777584789584791584809584849584863584869584873584879584897584911584917584923584951584963584971584981584993584999585019585023585031585037585041585043585049585061585071585073585077585107585113585119585131585149585163585199585217585251585269585271585283585289585313585317585337585341585367585383585391585413585437585443585461585467585493585503585517585547585551585569585577585581585587585593585601585619585643585653585671585677585691585721585727585733585737585743585749585757585779585791585799585839585841585847585853585857585863585877585881585883585889585899585911585913585917585919585953585989585997586009586037586051586057586067586073586087586111586121586123586129586139586147586153586189586213586237586273586277586291586301586309586319586349586361586363586367586387586403586429586433586457586459586463586471586493586499586501586541586543586567586571586577586589586601586603586609586627586631586633586667586679586693586711586723586741586769586787586793586801586811586813586819586837586841586849586871586897586903586909586919586921586933586939586951586961586973586979586981587017587021587033587051587053587057587063587087587101587107587117587123587131587137587143587149587173587179587189587201587219587263587267587269587281587287587297587303587341587371587381587387587413587417587429587437587441587459587467587473587497587513587519587527587533587539587549587551587563587579587599587603587617587621587623587633587659587669587677587687587693587711587731587737587747587749587753587771587773587789587813587827587833587849587863587887587891587897587927587933587947587959587969587971587987587989587999588011588019588037588043588061588073588079588083588097588113588121588131588151588167588169588173588191588199588229588239588241588257588277588293588311588347588359588361588383588389588397588403588433588437588463588481588493588503588509588517588521588529588569588571588619588631588641588647588649588667588673588683588703588733588737588743588767588773588779588811588827588839588871588877588881588893588911588937588941588947588949588953588977589021589027589049589063589109589111589123589139589159589163589181589187589189589207589213589219589231589241589243589273589289589291589297589327589331589349589357589387589409589439589451589453589471589481589493589507589529589531589579589583589591589601589607589609589639589643589681589711589717589751589753589759589763589783589793589807589811589829589847589859589861589873589877589903589921589933589993589997590021590027590033590041590071590077590099590119590123590129590131590137590141590153590171590201590207590243590251590263590267590269590279590309590321590323590327590357590363590377590383590389590399590407590431590437590489590537590543590567590573590593590599590609590627590641590647590657590659590669590713590717590719590741590753590771590797590809590813590819590833590839590867590899590921590923590929590959590963590983590987591023591053591061591067591079591089591091591113591127591131591137591161591163591181591193591233591259591271591287591289591301591317591319591341591377591391591403591407591421591431591443591457591469591499591509591523591553591559591581591599591601591611591623591649591653591659591673591691591709591739591743591749591751591757591779591791591827591841591847591863591881591887591893591901591937591959591973592019592027592049592057592061592073592087592099592121592129592133592139592157592199592217592219592223592237592261592289592303592307592309592321592337592343592351592357592367592369592387592391592393592429592451592453592463592469592483592489592507592517592531592547592561592577592589592597592601592609592621592639592643592649592661592663592681592693592723592727592741592747592759592763592793592843592849592853592861592873592877592897592903592919592931592939592967592973592987592993593003593029593041593051593059593071593081593083593111593119593141593143593149593171593179593183593207593209593213593227593231593233593251593261593273593291593293593297593321593323593353593381593387593399593401593407593429593447593449593473593479593491593497593501593507593513593519593531593539593573593587593597593603593627593629593633593641593647593651593689593707593711593767593777593783593839593851593863593869593899593903593933593951593969593977593987593993594023594037594047594091594103594107594119594137594151594157594161594163594179594193594203594211594227594241594271594281594283594287594299594311594313594329594359594367594379594397594401594403594421594427594449594457594467594469594499594511594521594523594533594551594563594569594571594577594617594637594641594653594667594679594697594709594721594739594749594751594773594793594821594823594827594829594857594889594899594911594917594929594931594953594959594961594977594989595003595037595039595043595057595069595073595081595087595093595097595117595123595129595139595141595157595159595181595183595201595207595229595247595253595261595267595271595277595291595303595313595319595333595339595351595363595373595379595381595411595451595453595481595513595519595523595547595549595571595577595579595613595627595687595703595709595711595717595733595741595801595807595817595843595873595877595927595939595943595949595951595957595961595963595967595981596009596021596027596047596053596059596069596081596083596093596117596119596143596147596159596179596209596227596231596243596251596257596261596273596279596291596293596317596341596363596369596399596419596423596461596489596503596507596537596569596573596579596587596593596599596611596623596633596653596663596669596671596693596707596737596741596749596767596779596789596803596821596831596839596851596857596861596863596879596899596917596927596929596933596941596963596977596983596987597031597049597053597059597073597127597131597133597137597169597209597221597239597253597263597269597271597301597307597349597353597361597367597383597391597403597407597409597419597433597437597451597473597497597521597523597539597551597559597577597581597589597593597599597613597637597643597659597671597673597677597679597689597697597757597761597767597769597781597803597823597827597833597853597859597869597889597899597901597923597929597967597997598007598049598051598057598079598093598099598123598127598141598151598159598163598187598189598193598219598229598261598303598307598333598363598369598379598387598399598421598427598439598447598457598463598487598489598501598537598541598571598613598643598649598651598657598669598681598687598691598711598721598727598729598777598783598789598799598817598841598853598867598877598883598891598903598931598933598963598967598973598981598987598999599003599009599021599023599069599087599117599143599147599149599153599191599213599231599243599251599273599281599303599309599321599341599353599359599371599383599387599399599407599413599419599429599477599479599491599513599519599537599551599561599591599597599603599611599623599629599657599663599681599693599699599701599713599719599741599759599779599783599803599831599843599857599869599891599899599927599933599939599941599959599983599993599999600011600043600053600071600073600091600101600109600167600169600203600217600221600233600239600241600247600269600283600289600293600307600311600317600319600337600359600361600367600371600401600403600407600421600433600449600451600463600469600487600517600529600557600569600577600601600623600631600641600659600673600689600697600701600703600727600751600791600823600827600833600841600857600877600881600883600889600893600931600947600949600959600961600973600979600983601021601031601037601039601043601061601067601079601093601127601147601187601189601193601201601207601219601231601241601247601259601267601283601291601297601309601313601319601333601339601357601379601397601411601423601439601451601457601487601507601541601543601589601591601607601631601651601669601687601697601717601747601751601759601763601771601801601807601813601819601823601831601849601873601883601889601897601903601943601949601961601969601981602029602033602039602047602057602081602083602087602093602099602111602137602141602143602153602179602197602201602221602227602233602257602267602269602279602297602309602311602317602321602333602341602351602377602383602401602411602431602453602461602477602479602489602501602513602521602543602551602593602597602603602621602627602639602647602677602687602689602711602713602717602729602743602753602759602773602779602801602821602831602839602867602873602887602891602909602929602947602951602971602977602983602999603011603013603023603047603077603091603101603103603131603133603149603173603191603203603209603217603227603257603283603311603319603349603389603391603401603431603443603457603467603487603503603521603523603529603541603553603557603563603569603607603613603623603641603667603679603689603719603731603739603749603761603769603781603791603793603817603821603833603847603851603853603859603881603893603899603901603907603913603917603919603923603931603937603947603949603989604001604007604013604031604057604063604069604073604171604189604223604237604243604249604259604277604291604309604313604319604339604343604349604361604369604379604397604411604427604433604441604477604481604517604529604547604559604579604589604603604609604613604619604649604651604661604697604699604711604727604729604733604753604759604781604787604801604811604819604823604829604837604859604861604867604883604907604931604939604949604957604973604997605009605021605023605039605051605069605071605113605117605123605147605167605173605177605191605221605233605237605239605249605257605261605309605323605329605333605347605369605393605401605411605413605443605471605477605497605503605509605531605533605543605551605573605593605597605599605603605609605617605629605639605641605687605707605719605779605789605809605837605849605861605867605873605879605887605893605909605921605933605947605953605977605987605993606017606029606031606037606041606049606059606077606079606083606091606113606121606131606173606181606223606241606247606251606299606301606311606313606323606341606379606383606413606433606443606449606493606497606503606521606527606539606559606569606581606587606589606607606643606649606653606659606673606721606731606733606737606743606757606791606811606829606833606839606847606857606863606899606913606919606943606959606961606967606971606997607001607003607007607037607043607049607063607067607081607091607093607097607109607127607129607147607151607153607157607163607181607199607213607219607249607253607261607301607303607307607309607319607331607337607339607349607357607363607417607421607423607471607493607517607531607549607573607583607619607627607667607669607681607697607703607721607723607727607741607769607813607819607823607837607843607861607883607889607909607921607931607933607939607951607961607967607991607993608011608029608033608087608089608099608117608123608129608131608147608161608177608191608207608213608269608273608297608299608303608339608347608357608359608369608371608383608389608393608401608411608423608429608431608459608471608483608497608519608521608527608581608591608593608609608611608633608653608659608669608677608693608701608737608743608749608759608767608789608819608831608843608851608857608863608873608887608897608899608903608941608947608953608977608987608989608999609043609047609067609071609079609101609107609113609143609149609163609173609179609199609209609221609227609233609241609253609269609277609283609289609307609313609337609359609361609373609379609391609397609403609407609421609437609443609461609487609503609509609517609527609533609541609571609589609593609599609601609607609613609617609619609641609673609683609701609709609743609751609757609779609781609803609809609821609859609877609887609907609911609913609923609929609979609989609991609997610031610063610081610123610157610163610187610193610199610217610219610229610243610271610279610289610301610327610331610339610391610409610417610429610439610447610457610469610501610523610541610543610553610559610567610579610583610619610633610639610651610661610667610681610699610703610721610733610739610741610763610781610783610787610801610817610823610829610837610843610847610849610867610877610879610891610913610919610921610933610957610969610993611011611027611033611057611069611071611081611101611111611113611131611137611147611189611207611213611257611263611279611293611297611323611333611389611393611411611419611441611449611453611459611467611483611497611531611543611549611551611557611561611587611603611621611641611657611671611693611707611729611753611791611801611803611827611833611837611839611873611879611887611903611921611927611939611951611953\"\n return primes[a:a+b]\n pass", "def solve(a, b):\n \n PrimList = [2]\n primstr = \"2\"\n z = 1\n \n while len(primstr) < a+b:\n \n z += 2\n test = 0\n maxsqrt = round(z**0.5)\n \n for p in PrimList:\n \n if p > maxsqrt:\n \n break\n \n if z % p == 0:\n \n test = 1\n break\n \n if test == 1:\n \n continue\n \n PrimList.append(z)\n primstr += str(z)\n \n \n return primstr[a:a+b]", "from itertools import count, islice\n # ideone.com/aVndFM\ndef postponed_sieve(): # postponed sieve, by Will Ness\n yield 2; yield 3; yield 5; yield 7; # original code David Eppstein,\n sieve = {} # Alex Martelli, ActiveState Recipe 2002\n ps = postponed_sieve() # a separate base Primes Supply:\n p = next(ps) and next(ps) # (3) a Prime to add to dict\n q = p*p # (9) its sQuare\n for c in count(9,2): # the Candidate\n if c in sieve: # c's a multiple of some base prime\n s = sieve.pop(c) # i.e. a composite ; or\n elif c < q:\n yield c # a prime\n continue\n else: # (c==q): # or the next base prime's square:\n s=count(q+2*p,2*p) # (9+6, by 6 : 15,21,27,33,...)\n p=next(ps) # (5)\n q=p*p # (25)\n for m in s: # the next multiple\n if m not in sieve: # no duplicates\n break\n sieve[m] = s # original test entry: ideone.com/WFv4f\n\ndef sequence():\n for d in postponed_sieve():\n yield from str(d)\n\nsolve = lambda s, l: ''.join(islice(sequence(), s, s+l))", "def solve(a,b):\n list = '2357111317192329313741434753596167717379838997101103107109113127131137139149151157163167173179181191193197199211223227229233239241251257263269271277281283293307311313317331337347349353359367373379383389397401409419421431433439443449457461463467479487491499503509521523541547557563569571577587593599601607613617619631641643647653659661673677683691701709719727733739743751757761769773787797809811821823827829839853857859863877881883887907911919929937941947953967971977983991997100910131019102110311033103910491051106110631069108710911093109711031109111711231129115111531163117111811187119312011213121712231229123112371249125912771279128312891291129713011303130713191321132713611367137313811399140914231427142914331439144714511453145914711481148314871489149314991511152315311543154915531559156715711579158315971601160716091613161916211627163716571663166716691693169716991709172117231733174117471753175917771783178717891801181118231831184718611867187118731877187918891901190719131931193319491951197319791987199319971999200320112017202720292039205320632069208120832087208920992111211321292131213721412143215321612179220322072213222122372239224322512267226922732281228722932297230923112333233923412347235123572371237723812383238923932399241124172423243724412447245924672473247725032521253125392543254925512557257925912593260926172621263326472657265926632671267726832687268926932699270727112713271927292731274127492753276727772789279127972801280328192833283728432851285728612879288728972903290929172927293929532957296329692971299930013011301930233037304130493061306730793083308931093119312131373163316731693181318731913203320932173221322932513253325732593271329933013307331333193323332933313343334733593361337133733389339134073413343334493457346134633467346934913499351135173527352935333539354135473557355935713581358335933607361336173623363136373643365936713673367736913697370137093719372737333739376137673769377937933797380338213823383338473851385338633877388138893907391139173919392339293931394339473967398940014003400740134019402140274049405140574073407940914093409941114127412941334139415341574159417742014211421742194229423142414243425342594261427142734283428942974327433743394349435743634373439143974409442144234441444744514457446344814483449345074513451745194523454745494561456745834591459746034621463746394643464946514657466346734679469147034721472347294733475147594783478747894793479948014813481748314861487148774889490349094919493149334937494349514957496749694973498749934999500350095011502150235039505150595077508150875099510151075113511951475153516751715179518951975209522752315233523752615273527952815297530353095323533353475351538153875393539954075413541754195431543754415443544954715477547954835501550355075519552155275531555755635569557355815591562356395641564756515653565756595669568356895693570157115717573757415743574957795783579158015807581358215827583958435849585158575861586758695879588158975903592359275939595359815987600760116029603760436047605360676073607960896091610161136121613161336143615161636173619761996203621162176221622962476257626362696271627762876299630163116317632363296337634363536359636163676373637963896397642164276449645164696473648164916521652965476551655365636569657165776581659966076619663766536659666166736679668966916701670367096719673367376761676367796781679167936803682368276829683368416857686368696871688368996907691169176947694969596961696769716977698369916997700170137019702770397043705770697079710371097121712771297151715971777187719372077211721372197229723772437247725372837297730773097321733173337349735173697393741174177433745174577459747774817487748974997507751775237529753775417547754975597561757375777583758975917603760776217639764376497669767376817687769176997703771777237727774177537757775977897793781778237829784178537867787378777879788379017907791979277933793779497951796379938009801180178039805380598069808180878089809381018111811781238147816181678171817981918209821982218231823382378243826382698273828782918293829783118317832983538363836983778387838984198423842984318443844784618467850185138521852785378539854385638573858185978599860986238627862986418647866386698677868186898693869987078713871987318737874187478753876187798783880388078819882188318837883988498861886388678887889389238929893389418951896389698971899990019007901190139029904190439049905990679091910391099127913391379151915791619173918191879199920392099221922792399241925792779281928392939311931993239337934193439349937193779391939794039413941994219431943394379439946194639467947394799491949795119521953395399547955195879601961396199623962996319643964996619677967996899697971997219733973997439749976797699781978797919803981198179829983398399851985798599871988398879901990799239929993199419949996799731000710009100371003910061100671006910079100911009310099101031011110133101391014110151101591016310169101771018110193102111022310243102471025310259102671027110273102891030110303103131032110331103331033710343103571036910391103991042710429104331045310457104591046310477104871049910501105131052910531105591056710589105971060110607106131062710631106391065110657106631066710687106911070910711107231072910733107391075310771107811078910799108311083710847108531085910861108671088310889108911090310909109371093910949109571097310979109871099311003110271104711057110591106911071110831108711093111131111711119111311114911159111611117111173111771119711213112391124311251112571126111273112791128711299113111131711321113291135111353113691138311393113991141111423114371144311447114671147111483114891149111497115031151911527115491155111579115871159311597116171162111633116571167711681116891169911701117171171911731117431177711779117831178911801118071181311821118271183111833118391186311867118871189711903119091192311927119331193911941119531195911969119711198111987120071201112037120411204312049120711207312097121011210712109121131211912143121491215712161121631219712203122111222712239122411225112253122631226912277122811228912301123231232912343123471237312377123791239112401124091241312421124331243712451124571247312479124871249112497125031251112517125271253912541125471255312569125771258312589126011261112613126191263712641126471265312659126711268912697127031271312721127391274312757127631278112791127991280912821128231282912841128531288912893128991290712911129171291912923129411295312959129671297312979129831300113003130071300913033130371304313049130631309313099131031310913121131271314713151131591316313171131771318313187132171321913229132411324913259132671329113297133091331313327133311333713339133671338113397133991341113417134211344113451134571346313469134771348713499135131352313537135531356713577135911359713613136191362713633136491366913679136811368713691136931369713709137111372113723137291375113757137591376313781137891379913807138291383113841138591387313877138791388313901139031390713913139211393113933139631396713997139991400914011140291403314051140571407114081140831408714107141431414914153141591417314177141971420714221142431424914251142811429314303143211432314327143411434714369143871438914401144071441114419144231443114437144471444914461144791448914503145191453314537145431454914551145571456114563145911459314621146271462914633146391465314657146691468314699147131471714723147311473714741147471475314759147671477114779147831479714813148211482714831148431485114867148691487914887148911489714923149291493914947149511495714969149831501315017150311505315061150731507715083150911510115107151211513115137151391514915161151731518715193151991521715227152331524115259152631526915271152771528715289152991530715313153191532915331153491535915361153731537715383153911540115413154271543915443154511546115467154731549315497155111552715541155511555915569155811558315601156071561915629156411564315647156491566115667156711567915683157271573115733157371573915749157611576715773157871579115797158031580915817158231585915877158811588715889159011590715913159191592315937159591597115973159911600116007160331605716061160631606716069160731608716091160971610316111161271613916141161831618716189161931621716223162291623116249162531626716273163011631916333163391634916361163631636916381164111641716421164271643316447164511645316477164811648716493165191652916547165531656116567165731660316607166191663116633166491665116657166611667316691166931669916703167291674116747167591676316787168111682316829168311684316871168791688316889169011690316921169271693116937169431696316979169811698716993170111702117027170291703317041170471705317077170931709917107171171712317137171591716717183171891719117203172071720917231172391725717291172931729917317173211732717333173411735117359173771738317387173891739317401174171741917431174431744917467174711747717483174891749117497175091751917539175511756917573175791758117597175991760917623176271765717659176691768117683177071771317729177371774717749177611778317789177911780717827178371783917851178631788117891179031790917911179211792317929179391795717959179711797717981179871798918013180411804318047180491805918061180771808918097181191812118127181311813318143181491816918181181911819918211182171822318229182331825118253182571826918287182891830118307183111831318329183411835318367183711837918397184011841318427184331843918443184511845718461184811849318503185171852118523185391854118553185831858718593186171863718661186711867918691187011871318719187311874318749187571877318787187931879718803188391885918869188991891118913189171891918947189591897318979190011900919013190311903719051190691907319079190811908719121191391914119157191631918119183192071921119213192191923119237192491925919267192731928919301193091931919333193731937919381193871939119403194171942119423194271942919433194411944719457194631946919471194771948319489195011950719531195411954319553195591957119577195831959719603196091966119681196871969719699197091971719727197391975119753197591976319777197931980119813198191984119843198531986119867198891989119913199191992719937199491996119963199731997919991199931999720011200212002320029200472005120063200712008920101201072011320117201232012920143201472014920161201732017720183202012021920231202332024920261202692028720297203232032720333203412034720353203572035920369203892039320399204072041120431204412044320477204792048320507205092052120533205432054920551205632059320599206112062720639206412066320681206932070720717207192073120743207472074920753207592077120773207892080720809208492085720873208792088720897208992090320921209292093920947209592096320981209832100121011210132101721019210232103121059210612106721089211012110721121211392114321149211572116321169211792118721191211932121121221212272124721269212772128321313213172131921323213412134721377213792138321391213972140121407214192143321467214812148721491214932149921503215172152121523215292155721559215632156921577215872158921599216012161121613216172164721649216612167321683217012171321727217372173921751217572176721773217872179921803218172182121839218412185121859218632187121881218932191121929219372194321961219772199121997220032201322027220312203722039220512206322067220732207922091220932210922111221232212922133221472215322157221592217122189221932222922247222592227122273222772227922283222912230322307223432234922367223692238122391223972240922433224412244722453224692248122483225012251122531225412254322549225672257122573226132261922621226372263922643226512266922679226912269722699227092271722721227272273922741227512276922777227832278722807228112281722853228592286122871228772290122907229212293722943229612296322973229932300323011230172302123027230292303923041230532305723059230632307123081230872309923117231312314323159231672317323189231972320123203232092322723251232692327923291232932329723311233212332723333233392335723369233712339923417234312344723459234732349723509235312353723539235492355723561235632356723581235932359923603236092362323627236292363323663236692367123677236872368923719237412374323747237532376123767237732378923801238132381923827238312383323857238692387323879238872389323899239092391123917239292395723971239772398123993240012400724019240232402924043240492406124071240772408324091240972410324107241092411324121241332413724151241692417924181241972420324223242292423924247242512428124317243292433724359243712437324379243912440724413244192442124439244432446924473244812449924509245172452724533245472455124571245932461124623246312465924671246772468324691246972470924733247492476324767247812479324799248092482124841248472485124859248772488924907249172491924923249432495324967249712497724979249892501325031250332503725057250732508725097251112511725121251272514725153251632516925171251832518925219252292523725243252472525325261253012530325307253092532125339253432534925357253672537325391254092541125423254392544725453254572546325469254712552325537255412556125577255792558325589256012560325609256212563325639256432565725667256732567925693257032571725733257412574725759257632577125793257992580125819258412584725849258672587325889259032591325919259312593325939259432595125969259812599725999260032601726021260292604126053260832609926107261112611326119261412615326161261712617726183261892620326209262272623726249262512626126263262672629326297263092631726321263392634726357263712638726393263992640726417264232643126437264492645926479264892649726501265132653926557265612657326591265972662726633266412664726669266812668326687266932669926701267112671326717267232672926731267372675926777267832680126813268212683326839268492686126863268792688126891268932690326921269272694726951269532695926981269872699327011270172703127043270592706127067270732707727091271032710727109271272714327179271912719727211272392724127253272592727127277272812728327299273292733727361273672739727407274092742727431274372744927457274792748127487275092752727529275392754127551275812758327611276172763127647276532767327689276912769727701277332773727739277432774927751277632776727773277792779127793277992780327809278172782327827278472785127883278932790127917279192794127943279472795327961279672798327997280012801928027280312805128057280692808128087280972809928109281112812328151281632818128183282012821128219282292827728279282832828928297283072830928319283492835128387283932840328409284112842928433284392844728463284772849328499285132851728537285412854728549285592857128573285792859128597286032860728619286212862728631286432864928657286612866328669286872869728703287112872328729287512875328759287712878928793288072881328817288372884328859288672887128879289012890928921289272893328949289612897929009290172902129023290272903329059290632907729101291232912929131291372914729153291672917329179291912920129207292092922129231292432925129269292872929729303293112932729333293392934729363293832938729389293992940129411294232942929437294432945329473294832950129527295312953729567295692957329581295872959929611296292963329641296632966929671296832971729723297412975329759297612978929803298192983329837298512986329867298732987929881299172992129927299472995929983299893001130013300293004730059300713008930091300973010330109301133011930133301373013930161301693018130187301973020330211302233024130253302593026930271302933030730313303193032330341303473036730389303913040330427304313044930467304693049130493304973050930517305293053930553305573055930577305933063130637306433064930661306713067730689306973070330707307133072730757307633077330781308033080930817308293083930841308513085330859308693087130881308933091130931309373094130949309713097730983310133101931033310393105131063310693107931081310913112131123311393114731151311533115931177311813118331189311933121931223312313123731247312493125331259312673127131277313073131931321313273133331337313573137931387313913139331397314693147731481314893151131513315173153131541315433154731567315733158331601316073162731643316493165731663316673168731699317213172331727317293174131751317693177131793317993181731847318493185931873318833189131907319573196331973319813199132003320093202732029320513205732059320633206932077320833208932099321173211932141321433215932173321833218932191322033221332233322373225132257322613229732299323033230932321323233232732341323533235932363323693237132377323813240132411324133242332429324413244332467324793249132497325033250732531325333253732561325633256932573325793258732603326093261132621326333264732653326873269332707327133271732719327493277132779327833278932797328013280332831328333283932843328693288732909329113291732933329393294132957329693297132983329873299332999330133302333029330373304933053330713307333083330913310733113331193314933151331613317933181331913319933203332113322333247332873328933301333113331733329333313334333347333493335333359333773339133403334093341333427334573346133469334793348733493335033352133529335333354733563335693357733581335873358933599336013361333617336193362333629336373364133647336793370333713337213373933749337513375733767337693377333791337973380933811338273382933851338573386333871338893389333911339233393133937339413396133967339973401934031340333403934057340613412334127341293414134147341573415934171341833421134213342173423134253342593426134267342733428334297343013430334313343193432734337343513436134367343693438134403344213442934439344573446934471344833448734499345013451134513345193453734543345493458334589345913460334607346133463134649346513466734673346793468734693347033472134729347393474734757347593476334781348073481934841348433484734849348713487734883348973491334919349393494934961349633498135023350273505135053350593506935081350833508935099351073511135117351293514135149351533515935171352013522135227352513525735267352793528135291353113531735323353273533935353353633538135393354013540735419354233543735447354493546135491355073550935521355273553135533355373554335569355733559135593355973560335617356713567735729357313574735753357593577135797358013580335809358313583735839358513586335869358793589735899359113592335933359513596335969359773598335993359993600736011360133601736037360613606736073360833609736107361093613136137361513616136187361913620936217362293624136251362633626936277362933629936307363133631936341363433635336373363833638936433364513645736467364693647336479364933649736523365273652936541365513655936563365713658336587365993660736629366373664336653366713667736683366913669736709367133672136739367493676136767367793678136787367913679336809368213683336847368573687136877368873689936901369133691936923369293693136943369473697336979369973700337013370193702137039370493705737061370873709737117371233713937159371713718137189371993720137217372233724337253372733727737307373093731337321373373733937357373613736337369373793739737409374233744137447374633748337489374933750137507375113751737529375373754737549375613756737571375733757937589375913760737619376333764337649376573766337691376933769937717377473778137783377993781137813378313784737853378613787137879378893789737907379513795737963379673798737991379933799738011380393804738053380693808338113381193814938153381673817738183381893819738201382193823138237382393826138273382813828738299383033831738321383273832938333383513837138377383933843138447384493845338459384613850138543385573856138567385693859338603386093861138629386393865138653386693867138677386933869938707387113871338723387293873738747387493876738783387913880338821388333883938851388613886738873388913890338917389213892338933389533895938971389773899339019390233904139043390473907939089390973910339107391133911939133391393915739161391633918139191391993920939217392273922939233392393924139251392933930139313393173932339341393433935939367393713937339383393973940939419394393944339451394613949939503395093951139521395413955139563395693958139607396193962339631396593966739671396793970339709397193972739733397493976139769397793979139799398213982739829398393984139847398573986339869398773988339887399013992939937399533997139979399833998940009400134003140037400394006340087400934009940111401234012740129401514015340163401694017740189401934021340231402374024140253402774028340289403434035140357403614038740423404274042940433404594047140483404874049340499405074051940529405314054340559405774058340591405974060940627406374063940693406974069940709407394075140759407634077140787408014081340819408234082940841408474084940853408674087940883408974090340927409334093940949409614097340993410114101741023410394104741051410574107741081411134111741131411414114341149411614117741179411834118941201412034121341221412274123141233412434125741263412694128141299413334134141351413574138141387413894139941411414134144341453414674147941491415074151341519415214153941543415494157941593415974160341609416114161741621416274164141647416514165941669416814168741719417294173741759417614177141777418014180941813418434184941851418634187941887418934189741903419114192741941419474195341957419594196941981419834199942013420174201942023420434206142071420734208342089421014213142139421574216942179421814218742193421974220942221422234222742239422574228142283422934229942307423234233142337423494235942373423794239142397424034240742409424334243742443424514245742461424634246742473424874249142499425094253342557425694257142577425894261142641426434264942667426774268342689426974270142703427094271942727427374274342751427674277342787427934279742821428294283942841428534285942863428994290142923429294293742943429534296142967429794298943003430134301943037430494305143063430674309343103431174313343151431594317743189432014320743223432374326143271432834329143313433194332143331433914339743399434034341143427434414345143457434814348743499435174354143543435734357743579435914359743607436094361343627436334364943651436614366943691437114371743721437534375943777437814378343787437894379343801438534386743889438914391343933439434395143961439634396943973439874399143997440174402144027440294404144053440594407144087440894410144111441194412344129441314415944171441794418944201442034420744221442494425744263442674426944273442794428144293443514435744371443814438344389444174444944453444834449144497445014450744519445314453344537445434454944563445794458744617446214462344633446414464744651446574468344687446994470144711447294474144753447714477344777447894479744809448194483944843448514486744879448874489344909449174492744939449534495944963449714498344987450074501345053450614507745083451194512145127451314513745139451614517945181451914519745233452474525945263452814528945293453074531745319453294533745341453434536145377453894540345413454274543345439454814549145497455034552345533455414555345557455694558745589455994561345631456414565945667456734567745691456974570745737457514575745763457674577945817458214582345827458334584145853458634586945887458934594345949459534595945971459794598946021460274604946051460614607346091460934609946103461334614146147461534617146181461834618746199462194622946237462614627146273462794630146307463094632746337463494635146381463994641146439464414644746451464574647146477464894649946507465114652346549465594656746573465894659146601466194663346639466434664946663466794668146687466914670346723467274674746751467574676946771468074681146817468194682946831468534686146867468774688946901469194693346957469934699747017470414705147057470594708747093471114711947123471294713747143471474714947161471894720747221472374725147269472794728747293472974730347309473174733947351473534736347381473874738947407474174741947431474414745947491474974750147507475134752147527475334754347563475694758147591475994760947623476294763947653476574765947681476994770147711477134771747737477414774347777477794779147797478074780947819478374784347857478694788147903479114791747933479394794747951479634796947977479814801748023480294804948073480794809148109481194812148131481574816348179481874819348197482214823948247482594827148281482994831148313483374834148353483714838348397484074840948413484374844948463484734847948481484874849148497485234852748533485394854148563485714858948593486114861948623486474864948661486734867748679487314873348751487574876148767487794878148787487994880948817488214882348847488574885948869488714888348889489074894748953489734898948991490034900949019490314903349037490434905749069490814910349109491174912149123491394915749169491714917749193491994920149207492114922349253492614927749279492974930749331493334933949363493674936949391493934940949411494174942949433494514945949463494774948149499495234952949531495374954749549495594959749603496134962749633496394966349667496694968149697497114972749739497414974749757497834978749789498014980749811498234983149843498534987149877498914991949921499274993749939499434995749991499934999950021500235003350047500515005350069500775008750093501015011150119501235012950131501475015350159501775020750221502275023150261502635027350287502915031150321503295033350341503595036350377503835038750411504175042350441504595046150497505035051350527505395054350549505515058150587505915059350599506275064750651506715068350707507235074150753507675077350777507895082150833508395084950857508675087350891508935090950923509295095150957509695097150989509935100151031510435104751059510615107151109511315113351137511515115751169511935119751199512035121751229512395124151257512635128351287513075132951341513435134751349513615138351407514135141951421514275143151437514395144951461514735147951481514875150351511515175152151539515515156351577515815159351599516075161351631516375164751659516735167951683516915171351719517215174951767517695178751797518035181751827518295183951853518595186951871518935189951907519135192951941519495197151973519775199152009520215202752051520575206752069520815210352121521275214752153521635217752181521835218952201522235223752249522535225952267522895229152301523135232152361523635236952379523875239152433524535245752489525015251152517525295254152543525535256152567525715257952583526095262752631526395266752673526915269752709527115272152727527335274752757527695278352807528135281752837528595286152879528835288952901529035291952937529515295752963529675297352981529995300353017530475305153069530775308753089530935310153113531175312953147531495316153171531735318953197532015323153233532395326753269532795328153299533095332353327533535335953377533815340153407534115341953437534415345353479535035350753527535495355153569535915359353597536095361153617536235362953633536395365353657536815369353699537175371953731537595377353777537835379153813538195383153849538575386153881538875389153897538995391753923539275393953951539595398753993540015401154013540375404954059540835409154101541215413354139541515416354167541815419354217542515426954277542875429354311543195432354331543475436154367543715437754401544035440954413544195442154437544435444954469544935449754499545035451754521545395454154547545595456354577545815458354601546175462354629546315464754667546735467954709547135472154727547515476754773547795478754799548295483354851548695487754881549075491754919549415494954959549735497954983550015500955021550495505155057550615507355079551035510955117551275514755163551715520155207552135521755219552295524355249552595529155313553315533355337553395534355351553735538155399554115543955441554575546955487555015551155529555415554755579555895560355609556195562155631556335563955661556635566755673556815569155697557115571755721557335576355787557935579955807558135581755819558235582955837558435584955871558895589755901559035592155927559315593355949559675598755997560035600956039560415605356081560875609356099561015611356123561315614956167561715617956197562075620956237562395624956263562675626956299563115633356359563695637756383563935640156417564315643756443564535646756473564775647956489565015650356509565195652756531565335654356569565915659756599566115662956633566595666356671566815668756701567115671356731567375674756767567735677956783568075680956813568215682756843568575687356891568935689756909569115692156923569295694156951569575696356983569895699356999570375704157047570595707357077570895709757107571195713157139571435714957163571735717957191571935720357221572235724157251572595726957271572835728757301573295733157347573495736757373573835738957397574135742757457574675748757493575035752757529575575755957571575875759357601576375764157649576535766757679576895769757709577135771957727577315773757751577735778157787577915779357803578095782957839578475785357859578815789957901579175792357943579475797357977579915801358027580315804358049580575806158067580735809958109581115812958147581515815358169581715818958193581995820758211582175822958231582375824358271583095831358321583375836358367583695837958391583935840358411584175842758439584415845158453584775848158511585375854358549585675857358579586015860358613586315865758661586795868758693586995871158727587335874158757587635877158787587895883158889588975890158907589095891358921589375894358963589675897958991589975900959011590215902359029590515905359063590695907759083590935910759113591195912359141591495915959167591835919759207592095921959221592335923959243592635927359281593335934159351593575935959369593775938759393593995940759417594195944159443594475945359467594715947359497595095951359539595575956159567595815961159617596215962759629596515965959663596695967159693596995970759723597295974359747597535977159779597915979759809598335986359879598875992159929599515995759971599815999960013600176002960037600416007760083600896009160101601036010760127601336013960149601616016760169602096021760223602516025760259602716028960293603176033160337603436035360373603836039760413604276044360449604576049360497605096052160527605396058960601606076061160617606236063160637606476064960659606616067960689607036071960727607336073760757607616076360773607796079360811608216085960869608876088960899609016091360917609196092360937609436095360961610016100761027610316104361051610576109161099611216112961141611516115361169612116122361231612536126161283612916129761331613336133961343613576136361379613816140361409614176144161463614696147161483614876149361507615116151961543615476155361559615616158361603616096161361627616316163761643616516165761667616736168161687617036171761723617296175161757617816181361819618376184361861618716187961909619276193361949619616196761979619816198761991620036201162017620396204762053620576207162081620996211962129621316213762141621436217162189621916220162207622136221962233622736229762299623036231162323623276234762351623836240162417624236245962467624736247762483624976250162507625336253962549625636258162591625976260362617626276263362639626536265962683626876270162723627316274362753627616277362791628016281962827628516286162869628736289762903629216292762929629396296962971629816298362987629896302963031630596306763073630796309763103631136312763131631496317963197631996321163241632476327763281632996331163313633176333163337633476335363361633676337763389633916339763409634196342163439634436346363467634736348763493634996352163527635336354163559635776358763589635996360163607636116361763629636476364963659636676367163689636916369763703637096371963727637376374363761637736378163793637996380363809638236383963841638536385763863639016390763913639296394963977639976400764013640196403364037640636406764081640916410964123641516415364157641716418764189642176422364231642376427164279642836430164303643196432764333643736438164399644036443364439644516445364483644896449964513645536456764577645796459164601646096461364621646276463364661646636466764679646936470964717647476476364781647836479364811648176484964853648716487764879648916490164919649216492764937649516496964997650036501165027650296503365053650636507165089650996510165111651196512365129651416514765167651716517365179651836520365213652396525765267652696528765293653096532365327653536535765371653816539365407654136541965423654376544765449654796549765519655216553765539655436555165557655636557965581655876559965609656176562965633656476565165657656776568765699657016570765713657176571965729657316576165777657896580965827658316583765839658436585165867658816589965921659276592965951659576596365981659836599366029660376604166047660676607166083660896610366107661096613766161661696617366179661916622166239662716629366301663376634366347663596636166373663776638366403664136643166449664576646366467664916649966509665236652966533665416655366569665716658766593666016661766629666436665366683666976670166713667216673366739667496675166763667916679766809668216684166851668536686366877668836688966919669236693166943669476694966959669736697767003670216703367043670496705767061670736707967103671216712967139671416715367157671696718167187671896721167213672176721967231672476726167271672736728967307673396734367349673696739167399674096741167421674276742967433674476745367477674816748967493674996751167523675316753767547675596756767577675796758967601676076761967631676516767967699677096772367733677416775167757677596776367777677836778967801678076781967829678436785367867678836789167901679276793167933679396794367957679616796767979679876799368023680416805368059680716808768099681116811368141681476816168171682076820968213682196822768239682616827968281683116832968351683716838968399684376844368447684496847368477684836848968491685016850768521685316853968543685676858168597686116863368639686596866968683686876869968711687136872968737687436874968767687716877768791688136881968821688636887968881688916889768899689036890968917689276894768963689936900169011690196902969031690616906769073691096911969127691436914969151691636919169193691976920369221692336923969247692576925969263693136931769337693416937169379693836938969401694036942769431694396945769463694676947369481694916949369497694996953969557695936962369653696616967769691696976970969737697396976169763697676977969809698216982769829698336984769857698596987769899699116992969931699416995969991699977000170003700097001970039700517006170067700797009970111701177012170123701397014170157701637017770181701837019970201702077022370229702377024170249702717028970297703097031370321703277035170373703797038170393704237042970439704517045770459704817048770489705017050770529705377054970571705737058370589706077061970621706277063970657706637066770687707097071770729707537076970783707937082370841708437084970853708677087770879708917090170913709197092170937709497095170957709697097970981709917099770999710117102371039710597106971081710897111971129711437114771153711617116771171711917120971233712377124971257712617126371287712937131771327713297133371339713417134771353713597136371387713897139971411714137141971429714377144371453714717147371479714837150371527715377154971551715637156971593715977163371647716637167171693716997170771711717137171971741717617177771789718077180971821718377184371849718617186771879718817188771899719097191771933719417194771963719717198371987719937199972019720317204372047720537207372077720897209172101721037210972139721617216772169721737221172221722237222772229722517225372269722717227772287723077231372337723417235372367723797238372421724317246172467724697248172493724977250372533725477255172559725777261372617726237264372647726497266172671726737267972689727017270772719727277273372739727637276772797728177282372859728697287172883728897289372901729077291172923729317293772949729537295972973729777299773009730137301973037730397304373061730637307973091731217312773133731417318173189732377324373259732777329173303733097332773331733517336173363733697337973387734177342173433734537345973471734777348373517735237352973547735537356173571735837358973597736077360973613736377364373651736737367973681736937369973709737217372773751737577377173783738197382373847738497385973867738777388373897739077393973943739517396173973739997401774021740277404774051740717407774093740997410174131741437414974159741617416774177741897419774201742037420974219742317425774279742877429374297743117431774323743537435774363743777438174383744117441374419744417444974453744717448974507745097452174527745317455174561745677457374587745977460974611746237465374687746997470774713747177471974729747317474774759747617477174779747977482174827748317484374857748617486974873748877489174897749037492374929749337494174959750117501375017750297503775041750797508375109751337514975161751677516975181751937520975211752177522375227752397525375269752777528975307753237532975337753477535375367753777538975391754017540375407754317543775479755037551175521755277553375539755417555375557755717557775583756117561775619756297564175653756597567975683756897570375707757097572175731757437576775773757817578775793757977582175833758537586975883759137593175937759417596775979759837598975991759977600176003760317603976079760817609176099761037612376129761477615776159761637620776213762317624376249762537625976261762837628976303763337634376367763697637976387764037642176423764417646376471764817648776493765077651176519765377654176543765617657976597766037660776631766497665176667766737667976697767177673376753767577677176777767817680176819768297683176837768477687176873768837690776913769197694376949769617696376991770037701777023770297704177047770697708177093771017713777141771537716777171771917720177213772377723977243772497726177263772677726977279772917731777323773397734777351773597736977377773837741777419774317744777471774777747977489774917750977513775217752777543775497755177557775637756977573775877759177611776177762177641776477765977681776877768977699777117771377719777237773177743777477776177773777837779777801778137783977849778637786777893778997792977933779517796977977779837799978007780177803178041780497805978079781017812178137781397815778163781677817378179781917819378203782297823378241782597827778283783017830778311783177834178347783677840178427784377843978467784797848778497785097851178517785397854178553785697857178577785837859378607786237864378649786537869178697787077871378721787377877978781787877879178797788037880978823788397885378857788777888778889788937890178919789297894178977789797898979031790397904379063790877910379111791337913979147791517915379159791817918779193792017922979231792417925979273792797928379301793097931979333793377934979357793677937979393793977939979411794237942779433794517948179493795317953779549795597956179579795897960179609796137962179627796317963379657796697968779691796937969779699797577976979777798017981179813798177982379829798417984379847798617986779873798897990179903799077993979943799677997379979799877999779999800218003980051800718007780107801118014180147801498015380167801738017780191802078020980221802318023380239802518026380273802798028780309803178032980341803478036380369803878040780429804478044980471804738048980491805138052780537805578056780599806038061180621806278062980651806578066980671806778068180683806878070180713807378074780749807618077780779807838078980803808098081980831808338084980863808978090980911809178092380929809338095380963809898100181013810178101981023810318104181043810478104981071810778108381097811018111981131811578116381173811818119781199812038122381233812398128181283812938129981307813318134381349813538135981371813738140181409814218143981457814638150981517815278153381547815518155381559815638156981611816198162981637816478164981667816718167781689817018170381707817278173781749817618176981773817998181781839818478185381869818838189981901819198192981931819378194381953819678197181973820038200782009820138202182031820378203982051820678207382129821398214182153821638217182183821898219382207822178221982223822318223782241822618226782279823018230782339823498235182361823738238782393824218245782463824698247182483824878249382499825078252982531825498255982561825678257182591826018260982613826198263382651826578269982721827238272782729827578275982763827818278782793827998281182813828378284782883828898289182903829138293982963829818299783003830098302383047830598306383071830778308983093831018311783137831778320383207832198322183227832318323383243832578326783269832738329983311833398334183357833838338983399834018340783417834238343183437834438344983459834718347783497835378355783561835638357983591835978360983617836218363983641836538366383689837018371783719837378376183773837778379183813838338384383857838698387383891839038391183921839338393983969839838398784011840178404784053840598406184067840898412184127841318413784143841638417984181841918419984211842218422384229842398424784263842998430784313843178431984347843498437784389843918440184407844218443184437844438444984457844638446784481844998450384509845218452384533845518455984589846298463184649846538465984673846918469784701847138471984731847378475184761847878479384809848118482784857848598486984871849138491984947849618496784977849798499185009850218502785037850498506185081850878509185093851038510985121851338514785159851938519985201852138522385229852378524385247852598529785303853138533185333853618536385369853818541185427854298543985447854518545385469854878551385517855238553185549855718557785597856018560785619856218562785639856438566185667856698569185703857118571785733857518578185793858178581985829858318583785843858478585385889859038590985931859338599185999860118601786027860298606986077860838611186113861178613186137861438616186171861798618386197862018620986239862438624986257862638626986287862918629386297863118632386341863518635386357863698637186381863898639986413864238644186453864618646786477864918650186509865318653386539865618657386579865878659986627866298667786689866938671186719867298674386753867678677186783868138683786843868518685786861868698692386927869298693986951869598696986981869938701187013870378704187049870718708387103871078711987121871338714987151871798718187187872118722187223872518725387257872778728187293872998731387317873238733787359873838740387407874218742787433874438747387481874918750987511875178752387539875418754787553875578755987583875878758987613876238762987631876418764387649876718767987683876918769787701877198772187739877438775187767877938779787803878118783387853878698787787881878878791187917879318794387959879618797387977879918800188003880078801988037880698807988093881178812988169881778821188223882378824188259882618828988301883218832788337883398837988397884118842388427884638846988471884938849988513885238854788589885918860788609886438865188657886618866388667886818872188729887418874788771887898879388799888018880788811888138881788819888438885388861888678887388883888978890388919889378895188969889938899789003890098901789021890418905189057890698907189083890878910189107891138911989123891378915389189892038920989213892278923189237892618926989273892938930389317893298936389371893818938789393893998941389417894318944389449894598947789491895018951389519895218952789533895618956389567895918959789599896038961189627896338965389657896598966989671896818968989753897598976789779897838979789809898198982189833898398984989867898918989789899899098991789923899398995989963899778998389989900019000790011900179001990023900319005390059900679007190073900899010790121901279014990163901739018790191901979019990203902179022790239902479026390271902819028990313903539035990371903739037990397904019040390407904379043990469904739048190499905119052390527905299053390547905839059990617906199063190641906479065990677906799069790703907099073190749907879079390803908219082390833908419084790863908879090190907909119091790931909479097190977909899099791009910199103391079910819109791099911219112791129911399114191151911539115991163911839119391199912299123791243912499125391283912919129791303913099133191367913699137391381913879139391397914119142391433914539145791459914639149391499915139152991541915719157391577915839159191621916319163991673916919170391711917339175391757917719178191801918079181191813918239183791841918679187391909919219193991943919519195791961919679196991997920039200992033920419205192077920839210792111921199214392153921739217792179921899220392219922219222792233922379224392251922699229792311923179233392347923539235792363923699237792381923839238792399924019241392419924319245992461924679247992489925039250792551925579256792569925819259392623926279263992641926479265792669926719268192683926939269992707927179272392737927539276192767927799278992791928019280992821928319284992857928619286392867928939289992921929279294192951929579295992987929939300193047930539305993077930839308993097931039311393131931339313993151931699317993187931999322993239932419325193253932579326393281932839328793307933199332393329933379337193377933839340793419934279346393479934819348793491934939349793503935239352993553935579355993563935819360193607936299363793683937019370393719937399376193763937879380993811938279385193871938879388993893939019391193913939239393793941939499396793971939799398393997940079400994033940499405794063940799409994109941119411794121941519415394169942019420794219942299425394261942739429194307943099432194327943319434394349943519437994397943999442194427944339443994441944479446394477944839451394529945319454194543945479455994561945739458394597946039461394621946499465194687946939470994723947279474794771947779478194789947939481194819948239483794841948479484994873948899490394907949339494994951949619499394999950039500995021950279506395071950839508795089950939510195107951119513195143951539517795189951919520395213952199523195233952399525795261952679527395279952879531195317953279533995369953839539395401954139541995429954419544395461954679547195479954839550795527955319553995549955619556995581955979560395617956219562995633956519570195707957139571795723957319573795747957739578395789957919580195803958139581995857958699587395881958919591195917959239592995947959579595995971959879598996001960139601796043960539605996079960979613796149961579616796179961819619996211962219622396233962599626396269962819628996293963239632996331963379635396377964019641996431964439645196457964619646996479964879649396497965179652796553965579658196587965899660196643966619666796671966979670396731967379673996749967579676396769967799678796797967999682196823968279684796851968579689396907969119693196953969599697396979969899699797001970039700797021970399707397081971039711797127971519715797159971699717197177971879721397231972419725997283973019730397327973679736997373973799738197387973979742397429974419745397459974639749997501975119752397547975499755397561975719757797579975839760797609976139764997651976739768797711977299777197777977879778997813978299784197843978479784997859978619787197879978839791997927979319794397961979679797397987980099801198017980419804798057980819810198123981299814398179982079821398221982279825198257982699829798299983179832198323983279834798369983779838798389984079841198419984299844398453984599846798473984799849198507985199853398543985619856398573985979862198627986399864198663986699868998711987139871798729987319873798773987799880198807988099883798849988679886998873988879889398897988999890998911989279892998939989479895398963989819899398999990139901799023990419905399079990839908999103991099911999131991339913799139991499917399181991919922399233992419925199257992599927799289993179934799349993679937199377993919939799401994099943199439994699948799497995239952799529995519955999563995719957799581996079961199623996439966199667996799968999707997099971399719997219973399761997679978799793998099981799823998299983399839998599987199877998819990199907999239992999961999719998999991100003100019100043100049100057100069100103100109100129100151100153100169100183100189100193100207100213100237100267100271100279100291100297100313100333100343100357100361100363100379100391100393100403100411100417100447100459100469100483100493100501100511100517100519100523100537100547100549100559100591100609100613100621100649100669100673100693100699100703100733100741100747100769100787100799100801100811100823100829100847100853100907100913100927100931100937100943100957100981100987100999101009101021101027101051101063101081101089101107101111101113101117101119101141101149101159101161101173101183101197101203101207101209101221101267101273101279101281101287101293101323101333101341101347101359101363101377101383101399101411101419101429101449101467101477101483101489101501101503101513101527101531101533101537101561101573101581101599101603101611101627101641101653101663101681101693101701101719101723101737101741101747101749101771101789101797101807101833101837101839101863101869101873101879101891101917101921101929101939101957101963101977101987101999102001102013102019102023102031102043102059102061102071102077102079102101102103102107102121102139102149102161102181102191102197102199102203102217102229102233102241102251102253102259102293102299102301102317102329102337102359102367102397102407102409102433102437102451102461102481102497102499102503102523102533102539102547102551102559102563102587102593102607102611102643102647102653102667102673102677102679102701102761102763102769102793102797102811102829102841102859102871102877102881102911102913102929102931102953102967102983103001103007103043103049103067103069103079103087103091103093103099103123103141103171103177103183103217103231103237103289103291103307103319103333103349103357103387103391103393103399103409103421103423103451103457103471103483103511103529103549103553103561103567103573103577103583103591103613103619103643103651103657103669103681103687103699103703103723103769103787103801103811103813103837103841103843103867103889103903103913103919103951103963103967103969103979103981103991103993103997104003104009104021104033104047104053104059104087104089104107104113104119104123104147104149104161104173104179104183104207104231104233104239104243104281104287104297104309104311104323104327104347104369104381104383104393104399104417104459104471104473104479104491104513104527104537104543104549104551104561104579104593104597104623104639104651104659104677104681104683104693104701104707104711104717104723104729104743104759104761104773104779104789104801104803104827104831104849104851104869104879104891104911104917104933104947104953104959104971104987104999105019105023105031105037105071105097105107105137105143105167105173105199105211105227105229105239105251105253105263105269105277105319105323105331105337105341105359105361105367105373105379105389105397105401105407105437105449105467105491105499105503105509105517105527105529105533105541105557105563105601105607105613105619105649105653105667105673105683105691105701105727105733105751105761105767105769105817105829105863105871105883105899105907105913105929105943105953105967105971105977105983105997106013106019106031106033106087106103106109106121106123106129106163106181106187106189106207106213106217106219106243106261106273106277106279106291106297106303106307106319106321106331106349106357106363106367106373106391106397106411106417106427106433106441106451106453106487106501106531106537106541106543106591106619106621106627106637106649106657106661106663106669106681106693106699106703106721106727106739106747106751106753106759106781106783106787106801106823106853106859106861106867106871106877106903106907106921106937106949106957106961106963106979106993107021107033107053107057107069107071107077107089107099107101107119107123107137107171107183107197107201107209107227107243107251107269107273107279107309107323107339107347107351107357107377107441107449107453107467107473107507107509107563107581107599107603107609107621107641107647107671107687107693107699107713107717107719107741107747107761107773107777107791107827107837107839107843107857107867107873107881107897107903107923107927107941107951107971107981107999108007108011108013108023108037108041108061108079108089108107108109108127108131108139108161108179108187108191108193108203108211108217108223108233108247108263108271108287108289108293108301108343108347108359108377108379108401108413108421108439108457108461108463108497108499108503108517108529108533108541108553108557108571108587108631108637108643108649108677108707108709108727108739108751108761108769108791108793108799108803108821108827108863108869108877108881108883108887108893108907108917108923108929108943108947108949108959108961108967108971108991109001109013109037109049109063109073109097109103109111109121109133109139109141109147109159109169109171109199109201109211109229109253109267109279109297109303109313109321109331109357109363109367109379109387109391109397109423109433109441109451109453109469109471109481109507109517109519109537109541109547109567109579109583109589109597109609109619109621109639109661109663109673109717109721109741109751109789109793109807109819109829109831109841109843109847109849109859109873109883109891109897109903109913109919109937109943109961109987110017110023110039110051110059110063110069110083110119110129110161110183110221110233110237110251110261110269110273110281110291110311110321110323110339110359110419110431110437110441110459110477110479110491110501110503110527110533110543110557110563110567110569110573110581110587110597110603110609110623110629110641110647110651110681110711110729110731110749110753110771110777110807110813110819110821110849110863110879110881110899110909110917110921110923110927110933110939110947110951110969110977110989111029111031111043111049111053111091111103111109111119111121111127111143111149111187111191111211111217111227111229111253111263111269111271111301111317111323111337111341111347111373111409111427111431111439111443111467111487111491111493111497111509111521111533111539111577111581111593111599111611111623111637111641111653111659111667111697111721111731111733111751111767111773111779111781111791111799111821111827111829111833111847111857111863111869111871111893111913111919111949111953111959111973111977111997112019112031112061112067112069112087112097112103112111112121112129112139112153112163112181112199112207112213112223112237112241112247112249112253112261112279112289112291112297112303112327112331112337112339112349112361112363112397112403112429112459112481112501112507112543112559112571112573112577112583112589112601112603112621112643112657112663112687112691112741112757112759112771112787112799112807112831112843112859112877112901112909112913112919112921112927112939112951112967112979112997113011113017113021113023113027113039113041113051113063113081113083113089113093113111113117113123113131113143113147113149113153113159113161113167113171113173113177113189113209113213113227113233113279113287113327113329113341113357113359113363113371113381113383113417113437113453113467113489113497113501113513113537113539113557113567113591113621113623113647113657113683113717113719113723113731113749113759113761113777113779113783113797113809113819113837113843113891113899113903113909113921113933113947113957113963113969113983113989114001114013114031114041114043114067114073114077114083114089114113114143114157114161114167114193114197114199114203114217114221114229114259114269114277114281114299114311114319114329114343114371114377114407114419114451114467114473114479114487114493114547114553114571114577114593114599114601114613114617114641114643114649114659114661114671114679114689114691114713114743114749114757114761114769114773114781114797114799114809114827114833114847114859114883114889114901114913114941114967114973114997115001115013115019115021115057115061115067115079115099115117115123115127115133115151115153115163115183115201115211115223115237115249115259115279115301115303115309115319115321115327115331115337115343115361115363115399115421115429115459115469115471115499115513115523115547115553115561115571115589115597115601115603115613115631115637115657115663115679115693115727115733115741115751115757115763115769115771115777115781115783115793115807115811115823115831115837115849115853115859115861115873115877115879115883115891115901115903115931115933115963115979115981115987116009116027116041116047116089116099116101116107116113116131116141116159116167116177116189116191116201116239116243116257116269116273116279116293116329116341116351116359116371116381116387116411116423116437116443116447116461116471116483116491116507116531116533116537116539116549116579116593116639116657116663116681116687116689116707116719116731116741116747116789116791116797116803116819116827116833116849116867116881116903116911116923116927116929116933116953116959116969116981116989116993117017117023117037117041117043117053117071117101117109117119117127117133117163117167117191117193117203117209117223117239117241117251117259117269117281117307117319117329117331117353117361117371117373117389117413117427117431117437117443117497117499117503117511117517117529117539117541117563117571117577117617117619117643117659117671117673117679117701117703117709117721117727117731117751117757117763117773117779117787117797117809117811117833117839117841117851117877117881117883117889117899117911117917117937117959117973117977117979117989117991118033118037118043118051118057118061118081118093118127118147118163118169118171118189118211118213118219118247118249118253118259118273118277118297118343118361118369118373118387118399118409118411118423118429118453118457118463118471118493118529118543118549118571118583118589118603118619118621118633118661118669118673118681118687118691118709118717118739118747118751118757118787118799118801118819118831118843118861118873118891118897118901118903118907118913118927118931118967118973119027119033119039119047119057119069119083119087119089119099119101119107119129119131119159119173119179119183119191119227119233119237119243119267119291119293119297119299119311119321119359119363119389119417119419119429119447119489119503119513119533119549119551119557119563119569119591119611119617119627119633119653119657119659119671119677119687119689119699119701119723119737119747119759119771119773119783119797119809119813119827119831119839119849119851119869119881119891119921119923119929119953119963119971119981119983119993120011120017120041120047120049120067120077120079120091120097120103120121120157120163120167120181120193120199120209120223120233120247120277120283120293120299120319120331120349120371120383120391120397120401120413120427120431120473120503120511120539120551120557120563120569120577120587120607120619120623120641120647120661120671120677120689120691120709120713120721120737120739120749120763120767120779120811120817120823120829120833120847120851120863120871120877120889120899120907120917120919120929120937120941120943120947120977120997121001121007121013121019121021121039121061121063121067121081121123121139121151121157121169121171121181121189121229121259121267121271121283121291121309121313121321121327121333121343121349121351121357121367121369121379121403121421121439121441121447121453121469121487121493121501121507121523121531121547121553121559121571121577121579121591121607121609121621121631121633121637121661121687121697121711121721121727121763121787121789121843121853121867121883121889121909121921121931121937121949121951121963121967121993121997122011122021122027122029122033122039122041122051122053122069122081122099122117122131122147122149122167122173122201122203122207122209122219122231122251122263122267122273122279122299122321122323122327122347122363122387122389122393122399122401122443122449122453122471122477122489122497122501122503122509122527122533122557122561122579122597122599122609122611122651122653122663122693122701122719122741122743122753122761122777122789122819122827122833122839122849122861122867122869122887122891122921122929122939122953122957122963122971123001123007123017123031123049123059123077123083123091123113123121123127123143123169123191123203123209123217123229123239123259123269123289123307123311123323123341123373123377123379123397123401123407123419123427123433123439123449123457123479123491123493123499123503123517123527123547123551123553123581123583123593123601123619123631123637123653123661123667123677123701123707123719123727123731123733123737123757123787123791123803123817123821123829123833123853123863123887123911123923123931123941123953123973123979123983123989123997124001124021124067124087124097124121124123124133124139124147124153124171124181124183124193124199124213124231124247124249124277124291124297124301124303124309124337124339124343124349124351124363124367124427124429124433124447124459124471124477124489124493124513124529124541124543124561124567124577124601124633124643124669124673124679124693124699124703124717124721124739124753124759124769124771124777124781124783124793124799124819124823124847124853124897124907124909124919124951124979124981124987124991125003125017125029125053125063125093125101125107125113125117125119125131125141125149125183125197125201125207125219125221125231125243125261125269125287125299125303125311125329125339125353125371125383125387125399125407125423125429125441125453125471125497125507125509125527125539125551125591125597125617125621125627125639125641125651125659125669125683125687125693125707125711125717125731125737125743125753125777125789125791125803125813125821125863125887125897125899125921125927125929125933125941125959125963126001126011126013126019126023126031126037126041126047126067126079126097126107126127126131126143126151126173126199126211126223126227126229126233126241126257126271126307126311126317126323126337126341126349126359126397126421126433126443126457126461126473126481126487126491126493126499126517126541126547126551126583126601126611126613126631126641126653126683126691126703126713126719126733126739126743126751126757126761126781126823126827126839126851126857126859126913126923126943126949126961126967126989127031127033127037127051127079127081127103127123127133127139127157127163127189127207127217127219127241127247127249127261127271127277127289127291127297127301127321127331127343127363127373127399127403127423127447127453127481127487127493127507127529127541127549127579127583127591127597127601127607127609127637127643127649127657127663127669127679127681127691127703127709127711127717127727127733127739127747127763127781127807127817127819127837127843127849127859127867127873127877127913127921127931127951127973127979127997128021128033128047128053128099128111128113128119128147128153128159128173128189128201128203128213128221128237128239128257128273128287128291128311128321128327128339128341128347128351128377128389128393128399128411128413128431128437128449128461128467128473128477128483128489128509128519128521128549128551128563128591128599128603128621128629128657128659128663128669128677128683128693128717128747128749128761128767128813128819128831128833128837128857128861128873128879128903128923128939128941128951128959128969128971128981128983128987128993129001129011129023129037129049129061129083129089129097129113129119129121129127129169129187129193129197129209129221129223129229129263129277129281129287129289129293129313129341129347129361129379129401129403129419129439129443129449129457129461129469129491129497129499129509129517129527129529129533129539129553129581129587129589129593129607129629129631129641129643129671129707129719129733129737129749129757129763129769129793129803129841129853129887129893129901129917129919129937129953129959129967129971130003130021130027130043130051130057130069130073130079130087130099130121130127130147130171130183130199130201130211130223130241130253130259130261130267130279130303130307130337130343130349130363130367130369130379130399130409130411130423130439130447130457130469130477130483130489130513130517130523130531130547130553130579130589130619130621130631130633130639130643130649130651130657130681130687130693130699130729130769130783130787130807130811130817130829130841130843130859130873130927130957130969130973130981130987131009131011131023131041131059131063131071131101131111131113131129131143131149131171131203131213131221131231131249131251131267131293131297131303131311131317131321131357131363131371131381131413131431131437131441131447131449131477131479131489131497131501131507131519131543131561131581131591131611131617131627131639131641131671131687131701131707131711131713131731131743131749131759131771131777131779131783131797131837131839131849131861131891131893131899131909131927131933131939131941131947131959131969132001132019132047132049132059132071132103132109132113132137132151132157132169132173132199132229132233132241132247132257132263132283132287132299132313132329132331132347132361132367132371132383132403132409132421132437132439132469132491132499132511132523132527132529132533132541132547132589132607132611132619132623132631132637132647132661132667132679132689132697132701132707132709132721132739132749132751132757132761132763132817132833132851132857132859132863132887132893132911132929132947132949132953132961132967132971132989133013133033133039133051133069133073133087133097133103133109133117133121133153133157133169133183133187133201133213133241133253133261133271133277133279133283133303133319133321133327133337133349133351133379133387133391133403133417133439133447133451133481133493133499133519133541133543133559133571133583133597133631133633133649133657133669133673133691133697133709133711133717133723133733133769133781133801133811133813133831133843133853133873133877133919133949133963133967133979133981133993133999134033134039134047134053134059134077134081134087134089134093134129134153134161134171134177134191134207134213134219134227134243134257134263134269134287134291134293134327134333134339134341134353134359134363134369134371134399134401134417134437134443134471134489134503134507134513134581134587134591134593134597134609134639134669134677134681134683134699134707134731134741134753134777134789134807134837134839134851134857134867134873134887134909134917134921134923134947134951134989134999135007135017135019135029135043135049135059135077135089135101135119135131135151135173135181135193135197135209135211135221135241135257135271135277135281135283135301135319135329135347135349135353135367135389135391135403135409135427135431135433135449135461135463135467135469135479135497135511135533135559135571135581135589135593135599135601135607135613135617135623135637135647135649135661135671135697135701135719135721135727135731135743135757135781135787135799135829135841135851135859135887135893135899135911135913135929135937135977135979136013136027136033136043136057136067136069136093136099136111136133136139136163136177136189136193136207136217136223136237136247136261136273136277136303136309136319136327136333136337136343136351136361136373136379136393136397136399136403136417136421136429136447136453136463136471136481136483136501136511136519136523136531136537136541136547136559136573136601136603136607136621136649136651136657136691136693136709136711136727136733136739136751136753136769136777136811136813136841136849136859136861136879136883136889136897136943136949136951136963136973136979136987136991136993136999137029137077137087137089137117137119137131137143137147137153137177137183137191137197137201137209137219137239137251137273137279137303137321137339137341137353137359137363137369137383137387137393137399137413137437137443137447137453137477137483137491137507137519137537137567137573137587137593137597137623137633137639137653137659137699137707137713137723137737137743137771137777137791137803137827137831137849137867137869137873137909137911137927137933137941137947137957137983137993137999138007138041138053138059138071138077138079138101138107138113138139138143138157138163138179138181138191138197138209138239138241138247138251138283138289138311138319138323138337138349138371138373138389138401138403138407138427138433138449138451138461138469138493138497138511138517138547138559138563138569138571138577138581138587138599138617138629138637138641138647138661138679138683138727138731138739138763138793138797138799138821138829138841138863138869138883138889138893138899138917138923138937138959138967138977139021139033139067139079139091139109139121139123139133139169139177139187139199139201139241139267139273139291139297139301139303139309139313139333139339139343139361139367139369139387139393139397139409139423139429139439139457139459139483139487139493139501139511139537139547139571139589139591139597139609139619139627139661139663139681139697139703139709139721139729139739139747139753139759139787139801139813139831139837139861139871139883139891139901139907139921139939139943139967139969139981139987139991139999140009140053140057140069140071140111140123140143140159140167140171140177140191140197140207140221140227140237140249140263140269140281140297140317140321140333140339140351140363140381140401140407140411140417140419140423140443140449140453140473140477140521140527140533140549140551140557140587140593140603140611140617140627140629140639140659140663140677140681140683140689140717140729140731140741140759140761140773140779140797140813140827140831140837140839140863140867140869140891140893140897140909140929140939140977140983140989141023141041141061141067141073141079141101141107141121141131141157141161141179141181141199141209141221141223141233141241141257141263141269141277141283141301141307141311141319141353141359141371141397141403141413141439141443141461141481141497141499141509141511141529141539141551141587141601141613141619141623141629141637141649141653141667141671141677141679141689141697141707141709141719141731141761141767141769141773141793141803141811141829141833141851141853141863141871141907141917141931141937141941141959141961141971141991142007142019142031142039142049142057142061142067142097142099142111142123142151142157142159142169142183142189142193142211142217142223142231142237142271142297142319142327142357142369142381142391142403142421142427142433142453142469142501142529142537142543142547142553142559142567142573142589142591142601142607142609142619142657142673142697142699142711142733142757142759142771142787142789142799142811142837142841142867142871142873142897142903142907142939142949142963142969142973142979142981142993143053143063143093143107143111143113143137143141143159143177143197143239143243143249143257143261143263143281143287143291143329143333143357143387143401143413143419143443143461143467143477143483143489143501143503143509143513143519143527143537143551143567143569143573143593143609143617143629143651143653143669143677143687143699143711143719143729143743143779143791143797143807143813143821143827143831143833143873143879143881143909143947143953143971143977143981143999144013144031144037144061144071144073144103144139144161144163144167144169144173144203144223144241144247144253144259144271144289144299144307144311144323144341144349144379144383144407144409144413144427144439144451144461144479144481144497144511144539144541144563144569144577144583144589144593144611144629144659144667144671144701144709144719144731144737144751144757144763144773144779144791144817144829144839144847144883144887144889144899144917144931144941144961144967144973144983145007145009145021145031145037145043145063145069145091145109145121145133145139145177145193145207145213145219145253145259145267145283145289145303145307145349145361145381145391145399145417145423145433145441145451145459145463145471145477145487145501145511145513145517145531145543145547145549145577145589145601145603145633145637145643145661145679145681145687145703145709145721145723145753145757145759145771145777145799145807145819145823145829145861145879145897145903145931145933145949145963145967145969145987145991146009146011146021146023146033146051146057146059146063146077146093146099146117146141146161146173146191146197146203146213146221146239146249146273146291146297146299146309146317146323146347146359146369146381146383146389146407146417146423146437146449146477146513146519146521146527146539146543146563146581146603146609146617146639146647146669146677146681146683146701146719146743146749146767146777146801146807146819146833146837146843146849146857146891146893146917146921146933146941146953146977146983146987146989147011147029147031147047147073147083147089147097147107147137147139147151147163147179147197147209147211147221147227147229147253147263147283147289147293147299147311147319147331147341147347147353147377147391147397147401147409147419147449147451147457147481147487147503147517147541147547147551147557147571147583147607147613147617147629147647147661147671147673147689147703147709147727147739147743147761147769147773147779147787147793147799147811147827147853147859147863147881147919147937147949147977147997148013148021148061148063148073148079148091148123148139148147148151148153148157148171148193148199148201148207148229148243148249148279148301148303148331148339148361148367148381148387148399148403148411148429148439148457148469148471148483148501148513148517148531148537148549148573148579148609148627148633148639148663148667148669148691148693148711148721148723148727148747148763148781148783148793148817148829148853148859148861148867148873148891148913148921148927148931148933148949148957148961148991148997149011149021149027149033149053149057149059149069149077149087149099149101149111149113149119149143149153149159149161149173149183149197149213149239149249149251149257149269149287149297149309149323149333149341149351149371149377149381149393149399149411149417149419149423149441149459149489149491149497149503149519149521149531149533149543149551149561149563149579149603149623149627149629149689149711149713149717149729149731149749149759149767149771149791149803149827149837149839149861149867149873149893149899149909149911149921149939149953149969149971149993150001150011150041150053150061150067150077150083150089150091150097150107150131150151150169150193150197150203150209150211150217150221150223150239150247150287150299150301150323150329150343150373150377150379150383150401150407150413150427150431150439150473150497150503150517150523150533150551150559150571150583150587150589150607150611150617150649150659150697150707150721150743150767150769150779150791150797150827150833150847150869150881150883150889150893150901150907150919150929150959150961150967150979150989150991151007151009151013151027151049151051151057151091151121151141151153151157151163151169151171151189151201151213151237151241151243151247151253151273151279151289151303151337151339151343151357151379151381151391151397151423151429151433151451151471151477151483151499151507151517151523151531151537151549151553151561151573151579151597151603151607151609151631151637151643151651151667151673151681151687151693151703151717151729151733151769151771151783151787151799151813151817151841151847151849151871151883151897151901151903151909151937151939151967151969152003152017152027152029152039152041152063152077152081152083152093152111152123152147152183152189152197152203152213152219152231152239152249152267152287152293152297152311152363152377152381152389152393152407152417152419152423152429152441152443152459152461152501152519152531152533152539152563152567152597152599152617152623152629152639152641152657152671152681152717152723152729152753152767152777152783152791152809152819152821152833152837152839152843152851152857152879152897152899152909152939152941152947152953152959152981152989152993153001153059153067153071153073153077153089153107153113153133153137153151153191153247153259153269153271153277153281153287153313153319153337153343153353153359153371153379153407153409153421153427153437153443153449153457153469153487153499153509153511153521153523153529153533153557153563153589153607153611153623153641153649153689153701153719153733153739153743153749153757153763153817153841153871153877153887153889153911153913153929153941153947153949153953153991153997154001154027154043154057154061154067154073154079154081154087154097154111154127154153154157154159154181154183154211154213154229154243154247154267154277154279154291154303154313154321154333154339154351154369154373154387154409154417154423154439154459154487154493154501154523154543154571154573154579154589154591154613154619154621154643154667154669154681154691154699154723154727154733154747154753154769154787154789154799154807154823154841154849154871154873154877154883154897154927154933154937154943154981154991155003155009155017155027155047155069155081155083155087155119155137155153155161155167155171155191155201155203155209155219155231155251155269155291155299155303155317155327155333155371155377155381155383155387155399155413155423155443155453155461155473155501155509155521155537155539155557155569155579155581155593155599155609155621155627155653155657155663155671155689155693155699155707155717155719155723155731155741155747155773155777155783155797155801155809155821155833155849155851155861155863155887155891155893155921156007156011156019156041156059156061156071156089156109156119156127156131156139156151156157156217156227156229156241156253156257156259156269156307156319156329156347156353156361156371156419156421156437156467156487156491156493156511156521156539156577156589156593156601156619156623156631156641156659156671156677156679156683156691156703156707156719156727156733156749156781156797156799156817156823156833156841156887156899156901156913156941156943156967156971156979157007157013157019157037157049157051157057157061157081157103157109157127157133157141157163157177157181157189157207157211157217157219157229157231157243157247157253157259157271157273157277157279157291157303157307157321157327157349157351157363157393157411157427157429157433157457157477157483157489157513157519157523157543157559157561157571157579157627157637157639157649157667157669157679157721157733157739157747157769157771157793157799157813157823157831157837157841157867157877157889157897157901157907157931157933157951157991157999158003158009158017158029158047158071158077158113158129158141158143158161158189158201158209158227158231158233158243158261158269158293158303158329158341158351158357158359158363158371158393158407158419158429158443158449158489158507158519158527158537158551158563158567158573158581158591158597158611158617158621158633158647158657158663158699158731158747158749158759158761158771158777158791158803158843158849158863158867158881158909158923158927158941158959158981158993159013159017159023159059159073159079159097159113159119159157159161159167159169159179159191159193159199159209159223159227159233159287159293159311159319159337159347159349159361159389159403159407159421159431159437159457159463159469159473159491159499159503159521159539159541159553159563159569159571159589159617159623159629159631159667159671159673159683159697159701159707159721159737159739159763159769159773159779159787159791159793159799159811159833159839159853159857159869159871159899159911159931159937159977159979160001160009160019160031160033160049160073160079160081160087160091160093160117160141160159160163160169160183160201160207160217160231160243160253160309160313160319160343160357160367160373160387160397160403160409160423160441160453160481160483160499160507160541160553160579160583160591160603160619160621160627160637160639160649160651160663160669160681160687160697160709160711160723160739160751160753160757160781160789160807160813160817160829160841160861160877160879160883160903160907160933160967160969160981160997161009161017161033161039161047161053161059161071161087161093161123161137161141161149161159161167161201161221161233161237161263161267161281161303161309161323161333161339161341161363161377161387161407161411161453161459161461161471161503161507161521161527161531161543161561161563161569161573161591161599161611161627161639161641161659161683161717161729161731161741161743161753161761161771161773161779161783161807161831161839161869161873161879161881161911161921161923161947161957161969161971161977161983161999162007162011162017162053162059162079162091162109162119162143162209162221162229162251162257162263162269162277162287162289162293162343162359162389162391162413162419162439162451162457162473162493162499162517162523162527162529162553162557162563162577162593162601162611162623162629162641162649162671162677162683162691162703162709162713162727162731162739162749162751162779162787162791162821162823162829162839162847162853162859162881162889162901162907162917162937162947162971162973162989162997163003163019163021163027163061163063163109163117163127163129163147163151163169163171163181163193163199163211163223163243163249163259163307163309163321163327163337163351163363163367163393163403163409163411163417163433163469163477163481163483163487163517163543163561163567163573163601163613163621163627163633163637163643163661163673163679163697163729163733163741163753163771163781163789163811163819163841163847163853163859163861163871163883163901163909163927163973163979163981163987163991163993163997164011164023164039164051164057164071164089164093164113164117164147164149164173164183164191164201164209164231164233164239164249164251164267164279164291164299164309164321164341164357164363164371164377164387164413164419164429164431164443164447164449164471164477164503164513164531164569164581164587164599164617164621164623164627164653164663164677164683164701164707164729164743164767164771164789164809164821164831164837164839164881164893164911164953164963164987164999165001165037165041165047165049165059165079165083165089165103165133165161165173165181165203165211165229165233165247165287165293165311165313165317165331165343165349165367165379165383165391165397165437165443165449165457165463165469165479165511165523165527165533165541165551165553165559165569165587165589165601165611165617165653165667165673165701165703165707165709165713165719165721165749165779165799165811165817165829165833165857165877165883165887165901165931165941165947165961165983166013166021166027166031166043166063166081166099166147166151166157166169166183166189166207166219166237166247166259166273166289166297166301166303166319166349166351166357166363166393166399166403166409166417166429166457166471166487166541166561166567166571166597166601166603166609166613166619166627166631166643166657166667166669166679166693166703166723166739166741166781166783166799166807166823166841166843166847166849166853166861166867166871166909166919166931166949166967166973166979166987167009167017167021167023167033167039167047167051167071167077167081167087167099167107167113167117167119167149167159167173167177167191167197167213167221167249167261167267167269167309167311167317167329167339167341167381167393167407167413167423167429167437167441167443167449167471167483167491167521167537167543167593167597167611167621167623167627167633167641167663167677167683167711167729167747167759167771167777167779167801167809167861167863167873167879167887167891167899167911167917167953167971167987168013168023168029168037168043168067168071168083168089168109168127168143168151168193168197168211168227168247168253168263168269168277168281168293168323168331168347168353168391168409168433168449168451168457168463168481168491168499168523168527168533168541168559168599168601168617168629168631168643168673168677168697168713168719168731168737168743168761168769168781168803168851168863168869168887168893168899168901168913168937168943168977168991169003169007169009169019169049169063169067169069169079169093169097169111169129169151169159169177169181169199169217169219169241169243169249169259169283169307169313169319169321169327169339169343169361169369169373169399169409169427169457169471169483169489169493169501169523169531169553169567169583169591169607169627169633169639169649169657169661169667169681169691169693169709169733169751169753169769169777169783169789169817169823169831169837169843169859169889169891169909169913169919169933169937169943169951169957169987169991170003170021170029170047170057170063170081170099170101170111170123170141170167170179170189170197170207170213170227170231170239170243170249170263170267170279170293170299170327170341170347170351170353170363170369170371170383170389170393170413170441170447170473170483170497170503170509170537170539170551170557170579170603170609170627170633170641170647170669170689170701170707170711170741170749170759170761170767170773170777170801170809170813170827170837170843170851170857170873170881170887170899170921170927170953170957170971171007171023171029171043171047171049171053171077171079171091171103171131171161171163171167171169171179171203171233171251171253171263171271171293171299171317171329171341171383171401171403171427171439171449171467171469171473171481171491171517171529171539171541171553171559171571171583171617171629171637171641171653171659171671171673171679171697171707171713171719171733171757171761171763171793171799171803171811171823171827171851171863171869171877171881171889171917171923171929171937171947172001172009172021172027172031172049172069172079172093172097172127172147172153172157172169172171172181172199172213172217172219172223172243172259172279172283172297172307172313172321172331172343172351172357172373172399172411172421172423172427172433172439172441172489172507172517172519172541172553172561172573172583172589172597172603172607172619172633172643172649172657172663172673172681172687172709172717172721172741172751172759172787172801172807172829172849172853172859172867172871172877172883172933172969172973172981172987172993172999173021173023173039173053173059173081173087173099173137173141173149173177173183173189173191173207173209173219173249173263173267173273173291173293173297173309173347173357173359173429173431173473173483173491173497173501173531173539173543173549173561173573173599173617173629173647173651173659173669173671173683173687173699173707173713173729173741173743173773173777173779173783173807173819173827173839173851173861173867173891173897173909173917173923173933173969173977173981173993174007174017174019174047174049174061174067174071174077174079174091174101174121174137174143174149174157174169174197174221174241174257174259174263174281174289174299174311174329174331174337174347174367174389174407174413174431174443174457174467174469174481174487174491174527174533174569174571174583174599174613174617174631174637174649174653174659174673174679174703174721174737174749174761174763174767174773174799174821174829174851174859174877174893174901174907174917174929174931174943174959174989174991175003175013175039175061175067175069175079175081175103175129175141175211175229175261175267175277175291175303175309175327175333175349175361175391175393175403175411175433175447175453175463175481175493175499175519175523175543175573175601175621175631175633175649175663175673175687175691175699175709175723175727175753175757175759175781175783175811175829175837175843175853175859175873175891175897175909175919175937175939175949175961175963175979175991175993176017176021176023176041176047176051176053176063176081176087176089176123176129176153176159176161176179176191176201176207176213176221176227176237176243176261176299176303176317176321176327176329176333176347176353176357176369176383176389176401176413176417176419176431176459176461176467176489176497176503176507176509176521176531176537176549176551176557176573176591176597176599176609176611176629176641176651176677176699176711176713176741176747176753176777176779176789176791176797176807176809176819176849176857176887176899176903176921176923176927176933176951176977176983176989177007177011177013177019177043177091177101177109177113177127177131177167177173177209177211177217177223177239177257177269177283177301177319177323177337177347177379177383177409177421177427177431177433177467177473177481177487177493177511177533177539177553177589177601177623177647177677177679177691177739177743177761177763177787177791177797177811177823177839177841177883177887177889177893177907177913177917177929177943177949177953177967177979178001178021178037178039178067178069178091178093178103178117178127178141178151178169178183178187178207178223178231178247178249178259178261178289178301178307178327178333178349178351178361178393178397178403178417178439178441178447178469178481178487178489178501178513178531178537178559178561178567178571178597178601178603178609178613178621178627178639178643178681178691178693178697178753178757178781178793178799178807178813178817178819178831178853178859178873178877178889178897178903178907178909178921178931178933178939178951178973178987179021179029179033179041179051179057179083179089179099179107179111179119179143179161179167179173179203179209179213179233179243179261179269179281179287179317179321179327179351179357179369179381179383179393179407179411179429179437179441179453179461179471179479179483179497179519179527179533179549179563179573179579179581179591179593179603179623179633179651179657179659179671179687179689179693179717179719179737179743179749179779179801179807179813179819179821179827179833179849179897179899179903179909179917179923179939179947179951179953179957179969179981179989179999180001180007180023180043180053180071180073180077180097180137180161180179180181180211180221180233180239180241180247180259180263180281180287180289180307180311180317180331180337180347180361180371180379180391180413180419180437180463180473180491180497180503180511180533180539180541180547180563180569180617180623180629180647180667180679180701180731180749180751180773180779180793180797180799180811180847180871180883180907180949180959181001181003181019181031181039181061181063181081181087181123181141181157181183181193181199181201181211181213181219181243181253181273181277181283181297181301181303181361181387181397181399181409181421181439181457181459181499181501181513181523181537181549181553181603181607181609181619181639181667181669181693181711181717181721181729181739181751181757181759181763181777181787181789181813181837181871181873181889181891181903181913181919181927181931181943181957181967181981181997182009182011182027182029182041182047182057182059182089182099182101182107182111182123182129182131182141182159182167182177182179182201182209182233182239182243182261182279182297182309182333182339182341182353182387182389182417182423182431182443182453182467182471182473182489182503182509182519182537182549182561182579182587182593182599182603182617182627182639182641182653182657182659182681182687182701182711182713182747182773182779182789182803182813182821182839182851182857182867182887182893182899182921182927182929182933182953182957182969182981182999183023183037183041183047183059183067183089183091183119183151183167183191183203183247183259183263183283183289183299183301183307183317183319183329183343183349183361183373183377183383183389183397183437183439183451183461183473183479183487183497183499183503183509183511183523183527183569183571183577183581183587183593183611183637183661183683183691183697183707183709183713183761183763183797183809183823183829183871183877183881183907183917183919183943183949183959183971183973183979184003184007184013184031184039184043184057184073184081184087184111184117184133184153184157184181184187184189184199184211184231184241184259184271184273184279184291184309184321184333184337184351184369184409184417184441184447184463184477184487184489184511184517184523184553184559184567184571184577184607184609184627184631184633184649184651184669184687184693184703184711184721184727184733184753184777184823184829184831184837184843184859184879184901184903184913184949184957184967184969184993184997184999185021185027185051185057185063185069185071185077185089185099185123185131185137185149185153185161185167185177185183185189185221185233185243185267185291185299185303185309185323185327185359185363185369185371185401185429185441185467185477185483185491185519185527185531185533185539185543185551185557185567185569185593185599185621185641185651185677185681185683185693185699185707185711185723185737185747185749185753185767185789185797185813185819185821185831185833185849185869185873185893185897185903185917185923185947185951185957185959185971185987185993186007186013186019186023186037186041186049186071186097186103186107186113186119186149186157186161186163186187186191186211186227186229186239186247186253186259186271186283186299186301186311186317186343186377186379186391186397186419186437186451186469186479186481186551186569186581186583186587186601186619186629186647186649186653186671186679186689186701186707186709186727186733186743186757186761186763186773186793186799186841186859186869186871186877186883186889186917186947186959187003187009187027187043187049187067187069187073187081187091187111187123187127187129187133187139187141187163187171187177187181187189187193187211187217187219187223187237187273187277187303187337187339187349187361187367187373187379187387187393187409187417187423187433187441187463187469187471187477187507187513187531187547187559187573187597187631187633187637187639187651187661187669187687187699187711187721187751187763187787187793187823187843187861187871187877187883187897187907187909187921187927187931187951187963187973187987188011188017188021188029188107188137188143188147188159188171188179188189188197188249188261188273188281188291188299188303188311188317188323188333188351188359188369188389188401188407188417188431188437188443188459188473188483188491188519188527188533188563188579188603188609188621188633188653188677188681188687188693188701188707188711188719188729188753188767188779188791188801188827188831188833188843188857188861188863188869188891188911188927188933188939188941188953188957188983188999189011189017189019189041189043189061189067189127189139189149189151189169189187189199189223189229189239189251189253189257189271189307189311189337189347189349189353189361189377189389189391189401189407189421189433189437189439189463189467189473189479189491189493189509189517189523189529189547189559189583189593189599189613189617189619189643189653189661189671189691189697189701189713189733189743189757189767189797189799189817189823189851189853189859189877189881189887189901189913189929189947189949189961189967189977189983189989189997190027190031190051190063190093190097190121190129190147190159190181190207190243190249190261190271190283190297190301190313190321190331190339190357190367190369190387190391190403190409190471190507190523190529190537190543190573190577190579190583190591190607190613190633190639190649190657190667190669190699190709190711190717190753190759190763190769190783190787190793190807190811190823190829190837190843190871190889190891190901190909190913190921190979190997191021191027191033191039191047191057191071191089191099191119191123191137191141191143191161191173191189191227191231191237191249191251191281191297191299191339191341191353191413191441191447191449191453191459191461191467191473191491191497191507191509191519191531191533191537191551191561191563191579191599191621191627191657191669191671191677191689191693191699191707191717191747191749191773191783191791191801191803191827191831191833191837191861191899191903191911191929191953191969191977191999192007192013192029192037192043192047192053192091192097192103192113192121192133192149192161192173192187192191192193192229192233192239192251192259192263192271192307192317192319192323192341192343192347192373192377192383192391192407192431192461192463192497192499192529192539192547192553192557192571192581192583192587192601192611192613192617192629192631192637192667192677192697192737192743192749192757192767192781192791192799192811192817192833192847192853192859192877192883192887192889192917192923192931192949192961192971192977192979192991193003193009193013193031193043193051193057193073193093193133193139193147193153193163193181193183193189193201193243193247193261193283193301193327193337193357193367193373193379193381193387193393193423193433193441193447193451193463193469193493193507193513193541193549193559193573193577193597193601193603193607193619193649193663193679193703193723193727193741193751193757193763193771193789193793193799193811193813193841193847193859193861193871193873193877193883193891193937193939193943193951193957193979193993194003194017194027194057194069194071194083194087194093194101194113194119194141194149194167194179194197194203194239194263194267194269194309194323194353194371194377194413194431194443194471194479194483194507194521194527194543194569194581194591194609194647194653194659194671194681194683194687194707194713194717194723194729194749194767194771194809194813194819194827194839194861194863194867194869194891194899194911194917194933194963194977194981194989195023195029195043195047195049195053195071195077195089195103195121195127195131195137195157195161195163195193195197195203195229195241195253195259195271195277195281195311195319195329195341195343195353195359195389195401195407195413195427195443195457195469195479195493195497195511195527195539195541195581195593195599195659195677195691195697195709195731195733195737195739195743195751195761195781195787195791195809195817195863195869195883195887195893195907195913195919195929195931195967195971195973195977195991195997196003196033196039196043196051196073196081196087196111196117196139196159196169196171196177196181196187196193196201196247196271196277196279196291196303196307196331196337196379196387196429196439196453196459196477196499196501196519196523196541196543196549196561196579196583196597196613196643196657196661196663196681196687196699196709196717196727196739196751196769196771196799196817196831196837196853196871196873196879196901196907196919196927196961196991196993197003197009197023197033197059197063197077197083197089197101197117197123197137197147197159197161197203197207197221197233197243197257197261197269197273197279197293197297197299197311197339197341197347197359197369197371197381197383197389197419197423197441197453197479197507197521197539197551197567197569197573197597197599197609197621197641197647197651197677197683197689197699197711197713197741197753197759197767197773197779197803197807197831197837197887197891197893197909197921197927197933197947197957197959197963197969197971198013198017198031198043198047198073198083198091198097198109198127198139198173198179198193198197198221198223198241198251198257198259198277198281198301198313198323198337198347198349198377198391198397198409198413198427198437198439198461198463198469198479198491198503198529198533198553198571198589198593198599198613198623198637198641198647198659198673198689198701198719198733198761198769198811198817198823198827198829198833198839198841198851198859198899198901198929198937198941198943198953198959198967198971198977198997199021199033199037199039199049199081199103199109199151199153199181199193199207199211199247199261199267199289199313199321199337199343199357199373199379199399199403199411199417199429199447199453199457199483199487199489199499199501199523199559199567199583199601199603199621199637199657199669199673199679199687199697199721199729199739199741199751199753199777199783199799199807199811199813199819199831199853199873199877199889199909199921199931199933199961199967199999200003200009200017200023200029200033200041200063200087200117200131200153200159200171200177200183200191200201200227200231200237200257200273200293200297200323200329200341200351200357200363200371200381200383200401200407200437200443200461200467200483200513200569200573200579200587200591200597200609200639200657200671200689200699200713200723200731200771200779200789200797200807200843200861200867200869200881200891200899200903200909200927200929200971200983200987200989201007201011201031201037201049201073201101201107201119201121201139201151201163201167201193201203201209201211201233201247201251201281201287201307201329201337201359201389201401201403201413201437201449201451201473201491201493201497201499201511201517201547201557201577201581201589201599201611201623201629201653201661201667201673201683201701201709201731201743201757201767201769201781201787201791201797201809201821201823201827201829201833201847201881201889201893201907201911201919201923201937201947201953201961201973201979201997202001202021202031202049202061202063202067202087202099202109202121202127202129202183202187202201202219202231202243202277202289202291202309202327202339202343202357202361202381202387202393202403202409202441202471202481202493202519202529202549202567202577202591202613202621202627202637202639202661202667202679202693202717202729202733202747202751202753202757202777202799202817202823202841202859202877202879202889202907202921202931202933202949202967202973202981202987202999203011203017203023203039203051203057203117203141203173203183203207203209203213203221203227203233203249203279203293203309203311203317203321203323203339203341203351203353203363203381203383203387203393203417203419203429203431203449203459203461203531203549203563203569203579203591203617203627203641203653203657203659203663203669203713203761203767203771203773203789203807203809203821203843203857203869203873203897203909203911203921203947203953203969203971203977203989203999204007204013204019204023204047204059204067204101204107204133204137204143204151204161204163204173204233204251204299204301204311204319204329204331204353204359204361204367204371204377204397204427204431204437204439204443204461204481204487204509204511204517204521204557204563204583204587204599204601204613204623204641204667204679204707204719204733204749204751204781204791204793204797204803204821204857204859204871204887204913204917204923204931204947204973204979204983205019205031205033205043205063205069205081205097205103205111205129205133205141205151205157205171205187205201205211205213205223205237205253205267205297205307205319205327205339205357205391205397205399205417205421205423205427205433205441205453205463205477205483205487205493205507205519205529205537205549205553205559205589205603205607205619205627205633205651205657205661205663205703205721205759205763205783205817205823205837205847205879205883205913205937205949205951205957205963205967205981205991205993206009206021206027206033206039206047206051206069206077206081206083206123206153206177206179206183206191206197206203206209206221206233206237206249206251206263206273206279206281206291206299206303206341206347206351206369206383206399206407206411206413206419206447206461206467206477206483206489206501206519206527206543206551206593206597206603206623206627206639206641206651206699206749206779206783206803206807206813206819206821206827206879206887206897206909206911206917206923206933206939206951206953206993207013207017207029207037207041207061207073207079207113207121207127207139207169207187207191207197207199207227207239207241207257207269207287207293207301207307207329207331207341207343207367207371207377207401207409207433207443207457207463207469207479207481207491207497207509207511207517207521207523207541207547207551207563207569207589207593207619207629207643207653207661207671207673207679207709207719207721207743207763207769207797207799207811207821207833207847207869207877207923207931207941207947207953207967207971207973207997208001208003208009208037208049208057208067208073208099208111208121208129208139208141208147208189208207208213208217208223208231208253208261208277208279208283208291208309208319208333208337208367208379208387208391208393208409208433208441208457208459208463208469208489208493208499208501208511208513208519208529208553208577208589208591208609208627208631208657208667208673208687208697208699208721208729208739208759208787208799208807208837208843208877208889208891208907208927208931208933208961208963208991208993208997209021209029209039209063209071209089209123209147209159209173209179209189209201209203209213209221209227209233209249209257209263209267209269209299209311209317209327209333209347209353209357209359209371209381209393209401209431209441209449209459209471209477209497209519209533209543209549209563209567209569209579209581209597209621209623209639209647209659209669209687209701209707209717209719209743209767209771209789209801209809209813209819209821209837209851209857209861209887209917209927209929209939209953209959209971209977209983209987210011210019210031210037210053210071210097210101210109210113210127210131210139210143210157210169210173210187210191210193210209210229210233210241210247210257210263210277210283210299210317210319210323210347210359210361210391210401210403210407210421210437210461210467210481210487210491210499210523210527210533210557210599210601210619210631210643210659210671210709210713210719210731210739210761210773210803210809210811210823210827210839210853210857210869210901210907210911210913210923210929210943210961210967211007211039211049211051211061211063211067211073211093211097211129211151211153211177211187211193211199211213211217211219211229211231211241211247211271211283211291211297211313211319211333211339211349211369211373211403211427211433211441211457211469211493211499211501211507211543211559211571211573211583211597211619211639211643211657211661211663211681211691211693211711211723211727211741211747211777211781211789211801211811211817211859211867211873211877211879211889211891211927211931211933211943211949211969211979211997212029212039212057212081212099212117212123212131212141212161212167212183212203212207212209212227212239212243212281212293212297212353212369212383212411212419212423212437212447212453212461212467212479212501212507212557212561212573212579212587212593212627212633212651212669212671212677212683212701212777212791212801212827212837212843212851212867212869212873212881212897212903212909212917212923212969212981212987212999213019213023213029213043213067213079213091213097213119213131213133213139213149213173213181213193213203213209213217213223213229213247213253213263213281213287213289213307213319213329213337213349213359213361213383213391213397213407213449213461213467213481213491213523213533213539213553213557213589213599213611213613213623213637213641213649213659213713213721213727213737213751213791213799213821213827213833213847213859213881213887213901213919213929213943213947213949213953213973213977213989214003214007214009214021214031214033214043214051214063214069214087214091214129214133214141214147214163214177214189214211214213214219214237214243214259214283214297214309214351214363214373214381214391214399214433214439214451214457214463214469214481214483214499214507214517214519214531214541214559214561214589214603214607214631214639214651214657214663214667214673214691214723214729214733214741214759214763214771214783214787214789214807214811214817214831214849214853214867214883214891214913214939214943214967214987214993215051215063215077215087215123215141215143215153215161215179215183215191215197215239215249215261215273215279215297215309215317215329215351215353215359215381215389215393215399215417215443215447215459215461215471215483215497215503215507215521215531215563215573215587215617215653215659215681215687215689215693215723215737215753215767215771215797215801215827215833215843215851215857215863215893215899215909215921215927215939215953215959215981215983216023216037216061216071216091216103216107216113216119216127216133216149216157216173216179216211216217216233216259216263216289216317216319216329216347216371216373216379216397216401216421216431216451216481216493216509216523216551216553216569216571216577216607216617216641216647216649216653216661216679216703216719216731216743216751216757216761216779216781216787216791216803216829216841216851216859216877216899216901216911216917216919216947216967216973216991217001217003217027217033217057217069217081217111217117217121217157217163217169217199217201217207217219217223217229217241217253217271217307217309217313217319217333217337217339217351217361217363217367217369217387217397217409217411217421217429217439217457217463217489217499217517217519217559217561217573217577217579217619217643217661217667217681217687217691217697217717217727217733217739217747217771217781217793217823217829217849217859217901217907217909217933217937217969217979217981218003218021218047218069218077218081218083218087218107218111218117218131218137218143218149218171218191218213218227218233218249218279218287218357218363218371218381218389218401218417218419218423218437218447218453218459218461218479218509218513218521218527218531218549218551218579218591218599218611218623218627218629218641218651218657218677218681218711218717218719218723218737218749218761218783218797218809218819218833218839218843218849218857218873218887218923218941218947218963218969218971218987218989218993219001219017219019219031219041219053219059219071219083219091219097219103219119219133219143219169219187219217219223219251219277219281219293219301219311219313219353219361219371219377219389219407219409219433219437219451219463219467219491219503219517219523219529219533219547219577219587219599219607219613219619219629219647219649219677219679219683219689219707219721219727219731219749219757219761219763219767219787219797219799219809219823219829219839219847219851219871219881219889219911219917219931219937219941219943219953219959219971219977219979219983220009220013220019220021220057220063220123220141220147220151220163220169220177220189220217220243220279220291220301220307220327220333220351220357220361220369220373220391220399220403220411220421220447220469220471220511220513220529220537220543220553220559220573220579220589220613220663220667220673220681220687220699220709220721220747220757220771220783220789220793220807220811220841220859220861220873220877220879220889220897220901220903220907220919220931220933220939220973221021221047221059221069221071221077221083221087221093221101221159221171221173221197221201221203221209221219221227221233221239221251221261221281221303221311221317221327221393221399221401221411221413221447221453221461221471221477221489221497221509221537221539221549221567221581221587221603221621221623221653221657221659221671221677221707221713221717221719221723221729221737221747221773221797221807221813221827221831221849221873221891221909221941221951221953221957221987221989221999222007222011222023222029222041222043222059222067222073222107222109222113222127222137222149222151222161222163222193222197222199222247222269222289222293222311222317222323222329222337222347222349222361222367222379222389222403222419222437222461222493222499222511222527222533222553222557222587222601222613222619222643222647222659222679222707222713222731222773222779222787222791222793222799222823222839222841222857222863222877222883222913222919222931222941222947222953222967222977222979222991223007223009223019223037223049223051223061223063223087223099223103223129223133223151223207223211223217223219223229223241223243223247223253223259223273223277223283223291223303223313223319223331223337223339223361223367223381223403223423223429223439223441223463223469223481223493223507223529223543223547223549223577223589223621223633223637223667223679223681223697223711223747223753223757223759223781223823223829223831223837223841223843223849223903223919223921223939223963223969223999224011224027224033224041224047224057224069224071224101224113224129224131224149224153224171224177224197224201224209224221224233224239224251224261224267224291224299224303224309224317224327224351224359224363224401224423224429224443224449224461224467224473224491224501224513224527224563224569224579224591224603224611224617224629224633224669224677224683224699224711224717224729224737224743224759224771224797224813224831224863224869224881224891224897224909224911224921224929224947224951224969224977224993225023225037225061225067225077225079225089225109225119225133225143225149225157225161225163225167225217225221225223225227225241225257225263225287225289225299225307225341225343225347225349225353225371225373225383225427225431225457225461225479225493225499225503225509225523225527225529225569225581225583225601225611225613225619225629225637225671225683225689225697225721225733225749225751225767225769225779225781225809225821225829225839225859225871225889225919225931225941225943225949225961225977225983225989226001226007226013226027226063226087226099226103226123226129226133226141226169226183226189226199226201226217226231226241226267226283226307226313226337226357226367226379226381226397226409226427226433226451226453226463226483226487226511226531226547226549226553226571226601226609226621226631226637226643226649226657226663226669226691226697226741226753226769226777226783226789226799226813226817226819226823226843226871226901226903226907226913226937226943226991227011227027227053227081227089227093227111227113227131227147227153227159227167227177227189227191227207227219227231227233227251227257227267227281227299227303227363227371227377227387227393227399227407227419227431227453227459227467227471227473227489227497227501227519227531227533227537227561227567227569227581227593227597227603227609227611227627227629227651227653227663227671227693227699227707227719227729227743227789227797227827227849227869227873227893227947227951227977227989227993228013228023228049228061228077228097228103228113228127228131228139228181228197228199228203228211228223228233228251228257228281228299228301228307228311228331228337228341228353228359228383228409228419228421228427228443228451228457228461228469228479228509228511228517228521228523228539228559228577228581228587228593228601228611228617228619228637228647228677228707228713228731228733228737228751228757228773228793228797228799228829228841228847228853228859228869228881228883228887228901228911228913228923228929228953228959228961228983228989229003229027229037229081229093229123229127229133229139229153229157229171229181229189229199229213229217229223229237229247229249229253229261229267229283229309229321229343229351229373229393229399229403229409229423229433229459229469229487229499229507229519229529229547229549229553229561229583229589229591229601229613229627229631229637229639229681229693229699229703229711229717229727229739229751229753229759229763229769229771229777229781229799229813229819229837229841229847229849229897229903229937229939229949229961229963229979229981230003230017230047230059230063230077230081230089230101230107230117230123230137230143230149230189230203230213230221230227230233230239230257230273230281230291230303230309230311230327230339230341230353230357230369230383230387230389230393230431230449230453230467230471230479230501230507230539230551230561230563230567230597230611230647230653230663230683230693230719230729230743230761230767230771230773230779230807230819230827230833230849230861230863230873230891230929230933230939230941230959230969230977230999231001231017231019231031231041231053231067231079231107231109231131231169231197231223231241231269231271231277231289231293231299231317231323231331231347231349231359231367231379231409231419231431231433231443231461231463231479231481231493231503231529231533231547231551231559231563231571231589231599231607231611231613231631231643231661231677231701231709231719231779231799231809231821231823231827231839231841231859231871231877231893231901231919231923231943231947231961231967232003232007232013232049232051232073232079232081232091232103232109232117232129232153232171232187232189232207232217232259232303232307232333232357232363232367232381232391232409232411232417232433232439232451232457232459232487232499232513232523232549232567232571232591232597232607232621232633232643232663232669232681232699232709232711232741232751232753232777232801232811232819232823232847232853232861232871232877232891232901232907232919232937232961232963232987233021233069233071233083233113233117233141233143233159233161233173233183233201233221233231233239233251233267233279233293233297233323233327233329233341233347233353233357233371233407233417233419233423233437233477233489233509233549233551233557233591233599233609233617233621233641233663233669233683233687233689233693233713233743233747233759233777233837233851233861233879233881233911233917233921233923233939233941233969233983233993234007234029234043234067234083234089234103234121234131234139234149234161234167234181234187234191234193234197234203234211234217234239234259234271234281234287234293234317234319234323234331234341234343234361234383234431234457234461234463234467234473234499234511234527234529234539234541234547234571234587234589234599234613234629234653234659234673234683234713234721234727234733234743234749234769234781234791234799234803234809234811234833234847234851234863234869234893234907234917234931234947234959234961234967234977234979234989235003235007235009235013235043235051235057235069235091235099235111235117235159235171235177235181235199235211235231235241235243235273235289235307235309235337235349235369235397235439235441235447235483235489235493235513235519235523235537235541235553235559235577235591235601235607235621235661235663235673235679235699235723235747235751235783235787235789235793235811235813235849235871235877235889235891235901235919235927235951235967235979235997236017236021236053236063236069236077236087236107236111236129236143236153236167236207236209236219236231236261236287236293236297236323236329236333236339236377236381236387236399236407236429236449236461236471236477236479236503236507236519236527236549236563236573236609236627236641236653236659236681236699236701236707236713236723236729236737236749236771236773236779236783236807236813236867236869236879236881236891236893236897236909236917236947236981236983236993237011237019237043237053237067237071237073237089237091237137237143237151237157237161237163237173237179237203237217237233237257237271237277237283237287237301237313237319237331237343237361237373237379237401237409237467237487237509237547237563237571237581237607237619237631237673237683237689237691237701237707237733237737237749237763237767237781237791237821237851237857237859237877237883237901237911237929237959237967237971237973237977237997238001238009238019238031238037238039238079238081238093238099238103238109238141238151238157238159238163238171238181238201238207238213238223238229238237238247238261238267238291238307238313238321238331238339238361238363238369238373238397238417238423238439238451238463238471238477238481238499238519238529238531238547238573238591238627238639238649238657238673238681238691238703238709238723238727238729238747238759238781238789238801238829238837238841238853238859238877238879238883238897238919238921238939238943238949238967238991239017239023239027239053239069239081239087239119239137239147239167239171239179239201239231239233239237239243239251239263239273239287239297239329239333239347239357239383239387239389239417239423239429239431239441239461239489239509239521239527239531239539239543239557239567239579239587239597239611239623239633239641239671239689239699239711239713239731239737239753239779239783239803239807239831239843239849239851239857239873239879239893239929239933239947239957239963239977239999240007240011240017240041240043240047240049240059240073240089240101240109240113240131240139240151240169240173240197240203240209240257240259240263240271240283240287240319240341240347240349240353240371240379240421240433240437240473240479240491240503240509240517240551240571240587240589240599240607240623240631240641240659240677240701240707240719240727240733240739240743240763240769240797240811240829240841240853240859240869240881240883240893240899240913240943240953240959240967240997241013241027241037241049241051241061241067241069241079241093241117241127241141241169241177241183241207241229241249241253241259241261241271241291241303241313241321241327241333241337241343241361241363241391241393241421241429241441241453241463241469241489241511241513241517241537241543241559241561241567241589241597241601241603241639241643241651241663241667241679241687241691241711241727241739241771241781241783241793241807241811241817241823241847241861241867241873241877241883241903241907241919241921241931241939241951241963241973241979241981241993242009242057242059242069242083242093242101242119242129242147242161242171242173242197242201242227242243242257242261242273242279242309242329242357242371242377242393242399242413242419242441242447242449242453242467242479242483242491242509242519242521242533242551242591242603242617242621242629242633242639242647242659242677242681242689242713242729242731242747242773242779242789242797242807242813242819242863242867242873242887242911242923242927242971242989242999243011243031243073243077243091243101243109243119243121243137243149243157243161243167243197243203243209243227243233243239243259243263243301243311243343243367243391243401243403243421243431243433243437243461243469243473243479243487243517243521243527243533243539243553243577243583243587243589243613243623243631243643243647243671243673243701243703243707243709243769243781243787243799243809243829243839243851243857243863243871243889243911243917243931243953243973243989244003244009244021244033244043244087244091244109244121244129244141244147244157244159244177244199244217244219244243244247244253244261244291244297244301244303244313244333244339244351244357244367244379244381244393244399244403244411244423244429244451244457244463244471244481244493244507244529244547244553244561244567244583244589244597244603244619244633244637244639244667244669244687244691244703244711244721244733244747244753244759244781244787244813244837244841244843244859244861244873244877244889244897244901244939244943244957244997245023245029245033245039245071245083245087245107245129245131245149245171245173245177245183245209245251245257245261245269245279245291245299245317245321245339245383245389245407245411245417245419245437245471245473245477245501245513245519245521245527245533245561245563245587245591245593245621245627245629245639245653245671245681245683245711245719245723245741245747245753245759245771245783245789245821245849245851245863245881245897245899245909245911245941245963245977245981245983245989246011246017246049246073246097246119246121246131246133246151246167246173246187246193246203246209246217246223246241246247246251246271246277246289246317246319246329246343246349246361246371246391246403246439246469246473246497246509246511246523246527246539246557246569246577246599246607246611246613246637246641246643246661246683246689246707246709246713246731246739246769246773246781246787246793246803246809246811246817246833246839246889246899246907246913246919246923246929246931246937246941246947246971246979247001247007247031247067247069247073247087247099247141247183247193247201247223247229247241247249247259247279247301247309247337247339247343247363247369247381247391247393247409247421247433247439247451247463247501247519247529247531247547247553247579247591247601247603247607247609247613247633247649247651247691247693247697247711247717247729247739247759247769247771247781247799247811247813247829247847247853247873247879247889247901247913247939247943247957247991247993247997247999248021248033248041248051248057248063248071248077248089248099248117248119248137248141248161248167248177248179248189248201248203248231248243248257248267248291248293248299248309248317248323248351248357248371248389248401248407248431248441248447248461248473248477248483248509248533248537248543248569248579248587248593248597248609248621248627248639248641248657248683248701248707248719248723248737248749248753248779248783248789248797248813248821248827248839248851248861248867248869248879248887248891248893248903248909248971248981248987249017249037249059249079249089249097249103249107249127249131249133249143249181249187249199249211249217249229249233249253249257249287249311249317249329249341249367249377249383249397249419249421249427249433249437249439249449249463249497249499249503249517249521249533249539249541249563249583249589249593249607249647249659249671249677249703249721249727249737249749249763249779249797249811249827249833249853249857249859249863249871249881249911249923249943249947249967249971249973249989'\n return list[a:a+b]", "def solve(a, b):\n \"\"\"creates sequence of prime numbers\n up to at least a + b\n returns string of b elements from index a\n \"\"\"\n prime_seq = ''\n for prime in gen_primes():\n if len(prime_seq) > (a + b):\n break\n prime_seq += str(prime)\n print(prime_seq)\n return prime_seq[a:a+b]\n\ndef gen_primes():\n \"\"\"\n generate indefinite sequence of prime numbers\n implementing Erastothenes' Sieve\n returns generator object\n \"\"\"\n D = {}\n p = 2 # running integer\n while True:\n if p not in D:\n yield p\n D[p * p] = [p]\n else:\n for q in D[p]:\n D.setdefault(p + q, []).append(q)\n del D[p]\n p += 1", "def isPrime(n):\n for i in range(3,int(n**0.5)+1,2): # only odd numbers\n if n%i==0:\n return False\n return True\ndef solve(a, b):\n s = '2'\n i = 3\n while len(s) < (a+b):\n if isPrime(i) : s += str(i)\n i += 2\n return s[a:a+b]", "def is_prime(n):\n for i in range(2, int(n**(1/2) +1)):\n if n % i == 0:\n return False\n return True\n\ndef solve(a, b):\n primeseries =\"2\"\n for i in range(3,41000,2):\n if is_prime(i):\n primeseries += (str(i))\n return primeseries[a:a+b]", "def primes(n):\n\tprimes, p = [True for i in range(n+1)], 2\n\n\twhile p**2 <= n:\n\t\tif primes[p]:\n\t\t\tfor i in range(p*2, n+1, p): primes[i] = False\n\t\tp += 1\n\tprimes[0], primes[1] = False, False\n\n\treturn ''.join([str(i) for i in range(n+1) if primes[i]])\n\n\ndef solve(a, b):\n\tre = primes(a*10)\n\treturn re[a:b+a]", "import numpy as np\n\nxs = np.ones(1000000)\nxs[:2] = 0\nxs[2*2::2] = 0\nfor i in range(3, len(xs), 2):\n if not xs[i]:\n continue\n xs[i*i::i] = 0\nprimes = [i for i, x in enumerate(xs) if x]\ns = ''.join(c for p in primes for c in str(p))\n\ndef solve(a, b):\n return s[a:a+b]", "# pregenerate primes\nLIMIT = 10**6\nprimes = []\nsieve = list(range(LIMIT))\nsieve[1] = 0\nfor n in sieve:\n if n:\n primes.append(n)\n for i in range(n*n, LIMIT, n): sieve[i] = 0\n\nCopeland_Erdos = ''.join(map(str, primes))\n\ndef solve(a, b):\n return Copeland_Erdos[a:a+b]", "prime=lambda n:all(n % i for i in range(2, int(n ** .5) + 1))\nli = \"\".join(str(i) for i in range(2,10**5) if prime(i))\nsolve=lambda s,n:\"\".join(li)[s:s+n]", "s = \"2357111317192329313741434753596167717379838997101103107109113127131137139149151157163167173179181191193197199211223227229233239241251257263269271277281283293307311313317331337347349353359367373379383389397401409419421431433439443449457461463467479487491499503509521523541547557563569571577587593599601607613617619631641643647653659661673677683691701709719727733739743751757761769773787797809811821823827829839853857859863877881883887907911919929937941947953967971977983991997100910131019102110311033103910491051106110631069108710911093109711031109111711231129115111531163117111811187119312011213121712231229123112371249125912771279128312891291129713011303130713191321132713611367137313811399140914231427142914331439144714511453145914711481148314871489149314991511152315311543154915531559156715711579158315971601160716091613161916211627163716571663166716691693169716991709172117231733174117471753175917771783178717891801181118231831184718611867187118731877187918891901190719131931193319491951197319791987199319971999200320112017202720292039205320632069208120832087208920992111211321292131213721412143215321612179220322072213222122372239224322512267226922732281228722932297230923112333233923412347235123572371237723812383238923932399241124172423243724412447245924672473247725032521253125392543254925512557257925912593260926172621263326472657265926632671267726832687268926932699270727112713271927292731274127492753276727772789279127972801280328192833283728432851285728612879288728972903290929172927293929532957296329692971299930013011301930233037304130493061306730793083308931093119312131373163316731693181318731913203320932173221322932513253325732593271329933013307331333193323332933313343334733593361337133733389339134073413343334493457346134633467346934913499351135173527352935333539354135473557355935713581358335933607361336173623363136373643365936713673367736913697370137093719372737333739376137673769377937933797380338213823383338473851385338633877388138893907391139173919392339293931394339473967398940014003400740134019402140274049405140574073407940914093409941114127412941334139415341574159417742014211421742194229423142414243425342594261427142734283428942974327433743394349435743634373439143974409442144234441444744514457446344814483449345074513451745194523454745494561456745834591459746034621463746394643464946514657466346734679469147034721472347294733475147594783478747894793479948014813481748314861487148774889490349094919493149334937494349514957496749694973498749934999500350095011502150235039505150595077508150875099510151075113511951475153516751715179518951975209522752315233523752615273527952815297530353095323533353475351538153875393539954075413541754195431543754415443544954715477547954835501550355075519552155275531555755635569557355815591562356395641564756515653565756595669568356895693570157115717573757415743574957795783579158015807581358215827583958435849585158575861586758695879588158975903592359275939595359815987600760116029603760436047605360676073607960896091610161136121613161336143615161636173619761996203621162176221622962476257626362696271627762876299630163116317632363296337634363536359636163676373637963896397642164276449645164696473648164916521652965476551655365636569657165776581659966076619663766536659666166736679668966916701670367096719673367376761676367796781679167936803682368276829683368416857686368696871688368996907691169176947694969596961696769716977698369916997700170137019702770397043705770697079710371097121712771297151715971777187719372077211721372197229723772437247725372837297730773097321733173337349735173697393741174177433745174577459747774817487748974997507751775237529753775417547754975597561757375777583758975917603760776217639764376497669767376817687769176997703771777237727774177537757775977897793781778237829784178537867787378777879788379017907791979277933793779497951796379938009801180178039805380598069808180878089809381018111811781238147816181678171817981918209821982218231823382378243826382698273828782918293829783118317832983538363836983778387838984198423842984318443844784618467850185138521852785378539854385638573858185978599860986238627862986418647866386698677868186898693869987078713871987318737874187478753876187798783880388078819882188318837883988498861886388678887889389238929893389418951896389698971899990019007901190139029904190439049905990679091910391099127913391379151915791619173918191879199920392099221922792399241925792779281928392939311931993239337934193439349937193779391939794039413941994219431943394379439946194639467947394799491949795119521953395399547955195879601961396199623962996319643964996619677967996899697971997219733973997439749976797699781978797919803981198179829983398399851985798599871988398879901990799239929993199419949996799731000710009100371003910061100671006910079100911009310099101031011110133101391014110151101591016310169101771018110193102111022310243102471025310259102671027110273102891030110303103131032110331103331033710343103571036910391103991042710429104331045310457104591046310477104871049910501105131052910531105591056710589105971060110607106131062710631106391065110657106631066710687106911070910711107231072910733107391075310771107811078910799108311083710847108531085910861108671088310889108911090310909109371093910949109571097310979109871099311003110271104711057110591106911071110831108711093111131111711119111311114911159111611117111173111771119711213112391124311251112571126111273112791128711299113111131711321113291135111353113691138311393113991141111423114371144311447114671147111483114891149111497115031151911527115491155111579115871159311597116171162111633116571167711681116891169911701117171171911731117431177711779117831178911801118071181311821118271183111833118391186311867118871189711903119091192311927119331193911941119531195911969119711198111987120071201112037120411204312049120711207312097121011210712109121131211912143121491215712161121631219712203122111222712239122411225112253122631226912277122811228912301123231232912343123471237312377123791239112401124091241312421124331243712451124571247312479124871249112497125031251112517125271253912541125471255312569125771258312589126011261112613126191263712641126471265312659126711268912697127031271312721127391274312757127631278112791127991280912821128231282912841128531288912893128991290712911129171291912923129411295312959129671297312979129831300113003130071300913033130371304313049130631309313099131031310913121131271314713151131591316313171131771318313187132171321913229132411324913259132671329113297133091331313327133311333713339133671338113397133991341113417134211344113451134571346313469134771348713499135131352313537135531356713577135911359713613136191362713633136491366913679136811368713691136931369713709137111372113723137291375113757137591376313781137891379913807138291383113841138591387313877138791388313901139031390713913139211393113933139631396713997139991400914011140291403314051140571407114081140831408714107141431414914153141591417314177141971420714221142431424914251142811429314303143211432314327143411434714369143871438914401144071441114419144231443114437144471444914461144791448914503145191453314537145431454914551145571456114563145911459314621146271462914633146391465314657146691468314699147131471714723147311473714741147471475314759147671477114779147831479714813148211482714831148431485114867148691487914887148911489714923149291493914947149511495714969149831501315017150311505315061150731507715083150911510115107151211513115137151391514915161151731518715193151991521715227152331524115259152631526915271152771528715289152991530715313153191532915331153491535915361153731537715383153911540115413154271543915443154511546115467154731549315497155111552715541155511555915569155811558315601156071561915629156411564315647156491566115667156711567915683157271573115733157371573915749157611576715773157871579115797158031580915817158231585915877158811588715889159011590715913159191592315937159591597115973159911600116007160331605716061160631606716069160731608716091160971610316111161271613916141161831618716189161931621716223162291623116249162531626716273163011631916333163391634916361163631636916381164111641716421164271643316447164511645316477164811648716493165191652916547165531656116567165731660316607166191663116633166491665116657166611667316691166931669916703167291674116747167591676316787168111682316829168311684316871168791688316889169011690316921169271693116937169431696316979169811698716993170111702117027170291703317041170471705317077170931709917107171171712317137171591716717183171891719117203172071720917231172391725717291172931729917317173211732717333173411735117359173771738317387173891739317401174171741917431174431744917467174711747717483174891749117497175091751917539175511756917573175791758117597175991760917623176271765717659176691768117683177071771317729177371774717749177611778317789177911780717827178371783917851178631788117891179031790917911179211792317929179391795717959179711797717981179871798918013180411804318047180491805918061180771808918097181191812118127181311813318143181491816918181181911819918211182171822318229182331825118253182571826918287182891830118307183111831318329183411835318367183711837918397184011841318427184331843918443184511845718461184811849318503185171852118523185391854118553185831858718593186171863718661186711867918691187011871318719187311874318749187571877318787187931879718803188391885918869188991891118913189171891918947189591897318979190011900919013190311903719051190691907319079190811908719121191391914119157191631918119183192071921119213192191923119237192491925919267192731928919301193091931919333193731937919381193871939119403194171942119423194271942919433194411944719457194631946919471194771948319489195011950719531195411954319553195591957119577195831959719603196091966119681196871969719699197091971719727197391975119753197591976319777197931980119813198191984119843198531986119867198891989119913199191992719937199491996119963199731997919991199931999720011200212002320029200472005120063200712008920101201072011320117201232012920143201472014920161201732017720183202012021920231202332024920261202692028720297203232032720333203412034720353203572035920369203892039320399204072041120431204412044320477204792048320507205092052120533205432054920551205632059320599206112062720639206412066320681206932070720717207192073120743207472074920753207592077120773207892080720809208492085720873208792088720897208992090320921209292093920947209592096320981209832100121011210132101721019210232103121059210612106721089211012110721121211392114321149211572116321169211792118721191211932121121221212272124721269212772128321313213172131921323213412134721377213792138321391213972140121407214192143321467214812148721491214932149921503215172152121523215292155721559215632156921577215872158921599216012161121613216172164721649216612167321683217012171321727217372173921751217572176721773217872179921803218172182121839218412185121859218632187121881218932191121929219372194321961219772199121997220032201322027220312203722039220512206322067220732207922091220932210922111221232212922133221472215322157221592217122189221932222922247222592227122273222772227922283222912230322307223432234922367223692238122391223972240922433224412244722453224692248122483225012251122531225412254322549225672257122573226132261922621226372263922643226512266922679226912269722699227092271722721227272273922741227512276922777227832278722807228112281722853228592286122871228772290122907229212293722943229612296322973229932300323011230172302123027230292303923041230532305723059230632307123081230872309923117231312314323159231672317323189231972320123203232092322723251232692327923291232932329723311233212332723333233392335723369233712339923417234312344723459234732349723509235312353723539235492355723561235632356723581235932359923603236092362323627236292363323663236692367123677236872368923719237412374323747237532376123767237732378923801238132381923827238312383323857238692387323879238872389323899239092391123917239292395723971239772398123993240012400724019240232402924043240492406124071240772408324091240972410324107241092411324121241332413724151241692417924181241972420324223242292423924247242512428124317243292433724359243712437324379243912440724413244192442124439244432446924473244812449924509245172452724533245472455124571245932461124623246312465924671246772468324691246972470924733247492476324767247812479324799248092482124841248472485124859248772488924907249172491924923249432495324967249712497724979249892501325031250332503725057250732508725097251112511725121251272514725153251632516925171251832518925219252292523725243252472525325261253012530325307253092532125339253432534925357253672537325391254092541125423254392544725453254572546325469254712552325537255412556125577255792558325589256012560325609256212563325639256432565725667256732567925693257032571725733257412574725759257632577125793257992580125819258412584725849258672587325889259032591325919259312593325939259432595125969259812599725999260032601726021260292604126053260832609926107261112611326119261412615326161261712617726183261892620326209262272623726249262512626126263262672629326297263092631726321263392634726357263712638726393263992640726417264232643126437264492645926479264892649726501265132653926557265612657326591265972662726633266412664726669266812668326687266932669926701267112671326717267232672926731267372675926777267832680126813268212683326839268492686126863268792688126891268932690326921269272694726951269532695926981269872699327011270172703127043270592706127067270732707727091271032710727109271272714327179271912719727211272392724127253272592727127277272812728327299273292733727361273672739727407274092742727431274372744927457274792748127487275092752727529275392754127551275812758327611276172763127647276532767327689276912769727701277332773727739277432774927751277632776727773277792779127793277992780327809278172782327827278472785127883278932790127917279192794127943279472795327961279672798327997280012801928027280312805128057280692808128087280972809928109281112812328151281632818128183282012821128219282292827728279282832828928297283072830928319283492835128387283932840328409284112842928433284392844728463284772849328499285132851728537285412854728549285592857128573285792859128597286032860728619286212862728631286432864928657286612866328669286872869728703287112872328729287512875328759287712878928793288072881328817288372884328859288672887128879289012890928921289272893328949289612897929009290172902129023290272903329059290632907729101291232912929131291372914729153291672917329179291912920129207292092922129231292432925129269292872929729303293112932729333293392934729363293832938729389293992940129411294232942929437294432945329473294832950129527295312953729567295692957329581295872959929611296292963329641296632966929671296832971729723297412975329759297612978929803298192983329837298512986329867298732987929881299172992129927299472995929983299893001130013300293004730059300713008930091300973010330109301133011930133301373013930161301693018130187301973020330211302233024130253302593026930271302933030730313303193032330341303473036730389303913040330427304313044930467304693049130493304973050930517305293053930553305573055930577305933063130637306433064930661306713067730689306973070330707307133072730757307633077330781308033080930817308293083930841308513085330859308693087130881308933091130931309373094130949309713097730983310133101931033310393105131063310693107931081310913112131123311393114731151311533115931177311813118331189311933121931223312313123731247312493125331259312673127131277313073131931321313273133331337313573137931387313913139331397314693147731481314893151131513315173153131541315433154731567315733158331601316073162731643316493165731663316673168731699317213172331727317293174131751317693177131793317993181731847318493185931873318833189131907319573196331973319813199132003320093202732029320513205732059320633206932077320833208932099321173211932141321433215932173321833218932191322033221332233322373225132257322613229732299323033230932321323233232732341323533235932363323693237132377323813240132411324133242332429324413244332467324793249132497325033250732531325333253732561325633256932573325793258732603326093261132621326333264732653326873269332707327133271732719327493277132779327833278932797328013280332831328333283932843328693288732909329113291732933329393294132957329693297132983329873299332999330133302333029330373304933053330713307333083330913310733113331193314933151331613317933181331913319933203332113322333247332873328933301333113331733329333313334333347333493335333359333773339133403334093341333427334573346133469334793348733493335033352133529335333354733563335693357733581335873358933599336013361333617336193362333629336373364133647336793370333713337213373933749337513375733767337693377333791337973380933811338273382933851338573386333871338893389333911339233393133937339413396133967339973401934031340333403934057340613412334127341293414134147341573415934171341833421134213342173423134253342593426134267342733428334297343013430334313343193432734337343513436134367343693438134403344213442934439344573446934471344833448734499345013451134513345193453734543345493458334589345913460334607346133463134649346513466734673346793468734693347033472134729347393474734757347593476334781348073481934841348433484734849348713487734883348973491334919349393494934961349633498135023350273505135053350593506935081350833508935099351073511135117351293514135149351533515935171352013522135227352513525735267352793528135291353113531735323353273533935353353633538135393354013540735419354233543735447354493546135491355073550935521355273553135533355373554335569355733559135593355973560335617356713567735729357313574735753357593577135797358013580335809358313583735839358513586335869358793589735899359113592335933359513596335969359773598335993359993600736011360133601736037360613606736073360833609736107361093613136137361513616136187361913620936217362293624136251362633626936277362933629936307363133631936341363433635336373363833638936433364513645736467364693647336479364933649736523365273652936541365513655936563365713658336587365993660736629366373664336653366713667736683366913669736709367133672136739367493676136767367793678136787367913679336809368213683336847368573687136877368873689936901369133691936923369293693136943369473697336979369973700337013370193702137039370493705737061370873709737117371233713937159371713718137189371993720137217372233724337253372733727737307373093731337321373373733937357373613736337369373793739737409374233744137447374633748337489374933750137507375113751737529375373754737549375613756737571375733757937589375913760737619376333764337649376573766337691376933769937717377473778137783377993781137813378313784737853378613787137879378893789737907379513795737963379673798737991379933799738011380393804738053380693808338113381193814938153381673817738183381893819738201382193823138237382393826138273382813828738299383033831738321383273832938333383513837138377383933843138447384493845338459384613850138543385573856138567385693859338603386093861138629386393865138653386693867138677386933869938707387113871338723387293873738747387493876738783387913880338821388333883938851388613886738873388913890338917389213892338933389533895938971389773899339019390233904139043390473907939089390973910339107391133911939133391393915739161391633918139191391993920939217392273922939233392393924139251392933930139313393173932339341393433935939367393713937339383393973940939419394393944339451394613949939503395093951139521395413955139563395693958139607396193962339631396593966739671396793970339709397193972739733397493976139769397793979139799398213982739829398393984139847398573986339869398773988339887399013992939937399533997139979399833998940009400134003140037400394006340087400934009940111401234012740129401514015340163401694017740189401934021340231402374024140253402774028340289403434035140357403614038740423404274042940433404594047140483404874049340499405074051940529405314054340559405774058340591405974060940627406374063940693406974069940709407394075140759407634077140787408014081340819408234082940841408474084940853408674087940883408974090340927409334093940949409614097340993410114101741023410394104741051410574107741081411134111741131411414114341149411614117741179411834118941201412034121341221412274123141233412434125741263412694128141299413334134141351413574138141387413894139941411414134144341453414674147941491415074151341519415214153941543415494157941593415974160341609416114161741621416274164141647416514165941669416814168741719417294173741759417614177141777418014180941813418434184941851418634187941887418934189741903419114192741941419474195341957419594196941981419834199942013420174201942023420434206142071420734208342089421014213142139421574216942179421814218742193421974220942221422234222742239422574228142283422934229942307423234233142337423494235942373423794239142397424034240742409424334243742443424514245742461424634246742473424874249142499425094253342557425694257142577425894261142641426434264942667426774268342689426974270142703427094271942727427374274342751427674277342787427934279742821428294283942841428534285942863428994290142923\"\nsolve = lambda a, b: s[a:a+b]", "import math\ndef primes(x,y):\n a=''\n for num in range(x,y,2):\n if all(num%i!=0 for i in range(3,int(math.sqrt(num))+1, 2)):\n a=a+str(num)\n return a\ndef solve(a, b):\n print((a, b))\n return primes(1,50000)[a:a+b]\n \n \n", "def is_prime(n):\n if n<2:\n return False\n elif n==2:\n return True\n elif n%2==0:\n return False\n x=3\n while(x*x<=n):\n if n%x==0:\n return False\n x+=2\n return True\n\ndef make_prime_stream(n):\n s='2'\n x=3\n while(len(s)<n):\n if is_prime(x):\n s+=str(x)\n x+=2\n return s\n\nprime_stream=make_prime_stream(21000)\n\ndef solve(a, b):\n return prime_stream[a:a+b]"] | {"fn_name": "solve", "inputs": [[2, 2], [10, 5], [10, 3], [20, 9], [30, 12], [40, 8], [50, 6], [10000, 5], [20000, 5]], "outputs": [["57"], ["19232"], ["192"], ["414347535"], ["616771737983"], ["83899710"], ["031071"], ["02192"], ["09334"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 436,630 |
def solve(a, b):
|
7dbc4e200e62c3fa0bd487d202729897 | UNKNOWN | Cheesy Cheeseman just got a new monitor! He is happy with it, but he just discovered that his old desktop wallpaper no longer fits. He wants to find a new wallpaper, but does not know which size wallpaper he should be looking for, and alas, he just threw out the new monitor's box. Luckily he remembers the width and the aspect ratio of the monitor from when Bob Mortimer sold it to him. Can you help Cheesy out?
# The Challenge
Given an integer `width` and a string `ratio` written as `WIDTH:HEIGHT`, output the screen dimensions as a string written as `WIDTHxHEIGHT`. | ["def find_screen_height(width, ratio): \n a, b = map(int, ratio.split(\":\"))\n return f\"{width}x{int(width / a * b)}\"", "def find_screen_height(width, ratio): \n #Turns the string ratio into a list with the two numbers as elements\n z = ratio.split(\":\")\n \n #calculates the height value\n height = (width/int(z[0]))*int(z[1])\n \n #Displays the string\n return f\"{width}x{int(height)}\"\n \n", "def find_screen_height(width, ratio): \n return f'{width}x{width * int(ratio.split(\":\")[1]) // int(ratio.split(\":\")[0])}'", "from fractions import Fraction\n\ndef find_screen_height(width, ratio): \n ratio = ratio.replace(\":\",\"/\")\n ratio = float(sum(Fraction(s) for s in ratio.split()))\n return \"{}x{}\".format(width, int(width/ratio))", "def find_screen_height(width, ratio): \n a, b = map(int, ratio.split(':'))\n return f'{width}x{width * b // a}'", "def find_screen_height(width, ratio): \n r = ratio.split(':')\n return f'{width}x{int(width * int(r[1]) / int(r[0]))}'", "def find_screen_height(width, ratio):\n r = list(map(int, ratio.split(':')))\n return f'{width}x{width * r[1]//r[0]}'", "def find_screen_height(width, ratio): \n wr, rr = (int(n) for n in ratio.split(\":\"))\n return f\"{width}x{width * rr // wr}\"", "def find_screen_height(width: int, ratio: str) -> str:\n \"\"\"\" Get screen dimensions as a string written as WIDTHxHEIGHT based on width and ratio. \"\"\"\n _width_ratio, _height_ratio = ratio.split(\":\")\n return f\"{width}x{int((width / int(_width_ratio)) * int(_height_ratio))}\"\n", "def find_screen_height(width, ratio):\n return \"{}x{}\".format(width, int(((width / int(ratio.split(':')[0])) * int(ratio.split(':')[1]))))"] | {"fn_name": "find_screen_height", "inputs": [[1024, "4:3"], [1280, "16:9"], [3840, "32:9"], [1600, "4:3"], [1280, "5:4"], [2160, "3:2"], [1920, "16:9"], [5120, "32:9"]], "outputs": [["1024x768"], ["1280x720"], ["3840x1080"], ["1600x1200"], ["1280x1024"], ["2160x1440"], ["1920x1080"], ["5120x1440"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 1,756 |
def find_screen_height(width, ratio):
|
3b6a9ae3b21f0824670c79825e334fac | UNKNOWN | Peter can see a clock in the mirror from the place he sits in the office.
When he saw the clock shows 12:22
1
2
3
4
5
6
7
8
9
10
11
12
He knows that the time is 11:38
1
2
3
4
5
6
7
8
9
10
11
12
in the same manner:
05:25 --> 06:35
01:50 --> 10:10
11:58 --> 12:02
12:01 --> 11:59
Please complete the function `WhatIsTheTime(timeInMirror)`, where `timeInMirror` is the mirrored time (what Peter sees) as string.
Return the _real_ time as a string.
Consider hours to be between 1 <= hour < 13.
So there is no 00:20, instead it is 12:20.
There is no 13:20, instead it is 01:20. | ["def what_is_the_time(time_in_mirror):\n h, m = map(int, time_in_mirror.split(':'))\n return '{:02}:{:02}'.format(-(h + (m != 0)) % 12 or 12, -m % 60)", "def what_is_the_time(time_in_mirror):\n array = time_in_mirror.split(\":\")\n a = int(array[0])\n b = int(array[1])\n \n if a == 11: a = 12\n elif a == 12: a = 11\n else: a = 11 - a\n \n if b == 0: \n b = 0\n a += 1\n else: b = 60 - b \n return \"{:02}:{:02}\".format(a, b)", "def what_is_the_time(time_in_mirror):\n\n CW_HRS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n MIRROR = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11]\n\n if time_in_mirror in [\"12:00\", \"12:30\", \"06:00\", \"06:30\"]:\n return time_in_mirror\n \n hours, minutes = time_in_mirror.split(':')\n hours, minutes = int(hours), int(minutes)\n hrs = abs(12 - hours) if minutes == 0 else MIRROR[hours]\n mins = 0 if minutes == 0 else 60 - minutes \n \n return \"{:02}:{:02}\".format(hrs, mins)", "def what_is_the_time(time_in_mirror):\n l=[]\n hour=[]\n minute=[]\n res=[]\n for i in time_in_mirror:\n l.append(i)\n l.pop(2)\n hour.append(l[0])\n hour.append(l[1])\n minute.append(l[2])\n minute.append(l[3])\n hour=''.join(hour)\n minute=''.join(minute)\n hour=int(hour)\n\n minute=int(minute)\n if(hour<11 and minute!=0):\n hour=11-hour\n elif(hour<11 and minute==0):\n hour=12-hour\n elif(hour==11 and minute!=0):\n hour=12\n elif(hour==11 and minute==0):\n hour=1\n elif(hour==12 and minute!=0):\n hour=11\n elif(hour==12 and minute==0):\n hour=12\n if minute==0:\n minute=0\n else:\n minute=60-minute\n if(hour<10):\n res.append(str(0))\n res.append(str(hour))\n else:\n res.append(str(hour))\n res.append(':')\n if(minute<10):\n res.append('0')\n res.append(str(minute))\n else:\n res.append(str(minute))\n res=''.join(res)\n return res\n #amele styleeee\n\n", "def what_is_the_time(time_in_mirror):\n hours, minutes = list(map(int, time_in_mirror.split(':')))\n \n if minutes == 0:\n mirrored_hours = 12 - hours\n mirrored_minutes = 0\n else:\n mirrored_hours = (11 - hours) % 12\n mirrored_minutes = 60 - minutes\n if mirrored_hours == 0:\n mirrored_hours = 12\n \n return \"{:02d}:{:02d}\".format(mirrored_hours, mirrored_minutes)\n", "def what_is_the_time(time):\n h, m = (int(n) for n in time.split(\":\"))\n return f\"{-(h + (m>0)) % 12 or 12:02d}:{-m % 60:02d}\"", "def what_is_the_time(time_in_mirror: str) -> str:\n h, m = list(map(int, time_in_mirror.split(\":\")))\n h, m = divmod(720 - m - (h % 12) * 60, 60)\n return f\"{h or 12:02d}:{m:02d}\"\n", "def what_is_the_time(time):\n a,b = map(int,time.split(':'))\n if 1<=a<=10 and 1<=b<=59 : a, b = 11-a, 60-b\n elif 11<=a<=12 and 1<=b<=59 : a, b = 23-a,60-b\n else : a, b = 12-a,b\n return '{0:>02}:{1:>02}'.format(a or 12,b)", "def what_is_the_time(time_in_mirror):\n if not time_in_mirror: return\n x, y = map(int, time_in_mirror.split(':'))\n q, r = divmod(720-60*x-y, 60)\n return \"{:02d}:{:02d}\".format(q%12 or 12, r)", "def what_is_the_time(time_in_mirror):\n hours, minutes = map(int, time_in_mirror.split(':'))\n m_hours, m_minutes = divmod(720 - 60 * hours - minutes, 60)\n return '{:02}:{:02}'.format(m_hours + 12 * (m_hours <= 0), m_minutes)"] | {"fn_name": "what_is_the_time", "inputs": [["06:35"], ["11:59"], ["12:02"], ["04:00"], ["06:00"], ["12:00"]], "outputs": [["05:25"], ["12:01"], ["11:58"], ["08:00"], ["06:00"], ["12:00"]]} | INTRODUCTORY | PYTHON3 | CODEWARS | 3,549 |
def what_is_the_time(time_in_mirror):
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.