Compare commits

...

6 Commits

Author SHA1 Message Date
Scarfinos
7aeced8c3a
Merge 23fac3c479 into f3f32ae3ca 2024-11-21 21:37:49 +05:30
pre-commit-ci[bot]
f3f32ae3ca
[pre-commit.ci] pre-commit autoupdate (#12385)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.3 → v0.7.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.3...v0.7.4)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-11-18 22:07:12 +01:00
Christian Clauss
e3bd7721c8
validate_filenames.py Shebang python for Windows (#12371) 2024-11-15 14:59:14 +01:00
pre-commit-ci[bot]
e3f3d668be
[pre-commit.ci] pre-commit autoupdate (#12370)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.7.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.2...v0.7.3)
- [github.com/abravalheri/validate-pyproject: v0.22 → v0.23](https://github.com/abravalheri/validate-pyproject/compare/v0.22...v0.23)

* Update sudoku_solver.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-11-11 21:05:50 +01:00
Scarfinos
23fac3c479 #9943 : improve coverage of average_mode.py 2024-10-30 09:55:48 +01:00
Scarfinos
66ab2a1f61 #9943 : adding some coverage for string 2024-10-27 23:35:36 +01:00
12 changed files with 40 additions and 5 deletions

View File

@ -16,7 +16,7 @@ repos:
- id: auto-walrus
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.7.4
hooks:
- id: ruff
- id: ruff-format
@ -42,7 +42,7 @@ repos:
pass_filenames: false
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.22
rev: v0.23
hooks:
- id: validate-pyproject

View File

@ -172,7 +172,7 @@ def solved(values):
def from_file(filename, sep="\n"):
"Parse a file into a list of strings, separated by sep."
return open(filename).read().strip().split(sep) # noqa: SIM115
return open(filename).read().strip().split(sep)
def random_puzzle(assignments=17):

View File

@ -7,6 +7,8 @@ def mode(input_list: list) -> list[Any]:
The input list may contain any Datastructure or any Datatype.
>>> mode([])
[]
>>> mode([2, 3, 4, 5, 3, 4, 2, 5, 2, 2, 4, 2, 2, 2])
[2]
>>> mode([3, 4, 5, 3, 4, 2, 5, 2, 2, 4, 4, 2, 2, 2])

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!python
import os
try:

View File

@ -59,6 +59,10 @@ def get_barcode(barcode: str) -> int:
>>> get_barcode("8718452538119")
8718452538119
>>> get_barcode("-367062129")
Traceback (most recent call last):
...
ValueError: The entered barcode has a negative value. Try again.
>>> get_barcode("dwefgiweuf")
Traceback (most recent call last):
...

View File

@ -14,6 +14,8 @@ def can_string_be_rearranged_as_palindrome_counter(
"""
A Palindrome is a String that reads the same forward as it does backwards.
Examples of Palindromes mom, dad, malayalam
>>> can_string_be_rearranged_as_palindrome("")
True
>>> can_string_be_rearranged_as_palindrome_counter("Momo")
True
>>> can_string_be_rearranged_as_palindrome_counter("Mother")

View File

@ -9,6 +9,8 @@ def check_anagrams(first_str: str, second_str: str) -> bool:
"""
Two strings are anagrams if they are made up of the same letters but are
arranged differently (ignoring the case).
>>> check_anagrams('This', 'These')
False
>>> check_anagrams('Silent', 'Listen')
True
>>> check_anagrams('This is a string', 'Is this a string')

View File

@ -6,6 +6,14 @@ def count_vowels(s: str) -> int:
:return: Number of vowels in the input string.
Examples:
>>> count_vowels(10)
Traceback (most recent call last):
...
ValueError: Input must be a string
>>> count_vowels(True)
Traceback (most recent call last):
...
ValueError: Input must be a string
>>> count_vowels("hello world")
3
>>> count_vowels("HELLO WORLD")

View File

@ -27,6 +27,8 @@ def luhn_validation(credit_card_number: str) -> bool:
True
>>> luhn_validation('41111111111111')
False
>>> luhn_validation('4678001415')
True
"""
cc_number = credit_card_number
total = 0

View File

@ -32,6 +32,11 @@ email_tests: tuple[tuple[str, bool], ...] = (
),
("i.like.underscores@but_its_not_allowed_in_this_part", False),
("", False),
(".startdot@example", False),
("enddot.@example", False),
("double..dot@example", False),
("example@-dashstart", False),
("example@dashend-", False),
)
# The maximum octets (one character as a standard unicode character is one byte)
@ -97,7 +102,7 @@ def is_valid_email_address(email: str) -> bool:
return False
# (6.) Validate the placement of "-" characters
if domain.startswith("-") or domain.endswith("."):
if domain.startswith("-") or domain.endswith("-"):
return False
# (7.) Validate the placement of "." characters

View File

@ -91,6 +91,14 @@ def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]:
>>> y1 = len(ops1[0]) - 1
>>> assemble_transformation(ops1, x1, y1)
[]
>>> ops2 = [['0', 'Ic', 'Iu'],
... ['Da', 'Da', 'Rau'],
... ['Dt', 'Dt', 'Rtu']]
>>> x2 = len(ops2) - 1
>>> y2 = len(ops2[0]) - 1
>>> assemble_transformation(ops2, x2, y2)
['Ic', 'Da', 'Rtu']
"""
if i == 0 and j == 0:
return []

View File

@ -88,6 +88,8 @@ def to_pascal_case(text: str) -> str:
def to_camel_case(text: str) -> str:
"""
>>> to_camel_case("")
'not valid string'
>>> to_camel_case("one two 31235three4four")
'oneTwo31235three4four'
"""