Skip to content

Instantly share code, notes, and snippets.

View neizod's full-sized avatar
📚
phd completed, seeking my new goal in life

Nattawut Phetmak neizod

📚
phd completed, seeking my new goal in life
View GitHub Profile
@neizod
neizod / bkk_aqi_data.csv
Last active October 11, 2019 17:07
Interpolate Bangkok Pollution with IDW (and Voronoi)
x y aqi note
390 60 82 Bang Plat
520 150 78 Phaya Thai
750 160 99 Wang Thonglang
530 260 74 Pathum Wan
410 460 151 Rat Burana
520 480 76 Phra Pradaeng
730 460 65 Bang Na
1060 140 255 ?
@neizod
neizod / antumbra.ipynb
Created March 2, 2020 00:59
Umbra-Penambra-Antumbra and Shadow Densities.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neizod
neizod / pebbles.py
Last active September 27, 2020 07:12
IMO 2020 Problem 3: Pebbles
#!/usr/bin/env python3
import sys
from argparse import ArgumentParser
from itertools import combinations
from random import seed, shuffle, randrange
sumsupto = lambda n: n*(n+1)//2
tco = lambda t: f'\033[01;{31+t[1]}m{t[0]:02}\033[00m'
@neizod
neizod / generate.py
Last active May 26, 2021 05:29
Megagon SVG!
#!/usr/bin/env python3
# NOTE
# LAYERS is a non-empty list of integers.
# The n-gon can be determine by calc_ngon(LAYERS), e.g.,
#LAYERS = [1, 2, 2] # heptagon (not constructible)
#LAYERS = [1, 4, 3] # heptadecagon (17 sides)
#LAYERS = [2, 2, 3, 2] # tetracontadigon (42)
#LAYERS = [4, 1, 4, 3, 2, 2] # 360-gon
#!/usr/bin/env python3
# change params here
N = 3
M = 3
PRINT_UNIQUE_ANSWERS = True
#!/usr/bin/env python3
from itertools import combinations
def is_undividable_clique(family, number):
for subgraph in combinations(family, 4):
if sum(subgraph) % number == 0:
return False
return True
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neizod
neizod / chain_reactions.py
Created April 3, 2022 04:49
Google Code Jam 2022 -- Qualification Round
import sys
from operator import iconcat
from functools import reduce
sys.setrecursionlimit(100010)
class Node(object):
def __init__(self):
self.fun = 0
@neizod
neizod / equal_sum.py
Created April 12, 2022 01:43
Google Code Jam 2022, 1A, Equal Sum
#!/usr/bin/env python3
import random
UPPER_BOUND = 10**9
BINARY_BOUND = len(f'{UPPER_BOUND:b}')
def is_binary(x):
return x == 2**len(f'{x:b}')
@neizod
neizod / draw.js
Created June 10, 2022 10:26
proof without words for 1²+2²+3²+...+n² = n(n+1)(2n+1)/6. illustrated with three.js
/*
* | y
* |
* .
* / \
* z / \ x
*
*/
const scene = new THREE.Scene();