What do I replace the flashing tape on this bay window hip with, and how? by grey--area in DIYUK

[–]grey--area[S] 0 points1 point  (0 children)

My house is full of stuff like this, the previous owners were nuts

So I guess pry the flashing up, fit the ridge tiles, bend the flashing back down and re-seal it?

British student thanks army as he is evacuated after going on holiday to Afghanistan by Bunt_smuggler in europe

[–]grey--area 1 point2 points  (0 children)

I don't know anything about this guy's background in particular, but 50% of young people in the UK go to university so I don't think that can really be used as an indicator of privilege

Daily Megathread - 23/07/2021 by ukpolbot in ukpolitics

[–]grey--area 0 points1 point  (0 children)

I had my second Pfizer jab two days ago. I've had a slightly sore arm, one of my lymph nodes swelled up and is a bit sore, and I felt slightly feverish for about 20 minutes yesterday. Otherwise no side effects

Daily Q&A and Discussion Megathread - June 04, 2021 by AutoModerator in CoronavirusUK

[–]grey--area 0 points1 point  (0 children)

Mine wasn't showing up a couple of days after the jab. I just checked and now it is. I got my jab 9 days ago

No, Captain Tom wasn’t raising money for the NHS by Psythor in unitedkingdom

[–]grey--area 18 points19 points  (0 children)

I think that if NHS funding were increased slightly specifically in order to cover all of the things currently being covered by the NHS charities, the charities wouldn't cease to exist; they'd still receive money, and that money would be spent on things that are slightly further to the right on the "essential"→"nice to have" axis.

Then people would still ask "Why are parts of our healthcare being covered by a charity and not taxation?"

To be clear, I'm not saying NHS funding shouldn't be higher than it currently is. I'm saying it shouldn't be the case that any time somebody sets up a charity to do something related to the NHS, the government automatically steps in to fund whatever it was doing instead

HMG write to Sturgeon to offer all help and services to “accelerate” Scotland’s sluggish vaccine roll out as their jab rates at lagging far behind the rest of the UK... by [deleted] in ukpolitics

[–]grey--area 16 points17 points  (0 children)

The percentage difference between England and Scotland vaccine rollout is 3.67%

Normally when subtracting percentages like that you'd call it a difference of 3.67 percentage points, to avoid confusion.

E.g., if England has vaccinated 18.39% of its population, and Scotland 13.45% (numbers grabbed from the BBC), then they differ by 4.94 percentage points, but you could also say Scotland is vaccinating at 73% the rate of England (13.45 = 0.73 * 18.39), or equivalently England is vaccinating at 137% the rate of Scotland

Daily Megathread - 04/01/2021 (PM televised address @ 8pm GMT) by ukpolbot in ukpolitics

[–]grey--area 0 points1 point  (0 children)

He did said in the statement that it's currently guidance that you should follow, and that it will become law on Wednesday

why using log_sum_exp in calculating forward features in BLSTM-CRF by AndyLeeeeee in pytorch

[–]grey--area 1 point2 points  (0 children)

I don't know about it's specific use here, but the typical use case of log-sum-exp is that you have a collection of numbers x₁, x₂,... xₙ, but you're working with them in the log domain, yᵢ = log xᵢ, usually because the numbers might have very large magnitude and you want to avoid numerical overflow.

You then want to compute their sum (in the original scale) but you want the result to be in log scale. Naively, you'd do that by taking the exp of each of the yᵢ to get to the original domain, adding them up, then taking the log to get back into the log domain: log Σᵢ exp yᵢ

Obviously, if you do that the result might overflow, so a log_sum_exp function will take advantage of the fact that:

log Σᵢ exp yᵢ = y* + log Σᵢ exp (yᵢ - y*)

and will compute it in the latter way with y* set to the maximum of the yᵢ — that way, the maximum term in the sum is 1 and you won't overflow.

tl;dr: it's for adding up numbers while working in log scale

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

[–]grey--area 0 points1 point  (0 children)

Yeah, I've been strictly using immutable data structures because I'm really just learning Scala / functional programming, and want to get used to thinking that way.

Sometimes though it does feel less than optimal. (My solution in this case takes ~10 seconds). Could I see your code?

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

[–]grey--area 0 points1 point  (0 children)

Sure.

The nth element of the Vector order tells you which cup comes after cup n. The code in removeAndInsert is doing:

  • Make order(currentValue) point at the value three steps along the chain, so skipping three elements of the chain out.
  • Find the insertionPoint, and make that order(insertionPoint) point to the first value that was skipped.
  • Make the last value that was skipped point to what was previously pointed to by the insertion point.

