Skip to content

Commit

Permalink
Update pyproject.toml config & GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesfranciscodev committed Apr 6, 2024
1 parent 0690e88 commit bfbea46
Show file tree
Hide file tree
Showing 128 changed files with 602 additions and 419 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install ruff
- name: Run Flake8
run: flake8
- name: Formatting
run: ruff check .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bin/*
lib/*
.DS_Store
__pycache__
poetry.lock
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![CodinGame](images/MeanMax_Logo.jpg)

The repository hosts solutions to diverse programming challenges from [CodinGame](https://www.codingame.com/), written in languages such as Python, C++, and Java. Each solution resides in a file named after the respective challenge. CodinGame offers developers a platform to enhance coding skills through engaging challenges, supporting multiple programming languages, and fostering friendly competition for solving challenges efficiently.
The "Solutions to CodinGame Puzzles" project is a comprehensive repository housing solutions to an array of programming challenges sourced from CodinGame, a platform designed to enhance coding skills through interactive challenges. This repository features solutions implemented in Python, C++, Java, and other languages, each neatly organized within files named after the respective challenge. Covering a spectrum of difficulty levels from easy to hard, these solutions tackle diverse topics such as variables, input/output handling, conditions, loops, arrays, graphs, and more. With a focus on efficiency and clarity, the project aims to serve as a valuable resource for developers seeking to sharpen their problem-solving abilities and explore various programming paradigms while enjoying the friendly competition fostered by CodinGame's platform. Additionally, the project provides detailed documentation and adheres to standardized coding practices, ensuring accessibility and ease of use for contributors and users alike.

![](https://img.shields.io/github/languages/count/charlesfranciscodev/codingame.svg) ![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg) ![](https://img.shields.io/badge/code%20style-flake8-black)

Expand Down Expand Up @@ -55,3 +55,16 @@ The repository hosts solutions to diverse programming challenges from [CodinGame
| Genome Sequencing 🧬 | [Python](./puzzles/python3/genome-sequencing) ★ | Strings, Shortest Common Supersequence |
| Blunder 2 🎱 | [Python](./puzzles/python3/blunder2) ★ | Pathfinding |
| Blunder 3 ⌛ | [Python](./puzzles/python3/blunder3) ★ | Time Complexity |

### Poetry

```shell
# Installing dependencies
poetry install

# Linting
poetry run ruff check .

# Formatting
poetry run ruff format .
```
2 changes: 1 addition & 1 deletion clash-of-code/fastest/arithmetic_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
for i in range(0, n):
a.append(str(x))
x += r
print(' '.join(a))
print(" ".join(a))
2 changes: 1 addition & 1 deletion clash-of-code/fastest/ball_drop_bounce.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
h = int(input())
print(h * 2 ** 6)
print(h * 2**6)
8 changes: 4 additions & 4 deletions clash-of-code/fastest/boom_ts_bing_ding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

for w in s.split():
if w == "boom":
if (x < 30):
if x < 30:
x += 1
elif w == "ts":
if (x > 0):
if x > 0:
x -= 1
elif w == "bing":
if (y < 10):
if y < 10:
y += 1
elif w == "ding":
if (y > 0):
if y > 0:
y -= 1

print("{} {}".format(x, y))
4 changes: 2 additions & 2 deletions clash-of-code/fastest/bubble_sort_books.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
a = []
n = int(input())
for i in range(n):
line = input().split(',')
line = input().split(",")
a.append((line[0], int(line[1])))

swapped = True
Expand All @@ -10,7 +10,7 @@
swapped = False
for i in range(0, len(a) - 1):
if a[i][0] > a[i + 1][0]:
nb_pages += (a[i][1] + a[i + 1][1])
nb_pages += a[i][1] + a[i + 1][1]
temp = a[i]
a[i] = a[i + 1]
a[i + 1] = temp
Expand Down
10 changes: 5 additions & 5 deletions clash-of-code/fastest/calc-weight/calc_weight.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
def calculate_actual_weight(body_weight, repetitions, exercise_type, added_weight):
if exercise_type == 'bp':
if exercise_type == "bp":
actual_weight = (added_weight + 20) * repetitions
elif exercise_type == 'lp':
elif exercise_type == "lp":
actual_weight = (added_weight + 47) * repetitions
elif exercise_type == 'p':
actual_weight = (added_weight + body_weight)
elif exercise_type == "p":
actual_weight = added_weight + body_weight
else:
actual_weight = 0

return actual_weight


if __name__ == '__main__':
if __name__ == "__main__":
# Get input from the user
body_weight = int(input())
repetitions = int(input())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ def test_large_list(self):
self.assertEqual(result, "returns")


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion clash-of-code/fastest/clash-royal/clash_royal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def clash_royal_match(health, level):
return "rawr", health


if __name__ == '__main__':
if __name__ == "__main__":
# Get input
health = int(input())
level = int(input())
Expand Down
2 changes: 1 addition & 1 deletion clash-of-code/fastest/clash-royal/test_clash_royal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def test_clash_royal_match(self):
self.assertEqual(remaining_health, -280)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion clash-of-code/fastest/coin_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
change[i] += 1
n -= coins[i]

print(' '.join(map(str, change)))
print(" ".join(map(str, change)))
16 changes: 10 additions & 6 deletions clash-of-code/fastest/color-code/color_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ def name_color(code):
return "white"

# Check if one value is >= 10 and the other two are < 10 (high-value color)
if (red >= 10 and green < 10 and blue < 10) or \
(red < 10 and green >= 10 and blue < 10) or \
(red < 10 and green < 10 and blue >= 10):
if (
(red >= 10 and green < 10 and blue < 10)
or (red < 10 and green >= 10 and blue < 10)
or (red < 10 and green < 10 and blue >= 10)
):
if red >= 10:
return "red"
elif green >= 10:
Expand All @@ -24,9 +26,11 @@ def name_color(code):
return "blue"

# Check if two colors are >= 10 and the other is < 10 (secondary colors)
if (red >= 10 and green >= 10 and blue < 10) or \
(red >= 10 and green < 10 and blue >= 10) or \
(red < 10 and green >= 10 and blue >= 10):
if (
(red >= 10 and green >= 10 and blue < 10)
or (red >= 10 and green < 10 and blue >= 10)
or (red < 10 and green >= 10 and blue >= 10)
):
if red >= 10 and blue >= 10:
return "magenta"
elif red >= 10 and green >= 10:
Expand Down
2 changes: 1 addition & 1 deletion clash-of-code/fastest/color-code/test_color_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ def test_grey_color(self):
self.assertEqual(result, "grey")


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
7 changes: 7 additions & 0 deletions clash-of-code/fastest/convert_number.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
def decimal_to_binary(decimal):
return bin(decimal)[2:]


def binary_to_decimal(binary):
return int(binary, 2)


def decimal_to_hexadecimal(decimal):
return hex(decimal)[2:].upper()


def hexadecimal_to_decimal(hexadecimal):
return int(hexadecimal, 16)


def binary_to_hexadecimal(binary):
decimal = binary_to_decimal(binary)
return decimal_to_hexadecimal(decimal)


def hexadecimal_to_binary(hexadecimal):
decimal = hexadecimal_to_decimal(hexadecimal)
return decimal_to_binary(decimal)


# Function to convert numbers based on input and output types
def convert_number(input_type, output_type, number):
if input_type == "bin" and output_type == "dec":
Expand All @@ -35,6 +41,7 @@ def convert_number(input_type, output_type, number):
else:
return None


# Main program
n = int(input())

Expand Down
2 changes: 1 addition & 1 deletion clash-of-code/fastest/count_letters_digits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
count_digits = 0
for c in s:
if c.isalpha():
count_letters +=1
count_letters += 1
elif c.isdigit():
count_digits += 1
print(round(count_letters / count_digits))
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ def find_cheating_couples(n, relationships):
partners[a] = set()
if b not in partners:
partners[b] = set()

partners[a].add(b)
partners[b].add(a)

# Count the couples where both partners are cheaters
for a, b in relationships:
if len(partners[a]) > 1 and len(partners[b]) > 1:
cheaters_count += 1

return cheaters_count


if __name__ == '__main__':
if __name__ == "__main__":
# Read input
n = int(input())
relationships = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def test_example_2(self):
self.assertEqual(find_cheating_couples(n, relationships), 2)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
3 changes: 2 additions & 1 deletion clash-of-code/fastest/find_lost_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ def find_lost_integer(numbers):

return None


# Read input until 0 is encountered
numbers = []
while True:
line = input().strip()
if line == '0':
if line == "0":
break
numbers.extend(map(int, line.split()))

Expand Down
2 changes: 1 addition & 1 deletion clash-of-code/fastest/game_nb_claps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
s = str(i)
if i % 7 == 0:
nb_claps += 1
elif '7' in s:
elif "7" in s:
nb_claps += 1
elif sum(map(int, s)) % 7 == 0:
nb_claps += 1
Expand Down
5 changes: 3 additions & 2 deletions clash-of-code/fastest/gold-mining/gold_mining.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ def maximum_gold(m, n, k, grid):
for j in range(0, n, k):
gold_sum = 0

for x in range(i, i+k):
for y in range(j, j+k):
for x in range(i, i + k):
for y in range(j, j + k):
gold_sum += grid[x][y]

max_gold = max(max_gold, gold_sum)

return max_gold


# Read input
m, n, k = map(int, input().split())
grid = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def test_harshad_number(self):
self.assertFalse(is_harshad_number(99)) # 9 + 9 = 18, 99 is not divisible by 18


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion clash-of-code/fastest/leet_speak.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
s = input()
leet_s = ""
leet_dict = {'o': '0', 'l': '1', 'z': '2', 'e': '3', 'a': '4', 's': '5', 'g': '6', 't': '7', 'b': '8', 'q': '9'}
leet_dict = {"o": "0", "l": "1", "z": "2", "e": "3", "a": "4", "s": "5", "g": "6", "t": "7", "b": "8", "q": "9"}

for c in s:
c_lower = c.lower()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def generate_leetspeak_variants(word):
leet_dict = {'A': '4', 'E': '3', 'I': '1', 'L': '1', 'T': '7', 'O': '0'}
leet_dict = {"A": "4", "E": "3", "I": "1", "L": "1", "T": "7", "O": "0"}
variants = set()

def generate_variants(current_variant, remaining_chars):
Expand All @@ -13,7 +13,7 @@ def generate_variants(current_variant, remaining_chars):

generate_variants(current_variant + char, rest)

generate_variants('', word)
generate_variants("", word)
return sorted(variants)


Expand Down
Loading

0 comments on commit bfbea46

Please sign in to comment.