Skip to content

Instantly share code, notes, and snippets.

View augusto-altman's full-sized avatar
😄
Coding for @joyoushq

Augusto Altman Quaranta augusto-altman

😄
Coding for @joyoushq
View GitHub Profile
@augusto-altman
augusto-altman / kthPassword.js
Created September 12, 2019 22:14
A problem stated in NZ programming competition
// 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;
@augusto-altman
augusto-altman / codility-alpha2010.js
Last active April 21, 2016 00:02
Codility - Alpha 2010
//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
var romanMap = [
{
I: 'I',
V: 'V',
X: 'X'
}, {
I: 'X',
V: 'L',
X: 'C'
}, {
@augusto-altman
augusto-altman / magicEval
Created September 21, 2014 19:35
A javascript implementation of the eval function using the blob native api.
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);
}
@augusto-altman
augusto-altman / bind.polyfill
Created August 24, 2014 23:25
Function.prototype.bind() polyfill
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,