Requirements: Python 3.9+
Running: python3 -m vpm < input.txt
| import sys | |
| if len(sys.argv) != 3: | |
| print('Usage: absent.py all.txt meet.txt') | |
| fn_all, fn_meet = sys.argv[1:] | |
| with open(fn_meet) as meet: | |
| participants = meet.read().splitlines() |
| A simple game logic example which demonstrates basic OOP techniques in Python. |
| import io | |
| import os.path | |
| from PIL import Image | |
| TEMPLATE = """ | |
| <!DOCTYPE html> | |
| <html> | |
| <head> |
Requirements: Python 3.9+
Running: python3 -m vpm < input.txt
| KBD_LAYOUT = { | |
| 'en': 'abcdefghijklmnopqrstuvwxyz[];\',.ABCDEFGHIJKLMNOPQRSTUVWXYZ{}:"<>`~@#$^&', | |
| 'ru': 'фисвуапршолдьтщзйкыегмцчняхъжэбюФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯХЪЖЭБЮёЁ"№;:?', | |
| 'uk': 'фисвуапршолдьтщзйкіегмцчняхїжєбюФИСВУАПРШОЛДЬТЩЗЙКІЕГМЦЧНЯХЇЖЄБЮ\'₴"№;:?' | |
| } |
| # Cellular automata | |
| # https://natureofcode.com/book/chapter-7-cellular-automata/ | |
| def ca(rule, ncells): | |
| def _next_cell(a, b, c): | |
| a <<= 1 | |
| a |= b | |
| a <<= 1 | |
| a |= c | |
| return (rule & (1 << a)) >> a |
| def reverse_bits(n): | |
| assert 1 <= n <= 1000000000,\ | |
| 'argument must be in range [1, 1000000000]' | |
| r = 0 | |
| while n: | |
| r <<= 1 | |
| r |= n & 1 | |
| n >>= 1 | |
| return r |
| def spiral(m, n): | |
| """ Spiral matrix traversal (counterclockwise). """ | |
| m -= 1 | |
| dx, dy = 0, 1 | |
| x, y = 0, -1 | |
| while m >= 0 and n >= 0: | |
| for _ in range(m if dx else n): | |
| x += dx | |
| y += dy |
| from collections import namedtuple | |
| from operator import itemgetter, sub | |
| class rgb: | |
| # https://www.w3.org/TR/REC-html40/types.html#h-6.5 | |
| _NAMED_COLORS = { | |
| 'black': 0x000000, | |
| 'green': 0x008000, | |
| 'silver': 0xC0C0C0, |
| import json | |
| import math | |
| import re | |
| import urllib.parse | |
| from collections import Counter | |
| from difflib import SequenceMatcher | |
| from pprint import pprint | |
| from tldextract import extract as tldextract | |
| from unidecode import unidecode |