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 / 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 / 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 / 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 / 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

Keybase proof

I hereby claim:

  • I am neizod on github.
  • I am neizod (https://keybase.io/neizod) on keybase.
  • I have a public key whose fingerprint is 48AB A6A9 A002 DCD8 6E24 DFB0 0E27 2831 8C9B 4947

To claim this, I am signing this object:

@neizod
neizod / it.ipynb
Created May 11, 2015 00:26
test nbviewer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python3
from numpy import matrix, zeros
class RandomWalk(object):
limpow = 10**9
offset = [(0,-1), (0,1), (-1,0), (1,0)]
@neizod
neizod / kmeans.py
Last active August 29, 2015 14:07
k-means clustering.
#!/usr/bin/env python3
import sys
from itertools import count
class Point(object):
def __init__(self, pp):
self.x, self.y = pp
@neizod
neizod / bubble.cpp
Last active August 29, 2015 14:06
Sorting Algorithms
#include <iostream>
using namespace std;
int arr[] = {2,5,3,9,1,0,7,4,8,6};
void show(int i=-1) {
for (int k=0; k<10; k++) {
if (i-1 == k) cout << "\x1b[37;1m";
if (i == k) cout << "\x1b[31;1m";
cout << arr[k];
@neizod
neizod / freq.html
Created March 29, 2014 17:35
[quick-dirty] html+js hack for cracking the substitution encryption.
<h3>encrypted sentence</h3>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<input name="text" size="40" />
<button id="mk">make</button>
<hr />
<h3>decrypted sentence</h3>
<div id="box"></div>
<hr />