Skip to content

Instantly share code, notes, and snippets.

View Binyoh1's full-sized avatar

Binyoh Langhe Theodore Binyoh1

View GitHub Profile
@Binyoh1
Binyoh1 / exercism_triangle.py
Created December 2, 2024 07:34
Solution to the Triangle exercise on the Exercism Python Track
def equilateral(sides):
return len(set(sides)) == 1 and (sides[0] + sides[1] >= sides[2] and sides[0] + sides[2] >= sides[1] and sides[1] + sides[2] >= sides[0]) and 0 not in sides
def isosceles(sides):
return len(set(sides)) <= 2 and (sides[0] + sides[1] >= sides[2] and sides[0] + sides[2] >= sides[1] and sides[1] + sides[2] >= sides[0])
def scalene(sides):
return len(set(sides)) == 3 and (sides[0] + sides[1] >= sides[2] and sides[0] + sides[2] >= sides[1] and sides[1] + sides[2] >= sides[0])
@Binyoh1
Binyoh1 / exercism_leap.py
Last active December 2, 2024 07:33
Solution to the Leap exercise on the Exercism Python Track
def leap_year(year):
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
@Binyoh1
Binyoh1 / exercism_ghost_gobble_arcade_game.py
Created December 2, 2024 07:30
Solution to the Ghost Gobble Arcade Game exercise on the Exercism Python Track
def eat_ghost(power_pellet_active, touching_ghost):
return power_pellet_active and touching_ghost
def score(touching_power_pellet, touching_dot):
return touching_power_pellet or touching_dot
def lose(power_pellet_active, touching_ghost):
return not power_pellet_active and touching_ghost
def win(has_eaten_all_dots, power_pellet_active, touching_ghost):
@Binyoh1
Binyoh1 / exercism_square_root.py
Created December 2, 2024 07:27
Solution to the Square Root exercise on the Exercism Python Track
def square_root(number):
return number ** 0.5
@Binyoh1
Binyoh1 / exercism_armstrong_numbers.py
Created December 2, 2024 07:25
Solution tot he Armstrong Numbers exercise on the Exercism Python Track
def is_armstrong_number(number):
return number == sum(int(digit)**len(str(number)) for digit in str(number)
@Binyoh1
Binyoh1 / exercism_grains.py
Created December 2, 2024 07:23
Solution to the Grains exercise on the Exercism Python Track
def square(number):
if number not in range(1, 65):
raise ValueError("square must be between 1 and 64")
else:
return pow(2, number-1)
def total():
return pow(2, 64) - 1
@Binyoh1
Binyoh1 / exercism_collatz_conjecture.py
Created December 2, 2024 07:22
Solution to the Collatz Conjecture exercise on the Exercism Python Track
def steps(number):
if number < 1 or type(number) != int:
raise ValueError("Only positive integers are allowed")
step_count = 0
while number != 1:
number = number // 2 if number % 2 == 0 else 3 * number + 1
step_count += 1
return step_count
@Binyoh1
Binyoh1 / exercism_guidos_gorgeous_lasagna.py
Created December 2, 2024 07:20
Solution to the Guido's Gorgeous Lasagna exercise on the Exercism Python Track
def bake_time_remaining(elapsed_bake_time):
return EXPECTED_BAKE_TIME - elapsed_bake_time
def preparation_time_in_minutes(number_of_layers):
return number_of_layers * PREPARATION_TIME
def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
return preparation_time_in_minutes(number_of_layers) + int(elapsed_bake_time)
@Binyoh1
Binyoh1 / exercism_currency_exchange.py
Created December 2, 2024 07:16
Solution to the Currency Exchange exercise on the Exercism Python Track
def exchange_money(budget, exchange_rate):
return budget / exchange_rate
def get_change(budget, exchanging_value):
return budget - exchanging_value
def get_value_of_bills(denomination, number_of_bills):
return int(denomination * number_of_bills)
def get_number_of_bills(amount, denomination):
return amount // denomination
def get_leftover_of_bills(amount, denomination):
return amount % denomination