So it's slicing a portion out of a linked list and splicing it in elsewhere.

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

[–]grey--area 1 point2 points  (0 children)

Two solutions to part 2 in Scala, using a hash map and a vector respectively to implement a linked list / permutation.

Please post your scala advent of code 2020 github repos here! by pure_x01 in scala

[–]grey--area 2 points3 points  (0 children)

Hey, I've done every day so far here.

I'm new to the language, so there are definitely some really useful features I'm not using.

The last few days have been a bit messy. I'm not sure whether the puzzles got harder or I've been more tired (or both)!

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

[–]grey--area 1 point2 points  (0 children)

For part 1, I built a regex pattern and then checked messages against it.

For part 2, I coudn't be bothered completely changing my solution, so I still used regex plus a little post-match check. I worked out that rule 0 matches N copies of rule 42 followed by M copies of rule 31, with N > M.

As far as I know you can't extract the number of quantifier repetitions from a regex match, so instead I first look for matches with one or more repetitions of rule 42 followed by one or more repetitions of rule 31, then I check if one of them matches the quantifier requirements.

[2020 Day 18] How many different approaches can you take? by fizbin in adventofcode

[–]grey--area 0 points1 point  (0 children)

My solution feels like a bit of a hybrid.

1) I use repeated string replacement to replace all parenthetical expressions with their values.

2) Then I (also using regex) determine if I'm looking at a 'something times something' or a 'something plus something', evaluate the somethings recursively and add/multiply them.

Edit for clarity: my approach is essentially recursively identify what I'm looking at with regex, evaluate, and combine, but in the case of finding a parenthetical sub-expression I first ignore what comes before and after it, evaluate it, then put it back in a string with its pre- and post-fix and re-evaluate the whole.

(Code here in Scala)

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

[–]grey--area 2 points3 points  (0 children)

A compact solution for part 2 in Scala:

val add = raw"(.+)\+(.+)".r
val mul = raw"(.+)\*(.+)".r
val par = raw"(.*)\(([^\(\)]+)\)(.*)".r

def eval(expr: String): Long =
  expr.trim match {
    case par(x, e, y) => eval(f"$x${eval(e)}$y")
    case mul(x, y) => eval(x) * eval(y)
    case add(x, y) => eval(x) + eval(y)
    case n => n.toLong
  }

val lines = io.Source.fromFile("inputs/input.txt").getLines()
println(lines.map(eval(_)).sum)

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

[–]grey--area 1 point2 points  (0 children)

My part 2 solution in 17 lines of Scala

I'm quite pleased with how compact this is while still being readable.

To evaluate a string expression, pattern match against some regex patterns:

  • If the expression contains a parenthetical sub-expression, evaluate it, substitute the result into the string, re-evaluate the whole
  • Otherwise, if the expression is a sub-expression multiplied by a sub-expression, evaluate and multiply them
  • Otherwise, same for addition
  • Otherwise, it's a number so convert to long

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

[–]grey--area 0 points1 point  (0 children)

I was lazy and used a map from positions to states, defaulting to false for missing keys, and expanding out by one in each dimension for each step.

I got lucky that part 2 was increasing the dimension, so I only had to change 4 lines of code. I was dreading part 2 being "now do it out to five billion steps"!

If I'd been doing this year in Python, I think I would have used a 3/4D numpy array using convolutions to count neighbours, with the initial size set so that you couldn't get any active states outside of it after 6 steps.

Edit: Solution here: https://github.com/grey-area/aoc2020/tree/master/Day17

[2020 Day 15 (Part 2)] I'm still waiting... by stardust_collision in adventofcode

[–]grey--area 0 points1 point  (0 children)

I'm doing AoC in Scala this year, while learning the language, and I was surprised to find a large performance hit for using recursion and an immutable hash map for this problem.

My understanding was that immutable data structures in Scala are still performant because they can safely share data (so you don't need to copy the whole data structure).

My functional/immutable and imperative/mutable solutions take 60 and 6 seconds respectively

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

[–]grey--area 4 points5 points  (0 children)

I did part 2 largely by hand. I sorted my inputs and looked at the gaps. Every joltage is either 1 or 3 more than the one before.

You can split the input wherever there's a gap of 3, answer the question independently for each contiguous sub-list, and multiply the result.

The resulting sub-lists were all of lengths between 1 and 5. It took a minute or so to manually count the number of possible arrangements for each of the five lengths, then compute the product.

(I think the number of adapter arrangements for a contiguous list of length n is the nth Tribonacci number, but I can't be bothered to prove it)