Javascript answer, Part 1 and 2 in one script, change the part2 boolean to false if you want a part 1 answer. Looking at other people's responses, mine feels very inefficient :(
part2
let fs = require("fs"), part2 = false, n = 0; fs.readFile("input.txt","utf8",(err,data) => { if (err) throw err; let veryuppercount = 0; data.split(/\n\s/gi).map(e => { if (part2) { let uppercount = 0; e = e.split(/\n/g); e[0].split("").map(f => { let counter = 0; e.slice(1,e.length).map(g => { g.split("").map(h => { if (h == f) counter++ })}) if (counter == e.length-1) uppercount++ }) veryuppercount += uppercount; } else { e = e.replace(/\n/g,"") if (e) { let noduplicate = [...new Set(e.split(""))]; n += noduplicate.length }}}) if (part2) console.log(veryuppercount) else console.log(n) })
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Javascript answer, Part 1 and 2 in one script, change the
part2
boolean to false if you want a part 1 answer.Looking at other people's responses, mine feels very inefficient :(