-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6532636
commit 1d7581f
Showing
3 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
def find_incorrect_value(tree): | ||
for child in enumerate(tree): | ||
left_child = i * 2 + 1 | ||
right_child = i * 2 + 2 | ||
def move_zeros(lst): | ||
zeros = [] | ||
for i in range(len(lst)-1, -1, -1): | ||
if lst[i] == 0: | ||
zeros.append(lst.pop(i)) | ||
lst.extend(zeros) | ||
return lst | ||
|
||
|
||
|
||
print(find_incorrect_value([28, 13, 14, 6, 7, 5, 9])) | ||
# 9, 5, 7, 6, 14, 13, 28 | ||
print(find_incorrect_value([27, 14, 14, 6, 7, 5, 9])) | ||
|
||
print(move_zeros([1, 2, 0, 1, 0, 1, 0, 3, 0, 1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import re | ||
|
||
|
||
def pig_it(text): | ||
word_pattern = re.compile(r'[a-zA-Z]+') | ||
|
||
def pig_word(word): | ||
return word[1:] + word[0] + 'ay' | ||
|
||
return word_pattern.sub(lambda match: pig_word(match.group()), text) | ||
|
||
|
||
print(pig_it("Hello there sir 67!")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
rgb_hex_dict = {x: str(x) if x < 10 else chr(x + 55) for x in range(16)} | ||
|
||
|
||
def rgb(r, g, b): | ||
r = max(0, min(255, r)) | ||
g = max(0, min(255, g)) | ||
b = max(0, min(255, b)) | ||
r_hex = f"{rgb_hex_dict[r // 16]}{rgb_hex_dict[r % 16]}" | ||
g_hex = f"{rgb_hex_dict[g // 16]}{rgb_hex_dict[g % 16]}" | ||
b_hex = f"{rgb_hex_dict[b // 16]}{rgb_hex_dict[b % 16]}" | ||
return f"{r_hex}{g_hex}{b_hex}" | ||
|
||
|
||
print(rgb(0, 1, 1)) |