2017-08-15

This commit is contained in:
2017-08-15 09:55:28 -05:00
parent 549ba5084e
commit 4a9b690bb2
28 changed files with 1153 additions and 18 deletions

View File

@@ -1 +0,0 @@
example

Binary file not shown.

View File

@@ -0,0 +1 @@
{}

View File

@@ -3,5 +3,5 @@
#
def hello(name=''):
return
def hello(name='World'):
return 'Hello, '+name+'!'

30
python/isogram/README.md Normal file
View File

@@ -0,0 +1,30 @@
# Isogram
Determine if a word or phrase is an isogram.
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter.
Examples of isograms:
- lumberjacks
- background
- downstream
The word *isograms*, however, is not an isogram, because the s repeats.
### Submitting Exercises
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
For more detailed information about running tests, code style and linting,
please see the [help page](http://exercism.io/languages/python).
## Source
Wikipedia [https://en.wikipedia.org/wiki/Isogram](https://en.wikipedia.org/wiki/Isogram)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@@ -0,0 +1,2 @@
def is_isogram():
pass

View File

@@ -0,0 +1,39 @@
import unittest
from isogram import is_isogram
# test cases adapted from `x-common//canonical-data.json` @ version: 1.1.0
class TestIsogram(unittest.TestCase):
def test_empty_string(self):
self.assertTrue(is_isogram(""))
def test_isogram_with_only_lower_case_characters(self):
self.assertTrue(is_isogram("isogram"))
def test_word_with_one_duplicated_character(self):
self.assertFalse(is_isogram("eleven"))
def test_longest_reported_english_isogram(self):
self.assertTrue(is_isogram("subdermatoglyphic"))
def test_word_with_duplicated_character_in_mixed_case(self):
self.assertFalse(is_isogram("Alphabet"))
def test_hypothetical_isogrammic_word_with_hyphen(self):
self.assertTrue(is_isogram("thumbscrew-japingly"))
def test_isogram_with_duplicated_non_letter_character(self):
self.assertTrue(is_isogram("Hjelmqvist-Gryb-Zock-Pfund-Wax"))
def test_made_up_name_that_is_an_isogram(self):
self.assertTrue(is_isogram("Emily Jung Schwartzkopf"))
def test_duplicated_character_in_the_middle(self):
self.assertFalse(is_isogram("accentor"))
if __name__ == '__main__':
unittest.main()

1
python/leap/.cache/v/cache/lastfailed vendored Normal file
View File

@@ -0,0 +1 @@
{}

44
python/leap/README.md Normal file
View File

@@ -0,0 +1,44 @@
# Leap
Given a year, report if it is a leap year.
The tricky thing here is that a leap year in the Gregorian calendar occurs:
```plain
on every year that is evenly divisible by 4
except every year that is evenly divisible by 100
unless the year is also evenly divisible by 400
```
For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap
year, but 2000 is.
If your language provides a method in the standard library that does
this look-up, pretend it doesn't exist and implement it yourself.
## Notes
Though our exercise adopts some very simple rules, there is more to
learn!
For a delightful, four minute explanation of the whole leap year
phenomenon, go watch [this youtube video][video].
[video]: http://www.youtube.com/watch?v=xX96xng7sAE
### Submitting Exercises
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
For more detailed information about running tests, code style and linting,
please see the [help page](http://exercism.io/languages/python).
## Source
JavaRanch Cattle Drive, exercise 3 [http://www.javaranch.com/leap.jsp](http://www.javaranch.com/leap.jsp)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Binary file not shown.

2
python/leap/leap.py Normal file
View File

@@ -0,0 +1,2 @@
def is_leap_year(yr):
return yr % 4 == 0 and (yr % 100 != 0 or yr % 400 == 0)

23
python/leap/leap_test.py Normal file
View File

@@ -0,0 +1,23 @@
import unittest
from leap import is_leap_year
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
class YearTest(unittest.TestCase):
def test_year_not_divisible_by_4(self):
self.assertFalse(is_leap_year(2015))
def test_year_divisible_by_4_not_divisible_by_100(self):
self.assertTrue(is_leap_year(2016))
def test_year_divisible_by_100_not_divisible_by_400(self):
self.assertFalse(is_leap_year(2100))
def test_year_divisible_by_400(self):
self.assertTrue(is_leap_year(2000))
if __name__ == '__main__':
unittest.main()