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
var str = "aaaaaaaa"; | |
var word = "aaa"; | |
var ltr = "w"; | |
var result = ""; | |
for(var i = 0; i < str.length; i++) { | |
//console.log(str) |
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
{} |
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
function main() { | |
var m_temp = readLine().split(' '); | |
var m = parseInt(m_temp[0]); | |
var n = parseInt(m_temp[1]); | |
magazine = readLine().split(' '); | |
ransom = readLine().split(' '); | |
var arr = [] | |
var dict = {} | |
for(var i = 0; i < magazine.length; i++) { | |
if(dict[magazine[i]]) { |
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
function sieve(x) { | |
var arr = []; | |
var output = []; | |
for(var i = 0; i < x; i++) { | |
arr.push(true); | |
} | |
for(var i = 2; i <= Math.sqrt(x); i++) { | |
if(arr[i]) { | |
for(var j = i*i; j <x; j+=i) { | |
arr[j] = false; |
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
var n = function(digit) { | |
return function(op) { | |
return op ? op(digit) : digit; | |
} | |
}; | |
var zero = n(0); | |
var one = n(1); | |
var two = n(2); | |
var three = n(3); | |
var four = n(4); |
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
Function.prototype.pipe = function(fun) { | |
return function(param) { | |
return fun(this(param)); | |
}.bind(this); //The bind() method creates a new function that, when called, has its this keyword | |
}; //set to the provided value, with a given sequence of arguments preceding any provided | |
//when the new function is called. |
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
function once(fn) { | |
var call = true | |
return function() { | |
if (call) { | |
call = false | |
return fn.apply(this, arguments) | |
} | |
} | |
} |
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
function compose(f, g) { | |
return function() { | |
return f(g.apply(this, arguments)); | |
}; | |
} |
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
function iqTest(numbers){ | |
numbers = numbers.split(" "); | |
var even = numbers.filter(function(number) { | |
return number % 2 === 0; | |
}); | |
var odd = numbers.filter(function(number) { | |
return number % 2 !== 0; | |
}); | |
console.log(even, odd); | |
if(even.length > odd.length) return numbers.indexOf(odd[0])+1; |
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
Array.prototype.int = function (){ | |
return this.filter(function (x) { return typeof x == 'number' && x == ~~x }); | |
} | |
Array.prototype.even = function(){ | |
return this.int().filter(function (x) { return ~x & 1 }); | |
} | |
Array.prototype.odd = function(){ | |
return this.int().filter(function (x) { return x & 1 }); | |
} |
NewerOlder