Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Word Pattern by mortonfox
"use strict";
function checkCommand(pattern, command){
return parseInt(command.replace(/[0-9]/g, '0').replace(/[^0-9]/g, '1'), 2) == pattern;
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(checkCommand(42, "12a0b3e4"), true, "42 is the answer");
assert.equal(checkCommand(101, "ab23b4zz"), false, "one hundred plus one");
assert.equal(checkCommand(0, "478103487120470129"), true, "Any number");
assert.equal(checkCommand(127, "Checkio"), true, "Uppercase");
assert.equal(checkCommand(7, "Hello"), false, "Only full match");
assert.equal(checkCommand(8, "a"), false, "Too short command");
assert.equal(checkCommand(5, "H2O"), true, "Water");
assert.equal(checkCommand(42, "C2H5OH"), false, "Yep, this is not the Answer");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
May 19, 2017