andre's recent activity
-
Comment on What do you all think about HBO's The Last of Us show? - S1E1 Discussion in ~tv
-
Comment on What do you all think about HBO's The Last of Us show? - S1E1 Discussion in ~tv
andre Definitely. I play a lot of PC games, but have less than zero interest in consoles, for many reasons. I've heard nothing but good things about the game, and I'm happy there's a TV adaptation as...Definitely. I play a lot of PC games, but have less than zero interest in consoles, for many reasons. I've heard nothing but good things about the game, and I'm happy there's a TV adaptation as I'd otherwise never experience it.
-
Comment on Verstappen bests Hamilton to claim first career world championship in ~sports
andre Lewis deserved the race win, Max deserved WDC.Lewis deserved the race win, Max deserved WDC.
-
Comment on Al Jazeera to launch rightwing media platform targeting US conservatives in ~news
andre I thought this was an Onion article at first, but sure enough... I can't see it taking off though - as soon as a righty realizes Rightly is owned by Al Jazeera, their hate of brown people will...I thought this was an Onion article at first, but sure enough... I can't see it taking off though - as soon as a righty realizes Rightly is owned by Al Jazeera, their hate of brown people will make them change the channel.
-
Comment on Need a laptop for school, budget $2000, details inside in ~tech
andre As a counterpoint, when going to UT for computer science in the 2000s, I'd estimate a full 65% of students and 90% of faculty had MacBooks. (As a side note, despite tempest's resistance to Macs,...As a counterpoint, when going to UT for computer science in the 2000s, I'd estimate a full 65% of students and 90% of faculty had MacBooks.
(As a side note, despite tempest's resistance to Macs, I'm going to join stu2b50 and recommend an M1 Air - I can't imagine picking that and ending up disappointed)
-
Comment on Trump revokes rule preventing White House staff from lobbying in ~news
andre That would require politicians to put the prosperity of the country above their donors.That would require politicians to put the prosperity of the country above their donors.
-
Comment on Are software engineers "engineers"? in ~comp
andre I have a Bachelor of Arts in Computer Science from UT Austin - it actually used to be in both schools, with some of the non-CS elective classes being the differentiating factor.I have a Bachelor of Arts in Computer Science from UT Austin - it actually used to be in both schools, with some of the non-CS elective classes being the differentiating factor.
-
Comment on The scary power of the companies that finally shut Trump up in ~tech
andre I agree: they're taking action based on a high level, long-term business strategy. Unless I misunderstood this entire thread, skybrian was arguing that we should give Twitter/Facebook the benefit...I agree: they're taking action based on a high level, long-term business strategy.
Unless I misunderstood this entire thread, skybrian was arguing that we should give Twitter/Facebook the benefit of the doubt that they acted for the benefit of society instead of on a business calculus (which, ultimately, is a decision of what will create the most profit), which struck me as naive.
-
Comment on The scary power of the companies that finally shut Trump up in ~tech
andre If you don't think that Twitter and Facebook have spent substantial resources over the last four years attempting to asses the financial risk/reward of (de)platforming Trump, I don't think our...If you don't think that Twitter and Facebook have spent substantial resources over the last four years attempting to asses the financial risk/reward of (de)platforming Trump, I don't think our dialogue will be productive.
He wasn't banned because Dorsey and Zuck suddenly grew consciences - these are corporations beholden to their stockholders and governmental regulations, and the calculus shifted such that banning him was the right business move.
My default thought pattern is that all of these people are greedy assholes, and whereas you need evidence that the decision was based on finances, I need evidence that it wasn't. Neither of us has this, so it's speculation all around.
-
Comment on The scary power of the companies that finally shut Trump up in ~tech
andre I agree that it's good to be cautious, but let's not be naive either.I agree that it's good to be cautious, but let's not be naive either.
-
Comment on Donald Trump response to yesterday violent roitious insurrection at the Capitol in ~news
andre I liked Sam Harris' take on Twitter:I liked Sam Harris' take on Twitter:
This Boston Dynamics Trump robot is amazing.
-
Comment on Day 8: Handheld Halting in ~comp
andre I didn't need to add anything special for part 2 - if you were stopping execution when you saw an instruction twice (from part 1), you shouldn't have hit any infinite loops. I actually thought the...I didn't need to add anything special for part 2 - if you were stopping execution when you saw an instruction twice (from part 1), you shouldn't have hit any infinite loops. I actually thought the problem was well structured to have you implement that part first.
-
Comment on Day 8: Handheld Halting in ~comp
andre JavaScript Parts 1 + 2 function parseInput(input) { let lines = input.split('\n').map(l => { const [, instr, param] = l.match(/(.*) (.*)/) return { instr, param: Number(param) } }) return lines }...JavaScript
Parts 1 + 2
function parseInput(input) { let lines = input.split('\n').map(l => { const [, instr, param] = l.match(/(.*) (.*)/) return { instr, param: Number(param) } }) return lines } function run(prog) { let ptr = 0 let acc = 0 let seen = [] while (true) { if (!prog[ptr]) return { halts: true, acc } if (seen[ptr]) return { halts: false, acc } const { instr, param } = prog[ptr] seen[ptr] = true if (instr === 'jmp') { ptr += param } if (instr === 'acc') { acc += param ptr++ } if (instr === 'nop') { ptr++ } } } export function solvePart1(input) { let prog = parseInput(input) return run(prog).acc } export function solvePart2(input) { let prog = parseInput(input) for (let i = 0; i < prog.length; i++) { let { instr, param } = prog[i] if (instr.match(/(nop|jmp)/)) { const progCopy = [...prog] progCopy[i] = { instr: instr === 'nop' ? 'jmp' : 'nop', param, } const result = run(progCopy) if (result.halts) return result.acc } } }
-
Comment on Day 7: Handy Haversacks in ~comp
andre I was really unhappy with my original solution, so this is a refactored solution after thinking about it more clearly and taking some inspiration from Sophie Alpert. JS Parts 1+2 function...I was really unhappy with my original solution, so this is a refactored solution after thinking about it more clearly and taking some inspiration from Sophie Alpert.
JS
Parts 1+2
function parseInput(input) { const contains = {} const containedIn = {} input.split('\n').forEach(line => { let [, color, children] = line.match(/(.*) bags contain (.*)/) contains[color] = [] for (let [, num, type] of children.matchAll(/(\d+) (.+?) bags?[,.]/g)) { contains[color].push({ num: Number(num), type }) ;(containedIn[type] || (containedIn[type] = [])).push(color) } }) return { contains, containedIn } } export function solvePart1(input) { let { containedIn } = parseInput(input) function containers(color, set = new Set()) { containedIn[color]?.forEach(c => { set.add(c) containers(c, set) }) return set } return containers('shiny gold').size } export function solvePart2(input) { let { contains } = parseInput(input) function sumBags(root) { return 1 + _.sum(contains[root].map(c => c.num * sumBags(c.type))) } return sumBags('shiny gold') - 1 }
-
Comment on Day 5: Binary Boarding in ~comp
andre JavaScript My initial implementation was a typical binary search and then straightforward id calculation. After reading some of the answers here and realizing it's just a binary number, here's a...JavaScript
My initial implementation was a typical binary search and then straightforward id calculation. After reading some of the answers here and realizing it's just a binary number, here's a more interesting solution:
Parts 1 + 2
export function solvePart1(input) { input = input.split('\n') return _.max( input.map(seat => { return parseInt(seat.replace(/(F|L)/g, 0).replace(/(B|R)/g, 1), 2) }), ) } export function solvePart2(input) { input = input.split('\n') const ids = input .map(seat => { return parseInt(seat.replace(/(F|L)/g, 0).replace(/(B|R)/g, 1), 2) }) .sort((a, b) => a - b) // Array.sort() is lexicographical in JS, lol for (let i = 0; i < ids.length; i++) { if (ids[i] !== ids[0] + i) { return ids[0] + i } } }
-
Comment on <deleted topic> in ~comp
andre If you want to see one of the consistent leaderboard finishers solve the puzzles live, check out Jonathan Paulson's YouTube channel.If you want to see one of the consistent leaderboard finishers solve the puzzles live, check out Jonathan Paulson's YouTube channel.
-
Comment on Day 4: Passport Processing in ~comp
andre I didn't start this one at release time, but it wouldn't have mattered - had a really annoying mistake that took a while to track down. Reasonably happy with the outcome though. JavaScript Parts 1...I didn't start this one at release time, but it wouldn't have mattered - had a really annoying mistake that took a while to track down. Reasonably happy with the outcome though.
JavaScript
Parts 1 and 2
function isValid(p) { if (!p) return false if (p.byr < 1920 || p.byr > 2002) return false if (p.iyr < 2010 || p.iyr > 2020) return false if (p.eyr < 2020 || p.eyr > 2030) return false let [match, hgt, unit] = /(\d+)(cm|in)?/.exec(p.hgt) if ( !match || !unit || (unit == 'cm' && (hgt < 150 || hgt > 193)) || (unit == 'in' && (hgt < 59 || hgt > 76)) ) { return false } if (!/^#[0-9a-f]{6}$/.test(p.hcl)) return false if (!/(amb|blu|brn|gry|grn|hzl|oth)/.test(p.ecl)) return false if (!/^\d{9}$/.test(p.pid)) return false return true } function Passport(line) { const requiredFields = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'] const passport = line.split(' ').reduce((acc, field) => { const [key, value] = field.split(':') const idx = requiredFields.indexOf(key) if (idx > -1) requiredFields.splice(idx, 1) acc[key] = value return acc }, {}) if (requiredFields.length) return null return passport } export function solvePart1(input) { input = input.split('\n\n').map(l => l.replace(/\n/g, ' ')) return input.filter(Passport).length } export function solvePart2(input) { input = input.split('\n\n').map(l => l.replace(/\n/g, ' ')) return input.map(Passport).filter(isValid).length }
-
Comment on Day 3: Toboggan Trajectory in ~comp
andre Nothing too special here, very similar to solution to most people I imagine. 858/576. Part 1 and 2 in JS function countTrees(path, dx, dy) { let y = 0 let x = 0 let trees = 0 while (y <...Nothing too special here, very similar to solution to most people I imagine. 858/576.
Part 1 and 2 in JS
function countTrees(path, dx, dy) { let y = 0 let x = 0 let trees = 0 while (y < path.length) { if (path[y][x] === '#') { trees++ } x = (x + dx) % path[y].length y += dy } return trees } export function solvePart1(input) { input = input.split('\n') return countTrees(input, 3, 1) } export function solvePart2(input) { input = input.split('\n') const slopes = [ [1, 1], [3, 1], [5, 1], [7, 1], [1, 2], ] return slopes.map(s => countTrees(input, ...s)).reduce((acc, t) => acc * t, 1) }
-
Comment on <deleted topic> in ~comp
andre I did 2017 and 2018 in JS, will be doing 2020 in the same. Here's my run harness and solutions. I'm happy with the workflow: run tests in watch mode (so they immediately execute when I save a file...I did 2017 and 2018 in JS, will be doing 2020 in the same. Here's my run harness and solutions. I'm happy with the workflow: run tests in watch mode (so they immediately execute when I save a file in vim) while writing the answer, followed by
yarn run solve 2020 02 1
, which downloads the input from AoC, executes your solution, and puts the answer in your clipboard.Day 01
export function solvePart1(input) { input = U.linesToNumbers(input) for (let i = 0; i < input.length; i++) { for (let k = 0; k < input.length; k++) { if (input[i] + input[k] === 2020) { return input[i] * input[k] } } } } export function solvePart2(input) { input = U.linesToNumbers(input) for (let i = 0; i < input.length; i++) { for (let j = 0; j < input.length; j++) { for (let k = 0; k < input.length; k++) { if (input[i] + input[k] + input[j] === 2020) { return input[i] * input[k] * input[j] } } } } }
Day 02
export function solvePart1(input) { return input.split('\n').filter(line => { let [, min, max, letter, str] = /(\d+)-(\d+) (.): (.*)/.exec(line) min = Number(min) max = Number(max) const count = str.split('').filter(c => c === letter).length return count >= min && count <= max }).length } export function solvePart2(input) { return input.split('\n').filter(line => { let [, min, max, letter, str] = /(\d+)-(\d+) (.): (.*)/.exec(line) min = Number(min) max = Number(max) return U.xor(str[min - 1] === letter, str[max - 1] === letter) }).length }
-
Comment on <deleted topic> in ~comp
andre I did 20/25 in 2018, skipped 2019, but am planning on giving it another go this year.I did 20/25 in 2018, skipped 2019, but am planning on giving it another go this year.
Oh rad! Thanks for letting me know.