# MeckiSpaghetti's recent activity

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

MeckiSpaghetti
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
.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.advent_of_code

MeckiSpaghetti
(edited )
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. ## Comment on Day 5: Supply Stacks in ~comp.advent_of_code

MeckiSpaghetti
(edited )
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
.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
.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.advent_of_code

MeckiSpaghetti
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
.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.advent_of_code

MeckiSpaghetti
(edited )
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
.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
.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
``````
6. ## Comment on Day 2: Rock Paper Scissors in ~comp.advent_of_code

MeckiSpaghetti
(edited )
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
.split("\n")
.map(&OUTCOMES)

p rows.sum(&:first) # Part 1
p rows.sum(&:last) # Part 2
``````
7. ## Comment on Day 1: Calorie Counting in ~comp.advent_of_code

MeckiSpaghetti
(edited )
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
.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
You can read the serial port with a web app?? ðŸ˜ƒ

You can read the serial port with a web app?? ðŸ˜ƒ

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

MeckiSpaghetti
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.

11. ## Comment on <deleted topic> in ~tech

MeckiSpaghetti
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
Seems to be geo-blocked, canâ€™t access it from Europe.

Seems to be geo-blocked, canâ€™t access it from Europe.

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

MeckiSpaghetti
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 ðŸ˜…

15. ## Comment on A completely upgradeable laptop in ~tech

MeckiSpaghetti
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!

16. ## Comment on A completely upgradeable laptop in ~tech

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

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

17. ## Comment on A completely upgradeable laptop in ~tech

MeckiSpaghetti
(edited )
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
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.

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

MeckiSpaghetti
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?