Skip to content

Commit

Permalink
python/pangram: 1st iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Apr 23, 2024
1 parent 85f8e6d commit a48ec27
Show file tree
Hide file tree
Showing 15 changed files with 598 additions and 3 deletions.
1 change: 1 addition & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
- [scrabble-score](./scrabble-score/README.md)
- [difference-of-squares](./difference-of-squares/README.md)
- [luhn](./luhn/README.md)
- [pangram](./pangram/README.md)
1 change: 1 addition & 0 deletions python/pangram/.coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"arcs":{"/home/vpayno/git_vpayno/exercism-workspace/python/pangram/test/__init__.py":[[0,0],[0,-1]],"/home/vpayno/git_vpayno/exercism-workspace/python/pangram/pangram.py":[[0,1],[1,4],[4,-1],[4,15],[15,18],[18,18],[18,20],[20,-4],[15,16],[16,-4]]}}
33 changes: 33 additions & 0 deletions python/pangram/.coverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" ?>
<coverage branch-rate="0.75" branches-covered="3" branches-valid="4" complexity="0" line-rate="0.8333" lines-covered="5" lines-valid="6" timestamp="1713841617589" version="4.5.4">
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/home/vpayno/git_vpayno/exercism-workspace/python/pangram</source>
</sources>
<packages>
<package branch-rate="0.75" complexity="0" line-rate="0.8333" name=".">
<classes>
<class branch-rate="0.75" complexity="0" filename="pangram.py" line-rate="0.8333" name="pangram.py">
<methods/>
<lines>
<line hits="0" number="0"/>
<line hits="1" number="4"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="15"/>
<line hits="1" number="16"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="exit" number="18"/>
<line hits="1" number="20"/>
</lines>
</class>
</classes>
</package>
<package branch-rate="1" complexity="0" line-rate="1" name="test">
<classes>
<class branch-rate="1" complexity="0" filename="test/__init__.py" line-rate="1" name="__init__.py">
<methods/>
<lines/>
</class>
</classes>
</package>
</packages>
</coverage>
2 changes: 2 additions & 0 deletions python/pangram/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = __init__.py, *_test.py
1 change: 1 addition & 0 deletions python/pangram/.pylintrc
7 changes: 6 additions & 1 deletion python/pangram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ For this exercise, a sentence is a pangram if it contains each of the 26 letters

### Based on

Wikipedia - https://en.wikipedia.org/wiki/Pangram
Wikipedia - https://en.wikipedia.org/wiki/Pangram

### My Solution

- [my solution](./pangram.py)
- [run-tests](./run-tests-python.txt)
22 changes: 20 additions & 2 deletions python/pangram/pangram.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
def is_pangram(sentence):
pass
"""Python Pangram Exercism"""


def is_pangram(text: str) -> bool:
"""Is the input a pangram?
>>> text: set[str] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz"
>>> len(sorted({r for r in text.lower() if r.isalpha()}))
26
:param text: string
:return: bool
"""

if not text or len(text) < 26:
return False

letters: set[str] = {r for r in text.lower() if r.isalpha()}

return len(letters) == 26
20 changes: 20 additions & 0 deletions python/pangram/pangram.py,cover
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
> """Python Pangram Exercism"""


> def is_pangram(text: str) -> bool:
> """Is the input a pangram?

> >>> text: set[str] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz"
> >>> len(sorted({r for r in text.lower() if r.isalpha()}))
> 26

> :param text: string
> :return: bool
> """

> if not text or len(text) < 26:
> return False

> letters: set[str] = {r for r in text.lower() if r.isalpha()}

> return len(letters) == 26
5 changes: 5 additions & 0 deletions python/pangram/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
pythonpath = .
addopts = --doctest-modules
markers =
task: exercise task/step
Loading

0 comments on commit a48ec27

Please sign in to comment.