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
| var isSublist = function(a,b) { | |
| var a_idx=0; | |
| for(var b_idx=0; b_idx<b.length; b_idx+=1) { | |
| if (a[a_idx]==b[b_idx]) { | |
| if (a_idx==a.length-1) { | |
| return true; | |
| } | |
| a_idx+=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
| var reverse = function (a) { | |
| for (var i=0, arrayLen=a.length ; i<arrayLen/2; i+=1) { | |
| var temp = a[arrayLen-i-1]; | |
| a[arrayLen-i-1] = a[i]; | |
| a[i] = temp; | |
| } | |
| return a; | |
| }; |
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
| main=putStr$q++show q;q="main=putStr$q++show q;q=" |
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
| // obj1 is much more human readable! | |
| var obj1 = { | |
| "a" : "value", | |
| "bc" : "value", | |
| "def" : "value" | |
| } | |
| var obj2 = { | |
| "a" : "value", |
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
| // 71 ms for input:1000000 | |
| var prime_procedural = function(end) { | |
| var i,j,n; | |
| var sieve = [], | |
| primes = []; | |
| sieve[0]=false; | |
| for(i=1; i<end+1; i+=1) { | |
| sieve[i]=true; |
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
| var graph1 = { | |
| vertex: ["1","2","3"], | |
| edge: [, | |
| /* vertex1, vertex2, weight */ | |
| ["1", "2", 4], | |
| ["1", "3", 7], | |
| ["2", "3", 1] | |
| ] | |
| }, | |
| graph2 = { |
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
| "use strict"; | |
| /****** Library START ******/ | |
| var hike = function() { | |
| var user_fn, i, len, rule_strs, rule_parsed, | |
| rule = {}, /* arg length -> [arg name] */ | |
| _arguments = Array.prototype.slice.call(arguments); | |
| user_fn = _arguments.pop(); |
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
| <html> | |
| <head> | |
| <script type="text/javascript" | |
| src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
| </head> | |
| <body> | |
| <script type="text/javascript" src="js/index.js"></script> | |
| </body> | |
| </html> |
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
| //include | |
| //------------------------------------------ | |
| #include <vector> | |
| #include <list> | |
| #include <map> | |
| #include <set> | |
| #include <deque> | |
| #include <stack> | |
| #include <bitset> | |
| #include <algorithm> |
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
| // node --harmony timeout-seq.js | |
| [3,5,10] | |
| .map(function(sec) { return sec * 1000; }) | |
| .map(function(duration) { | |
| return function task(resolve) { | |
| setTimeout(function() { | |
| console.log(duration); | |
| resolve(); | |
| }, duration); |