This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAP = [ | |
(1000, "M"), | |
(900, "CM"), | |
(500, "D"), | |
(400, "CD"), | |
(100, "C"), | |
(90, "XC"), | |
(50, "L"), | |
(40, "XL"), | |
(10, "X"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |