# ----------------------------
# Homework Hack 1: Binary Converter
# ----------------------------

# Function to convert decimal to binary
def decimal_to_binary(decimal_num):
    if decimal_num >= 0:
        return bin(decimal_num)[2:]  # Remove '0b' prefix for positive numbers
    else:
        return '-' + bin(abs(decimal_num))[2:]  # Handle negative numbers

# Function to convert binary (as string) to decimal
def binary_to_decimal(binary_str):
    if binary_str.startswith('-'):
        return -int(binary_str[1:], 2)
    else:
        return int(binary_str, 2)

# Test cases
print("Decimal to Binary Examples:")
print("10 →", decimal_to_binary(10))
print("-5 →", decimal_to_binary(-5))
print("0 →", decimal_to_binary(0))

print("\nBinary to Decimal Examples:")
print("1010 →", binary_to_decimal("1010"))
print("-101 →", binary_to_decimal("-101"))
print("0 →", binary_to_decimal("0"))

Decimal to Binary Examples:
10 → 1010
-5 → -101
0 → 0

Binary to Decimal Examples:
1010 → 10
-101 → -5
0 → 0
# ----------------------------
# Homework Hack 2: Difficulty Level Checker
# ----------------------------

import time

valid_difficulties = ["easy", "medium", "hard"]

difficulty = input("Enter difficulty (easy, medium, hard): ").lower().strip()

# Keep asking until a valid difficulty level is entered
while difficulty not in valid_difficulties:
    print("Please enter a valid difficulty level.")
    time.sleep(0.5)
    difficulty = input("Enter difficulty (easy, medium, hard): ").lower().strip()

print("Difficulty set to:", difficulty)

Difficulty set to: easy