Advent of Code - Day 5 Part 1
by Uzair Mehmood
HTML
<textarea placeholder="Enter Input Here" rows="20" cols="50"></textarea>
<p></p>
JavaScript
$('textarea').change(function () {
var words = $(this).val().split('\n');
var niceCount = 0;
$.each(words, function (i, word) {
var disallowed = (/ab|cd|pq|xy/gi).test(word);
var vowels = word.match(/[aeiou]/gi);
vowels = vowels ? vowels.length : 0;
var duplicates = (/([a-z])\1/gi).test(word);
if (!disallowed && vowels >= 3 && duplicates) {
niceCount++
}
});
$('p').text('Total Nice Strings : ' + niceCount);
});