Skip to content

Commit 4856f9b

Browse files
committed
Adding more
1 parent c9d5884 commit 4856f9b

File tree

56 files changed

+557
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+557
-684
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
# Byte-compiled / optimized / DLL files
1212
__pycache__/
1313
*.py[cod]
14-

.pre-commit-config.yaml

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
# File configures YAPF to be used as a git hook with https://github.com/pre-commit/pre-commit
22
repos:
3-
- repo: https://github.com/pycqa/isort
4-
rev: 5.13.2
5-
hooks:
6-
- id: isort
7-
name: isort (python)
83
- repo: local
94
hooks:
105
- id: yapf
116
name: yapf
127
language: python
138
entry: yapf
14-
args: ["-p","-i","-r"]
9+
args: ["-p","-i","r"]
1510
types: [python]
16-
1711
- repo: https://github.com/pre-commit/pre-commit-hooks
1812
rev: v4.5.0
1913
hooks:
2014
- id: trailing-whitespace
2115
- id: check-yaml
2216
- id: check-docstring-first
2317
- id: check-added-large-files
18+
args: ['--maxkb=500']
2419
- id: check-ast
2520
- id: check-json
26-
types: [text]
27-
files: \.(json|template)$
2821
- id: pretty-format-json
22+
args:
23+
- "--autofix"
24+
- "--indent=2"
25+
- "--no-sort-keys"
2926
- id: debug-statements
3027
- id: check-merge-conflict
3128
- id: end-of-file-fixer
3229
- id: detect-private-key
3330
- id: mixed-line-ending
3431
- id: requirements-txt-fixer
3532
- id: fix-byte-order-marker
33+
- repo: https://github.com/asottile/reorder_python_imports
34+
rev: v3.12.0
35+
hooks:
36+
- id: reorder-python-imports

.style.yapf

+58-58
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1+
# YAPF Configuration File
2+
13
[style]
2-
based_on_style =
3-
column_limit = 88
4-
align_closing_bracket_with_visual_indent
5-
allow_multiline_lambdas
6-
allow_multiline_dictionary_keys
7-
allow_split_before_default_or_named_assigns =
8-
allow_split_before_dict_value =
9-
arithmetic_precedence_indication =
4+
based_on_style = pep8
5+
align_closing_bracket_with_visual_indent = False
6+
allow_multiline_lambdas = False
7+
allow_multiline_dictionary_keys = True
8+
allow_split_before_default_or_named_assigns = True
9+
allow_split_before_dict_value = True
10+
arithmetic_precedence_indication = True
1011
blank_lines_around_top_level_definition = 1
11-
blank_line_before_class_docstring = true
12+
blank_line_before_class_docstring = True
1213
blank_lines_between_top_level_imports_and_variables = 2
13-
coalesce_brackets =
14-
column_limit =
15-
continuation_align_style =
16-
continuation_indent_width =
17-
dedent_closing_brackets =
18-
disable_ending_comma_heuristic =
19-
disable_split_list_with_comment =
20-
each_dict_entry_on_separate_line =
21-
force_multiline_dict =
22-
i18n_comment =
23-
i18n_function_call =
24-
indent_blank_lines =
25-
indent_closing_brackets =
26-
indent_dictionary_value =
27-
indent_width =
28-
join_multiple_lines =
29-
no_spaces_around_selected_binary_operators =
30-
space_between_ending_comma_and_closing_bracket =
31-
space_inside_brackets =
32-
spaces_around_default_or_named_assign = true
33-
spaces_around_dict_delimiters = false
34-
spaces_around_list_delimiters = false
35-
spaces_around_power_operator = true
36-
spaces_around_subscript_colon =
37-
spaces_around_tuple_delimiters =
14+
coalesce_brackets = True
15+
column_limit = 120
16+
continuation_align_style = VALIGN-RIGHT
17+
continuation_indent_width = 4
18+
dedent_closing_brackets = True
19+
disable_ending_comma_heuristic = True
20+
each_dict_entry_on_separate_line = True
21+
force_multiline_dict = True
22+
i18n_comment = "#! TODO:"
23+
i18n_function_call = []
24+
indent_blank_lines = False
25+
indent_closing_brackets = True
26+
indent_dictionary_value = True
27+
indent_width = 2
28+
use_tabs = True
29+
join_multiple_lines = False
30+
no_spaces_around_selected_binary_operators = ['/']
31+
space_between_ending_comma_and_closing_bracket = False
32+
space_inside_brackets = False
33+
spaces_around_default_or_named_assign = True
34+
spaces_around_dict_delimiters = True
35+
spaces_around_list_delimiters = False
36+
spaces_around_power_operator = False
37+
spaces_around_subscript_colon = True
38+
spaces_around_tuple_delimiters = False
3839
spaces_before_comment="15, 20"
39-
split_all_comma_separated_values =
40-
split_all_top_level_comma_separated_values =
41-
split_arguments_when_comma_terminated =
42-
split_before_arithmetic_operator =
43-
split_before_bitwise_operator =
44-
split_before_closing_bracket =
45-
split_before_dict_set_generator =
46-
split_before_dot =
47-
split_before_expression_after_opening_paren =
48-
split_before_first_argument =
49-
split_before_logical_operator = true
50-
split_before_named_assigns =
51-
split_complex_comprehension =
52-
split_penalty_after_opening_bracket =
53-
split_penalty_after_unary_operator =
54-
split_penalty_arithmetic_operator =
55-
split_penalty_before_if_expr =
56-
split_penalty_bitwise_operator =
57-
split_penalty_comprehension =
58-
split_penalty_excess_character =
59-
split_penalty_for_added_line_split =
60-
split_penalty_import_names =
61-
split_penalty_logical_operator =
62-
use_tabs =
40+
split_all_comma_separated_values = False
41+
split_all_top_level_comma_separated_values = True
42+
split_arguments_when_comma_terminated = False
43+
split_before_arithmetic_operator = False
44+
split_before_bitwise_operator = False
45+
split_before_closing_bracket = True
46+
split_before_dict_set_generator = True
47+
split_before_dot = False
48+
split_before_expression_after_opening_paren = False
49+
split_before_first_argument = True
50+
split_before_logical_operator = True
51+
split_before_named_assigns = True
52+
split_complex_comprehension = True
53+
split_penalty_after_opening_bracket = 0
54+
split_penalty_after_unary_operator = 100
55+
split_penalty_arithmetic_operator = 0
56+
split_penalty_before_if_expr = 100
57+
split_penalty_bitwise_operator = 0
58+
split_penalty_comprehension = 100
59+
split_penalty_excess_character = 1
60+
split_penalty_for_added_line_split = 10
61+
split_penalty_import_names = 10
62+
split_penalty_logical_operator = 100

