Skip to content

Instantly share code, notes, and snippets.

View md2perpe's full-sized avatar

Per Persson md2perpe

View GitHub Profile
@md2perpe
md2perpe / .gitignore
Last active April 17, 2024 23:36
StackOverflow 64497615
venv/
*.pyc
@md2perpe
md2perpe / fizzbuzz.py
Created December 28, 2020 18:38
FizzBuzz
from itertools import count, cycle
for (n, d3, d5) in zip(count(0), cycle([True, False, False]), cycle([True, False, False, False, False])):
print(("Fizz" if d3 else "")+("Buzz" if d5 else "") or str(n))
@md2perpe
md2perpe / solve.py
Created December 25, 2020 16:32
Solve a specific character addition
# Solve:
# LETA
# +TALL
# =====
# CACHE
for a in range(10):
for e in range(10):
for l in range(10):
for t in range(10):
@md2perpe
md2perpe / .gitignore
Last active December 23, 2020 16:40
Hello world in x86-64 assembly
*.o
@md2perpe
md2perpe / solution.py
Created December 10, 2020 01:11
Simple coding challenge found on Facebook
# https://www.facebook.com/groups/270834543757117/?creative_provider_id=admin_can_post_branded_content&notif_id=1607539332809717&notif_t=qp_notifs_pups_notification_to_mall_dogfood_1730789509&ref=notif
N = 10
for i in range(N):
print("He" * i)
print("Ha" * i)
print("Hi" * i)
# Maximum unattacked squares
def attacked_from_square(r, c):
attacked = set([])
for i in range(5):
attacked.add((r,i))
attacked.add((i,c))
if 0<=r+i<5 and 0<=c+i<5:
attacked.add((r+i,c+i))
if 0<=r+i<5 and 0<=c-i<5:
################
known_domains = {
"hotmail.com": [],
"gmail.com": [],
"yahoo.com": [],
"mail.ru": [],
}
notfound = []
################
We couldn’t find that file to show.
@md2perpe
md2perpe / mandelbrot.c
Created December 30, 2019 19:53
Mandelbrot
#include <stdio.h>
#define R 50
#define C 150
#define K 50
int main()
{
int r, c;
for (r=0; r<R; r++)
import datetime
FIRST_MONDAY = datetime.datetime(1970, 1, 5, tzinfo=datetime.timezone.utc).timestamp()
HOUR = 3600
DAY = 24*HOUR
WEEK = 7*DAY
CLOSE_HOUR = 22
OPEN_HOUR = 8