This file contains hidden or 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
| Array.prototype.reverse1 = function() { | |
| var stack = [], | |
| n = this.length | |
| for(var i=n-1;i>=0;i--) { | |
| stack.push(this[i]) | |
| } | |
| return stack | |
| } | |
| Array.prototype.reverse2 = function() { | |
| var i = 0, |
This file contains hidden or 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
| ''' | |
| Reverse the order of the items in the array. | |
| @thinkphp | |
| MIT Style License | |
| ''' | |
| arr = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31] | |
| def reverse(arr): | |
| m = len(arr) / 2 | |
| n = len(arr) - 1 | |
| for i in range(m): |
This file contains hidden or 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
| ''' | |
| Calculate the value of PI using Infinite Series | |
| Twitter: @thinkphp | |
| Website: http://thinkphp.ro | |
| G+ : http://gplus.to/thinkphp | |
| MIT Style License | |
| 4*(1- 1/3 + 1/5 - 1/7 + 1/9 +...) | |
| ''' | |
| import math |
This file contains hidden or 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
| ''' | |
| Computes the value of e(2.718281827...) using infinite series | |
| Twitter: @thinkphp | |
| Website: http://thinkphp.ro | |
| G+ : http://gplus.to/thinkphp | |
| MIT Style License | |
| 1 + 1/1! + 1/2! + 1/3! + ... | |
| 2 + 1/2! + 1/3!+ ... | |
| ''' |
This file contains hidden or 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
| ''' | |
| x | |
| f(x) = e - a | |
| if f(0)*f(a) < 0 then exists the solution (0,a] | |
| ''' | |
| import math | |
| import sys | |
| def loge(n,li,ls): | |
| if math.fabs(li-ls) <= 0.000001: |
This file contains hidden or 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
| ''' | |
| Computes SQuare RooT in Python SQRT | |
| s = (s+nr/s)1/2 | |
| Twitter : http://twitter.com/thinkphp | |
| Website : http://thinkphp.ro | |
| Google Plus : http://gplus.to/thinkphp | |
| MIT Style License | |
| ''' |
This file contains hidden or 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
| ''' | |
| Sieve of Eratosthenes in Python | |
| Twitter : http://twitter.com/thinkphp | |
| Website : http://thinkphp.ro | |
| Google Plus : http://gplus.to/thinkphp | |
| MIT Style License | |
| ''' | |
| import sys |
This file contains hidden or 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
| ''' | |
| Primes | |
| Twitter : http://twitter.com/thinkphp | |
| Website : http://thinkphp.ro | |
| Google Plus : http://gplus.to/thinkphp | |
| MIT Style License | |
| ''' | |
| import math | |
| import sys |
This file contains hidden or 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
| /* | |
| Insertion Sort in JavaScript | |
| Twitter : http://twitter.com/thinkphp | |
| Website : http://thinkphp.ro | |
| Google Plus : http://gplus.to/thinkphp | |
| MIT Style License | |
| */ | |
| function insertionSort(arr) { | |
| var n = arr.length-1, |
This file contains hidden or 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
| /** | |
| Insertion Sort in PHP | |
| Twitter : http://twitter.com/thinkphp | |
| Website : http://thinkphp.ro | |
| Google Plus : http://gplus.to/thinkphp | |
| MIT Style License | |
| */ | |
| function insertionSort($arr){ | |
| $n = count($arr); |