forked from exercism/python
-
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.
Merge pull request #3 from exercism/master
Pulling in most recent exercise changes
- Loading branch information
Showing
14 changed files
with
130 additions
and
124 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,2 +1,2 @@ | ||
def binary_search(list_of_numbers, number): | ||
def find(search_list, value): | ||
pass |
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
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
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,2 +1,2 @@ | ||
def hey(phrase): | ||
def response(hey_bob): | ||
pass |
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
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,26 +1,26 @@ | ||
def hey(stimulus): | ||
stimulus = stimulus.strip() | ||
def response(hey_bob): | ||
hey_bob = hey_bob.strip() | ||
|
||
if _is_silence(stimulus): | ||
if _is_silence(hey_bob): | ||
return 'Fine. Be that way!' | ||
if _is_shouting(stimulus): | ||
if _is_question(stimulus): | ||
if _is_shouting(hey_bob): | ||
if _is_question(hey_bob): | ||
return "Calm down, I know what I'm doing!" | ||
else: | ||
return 'Whoa, chill out!' | ||
elif _is_question(stimulus): | ||
elif _is_question(hey_bob): | ||
return 'Sure.' | ||
else: | ||
return 'Whatever.' | ||
|
||
|
||
def _is_silence(stimulus): | ||
return stimulus == '' | ||
def _is_silence(hey_bob): | ||
return hey_bob == '' | ||
|
||
|
||
def _is_shouting(stimulus): | ||
return stimulus.isupper() | ||
def _is_shouting(hey_bob): | ||
return hey_bob.isupper() | ||
|
||
|
||
def _is_question(stimulus): | ||
return stimulus.endswith('?') | ||
def _is_question(hey_bob): | ||
return hey_bob.endswith('?') |
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,2 +1,2 @@ | ||
def collatz_steps(number): | ||
def steps(number): | ||
pass |
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
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,4 +1,4 @@ | ||
def collatz_steps(n): | ||
def steps(n): | ||
if n <= 0: | ||
raise ValueError("input should be positive") | ||
|
||
|
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,13 @@ | ||
def saddle_points(m): | ||
if not m: | ||
return set() | ||
if any(len(r) != len(m[0]) for r in m): | ||
def saddle_points(matrix): | ||
if not matrix: | ||
return [{}] | ||
if any(len(row) != len(matrix[0]) for row in matrix): | ||
raise ValueError('irregular matrix') | ||
mmax = [max(r) for r in m] | ||
mmin = [min(c) for c in zip(*m)] | ||
points = [(i+1, j+1) for i in range(len(m)) | ||
for j in range(len(m[0])) if mmax[i] == mmin[j]] | ||
mmax = [max(row) for row in matrix] | ||
mmin = [min(col) for col in zip(*matrix)] | ||
points = [{"row": index + 1, "column": col_index + 1} | ||
for index in range(len(matrix)) | ||
for col_index in range(len(matrix[0])) | ||
if mmax[index] == mmin[col_index]] | ||
|
||
return set(points) | ||
return points or [{}] |
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
Oops, something went wrong.