Skip to content

Commit

Permalink
landscape.io
Browse files Browse the repository at this point in the history
  • Loading branch information
theonlypwner committed Feb 7, 2016
1 parent 76ad9fd commit b558de7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Interview Cake Solutions
===========
[![Build Status](https://travis-ci.org/theonlypwner/interviewcake.svg)](https://travis-ci.org/theonlypwner/interviewcake)
[![Coverage Status](https://coveralls.io/repos/github/theonlypwner/interviewcake/badge.svg)](https://coveralls.io/github/theonlypwner/interviewcake)
[![Code Health](https://landscape.io/github/theonlypwner/interviewcake/master/landscape.svg?style=flat)](https://landscape.io/github/theonlypwner/interviewcake/master)

Even though they have posted solutions to these problems, my solutions are extended.
They include the "bonus" parts along with extra tasks. Also, my solutions include unit tests.
Expand Down
12 changes: 6 additions & 6 deletions ic/q43.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def merge_arrays(*a):
"""

N = len(a)
index = [0] * N
cur_index = [0] * N
result = []

# Add smallest element so far
Expand All @@ -69,16 +69,16 @@ def merge_arrays(*a):

# Find array with smallest next item
for array in range(N):
if index[array] < len(a[array]) and (min_array == None or
a[array][index[array]] < a[min_array][index[min_array]]):
if cur_index[array] < len(a[array]) and (min_array is None or
a[array][cur_index[array]] < a[min_array][cur_index[min_array]]):

min_array = array

if min_array == None:
if min_array is None:
break

# Add it
result.append(a[min_array][index[min_array]])
index[min_array] += 1
result.append(a[min_array][cur_index[min_array]])
cur_index[min_array] += 1

return result

0 comments on commit b558de7

Please sign in to comment.