We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2d1410c commit a3d775bCopy full SHA for a3d775b
.pre-commit-config.yaml
@@ -0,0 +1,12 @@
1
+repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.12.7
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+
8
+ - repo: https://github.com/psf/black
9
+ rev: 25.1.0
10
11
+ - id: black
12
+ language_version: python3.13
array_string/can_place_flowers/solution.py
@@ -8,7 +8,9 @@ def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:
for index in range(len(flowerbed)):
if flowerbed[index] == 0:
left_is_empty = (index == 0) or (flowerbed[index - 1] == 0)
- right_is_empty = (index == len(flowerbed) - 1) or (flowerbed[index + 1] == 0)
+ right_is_empty = (index == len(flowerbed) - 1) or (
+ flowerbed[index + 1] == 0
13
+ )
14
if left_is_empty and right_is_empty:
15
flowerbed[index] = 1
16
counter += 1
array_string/greatest_common_divisor_of_strings/solution.py
@@ -12,4 +12,4 @@ def is_valid_gcd(index):
for i in range(min(length1, length2), 0, -1):
if is_valid_gcd(i):
return str1[:i]
- return ""
+ return ""
array_string/kids_with_the_greatest_number_of_candies/solution.py
@@ -4,4 +4,6 @@
class Solution:
def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]:
max_candies = max(candies)
- return [current_candies + extraCandies >= max_candies for current_candies in candies]
+ return [
+ current_candies + extraCandies >= max_candies for current_candies in candies
+ ]
array_string/merge_strings_alternately/solution.py
@@ -8,4 +8,4 @@ def mergeAlternately(self, word1: str, word2: str) -> str:
if index < len(word2):
result.append(word2[index])
- return ''.join(result)
+ return "".join(result)
tests/test_can_place_flowers.py
@@ -1,14 +1,18 @@
import pytest
from array_string.can_place_flowers.solution import Solution
-@pytest.mark.parametrize("flowerbed, n, expected", [
- ([1, 0, 0, 0, 1], 1, True),
- ([1, 0, 0, 0, 1], 2, False),
- ([1,0,1,0,1,0,1], 1, False),
- ([1, 0, 0, 0, 1, 0, 0], 2, True),
- ([0], 1, True),
- ([1,0,1,0,1,0,1], 0, True)
-])
+@pytest.mark.parametrize(
+ "flowerbed, n, expected",
+ [
+ ([1, 0, 0, 0, 1], 1, True),
+ ([1, 0, 0, 0, 1], 2, False),
+ ([1, 0, 1, 0, 1, 0, 1], 1, False),
+ ([1, 0, 0, 0, 1, 0, 0], 2, True),
+ ([0], 1, True),
+ ([1, 0, 1, 0, 1, 0, 1], 0, True),
+ ],
+)
def test_merge_alternately(flowerbed, n, expected):
17
solution = Solution()
- assert solution.canPlaceFlowers(flowerbed, n) == expected
18
+ assert solution.canPlaceFlowers(flowerbed, n) == expected
tests/test_greatest_common_divisor_of_strings.py
@@ -1,11 +1,11 @@
from array_string.greatest_common_divisor_of_strings.solution import Solution
-@pytest.mark.parametrize("str1, str2, expected", [
- ("ABCABC", "ABC", "ABC"),
- ("ABABAB", "ABAB", "AB"),
- ("LEET", "CODE", "")
+ "str1, str2, expected",
+ [("ABCABC", "ABC", "ABC"), ("ABABAB", "ABAB", "AB"), ("LEET", "CODE", "")],
def test_merge_alternately(str1, str2, expected):
- assert solution.gcdOfStrings(str1, str2) == expected
+ assert solution.gcdOfStrings(str1, str2) == expected
tests/test_kids_with_candies.py
@@ -1,11 +1,15 @@
from array_string.kids_with_the_greatest_number_of_candies.solution import Solution
-@pytest.mark.parametrize("candies, extraCandies, expected", [
- ([2, 3, 5, 1, 3], 3, [True, True, True, False, True] ),
- ([4, 2, 1, 1, 2], 1, [True, False, False, False, False]),
- ([12, 1, 12], 10, [True, False, True])
+ "candies, extraCandies, expected",
+ ([2, 3, 5, 1, 3], 3, [True, True, True, False, True]),
+ ([4, 2, 1, 1, 2], 1, [True, False, False, False, False]),
+ ([12, 1, 12], 10, [True, False, True]),
def test_merge_alternately(candies, extraCandies, expected):
- assert solution.kidsWithCandies(candies, extraCandies) == expected
+ assert solution.kidsWithCandies(candies, extraCandies) == expected
tests/test_merge_strings_alternately.py
from array_string.merge_strings_alternately.solution import Solution
-@pytest.mark.parametrize("word1, word2, expected", [
- ("abc", "pqr", "apbqcr"),
- ("ab", "pqrs", "apbqrs"),
- ("abcd", "pq", "apbqcd")
+ "word1, word2, expected",
+ [("abc", "pqr", "apbqcr"), ("ab", "pqrs", "apbqrs"), ("abcd", "pq", "apbqcd")],
def test_merge_alternately(word1, word2, expected):
- assert solution.mergeAlternately(word1, word2) == expected
+ assert solution.mergeAlternately(word1, word2) == expected
0 commit comments