Skip to content

Instantly share code, notes, and snippets.

View Cyborg-Model-Z's full-sized avatar
💭
now analyzing amphibian reproduction in an integrated development

Cyborg-Model-Z

💭
now analyzing amphibian reproduction in an integrated development
View GitHub Profile
@Cyborg-Model-Z
Cyborg-Model-Z / pig it
Created July 21, 2019 21:37
Pig latin
def pig_it(text):
print(text)
def startsvowel(wordlist):
latin_list=[]
for str in wordlist:
if str[0] == "a" or str [0] =="A":
latin_list.append(str + "ay")
elif str[0] == "e" or str[0] == "E":
latin_list.append(str+ "ay")
elif str[0] == "str[0] =="I":
@camsbury
This exercise wanted you to take an int and determine if it was "jumping" with jumping meaning the subsequent numbers in the string only differ by one
787 = jumping 1234 = jumping 1235 != jumping 5656543234 = jumping
I put a little skeleton together but I think I should be getting some "no's" and I'm getting all yesses
```
def make_str(int):
return str(int)
def split_number(str):
lst = [int(d) for d in str]
I need to add all elements in an array of arrays, there are 7 days of the week and 52 weeks in a year, so each weekday has 52 elements to add together
sunday = [6737, 7244, 5776, 9826, 7057, 9247, 5842, 5484, 6543, 5153, 6832, 8274,
7148, 6152, 5940, 8040, 9174, 7555, 7682, 5252, 8793, 8837, 7320, 8478, 6063,
5751, 9716, 5085, 7315, 7859, 6628, 5425, 6331, 7097, 6249, 8381, 5936, 8496,
6934, 8347, 7036, 6421, 6510, 5821, 8602, 5312, 7836, 8032, 9871, 5990, 6309, 7825]
monday = [9175, 7883, 7596, 8635, 9274, 9675, 5603, 6863, 6442, 9500, 7468, 9719,
6648, 8180, 7944, 5190, 6209, 7175, 5984, 9737, 5548, 6803, 9254, 5932, 7360, 9221,
5702, 5252, 7041, 7287, 5185, 9139, 7187, 8855, 9310, 9105, 9769, 9679, 7842,
7466, 7321, 6785, 8770, 8108, 7985, 5186, 9021, 9098, 6099, 5828, 7217, 9387]
@camsbury this is a 7 kyu and I think I'm pretty damn close, even divided it into two as you recommended, but this is timing out for some reason
```def odd_or_even(n):
if(n) % 2 == 0:
return n-1
else:
return n-2
def count_to(n):
while n>0:
@camsbury
I'm having trouble figuring out how to count by a certain number- the formula is (x,y) where for y numbers you count by x, aka (2,5) would return [2,4,6,8,10]
```
def count_by(x, n):
while n>0:
lst=[]
lst.append(x+x)
n=n-1
```
@camsbury
In this kata my goal is to take a list of ints and return each int *2. It looks like I need to remove duplicates first. I was thinking of converting to a dict and then changing back to a list, as an internet example suggested, but wondered if you had another way
[1,1,3,3,7,8] should return [2,6,14,16]
```
def remove_duplicates(a):
def mapit(a):
map(maps,a)
```
text = "python is fun"
substring = " "
def spaces(text):
return (str[::text.count(" ", 0,100)])
spaces(text)
print (spaces("to sit in solemn silence"))
text = "python is fun"
substring = " "
def spaces(text):
return (str[::text.count(" ", 0,100)])
spaces(text)
print (spaces("to sit in solemn silence"))
https://www.codewars.com/kata/growth-of-a-population/train/python
>In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants?
So far I got
'''
def nb_year(p0,percent,aug,p):
n=0
while p <= 1200:
input_arrays = [[1, 30, 2], [21, 20, 20], [1, 2, 3]]
def round_down_to_twenty(input_arrays):
for array in input_arrays:
for x in array:
if x >=20:
x = 20
else: x=x
def average_array(arrays):