MeckiSpaghetti's recent activity

  1. Comment on Day 8: Treetop Tree House in ~comp

    MeckiSpaghetti
    Link
    Ruby Part 1 def is_visible?(x, y) tree = $map[y][x] up = (0...y).map{ |i| $map[i][x] } right = (x+1...$map.first.size).map{ |i| $map[y][i] } down = (y+1...$map.size).map{ |i| $map[i][x] } left =...

    Ruby

    Part 1
    def is_visible?(x, y)
      
      tree = $map[y][x]
      up    = (0...y).map{ |i| $map[i][x] }
      right = (x+1...$map.first.size).map{ |i| $map[y][i] }
      down  = (y+1...$map.size).map{ |i| $map[i][x] }
      left  = (0...x).map{ |i| $map[y][i] }
      
      up.all?{ |e| e < tree } ||
      right.all?{ |e| e < tree } ||
      down.all?{ |e| e < tree } ||
      left.all?{ |e| e < tree } ||
      x == 0 || y == 0 ||
      x == $map.first.size-1 ||
      y == $map.size-1
    end
    
    $map = File
          .read("input.txt")
          .split
          .map{ |x| x.chars.map(&:to_i) }
    
    p (0...$map.size*$map.first.size)
        .count { |i| is_visible?(i%$map.first.size, i/$map.size) }
    
    1 vote
  2. Comment on Day 6: Tuning Trouble in ~comp

    MeckiSpaghetti
    (edited )
    Link
    Ruby Part 1 i = File.read("input.txt") i.chars.each_cons(4) do |s| if s == s.uniq p i.index(s.join)+4 break end end Part 2 i = File.read("input.txt") i.chars.each_cons(14) do |s| if s == s.uniq p...

    Ruby

    Part 1
    i = File.read("input.txt")
    
    i.chars.each_cons(4) do |s|
      if s == s.uniq
        p i.index(s.join)+4
        break
      end
    end
    
    Part 2
    i = File.read("input.txt")
    
    i.chars.each_cons(14) do |s|
      if s == s.uniq
        p i.index(s.join)+14
        break
      end
    end
    
    3 votes
  3. Comment on Day 5: Supply Stacks in ~comp

    MeckiSpaghetti
    (edited )
    Link
    Ruby Part 1 require "active_support/all" s,i = File .read("input.txt") .split("\n\n") s = s .split("\n")[..-2] .reverse .map{ |r| (1..r.size).step(4).map{ |e| r[e] } } .transpose .map{ |r|...

    Ruby

    Part 1
    require "active_support/all"
    
    s,i = File
            .read("input.txt")
            .split("\n\n")
    s = s
            .split("\n")[..-2]
            .reverse
            .map{ |r| (1..r.size).step(4).map{ |e| r[e] } }
            .transpose
            .map{ |r| r.delete_if(&:blank?) }
    
    i = i.split("\n")
    
    i.each do |line|
      a, f, t = line.scan(/\d+/).map(&:to_i) 
      a.times { s[t-1] << s[f-1].pop }
    end
    
    p s.map(&:last).join
    
    Part 2
    require "active_support/all"
    
    s,i = File
            .read("input.txt")
            .split("\n\n")
    s = s
            .split("\n")[..-2]
            .reverse
            .map{ |r| (1..r.size).step(4).map{ |e| r[e] } }
            .transpose
            .map{ |r| r.delete_if(&:blank?) }
    
    i = i.split("\n")
    
    i.each do |line|
      a, f, t = line.scan(/\d+/).map(&:to_i) 
      s[t-1] << s[f-1].pop(a)
      s[t-1].flatten!
    end
    
    p s.map(&:last).join
    
    1 vote
  4. Comment on Day 4: Camp Cleanup in ~comp

    MeckiSpaghetti
    Link
    Ruby require "active_support/all" sum = File .read("input.txt") .split(/-|,|\s/) .map(&:to_i) .each_slice(4) p1 = sum.count{ |a, b, c, d| (a..b).cover?(c..d) || (c..d).cover?(a..b) } p2 =...
    Ruby
    require "active_support/all"
    
    sum = File
          .read("input.txt")
          .split(/-|,|\s/)
          .map(&:to_i)
          .each_slice(4)
          
    p1 = sum.count{ |a, b, c, d| (a..b).cover?(c..d) || (c..d).cover?(a..b) }
    p2 = sum.count{ |a, b, c, d| (a..b).overlaps?(c..d) }
    
    p p1 # Part 1
    p p2 # Part 2
    
    1 vote
  5. Comment on Day 3: Rucksack Reorganization in ~comp

    MeckiSpaghetti
    (edited )
    Link
    Ruby Part 1 sum = File .read("input.txt") .split("\n") .map{ |l| [l[...l.size/2], l[l.size/2..]] } .map{ |a, b| a.chars & b.chars } .flatten .map{ |a| (a.ord-38) % 58 } .sum p sum Part 2 sum =...

    Ruby

    Part 1
    sum = File
             .read("input.txt")
             .split("\n")
             .map{ |l| [l[...l.size/2], l[l.size/2..]] }
             .map{ |a, b| a.chars & b.chars }
             .flatten 
             .map{ |a| (a.ord-38) % 58 }
             .sum
             
    p sum 
    
    Part 2
    sum = File
             .read("input.txt")
             .split("\n")
             .each_slice(3)
             .map{ |a, b, c| a.chars & b.chars & c.chars }
             .flatten 
             .map{ |a| (a.ord-38) % 58 }
             .sum
             
    p sum 
    
    2 votes
  6. Comment on Day 2: Rock Paper Scissors in ~comp

    MeckiSpaghetti
    (edited )
    Link
    Ruby both parts OUTCOMES = { 'A X' => [4, 3], 'A Y' => [8, 4], 'A Z' => [3, 8], 'B X' => [1, 1], 'B Y' => [5, 5], 'B Z' => [9, 9], 'C X' => [7, 2], 'C Y' => [2, 6], 'C Z' => [6, 7] } rows = File...

    Ruby

    both parts
    OUTCOMES = {
      'A X' => [4, 3],
      'A Y' => [8, 4],
      'A Z' => [3, 8],
      'B X' => [1, 1],
      'B Y' => [5, 5],
      'B Z' => [9, 9],
      'C X' => [7, 2],
      'C Y' => [2, 6],
      'C Z' => [6, 7]
    }
    
    rows = File
         .read("input.txt")
         .split("\n")
         .map(&OUTCOMES)
         
    p rows.sum(&:first) # Part 1
    p rows.sum(&:last) # Part 2
    
    3 votes
  7. Comment on Day 1: Calorie Counting in ~comp

    MeckiSpaghetti
    (edited )
    Link
    solution in Ruby Both parts s = File .read("input.txt") .split("\n\n") .map{ _1.split.map(&:to_i).sum } .sort .reverse p s.first # Part #1 p s.take(3).sum # Part #2

    solution in Ruby

    Both parts
    s = File
         .read("input.txt")
         .split("\n\n")
         .map{ _1.split.map(&:to_i).sum }
         .sort
         .reverse
    
    p s.first # Part #1
    p s.take(3).sum # Part #2
    
    1 vote
  8. Comment on Help me decide what technology should I use for this project in ~comp

    MeckiSpaghetti
    Link Parent
    You can read the serial port with a web app?? 😃

    You can read the serial port with a web app?? 😃

  9. Comment on Rust Moderation Team resigns in ~comp

  10. Comment on AI robots take off, with Boston Dynamics. Beyond Atlas' Parkour. in ~science

    MeckiSpaghetti
    Link
    I'm both fascinated and scared by what will be possible in the near future.

    I'm both fascinated and scared by what will be possible in the near future.

    3 votes
  11. Comment on <deleted topic> in ~tech

    MeckiSpaghetti
    Link Parent
    Yeah! I think people would be so much nicer to each other if everything was spoken word 😊

    Yeah!

    I think people would be so much nicer to each other if everything was spoken word 😊

    1 vote
  12. Comment on Star Trek: Lower Decks S02E01 - "Strange Energies" in ~tv

    MeckiSpaghetti
    Link
    Seems to be geo-blocked, can’t access it from Europe.

    Seems to be geo-blocked, can’t access it from Europe.

  13. Comment on Has UML died without anyone noticing? in ~comp

  14. Comment on Twitter and anti-intellectualism in ~humanities

    MeckiSpaghetti
    Link Parent
    It’s easy to overlook that many people don’t participate in (online) discourses. I’m sure there is a nice word for this kind of "bias": you only read the opinions of the people who have the...

    It’s easy to overlook that many people don’t participate in (online) discourses. I’m sure there is a nice word for this kind of "bias": you only read the opinions of the people who have the courage and ability to express themselves. It’s possible that the "mood" you perceive by reading the posts is not mirroring a real average, since you don’t see the lurkers and their honest thoughts 😅

    6 votes
  15. Comment on <deleted topic> in ~tech

    MeckiSpaghetti
    Link Parent
    Okay, the page does some lazy loading, had to scroll down and wait to "extend" the content a few times before being able to search for the word "hours". In case anyone is interested: We believe...

    Okay, the page does some lazy loading, had to scroll down and wait to "extend" the content a few times before being able to search for the word "hours". In case anyone is interested:

    We believe that battery life is the closest thing to a true Achilles' heel for the Framework laptop. In PCMark 10 Modern Office battery testing—which includes a mix of office applications, streaming video chat, and desktop idle workloads—the Framework doesn't quite hit nine hours of runtime, despite its solid 55Wh battery capacity.

    It could be worse!

    3 votes
  16. Comment on <deleted topic> in ~tech

    MeckiSpaghetti
    Link Parent
    I wish there were more details regarding battery life in the review.

    I wish there were more details regarding battery life in the review.

    2 votes
  17. Comment on <deleted topic> in ~tech

    MeckiSpaghetti
    (edited )
    Link
    Am I seeing this correctly that the air vents are at the bottom side of the device? Does anyone know if it’s used to suck in surrounding air or to blow the heat out? It seems like a questionable...

    Am I seeing this correctly that the air vents are at the bottom side of the device? Does anyone know if it’s used to suck in surrounding air or to blow the heat out?

    It seems like a questionable design choice to me, especially when having the notebook on a blanket or on a lap with clothes that might cover the vents.

    It reminds me of old Apple MacBook models which had the same problem …

    1 vote
  18. Comment on Peachesnstink: An interesting tildes/reddit-esque website in ~tech

    MeckiSpaghetti
    Link Parent
    Okay, right after posting I found out: I have to push the plus button of each thread to discover its title.

    Okay, right after posting I found out: I have to push the plus button of each thread to discover its title.

    4 votes
  19. Comment on Peachesnstink: An interesting tildes/reddit-esque website in ~tech

    MeckiSpaghetti
    Link
    Hmm, maybe I am still misunderstand the concept. As a guest a could see the threads, but as soon as I signed up, I can’t see anything. No matter if I’m in locked mode or not. What am I doing wrong?

    Hmm, maybe I am still misunderstand the concept. As a guest a could see the threads, but as soon as I signed up, I can’t see anything. No matter if I’m in locked mode or not.

    What am I doing wrong?

    2 votes
  20. Comment on EVGA confirms it's replacing all its RTX 3090s killed by Amazon's New World MMO in ~games

    MeckiSpaghetti
    Link Parent
    I have the feeling that the outrage would be even greater when it would be about hard drives. Many people still don’t make backups and would moan about having lost important data. So I think,...

    I have the feeling that the outrage would be even greater when it would be about hard drives. Many people still don’t make backups and would moan about having lost important data. So I think, replacing the hard drive and then having to recover the data would be more effort than to just replace the graphics card.

    3 votes