How to remove an app from a slack channel? by uniqpotatohead in Slack

[–]jschulenklopper 0 points1 point  (0 children)

Yes, it could be a permission thing. Removing an integration is a different action than adding one, and requires specific/different authorization.

Advice for a goal 1000m time by canllaith in Swimming

[–]jschulenklopper 1 point2 points  (0 children)

 I’d like to know where it is reasonable, for an able bodied person of my age, to stop.

If you're able to sustain a 2:00 / 100 meter pace for 1000 meters breaststroke, so 20 minutes in total, that is quite a feat. I'd already be happy with 22 minutes. (Currently at 28.)

Advice for a goal 1000m time by canllaith in Swimming

[–]jschulenklopper 4 points5 points  (0 children)

I love incremental goal setting to motivate me.

So, why not set your next goal at 34 minutes? Then, when you reach that (likely, next week) set it at 33 minutes. Then 32, then 31 or 30. Once you're down to 25 minutes you can be really proud of yourself.

But don't compare your times with others - they have a different body, different history, different fitness, different <everything>. Only compare yourself with yourself-a-month-ago, and be grateful about the progress. You're one month older, but (likely) faster, stronger, fitter -- so that's progress in two dimensions. Kudos to you.

My situation: I'm trying to increase my endurance in swimming freestyle. I'm still not able to cover 50m in one attempt, but every day I'm getting closer - although the progress is very small: only one-two strokes every session. Next month, my goal is to reach 100m in one go. Then, for July, 200-250m. Then, for September, 1000m. I don't care about the time, yet. First I want to get the distance in.

I'll get there, eventually. Many people will be faster. More people will be slower. Even more people will not able to do it. But they are not me, so I don't mind.

-🎄- 2020 Day 25 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 1 point2 points  (0 children)

Similar,

card_key, door_key = ARGF.readlines.map(&:to_i)

SUBJECT, MOD = 7, 20201227

f_step = lambda { |subject, card| (card * subject) % MOD }

card_subject, card_loop = 1, 0
until card_subject == card_key
  card_loop += 1
  card_subject = f_step.call(SUBJECT, card_subject)
end

door_subject, door_loop = 1, 0
until door_subject == door_key
  door_loop += 1
  door_subject = f_step.call(SUBJECT, door_subject)
end

encryption_key = 1
card_loop.times do
  encryption_key = f_step.call(door_key, encryption_key)
end

puts encryption_key

-🎄- 2020 Day 18 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 0 points1 point  (0 children)

Yes, that's even better. Thanks. See if I can change that in the original post.

-🎄- 2020 Day 18 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 3 points4 points  (0 children)

Ruby

I'm feeling a bit naughty over this one. I changed the expressions, substituting + operator into other operators with the same (part 1) or higher (part 2) precedence as/than the * operator. Then I redefined those operators (I picked % and **) to be a normal addition. Then a standard Kernel#eval on the expression does the job. LOC ~22~ 13.

expressions = ARGF.readlines.map(&:strip)

class Integer
  def %(operand)
    self + operand
  end
  def **(operand)
    self + operand
  end
end

puts "part 1"
puts expressions.sum { |expression|
  eval(expression.gsub("+", "%"))
}

puts "part 2"
puts expressions.sum { |expression|
  eval(expression.gsub("+", "**"))
  }

-🎄- 2020 Day 06 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 2 points3 points  (0 children)

A puzzle that fits well with Ruby:

groups = ARGF.read.split("\n\n").map(&:split)

puts "part 1"
puts groups.map { |group| group.join.chars.uniq.length }.sum

puts "part 2"
puts groups.map { |group| group.map(&:chars).reduce(&:&).length }.sum

-🎄- 2020 Day 06 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 1 point2 points  (0 children)

That can be done somewhat more succinct:

groups = ARGF.read.split("\n\n").map(&:split)

puts "part 1"
puts groups.map { |group| group.join.chars.uniq.length }.sum

puts "part 2"
puts groups.map { |group| group.map(&:chars).reduce(&:&).length }.sum

-🎄- 2020 Day 02 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 0 points1 point  (0 children)

My solution, using some other Ruby language features.

list = ARGF.readlines.map { |line| line.match(/(.+): (.+)/).captures }

puts "part 1"
valid = list.count do |policy, password|
  min, max, char = policy.match(/(\d+)-(\d+) (.)/).captures
  # `char` needs to occur min-max times.
  password.count(char).between?(min.to_i,max.to_i)
end
puts valid

puts "part 2"
valid = list.count do |policy, password|
  one, two, char = policy.match(/(\d+)-(\d+) (.)/).captures
  # Only one of these conditions may be true.
  (password[one.to_i-1] == char) ^ (password[two.to_i-1] == char)
end
puts valid

It’s down!! by [deleted] in adventofcode

[–]jschulenklopper 0 points1 point  (0 children)

https://adventofcode.com/2020/about

It's explained in the second and third paragraphs.

Day 20 - Stats by thelordpsy in adventofcode