.yapfignore

-4
This file was deleted.

Codewars/1-kyu/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# Index
2-
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def move_zeros(array):
2-
return [x for x in array if x!=0] + [0] * array.count(0)
2+
return [x for x in array if x != 0] + [0] * array.count(0)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def solution(number):
2-
return sum(n for n in range(number) if n % 3 == 0 or n % 5 == 0)
2+
return sum(n for n in range(number) if n % 3 == 0 or n % 5 == 0)

Codewars/6-kyu/Split Strings/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
### Constraints
1414

15-
- If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_').
15+
- If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_').
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
def solution(s):
2-
result = []
3-
for i in range(0, len(s), 2):
4-
try:
5-
result.append("".join([s[i], s[i + 1]]))
6-
except IndexError:
7-
result.append("".join([s[-1:], "_"]))
8-
return result
2+
result = []
3+
for i in range(0, len(s), 2):
4+
try:
5+
result.append("".join([s[i], s[i + 1]]))
6+
except IndexError:
7+
result.append("".join([s[-1 :], "_"]))
8+
return result
+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
def solution(s):
2-
result = []
2+
result = []
33

4-
if len(s) % 2:
5-
s += '_'
6-
for i in range(0, len(s), 2):
7-
result.append(s[i : i + 2])
8-
return result
4+
if len(s) % 2:
5+
s += '_'
6+
for i in range(0, len(s), 2):
7+
result.append(s[i : i + 2])
8+
return result

Codewars/6-kyu/The lost beginning/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
### Constraints
1818

19-
-
19+
-
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Write your notes and observations here.
1+
Write your notes and observations here.

Codewars/7-kyu/Categorize New Member/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212

1313
### Constraints
1414

15-
- The Western Suburbs Croquet Club has two categories of membership, Senior and Open.
15+
- The Western Suburbs Croquet Club has two categories of membership, Senior and Open.
1616
- To be a senior, a member must be at least 55 years old and have a handicap greater than 7.
1717
- Input will consist of a list of pairs.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def openOrSenior(data):
2-
return ["Senior" if age >= 55 and handicap >= 8 else "Open" for (age, handicap) in data]
2+
return ["Senior" if age >= 55 and handicap >= 8 else "Open" for (age, handicap) in data]

