{{ message }}

Instantly share code, notes, and snippets.

💤
procrastinating

# Nattawut Phetmak neizod

💤
procrastinating
Last active Nov 4, 2016
break the nsa encryptio
View break_nsa.rst

# 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
```
Created Jan 14, 2016
uva 122 trees on the level
View simple-sol.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #!/usr/bin/env python3 from collections import deque class Node(object): def __init__(self): self.value = None self.left = None self.right = None
Last active Dec 19, 2015
View perceptron.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 type Vector = (Double, Double) dotV :: Vector -> Vector -> Double dotV (x, y) (u, v) = x * u + y * v addV :: Vector -> Vector -> Vector addV (x, y) (u, v) = (x + u, y + v)
Created Apr 27, 2013
codejam 1a
View a.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 def sqrt(n): if n == 0: return 0 a, b = divmod(n.bit_length(), 2) x = 2 ** (a + b) while True: y = x + n // x y //= 2 if y >= x: return x
Last active Dec 16, 2015
palindrome
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 1 2 3 11 22 101 111 121 202
Last active Dec 15, 2015 — forked from lifez/Insomnia cure.py
View insomnia-cure.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 from itertools import cycle, izip k, l, m, n, d = [int(raw_input()) for _ in range(5)] dragons = [cycle([False] * (i-1) + [True]) for i in {k, l, m, n}] print sum(any(next(izip(*dragons))) for _ in xrange(d))
Last active Dec 14, 2015 — forked from Python1Liners/LICENSE.txt
Happy Valentine's Day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2013 Nattawut Phetmak Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Last active Dec 11, 2015
ML, Racket, Ruby Lecture @ Cousera
View week1.md

## เมื่อพูดถึงภาษาคอมพิวเตอร์

• syntax: เขียนยังไงให้ computer เข้าใจเรา?
• semantics: ภาษาที่เราเขียนมันมีขั้นตอนการทำงานยังไง?
• idioms: ปรัญชาเบื้องหลังภาษานั้นๆ
• เช่นภาษา python มีปรัชญาว่า มันควรมีเพียงวิธีเดียว (ที่ดีที่สุด) ในการเขียนโปรแกรมให้ทำงานอยากเดียวกัน (เพื่อให้ programmer สามารถอ่าน code คนอื่นได้ง่าย)
• ส่วนภาษา ruby มีปรัชญาตรงนี้กลับกัน คือจะเขียนยังไงก็ได้ให้มันทำงานได้ (programmer จะสนุกกับการเขียนโปรแกรม... แต่ programmer คนอื่นมาอ่านรู้เรื่องหรือเปล่าก็อีกเรื่อง)
• libraries: code ที่คนอื่นเขียนไว้ให้ใช้
• tools: เครื่องมือช่วยสร้างโปรแกรมในภาษานั้นๆ เช่น repl, debugger, ide
Created Oct 9, 2012
Mathematical Thinking
View lecture.md

## Logic

• S => N
• S is called antecedent.
• S is sufficient for N.
• N is necessary for S.
• S <=> N
• S is sufficient and necessary for N
Created Oct 6, 2012
Learn to Program: The Fundamentals
View lecture.md

# Theory

## Memory

There are 2 places of memory in Python program.

• Heap: value of variables, functions recipe bind w/ memory address. e.g.
• memory addr: `x1` -> int: 42