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 / simple-sol.py
Created January 14, 2016 17:24
uva 122 trees on the level
#!/usr/bin/env python3
from collections import deque
class Node(object):
def __init__(self):
self.value = None
self.left = None
self.right = None
@neizod
neizod / break_nsa.rst
Last active November 4, 2016 06:20
break the nsa encryptio

Break the NSA Encryption

`Challenge on Gist`_ from `this Facebook Post`_ provide an interesting question on cracking the NSA encryption. Doesn't this hook you enough? Let's roll. :D

Note, you can also test the validity of logic in this file with the command:

$ python3 -m doctest break_nsa.rst --verbose
@neizod
neizod / coupon.R
Last active July 16, 2017 02:43
R Program That Draw Histogram of Coupon's Collector Problem
random.int <- function(n) { sample.int(n, 1) }
random.coupon <- function(...) {
count <- 0
have.coupon <- logical(...)
while (!all(have.coupon)) {
have.coupon[random.int(...)] <- TRUE
count <- count + 1
}
@neizod
neizod / draw-cubic-ufo.R
Last active May 25, 2018 05:01
3D drawing script for explaining how to solve Google Code Jam, 2018 Qualification, Cubic UFO.
#!/usr/bin/env Rscript
library(rgl)
library(sp)
calc_radian <- function(i, tick, uplim) {
2 * pi * (i / tick) * (uplim / 360)
}
@neizod
neizod / ulti-chull.ipynb
Created August 7, 2018 23:22
Kirkpatrick–Seidel algorithm
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{independent-study}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions\relax
\LoadClass[11pt,a4paper,oneside]{book}
% thai book
\usepackage[english,thai]{babel}
@neizod
neizod / smallest-circle.ipynb
Last active November 16, 2018 19:50
Smallest-circle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neizod
neizod / answer-final.mzn
Last active November 26, 2018 02:53
MiniZinc examples for Blognone.
array[1..3] of int: divisors = [2, 3, 7];
var 1..100: answer;
constraint forall(d in divisors)( answer mod d == 0 );
solve satisfy;
output [ "The ultimate answer is \(answer).\n" ];
#include <iostream>
using namespace std;
bool is_int(string number) {
bool after_dot = false;
for (char c : number) {
if (after_dot and c != '0') {
return false;
} else if (c == '.') {
@neizod
neizod / mersenne-twister.ipynb
Created September 30, 2019 23:12
Mersenne Twister
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.