Codewars/7-kyu/Convert a Number to a String!/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
### Constraints
1414

15-
- Output must be of type String.
15+
- Output must be of type String.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def number_to_string(num):
2-
return f"{num}"
2+
return f"{num}"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
def get_middle(s):
2-
index, odd = divmod(len(s), 2)
3-
return s[index] if odd else s[index - 1:index + 1]
2+
index, odd = divmod(len(s), 2)
3+
return s[index] if odd else s[index - 1 : index + 1]
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def get_total(costs, items, tax):
2-
return round(sum(costs.get(item, 0) for item in items) * (1 + tax), 2)
2+
return round(sum(costs.get(item, 0) for item in items) * (1+tax), 2)

Codewars/7-kyu/If you can't beat 'em, join 'em/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
### Constraints
1414

15-
- In the case of more than one list sharing the same sum, place them in the same order as they were provided.
15+
- In the case of more than one list sharing the same sum, place them in the same order as they were provided.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from itertools import chain
22

33
def cant_beat_so_join(lsts):
4-
return list(chain.from_iterable(sorted(lsts, key=sum, reverse=True)))
4+
return list(chain.from_iterable(sorted(lsts, key = sum, reverse = True)))

Codewars/7-kyu/Jaden Casing Strings/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
### Objective
1010

11-
- Write a Function that, performs Pascal-Case (capitalize every word's first letter) on a given string.
11+
- Write a Function that, performs Pascal-Case (capitalize every word's first letter) on a given string.
1212

1313
### Constraints
1414

15-
- Return type must be of type String.
15+
- Return type must be of type String.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def pascal_case(string):
2-
return ' '.join(word.capitalize() for word in string.split())
2+
return ' '.join(word.capitalize() for word in string.split())

Codewars/7-kyu/Number of People in the Bus/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
### Objective
1010

11-
- Write a Function that, given a list (or array) of integer pairs, representing the number of people that get on the bus (the first item) and the number of people that get off the bus (the second item) at a bus stop, returns the number of people who are still on the bus after the last bus stop (after the last array).
11+
- Write a Function that, given a list (or array) of integer pairs, representing the number of people that get on the bus (the first item) and the number of people that get off the bus (the second item) at a bus stop, returns the number of people who are still on the bus after the last bus stop (after the last array).
1212

1313
### Constraints
1414

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def number(bus_stops):
2-
return sum(on - off for on, off in bus_stops)
2+
return sum(on - off for on, off in bus_stops)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def reverse_words(sentence):
2-
return ' '.join(word[::-1] for word in sentence.split(' '))
2+
return ' '.join(word[::-1] for word in sentence.split(' '))

Codewars/7-kyu/String ends with/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
### Constraints
1414

15-
- Return type must be a boolean value.
15+
- Return type must be a boolean value.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def solution(string, ending):
2-
return ending in string[-len(ending):]
2+
return ending in string[-len(ending):]
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def solution(string, ending):
2-
return string.endswith(ending)
2+
return string.endswith(ending)

Codewars/8-kyu/Beginner - Lost Without a Map/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
### Objective
1010

1111
- Write a Function that, given an array of integers, returns a new array with each integer's value doubled.
12-
12+
1313
### Constraints
1414

15-
- The output must be a new List.
15+
- The output must be a new List.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def maps(a):
2-
return [2 * x for x in a]
2+
return [2 * x for x in a]

Codewars/8-kyu/Beginner Series #2 Clock/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
### Objective
1010

1111
- Write a Function that, given "H" for Hours, "M" for Minutes and "S" for Seconds, returns the sum of all in Milliseconds.
12-
12+
1313
### Constraints
1414

1515
- H must be between 0 and 23
1616
- M must be between 0 and 59
17-
- S must be between 0 and 59
17+
- S must be between 0 and 59
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def past(h, m, s):
2-
return (3600 * h + 60 * m + s) * 1000
2+
return (3600*h + 60*m + s) * 1000

Codewars/8-kyu/Convert boolean values to strings 'Yes' or 'No'/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
### Constraints
1414

15-
- Output must be of String type.
15+
- Output must be of String type.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def bool_to_word(bool):
2-
return ['No', 'Yes'][bool]
2+
return ['No', 'Yes'][bool]

0 commit comments

Comments
 (0)