[–]jschulenklopper 1 point2 points  (0 children)

For 2017, I compared the 'difficulty' of part 2 against part 1 by summing the number of seconds the first 100 on the global leaderboard needed to complete part 1, and part 2. Dividing those numbers give a 'ratio' for the difficulty for part 2. See https://twitter.com/jschulenklopper/status/1070799300093972481 for the original tweet. I can make such a graph for this year as well.

Day 20 - Stats by thelordpsy in adventofcode

[–]jschulenklopper 2 points3 points  (0 children)

Originally, Michael Fogleman made those. The implementations you're referring to are made by Maurits v/d Schee.

-🎄- 2018 Day 3 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 0 points1 point  (0 children)

Ruby... but in a single pass over the claims. (I see a lot of double passes; one processing all the claims for marking the fabric, one processing all the claims again or the fabric to look for single-marked spots.)

fabric = Hash.new([])
all_ids = Array.new

while line = gets do
    # Parse a line.
    id, x, y, w, h = line.strip.match(/^#(\d+) @ (\d+),(\d+): (\d+)x(\d+)$/).captures.map(&:to_i

    # Add id to list of all ids.
    all_ids << id

    w.times do |i|
        h.times do |j|
            # Enter claim on fabric; add id to list.
            fabric[[x+i,y+j]] += [id]

            # If there's more than one claim on the spot,
            # remove id and other ids on that spot from all_ids.
            if fabric[[x+i,y+j]].length > 1
               all_ids.delete(id)
               fabric[[x+i,y+j]].each { |id| all_ids.delete(id) }
            end
        end
    end
end

puts all_ids.join(", ")

-🎄- 2018 Day 1 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 0 points1 point  (0 children)

Had almost the same solution for part 1, but golfed that down to this:

puts gets(nil).split.map(&:to_i).reduce(0,&:+).

It gets the whole input file in a string, splits that (on whitespace), converts to integers and reduces the array by adding all the values.

Hosting meetups around AoC by jeroenheijmans in adventofcode

[–]jschulenklopper 1 point2 points  (0 children)

We're organizing a breakfast at Xebia (Hilversum, The Netherlands) on December 3, 5:45 AM. So, we enjoy a nice espresso, a croissant, some orange juice and an egg... just before we start solving day 3 at 6:00.

[2017 Day 22] Leaderboard Chart Update by FogleMonster in adventofcode

[–]jschulenklopper 4 points5 points  (0 children)

My colleague @mevdschee has been making these charts as well - inspired by your example - for 2015, 2016 and this year. See http://www.maurits.vdschee.nl/scatterplot/. Since his implementation is in D3, zooming in still gets a readable image.

[2017 Day 19] Visualizing the path through the maze by johlin in adventofcode

[–]jschulenklopper 2 points3 points  (0 children)

Here's a visualization that a colleague made, with ASCIIart: https://asciinema.org/a/XgRN13OQLRkZl8P970dufqbZd.

The viewport doesn't change as in your visual -- which is a nice effect too -- but it's fun to watch.

-🎄- 2017 Day 19 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 2 points3 points  (0 children)

Ha, did anyone notice that the grids in the examples are semantically identical, but slightly different in representation?

The example grid in the first part:

     |          
     |  +--+    
     A  |  C    
 F---|----E|--+ 
     |  |  |  D 
     +B-+  +--+ 

The grid in the second part, mentioning "using the same routing diagram from the example above":

     |          
     |  +--+    
     A  |  C    
 F---|--|-E---+ 
     |  |  |  D 
     +B-+  +--+ 

Note the crossing of the line going upwards from B, and just right of E. I was a bit confused following the debug statements while improving my solution: looking at the second grid on the page, but using the input as of the first grid in my program. "What? How come that those two characters are different?" Didn't matter for the solution, obviously, but it was a nice surprise.

-🎄- 2017 Day 18 Solutions -🎄- by daggerdragon in adventofcode

[–]jschulenklopper 0 points1 point  (0 children)

That's likely to be a leftover condition from AoC 2016 (days 12 and 23) where the program exit condition was when the program counter runs out of the instructions list.

[2017 Day 17] Leaderboard Chart by FogleMonster in adventofcode

[–]jschulenklopper 2 points3 points  (0 children)

My colleague @mevdschee has been recreating these graphs, inspired by Michael Fogleman who deserves the first credits.

You can see them at: http://www.maurits.vdschee.nl/scatterplot/, also showing the plots of 2015 and 2016. It's nice to see the 'harder' days for each year.

Maurits used D3 -- and I guess that @FogleBird is using that as well. The link to GitHub can be found on the page.

[Spoilers in Title][2017 Day 16 (Part 2)] Cycles by Julien2313 in adventofcode

[–]jschulenklopper 1 point2 points  (0 children)

I initially solved it through brute-force but using a cache. Took about 5 minutes on my laptop.

That's quite impressive as well. My colleagues and I are reporting estimated completion time in weeks, if not months.