The British and American Style of Spelling

  • + 0 comments

    Javascript solution:

    const lines = input.split(/^\d+\s*$/gm);
    const words = lines[2].trim().split("\n");
    words.forEach((word) => {
        const regex = new RegExp(`\\b(${word}|${word.replace(/ze$/, 'se')})\\b`, 'gmi');
        const total = lines[1].match(regex)?.length || 0;
    
        console.log(total);
    });