Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
encode then compare solution in Clear category for [old] Word Pattern by Sim0000
"use strict";
function checkCommand(pattern, command){
let s = ''
for(let c of command){
s += c.match(/[0-9]/) ? '0' : '1';
}
return parseInt(s, 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 15, 2017