Skip to content

Instantly share code, notes, and snippets.

View browneye1826's full-sized avatar
🇺🇦
Praying for Ukraine

browneye1826

🇺🇦
Praying for Ukraine
View GitHub Profile
import re
BOLD = r"__(.*?)__", r"<strong>\1</strong>"
ITALIC = r"_(.*?)_", r"<em>\1</em>"
LIST = re.compile(r"^\* (.*)", re.M), r"<li>\1</li>"
END_LIST = re.compile(r"(<li>.*</li>)", re.S), r"<ul>\1</ul>"
HEADER = (
(re.compile(r"^%s (.+)" % ("#" * i)), r"<h{0}>\1</h{0}>".format(i))
for i in range(6, 0, -1)
MAP = [
(1000, "M"),
(900, "CM"),
(500, "D"),
(400, "CD"),
(100, "C"),
(90, "XC"),
(50, "L"),
(40, "XL"),
(10, "X"),
def is_palindrome(word: str) -> bool:
"""Return True if the given word is a palindrome
Args:
word (str): the word to check
Returns:
A boolean value.
"""
return word == word[::-1]
def is_leap_year(year: int) -> bool:
"""Return True if the given year is a leap year, False otherwise
Args:
year (int): an integer representing the year
Returns:
A boolean value.
"""
return year % 400 == 0 if year % 100 == 0 else year % 4 == 0