Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions challenge_4/python/whiterd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Invert Binary Tree

* Take in a binary tree object.

* For each level in the tree, reverse the order of the items in that level (mirror).

* Return the node object.
15 changes: 15 additions & 0 deletions challenge_4/python/whiterd/src/invert_bin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

'''
Input: An object consisting of a binary tree.

Output: The same tree with values mirrored.
'''

def mirror(node):
if node:
mirror(node.left)
mirror(node.right)
node.left, node.right = node.right, node.left

return node
30 changes: 30 additions & 0 deletions challenge_6/python/whiterd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Range Finder-er :tm:
###### Tested using Python 3.5.2 -- run using ```$ python src/id_ranges.py```

### Purpose:

* Identify the ranges that exist for a given input.

### Assuptions:

* Input is a non-empty list of ordered integers.

### Example 1:

Launch scipt and input a sequence of numbers separated by commas.

```
>>> Input a list of integers: [1,2,3,4,8,9,10,12,13,14]
['1->4', '8->10', '12->14']
```

### Example 2:

Given the input [1,2,3,4,9,10,15], your output should be:

```
>>> Input a list of integers: [1,2,3,4,9,10,15]
['1->4', '9->10']
```


30 changes: 30 additions & 0 deletions challenge_6/python/whiterd/src/id_ranges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python

"""
Identify the ranges that exist for a given input.

Assume: input is a non-empty list of ordered integers.
"""
from __future__ import print_function

def range_finderer(new_list):
result = []
temp = []
for i in new_list:
if not temp:
temp.append(i)
continue
elif(i - 1 == temp[-1]):
temp.append(i)
continue
else:
result.append(str(temp[0]) + '->' + str(temp[-1]))
temp = [i]
result.append(str(temp[0]) + '->' + str(temp[-1]))
return result


if __name__ == '__main__':

x = [int(x) for x in input('Input a list of integers: ')[1:-1].split(',')]
print(range_finderer(x))