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
/** | |
* Hackerrank Solution - Max draws | |
*/ | |
function processData(input) { | |
var data = input.split("\n") | |
var t = data[0]; | |
for (var i = 1 ; i <= t; i += 1) { | |
var n = data[i].match(/\d+/g); | |
console.log(parseInt(n) + 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
/** | |
* Hackerrank Solution - Handshake | |
*/ | |
function main() { | |
var T = parseInt(readLine()); | |
for(var a0 = 0; a0 < T; a0++){ | |
var N = parseInt(readLine()); | |
console.log(Math.floor(N * (N - 1)/2)); | |
} | |
} |
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 n_temp = readLine().split(' '); | |
var n = parseInt(n_temp[0]); | |
var k = parseInt(n_temp[1]); | |
var q = parseInt(n_temp[2]); | |
a = readLine().split(' '); | |
a = a.map(Number); | |
var rot = k%n; | |
for(var a0 = 0; a0 < q; a0++) { |
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 findPoint(input) { | |
var data = input.split("\n") | |
var n = data[0]; | |
for (var i = 1 ; i <= n; i += 1) { | |
var pq = data[i].match(/\d+/g).map(Number); | |
console.log((pq[2] + (pq[2] - pq[0])) + " " + (pq[3] + (pq[3] - pq[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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
/** | |
* Static class - this new MyClass will create scope but with same objects and class which are static, which tells that tells being as | |
* a static class, it can be told as MyClass will not be `this` giving its reference to MyClass for all instances | |
* and can shared | |
*/ | |
function MyClass() | |
{ | |
function add(num1, num2) { return (num1+num2); } | |
function sub(num1, num2) { return (num1-num2); } |
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
/** | |
* Creating multiple constructors @ each instance | |
* @constrctor | |
* / | |
function Foobar(foobar) { | |
this.foobar = foobar; | |
} | |
Foobar.prototype = { | |
foobar: null |
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
/** | |
* Global error event handler in javascript in browser in both async and sync operations | |
* window - signifies the browser context | |
* 'error' - event name | |
* @param e Evemt object of the error occurred to print the stack | |
* / | |
window.addEventListener('error', function (e) { | |
var stack = e.error.stack; | |
var message = e.error.toString(); | |
if (stack) { |
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
/** | |
* Largest integer number in javascript | |
* @type {number} | |
*/ | |
var x = 9007199254740992; | |
var y = -x; | |
x == x + 1; // true ! | |
y == y - 1; // also true ! | |
/** |
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
/*============================================ | |
Progress Indicator - Skill Meter | |
*===========================================*/ | |
/** | |
* DOM looks like below | |
* <div class="progress pr_progress" data-value="80"></div> | |
*/ | |
/** |
NewerOlder