andre's recent activity

  1. Comment on Al Jazeera to launch rightwing media platform targeting US conservatives in ~news

    andre
    Link
    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.

    7 votes
  2. Comment on Need a laptop for school, budget $2000, details inside in ~tech

    andre
    Link Parent
    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)

    9 votes
  3. Comment on Trump revokes rule preventing White House staff from lobbying in ~news

    andre
    Link Parent
    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.

    1 vote
  4. Comment on Are software engineers "engineers"? in ~comp

    andre
    Link Parent
    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.

    1 vote
  5. Comment on The scary power of the companies that finally shut Trump up in ~tech

    andre
    Link Parent
    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.

    8 votes
  6. Comment on The scary power of the companies that finally shut Trump up in ~tech

    andre
    Link Parent
    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.

    11 votes
  7. Comment on The scary power of the companies that finally shut Trump up in ~tech

    andre
    Link Parent
    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.

    7 votes
  8. Comment on Donald Trump response to yesterday violent roitious insurrection at the Capitol in ~news

    andre
    Link Parent
    I liked Sam Harris' take on Twitter:

    I liked Sam Harris' take on Twitter:

    This Boston Dynamics Trump robot is amazing.

    8 votes
  9. Comment on Day 8: Handheld Halting in ~comp

    andre
    Link Parent
    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.

    5 votes
  10. Comment on Day 8: Handheld Halting in ~comp

    andre
    Link
    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
        }
      }
    }
    
    2 votes
  11. Comment on Day 7: Handy Haversacks in ~comp

    andre
    Link
    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
    }
    
    3 votes
  12. Comment on Day 5: Binary Boarding in ~comp

    andre
    Link
    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
        }
      }
    }
    
    1 vote
  13. Comment on Advent of Code 2020 has begun in ~comp

    andre
    Link Parent
    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.

    6 votes
  14. Comment on Day 4: Passport Processing in ~comp

    andre
    Link
    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
    }
    
    3 votes
  15. Comment on Day 3: Toboggan Trajectory in ~comp

    andre
    Link
    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)
    }
    
    2 votes
  16. Comment on Advent of Code 2020 has begun in ~comp

    andre
    Link
    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
    }
    
    2 votes
  17. Comment on Advent of Code 2020 has begun in ~comp

    andre
    Link Parent
    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.

    5 votes
  18. Comment on FCC chairman Ajit Pai will step down on January 20 in ~tech

    andre
    Link Parent
    The old "you can't fire me, I quit!" trope in full effect.

    The old "you can't fire me, I quit!" trope in full effect.

    5 votes
  19. Comment on YouTube Vanced: A privacy-friendly YouTube app for Android with ads and telemetry stripped out in ~tech

    andre
    Link Parent
    So you're upset that people are turning on ad blockers, which causes a reduction in your personal revenue, but you wouldn't be bothered if YT completely failed, removing the entirety of your...

    So you're upset that people are turning on ad blockers, which causes a reduction in your personal revenue, but you wouldn't be bothered if YT completely failed, removing the entirety of your revenue?

    If YouTube failed as a result of ad blockers, presumably all other platforms whose revenue came from ads would also fail. What would you do then? And why not do whatever that is now?

    6 votes
  20. Comment on YouTube Vanced: A privacy-friendly YouTube app for Android with ads and telemetry stripped out in ~tech

    andre
    Link Parent
    To echo Don_Camillo above, if I go take a piss whenever an ad comes on, am I now stealing from the advertiser? Not only did the advertiser lose money on a false impression, YouTube lost extra...

    I don't get paid if the ad isn't served. That's why blocking those ads is avoiding paying for my content, which makes it piracy.

    To echo Don_Camillo above, if I go take a piss whenever an ad comes on, am I now stealing from the advertiser? Not only did the advertiser lose money on a false impression, YouTube lost extra money in bandwidth costs while serving the unwatched ad. Perhaps we should require computers to track our eyeballs during advertisements a la the "Fifteen Million Merits" Black Mirror episode to guarantee those advertisers are getting their money's worth.

    I've read all of your comments in this post, and I feel for you, I really do, but I'm still going to do everything in my power to prevent the above mentioned dystopian nightmare. If that means YouTube fails, so be it.

    7 votes