Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sarcodian committed Jan 23, 2017
1 parent d976096 commit 6b3e2d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions challenge_9/python/sarcodian/READ.me
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Takes a list of sorted values and squares them, resorting
the resulting list. The algorithm cannot use sort on the
resulting list.

If the first element of the list is greater then 0, we can
just return the list squared as tis already sorted.

Otherwise, we work backwards, but comparing the absolute value
of the first element with the last element and squaring the largest.

We then return the reverse of the squared list to get it sorted from
smallest to largest.
4 changes: 4 additions & 0 deletions challenge_9/python/sarcodian/src/challenge_9.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
def square_n_sort(L):
'''
Get an ordered list of ints and square the values, returning a list
of squares ordered from smallest to largest.
'''

L_square = []
L_sorted = []
Expand Down

0 comments on commit 6b3e2d8

Please sign in to comment.