From 42eccbf31ba956c93155bb1ce006522d248906b6 Mon Sep 17 00:00:00 2001 From: Marc Chan Date: Tue, 27 Feb 2018 00:11:09 +0800 Subject: [PATCH] Merge upstream/master into react-1257 pig-latin: improve documentation (#1352) add "Running the tests" section to README template (#1271) * add "Running the tests" section to README template * regenerate README files with new template * rewrite Running the tests section for clarity * -switch to a plaintext-readable format -add link explaining py.test vs pytest queen-attack: re-implement according to canonical data 2.1.0 (#1351) * queen-attack: re-implement according to canonical data 2.1.0 * queen-attack: rewrite to pass tests v2.1.0 * queen-attack: remove redundant tests Rm `test_invalid_position_can_attack` since `Queen()` grains: update tests to v1.1.0 (#1357) Fix typo and minor style issues in all READMEs (#1356) * Fix typo and style in README template * Fix `shold` to `should` * Fix minor style issues in `### Common pytest options` * Add blank line after all headers * Regenerate all READMEs * Remove redundant periods in READMEs add `awaiting review` exempt label to stale.yml (#1364) go-counting: adapt tests to canonical data v1.0.0 (#1360) * set correct canonical data version * adapt tests and example solution to canonical data 1.0.0 * use assertSetEqual() consistently sgf-parsing: implement exercise (#1359) * implement sgf-parsing * fix import statement * create entry in config.json * fix __eq__ for Python2 lens-person: forego exercise (#1299) * lens-person: forego exercise `lens-person` is specific to languages with immutable data (i.e. Haskell). This concept does not exist in Python, so the exercise should be foregone. * remove bad comma Implement exercise bank-account (#1260) * Implement exercise bank-account * bank-account: generate README using configlet * bank-account: fix typo and comments pascals-triangle: update tests to canonical-date v1.2.0 (#1164) house: return singleton list for single verse (#1354) * house: return singleton list for single verse RE #1347 ([comment](https://github.com/exercism/python/pull/1347#discussion_r170626365)) * house: fix example solution to pass changed tests meetup: remove fail-safe for undefined MeetupDayException (#1345) * meetup: remove fail-safe for undefined MeetupDayException Fixes #1344 * meetup: define MeetupDayException in example solution * meetup: fix example solution to raise correct exception * meetup: fix flake8 violations * meetup: add exception message Curriculum (#1355) * select core exercises and set exercise ordering * add missing obvious topics * make list-ops a core exercise * rational-numbers: increase difficulty * unlocked_by core exercises only (exercism/configlet#61) Ref: https://github.com/exercism/v2-feedback/issues/61#issuecomment-324130763 alphametics: mark computationally intensive test as extra-credit (#1358) * alphametics: mark computationally intensive test as extra-credit While this test is canonical, it does not technically add additional coverage. This test serves as a test for efficiency (https://github.com/exercism/problem-specifications/pull/1024#issuecomment-347316485) of a solution, not completeness. Furthermore, here are the run-times for this exercise from the [latest Travis build]() (at the time of this writing): | Python Version | Run-time (seconds) | | --- | --- | | 2.7 | 3.155 | | 3.3 | 2.461 | | 3.4 | 3.567 | | 3.5 | 7.270 | | 3.6 | 0.774 | Notice that the optimized example solution is only "fast" in 3.6. * alphametics: add to list of exercises allowed to skip tests in CI bank-account: update README using configlet (#1366) go-counting: update README to latest description (#1367) bracket-push: update tests to v1.3.0 (#1369) isbn-verifier: update tests to v2.4.0 (#1373) * Replace test case - "invalid character in isbn" * Add test case with only 9 digits Python "bowling" test issue. (#1372) Fixes /exercism/python/#1371. yacht: implement exercise (#1368) * yacht: implement exercise * yacht: use enumeration of score categories * Use enumeration instead of plain strings to represent categories * Improve func `ns` in example solution crypto-square: Clarify rectangular output requirement in README (#1375) scale-generator: clarify docs. (#1374) * Removed most mentions of terms that were irrelevant ("diminished interval") or undefined ("accidentals"). * Removed irrelevant table * Some light reformatting --- .github/stale.yml | 1 + config.json | 374 ++++++++++-------- config/exercise_readme.go.tmpl | 21 +- exercises/accumulate/README.md | 21 +- exercises/acronym/README.md | 21 +- exercises/all-your-base/README.md | 21 +- exercises/allergies/README.md | 21 +- exercises/alphametics/README.md | 21 +- exercises/alphametics/alphametics_test.py | 1 + exercises/anagram/README.md | 21 +- exercises/armstrong-numbers/README.md | 21 +- exercises/atbash-cipher/README.md | 21 +- exercises/bank-account/README.md | 72 ++++ exercises/bank-account/bank_account.py | 18 + exercises/bank-account/bank_account_test.py | 120 ++++++ exercises/bank-account/example.py | 35 ++ exercises/beer-song/README.md | 21 +- exercises/binary-search-tree/README.md | 21 +- exercises/binary-search/README.md | 21 +- exercises/binary/README.md | 21 +- exercises/bob/README.md | 21 +- exercises/book-store/README.md | 21 +- exercises/bowling/README.md | 21 +- exercises/bowling/bowling_test.py | 2 +- exercises/bracket-push/README.md | 21 +- exercises/bracket-push/bracket_push_test.py | 5 +- exercises/change/README.md | 21 +- exercises/circular-buffer/README.md | 21 +- exercises/clock/README.md | 21 +- exercises/collatz-conjecture/README.md | 21 +- exercises/complex-numbers/README.md | 21 +- exercises/connect/README.md | 21 +- exercises/crypto-square/README.md | 30 +- exercises/custom-set/README.md | 21 +- exercises/diamond/README.md | 21 +- exercises/difference-of-squares/README.md | 21 +- exercises/diffie-hellman/README.md | 21 +- exercises/dominoes/README.md | 21 +- exercises/dot-dsl/README.md | 21 +- exercises/error-handling/README.md | 21 +- exercises/etl/README.md | 21 +- exercises/flatten-array/README.md | 21 +- exercises/food-chain/README.md | 21 +- exercises/food-chain/example.py | 9 + exercises/food-chain/food_chain.py | 2 +- exercises/food-chain/food_chain_test.py | 159 ++++---- exercises/forth/README.md | 21 +- exercises/gigasecond/README.md | 21 +- exercises/go-counting/README.md | 23 +- exercises/go-counting/example.py | 12 +- exercises/go-counting/go_counting.py | 5 +- exercises/go-counting/go_counting_test.py | 109 ++--- exercises/grade-school/README.md | 21 +- exercises/grains/README.md | 21 +- exercises/grains/grains_test.py | 2 +- exercises/grep/README.md | 21 +- exercises/hamming/README.md | 21 +- exercises/hello-world/README.md | 21 +- exercises/hexadecimal/README.md | 21 +- exercises/house/README.md | 21 +- exercises/house/example.py | 20 +- exercises/house/house_test.py | 283 ++++--------- exercises/isbn-verifier/README.md | 21 +- exercises/isbn-verifier/isbn_verifier_test.py | 7 +- exercises/isogram/README.md | 21 +- exercises/kindergarten-garden/README.md | 21 +- exercises/largest-series-product/README.md | 21 +- exercises/leap/README.md | 21 +- exercises/linked-list/README.md | 21 +- exercises/list-ops/README.md | 21 +- exercises/luhn/README.md | 21 +- exercises/markdown/README.md | 21 +- exercises/matrix/README.md | 21 +- exercises/meetup/README.md | 21 +- exercises/meetup/example.py | 11 +- exercises/meetup/meetup_test.py | 7 +- exercises/minesweeper/README.md | 21 +- exercises/nth-prime/README.md | 21 +- exercises/nucleotide-count/README.md | 21 +- exercises/ocr-numbers/README.md | 21 +- exercises/octal/README.md | 21 +- exercises/palindrome-products/README.md | 21 +- exercises/pangram/README.md | 21 +- exercises/parallel-letter-frequency/README.md | 21 +- exercises/pascals-triangle/README.md | 21 +- exercises/pascals-triangle/example.py | 26 +- .../pascals-triangle/pascals_triangle.py | 10 +- .../pascals-triangle/pascals_triangle_test.py | 72 ++-- exercises/perfect-numbers/README.md | 21 +- exercises/phone-number/README.md | 21 +- exercises/pig-latin/README.md | 29 +- exercises/point-mutations/README.md | 21 +- exercises/poker/README.md | 21 +- exercises/pov/README.md | 21 +- exercises/prime-factors/README.md | 21 +- exercises/protein-translation/README.md | 21 +- exercises/proverb/README.md | 21 +- exercises/pythagorean-triplet/README.md | 21 +- exercises/queen-attack/README.md | 21 +- exercises/queen-attack/example.py | 42 +- exercises/queen-attack/queen_attack.py | 10 +- exercises/queen-attack/queen_attack_test.py | 67 +--- exercises/rail-fence-cipher/README.md | 21 +- exercises/raindrops/README.md | 21 +- exercises/rational-numbers/README.md | 21 +- exercises/react/README.md | 21 +- exercises/rectangles/README.md | 21 +- exercises/reverse-string/README.md | 21 +- exercises/rna-transcription/README.md | 21 +- exercises/robot-name/README.md | 21 +- exercises/robot-simulator/README.md | 21 +- exercises/roman-numerals/README.md | 21 +- exercises/rotational-cipher/README.md | 21 +- exercises/run-length-encoding/README.md | 21 +- exercises/saddle-points/README.md | 21 +- exercises/say/README.md | 21 +- exercises/scale-generator/README.md | 46 ++- exercises/scrabble-score/README.md | 21 +- exercises/secret-handshake/README.md | 21 +- exercises/series/README.md | 21 +- exercises/sgf-parsing/README.md | 110 ++++++ exercises/sgf-parsing/example.py | 100 +++++ exercises/sgf-parsing/sgf_parsing.py | 26 ++ exercises/sgf-parsing/sgf_parsing_test.py | 94 +++++ exercises/sieve/README.md | 21 +- exercises/simple-cipher/README.md | 21 +- exercises/simple-linked-list/README.md | 21 +- exercises/space-age/README.md | 21 +- exercises/spiral-matrix/README.md | 21 +- exercises/strain/README.md | 21 +- exercises/sublist/README.md | 21 +- exercises/sum-of-multiples/README.md | 21 +- exercises/tournament/README.md | 21 +- exercises/transpose/README.md | 21 +- exercises/tree-building/README.md | 21 +- exercises/triangle/README.md | 21 +- exercises/trinary/README.md | 21 +- exercises/twelve-days/README.md | 21 +- exercises/two-bucket/README.md | 23 +- exercises/two-fer/README.md | 21 +- exercises/variable-length-quantity/README.md | 21 +- exercises/word-count/README.md | 21 +- exercises/word-search/README.md | 21 +- exercises/wordy/README.md | 21 +- exercises/yacht/README.md | 85 ++++ exercises/yacht/example.py | 65 +++ exercises/yacht/yacht.py | 18 + exercises/yacht/yacht_test.py | 90 +++++ exercises/zebra-puzzle/README.md | 21 +- exercises/zipper/README.md | 21 +- test/check-exercises.py | 2 +- 151 files changed, 3726 insertions(+), 806 deletions(-) create mode 100644 exercises/bank-account/README.md create mode 100644 exercises/bank-account/bank_account.py create mode 100644 exercises/bank-account/bank_account_test.py create mode 100644 exercises/bank-account/example.py create mode 100644 exercises/sgf-parsing/README.md create mode 100644 exercises/sgf-parsing/example.py create mode 100644 exercises/sgf-parsing/sgf_parsing.py create mode 100644 exercises/sgf-parsing/sgf_parsing_test.py create mode 100644 exercises/yacht/README.md create mode 100644 exercises/yacht/example.py create mode 100644 exercises/yacht/yacht.py create mode 100644 exercises/yacht/yacht_test.py diff --git a/.github/stale.yml b/.github/stale.yml index d03d161912..e17316ffaf 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -9,6 +9,7 @@ exemptLabels: - epic - enhancement - beginner friendly + - awaiting review # Label to use when marking an issue as stale staleLabel: abandoned # Comment to post when marking an issue as stale. Set to `false` to disable diff --git a/config.json b/config.json index cbee3d09ab..0167deb4de 100644 --- a/config.json +++ b/config.json @@ -6,7 +6,7 @@ { "uuid": "f458c48a-4a05-4809-9168-8edd55179349", "slug": "hello-world", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -18,7 +18,7 @@ { "uuid": "b6acda85-5f62-4d9c-bb4f-42b7a360355a", "slug": "leap", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -41,7 +41,7 @@ "uuid": "d1a98c79-d3cc-4035-baab-0e334d2b6a57", "slug": "isogram", "core": false, - "unlocked_by": null, + "unlocked_by": "two-fer", "difficulty": 1, "topics": [ "conditionals", @@ -54,7 +54,7 @@ "uuid": "bebf7ae6-1c35-48bc-926b-e053a975eb10", "slug": "pangram", "core": false, - "unlocked_by": null, + "unlocked_by": "hello-world", "difficulty": 1, "topics": [ "loops", @@ -84,7 +84,7 @@ "uuid": "7961c852-c87a-44b0-b152-efea3ac8555c", "slug": "isbn-verifier", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 1, "topics": [ "type_conversion", @@ -98,7 +98,7 @@ "uuid": "8648fa0c-d85f-471b-a3ae-0f8c05222c89", "slug": "hamming", "core": false, - "unlocked_by": null, + "unlocked_by": "hello-world", "difficulty": 1, "topics": [ "conditionals", @@ -115,7 +115,7 @@ "uuid": "04316811-0bc3-4377-8ff5-5a300ba41d61", "slug": "word-count", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 3, "topics": [ "strings", @@ -139,7 +139,7 @@ { "uuid": "009a80e2-7901-4d3b-9af2-cdcbcc0b49ae", "slug": "bob", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -148,11 +148,26 @@ "conditionals" ] }, + { + "uuid": "22f937e5-52a7-4956-9dde-61c985251a6b", + "slug": "yacht", + "core": false, + "unlocked_by": null, + "difficulty": 1, + "topics": [ + "conditionals", + "equality", + "games", + "integers", + "pattern_matching", + "sequences" + ] + }, { "uuid": "505e7bdb-e18d-45fd-9849-0bf33492efd9", "slug": "run-length-encoding", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 1, "topics": [ "strings", @@ -164,7 +179,7 @@ "uuid": "a5aff23f-7829-403f-843a-d3312dca31e8", "slug": "meetup", "core": false, - "unlocked_by": null, + "unlocked_by": "list-ops", "difficulty": 1, "topics": [ "strings", @@ -178,7 +193,7 @@ "uuid": "e9b0defc-dac5-11e7-9296-cec278b6b50a", "slug": "armstrong-numbers", "core": false, - "unlocked_by": null, + "unlocked_by": "sum-of-multiples", "difficulty": 1, "topics": [ "mathematics", @@ -190,7 +205,7 @@ "uuid": "4c408aab-80b9-475d-9c06-b01cd0fcd08f", "slug": "rotational-cipher", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 1, "topics": [ "strings", @@ -202,17 +217,17 @@ "uuid": "913b6099-d75a-4c27-8243-476081752c31", "slug": "difference-of-squares", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 1, "topics": [ - "mathematics" + "mathematics" ] }, { "uuid": "43eaf8bd-0b4d-4ea9-850a-773f013325ef", "slug": "anagram", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 1, "topics": [ "strings", @@ -224,20 +239,21 @@ { "uuid": "83627e35-4689-4d9b-a81b-284c2c084466", "slug": "allergies", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ "classes", "mathematics", - "bitwise_operations" + "bitwise_operations", + "enumerations" ] }, { "uuid": "aa4c2e85-b8f8-4309-9708-d8ff805054c2", "slug": "series", "core": false, - "unlocked_by": null, + "unlocked_by": "sum-of-multiples", "difficulty": 1, "topics": [ "algorithms", @@ -250,7 +266,7 @@ "uuid": "ca474c47-57bb-4995-bf9a-b6937479de29", "slug": "robot-simulator", "core": false, - "unlocked_by": null, + "unlocked_by": "clock", "difficulty": 1, "topics": [ "algorithms", @@ -265,20 +281,21 @@ "uuid": "ad0192e6-7742-4922-a53e-791e25eb9ba3", "slug": "sieve", "core": false, - "unlocked_by": null, + "unlocked_by": "binary-search", "difficulty": 1, "topics": [ "algorithms", "conditionals", "lists", - "loops" + "loops", + "mathematics" ] }, { "uuid": "02b91a90-244d-479e-a039-0e1d328c0be9", "slug": "atbash-cipher", "core": false, - "unlocked_by": null, + "unlocked_by": "grade-school", "difficulty": 1, "topics": [ "algorithms", @@ -290,7 +307,7 @@ { "uuid": "6e0caa0a-6a1a-4f03-bf0f-e07711f4b069", "slug": "sum-of-multiples", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -302,7 +319,7 @@ "uuid": "038c7f7f-02f6-496f-9e16-9372621cc4cd", "slug": "acronym", "core": false, - "unlocked_by": null, + "unlocked_by": "two-fer", "difficulty": 1, "topics": [ "strings", @@ -313,7 +330,7 @@ "uuid": "2f86ce8e-47c7-4858-89fc-e7729feb0f2f", "slug": "say", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "loops", @@ -326,18 +343,18 @@ "uuid": "21624a3e-6e43-4c0e-94b0-dee5cdaaf2aa", "slug": "largest-series-product", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 1, "topics": [ - "loops", - "logic", - "conditionals" + "loops", + "logic", + "conditionals" ] }, { "uuid": "42a2916c-ef03-44ac-b6d8-7eda375352c2", "slug": "kindergarten-garden", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -345,12 +362,12 @@ "classes", "optional_values", "variables" - ] + ] }, { "uuid": "aadde1a8-ed7a-4242-bfc0-6dddfd382cf3", "slug": "grade-school", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -366,7 +383,7 @@ "uuid": "07481204-fe88-4aa2-995e-d40d1ae15070", "slug": "flatten-array", "core": false, - "unlocked_by": null, + "unlocked_by": "grade-school", "difficulty": 1, "topics": [ "recursion", @@ -379,7 +396,7 @@ "uuid": "bffe2007-717a-44ee-b628-b9c86a5001e8", "slug": "roman-numerals", "core": false, - "unlocked_by": null, + "unlocked_by": "list-ops", "difficulty": 1, "topics": [ "conditionals", @@ -407,7 +424,7 @@ "uuid": "a24e6d34-9952-44f4-a0cd-02c7fedb4875", "slug": "grains", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 1, "topics": [ "bitwise_operations", @@ -420,7 +437,7 @@ "uuid": "34dde040-672e-472f-bf2e-b87b6f9933c0", "slug": "luhn", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 1, "topics": [ "mathematics", @@ -435,7 +452,7 @@ "uuid": "a3b24ef2-303a-494e-8804-e52a67ef406b", "slug": "etl", "core": false, - "unlocked_by": null, + "unlocked_by": "grade-school", "difficulty": 1, "topics": [ "loops", @@ -447,7 +464,7 @@ "uuid": "41dd9178-76b4-4f78-b71a-b5ff8d12645b", "slug": "prime-factors", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 1, "topics": [ "mathematics", @@ -460,7 +477,7 @@ "uuid": "a5bc16da-8d55-4840-9523-686aebbaaa7e", "slug": "pig-latin", "core": false, - "unlocked_by": null, + "unlocked_by": "book-store", "difficulty": 1, "topics": [ "strings", @@ -474,7 +491,7 @@ "uuid": "09b2f396-00d7-4d89-ac47-5c444e00dd99", "slug": "simple-cipher", "core": false, - "unlocked_by": null, + "unlocked_by": "list-ops", "difficulty": 1, "topics": [ "cryptography", @@ -486,20 +503,20 @@ "uuid": "d081446b-f26b-41a2-ab7f-dd7f6736ecfe", "slug": "scrabble-score", "core": false, - "unlocked_by": null, + "unlocked_by": "sum-of-multiples", "difficulty": 1, "topics": [ - "loops", - "strings", - "games", - "maps" + "loops", + "strings", + "games", + "maps" ] }, { "uuid": "e8685468-8006-480f-87c6-6295700def38", "slug": "crypto-square", "core": false, - "unlocked_by": null, + "unlocked_by": "allergies", "difficulty": 1, "topics": [ "strings", @@ -511,7 +528,7 @@ "uuid": "cc5eb848-09bc-458c-8fb6-3a17687cb4eb", "slug": "sublist", "core": false, - "unlocked_by": null, + "unlocked_by": "grade-school", "difficulty": 1, "topics": [ "lists", @@ -523,7 +540,7 @@ "uuid": "7b53865e-a981-46e0-8e47-6f8e1f3854b3", "slug": "pythagorean-triplet", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 1, "topics": [ "conditionals", @@ -545,7 +562,7 @@ "uuid": "77ee3b0e-a4e9-4257-bcfc-ff2c8f1477ab", "slug": "circular-buffer", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 1, "topics": [ "algorithms", @@ -559,7 +576,7 @@ "uuid": "bf30b17f-6b71-4bb5-815a-88f8181b89ae", "slug": "robot-name", "core": false, - "unlocked_by": null, + "unlocked_by": "hello-world", "difficulty": 1, "topics": [ "regular_expressions", @@ -573,7 +590,7 @@ "uuid": "b564927a-f08f-4287-9e8d-9bd5daa7081f", "slug": "matrix", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "loops", @@ -586,32 +603,32 @@ "uuid": "6434cc19-1ea3-43dd-9580-72267ec76b80", "slug": "rail-fence-cipher", "core": false, - "unlocked_by": null, + "unlocked_by": "book-store", "difficulty": 1, "topics": [ - "algorithms", - "cryptography", - "text_formatting", - "lists" + "algorithms", + "cryptography", + "text_formatting", + "lists" ] }, { "uuid": "a20924d2-fe6d-4714-879f-3239feb9d2f2", "slug": "nth-prime", "core": false, - "unlocked_by": null, + "unlocked_by": "book-store", "difficulty": 1, "topics": [ - "algorithms", - "mathematics", - "loops", - "lists" + "algorithms", + "mathematics", + "loops", + "lists" ] }, { "uuid": "71c96c5f-f3b6-4358-a9c6-fc625e2edda2", "slug": "saddle-points", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -628,7 +645,7 @@ "uuid": "b7984882-65df-4993-a878-7872c776592a", "slug": "beer-song", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 1, "topics": [ "loops", @@ -640,10 +657,10 @@ "uuid": "c23ae7a3-3095-4608-8720-ee9ce8938f26", "slug": "perfect-numbers", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 1, "topics": [ - "algorithms", + "algorithms", "loops", "mathematics", "logic" @@ -653,7 +670,7 @@ "uuid": "0d5b2a0e-31ff-4c8c-a155-0406f7dca3ae", "slug": "secret-handshake", "core": false, - "unlocked_by": null, + "unlocked_by": "sum-of-multiples", "difficulty": 1, "topics": [ "conditionals", @@ -670,7 +687,7 @@ "uuid": "d41238ce-359c-4a9a-81ea-ca5d2c4bb50d", "slug": "twelve-days", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 1, "topics": [ "strings", @@ -682,7 +699,7 @@ "uuid": "fa795dcc-d390-4e98-880c-6e8e638485e3", "slug": "palindrome-products", "core": false, - "unlocked_by": null, + "unlocked_by": "saddle-points", "difficulty": 1, "topics": [ "mathematics", @@ -693,7 +710,7 @@ "uuid": "45229a7c-6703-4240-8287-16645881a043", "slug": "bracket-push", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 1, "topics": [ "recursion", @@ -706,7 +723,7 @@ "uuid": "7e768b54-4591-4a30-9ddb-66ca13400ca3", "slug": "minesweeper", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "lists", @@ -720,7 +737,7 @@ "uuid": "b280c252-5320-4e53-8294-1385d564eb02", "slug": "queen-attack", "core": false, - "unlocked_by": null, + "unlocked_by": "clock", "difficulty": 1, "topics": [ "exception_handling", @@ -735,7 +752,7 @@ "uuid": "af50bb9a-e400-49ce-966f-016c31720be1", "slug": "wordy", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "logic", @@ -751,7 +768,7 @@ "uuid": "f384c6f8-987d-41a2-b504-e50506585526", "slug": "phone-number", "core": false, - "unlocked_by": null, + "unlocked_by": "sum-of-multiples", "difficulty": 1, "topics": [ "pattern_matching", @@ -764,7 +781,7 @@ "uuid": "98ca48ed-5818-442c-bce1-308c8b3b3b77", "slug": "ocr-numbers", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "lists", @@ -776,7 +793,7 @@ "uuid": "7c2e93ae-d265-4481-b583-a496608c6031", "slug": "house", "core": false, - "unlocked_by": null, + "unlocked_by": "allergies", "difficulty": 1, "topics": [ "recursion", @@ -789,21 +806,21 @@ "uuid": "f0bc144f-3226-4e53-93ee-e60316b29e31", "slug": "triangle", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 1, "topics": [ - "conditionals", - "pattern_matching", - "classes", - "mathematics", - "object_oriented_programming" + "conditionals", + "pattern_matching", + "classes", + "mathematics", + "object_oriented_programming" ] }, { "uuid": "a9c2fbda-a1e4-42dd-842f-4de5bb361b91", "slug": "dot-dsl", "core": false, - "unlocked_by": null, + "unlocked_by": "clock", "difficulty": 5, "topics": [ "equality", @@ -820,7 +837,7 @@ "uuid": "dc6e61a2-e9b9-4406-ba5c-188252afbba1", "slug": "transpose", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 1, "topics": [ "strings", @@ -832,21 +849,21 @@ "uuid": "aeaed0e4-0973-4035-8bc5-07480849048f", "slug": "tree-building", "core": false, - "unlocked_by": null, + "unlocked_by": "allergies", "difficulty": 3, "topics": [ - "refactoring", - "sorting", - "trees", - "records", - "maps" + "refactoring", + "sorting", + "trees", + "records", + "maps" ] }, { "uuid": "dcc0ee26-e384-4bd4-8c4b-613fa0bb8188", "slug": "poker", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "lists", @@ -859,7 +876,7 @@ "uuid": "7e1d90d5-dbc9-47e0-8e26-c3ff83b73c2b", "slug": "zebra-puzzle", "core": false, - "unlocked_by": null, + "unlocked_by": "book-store", "difficulty": 1, "topics": [ "logic" @@ -869,7 +886,7 @@ "uuid": "4bebdd8d-a032-4993-85c5-7cc74fc89312", "slug": "rectangles", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "algorithms", @@ -880,7 +897,7 @@ { "uuid": "a8288e93-93c5-4e0f-896c-2a376f6f6e5e", "slug": "binary-search", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -894,7 +911,7 @@ { "uuid": "818c6472-b734-4ff4-8016-ce540141faec", "slug": "list-ops", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -911,7 +928,7 @@ { "uuid": "4899b2ef-675f-4d14-b68a-1a457de91276", "slug": "book-store", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -921,22 +938,22 @@ ] }, { - "uuid": "4c6edc8a-7bc0-4386-a653-d1091fe49301", - "slug": "simple-linked-list", - "core": false, - "unlocked_by": null, - "difficulty": 1, - "topics": [ - "lists", - "algorithms", - "conditionals" - ] + "uuid": "4c6edc8a-7bc0-4386-a653-d1091fe49301", + "slug": "simple-linked-list", + "core": false, + "unlocked_by": "clock", + "difficulty": 1, + "topics": [ + "lists", + "algorithms", + "conditionals" + ] }, { "uuid": "ca7a8b16-e5d5-4211-84f0-2f8e35b4a665", "slug": "linked-list", "core": false, - "unlocked_by": "simple-linked-list", + "unlocked_by": "clock", "difficulty": 3, "topics": [ "lists", @@ -949,7 +966,7 @@ "slug": "rational-numbers", "core": false, "unlocked_by": null, - "difficulty": 2, + "difficulty": 5, "topics": [ "equality", "classes", @@ -961,7 +978,7 @@ "uuid": "a7bc6837-59e4-46a1-89a2-a5aa44f5e66e", "slug": "diamond", "core": false, - "unlocked_by": null, + "unlocked_by": "saddle-points", "difficulty": 1, "topics": [ "strings", @@ -973,7 +990,7 @@ "uuid": "aa4332bd-fc38-47a4-8bff-e1b660798418", "slug": "variable-length-quantity", "core": false, - "unlocked_by": null, + "unlocked_by": "allergies", "difficulty": 1, "topics": [ "algorithms", @@ -985,7 +1002,7 @@ "uuid": "a2ff75f9-8b2c-4c4b-975d-913711def9ab", "slug": "all-your-base", "core": false, - "unlocked_by": null, + "unlocked_by": "list-ops", "difficulty": 4, "topics": [ "integers", @@ -995,7 +1012,7 @@ { "uuid": "459fda78-851e-4bb0-a416-953528f46bd7", "slug": "clock", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 2, "topics": [ @@ -1010,7 +1027,7 @@ "uuid": "ecc97fc6-2e72-4325-9b67-b56c83b13a91", "slug": "grep", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 4, "topics": [ "files", @@ -1022,7 +1039,7 @@ "uuid": "ca970fee-71b4-41e1-a5c3-b23bf574eb33", "slug": "bowling", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 5, "topics": [ "classes", @@ -1034,7 +1051,7 @@ "uuid": "dc2917d5-aaa9-43d9-b9f4-a32919fdbe18", "slug": "word-search", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 6, "topics": [ "strings", @@ -1045,7 +1062,7 @@ "uuid": "66466141-485c-470d-b73b-0a3d5a957c3d", "slug": "alphametics", "core": false, - "unlocked_by": null, + "unlocked_by": "book-store", "difficulty": 6, "topics": [ "mathematics", @@ -1057,7 +1074,7 @@ "uuid": "49377a3f-38ba-4d61-b94c-a54cfc9034d0", "slug": "tournament", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "loops", @@ -1070,7 +1087,7 @@ "uuid": "8cd58325-61fc-46fd-85f9-425b4c41f3de", "slug": "scale-generator", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 3, "topics": [ "strings", @@ -1081,7 +1098,7 @@ "uuid": "c89243f3-703e-4fe0-8e43-f200eedf2825", "slug": "protein-translation", "core": false, - "unlocked_by": null, + "unlocked_by": "two-fer", "difficulty": 3, "topics": [ "strings", @@ -1092,7 +1109,7 @@ "uuid": "889df88a-767d-490f-92c4-552d8ec9de34", "slug": "change", "core": false, - "unlocked_by": null, + "unlocked_by": "binary-search", "difficulty": 4, "topics": [ "loops", @@ -1103,7 +1120,7 @@ { "uuid": "4177de10-f767-4306-b45d-5e9c08ef4753", "slug": "two-fer", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 1, "topics": [ @@ -1116,7 +1133,7 @@ "uuid": "f5503274-ac23-11e7-abc4-cec278b6b50a", "slug": "connect", "core": false, - "unlocked_by": null, + "unlocked_by": "kindergarten-garden", "difficulty": 1, "topics": [ "parsing", @@ -1127,34 +1144,36 @@ "uuid": "33f689ee-1d9c-4908-a71c-f84bff3510df", "slug": "collatz-conjecture", "core": false, - "unlocked_by": null, + "unlocked_by": "sum-of-multiples", "difficulty": 1, "topics": [ - "loops" + "loops", + "mathematics" ] }, { "uuid": "d4ddeb18-ac22-11e7-abc4-cec278b6b50a", "slug": "go-counting", "core": false, - "unlocked_by": null, + "unlocked_by": "saddle-points", "difficulty": 4, "topics": [ "parsing", "tuples", - "optional_values", - "classes" + "classes", + "control-flow" ] }, { "uuid": "7f4d5743-7ab8-42ca-b393-767f7e9a4e97", "slug": "complex-numbers", "core": false, - "unlocked_by": null, + "unlocked_by": "leap", "difficulty": 6, "topics": [ "tuples", - "mathematics" + "mathematics", + "equality" ] }, { @@ -1171,29 +1190,31 @@ "uuid": "6f530d0c-d13e-4270-b120-e42c16691a66", "slug": "two-bucket", "core": false, - "unlocked_by": null, + "unlocked_by": "saddle-points", "difficulty": 5, "topics": [ "algorithms", "loops", - "conditionals" + "conditionals", + "control-flow" ] }, { "uuid": "88610b9a-6d3e-4924-a092-6d2f907ed4e2", "slug": "markdown", - "core": false, + "core": true, "unlocked_by": null, "difficulty": 3, "topics": [ - "refactoring" + "refactoring", + "text_formatting" ] }, { "uuid": "14e1dfe3-a45c-40c1-bf61-2e4f0cca5579", "slug": "forth", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 5, "topics": [ "parsing", @@ -1204,7 +1225,7 @@ "uuid": "f229746e-5ea9-4774-b3e0-9b9c2ebf9558", "slug": "food-chain", "core": false, - "unlocked_by": null, + "unlocked_by": "allergies", "difficulty": 4, "topics": [ "algorithms", @@ -1216,19 +1237,19 @@ "uuid": "569210ea-71c1-4fd2-941e-6bf0d953019e", "slug": "zipper", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 8, "topics": [ - "recursion", - "searching", - "trees" + "recursion", + "searching", + "trees" ] }, { "uuid": "0dac0feb-e1c8-497e-9a1b-e96e0523eea6", "slug": "error-handling", "core": false, - "unlocked_by": null, + "unlocked_by": "bob", "difficulty": 3, "topics": [ "exception_handling" @@ -1238,7 +1259,7 @@ "uuid": "54995590-65eb-4178-a527-0d7b1526a843", "slug": "dominoes", "core": false, - "unlocked_by": null, + "unlocked_by": "binary-search", "difficulty": 7, "topics": [ "tuples", @@ -1249,7 +1270,7 @@ "uuid": "d98b1080-36d4-4357-b12a-685d204856bf", "slug": "pov", "core": false, - "unlocked_by": null, + "unlocked_by": "markdown", "difficulty": 9, "topics": [ "graphs", @@ -1262,20 +1283,21 @@ "uuid": "4c0d0d6b-347e-40ae-9b51-08555fe76cb9", "slug": "react", "core": false, - "unlocked_by": null, + "unlocked_by": "saddle-points", "difficulty": 8, "topics": [ "events", - "reactive_programming" + "reactive_programming", + "callbacks" ] }, { "uuid": "df7cd9b9-283a-4466-accf-98c4a7609450", "slug": "binary-search-tree", "core": false, - "unlocked_by": null, + "unlocked_by": "grade-school", "difficulty": 4, - "topics":[ + "topics": [ "recursion", "classes", "trees", @@ -1284,26 +1306,49 @@ ] }, { - "uuid": "bb07c236-062c-2980-483a-a221e4724445dcd6f32", - "slug": "custom-set", - "core": false, - "unlocked_by": null, - "difficulty": 5, - "topics": [ - "sets" - ] + "uuid": "bb07c236-062c-2980-483a-a221e4724445dcd6f32", + "slug": "custom-set", + "core": false, + "unlocked_by": "book-store", + "difficulty": 5, + "topics": [ + "sets" + ] }, { - "uuid": "b0c7cf95-6470-4c1a-8eaa-6775310926a2", - "slug": "spiral-matrix", - "core": false, - "unlocked_by": null, - "difficulty": 2, - "topics": [ - "algorithms", - "control-flow", - "lists" - ] + "uuid": "b0c7cf95-6470-4c1a-8eaa-6775310926a2", + "slug": "spiral-matrix", + "core": false, + "unlocked_by": "saddle-points", + "difficulty": 2, + "topics": [ + "algorithms", + "control-flow", + "lists" + ] + }, + { + "uuid": "0d6325d1-c0a3-456e-9a92-cea0559e82ed", + "slug": "sgf-parsing", + "core": false, + "unlocked_by": null, + "difficulty": 7, + "topics": [ + "parsing", + "trees" + ] + }, + { + "uuid": "83a3ff95-c043-401c-bc2c-547d52344b02", + "slug": "bank-account", + "core": false, + "unlocked_by": null, + "difficulty": 4, + "topics": [ + "classes", + "concurrency", + "conditionals" + ] }, { "uuid": "e7351e8e-d3ff-4621-b818-cd55cf05bffd", @@ -1365,5 +1410,8 @@ "slug": "parallel-letter-frequency", "deprecated": true } + ], + "foregone": [ + "lens-person" ] } diff --git a/config/exercise_readme.go.tmpl b/config/exercise_readme.go.tmpl index ab739fb652..b0aa1d02e1 100644 --- a/config/exercise_readme.go.tmpl +++ b/config/exercise_readme.go.tmpl @@ -12,12 +12,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test {{ .Spec.SnakeCaseName }}_test.py` +- Python 3.3+: `pytest {{ .Spec.SnakeCaseName }}_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest {{ .Spec.SnakeCaseName }}_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/{{ .Spec.Slug }}` directory. @@ -32,4 +50,5 @@ please see the [help page](http://exercism.io/languages/python). {{ . }} {{ end }} ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/accumulate/README.md b/exercises/accumulate/README.md index 1acacb0bdb..03eb72f7f2 100644 --- a/exercises/accumulate/README.md +++ b/exercises/accumulate/README.md @@ -33,12 +33,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test accumulate_test.py` +- Python 3.3+: `pytest accumulate_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest accumulate_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/accumulate` directory. @@ -53,4 +71,5 @@ please see the [help page](http://exercism.io/languages/python). Conversation with James Edward Gray II [https://twitter.com/jeg2](https://twitter.com/jeg2) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/acronym/README.md b/exercises/acronym/README.md index 2ad35ef586..13c3f3b795 100644 --- a/exercises/acronym/README.md +++ b/exercises/acronym/README.md @@ -15,12 +15,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test acronym_test.py` +- Python 3.3+: `pytest acronym_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest acronym_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/acronym` directory. @@ -35,4 +53,5 @@ please see the [help page](http://exercism.io/languages/python). Julien Vanier [https://github.com/monkbroc](https://github.com/monkbroc) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/all-your-base/README.md b/exercises/all-your-base/README.md index ebd6c33611..5f4d2d0130 100644 --- a/exercises/all-your-base/README.md +++ b/exercises/all-your-base/README.md @@ -39,12 +39,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test all_your_base_test.py` +- Python 3.3+: `pytest all_your_base_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest all_your_base_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/all-your-base` directory. @@ -55,4 +73,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/allergies/README.md b/exercises/allergies/README.md index 732046d586..25ffea6304 100644 --- a/exercises/allergies/README.md +++ b/exercises/allergies/README.md @@ -37,12 +37,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test allergies_test.py` +- Python 3.3+: `pytest allergies_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest allergies_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/allergies` directory. @@ -57,4 +75,5 @@ please see the [help page](http://exercism.io/languages/python). Jumpstart Lab Warm-up [http://jumpstartlab.com](http://jumpstartlab.com) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/alphametics/README.md b/exercises/alphametics/README.md index ab43458410..995a500419 100644 --- a/exercises/alphametics/README.md +++ b/exercises/alphametics/README.md @@ -39,12 +39,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test alphametics_test.py` +- Python 3.3+: `pytest alphametics_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest alphametics_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/alphametics` directory. @@ -55,4 +73,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/alphametics/alphametics_test.py b/exercises/alphametics/alphametics_test.py index c8afec3456..be4899c5bc 100644 --- a/exercises/alphametics/alphametics_test.py +++ b/exercises/alphametics/alphametics_test.py @@ -66,6 +66,7 @@ def test_puzzle_with_ten_letters(self): "S": 6, "T": 9}) + @unittest.skip("extra-credit") def test_puzzle_with_ten_letters_and_199_addends(self): self.assertEqual( solve( diff --git a/exercises/anagram/README.md b/exercises/anagram/README.md index 308803797d..6a44944a23 100644 --- a/exercises/anagram/README.md +++ b/exercises/anagram/README.md @@ -14,12 +14,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test anagram_test.py` +- Python 3.3+: `pytest anagram_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest anagram_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/anagram` directory. @@ -34,4 +52,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/armstrong-numbers/README.md b/exercises/armstrong-numbers/README.md index 94fbb9c3db..8207b92a6e 100644 --- a/exercises/armstrong-numbers/README.md +++ b/exercises/armstrong-numbers/README.md @@ -19,12 +19,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test armstrong_numbers_test.py` +- Python 3.3+: `pytest armstrong_numbers_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest armstrong_numbers_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/armstrong-numbers` directory. @@ -39,4 +57,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Narcissistic_number](https://en.wikipedia.org/wiki/Narcissistic_number) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/atbash-cipher/README.md b/exercises/atbash-cipher/README.md index d30ef2c348..825e1d06ec 100644 --- a/exercises/atbash-cipher/README.md +++ b/exercises/atbash-cipher/README.md @@ -36,12 +36,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test atbash_cipher_test.py` +- Python 3.3+: `pytest atbash_cipher_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest atbash_cipher_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/atbash-cipher` directory. @@ -56,4 +74,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [http://en.wikipedia.org/wiki/Atbash](http://en.wikipedia.org/wiki/Atbash) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/bank-account/README.md b/exercises/bank-account/README.md new file mode 100644 index 0000000000..2fc585d38a --- /dev/null +++ b/exercises/bank-account/README.md @@ -0,0 +1,72 @@ +# Bank Account + +Simulate a bank account supporting opening/closing, withdrawals, and deposits +of money. Watch out for concurrent transactions! + +A bank account can be accessed in multiple ways. Clients can make +deposits and withdrawals using the internet, mobile phones, etc. Shops +can charge against the account. + +Create an account that can be accessed from multiple threads/processes +(terminology depends on your programming language). + +It should be possible to close an account; operations against a closed +account must fail. + +## Instructions + +Run the test file, and fix each of the errors in turn. When you get the +first test to pass, go to the first pending or skipped test, and make +that pass as well. When all of the tests are passing, feel free to +submit. + +Remember that passing code is just the first step. The goal is to work +towards a solution that is as readable and expressive as you can make +it. + +Have fun! + +## Exception messages + +Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to +indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not +every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include +a message. + +To raise a message with an exception, just write it as an argument to the exception type. For example, instead of +`raise Exception`, you should write: + +```python +raise Exception("Meaningful message indicating the source of the error") +``` + +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test bank_account_test.py` +- Python 3.3+: `pytest bank_account_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest bank_account_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + +## Submitting Exercises + +Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/bank-account` directory. + +You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`. + +For more detailed information about running tests, code style and linting, +please see the [help page](http://exercism.io/languages/python). + +## Submitting Incomplete Solutions + +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/bank-account/bank_account.py b/exercises/bank-account/bank_account.py new file mode 100644 index 0000000000..fab129e36f --- /dev/null +++ b/exercises/bank-account/bank_account.py @@ -0,0 +1,18 @@ +class BankAccount(object): + def __init__(self): + pass + + def get_balance(self): + pass + + def open(self): + pass + + def deposit(self, amount): + pass + + def withdraw(self, amount): + pass + + def close(self): + pass diff --git a/exercises/bank-account/bank_account_test.py b/exercises/bank-account/bank_account_test.py new file mode 100644 index 0000000000..8879c76b18 --- /dev/null +++ b/exercises/bank-account/bank_account_test.py @@ -0,0 +1,120 @@ +import sys +import threading +import time +import unittest + +from bank_account import BankAccount + + +class BankAccountTests(unittest.TestCase): + + def setUp(self): + self.account = BankAccount() + + def test_newly_opened_account_has_zero_balance(self): + self.account.open() + self.assertEqual(self.account.get_balance(), 0) + + def test_can_deposit_money(self): + self.account.open() + self.account.deposit(100) + self.assertEqual(self.account.get_balance(), 100) + + def test_can_deposit_money_sequentially(self): + self.account.open() + self.account.deposit(100) + self.account.deposit(50) + + self.assertEqual(self.account.get_balance(), 150) + + def test_can_withdraw_money(self): + self.account.open() + self.account.deposit(100) + self.account.withdraw(50) + + self.assertEqual(self.account.get_balance(), 50) + + def test_can_withdraw_money_sequentially(self): + self.account.open() + self.account.deposit(100) + self.account.withdraw(20) + self.account.withdraw(80) + + self.assertEqual(self.account.get_balance(), 0) + + def test_checking_balance_of_closed_account_throws_error(self): + self.account.open() + self.account.close() + + with self.assertRaises(ValueError): + self.account.get_balance() + + def test_deposit_into_closed_account(self): + self.account.open() + self.account.close() + + with self.assertRaises(ValueError): + self.account.deposit(50) + + def test_withdraw_from_closed_account(self): + self.account.open() + self.account.close() + + with self.assertRaises(ValueError): + self.account.withdraw(50) + + def test_cannot_withdraw_more_than_deposited(self): + self.account.open() + self.account.deposit(25) + + with self.assertRaises(ValueError): + self.account.withdraw(50) + + def test_cannot_withdraw_negative(self): + self.account.open() + self.account.deposit(100) + + with self.assertRaises(ValueError): + self.account.withdraw(-50) + + def test_cannot_deposit_negative(self): + self.account.open() + + with self.assertRaises(ValueError): + self.account.deposit(-50) + + def test_can_handle_concurrent_transactions(self): + self.account.open() + self.account.deposit(1000) + + for _ in range(10): + self.adjust_balance_concurrently() + + def adjust_balance_concurrently(self): + def transact(): + self.account.deposit(5) + time.sleep(0.001) + self.account.withdraw(5) + + # Greatly improve the chance of an operation being interrupted + # by thread switch, thus testing synchronization effectively + try: + sys.setswitchinterval(1e-12) + except AttributeError: + # For Python 2 compatibility + sys.setcheckinterval(1) + + threads = [] + for _ in range(1000): + t = threading.Thread(target=transact) + threads.append(t) + t.start() + + for thread in threads: + thread.join() + + self.assertEqual(self.account.get_balance(), 1000) + + +if __name__ == '__main__': + unittest.main() diff --git a/exercises/bank-account/example.py b/exercises/bank-account/example.py new file mode 100644 index 0000000000..55b6f9ff8d --- /dev/null +++ b/exercises/bank-account/example.py @@ -0,0 +1,35 @@ +import threading + + +class BankAccount(object): + def __init__(self): + self.is_open = False + self.balance = 0 + self.lock = threading.Lock() + + def get_balance(self): + with self.lock: + if self.is_open: + return self.balance + else: + raise ValueError + + def open(self): + self.is_open = True + + def deposit(self, amount): + with self.lock: + if self.is_open and amount > 0: + self.balance += amount + else: + raise ValueError + + def withdraw(self, amount): + with self.lock: + if self.is_open and 0 < amount <= self.balance: + self.balance -= amount + else: + raise ValueError + + def close(self): + self.is_open = False diff --git a/exercises/beer-song/README.md b/exercises/beer-song/README.md index d7f9cb6200..80694cf352 100644 --- a/exercises/beer-song/README.md +++ b/exercises/beer-song/README.md @@ -328,12 +328,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test beer_song_test.py` +- Python 3.3+: `pytest beer_song_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest beer_song_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/beer-song` directory. @@ -348,4 +366,5 @@ please see the [help page](http://exercism.io/languages/python). Learn to Program by Chris Pine [http://pine.fm/LearnToProgram/?Chapter=06](http://pine.fm/LearnToProgram/?Chapter=06) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/binary-search-tree/README.md b/exercises/binary-search-tree/README.md index 6a9de9c342..1e2deee9af 100644 --- a/exercises/binary-search-tree/README.md +++ b/exercises/binary-search-tree/README.md @@ -61,12 +61,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test binary_search_tree_test.py` +- Python 3.3+: `pytest binary_search_tree_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest binary_search_tree_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/binary-search-tree` directory. @@ -81,4 +99,5 @@ please see the [help page](http://exercism.io/languages/python). Josh Cheek [https://twitter.com/josh_cheek](https://twitter.com/josh_cheek) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/binary-search/README.md b/exercises/binary-search/README.md index e1ff286962..223a9a25f1 100644 --- a/exercises/binary-search/README.md +++ b/exercises/binary-search/README.md @@ -42,12 +42,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test binary_search_test.py` +- Python 3.3+: `pytest binary_search_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest binary_search_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/binary-search` directory. @@ -62,4 +80,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [http://en.wikipedia.org/wiki/Binary_search_algorithm](http://en.wikipedia.org/wiki/Binary_search_algorithm) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/binary/README.md b/exercises/binary/README.md index dbaebb5db9..7b66423614 100644 --- a/exercises/binary/README.md +++ b/exercises/binary/README.md @@ -38,12 +38,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test binary_test.py` +- Python 3.3+: `pytest binary_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest binary_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/binary` directory. @@ -58,4 +76,5 @@ please see the [help page](http://exercism.io/languages/python). All of Computer Science [http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-](http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/bob/README.md b/exercises/bob/README.md index 2fcee0a913..c7d4f0b113 100644 --- a/exercises/bob/README.md +++ b/exercises/bob/README.md @@ -21,12 +21,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test bob_test.py` +- Python 3.3+: `pytest bob_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest bob_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/bob` directory. @@ -41,4 +59,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=06](http://pine.fm/LearnToProgram/?Chapter=06) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/book-store/README.md b/exercises/book-store/README.md index 483e561477..f4a532f931 100644 --- a/exercises/book-store/README.md +++ b/exercises/book-store/README.md @@ -75,12 +75,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test book_store_test.py` +- Python 3.3+: `pytest book_store_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest book_store_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/book-store` directory. @@ -95,4 +113,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by the harry potter kata from Cyber-Dojo. [http://cyber-dojo.org](http://cyber-dojo.org) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/bowling/README.md b/exercises/bowling/README.md index 71a84607a2..a217b90e3f 100644 --- a/exercises/bowling/README.md +++ b/exercises/bowling/README.md @@ -68,12 +68,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test bowling_test.py` +- Python 3.3+: `pytest bowling_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest bowling_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/bowling` directory. @@ -88,4 +106,5 @@ please see the [help page](http://exercism.io/languages/python). The Bowling Game Kata at but UncleBob [http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata](http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/bowling/bowling_test.py b/exercises/bowling/bowling_test.py index 46bc871fb0..67f8f6b651 100644 --- a/exercises/bowling/bowling_test.py +++ b/exercises/bowling/bowling_test.py @@ -119,7 +119,7 @@ def test_all_strikes_is_a_perfect_game(self): def test_rolls_cannot_score_negative_points(self): with self.assertRaisesWithMessage(ValueError): - self.game.roll(11) + self.game.roll(-1) def test_a_roll_cannot_score_more_than_10_points(self): diff --git a/exercises/bracket-push/README.md b/exercises/bracket-push/README.md index 620ee97a57..7d264690bd 100644 --- a/exercises/bracket-push/README.md +++ b/exercises/bracket-push/README.md @@ -11,12 +11,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test bracket_push_test.py` +- Python 3.3+: `pytest bracket_push_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest bracket_push_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/bracket-push` directory. @@ -31,4 +49,5 @@ please see the [help page](http://exercism.io/languages/python). Ginna Baker ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/bracket-push/bracket_push_test.py b/exercises/bracket-push/bracket_push_test.py index bb7b19078c..19b7790f84 100644 --- a/exercises/bracket-push/bracket_push_test.py +++ b/exercises/bracket-push/bracket_push_test.py @@ -3,7 +3,7 @@ from bracket_push import is_paired -# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0 +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.3.0 class BracketPushTests(unittest.TestCase): def test_paired_square_brackets(self): @@ -24,6 +24,9 @@ def test_wrong_closing_bracket(self): def test_paired_with_whitespace(self): self.assertEqual(is_paired("{ }"), True) + def test_partially_paired_brackets(self): + self.assertEqual(is_paired("{[])"), False) + def test_simple_nested_brackets(self): self.assertEqual(is_paired("{[]}"), True) diff --git a/exercises/change/README.md b/exercises/change/README.md index 07824338b6..33f09a97be 100644 --- a/exercises/change/README.md +++ b/exercises/change/README.md @@ -24,12 +24,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test change_test.py` +- Python 3.3+: `pytest change_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest change_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/change` directory. @@ -44,4 +62,5 @@ please see the [help page](http://exercism.io/languages/python). Software Craftsmanship - Coin Change Kata [https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata](https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/circular-buffer/README.md b/exercises/circular-buffer/README.md index b0d71e3c68..3dcd0595e8 100644 --- a/exercises/circular-buffer/README.md +++ b/exercises/circular-buffer/README.md @@ -58,12 +58,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test circular_buffer_test.py` +- Python 3.3+: `pytest circular_buffer_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest circular_buffer_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/circular-buffer` directory. @@ -78,4 +96,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [http://en.wikipedia.org/wiki/Circular_buffer](http://en.wikipedia.org/wiki/Circular_buffer) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/clock/README.md b/exercises/clock/README.md index 696ff897b4..3cc70cf544 100644 --- a/exercises/clock/README.md +++ b/exercises/clock/README.md @@ -14,12 +14,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test clock_test.py` +- Python 3.3+: `pytest clock_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest clock_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/clock` directory. @@ -34,4 +52,5 @@ please see the [help page](http://exercism.io/languages/python). Pairing session with Erin Drummond [https://twitter.com/ebdrummond](https://twitter.com/ebdrummond) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/collatz-conjecture/README.md b/exercises/collatz-conjecture/README.md index 6180a0485a..2033352e2c 100644 --- a/exercises/collatz-conjecture/README.md +++ b/exercises/collatz-conjecture/README.md @@ -39,12 +39,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test collatz_conjecture_test.py` +- Python 3.3+: `pytest collatz_conjecture_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest collatz_conjecture_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/collatz-conjecture` directory. @@ -59,4 +77,5 @@ please see the [help page](http://exercism.io/languages/python). An unsolved problem in mathematics named after mathematician Lothar Collatz [https://en.wikipedia.org/wiki/3x_%2B_1_problem](https://en.wikipedia.org/wiki/3x_%2B_1_problem) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/complex-numbers/README.md b/exercises/complex-numbers/README.md index 33adff16c9..be915be539 100644 --- a/exercises/complex-numbers/README.md +++ b/exercises/complex-numbers/README.md @@ -44,12 +44,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test complex_numbers_test.py` +- Python 3.3+: `pytest complex_numbers_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest complex_numbers_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/complex-numbers` directory. @@ -64,4 +82,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Complex_number](https://en.wikipedia.org/wiki/Complex_number) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/connect/README.md b/exercises/connect/README.md index 2e3ed952a7..b5c1799092 100644 --- a/exercises/connect/README.md +++ b/exercises/connect/README.md @@ -38,12 +38,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test connect_test.py` +- Python 3.3+: `pytest connect_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest connect_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/connect` directory. @@ -54,4 +72,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/crypto-square/README.md b/exercises/crypto-square/README.md index 93953dbed4..35e2f2eabe 100644 --- a/exercises/crypto-square/README.md +++ b/exercises/crypto-square/README.md @@ -45,11 +45,10 @@ The message above is coded as: imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau ``` -Output the encoded text in chunks. Phrases that fill perfect rectangles -`(r X c)` should be output `c` chunks of `r` length, separated by spaces. -Phrases that do not fill perfect rectangles will have `n` empty spaces. -Those spaces should be distributed evenly, added to the end of the last -`n` chunks. +Output the encoded text in chunks that fill perfect rectangles `(r X c)`, +with `c` chunks of `r` length, separated by spaces. For phrases that are +`n` characters short of the perfect rectangle, pad each of the last `n` +chunks with a single trailing space. ```text imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau @@ -77,12 +76,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test crypto_square_test.py` +- Python 3.3+: `pytest crypto_square_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest crypto_square_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/crypto-square` directory. @@ -97,4 +114,5 @@ please see the [help page](http://exercism.io/languages/python). J Dalbey's Programming Practice problems [http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html](http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/custom-set/README.md b/exercises/custom-set/README.md index 4a4a2b7b77..ee82d4b921 100644 --- a/exercises/custom-set/README.md +++ b/exercises/custom-set/README.md @@ -15,12 +15,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test custom_set_test.py` +- Python 3.3+: `pytest custom_set_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest custom_set_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/custom-set` directory. @@ -31,4 +49,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/diamond/README.md b/exercises/diamond/README.md index 408172c32a..03315ade75 100644 --- a/exercises/diamond/README.md +++ b/exercises/diamond/README.md @@ -60,12 +60,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test diamond_test.py` +- Python 3.3+: `pytest diamond_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest diamond_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/diamond` directory. @@ -80,4 +98,5 @@ please see the [help page](http://exercism.io/languages/python). Seb Rose [http://claysnow.co.uk/recycling-tests-in-tdd/](http://claysnow.co.uk/recycling-tests-in-tdd/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/difference-of-squares/README.md b/exercises/difference-of-squares/README.md index 027d8c484f..4b28042310 100644 --- a/exercises/difference-of-squares/README.md +++ b/exercises/difference-of-squares/README.md @@ -20,12 +20,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test difference_of_squares_test.py` +- Python 3.3+: `pytest difference_of_squares_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest difference_of_squares_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/difference-of-squares` directory. @@ -40,4 +58,5 @@ please see the [help page](http://exercism.io/languages/python). Problem 6 at Project Euler [http://projecteuler.net/problem=6](http://projecteuler.net/problem=6) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/diffie-hellman/README.md b/exercises/diffie-hellman/README.md index d7c1bc5ff5..f5b49aa207 100644 --- a/exercises/diffie-hellman/README.md +++ b/exercises/diffie-hellman/README.md @@ -62,12 +62,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test diffie_hellman_test.py` +- Python 3.3+: `pytest diffie_hellman_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest diffie_hellman_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/diffie-hellman` directory. @@ -82,4 +100,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia, 1024 bit key from www.cryptopp.com/wiki. [http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange](http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/dominoes/README.md b/exercises/dominoes/README.md index eace049598..86b1d321c5 100644 --- a/exercises/dominoes/README.md +++ b/exercises/dominoes/README.md @@ -22,12 +22,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test dominoes_test.py` +- Python 3.3+: `pytest dominoes_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest dominoes_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/dominoes` directory. @@ -38,4 +56,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/dot-dsl/README.md b/exercises/dot-dsl/README.md index 2a39752f28..2964d08f48 100644 --- a/exercises/dot-dsl/README.md +++ b/exercises/dot-dsl/README.md @@ -48,12 +48,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test dot_dsl_test.py` +- Python 3.3+: `pytest dot_dsl_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest dot_dsl_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/dot-dsl` directory. @@ -64,4 +82,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/error-handling/README.md b/exercises/error-handling/README.md index 338aca7ff2..6fdbed5a04 100644 --- a/exercises/error-handling/README.md +++ b/exercises/error-handling/README.md @@ -27,12 +27,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test error_handling_test.py` +- Python 3.3+: `pytest error_handling_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest error_handling_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/error-handling` directory. @@ -43,4 +61,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/etl/README.md b/exercises/etl/README.md index 833de31eed..4e8483a9eb 100644 --- a/exercises/etl/README.md +++ b/exercises/etl/README.md @@ -54,12 +54,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test etl_test.py` +- Python 3.3+: `pytest etl_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest etl_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/etl` directory. @@ -74,4 +92,5 @@ please see the [help page](http://exercism.io/languages/python). The Jumpstart Lab team [http://jumpstartlab.com](http://jumpstartlab.com) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/flatten-array/README.md b/exercises/flatten-array/README.md index 8063da56e9..ce4aee287f 100644 --- a/exercises/flatten-array/README.md +++ b/exercises/flatten-array/README.md @@ -18,12 +18,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test flatten_array_test.py` +- Python 3.3+: `pytest flatten_array_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest flatten_array_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/flatten-array` directory. @@ -38,4 +56,5 @@ please see the [help page](http://exercism.io/languages/python). Interview Question [https://reference.wolfram.com/language/ref/Flatten.html](https://reference.wolfram.com/language/ref/Flatten.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/food-chain/README.md b/exercises/food-chain/README.md index c7531d2e96..4fe50ad6ad 100644 --- a/exercises/food-chain/README.md +++ b/exercises/food-chain/README.md @@ -71,12 +71,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test food_chain_test.py` +- Python 3.3+: `pytest food_chain_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest food_chain_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/food-chain` directory. @@ -91,4 +109,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [http://en.wikipedia.org/wiki/There_Was_an_Old_Lady_Who_Swallowed_a_Fly](http://en.wikipedia.org/wiki/There_Was_an_Old_Lady_Who_Swallowed_a_Fly) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/food-chain/example.py b/exercises/food-chain/example.py index 5deb43a94f..b5a701e694 100644 --- a/exercises/food-chain/example.py +++ b/exercises/food-chain/example.py @@ -43,3 +43,12 @@ def chain(): song += verse return song + + +def verses(letter): + return letter.replace('die.', 'die.slice').split('slice') + + +def recite(start_verse, end_verse): + generated = [verse.replace("\n", "") for verse in verses(chain())] + return generated[start_verse-1:end_verse] diff --git a/exercises/food-chain/food_chain.py b/exercises/food-chain/food_chain.py index fe6bd97378..ed87e69c4e 100644 --- a/exercises/food-chain/food_chain.py +++ b/exercises/food-chain/food_chain.py @@ -1,2 +1,2 @@ -def chain(): +def recite(start_verse, end_verse): pass diff --git a/exercises/food-chain/food_chain_test.py b/exercises/food-chain/food_chain_test.py index 100e37ae33..19afcacc57 100644 --- a/exercises/food-chain/food_chain_test.py +++ b/exercises/food-chain/food_chain_test.py @@ -1,108 +1,107 @@ import unittest -from food_chain import chain - -# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0 - -song = """I know an old lady who swallowed a fly. -I don't know why she swallowed the fly. Perhaps she'll die. - -I know an old lady who swallowed a spider. -It wriggled and jiggled and tickled inside her. -She swallowed the spider to catch the fly. -I don't know why she swallowed the fly. Perhaps she'll die. - -I know an old lady who swallowed a bird. -How absurd to swallow a bird! -She swallowed the bird to catch the spider that wriggled -and jiggled and tickled inside her. -She swallowed the spider to catch the fly. -I don't know why she swallowed the fly. Perhaps she'll die. - -I know an old lady who swallowed a cat. -Imagine that, to swallow a cat! -She swallowed the cat to catch the bird. -She swallowed the bird to catch the spider that wriggled -and jiggled and tickled inside her. -She swallowed the spider to catch the fly. -I don't know why she swallowed the fly. Perhaps she'll die. - -I know an old lady who swallowed a dog. -What a hog, to swallow a dog! -She swallowed the dog to catch the cat. -She swallowed the cat to catch the bird. -She swallowed the bird to catch the spider that wriggled -and jiggled and tickled inside her. -She swallowed the spider to catch the fly. -I don't know why she swallowed the fly. Perhaps she'll die. - -I know an old lady who swallowed a goat. -Just opened her throat and swallowed a goat! -She swallowed the goat to catch the dog. -She swallowed the dog to catch the cat. -She swallowed the cat to catch the bird. -She swallowed the bird to catch the spider that wriggled -and jiggled and tickled inside her. -She swallowed the spider to catch the fly. -I don't know why she swallowed the fly. Perhaps she'll die. - -I know an old lady who swallowed a cow. -I don't know how she swallowed a cow! -She swallowed the cow to catch the goat. -She swallowed the goat to catch the dog. -She swallowed the dog to catch the cat. -She swallowed the cat to catch the bird. -She swallowed the bird to catch the spider that wriggled -and jiggled and tickled inside her. -She swallowed the spider to catch the fly. -I don't know why she swallowed the fly. Perhaps she'll die. - -I know an old lady who swallowed a horse. -She's dead, of course!""" - - -def verses(letter): - return letter.replace('die.', 'die.slice').split('slice') - - -original = [verse.replace("\n", "").replace(" ", "").lower() - for verse in verses(song)] - -generated = [verse.replace("\n", "").replace(" ", "").lower() - for verse in verses(chain())] +from food_chain import recite +# Tests adapted from `problem-specifications//canonical-data.json` @ v2.1.0 + class FoodChainTest(unittest.TestCase): def test_fly(self): - self.assertEqual(original[0], generated[0]) + expected = [ + "I know an old lady who swallowed a fly." + "I don't know why she swallowed the fly. Perhaps she'll die." + ] + self.assertEqual(recite(1, 1), expected) def test_spider(self): - self.assertEqual(original[1], generated[1]) + expected = [ + "I know an old lady who swallowed a spider." + "It wriggled and jiggled and tickled inside her." + "She swallowed the spider to catch the fly." + "I don't know why she swallowed the fly. Perhaps she'll die." + ] + self.assertEqual(recite(2, 2), expected) def test_bird(self): - self.assertEqual(original[2], generated[2]) + expected = [ + "I know an old lady who swallowed a bird." + "How absurd to swallow a bird!" + "She swallowed the bird to catch the spider that " + "wriggled and jiggled and tickled inside her." + "She swallowed the spider to catch the fly." + "I don't know why she swallowed the fly. Perhaps she'll die." + ] + self.assertEqual(recite(3, 3), expected) def test_cat(self): - self.assertEqual(original[3], generated[3]) + expected = [ + "I know an old lady who swallowed a cat." + "Imagine that, to swallow a cat!" + "She swallowed the cat to catch the bird." + "She swallowed the bird to catch the spider that " + "wriggled and jiggled and tickled inside her." + "She swallowed the spider to catch the fly." + "I don't know why she swallowed the fly. Perhaps she'll die." + ] + self.assertEqual(recite(4, 4), expected) def test_dog(self): - self.assertEqual(original[4], generated[4]) + expected = [ + "I know an old lady who swallowed a dog." + "What a hog, to swallow a dog!" + "She swallowed the dog to catch the cat." + "She swallowed the cat to catch the bird." + "She swallowed the bird to catch the spider that wriggled " + "and jiggled and tickled inside her." + "She swallowed the spider to catch the fly." + "I don't know why she swallowed the fly. Perhaps she'll die." + ] + self.assertEqual(recite(5, 5), expected) def test_goat(self): - self.assertEqual(original[5], generated[5]) + expected = [ + "I know an old lady who swallowed a goat." + "Just opened her throat and swallowed a goat!" + "She swallowed the goat to catch the dog." + "She swallowed the dog to catch the cat." + "She swallowed the cat to catch the bird." + "She swallowed the bird to catch the spider that " + "wriggled and jiggled and tickled inside her." + "She swallowed the spider to catch the fly." + "I don't know why she swallowed the fly. Perhaps she'll die." + ] + self.assertEqual(recite(6, 6), expected) def test_cow(self): - self.assertEqual(original[6], generated[6]) + expected = [ + "I know an old lady who swallowed a cow." + "I don't know how she swallowed a cow!" + "She swallowed the cow to catch the goat." + "She swallowed the goat to catch the dog." + "She swallowed the dog to catch the cat." + "She swallowed the cat to catch the bird." + "She swallowed the bird to catch the spider that " + "wriggled and jiggled and tickled inside her." + "She swallowed the spider to catch the fly." + "I don't know why she swallowed the fly. Perhaps she'll die." + ] + self.assertEqual(recite(7, 7), expected) def test_horse(self): - self.assertEqual(original[7], generated[7]) + expected = [ + "I know an old lady who swallowed a horse." + "She's dead, of course!" + ] + self.assertEqual(recite(8, 8), expected) def test_multiple_verses(self): - self.assertEqual(original[0:3], generated[0:3]) + expected = [recite(n, n)[0] for n in range(1, 4)] + self.assertEqual(recite(1, 3), expected) def test_full_song(self): - self.assertEqual(original, generated) + expected = [recite(n, n)[0] for n in range(1, 9)] + self.assertEqual(recite(1, 8), expected) if __name__ == '__main__': diff --git a/exercises/forth/README.md b/exercises/forth/README.md index 80643cc8e3..0f079a7837 100644 --- a/exercises/forth/README.md +++ b/exercises/forth/README.md @@ -33,12 +33,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test forth_test.py` +- Python 3.3+: `pytest forth_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest forth_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/forth` directory. @@ -49,4 +67,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/gigasecond/README.md b/exercises/gigasecond/README.md index 90b5e14796..bcbf0382a1 100644 --- a/exercises/gigasecond/README.md +++ b/exercises/gigasecond/README.md @@ -12,12 +12,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test gigasecond_test.py` +- Python 3.3+: `pytest gigasecond_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest gigasecond_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/gigasecond` directory. @@ -32,4 +50,5 @@ please see the [help page](http://exercism.io/languages/python). Chapter 9 in Chris Pine's online Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=09](http://pine.fm/LearnToProgram/?Chapter=09) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/go-counting/README.md b/exercises/go-counting/README.md index 1baaa0cc73..cdd5a25917 100644 --- a/exercises/go-counting/README.md +++ b/exercises/go-counting/README.md @@ -11,6 +11,8 @@ Write a function that determines the territory of each player. You may assume that any stones that have been stranded in enemy territory have already been taken off the board. +Write a function that determines the territory which includes a specified coordinate. + Multiple empty intersections may be encircled at once and for encircling only horizontal and vertical neighbours count. In the following diagram the stones which matter are marked "O" and the stones that don't are @@ -41,12 +43,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test go_counting_test.py` +- Python 3.3+: `pytest go_counting_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest go_counting_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/go-counting` directory. @@ -57,4 +77,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/go-counting/example.py b/exercises/go-counting/example.py index b0ba0ee0ba..4c2ca3d54a 100644 --- a/exercises/go-counting/example.py +++ b/exercises/go-counting/example.py @@ -8,7 +8,7 @@ class Board: def __init__(self, board): - self.board = board.splitlines() + self.board = board self.width = len(self.board[0]) self.height = len(self.board) @@ -35,10 +35,10 @@ def walk(self, x, y, return (visited_territory, visited_stones) - def territoryFor(self, coord): - assert len(coord) == 2 - x, y = coord[0], coord[1] - if not self.valid(x, y) or self.board[y][x] in STONES: + def territory(self, x, y): + if not self.valid(x, y): + raise ValueError('invalid coordinate') + if self.board[y][x] in STONES: return (NONE, set()) visited_territory, visited_stones = self.walk(x, y) @@ -55,7 +55,7 @@ def territories(self): for y in range(self.height): for x in range(self.width): if not (x, y) in visited: - owner, owned_territories = self.territoryFor((x, y)) + owner, owned_territories = self.territory(x, y) result[owner].update(owned_territories) visited.update(owned_territories) diff --git a/exercises/go-counting/go_counting.py b/exercises/go-counting/go_counting.py index a35bf6f7b3..d1c689e704 100644 --- a/exercises/go-counting/go_counting.py +++ b/exercises/go-counting/go_counting.py @@ -9,12 +9,13 @@ class Board: def __init__(self, board): pass - def territoryFor(self, coord): + def territory(self, x, y): """Find the owner and the territories given a coordinate on the board Args: - coord ((int,int)): Coordinate on the board + x (int): Column on the board + y (int): Row on the board Returns: (str, set): A tuple, the first element being the owner diff --git a/exercises/go-counting/go_counting_test.py b/exercises/go-counting/go_counting_test.py index b75649acb6..1217f3e3d7 100644 --- a/exercises/go-counting/go_counting_test.py +++ b/exercises/go-counting/go_counting_test.py @@ -2,90 +2,97 @@ import go_counting -# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0 +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0 -board5x5 = "\n".join([ +board5x5 = [ " B ", " B B ", "B W B", " W W ", " W " -]) - -board9x9 = "\n".join([ - " B B ", - "B B B", - "WBBBWBBBW", - "W W W W W", - " ", - " W W W W ", - "B B B B", - " W BBB W ", - " B B " -]) +] class GoCountingTest(unittest.TestCase): - def test_5x5_for_black(self): + def test_black_corner_territory_on_5x5_board(self): board = go_counting.Board(board5x5) - stone, territory = board.territoryFor((0, 1)) + stone, territory = board.territory(x=0, y=1) self.assertEqual(stone, go_counting.BLACK) - self.assertEqual(territory, set([(0, 0), (0, 1), (1, 0)])) + self.assertSetEqual(territory, {(0, 0), (0, 1), (1, 0)}) - def test_5x5_for_white(self): + def test_white_center_territory_on_5x5_board(self): board = go_counting.Board(board5x5) - stone, territory = board.territoryFor((2, 3)) + stone, territory = board.territory(x=2, y=3) self.assertEqual(stone, go_counting.WHITE) - self.assertEqual(territory, set([(2, 3)])) + self.assertSetEqual(territory, {(2, 3)}) - def test_5x5_for_open_territory(self): + def test_open_corner_territory_on_5x5_board(self): board = go_counting.Board(board5x5) - stone, territory = board.territoryFor((1, 4)) + stone, territory = board.territory(x=1, y=4) self.assertEqual(stone, go_counting.NONE) - self.assertEqual(territory, set([(0, 3), (0, 4), (1, 4)])) + self.assertSetEqual(territory, {(0, 3), (0, 4), (1, 4)}) - def test_5x5_for_non_territory(self): + def test_a_stone_and_not_a_territory_on_5x5_board(self): board = go_counting.Board(board5x5) - stone, territory = board.territoryFor((1, 1)) + stone, territory = board.territory(x=1, y=1) self.assertEqual(stone, go_counting.NONE) - self.assertEqual(territory, set()) + self.assertSetEqual(territory, set()) - def test_5x5_for_valid_coordinate(self): + def test_invalid_because_x_is_too_low(self): board = go_counting.Board(board5x5) - stone, territory = board.territoryFor((-1, 1)) - self.assertEqual(stone, go_counting.NONE) - self.assertEqual(territory, set()) + with self.assertRaisesWithMessage(ValueError): + board.territory(x=-1, y=1) - def test_5x5_for_valid_coordinate2(self): + def test_invalid_because_x_is_too_high(self): board = go_counting.Board(board5x5) - stone, territory = board.territoryFor((1, 5)) - self.assertEqual(stone, go_counting.NONE) - self.assertEqual(territory, set()) + with self.assertRaisesWithMessage(ValueError): + board.territory(x=5, y=1) + + def test_invalid_because_y_is_too_low(self): + board = go_counting.Board(board5x5) + with self.assertRaisesWithMessage(ValueError): + board.territory(x=1, y=-1) - def test_one_territory_whole_board(self): - board = go_counting.Board(" ") + def test_invalid_because_y_is_too_high(self): + board = go_counting.Board(board5x5) + with self.assertRaisesWithMessage(ValueError): + board.territory(x=1, y=5) + + def test_one_territory_is_the_whole_board(self): + board = go_counting.Board([" "]) territories = board.territories() - self.assertEqual(territories[go_counting.BLACK], set()) - self.assertEqual(territories[go_counting.WHITE], set()) - self.assertEqual(territories[go_counting.NONE], set([(0, 0)])) + self.assertSetEqual(territories[go_counting.BLACK], set()) + self.assertSetEqual(territories[go_counting.WHITE], set()) + self.assertSetEqual(territories[go_counting.NONE], {(0, 0)}) def test_two_territories_rectangular_board(self): - input_board = "\n".join([ + input_board = [ " BW ", " BW " - ]) + ] board = go_counting.Board(input_board) territories = board.territories() - self.assertEqual(territories[go_counting.BLACK], set([(0, 0), (0, 1)])) - self.assertEqual(territories[go_counting.WHITE], set([(3, 0), (3, 1)])) - self.assertEqual(territories[go_counting.NONE], set()) + self.assertSetEqual(territories[go_counting.BLACK], {(0, 0), (0, 1)}) + self.assertSetEqual(territories[go_counting.WHITE], {(3, 0), (3, 1)}) + self.assertSetEqual(territories[go_counting.NONE], set()) - def test_9x9_for_open_territory(self): - board = go_counting.Board(board9x9) - stone, territory = board.territoryFor((0, 8)) - self.assertEqual(stone, go_counting.NONE) - self.assertEqual(territory, - set([(2, 7), (2, 8), (1, 8), (0, 8), (0, 7)])) + def test_two_region_rectangular_board(self): + input_board = [" B "] + board = go_counting.Board(input_board) + territories = board.territories() + self.assertSetEqual(territories[go_counting.BLACK], {(0, 0), (2, 0)}) + self.assertSetEqual(territories[go_counting.WHITE], set()) + self.assertSetEqual(territories[go_counting.NONE], set()) + + # Utility functions + def setUp(self): + try: + self.assertRaisesRegex + except AttributeError: + self.assertRaisesRegex = self.assertRaisesRegexp + + def assertRaisesWithMessage(self, exception): + return self.assertRaisesRegex(exception, r".+") if __name__ == '__main__': diff --git a/exercises/grade-school/README.md b/exercises/grade-school/README.md index c8b758cabb..1ee2a1c8be 100644 --- a/exercises/grade-school/README.md +++ b/exercises/grade-school/README.md @@ -42,12 +42,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test grade_school_test.py` +- Python 3.3+: `pytest grade_school_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest grade_school_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/grade-school` directory. @@ -62,4 +80,5 @@ please see the [help page](http://exercism.io/languages/python). A pairing session with Phil Battos at gSchool [http://gschool.it](http://gschool.it) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/grains/README.md b/exercises/grains/README.md index 6ad3f9584a..63a337682f 100644 --- a/exercises/grains/README.md +++ b/exercises/grains/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test grains_test.py` +- Python 3.3+: `pytest grains_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest grains_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/grains` directory. @@ -54,4 +72,5 @@ please see the [help page](http://exercism.io/languages/python). JavaRanch Cattle Drive, exercise 6 [http://www.javaranch.com/grains.jsp](http://www.javaranch.com/grains.jsp) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/grains/grains_test.py b/exercises/grains/grains_test.py index e5965e9b34..a7965e4aeb 100644 --- a/exercises/grains/grains_test.py +++ b/exercises/grains/grains_test.py @@ -6,7 +6,7 @@ ) -# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0 +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0 class GrainsTest(unittest.TestCase): def test_square_1(self): diff --git a/exercises/grep/README.md b/exercises/grep/README.md index 687911587c..04ae196253 100644 --- a/exercises/grep/README.md +++ b/exercises/grep/README.md @@ -72,12 +72,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test grep_test.py` +- Python 3.3+: `pytest grep_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest grep_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/grep` directory. @@ -92,4 +110,5 @@ please see the [help page](http://exercism.io/languages/python). Conversation with Nate Foster. [http://www.cs.cornell.edu/Courses/cs3110/2014sp/hw/0/ps0.pdf](http://www.cs.cornell.edu/Courses/cs3110/2014sp/hw/0/ps0.pdf) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/hamming/README.md b/exercises/hamming/README.md index 4dcc99ca0b..3849af1868 100644 --- a/exercises/hamming/README.md +++ b/exercises/hamming/README.md @@ -43,12 +43,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test hamming_test.py` +- Python 3.3+: `pytest hamming_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest hamming_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/hamming` directory. @@ -63,4 +81,5 @@ please see the [help page](http://exercism.io/languages/python). The Calculating Point Mutations problem at Rosalind [http://rosalind.info/problems/hamm/](http://rosalind.info/problems/hamm/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/hello-world/README.md b/exercises/hello-world/README.md index 885d3b5240..8e2328c19d 100644 --- a/exercises/hello-world/README.md +++ b/exercises/hello-world/README.md @@ -22,12 +22,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test hello_world_test.py` +- Python 3.3+: `pytest hello_world_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest hello_world_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/hello-world` directory. @@ -42,4 +60,5 @@ please see the [help page](http://exercism.io/languages/python). This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/hexadecimal/README.md b/exercises/hexadecimal/README.md index 2e4c1664d9..aeca4fa9b8 100644 --- a/exercises/hexadecimal/README.md +++ b/exercises/hexadecimal/README.md @@ -15,12 +15,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test hexadecimal_test.py` +- Python 3.3+: `pytest hexadecimal_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest hexadecimal_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/hexadecimal` directory. @@ -35,4 +53,5 @@ please see the [help page](http://exercism.io/languages/python). All of Computer Science [http://www.wolframalpha.com/examples/NumberBases.html](http://www.wolframalpha.com/examples/NumberBases.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/house/README.md b/exercises/house/README.md index 65722b5301..282e274055 100644 --- a/exercises/house/README.md +++ b/exercises/house/README.md @@ -113,12 +113,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test house_test.py` +- Python 3.3+: `pytest house_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest house_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/house` directory. @@ -133,4 +151,5 @@ please see the [help page](http://exercism.io/languages/python). British nursery rhyme [http://en.wikipedia.org/wiki/This_Is_The_House_That_Jack_Built](http://en.wikipedia.org/wiki/This_Is_The_House_That_Jack_Built) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/house/example.py b/exercises/house/example.py index 796f61b1df..2a428383db 100644 --- a/exercises/house/example.py +++ b/exercises/house/example.py @@ -1,4 +1,4 @@ -parts = [('lay in', 'the house that Jack built'), +parts = [('lay in', 'the house that Jack built.'), ('ate', 'the malt'), ('killed', 'the rat'), ('worried', 'the cat'), @@ -14,19 +14,13 @@ def verse(verse_num): v = ['This is {}'.format(parts[verse_num][1])] - v.extend(['that {0} {1}'.format(parts[i][0], parts[i][1]) + v.extend(['that {0} {1}'.format(*parts[i]) for i in range(verse_num - 1, -1, -1)]) - v[-1] += '.' - return v + return ''.join(v) def recite(start_verse, end_verse): - if start_verse == end_verse: - return verse(start_verse - 1) - else: - result = [] - for verse_num in range(start_verse-1, end_verse): - result.extend(verse(verse_num)) - result.append("") - result.pop() - return result + result = [] + for verse_num in range(start_verse-1, end_verse): + result.append(verse(verse_num)) + return result diff --git a/exercises/house/house_test.py b/exercises/house/house_test.py index 139f1b1efc..8b58eac4ff 100644 --- a/exercises/house/house_test.py +++ b/exercises/house/house_test.py @@ -14,267 +14,142 @@ def test_verse_one(self): def test_verse_two(self): expected = [ - "This is the malt", - "that lay in the house that Jack built.", + "This is the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(2, 2), expected) def test_verse_three(self): expected = [ - "This is the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(3, 3), expected) def test_verse_four(self): expected = [ - "This is the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(4, 4), expected) def test_verse_five(self): expected = [ - "This is the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(5, 5), expected) def test_verse_six(self): expected = [ - "This is the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the cow with the crumpled horn" + "that tossed the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(6, 6), expected) def test_verse_seven(self): expected = [ - "This is the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the maiden all forlorn" + "that milked the cow with the crumpled horn" + "that tossed the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(7, 7), expected) def test_verse_eight(self): expected = [ - "This is the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the man all tattered and torn" + "that kissed the maiden all forlorn" + "that milked the cow with the crumpled horn" + "that tossed the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(8, 8), expected) def test_verse_nine(self): expected = [ - "This is the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the priest all shaven and shorn" + "that married the man all tattered and torn" + "that kissed the maiden all forlorn" + "that milked the cow with the crumpled horn" + "that tossed the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(9, 9), expected) def test_verse_10(self): expected = [ - "This is the rooster that crowed in the morn", - "that woke the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the rooster that crowed in the morn" + "that woke the priest all shaven and shorn" + "that married the man all tattered and torn" + "that kissed the maiden all forlorn" + "that milked the cow with the crumpled horn" + "that tossed the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(10, 10), expected) def test_verse_11(self): expected = [ - "This is the farmer sowing his corn", - "that kept the rooster that crowed in the morn", - "that woke the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the farmer sowing his corn" + "that kept the rooster that crowed in the morn" + "that woke the priest all shaven and shorn" + "that married the man all tattered and torn" + "that kissed the maiden all forlorn" + "that milked the cow with the crumpled horn" + "that tossed the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(11, 11), expected) def test_verse_12(self): expected = [ - "This is the horse and the hound and the horn", - "that belonged to the farmer sowing his corn", - "that kept the rooster that crowed in the morn", - "that woke the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", + "This is the horse and the hound and the horn" + "that belonged to the farmer sowing his corn" + "that kept the rooster that crowed in the morn" + "that woke the priest all shaven and shorn" + "that married the man all tattered and torn" + "that kissed the maiden all forlorn" + "that milked the cow with the crumpled horn" + "that tossed the dog" + "that worried the cat" + "that killed the rat" + "that ate the malt" + "that lay in the house that Jack built." ] self.assertEqual(recite(12, 12), expected) def test_multiple_verses(self): - expected = [ - "This is the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - ] + expected = [recite(i, i)[0] for i in range(4, 9)] self.assertEqual(recite(4, 8), expected) def test_full_rhyme(self): - expected = [ - "This is the house that Jack built.", - "", - "This is the malt", - "that lay in the house that Jack built.", - "", - "This is the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the rooster that crowed in the morn", - "that woke the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the farmer sowing his corn", - "that kept the rooster that crowed in the morn", - "that woke the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - "", - "This is the horse and the hound and the horn", - "that belonged to the farmer sowing his corn", - "that kept the rooster that crowed in the morn", - "that woke the priest all shaven and shorn", - "that married the man all tattered and torn", - "that kissed the maiden all forlorn", - "that milked the cow with the crumpled horn", - "that tossed the dog", - "that worried the cat", - "that killed the rat", - "that ate the malt", - "that lay in the house that Jack built.", - ] + expected = [recite(i, i)[0] for i in range(1, 13)] self.assertEqual(recite(1, 12), expected) diff --git a/exercises/isbn-verifier/README.md b/exercises/isbn-verifier/README.md index 1067f16b05..f0ae471f6f 100644 --- a/exercises/isbn-verifier/README.md +++ b/exercises/isbn-verifier/README.md @@ -48,12 +48,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test isbn_verifier_test.py` +- Python 3.3+: `pytest isbn_verifier_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest isbn_verifier_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/isbn-verifier` directory. @@ -68,4 +86,5 @@ please see the [help page](http://exercism.io/languages/python). Converting a string into a number and some basic processing utilizing a relatable real world example. [https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation](https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/isbn-verifier/isbn_verifier_test.py b/exercises/isbn-verifier/isbn_verifier_test.py index 30470b9ac9..3fd62269e1 100644 --- a/exercises/isbn-verifier/isbn_verifier_test.py +++ b/exercises/isbn-verifier/isbn_verifier_test.py @@ -3,7 +3,7 @@ from isbn_verifier import verify -# Tests adapted from `problem-specifications//canonical-data.json` @ v2.2.0 +# Tests adapted from `problem-specifications//canonical-data.json` @ v2.4.0 class IsbnVerifierTests(unittest.TestCase): @@ -20,7 +20,7 @@ def test_invalid_check_digit_other_than_X(self): self.assertIs(verify('3-598-21507-A'), False) def test_invalid_character_in_isbn(self): - self.assertIs(verify('3-598-2K507-0'), False) + self.assertIs(verify('3-598-P1581-X'), False) def test_invalid_X_other_than_check_digit(self): self.assertIs(verify('3-598-2X507-9'), False) @@ -49,6 +49,9 @@ def test_invalid_check_digit_X_used_for_0(self): def test_valid_empty_isbn(self): self.assertIs(verify(''), False) + def test_input_is_nine_characters(self): + self.assertIs(verify('134456729'), False) + if __name__ == '__main__': unittest.main() diff --git a/exercises/isogram/README.md b/exercises/isogram/README.md index edb8898359..5115396b22 100644 --- a/exercises/isogram/README.md +++ b/exercises/isogram/README.md @@ -21,12 +21,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test isogram_test.py` +- Python 3.3+: `pytest isogram_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest isogram_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/isogram` directory. @@ -41,4 +59,5 @@ please see the [help page](http://exercism.io/languages/python). 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. diff --git a/exercises/kindergarten-garden/README.md b/exercises/kindergarten-garden/README.md index f512349d80..3980d87089 100644 --- a/exercises/kindergarten-garden/README.md +++ b/exercises/kindergarten-garden/README.md @@ -67,12 +67,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test kindergarten_garden_test.py` +- Python 3.3+: `pytest kindergarten_garden_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest kindergarten_garden_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/kindergarten-garden` directory. @@ -87,4 +105,5 @@ please see the [help page](http://exercism.io/languages/python). Random musings during airplane trip. [http://jumpstartlab.com](http://jumpstartlab.com) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/largest-series-product/README.md b/exercises/largest-series-product/README.md index 3e6e236d85..f88d6f4e49 100644 --- a/exercises/largest-series-product/README.md +++ b/exercises/largest-series-product/README.md @@ -21,12 +21,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test largest_series_product_test.py` +- Python 3.3+: `pytest largest_series_product_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest largest_series_product_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/largest-series-product` directory. @@ -41,4 +59,5 @@ please see the [help page](http://exercism.io/languages/python). A variation on Problem 8 at Project Euler [http://projecteuler.net/problem=8](http://projecteuler.net/problem=8) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/leap/README.md b/exercises/leap/README.md index 9b65afb240..e1f7826f35 100644 --- a/exercises/leap/README.md +++ b/exercises/leap/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test leap_test.py` +- Python 3.3+: `pytest leap_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest leap_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/leap` directory. @@ -54,4 +72,5 @@ please see the [help page](http://exercism.io/languages/python). 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. diff --git a/exercises/linked-list/README.md b/exercises/linked-list/README.md index 2207c2e469..38d438eb10 100644 --- a/exercises/linked-list/README.md +++ b/exercises/linked-list/README.md @@ -35,12 +35,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test linked_list_test.py` +- Python 3.3+: `pytest linked_list_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest linked_list_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/linked-list` directory. @@ -55,4 +73,5 @@ please see the [help page](http://exercism.io/languages/python). Classic computer science topic ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/list-ops/README.md b/exercises/list-ops/README.md index 1662001e8e..db5e2011b5 100644 --- a/exercises/list-ops/README.md +++ b/exercises/list-ops/README.md @@ -14,12 +14,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test list_ops_test.py` +- Python 3.3+: `pytest list_ops_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest list_ops_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/list-ops` directory. @@ -30,4 +48,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/luhn/README.md b/exercises/luhn/README.md index b1432b5f80..6ece2fe3e0 100644 --- a/exercises/luhn/README.md +++ b/exercises/luhn/README.md @@ -72,12 +72,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test luhn_test.py` +- Python 3.3+: `pytest luhn_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest luhn_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/luhn` directory. @@ -92,4 +110,5 @@ please see the [help page](http://exercism.io/languages/python). The Luhn Algorithm on Wikipedia [http://en.wikipedia.org/wiki/Luhn_algorithm](http://en.wikipedia.org/wiki/Luhn_algorithm) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/markdown/README.md b/exercises/markdown/README.md index 4f7a7d100d..10d263ce14 100644 --- a/exercises/markdown/README.md +++ b/exercises/markdown/README.md @@ -22,12 +22,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test markdown_test.py` +- Python 3.3+: `pytest markdown_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest markdown_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/markdown` directory. @@ -38,4 +56,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/matrix/README.md b/exercises/matrix/README.md index d89879ebe2..8fdffdfef8 100644 --- a/exercises/matrix/README.md +++ b/exercises/matrix/README.md @@ -48,12 +48,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test matrix_test.py` +- Python 3.3+: `pytest matrix_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest matrix_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/matrix` directory. @@ -68,4 +86,5 @@ please see the [help page](http://exercism.io/languages/python). Warmup to the `saddle-points` warmup. [http://jumpstartlab.com](http://jumpstartlab.com) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/meetup/README.md b/exercises/meetup/README.md index 9139bf25fa..a5a3434a59 100644 --- a/exercises/meetup/README.md +++ b/exercises/meetup/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test meetup_test.py` +- Python 3.3+: `pytest meetup_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest meetup_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/meetup` directory. @@ -54,4 +72,5 @@ please see the [help page](http://exercism.io/languages/python). Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month [https://twitter.com/copiousfreetime](https://twitter.com/copiousfreetime) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/meetup/example.py b/exercises/meetup/example.py index 2abeb1d130..7aa2e2c190 100644 --- a/exercises/meetup/example.py +++ b/exercises/meetup/example.py @@ -14,4 +14,13 @@ def _choice(which): return lambda dates: next(d for d in dates if 13 <= d.day <= 19) ix = -1 if (which == 'last') else (int(which[0]) - 1) - return lambda dates: dates[ix] + + def _func(dates): + if ix < len(dates): + return dates[ix] + raise MeetupDayException('day does not exist') + return _func + + +class MeetupDayException(Exception): + pass diff --git a/exercises/meetup/meetup_test.py b/exercises/meetup/meetup_test.py index 64b6754589..c1f4991d29 100644 --- a/exercises/meetup/meetup_test.py +++ b/exercises/meetup/meetup_test.py @@ -1,12 +1,7 @@ import unittest from datetime import date -from meetup import meetup_day - -try: - from meetup import MeetupDayException -except ImportError: - MeetupDayException = Exception +from meetup import meetup_day, MeetupDayException # Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0 diff --git a/exercises/minesweeper/README.md b/exercises/minesweeper/README.md index 33d283c781..892f8e0d89 100644 --- a/exercises/minesweeper/README.md +++ b/exercises/minesweeper/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test minesweeper_test.py` +- Python 3.3+: `pytest minesweeper_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest minesweeper_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/minesweeper` directory. @@ -50,4 +68,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/nth-prime/README.md b/exercises/nth-prime/README.md index 1fa13527eb..2acf11dca0 100644 --- a/exercises/nth-prime/README.md +++ b/exercises/nth-prime/README.md @@ -16,12 +16,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test nth_prime_test.py` +- Python 3.3+: `pytest nth_prime_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest nth_prime_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/nth-prime` directory. @@ -36,4 +54,5 @@ please see the [help page](http://exercism.io/languages/python). A variation on Problem 7 at Project Euler [http://projecteuler.net/problem=7](http://projecteuler.net/problem=7) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/nucleotide-count/README.md b/exercises/nucleotide-count/README.md index 957ad14903..83d2bcebe3 100644 --- a/exercises/nucleotide-count/README.md +++ b/exercises/nucleotide-count/README.md @@ -20,12 +20,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test nucleotide_count_test.py` +- Python 3.3+: `pytest nucleotide_count_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest nucleotide_count_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/nucleotide-count` directory. @@ -40,4 +58,5 @@ please see the [help page](http://exercism.io/languages/python). The Calculating DNA Nucleotides_problem at Rosalind [http://rosalind.info/problems/dna/](http://rosalind.info/problems/dna/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/ocr-numbers/README.md b/exercises/ocr-numbers/README.md index 44cebf86f0..53322be42a 100644 --- a/exercises/ocr-numbers/README.md +++ b/exercises/ocr-numbers/README.md @@ -86,12 +86,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test ocr_numbers_test.py` +- Python 3.3+: `pytest ocr_numbers_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest ocr_numbers_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/ocr-numbers` directory. @@ -106,4 +124,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by the Bank OCR kata [http://codingdojo.org/cgi-bin/wiki.pl?KataBankOCR](http://codingdojo.org/cgi-bin/wiki.pl?KataBankOCR) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/octal/README.md b/exercises/octal/README.md index 449b551b16..4b59ce77cb 100644 --- a/exercises/octal/README.md +++ b/exercises/octal/README.md @@ -54,12 +54,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test octal_test.py` +- Python 3.3+: `pytest octal_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest octal_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/octal` directory. @@ -74,4 +92,5 @@ please see the [help page](http://exercism.io/languages/python). All of Computer Science [http://www.wolframalpha.com/input/?i=base+8](http://www.wolframalpha.com/input/?i=base+8) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/palindrome-products/README.md b/exercises/palindrome-products/README.md index a6e91823a9..5355debba4 100644 --- a/exercises/palindrome-products/README.md +++ b/exercises/palindrome-products/README.md @@ -40,12 +40,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test palindrome_products_test.py` +- Python 3.3+: `pytest palindrome_products_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest palindrome_products_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/palindrome-products` directory. @@ -60,4 +78,5 @@ please see the [help page](http://exercism.io/languages/python). Problem 4 at Project Euler [http://projecteuler.net/problem=4](http://projecteuler.net/problem=4) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/pangram/README.md b/exercises/pangram/README.md index ff990708b2..effb7b3265 100644 --- a/exercises/pangram/README.md +++ b/exercises/pangram/README.md @@ -16,12 +16,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test pangram_test.py` +- Python 3.3+: `pytest pangram_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest pangram_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/pangram` directory. @@ -36,4 +54,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Pangram](https://en.wikipedia.org/wiki/Pangram) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/parallel-letter-frequency/README.md b/exercises/parallel-letter-frequency/README.md index 76f5523edf..62dbb5b3a8 100644 --- a/exercises/parallel-letter-frequency/README.md +++ b/exercises/parallel-letter-frequency/README.md @@ -15,12 +15,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test parallel_letter_frequency_test.py` +- Python 3.3+: `pytest parallel_letter_frequency_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest parallel_letter_frequency_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/parallel-letter-frequency` directory. @@ -31,4 +49,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/pascals-triangle/README.md b/exercises/pascals-triangle/README.md index 7d822eb310..61f37d0422 100644 --- a/exercises/pascals-triangle/README.md +++ b/exercises/pascals-triangle/README.md @@ -22,12 +22,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test pascals_triangle_test.py` +- Python 3.3+: `pytest pascals_triangle_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest pascals_triangle_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/pascals-triangle` directory. @@ -42,4 +60,5 @@ please see the [help page](http://exercism.io/languages/python). Pascal's Triangle at Wolfram Math World [http://mathworld.wolfram.com/PascalsTriangle.html](http://mathworld.wolfram.com/PascalsTriangle.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/pascals-triangle/example.py b/exercises/pascals-triangle/example.py index 15b2e04f3a..676791e640 100644 --- a/exercises/pascals-triangle/example.py +++ b/exercises/pascals-triangle/example.py @@ -1,14 +1,12 @@ -def triangle(nth): - return [row(i) for i in range(nth + 1)] - - -def is_triangle(t): - new_t = triangle(len(t) - 1) - return t == new_t - - -def row(nth): - r = [1] - for i in range(1, nth + 1): - r.append(int(r[-1] * (nth - i + 1) / i)) - return " ".join([str(i) for i in r]) +def rows(row_count): + if row_count < 0: + return None + elif row_count == 0: + return [] + r = [] + for i in range(row_count): + rn = [1] + for j in range(i): + rn.append(sum(r[-1][j:j+2])) + r.append(rn) + return r diff --git a/exercises/pascals-triangle/pascals_triangle.py b/exercises/pascals-triangle/pascals_triangle.py index 7123ba7554..c1d878ce01 100644 --- a/exercises/pascals-triangle/pascals_triangle.py +++ b/exercises/pascals-triangle/pascals_triangle.py @@ -1,10 +1,2 @@ -def triangle(row_count): - pass - - -def is_triangle(triangle_rows_list): - pass - - -def row(row_count): +def rows(row_count): pass diff --git a/exercises/pascals-triangle/pascals_triangle_test.py b/exercises/pascals-triangle/pascals_triangle_test.py index c52ea441f1..c2c5068145 100644 --- a/exercises/pascals-triangle/pascals_triangle_test.py +++ b/exercises/pascals-triangle/pascals_triangle_test.py @@ -1,37 +1,51 @@ import unittest -from pascals_triangle import triangle, row, is_triangle +from pascals_triangle import rows + + +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0 + +TRIANGLE = [ + [1], + [1, 1], + [1, 2, 1], + [1, 3, 3, 1], + [1, 4, 6, 4, 1], + [1, 5, 10, 10, 5, 1], + [1, 6, 15, 20, 15, 6, 1], + [1, 7, 21, 35, 35, 21, 7, 1], + [1, 8, 28, 56, 70, 56, 28, 8, 1], + [1, 9, 36, 84, 126, 126, 84, 36, 9, 1] +] class PascalsTriangleTest(unittest.TestCase): - def test_triangle1(self): - ans = ['1', '1 1', '1 2 1', '1 3 3 1', '1 4 6 4 1'] - self.assertEqual(triangle(4), ans) - - def test_triangle2(self): - ans = ['1', '1 1', '1 2 1', '1 3 3 1', '1 4 6 4 1', '1 5 10 10 5 1', - '1 6 15 20 15 6 1'] - self.assertEqual(triangle(6), ans) - - def test_is_triangle_true(self): - inp = ['1', '1 1', '1 2 1', '1 3 3 1', '1 4 6 4 1', '1 5 10 10 5 1'] - self.assertIs(is_triangle(inp), True) - - def test_is_triangle_false(self): - inp = ['1', '1 1', '1 2 1', '1 4 4 1'] - self.assertIs(is_triangle(inp), False) - - def test_row1(self): - ans = '1' - self.assertEqual(row(0), ans) - - def test_row2(self): - ans = '1 2 1' - self.assertEqual(row(2), ans) - - def test_row3(self): - ans = '1 7 21 35 35 21 7 1' - self.assertEqual(row(7), ans) + def test_zero_rows(self): + self.assertEqual(rows(0), []) + + def test_single_row(self): + self.assertEqual(rows(1), TRIANGLE[:1]) + + def test_two_rows(self): + self.assertEqual(rows(2), TRIANGLE[:2]) + + def test_three_rows(self): + self.assertEqual(rows(3), TRIANGLE[:3]) + + def test_four_rows(self): + self.assertEqual(rows(4), TRIANGLE[:4]) + + def test_five_rows(self): + self.assertEqual(rows(5), TRIANGLE[:5]) + + def test_six_rows(self): + self.assertEqual(rows(6), TRIANGLE[:6]) + + def test_ten_rows(self): + self.assertEqual(rows(10), TRIANGLE[:10]) + + def test_negative_rows(self): + self.assertEqual(rows(-1), None) if __name__ == '__main__': diff --git a/exercises/perfect-numbers/README.md b/exercises/perfect-numbers/README.md index a34b0aa59c..e734b91ef4 100644 --- a/exercises/perfect-numbers/README.md +++ b/exercises/perfect-numbers/README.md @@ -25,12 +25,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test perfect_numbers_test.py` +- Python 3.3+: `pytest perfect_numbers_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest perfect_numbers_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/perfect-numbers` directory. @@ -45,4 +63,5 @@ please see the [help page](http://exercism.io/languages/python). Taken from Chapter 2 of Functional Thinking by Neal Ford. [http://shop.oreilly.com/product/0636920029687.do](http://shop.oreilly.com/product/0636920029687.do) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/phone-number/README.md b/exercises/phone-number/README.md index 270f71e4c0..72ed048b6d 100644 --- a/exercises/phone-number/README.md +++ b/exercises/phone-number/README.md @@ -36,12 +36,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test phone_number_test.py` +- Python 3.3+: `pytest phone_number_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest phone_number_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/phone-number` directory. @@ -56,4 +74,5 @@ please see the [help page](http://exercism.io/languages/python). Event Manager by JumpstartLab [http://tutorials.jumpstartlab.com/projects/eventmanager.html](http://tutorials.jumpstartlab.com/projects/eventmanager.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/pig-latin/README.md b/exercises/pig-latin/README.md index 4245ec45ac..9fa95c72eb 100644 --- a/exercises/pig-latin/README.md +++ b/exercises/pig-latin/README.md @@ -7,10 +7,10 @@ confusing. It obeys a few simple rules (below), but when it's spoken quickly it's really difficult for non-children (and non-native speakers) to understand. -- **Rule 1**: If a word begins with a vowel sound, add an "ay" sound to - the end of the word. -- **Rule 2**: If a word begins with a consonant sound, move it to the - end of the word, and then add an "ay" sound to the end of the word. +- **Rule 1**: If a word begins with a vowel sound, add an "ay" sound to the end of the word. Please note that "xr" and "yt" at the beginning of a word make vowel sounds (e.g. "xray" -> "xrayay", "yttria" -> "yttriaay"). +- **Rule 2**: If a word begins with a consonant sound, move it to the end of the word and then add an "ay" sound to the end of the word. Consonant sounds can be made up of multiple consonants, a.k.a. a consonant cluster (e.g. "chair" -> "airchay"). +- **Rule 3**: If a word starts with a consonant sound followed by "qu", move it to the end of the word, and then add an "ay" sound to the end of the word (e.g. "square" -> "aresquay"). +- **Rule 4**: If a word contains a "y" after a consonant cluster or as the second letter in a two letter word it makes a vowel sound (e.g. "rhythm" -> "ythmrhay", "my" -> "ymay"). There are a few more rules for edge cases, and there are regional variants too. @@ -25,12 +25,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test pig_latin_test.py` +- Python 3.3+: `pytest pig_latin_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest pig_latin_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/pig-latin` directory. @@ -45,4 +63,5 @@ please see the [help page](http://exercism.io/languages/python). The Pig Latin exercise at Test First Teaching by Ultrasaurus [https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/](https://github.com/ultrasaurus/test-first-teaching/blob/master/learn_ruby/pig_latin/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/point-mutations/README.md b/exercises/point-mutations/README.md index 75c98cca1c..60ec8912b4 100644 --- a/exercises/point-mutations/README.md +++ b/exercises/point-mutations/README.md @@ -42,12 +42,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test point_mutations_test.py` +- Python 3.3+: `pytest point_mutations_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest point_mutations_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/point-mutations` directory. @@ -62,4 +80,5 @@ please see the [help page](http://exercism.io/languages/python). The Calculating Point Mutations problem at Rosalind [http://rosalind.info/problems/hamm/](http://rosalind.info/problems/hamm/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/poker/README.md b/exercises/poker/README.md index 360891f925..03d28f1fa6 100644 --- a/exercises/poker/README.md +++ b/exercises/poker/README.md @@ -13,12 +13,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test poker_test.py` +- Python 3.3+: `pytest poker_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest poker_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/poker` directory. @@ -33,4 +51,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by the training course from Udacity. [https://www.udacity.com/course/viewer#!/c-cs212/](https://www.udacity.com/course/viewer#!/c-cs212/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/pov/README.md b/exercises/pov/README.md index f3344a7663..8a00c56ff2 100644 --- a/exercises/pov/README.md +++ b/exercises/pov/README.md @@ -45,12 +45,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test pov_test.py` +- Python 3.3+: `pytest pov_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest pov_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/pov` directory. @@ -65,4 +83,5 @@ please see the [help page](http://exercism.io/languages/python). Adaptation of exercise from 4clojure [https://www.4clojure.com/](https://www.4clojure.com/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/prime-factors/README.md b/exercises/prime-factors/README.md index 7fc3a0a23b..9c4045c6b3 100644 --- a/exercises/prime-factors/README.md +++ b/exercises/prime-factors/README.md @@ -37,12 +37,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test prime_factors_test.py` +- Python 3.3+: `pytest prime_factors_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest prime_factors_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/prime-factors` directory. @@ -57,4 +75,5 @@ please see the [help page](http://exercism.io/languages/python). The Prime Factors Kata by Uncle Bob [http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata](http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/protein-translation/README.md b/exercises/protein-translation/README.md index d1886a18a4..88b0e53d3c 100644 --- a/exercises/protein-translation/README.md +++ b/exercises/protein-translation/README.md @@ -49,12 +49,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test protein_translation_test.py` +- Python 3.3+: `pytest protein_translation_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest protein_translation_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/protein-translation` directory. @@ -69,4 +87,5 @@ please see the [help page](http://exercism.io/languages/python). Tyler Long ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/proverb/README.md b/exercises/proverb/README.md index ed3434097a..d6ad5c9ed2 100644 --- a/exercises/proverb/README.md +++ b/exercises/proverb/README.md @@ -24,12 +24,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test proverb_test.py` +- Python 3.3+: `pytest proverb_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest proverb_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/proverb` directory. @@ -44,4 +62,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [http://en.wikipedia.org/wiki/For_Want_of_a_Nail](http://en.wikipedia.org/wiki/For_Want_of_a_Nail) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/pythagorean-triplet/README.md b/exercises/pythagorean-triplet/README.md index a933263e81..e486365739 100644 --- a/exercises/pythagorean-triplet/README.md +++ b/exercises/pythagorean-triplet/README.md @@ -25,12 +25,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test pythagorean_triplet_test.py` +- Python 3.3+: `pytest pythagorean_triplet_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest pythagorean_triplet_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/pythagorean-triplet` directory. @@ -45,4 +63,5 @@ please see the [help page](http://exercism.io/languages/python). Problem 9 at Project Euler [http://projecteuler.net/problem=9](http://projecteuler.net/problem=9) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/queen-attack/README.md b/exercises/queen-attack/README.md index 215c183c91..a64d48c02c 100644 --- a/exercises/queen-attack/README.md +++ b/exercises/queen-attack/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test queen_attack_test.py` +- Python 3.3+: `pytest queen_attack_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest queen_attack_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/queen-attack` directory. @@ -54,4 +72,5 @@ please see the [help page](http://exercism.io/languages/python). J Dalbey's Programming Practice problems [http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html](http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/queen-attack/example.py b/exercises/queen-attack/example.py index 5004b56b84..efec15c71a 100644 --- a/exercises/queen-attack/example.py +++ b/exercises/queen-attack/example.py @@ -1,27 +1,17 @@ -def board(pos1, pos2): - validate_position(pos1, pos2) - x1, y1 = pos1 - x2, y2 = pos2 - b = [['_'] * 8 for i in range(8)] - b[x1][y1] = 'W' - b[x2][y2] = 'B' - return [''.join(r) for r in b] +class Queen(object): + def __init__(self, row, column): + if not 0 <= row <= 7 or not 0 <= column <= 7: + raise ValueError("Invalid queen position: queen out of the board") + self.row = row + self.column = column - -def can_attack(pos1, pos2): - validate_position(pos1, pos2) - x1, y1 = pos1 - x2, y2 = pos2 - dx = x1 - x2 if x1 >= x2 else x2 - x1 - dy = y1 - y2 if y1 >= y2 else y2 - y1 - if dx == dy or dx == 0 or dy == 0: - return True - return False - - -def validate_position(pos1, pos2): - if any(x < 0 or x > 7 for x in pos1 + pos2): - raise ValueError('Invalid queen position: queen out of the board') - if pos1 == pos2: - raise ValueError('Invalid queen position: both queens in the same ' - 'square: {0}'.format(pos1)) + def can_attack(self, another_queen): + dx = abs(self.row - another_queen.row) + dy = abs(self.column - another_queen.column) + if dx == dy == 0: + raise ValueError( + 'Invalid queen position: both queens in the same square') + elif dx == dy or dx == 0 or dy == 0: + return True + else: + return False diff --git a/exercises/queen-attack/queen_attack.py b/exercises/queen-attack/queen_attack.py index 19e6501c0e..bc811e6164 100644 --- a/exercises/queen-attack/queen_attack.py +++ b/exercises/queen-attack/queen_attack.py @@ -1,6 +1,6 @@ -def board(white_position, black_position): - pass +class Queen(object): + def __init__(self, row, column): + pass - -def can_attack(white_position, black_position): - pass + def can_attack(self, another_queen): + pass diff --git a/exercises/queen-attack/queen_attack_test.py b/exercises/queen-attack/queen_attack_test.py index ea5a34e11d..5c1fa73198 100644 --- a/exercises/queen-attack/queen_attack_test.py +++ b/exercises/queen-attack/queen_attack_test.py @@ -1,92 +1,61 @@ import unittest -from queen_attack import board, can_attack +from queen_attack import Queen -# Tests adapted from `problem-specifications//canonical-data.json` @ v2.0.0 +# Tests adapted from `problem-specifications//canonical-data.json` @ v2.1.0 class QueenAttackTest(unittest.TestCase): + # Test creation of Queens with valid and invalid positions def test_queen_valid_position(self): try: - board((1, 1), (2, 2)) + Queen(2, 2) except ValueError: self.fail("Unexpected Exception") def test_queen_negative_row(self): with self.assertRaisesWithMessage(ValueError): - board((1, 1), (-2, 2)) + Queen(-2, 2) def test_queen_invalid_row(self): with self.assertRaisesWithMessage(ValueError): - board((1, 1), (8, 4)) + Queen(8, 4) def test_queen_negative_column(self): with self.assertRaisesWithMessage(ValueError): - board((1, 1), (2, -2)) + Queen(2, -2) def test_queen_invalid_column(self): with self.assertRaisesWithMessage(ValueError): - board((1, 1), (4, 8)) + Queen(4, 8) + # Test the ability of one queen to attack another def test_attack_false(self): - self.assertIs(can_attack((2, 4), (6, 6)), False) + self.assertIs(Queen(2, 4).can_attack(Queen(6, 6)), False) def test_attack_same_row(self): - self.assertIs(can_attack((2, 4), (2, 6)), True) + self.assertIs(Queen(2, 4).can_attack(Queen(2, 6)), True) def test_attack_same_column(self): - self.assertIs(can_attack((4, 5), (2, 5)), True) + self.assertIs(Queen(4, 5).can_attack(Queen(2, 5)), True) def test_attack_diagonal1(self): - self.assertIs(can_attack((2, 2), (0, 4)), True) + self.assertIs(Queen(2, 2).can_attack(Queen(0, 4)), True) def test_attack_diagonal2(self): - self.assertIs(can_attack((2, 2), (3, 1)), True) + self.assertIs(Queen(2, 2).can_attack(Queen(3, 1)), True) def test_attack_diagonal3(self): - self.assertIs(can_attack((2, 2), (1, 1)), True) + self.assertIs(Queen(2, 2).can_attack(Queen(1, 1)), True) def test_attack_diagonal4(self): - self.assertIs(can_attack((2, 2), (5, 5)), True) - - # Tests beyond this point are not part of the canonical data. - - # If either board or can_attack are called with an invalid board position - # they should raise a ValueError with a meaningful error message. - def test_invalid_position_can_attack(self): - with self.assertRaisesWithMessage(ValueError): - can_attack((0, 0), (7, 8)) - - def test_queens_same_position_board(self): - with self.assertRaisesWithMessage(ValueError): - board((2, 2), (2, 2)) + self.assertIs(Queen(2, 2).can_attack(Queen(5, 5)), True) + # Track-specific tests def test_queens_same_position_can_attack(self): with self.assertRaisesWithMessage(ValueError): - can_attack((2, 2), (2, 2)) - - def test_board1(self): - ans = ['________', - '________', - '___W____', - '________', - '________', - '______B_', - '________', - '________'] - self.assertEqual(board((2, 3), (5, 6)), ans) - - def test_board2(self): - ans = ['______W_', - '_______B', - '________', - '________', - '________', - '________', - '________', - '________'] - self.assertEqual(board((0, 6), (1, 7)), ans) + Queen(2, 2).can_attack(Queen(2, 2)) # Utility functions def setUp(self): diff --git a/exercises/rail-fence-cipher/README.md b/exercises/rail-fence-cipher/README.md index fa13001460..00d5be0384 100644 --- a/exercises/rail-fence-cipher/README.md +++ b/exercises/rail-fence-cipher/README.md @@ -66,12 +66,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test rail_fence_cipher_test.py` +- Python 3.3+: `pytest rail_fence_cipher_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest rail_fence_cipher_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/rail-fence-cipher` directory. @@ -86,4 +104,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher](https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/raindrops/README.md b/exercises/raindrops/README.md index 4b1cbe342b..871208c330 100644 --- a/exercises/raindrops/README.md +++ b/exercises/raindrops/README.md @@ -25,12 +25,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test raindrops_test.py` +- Python 3.3+: `pytest raindrops_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest raindrops_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/raindrops` directory. @@ -45,4 +63,5 @@ please see the [help page](http://exercism.io/languages/python). A variation on a famous interview question intended to weed out potential candidates. [http://jumpstartlab.com](http://jumpstartlab.com) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/rational-numbers/README.md b/exercises/rational-numbers/README.md index cd2b0b6fb4..3cba387ca7 100644 --- a/exercises/rational-numbers/README.md +++ b/exercises/rational-numbers/README.md @@ -36,12 +36,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test rational_numbers_test.py` +- Python 3.3+: `pytest rational_numbers_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest rational_numbers_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/rational-numbers` directory. @@ -56,4 +74,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Rational_number](https://en.wikipedia.org/wiki/Rational_number) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/react/README.md b/exercises/react/README.md index 664eceb277..00d3b3a039 100644 --- a/exercises/react/README.md +++ b/exercises/react/README.md @@ -23,12 +23,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test react_test.py` +- Python 3.3+: `pytest react_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest react_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/react` directory. @@ -39,4 +57,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/rectangles/README.md b/exercises/rectangles/README.md index a298ebcb62..c73b7f36dc 100644 --- a/exercises/rectangles/README.md +++ b/exercises/rectangles/README.md @@ -71,12 +71,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test rectangles_test.py` +- Python 3.3+: `pytest rectangles_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest rectangles_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/rectangles` directory. @@ -87,4 +105,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/reverse-string/README.md b/exercises/reverse-string/README.md index 8d14e7e51b..20c31219a2 100644 --- a/exercises/reverse-string/README.md +++ b/exercises/reverse-string/README.md @@ -14,12 +14,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test reverse_string_test.py` +- Python 3.3+: `pytest reverse_string_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest reverse_string_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/reverse-string` directory. @@ -34,4 +52,5 @@ please see the [help page](http://exercism.io/languages/python). Introductory challenge to reverse an input string [https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb](https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/rna-transcription/README.md b/exercises/rna-transcription/README.md index 87eafae7ef..6e16ef43aa 100644 --- a/exercises/rna-transcription/README.md +++ b/exercises/rna-transcription/README.md @@ -29,12 +29,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test rna_transcription_test.py` +- Python 3.3+: `pytest rna_transcription_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest rna_transcription_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/rna-transcription` directory. @@ -49,4 +67,5 @@ please see the [help page](http://exercism.io/languages/python). Hyperphysics [http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html](http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/robot-name/README.md b/exercises/robot-name/README.md index 40905ff57f..a97128f573 100644 --- a/exercises/robot-name/README.md +++ b/exercises/robot-name/README.md @@ -23,12 +23,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test robot_name_test.py` +- Python 3.3+: `pytest robot_name_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest robot_name_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/robot-name` directory. @@ -43,4 +61,5 @@ please see the [help page](http://exercism.io/languages/python). A debugging session with Paul Blackwell at gSchool. [http://gschool.it](http://gschool.it) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/robot-simulator/README.md b/exercises/robot-simulator/README.md index 24f15c21ac..424db544b2 100644 --- a/exercises/robot-simulator/README.md +++ b/exercises/robot-simulator/README.md @@ -35,12 +35,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test robot_simulator_test.py` +- Python 3.3+: `pytest robot_simulator_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest robot_simulator_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/robot-simulator` directory. @@ -55,4 +73,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by an interview question at a famous company. ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/roman-numerals/README.md b/exercises/roman-numerals/README.md index 8cd9aa1ba2..7ebb3f444c 100644 --- a/exercises/roman-numerals/README.md +++ b/exercises/roman-numerals/README.md @@ -50,12 +50,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test roman_numerals_test.py` +- Python 3.3+: `pytest roman_numerals_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest roman_numerals_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/roman-numerals` directory. @@ -70,4 +88,5 @@ please see the [help page](http://exercism.io/languages/python). The Roman Numeral Kata [http://codingdojo.org/cgi-bin/index.pl?KataRomanNumerals](http://codingdojo.org/cgi-bin/index.pl?KataRomanNumerals) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/rotational-cipher/README.md b/exercises/rotational-cipher/README.md index 7d9b7ad992..f2c0336e92 100644 --- a/exercises/rotational-cipher/README.md +++ b/exercises/rotational-cipher/README.md @@ -38,12 +38,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test rotational_cipher_test.py` +- Python 3.3+: `pytest rotational_cipher_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest rotational_cipher_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/rotational-cipher` directory. @@ -58,4 +76,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Caesar_cipher](https://en.wikipedia.org/wiki/Caesar_cipher) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/run-length-encoding/README.md b/exercises/run-length-encoding/README.md index bce40597e7..bd813a2b3b 100644 --- a/exercises/run-length-encoding/README.md +++ b/exercises/run-length-encoding/README.md @@ -31,12 +31,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test run_length_encoding_test.py` +- Python 3.3+: `pytest run_length_encoding_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest run_length_encoding_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/run-length-encoding` directory. @@ -51,4 +69,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Run-length_encoding](https://en.wikipedia.org/wiki/Run-length_encoding) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/saddle-points/README.md b/exercises/saddle-points/README.md index 757d6ed46d..6f8e3eccf2 100644 --- a/exercises/saddle-points/README.md +++ b/exercises/saddle-points/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test saddle_points_test.py` +- Python 3.3+: `pytest saddle_points_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest saddle_points_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/saddle-points` directory. @@ -54,4 +72,5 @@ please see the [help page](http://exercism.io/languages/python). J Dalbey's Programming Practice problems [http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html](http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/say/README.md b/exercises/say/README.md index 41648422a8..ecd2b70756 100644 --- a/exercises/say/README.md +++ b/exercises/say/README.md @@ -70,12 +70,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test say_test.py` +- Python 3.3+: `pytest say_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest say_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/say` directory. @@ -90,4 +108,5 @@ please see the [help page](http://exercism.io/languages/python). A variation on JavaRanch CattleDrive, exercise 4a [http://www.javaranch.com/say.jsp](http://www.javaranch.com/say.jsp) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/scale-generator/README.md b/exercises/scale-generator/README.md index 8ca4c46250..0605364337 100644 --- a/exercises/scale-generator/README.md +++ b/exercises/scale-generator/README.md @@ -4,13 +4,13 @@ Given a tonic, or starting note, and a set of intervals, generate the musical scale starting with the tonic and following the specified interval pattern. -Scales in Western music are based on the chromatic (12-note) scale.This +Scales in Western music are based on the chromatic (12-note) scale. This scale can be expressed as the following group of pitches: A, A#, B, C, C#, D, D#, E, F, F#, G, G# -A given sharp note (indicated by a #), can also be expressed as the flat -of the note above it (indicated by a b), so the chromatic scale can also be +A given sharp note (indicated by a #) can also be expressed as the flat +of the note above it (indicated by a b) so the chromatic scale can also be written like this: A, Bb, B, C, Db, D, Eb, E, F, Gb, G, Ab @@ -20,9 +20,9 @@ collection. They have seven pitches, and are called diatonic scales. The collection of notes in these scales is written with either sharps or flats, depending on the tonic. Here is a list of which are which: -No Accidentals: +No Sharps or Flats: C major -A minor +a minor Use Sharps: G, D, A, E, B, F# major @@ -43,17 +43,10 @@ a "whole step" or "major second" (written as an upper-case "M"). The diatonic scales are built using only these two intervals between adjacent notes. -Non-diatonic scales can contain the same letter twice, and can contain other intervals. -Sometimes they may be smaller than usual (diminished, written "D"), or larger -(augmented, written "A"). Intervals larger than an augmented second have other names. - -Here is a table of pitches with the names of their interval distance from the tonic (A). - -| A | A# | B | C | C# | D | D# | E | F | F# | G | G# | A | -|:------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:------:| -| Unison | Min 2nd | Maj 2nd | Min 3rd | Maj 3rd | Per 4th | Tritone | Per 5th | Min 6th | Maj 6th | Min 7th | Maj 7th | Octave | -| | | Dim 3rd | Aug 2nd | Dim 4th | | Aug 4th | Dim 5th | Aug 5th | Dim 7th | Aug 6th | Dim 8ve | | -| | | | | | | Dim 5th | | | | | | | +Non-diatonic scales can contain other intervals. An "augmented first" +interval, written "A", has two interceding notes (e.g., from A to C or +Db to E). There are also smaller and larger intervals, but they will not +figure into this exercise. ## Exception messages @@ -63,12 +56,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test scale_generator_test.py` +- Python 3.3+: `pytest scale_generator_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest scale_generator_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/scale-generator` directory. @@ -79,4 +90,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/scrabble-score/README.md b/exercises/scrabble-score/README.md index 895179f2c9..c804196097 100644 --- a/exercises/scrabble-score/README.md +++ b/exercises/scrabble-score/README.md @@ -47,12 +47,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test scrabble_score_test.py` +- Python 3.3+: `pytest scrabble_score_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest scrabble_score_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/scrabble-score` directory. @@ -67,4 +85,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/secret-handshake/README.md b/exercises/secret-handshake/README.md index 9f52ea2c52..0b9820e933 100644 --- a/exercises/secret-handshake/README.md +++ b/exercises/secret-handshake/README.md @@ -36,12 +36,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test secret_handshake_test.py` +- Python 3.3+: `pytest secret_handshake_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest secret_handshake_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/secret-handshake` directory. @@ -56,4 +74,5 @@ please see the [help page](http://exercism.io/languages/python). Bert, in Mary Poppins [http://www.imdb.com/title/tt0058331/quotes/qt0437047](http://www.imdb.com/title/tt0058331/quotes/qt0437047) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/series/README.md b/exercises/series/README.md index 0049c5dfd9..4692f6e667 100644 --- a/exercises/series/README.md +++ b/exercises/series/README.md @@ -28,12 +28,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test series_test.py` +- Python 3.3+: `pytest series_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest series_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/series` directory. @@ -48,4 +66,5 @@ please see the [help page](http://exercism.io/languages/python). A subset of the Problem 8 at Project Euler [http://projecteuler.net/problem=8](http://projecteuler.net/problem=8) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/sgf-parsing/README.md b/exercises/sgf-parsing/README.md new file mode 100644 index 0000000000..8f123b308f --- /dev/null +++ b/exercises/sgf-parsing/README.md @@ -0,0 +1,110 @@ +# SGF Parsing + +Parsing a Smart Game Format string. + +[SGF](https://en.wikipedia.org/wiki/Smart_Game_Format) is a standard format for +storing board game files, in particular go. + +SGF is a fairly simple format. An SGF file usually contains a single +tree of nodes where each node is a property list. The property list +contains key value pairs, each key can only occur once but may have +multiple values. + +An SGF file may look like this: + +```text +(;FF[4]C[root]SZ[19];B[aa];W[ab]) +``` + +This is a tree with three nodes: + +- The top level node has two properties: FF\[4\] (key = "FF", value = + "4") and C\[root\](key = "C", value = "root"). (FF indicates the + version of SGF and C is a comment.) + - The top level node has a single child which has a single property: + B\[aa\]. (Black plays on the point encoded as "aa", which is the + 1-1 point (which is a stupid place to play)). + - The B\[aa\] node has a single child which has a single property: + W\[ab\]. + +As you can imagine an SGF file contains a lot of nodes with a single +child, which is why there's a shorthand for it. + +SGF can encode variations of play. Go players do a lot of backtracking +in their reviews (let's try this, doesn't work, let's try that) and SGF +supports variations of play sequences. For example: + +```text +(;FF[4](;B[aa];W[ab])(;B[dd];W[ee])) +``` + +Here the root node has two variations. The first (which by convention +indicates what's actually played) is where black plays on 1-1. Black was +sent this file by his teacher who pointed out a more sensible play in +the second child of the root node: `B[dd]` (4-4 point, a very standard +opening to take the corner). + +A key can have multiple values associated with it. For example: + +```text +(;FF[4];AB[aa][ab][ba]) +``` + +Here `AB` (add black) is used to add three black stones to the board. + +There are a few more complexities to SGF (and parsing in general), which +you can mostly ignore. You should assume that the input is encoded in +UTF-8, the tests won't contain a charset property, so don't worry about +that. Furthermore you may assume that all newlines are unix style (`\n`, +no `\r` or `\r\n` will be in the tests) and that no optional whitespace +between properties, nodes, etc will be in the tests. + +The exercise will have you parse an SGF string and return a tree +structure of properties. You do not need to encode knowledge about the +data types of properties, just use the rules for the +[text](http://www.red-bean.com/sgf/sgf4.html#text) type everywhere. + +## Exception messages + +Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to +indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not +every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include +a message. + +To raise a message with an exception, just write it as an argument to the exception type. For example, instead of +`raise Exception`, you should write: + +```python +raise Exception("Meaningful message indicating the source of the error") +``` + +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test sgf_parsing_test.py` +- Python 3.3+: `pytest sgf_parsing_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest sgf_parsing_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + +## Submitting Exercises + +Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/sgf-parsing` directory. + +You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`. + +For more detailed information about running tests, code style and linting, +please see the [help page](http://exercism.io/languages/python). + +## Submitting Incomplete Solutions + +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/sgf-parsing/example.py b/exercises/sgf-parsing/example.py new file mode 100644 index 0000000000..008c2a36ee --- /dev/null +++ b/exercises/sgf-parsing/example.py @@ -0,0 +1,100 @@ +class SgfTree(object): + def __init__(self, properties=None, children=None): + self.properties = properties or {} + self.children = children or [] + + def __eq__(self, other): + if not isinstance(other, SgfTree): + return False + for k, v in self.properties.items(): + if k not in other.properties: + return False + if other.properties[k] != v: + return False + for k in other.properties.keys(): + if k not in self.properties: + return False + if len(self.children) != len(other.children): + return False + for a, b in zip(self.children, other.children): + if not (a == b): + return False + return True + + def __repr__(self): + """Ironically, encoding to SGF is much easier""" + rep = '(;' + for k, vs in self.properties.items(): + rep += k + for v in vs: + rep += '[{}]'.format(v) + if self.children: + if len(self.children) > 1: + rep += '(' + for c in self.children: + rep += repr(c)[1:-1] + if len(self.children) > 1: + rep += ')' + return rep + ')' + + +def is_upper(s): + a, z = map(ord, 'AZ') + return all( + a <= o and o <= z + for o in map(ord, s) + ) + + +def parse(input_string): + root = None + current = None + stack = list(input_string) + + def assert_that(condition): + if not condition: + raise ValueError( + 'invalid format at {}:{}: {}'.format( + repr(input_string), + len(input_string) - len(stack), + repr(''.join(stack)) + ) + ) + assert_that(stack) + + def pop(): + if stack[0] == '\\': + stack.pop(0) + ch = stack.pop(0) + return ' ' if ch in '\n\t' else ch + + def peek(): + return stack[0] + + def pop_until(ch): + v = '' + while peek() != ch: + v += pop() + return v + while stack: + assert_that(pop() == '(' and peek() == ';') + while pop() == ';': + properties = {} + while is_upper(peek()): + key = pop_until('[') + assert_that(is_upper(key)) + values = [] + while peek() == '[': + pop() + values.append(pop_until(']')) + pop() + properties[key] = values + if root is None: + current = root = SgfTree(properties) + else: + current = SgfTree(properties) + root.children.append(current) + while peek() == '(': + child_input = pop() + pop_until(')') + pop() + current.children.append(parse(child_input)) + return root diff --git a/exercises/sgf-parsing/sgf_parsing.py b/exercises/sgf-parsing/sgf_parsing.py new file mode 100644 index 0000000000..4f3e7f7ca7 --- /dev/null +++ b/exercises/sgf-parsing/sgf_parsing.py @@ -0,0 +1,26 @@ +class SgfTree(object): + def __init__(self, properties=None, children=None): + self.properties = properties or {} + self.children = children or [] + + def __eq__(self, other): + if not isinstance(other, SgfTree): + return False + for k, v in self.properties.items(): + if k not in other.properties: + return False + if other.properties[k] != v: + return False + for k in other.properties.keys(): + if k not in self.properties: + return False + if len(self.children) != len(other.children): + return False + for a, b in zip(self.children, other.children): + if a != b: + return False + return True + + +def parse(input_string): + pass diff --git a/exercises/sgf-parsing/sgf_parsing_test.py b/exercises/sgf-parsing/sgf_parsing_test.py new file mode 100644 index 0000000000..6bd6100026 --- /dev/null +++ b/exercises/sgf-parsing/sgf_parsing_test.py @@ -0,0 +1,94 @@ +import unittest + +from sgf_parsing import parse, SgfTree + + +class SgfParsingTest(unittest.TestCase): + def test_empty_input(self): + input_string = '' + with self.assertRaisesWithMessage(ValueError): + parse(input_string) + + def test_tree_with_no_nodes(self): + input_string = '()' + with self.assertRaisesWithMessage(ValueError): + parse(input_string) + + def test_node_without_tree(self): + input_string = ';' + with self.assertRaisesWithMessage(ValueError): + parse(input_string) + + def test_node_without_properties(self): + input_string = '(;)' + expected = SgfTree() + self.assertEqual(parse(input_string), expected) + + def test_single_node_tree(self): + input_string = '(;A[B])' + expected = SgfTree(properties={'A': ['B']}) + self.assertEqual(parse(input_string), expected) + + def test_properties_without_delimiter(self): + input_string = '(;a)' + with self.assertRaisesWithMessage(ValueError): + parse(input_string) + + def test_all_lowercase_property(self): + input_string = '(;a[b])' + with self.assertRaisesWithMessage(ValueError): + parse(input_string) + + def test_upper_and_lowercase_property(self): + input_string = '(;Aa[b])' + with self.assertRaisesWithMessage(ValueError): + parse(input_string) + + def test_two_nodes(self): + input_string = '(;A[B];B[C])' + expected = SgfTree( + properties={'A': ['B']}, + children=[ + SgfTree({'B': ['C']}) + ] + ) + self.assertEqual(parse(input_string), expected) + + def test_two_child_trees(self): + input_string = '(;A[B](;B[C])(;C[D]))' + expected = SgfTree( + properties={'A': ['B']}, + children=[ + SgfTree({'B': ['C']}), + SgfTree({'C': ['D']}), + ] + ) + self.assertEqual(parse(input_string), expected) + + def test_multiple_property_values(self): + input_string = '(;A[b][c][d])' + expected = SgfTree( + properties={'A': ['b', 'c', 'd']} + ) + self.assertEqual(parse(input_string), expected) + + def test_escaped_property(self): + input_string = '(;A[\]b\nc\nd\t\te \n\]])' + expected = SgfTree( + properties={'A': [']b c d e ]']} + ) + self.assertEqual(parse(input_string), expected) + + # Utility functions + def setUp(self): + try: + self.assertRaisesRegex + except AttributeError: + self.assertRaisesRegex = self.assertRaisesRegexp + + def assertRaisesWithMessage(self, exception): + return self.assertRaisesRegex(exception, r".+") + + +if __name__ == '__main__': + unittest.main() diff --git a/exercises/sieve/README.md b/exercises/sieve/README.md index a8d686670a..4300b7b349 100644 --- a/exercises/sieve/README.md +++ b/exercises/sieve/README.md @@ -35,12 +35,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test sieve_test.py` +- Python 3.3+: `pytest sieve_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest sieve_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/sieve` directory. @@ -55,4 +73,5 @@ please see the [help page](http://exercism.io/languages/python). Sieve of Eratosthenes at Wikipedia [http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/simple-cipher/README.md b/exercises/simple-cipher/README.md index 3a7984564f..44ec09a655 100644 --- a/exercises/simple-cipher/README.md +++ b/exercises/simple-cipher/README.md @@ -107,12 +107,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test simple_cipher_test.py` +- Python 3.3+: `pytest simple_cipher_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest simple_cipher_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/simple-cipher` directory. @@ -127,4 +145,5 @@ please see the [help page](http://exercism.io/languages/python). Substitution Cipher at Wikipedia [http://en.wikipedia.org/wiki/Substitution_cipher](http://en.wikipedia.org/wiki/Substitution_cipher) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/simple-linked-list/README.md b/exercises/simple-linked-list/README.md index 664c475530..cfca19f339 100644 --- a/exercises/simple-linked-list/README.md +++ b/exercises/simple-linked-list/README.md @@ -41,12 +41,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test simple_linked_list_test.py` +- Python 3.3+: `pytest simple_linked_list_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest simple_linked_list_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/simple-linked-list` directory. @@ -61,4 +79,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by 'Data Structures and Algorithms with Object-Oriented Design Patterns in Ruby', singly linked-lists. [http://www.brpreiss.com/books/opus8/html/page96.html#SECTION004300000000000000000](http://www.brpreiss.com/books/opus8/html/page96.html#SECTION004300000000000000000) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/space-age/README.md b/exercises/space-age/README.md index e9b5fdf32e..cc02b41896 100644 --- a/exercises/space-age/README.md +++ b/exercises/space-age/README.md @@ -25,12 +25,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test space_age_test.py` +- Python 3.3+: `pytest space_age_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest space_age_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/space-age` directory. @@ -45,4 +63,5 @@ please see the [help page](http://exercism.io/languages/python). Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=01](http://pine.fm/LearnToProgram/?Chapter=01) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/spiral-matrix/README.md b/exercises/spiral-matrix/README.md index 4fb24c8252..9fbde22c53 100644 --- a/exercises/spiral-matrix/README.md +++ b/exercises/spiral-matrix/README.md @@ -31,12 +31,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test spiral_matrix_test.py` +- Python 3.3+: `pytest spiral_matrix_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest spiral_matrix_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/spiral-matrix` directory. @@ -51,4 +69,5 @@ please see the [help page](http://exercism.io/languages/python). Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension. [https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/](https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/strain/README.md b/exercises/strain/README.md index 5f3444b625..1b3d296d9d 100644 --- a/exercises/strain/README.md +++ b/exercises/strain/README.md @@ -41,12 +41,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test strain_test.py` +- Python 3.3+: `pytest strain_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest strain_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/strain` directory. @@ -61,4 +79,5 @@ please see the [help page](http://exercism.io/languages/python). Conversation with James Edward Gray II [https://twitter.com/jeg2](https://twitter.com/jeg2) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/sublist/README.md b/exercises/sublist/README.md index 1f31c650bf..54bf3476d3 100644 --- a/exercises/sublist/README.md +++ b/exercises/sublist/README.md @@ -25,12 +25,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test sublist_test.py` +- Python 3.3+: `pytest sublist_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest sublist_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/sublist` directory. @@ -41,4 +59,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/sum-of-multiples/README.md b/exercises/sum-of-multiples/README.md index 53c898b9c8..3e4b4ab78e 100644 --- a/exercises/sum-of-multiples/README.md +++ b/exercises/sum-of-multiples/README.md @@ -16,12 +16,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test sum_of_multiples_test.py` +- Python 3.3+: `pytest sum_of_multiples_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest sum_of_multiples_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/sum-of-multiples` directory. @@ -36,4 +54,5 @@ please see the [help page](http://exercism.io/languages/python). A variation on Problem 1 at Project Euler [http://projecteuler.net/problem=1](http://projecteuler.net/problem=1) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/tournament/README.md b/exercises/tournament/README.md index 4d4f907adc..6e6ca9a0a2 100644 --- a/exercises/tournament/README.md +++ b/exercises/tournament/README.md @@ -72,12 +72,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test tournament_test.py` +- Python 3.3+: `pytest tournament_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest tournament_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/tournament` directory. @@ -88,4 +106,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/transpose/README.md b/exercises/transpose/README.md index c7d6e170f4..781c1e9496 100644 --- a/exercises/transpose/README.md +++ b/exercises/transpose/README.md @@ -66,12 +66,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test transpose_test.py` +- Python 3.3+: `pytest transpose_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest transpose_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/transpose` directory. @@ -86,4 +104,5 @@ please see the [help page](http://exercism.io/languages/python). Reddit r/dailyprogrammer challenge #270 [Easy]. [https://www.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text](https://www.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/tree-building/README.md b/exercises/tree-building/README.md index 249b1127e0..b83588ca3a 100644 --- a/exercises/tree-building/README.md +++ b/exercises/tree-building/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test tree_building_test.py` +- Python 3.3+: `pytest tree_building_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest tree_building_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/tree-building` directory. @@ -50,4 +68,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/triangle/README.md b/exercises/triangle/README.md index 1b0941d25e..79e49a220a 100644 --- a/exercises/triangle/README.md +++ b/exercises/triangle/README.md @@ -30,12 +30,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test triangle_test.py` +- Python 3.3+: `pytest triangle_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest triangle_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/triangle` directory. @@ -50,4 +68,5 @@ please see the [help page](http://exercism.io/languages/python). The Ruby Koans triangle project, parts 1 & 2 [http://rubykoans.com](http://rubykoans.com) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/trinary/README.md b/exercises/trinary/README.md index 91ce0c39bd..19046d98fe 100644 --- a/exercises/trinary/README.md +++ b/exercises/trinary/README.md @@ -29,12 +29,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test trinary_test.py` +- Python 3.3+: `pytest trinary_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest trinary_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/trinary` directory. @@ -49,4 +67,5 @@ please see the [help page](http://exercism.io/languages/python). All of Computer Science [http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-](http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/twelve-days/README.md b/exercises/twelve-days/README.md index cee2b8793f..4752145bad 100644 --- a/exercises/twelve-days/README.md +++ b/exercises/twelve-days/README.md @@ -36,12 +36,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test twelve_days_test.py` +- Python 3.3+: `pytest twelve_days_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest twelve_days_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/twelve-days` directory. @@ -56,4 +74,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [http://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)](http://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/two-bucket/README.md b/exercises/two-bucket/README.md index 3b413ef716..0061be0817 100644 --- a/exercises/two-bucket/README.md +++ b/exercises/two-bucket/README.md @@ -27,7 +27,7 @@ To conclude, the only valid moves are: - emptying one bucket and doing nothing to the other - filling one bucket and doing nothing to the other -Written with <3 at [Fullstack Academy](http://www.fullstackacademy.com/) by [Lindsay](http://lindsaylevine.com). +Written with <3 at [Fullstack Academy](http://www.fullstackacademy.com/) by Lindsay Levine. ## Exception messages @@ -37,12 +37,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test two_bucket_test.py` +- Python 3.3+: `pytest two_bucket_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest two_bucket_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/two-bucket` directory. @@ -57,4 +75,5 @@ please see the [help page](http://exercism.io/languages/python). Water Pouring Problem [http://demonstrations.wolfram.com/WaterPouringProblem/](http://demonstrations.wolfram.com/WaterPouringProblem/) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md index e697cc79d8..2f7d6b6a82 100644 --- a/exercises/two-fer/README.md +++ b/exercises/two-fer/README.md @@ -20,12 +20,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test two_fer_test.py` +- Python 3.3+: `pytest two_fer_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest two_fer_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/two-fer` directory. @@ -40,4 +58,5 @@ please see the [help page](http://exercism.io/languages/python). [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/variable-length-quantity/README.md b/exercises/variable-length-quantity/README.md index 455557f192..9e951b02e9 100644 --- a/exercises/variable-length-quantity/README.md +++ b/exercises/variable-length-quantity/README.md @@ -39,12 +39,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test variable_length_quantity_test.py` +- Python 3.3+: `pytest variable_length_quantity_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest variable_length_quantity_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/variable-length-quantity` directory. @@ -59,4 +77,5 @@ please see the [help page](http://exercism.io/languages/python). A poor Splice developer having to implement MIDI encoding/decoding. [https://splice.com](https://splice.com) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/word-count/README.md b/exercises/word-count/README.md index c4f09df094..9c41945510 100644 --- a/exercises/word-count/README.md +++ b/exercises/word-count/README.md @@ -19,12 +19,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test word_count_test.py` +- Python 3.3+: `pytest word_count_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest word_count_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/word-count` directory. @@ -39,4 +57,5 @@ please see the [help page](http://exercism.io/languages/python). This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour. ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/word-search/README.md b/exercises/word-search/README.md index a35864f6fa..09ef4a8e70 100644 --- a/exercises/word-search/README.md +++ b/exercises/word-search/README.md @@ -34,12 +34,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test word_search_test.py` +- Python 3.3+: `pytest word_search_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest word_search_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/word-search` directory. @@ -50,4 +68,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/wordy/README.md b/exercises/wordy/README.md index cd2b33f888..30f4898639 100644 --- a/exercises/wordy/README.md +++ b/exercises/wordy/README.md @@ -59,12 +59,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test wordy_test.py` +- Python 3.3+: `pytest wordy_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest wordy_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/wordy` directory. @@ -79,4 +97,5 @@ please see the [help page](http://exercism.io/languages/python). Inspired by one of the generated questions in the Extreme Startup game. [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/yacht/README.md b/exercises/yacht/README.md new file mode 100644 index 0000000000..f3a5ef4fde --- /dev/null +++ b/exercises/yacht/README.md @@ -0,0 +1,85 @@ +# Yacht + +# Score a single throw of dice in *Yacht* + +The dice game [Yacht](https://en.wikipedia.org/wiki/Yacht_(dice_game)) is from +the same family as Poker Dice, Generala and particularly Yahtzee, of which it +is a precursor. In the game, five dice are rolled and the result can be entered +in any of twelve categories. The score of a throw of the dice depends on +category chosen. + +## Scores in Yacht + + Category Score Example + Ones 1 × number of ones 1 1 1 4 5 scores 3 + Twos 2 × number of twos 2 2 3 4 5 scores 4 + Threes 3 × number of threes 3 3 3 3 3 scores 15 + Fours 4 × number of fours 1 2 3 3 5 scores 0 + Fives 5 × number of fives 5 1 5 2 5 scores 15 + Sixes 6 × number of sixes 2 3 4 5 6 scores 6 + Full House Total of the dice 3 3 3 5 5 scores 19 + Four of a Kind Total of the four dice 4 4 4 4 6 scores 16 + Little Straight 30 points 1 2 3 4 5 scores 30 + Big Straight 30 points 2 3 4 5 6 scores 30 + Choice Sum of the dice 2 3 3 4 6 scores 18 + Yacht 50 points 4 4 4 4 4 scores 50 + +If the dice do not satisfy the requirements of a category, the score is zero. +If, for example, *Four Of A Kind* is entered in the *Yacht* category, zero +points are scored. A *Yacht* scores zero if entered in the *Full House* category. + +## Task +Given a list of values for five dice and a category, your solution should return +the score of the dice for that category. If the dice do not satisfy the requirements +of the category your solution should return 0. You can assume that five values +will always be presented, and the value of each will be between one and six +inclusively. You should not assume that the dice are ordered. + +## Exception messages + +Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to +indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not +every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include +a message. + +To raise a message with an exception, just write it as an argument to the exception type. For example, instead of +`raise Exception`, you should write: + +```python +raise Exception("Meaningful message indicating the source of the error") +``` + +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test yacht_test.py` +- Python 3.3+: `pytest yacht_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest yacht_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + +## Submitting Exercises + +Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/yacht` directory. + +You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`. + +For more detailed information about running tests, code style and linting, +please see the [help page](http://exercism.io/languages/python). + +## Source + +James Kilfiger, using wikipedia [https://en.wikipedia.org/wiki/Yacht_(dice_game)](https://en.wikipedia.org/wiki/Yacht_(dice_game)) + +## Submitting Incomplete Solutions + +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/yacht/example.py b/exercises/yacht/example.py new file mode 100644 index 0000000000..67aa48a1ed --- /dev/null +++ b/exercises/yacht/example.py @@ -0,0 +1,65 @@ +from collections import Counter +from functools import partial + +YACHT = 0 +ONES = 1 +TWOS = 2 +THREES = 3 +FOURS = 4 +FIVES = 5 +SIXES = 6 +FULL_HOUSE = 7 +FOUR_OF_A_KIND = 8 +LITTLE_STRAIGHT = 9 +BIG_STRAIGHT = 10 +CHOICE = 11 + + +def ns(number, dice): + return sum(n for n in dice if n == number) + + +def full_house(dice): + counter = Counter(dice) + return sum(dice) if set(counter.values()) == {3, 2} else 0 + + +def four_of_a_kind(dice): + counter = Counter(dice) + number, count = counter.most_common()[0] + return 4 * number if count >= 4 else 0 + + +def little_straight(dice): + return 30 if set(dice) == {1, 2, 3, 4, 5} else 0 + + +def big_straight(dice): + return 30 if set(dice) == {2, 3, 4, 5, 6} else 0 + + +def yacht(dice): + return 50 if len(set(dice)) == 1 else 0 + + +functions = [ + yacht, + partial(ns, 1), + partial(ns, 2), + partial(ns, 3), + partial(ns, 4), + partial(ns, 5), + partial(ns, 6), + full_house, + four_of_a_kind, + little_straight, + big_straight, + sum, +] + + +def score(dice, category): + try: + return functions[category](dice) + except IndexError: + raise ValueError("no such category") diff --git a/exercises/yacht/yacht.py b/exercises/yacht/yacht.py new file mode 100644 index 0000000000..53aca69db4 --- /dev/null +++ b/exercises/yacht/yacht.py @@ -0,0 +1,18 @@ +# Score categories +# Change the values as you see fit +YACHT = None +ONES = None +TWOS = None +THREES = None +FOURS = None +FIVES = None +SIXES = None +FULL_HOUSE = None +FOUR_OF_A_KIND = None +LITTLE_STRAIGHT = None +BIG_STRAIGHT = None +CHOICE = None + + +def score(dice, category): + pass diff --git a/exercises/yacht/yacht_test.py b/exercises/yacht/yacht_test.py new file mode 100644 index 0000000000..423bb1b077 --- /dev/null +++ b/exercises/yacht/yacht_test.py @@ -0,0 +1,90 @@ +import unittest + +import yacht +from yacht import score + + +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0 + +class YachtTests(unittest.TestCase): + def test_yacht(self): + self.assertEqual(score([5, 5, 5, 5, 5], yacht.YACHT), 50) + + def test_not_yacht(self): + self.assertEqual(score([1, 3, 3, 2, 5], yacht.YACHT), 0) + + def test_ones(self): + self.assertEqual(score([1, 1, 1, 3, 5], yacht.ONES), 3) + + def test_ones_out_of_order(self): + self.assertEqual(score([3, 1, 1, 5, 1], yacht.ONES), 3) + + def test_no_ones(self): + self.assertEqual(score([4, 3, 6, 5, 5], yacht.ONES), 0) + + def test_twos(self): + self.assertEqual(score([2, 3, 4, 5, 6], yacht.TWOS), 2) + + def test_fours(self): + self.assertEqual(score([1, 4, 1, 4, 1], yacht.FOURS), 8) + + def test_yacht_counted_as_threes(self): + self.assertEqual(score([3, 3, 3, 3, 3], yacht.THREES), 15) + + def test_yacht_of_threes_counted_as_fives(self): + self.assertEqual(score([3, 3, 3, 3, 3], yacht.FIVES), 0) + + def test_sixes(self): + self.assertEqual(score([2, 3, 4, 5, 6], yacht.SIXES), 6) + + def test_full_house_two_small_three_big(self): + self.assertEqual(score([2, 2, 4, 4, 4], yacht.FULL_HOUSE), 16) + + def test_full_house_three_small_two_big(self): + self.assertEqual(score([5, 3, 3, 5, 3], yacht.FULL_HOUSE), 19) + + def test_two_pair_is_not_a_full_house(self): + self.assertEqual(score([2, 2, 4, 4, 5], yacht.FULL_HOUSE), 0) + + def test_yacht_is_not_a_full_house(self): + self.assertEqual(score([2, 2, 2, 2, 2], yacht.FULL_HOUSE), 0) + + def test_four_of_a_kind(self): + self.assertEqual(score([6, 6, 4, 6, 6], yacht.FOUR_OF_A_KIND), 24) + + def test_yacht_can_be_scored_as_four_of_a_kind(self): + self.assertEqual(score([3, 3, 3, 3, 3], yacht.FOUR_OF_A_KIND), 12) + + def test_full_house_is_not_four_of_a_kind(self): + self.assertEqual(score([3, 5, 4, 1, 2], yacht.FOUR_OF_A_KIND), 0) + + def test_little_straight(self): + self.assertEqual(score([3, 5, 4, 1, 2], yacht.LITTLE_STRAIGHT), 30) + + def test_little_straight_as_big_straight(self): + self.assertEqual(score([1, 2, 3, 4, 5], yacht.BIG_STRAIGHT), 0) + + def test_four_in_order_but_not_a_little_straight(self): + self.assertEqual(score([1, 1, 2, 3, 4], yacht.LITTLE_STRAIGHT), 0) + + def test_no_pairs_but_not_a_little_straight(self): + self.assertEqual(score([1, 2, 3, 4, 6], yacht.LITTLE_STRAIGHT), 0) + + def test_min_1_max_5_but_not_a_little_straight(self): + self.assertEqual(score([1, 1, 3, 4, 5], yacht.LITTLE_STRAIGHT), 0) + + def test_big_straight(self): + self.assertEqual(score([4, 6, 2, 5, 3], yacht.BIG_STRAIGHT), 30) + + def test_big_straight_as_little_straight(self): + self.assertEqual(score([6, 5, 4, 3, 2], yacht.LITTLE_STRAIGHT), 0) + + def test_choice(self): + self.assertEqual(score([3, 3, 5, 6, 6], yacht.CHOICE), 23) + + def test_yacht_as_choice(self): + self.assertEqual(score([2, 2, 2, 2, 2], yacht.CHOICE), 10) + + +if __name__ == '__main__': + unittest.main() diff --git a/exercises/zebra-puzzle/README.md b/exercises/zebra-puzzle/README.md index 999d096fcd..ff2539b14f 100644 --- a/exercises/zebra-puzzle/README.md +++ b/exercises/zebra-puzzle/README.md @@ -33,12 +33,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test zebra_puzzle_test.py` +- Python 3.3+: `pytest zebra_puzzle_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest zebra_puzzle_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/zebra-puzzle` directory. @@ -53,4 +71,5 @@ please see the [help page](http://exercism.io/languages/python). Wikipedia [https://en.wikipedia.org/wiki/Zebra_Puzzle](https://en.wikipedia.org/wiki/Zebra_Puzzle) ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/zipper/README.md b/exercises/zipper/README.md index a96ebf72b3..a9382cfa77 100644 --- a/exercises/zipper/README.md +++ b/exercises/zipper/README.md @@ -35,12 +35,30 @@ every exercise will require you to raise an exception, but for those that do, th a message. To raise a message with an exception, just write it as an argument to the exception type. For example, instead of -`raise Exception`, you shold write: +`raise Exception`, you should write: ```python raise Exception("Meaningful message indicating the source of the error") ``` +## Running the tests + +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): + +- Python 2.7: `py.test zipper_test.py` +- Python 3.3+: `pytest zipper_test.py` + +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest zipper_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + ## Submitting Exercises Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/zipper` directory. @@ -51,4 +69,5 @@ For more detailed information about running tests, code style and linting, please see the [help page](http://exercism.io/languages/python). ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/test/check-exercises.py b/test/check-exercises.py index b194ca3bde..ce8de45716 100755 --- a/test/check-exercises.py +++ b/test/check-exercises.py @@ -10,7 +10,7 @@ import json # Allow high-performance tests to be skipped -ALLOW_SKIP = ['largest-series-product'] +ALLOW_SKIP = ['alphametics', 'largest-series-product'] def python_executable_name():