loading...

Discussion on: Daily Challenge #272 - Printer Errors

Collapse
cesclass profile image
Cyril ESCLASSAN

JS w/ regexp

function error_printer(s) {
    const init_len = s.length;
    const err_len = s.replace(/[a-m]/g, "").length;
    return `${err_len}/${init_len}`;
}

Python w/o regexp

def error_printer(s) :
    init_len = len(s)
    err_len = len([e for e in s if ord(e) < ord('a') or ord(e) > ord('m')])
    return str(err_len) + "/" + str(init_len)