Skip to content

Instantly share code, notes, and snippets.

View tangingw's full-sized avatar

Mobieus Jay tangingw

View GitHub Profile
@tangingw
tangingw / counting.py
Created July 20, 2017 08:20
Algorithms for a tricky math problems
"""Synosis:
This is the algorithm that address the
following trick math question:
1 + 4 = 5
2 + 5 = 12
3 + 6 = 21
8 + 11 = ?
However this algorithm can also find the solution for such
@tangingw
tangingw / binary_tree_search.go
Last active May 23, 2017 04:41
This is a simple implementation of binary tree search algorithm in Golang
package main
import (
"fmt"
)
/*
Reference:
1. http://0xax.blogspot.my/2014/08/binary-tree-and-some-generic-tricks.html
2. https://www.tutorialspoint.com/data_structures_algorithms/tree_traversal.htm
@tangingw
tangingw / binary_search.go
Created March 3, 2017 03:59
This is golang binary search in recursive form
package main
//Recursive Binary Search
func binarySearch(numList []int64, key int64) int {
low := 0
high := len(numList) - 1
if low <= high {
@tangingw
tangingw / watch.py
Last active October 28, 2016 11:21
This is a naughty script that mimics linux watch command on Mac OS X.
import os
import sys
import time
"""This is a naughty script
to mimic linux watch process
in Mac OS X terminal. It might be
useful for other *BSD family.
"""