11
submitted 11 months ago* (last edited 11 months ago) by stifle867@programming.dev to c/advent_of_code@programming.dev

I'm using this starter kit for the scaffolding so I can simply run mix test for the example and mix d01.p2 to run the solution for my specific data set.

I've got the following code that passes p1 completely and the p2 example but not my specific data set. I can't find any bugs but the result fails for being "too high" and I'm really not sure why this is not being accepted. I have the debug output for each step and running through it manually everything seems right to me.

Is anyone able to point me in the right direction on what I'm missing?

https://pastebin.com/US8ikNLx

defmodule AdventOfCode.Day01 do
  def part1(args) do
    args
    |> String.split(~r/\n/, trim: true)
    |> Enum.map(&line_calibration_value/1)
    |> Enum.sum()
  end

  def part2(args) do
    args
    |> String.split(~r/\n/, trim: true)
    |> Enum.map(&words_to_numbers/1)
    |> Enum.map(&line_calibration_value/1)
    |> Enum.sum()
  end

  defp words_to_numbers(string) do
    numbers = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]

    String.replace(string, numbers, fn x ->
      (Enum.find_index(numbers, &(&1 == x)) + 1)
      |> Integer.to_string()
    end)
  end

  # TODO: doesn't work if the string has no numbers
  defp line_calibration_value(string) do
    # remove any non-numeric characters
    number_from_string = String.replace(string, ~r/[^\d]/, "")

    calibration_number = [
      # first number
      String.at(number_from_string, 0),
      # last number, or first number is string has length of 1
      String.at(number_from_string, -1)
    ]

    calibration_number
    |> List.to_string()
    |> String.to_integer()
  end
end

[-] stifle867@programming.dev 57 points 11 months ago* (last edited 11 months ago)

“Chicken meat poses a significant biosecurity risk to Australia, particularly the risk of highly pathogenic notifiable avian influenza (HPNAI) virus which can cause severe disease and mortality across Australia’s poultry industry, and may also affect wild bird populations.”

We do have a reputation for taking these things very seriously, as we should. We were even going to kill Johnny Depp's dogs at one point but settled for the "hostage video". Despite that, it does seem excessive in this case and should have been overturned on appeal at the very least.

Thankfully someone stepped up and ended up paying the fine on their behalf.

[-] stifle867@programming.dev 91 points 11 months ago

Revoke his bail as he is now showing an indication of a flight risk.

[-] stifle867@programming.dev 105 points 11 months ago

Thank you Russia for protecting us against those evil Ukranian Nazis by checks notes releasing back into society cannibals and murderers who dismembered teenagers, stabbed a single victim 666 times, murdered cats and dogs and cut the breasts off teenage girls before cutting out their tongues and hearts.

84
submitted 11 months ago by stifle867@programming.dev to c/news@lemmy.world

Experts believe the volcano could be ready to erupt because, while there were thousands of tremors happening in the week before last, since midnight on Monday, only 165 have been recorded.

[-] stifle867@programming.dev 72 points 11 months ago

This is not an answer to your question but it's tangentially related.

Someone I greatly respected ran an open-source project with the policy of merge everything. Completely flip this idea of carefully review, debate and revise every PR. His theory was that it helps to build an open community, and if something breaks someone else will revert that commit. He says that the main branch was almost always stable, a massive improvement to how it was run previously. He passed several years ago and for some reason this reminded me of him.

I guess what I'm trying to say is if you get something out there that people find useful, the code will be looked at. It doesn't help you if you're looking for someone to collaborate sorry.

[-] stifle867@programming.dev 51 points 1 year ago* (last edited 1 year ago)

I've been using Firefox on desktop and mobile exclusively for a number of years now. I will say the experience isn't perfect but it's better than using a browser made by a company that is actively hostile to its users.

It is important to take note that you will experience issues with some websites. For example, https://astro.build/ Try scrolling quickly up and down on this page on Firefox vs Chrome (on mobile).

7
submitted 1 year ago* (last edited 1 year ago) by stifle867@programming.dev to c/elixir@programming.dev

This only comes around once a year and is a great time to pick up some of their great courses using promo code 2023THANKS.

  • Elixir & OTP ~~$149~~ down to $89
  • Phoenix LiveView ~~$129~~ down to $77
  • Full-Stack GraphQL with Phoenix ~~$99~~ down to $59
[-] stifle867@programming.dev 148 points 1 year ago

This could have been prevented if there was a good toddler with a gun.

[-] stifle867@programming.dev 170 points 1 year ago

For context what he said was:

war crimes are war crimes even when committed by allies, and should be called out for what they are

Apparently condemning war crimes is enough to lose your job these days.

0
New Google Maps feature (programming.dev)

I got a push notification about how my Pixel just got more useful...yeah ok let's check this out. Turns out no, it's nothing new to me as Android 14 has been out for about a week now.

EXCEPT for a new "Immersive View" mode in Google Maps. It's just that I can't help but feel something here is wrong...missing even.

If you didn't see it, well I'm pretty sure the bridge doesn't have a huge structural gap in it.

How long before Google kills this feature?

[-] stifle867@programming.dev 132 points 1 year ago

That's actually one of the reasons I do not use Brave.

[-] stifle867@programming.dev 59 points 1 year ago

Thank you! The stupid thing is I'm literally enrolled in the beta program through the Google Play store... apparently that's the fake beta and you have to know this link for the real beta. I can confirm this issue does not exist on the "real" beta. You just saved me a lot of time.

[-] stifle867@programming.dev 75 points 1 year ago* (last edited 1 year ago)

For context, this is the "feature":

273

I've noticed a small issue with my email client for quite some time now where composing a new email will have several blank lines by default.

It's not too much of an issue to simply delete them but hey, maybe no one had pointed this out before! So I filed a bug report only to get this response... basically it's not a bug, its a feature!

11
submitted 1 year ago* (last edited 1 year ago) by stifle867@programming.dev to c/protonprivacy@lemmy.world

I've been a Proton Unlimited subscriber for some time now. I've always had an issue on Proton Mail (Android) when composing a new email it comes pre-filled with a number of blank lines in the body. Definitely a minor issue as it hadn't been fixed for a long time I decided to file a bug report. This was Proton's response:

Currently, this is the expected behavior when you are composing a message through the Proton Mail Android application.

Please kindly note that other users have expressed their opinion regarding this behavior as well and we have added your vote for this feature improvement request.

Basically: it's not a bug, it's a feature!

Is there actually anyone out there relying on this "feature"?

[-] stifle867@programming.dev 71 points 1 year ago

The article makes valid points but completely misses the real point. The real point, that has been pointed out every single time Google kills another product, is that every time they do that it erodes user trust. This point has been harped on for years, with more and more people agreeing with it the more and more Google kills products.

Is it any surprise then, that we're finally reaching a critical mass of users not trusting Google? It's less update this specific promise being untrustworthy, then the entire company being untrustworthy and this just happens to be the point that the dialogue had changed.

view more: next ›

stifle867

joined 1 year ago