Awesome ! Unfortunately I don't have twitter.. but here are my answers:
Day 1
def day_1(sentence: str) -> str: result = [] for word in sentence.split(): if word.isalpha(): word = word[1:] + word[0] + 'ay' result.append(word) return ' '.join(result)
Day 2 Pretty sure it can be waaaay better
def day_2(sequences: List[str]) -> List[str]: opening_seq = ('(', '[', '{') closing_seq = (')', ']', '}') matchs = { closing_seq[i]: opening_seq[i] for i in range(len(opening_seq)) } def check(sequence: str) -> bool: if len(sequence) % 2: return False if not all([ sequence.count(i) == sequence.count(matchs[i]) for i in matchs ]): return False stack = [] for c in sequence: if c in opening_seq: stack.append(c) elif c in closing_seq: if not stack: return False elif stack.pop() != matchs[c]: return False return not stack return ['YES' if check(s) else 'NO' for s in sequences]
Day 3
def day_3(sentence: str) -> str: return ' '.join([ word if len(word) < 5 else word[::-1] for word in sentence.split() ])
Day 4
def day_4(limit: int) -> int: seq = [0, 1] while seq[-1] < limit: seq.append(sum(seq[-2:])) return sum([i for i in seq if i % 2 == 0])
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Awesome !
Unfortunately I don't have twitter.. but here are my answers:
Day 1
Day 2
Pretty sure it can be waaaay better
Day 3
Day 4