Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
no toString(2) solution in Creative category for [old] Morse Clock by vincent.tscherter
"use strict";
function morseClock(a,b,c) {
return b = ".......-..-...--.-...-.-.--..----...-..-", c = "24-34-34",
a.replace(/^|:/g,'$&00').replace(/\d*(\d\d)/g,'$1')
.split("").map((a, d) => b.substr(4*(+a+1)-c[d],c[d])||":")
.join(" ");
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(morseClock("10:37:49"), ".- .... : .-- .--- : -.. -..-", "1st");
assert.equal(morseClock("21:34:56"), "-. ...- : .-- .-.. : -.- .--.", "2nd");
assert.equal(morseClock("00:1:02"), ".. .... : ... ...- : ... ..-.", "3rd");
assert.equal(morseClock("23:59:59"), "-. ..-- : -.- -..- : -.- -..-", "4th");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Dec. 5, 2016
Comments: