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
// Given a length and the constraints, ie, length 4, numbers 1, uppercase 2, lowercase 1. | |
// Find the kth password that matches these constraints from lexical ordering standpoint. | |
// So in the case of k=4; the first four passwords on this lexical ordering would be | |
// 1AAa->1AAb->1AAc->1AAd and that last password is your answer. | |
// Just to highlight the lexical ordering a little more; | |
// note the last password possible here would be zZZ9). | |
function charToDecimal(char) { | |
const asciiRepresentation = char.charCodeAt(0); | |
const firstSymbolSetSize = "9".charCodeAt(0) - "0".charCodeAt(0) + 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
//Problem link: https://codility.com/programmers/challenges/alpha2010/ | |
//Max score: 100% - Total time: 1 hr 02 mins | |
// ----------------------------------------------------------------------------------- | |
// ----------------------------------------------------------------------------------- | |
// ----------------------------------------------------------------------------------- | |
//First solution - Score: 84% | |
//Link: https://codility.com/demo/results/trainingS8K2BU-VRE/ | |
//Time: 17 mins |
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 romanMap = [ | |
{ | |
I: 'I', | |
V: 'V', | |
X: 'X' | |
}, { | |
I: 'X', | |
V: 'L', | |
X: 'C' | |
}, { |
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
function magicEval(code){ | |
var script = document.createElement("script"); | |
script.src = URL.createObjectURL(new Blob([code], {type: 'text/javascript'})); | |
script.type = "text/javascript"; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
} |
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
if (!Function.prototype.bind) { | |
Function.prototype.bind = function (oThis) { | |
if (typeof this !== "function") { | |
// closest thing possible to the ECMAScript 5 | |
// internal IsCallable function | |
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); | |
} | |
var aArgs = Array.prototype.slice.call(arguments, 1), | |
fToBind = this, |