inputs
stringlengths 50
14k
| targets
stringlengths 4
655k
|
|---|---|
Linked Lists - Length & Count
Implement Length() to count the number of nodes in a linked list.
Implement Count() to count the occurrences of an integer in a linked list.
I've decided to bundle these two functions within the same Kata since they are both very similar.
The `push()`/`Push()` and `buildOneTwoThree()`/`BuildOneTwoThree()` functions do not need to be redefined.
|
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
def length(node):
# Your code goes here.
i = 0
while node != None:
i+=1
node = node.next
return i
def count(node, data):
# Your code goes here.
res = 0
while node != None:
res+= node.data == data
node = node.next
return res
|
Linked Lists - Length & Count
Implement Length() to count the number of nodes in a linked list.
Implement Count() to count the occurrences of an integer in a linked list.
I've decided to bundle these two functions within the same Kata since they are both very similar.
The `push()`/`Push()` and `buildOneTwoThree()`/`BuildOneTwoThree()` functions do not need to be redefined.
|
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
def length(node):
return 0 if node == None else 1 if node.next == None else 1 + length(node.next)
def count(node, data):
return 0 if node == None else int(node.data == data) if node.next == None else int(node.data == data) + count(node.next, data)
|
Linked Lists - Length & Count
Implement Length() to count the number of nodes in a linked list.
Implement Count() to count the occurrences of an integer in a linked list.
I've decided to bundle these two functions within the same Kata since they are both very similar.
The `push()`/`Push()` and `buildOneTwoThree()`/`BuildOneTwoThree()` functions do not need to be redefined.
|
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
def length(node,filter=None):
l = 0
while node != None :
node, l = node.next, l+(filter is None or filter == node.data)
return l
def count(node, data): return length(node, data)
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(x, t):
arr = [x[0]]
for c in x[1:]:
if c + arr[-1] != t:
arr.append(c)
return arr
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(array, target):
i = 0
while i < len(array) - 1:
if array[i] + array[i+1] == target:
del array[i+1]
else:
i += 1
return array
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(x, t):
n = x[:1]
for i in x[1:]:
if i + n[-1] != t:
n.append(i)
return n
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(x, t):
res = [x[0]]
for elem in x[1:]:
if elem + res[-1] != t:
res.append(elem)
return res
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(arr, t):
i = 0
while i < len(arr)-1:
if arr[i] + arr[i+1] == t:
del arr[i+1]
else:
i += 1
return arr
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(nums, target):
if len(nums) < 2:
return nums
result = []
left = 0
right = 1
while True:
try:
if nums[left] + nums[right] != target:
result.append(nums[left])
left = right
except LookupError:
result.append(nums[left])
break
right += 1
return result
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
from functools import reduce
def trouble(x, t):
return reduce(lambda a, u: a + ([u] if not a or a[-1] + u != t else []), x[1:], x[0:1])
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(x, t):
res = []
for i in x:
if not res or res[-1] + i != t:
res.append(i)
return res
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(arr, t):
for i in range(len(arr) - 1):
if arr[i] + arr[i+1] == t:
return trouble(arr[:i+1] + arr[i+2:], t)
return arr
|
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number.
Example:
x = [1, 2, 3, 4, 5]
t = 3
1+2 = t, so remove 2. No other pairs = t, so rest of array remains:
[1, 3, 4, 5]
Work through the array from left to right.
Return the resulting array.
|
def trouble(x, t):
while(1):
for i in range(len(x) - 1):
if x[i] + x[i+1] == t:
x.pop(i+1)
break
else:
break
return x
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
return {contact[0]: contact[1] if len(contact) > 1 else None
for contact in data}
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
return {u[0]: (u[1] if len(u) > 1 else None) for u in data}
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
a = {}
for i in data:
a[i[0]] = i[1] if len(i) == 2 else None
return a
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
return {p[0]: p[1] if len(p) > 1 else None for p in data}
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
dictionary={}
for t in data:
if len(t)==1:
dictionary[t[0]]=None
elif len(t)==2:
dictionary[t[0]]=t[1]
return dictionary
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
return {l[0]: l[1] if len(l)>1 else None for l in data}
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
return {a : b[0] if b else None for a, *b in data}
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
from itertools import zip_longest
def user_contacts(data):
return dict(zip(*zip_longest(*data)))
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
return {name: (code[0] if code else None) for name, *code in data}
|
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like:
```python
[["Grae Drake", 98110], ["Bethany Kok"], ["Alex Nussbacher", 94101], ["Darrell Silver", 11201]]
```
Notice that one of the users above has a name but _doesn't_ have a zip code.
Write a function `user_contacts()` that takes a two-dimensional list like the one above and returns a dictionary with an item for each user where the key is the user's name and the value is the user's zip code. If your data doesn't include a zip code then the value should be `None`.
For example, using the input above, `user_contacts()` would return this dictionary:
```python
{
"Grae Drake": 98110,
"Bethany Kok": None,
"Alex Nussbacher": 94101,
"Darrell Silver": 11201,
}
```
You don't have to worry about leading zeros in zip codes.
|
def user_contacts(data):
return {d[0]:d[1] if len(d)>1 else None for d in data}
# Your code here.
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(n):
roman_numerals = {1000:'M',
900: 'CM',
500: 'D',
400: 'CD',
100: 'C',
90: 'XC',
50: 'L',
40: 'XL',
10: 'X',
9: 'IX',
5: 'V',
4: 'IV',
1: 'I'
}
roman_string = ''
for key in sorted(list(roman_numerals.keys()),reverse=True):
while n >= key:
roman_string += roman_numerals[key]
n -= key
return roman_string
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
vals = zip(('M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'),
(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1))
def solution(n):
if n == 0: return ""
return next(c + solution(n-v) for c,v in vals if v <= n)
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
units = " I II III IV V VI VII VIII IX".split(" ")
tens = " X XX XXX XL L LX LXX LXXX XC".split(" ")
hundreds = " C CC CCC CD D DC DCC DCCC CM".split(" ")
thousands = " M MM MMM".split(" ")
def solution(n):
return thousands[n//1000] + hundreds[n%1000//100] + tens[n%100//10] + units[n%10]
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(n):
return "M" * (n//1000) + hundreds[n%1000//100] + tens[n%100//10] + units[n%10]
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
anums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
rnums = "M CM D CD C XC L XL X IX V IV I".split()
def solution(x):
ret = []
for a,r in zip(anums, rnums):
n,x = divmod(x,a)
ret.append(r*n)
return ''.join(ret)
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(n):
dic = {1:'I',4:'IV',5:'V',9:'IX',10:'X',40:'XL',50:'L',90:'XC',100:'C',400:'CD',500:'D',900:'CM',1000:'M'}
roman = ''
for a in reversed(sorted(dic.keys())):
while (a <= n):
n = n - a;
roman = roman + dic[a];
return roman
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(n):
return " M MM MMM".split(" ")[n//1000] + \
" C CC CCC CD D DC DCC DCCC CM".split(" ")[n//100%10] + \
" X XX XXX XL L LX LXX LXXX XC".split(" ")[n//10%10] + \
" I II III IV V VI VII VIII IX".split(" ")[n%10]
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(n):
ed = ["","I","II","III","IV","V","VI","VII","VIII","IX"]
des = ["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"]
sot = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]
tys = ["","M","MM","MMM","MMMM"]
return tys[n // 1000] + sot[n // 100 % 10] + des[n // 10 % 10] + ed[n % 10]
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(n):
ROMAN_SYMBOLS = ["M", "D", "C", "L", "X", "V", "I"]
ROMAN_VALUES = [1000, 500, 100, 50, 10, 5, 1]
idx = 0
roman = []
while n > 0:
if n < ROMAN_VALUES[idx]:
idx += 1
continue
n -= ROMAN_VALUES[idx]
roman.append(ROMAN_SYMBOLS[idx])
if roman[-4:].count(roman[-1]) == 4:
roman = roman[:-3] + [ROMAN_SYMBOLS[idx-1]]
if roman[-3:-2] == roman[-1:]:
roman = roman[:-3] + [ROMAN_SYMBOLS[idx]] + [ROMAN_SYMBOLS[idx-2]]
return "".join(roman)
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(n):
numeral = ''
number = [1000, 900, 500, 400, 100, 90, 50, 40, 10,9,5,4,1]
numerals = ['M','CM','D','CD','C','XC','L', 'XL','X','IX','V','IV','I']
print(numerals)
square = lambda x, y: int(x/number[y]) * numerals[y]
for i in range(13):
numeral+= square(n, i)
n = n - number[i]*int(n/number[i])
return numeral
|
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer.
Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI.
Example:
```python
solution(1000) # should return 'M'
```
Help:
```
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
```
Remember that there can't be more than 3 identical symbols in a row.
More about roman numerals - http://en.wikipedia.org/wiki/Roman_numerals
|
def solution(x):
table = [
(1000,"M"),
(900,"CM"),
(500,"D"),
(400,"CD"),
(100,"C"),
(90,"XC"),
(50,"L"),
(40,"XL"),
(10,"X"),
(9,"IX"),
(5,"V"),
(4,"IV"),
(1,"I")
]
for num, rep in table:
if x >= num:
return rep + solution(x-num)
return str()
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(titles, term):
return list(filter(lambda title: term in title.lower(), titles))
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(titles, term):
return [ title for title in titles if term in title.lower() ]
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
search = lambda titles, term: list(filter(lambda title: term.lower() in title.lower(), titles))
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(titles, term):
term = term.casefold()
return [t for t in titles if term in t.casefold()]
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(titles, term):
term = term.lower()
return [s for s in titles if term in s.lower()]
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(titles, term):
return list(filter(lambda title: term.lower() in title.lower(), titles))
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(titles, term):
return list(t for t in titles if term.lower() in t.lower())
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(a, s):
s = s.lower()
return [x for x in a if s in x.lower()]
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
import re
def search(titles, term):
return [t for t in titles if re.search(term, t, re.I)]
|
The function must return the sequence of titles that match the string passed as an argument.
```if:javascript
TITLES is a preloaded sequence of strings.
```
```python
titles = ['Rocky 1', 'Rocky 2', 'My Little Poney']
search(titles, 'ock') --> ['Rocky 1', 'Rocky 2']
```
But the function return some weird result and skip some of the matching results.
Does the function have special movie taste?
Let's figure out !
|
def search(titles: list, term: str):
import re
return [title for title in titles if bool(re.search(term, title, re.IGNORECASE))]
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*a):
return sum(a)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*args):
return sum(args)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
return laLiga+copaDelRey+championsLeague
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
resultado = laLiga + copaDelRey + championsLeague
return resultado
goals(5,10,5)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
goals = lambda *a: sum(a)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laliga, copa_del_rey, champions):
return laliga + copa_del_rey + champions
print(f"Final result of Messi's goals is {goals(5, 10, 2)}.")
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*leagues):
'''return the sum of goals from all leagues'''
return sum(leagues)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
goals=lambda *b: sum(b)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
MESSI_IS_THE_BEST_FOOTBALLER_EVER = True
def goals(laLiga, copaDelRey, championsLeague):
if MESSI_IS_THE_BEST_FOOTBALLER_EVER:
return laLiga + copaDelRey + championsLeague
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
goals = lambda *leagues: sum(leagues)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
goals=lambda *params: sum(params)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
import itertools
def goals(laLiga, copaDelRey, championsLeague):
return list(itertools.accumulate([laLiga, copaDelRey, championsLeague]))[-1]
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
sum = int(laLiga) + int(copaDelRey) + int(championsLeague)
return sum
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(l, c, m):
return l+c+m
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(LaLiga, CopaDelRey, ChampionsLeague):
return LaLiga + CopaDelRey + ChampionsLeague
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
l = laLiga
c = copaDelRey
ch = championsLeague
return l + c + ch
pass
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*argv):
return sum(argv)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
return (laLiga + copaDelRey + championsLeague )
#BDD
#goals from each league
# sum of goals
#
#Psuedocode
# declare variables for the three leagues
#return the total number of goals
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
return(laLiga + copaDelRey + championsLeague)
#BDD
#Goals from each league
#Total Goals to be N
#
#Psudo Code
#goals from L1
#goals from L2
#goals from L3
#return the sum of goals from L1,L2,L3
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
goals = lambda l, co, ch : l + co + ch
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*games):
return sum(games)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(first, second, third):
return (first + second) + third
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
import numpy as np
def goals(laLiga, copaDelRey, championsLeague):
a = np.array((laLiga, copaDelRey, championsLeague))
return sum(a)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
tt = laLiga + copaDelRey + championsLeague
return tt
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
goalsScored = laLiga+copaDelRey+championsLeague
return goalsScored
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
"""(^-__-^)"""
count_goals = (laLiga+copaDelRey+championsLeague)
return (count_goals if count_goals > 0 else 0)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
goals = lambda a, b, c: sum((a, b, c))
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*args):
return sum([x for x in args])
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
pass1 = laLiga + copaDelRey + championsLeague
return pass1
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(l, c1, c2):
return (l+c1+c2)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(a, b, c):
return a+c+b
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga: int, copaDelRey: int, championsLeague: int) -> int:
return laLiga + copaDelRey + championsLeague
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*goals): # *goals unpacks all variables into a tuple
return sum(goals)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(l, cy, ch):
return (l+cy+ch)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
count = 0
for i in range(laLiga):
count+=1
for j in range(copaDelRey):
count+=1
for k in range(championsLeague):
count+=1
return count
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*c):
return sum(c)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(x, y, z):
return sum([x,y,z])
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
return laLiga+copaDelRey+championsLeague
#pass
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
'''Messi is the king'''
return laLiga+copaDelRey+championsLeague
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(a, e, o):
return a+e+o
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(l, cdl, cl):
return l+cdl+cl
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(a,b,e):
return a+b+e
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
yhteensa = laLiga + copaDelRey + championsLeague
return yhteensa
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
k = laLiga + copaDelRey + championsLeague
return k
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
pass
goals = laLiga + copaDelRey + championsLeague
return goals
goals(1,1,1)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*goles):
return sum([*goles])
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
Total = laLiga + copaDelRey + championsLeague
return Total
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(a,b,c):
return sum((a,b,c))
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
if laLiga >= 0 and copaDelRey >= 0 and championsLeague >= 0:
return laLiga + copaDelRey + championsLeague
else:
print('the input will always be valid')
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
goals = lambda *s: sum(s)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(l, d, s):
return l+d+s
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
_sum = (laLiga, copaDelRey, championsLeague)
return sum(_sum)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
goals = (int(laLiga) + int(copaDelRey) + int(championsLeague))
return(goals)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(*agr):
return sum(agr)
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
total_goals = (laLiga,copaDelRey,championsLeague)
return(sum(total_goals))
|
# Messi goals function
[Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues:
- LaLiga
- Copa del Rey
- Champions
Complete the function to return his total number of goals in all three leagues.
Note: the input will always be valid.
For example:
```
5, 10, 2 --> 17
```
|
def goals(laLiga, copaDelRey, championsLeague):
sum = laLiga + copaDelRey + championsLeague
return sum
goals(5, 10, 15)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.