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
"""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 |
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
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 |
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
package main | |
//Recursive Binary Search | |
func binarySearch(numList []int64, key int64) int { | |
low := 0 | |
high := len(numList) - 1 | |
if low <= high { |
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
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. | |
""" |
NewerOlder