Skip Navigation

User banner
Posts
5
Comments
92
Joined
2 yr. ago

  • Wow. Seems like I will never stop learning new things about Lua.

  • This isn't Lua code, Lua requires commas as separators for table items.

    EDIT: Retracted, it seems like Lua allows this madness

  • I hope it's going to be used instead of machine learning. Seems much more correct, secure and efficient to me.

  • Nice and easy.

    ::: spoiler Lua ```lua -- SPDX-FileCopyrightText: 2023 Jummit

    -- SPDX-License-Identifier: GPL-3.0-or-later

    local function nums(str) local res = {} for num in str:gmatch("%d+") do res[num] = true end return res end

    local cards = {} local points = 0 for line in io.open("4.input"):lines() do local winning, have = line:match("Card%s*%d+: (.) | (.)") winning = nums(winning) have = nums(have) local first = true local score = 0 local matching = 0 for num in pairs(have) do if winning[num] then matching = matching + 1 if first then first = false score = score + 1 else score = score * 2 end end end points = points + score table.insert(cards, {have=have, wins=matching, count=1}) end print(points)

    local cardSum = 0 for i, card in ipairs(cards) do cardSum = cardSum + card.count for n = i + 1, i + card.wins do cards[n].count = cards[n].count + card.count end end print(cardSum) ```

  • Input parsing AGAIN?

  • Mostly an input parsing problem this time, but it was fun to use Hares tokenizer functions:

  • Trickier than expected! I ran into an issue with Lua patterns, so I had to revert to a more verbose solution, which I then used in Hare as well.

    Lua:

    Hare:

  • and fuck people selling technology as a solution instead of system change.

  • It's also called depression. (I think, don't quote me on that.)

  • Any time I see graphs or statistics which cut of at 2020 to 2021 I get the feeling that the trend is being misrepresented, maybe deliberately.

  • But that would still put Earth on track to heat up roughly 2.5 to 2.9 degrees Celsius over preindustrial levels by the century’s end, the report found

    Doesn't that still mean extinction of nearly all life on earth? What's with the headline saying "safe levels"?

  • I think we have underestimated how much progress has been made on killing the planet.

  • It was always self defense. Just not as justified as it is now.

  • Same here. Sounds pretty sustainable to me!

  • I doubt TCP/UDP or basic HTTP requests will change much, but I guess it depends on how high-level the API is.

  • Of course the most productive comment is the least upvoted one. EDIT: After thinking about it, maybe it's best to add an explanation to bare links.

  • It's double speak. The translation is "We are evil and if you say something about what you see, we will silence you.".

  • General Programming Discussion @lemmy.ml

    Learnable Programming (Blog from 2012)

    Programming @beehaw.org

    Learnable Programming (Blog from 2012)

    Programming @programming.dev

    Learnable Programming (Blog from 2012)

    Art Share🎨 @lemmy.world

    Power cables from Serial Experiments Lain

    Creative @beehaw.org

    Power cables from Serial Experiments Lain