Posts
Category Archives: Uncategorized
QP – LCM
Find the least common multiple of an array of numbers #!/usr/bin/python3 import sys from math import gcd def lcm_list(nums): from functools import reduce def lcm(a, b): return a * b // gcd(a, b) return reduce(lcm, nums) nums = list(map(int, sys.argv[1:])) … Continue reading
Posted in Uncategorized
Leave a comment
QR – Unicode
Print a range of unicode characters #!/usr/bin/python3 import sys a = int(sys.argv[1],16) b = int(sys.argv[2],16) for i in range(a,b + 1): print(” “.join([str(hex(i)),” “,chr(i)]))
Posted in Uncategorized
Leave a comment
QS – Uppercase
Make the first field of standard input uppercase: python3 -c “import sys;[print(l.split()[0].upper(),*l.split()[1:]) for l in sys.stdin]”
Posted in Uncategorized
Leave a comment
QT – Italic
𝘊𝘰𝘯𝘷𝘦𝘳𝘵 𝘱𝘭𝘢𝘪𝘯 𝘵𝘦𝘹𝘵 𝘵𝘰 𝘶𝘯𝘪𝘤𝘰𝘥𝘦 𝘪𝘵𝘢𝘭𝘪𝘤 #!/usr/bin/python3 import sys str = ‘ ‘.join(sys.argv[1:]) def bold(input_text): chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz” bold_chars = “𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻” output = “” for character in input_text: if character in chars: output += bold_chars[chars.index(character)] else: output += character return … Continue reading
Posted in Uncategorized
Leave a comment