[-] kartoffelsaft@programming.dev 11 points 1 week ago

I've tried to hide all the moes but it feels sisyphean. I hide cyber moe, military moe, office moe... but the next day someone is going to start taco moe and I will see a half naked girl with cheese hair and a lettuce bra. There is no escape.

[-] kartoffelsaft@programming.dev 11 points 1 week ago

Hmm... the first three are the reals, but the last one is the rationals. Am I reading that right?

[-] kartoffelsaft@programming.dev 8 points 3 weeks ago

I wouldn't say that it'd be strictly impossible, however if it can be done then it would come at a considerable cost to useability, versatility, etc.

One adjacent concept that comes to mind is the use of the :visited CSS tag to extract a user's browsing habits. I remember seeing a demonstration of this where an "are you human" captcha was shown but the choice of image in each box was controlled by the :visited tag. I can't find that post, but this medium article demonstrates a similer concept. There are mitigations to this luckily, but a fullproof solution would be to remove the tag's functionality altogether, which would make certain websites (like the one we're on right now!) much more inconvenient to use.

It seems trivial to me for a website to detect user behaviors that indicate the use of an adblocker. For example, if a request for a page is immediately followed by a request for a video on that page, rather than after 5-60 seconds, then they're likey using an adblocker. If there is an ad placed between two paragaphs in an article, but two distant paragraphs are visible at the same time, it is more likely (although not guaranteed) that they are using an adblocker. If a user triggers an abnormal amount of those heuristics then they get flagged as an adblocking user.

[-] kartoffelsaft@programming.dev 35 points 1 month ago

I'm no biologist, but I'm pretty sure that this photo I took a while back has a lot of lichen:

That flakey & coral-looking stuff growing on the branches should be lichen.

[-] kartoffelsaft@programming.dev 5 points 1 month ago

I honestly assumed I was colorblind in one eye (I am diagnosed, at least)

[-] kartoffelsaft@programming.dev 6 points 1 month ago

bottom side of a pcb

[-] kartoffelsaft@programming.dev 5 points 2 months ago

I dunno, having two primes sum to a power of two is undeniably powerful in my experience. The number of times a calculation goes from tedious to trivial from this sum is incalculable. The lowest I'd put it is A.

[-] kartoffelsaft@programming.dev 8 points 6 months ago

I have mine set up with a bunch of categories that are sorted with a prepended 3-digit number. Allows me to have different sections of category without it getting mixed up. ex:

010 S
011 A+
012 A
013 A-
014 B+
etc...
350 plz play soon
355 wont play
...
800 dont remember buying this
[-] kartoffelsaft@programming.dev 4 points 9 months ago* (last edited 9 months ago)

Odin

When I read the problem description I expected the input to also be 2 digit numbers. When I looked at it I just had to say "huh."

Second part I think you definitely have to do in reverse (edit: if you are doing a linear search for the answer), as that allows you to nope out as soon as you find a match, whereas with doing it forward you have to keep checking just in case.

Formatted code

package day5

import "core:fmt"
import "core:strings"
import "core:slice"
import "core:strconv"

Range :: struct {
    dest: int,
    src: int,
    range: int,
}

Mapper :: struct {
    ranges: []Range,
}

parse_range :: proc(s: string) -> (ret: Range) {
    rest := s

    parseLen := -1

    destOk: bool
    ret.dest, destOk = strconv.parse_int(rest, 10, &parseLen)
    rest = strings.trim_left_space(rest[parseLen:])

    srcOk: bool
    ret.src, srcOk = strconv.parse_int(rest, 10, &parseLen)
    rest = strings.trim_left_space(rest[parseLen:])

    rangeOk: bool
    ret.range, rangeOk = strconv.parse_int(rest, 10, &parseLen)

    return
}

parse_mapper :: proc(ss: []string) -> (ret: Mapper) {
    ret.ranges = make([]Range, len(ss)-1)
    for s, i in ss[1:] {
        ret.ranges[i] = parse_range(s)
    }

    return
}

parse_mappers :: proc(ss: []string) -> []Mapper {
    mapsStr := make([dynamic][]string)
    defer delete(mapsStr)

    restOfLines := ss
    isLineEmpty :: proc(s: string)->bool {return len(s)==0}

    for i, found := slice.linear_search_proc(restOfLines, isLineEmpty); 
        found; 
        i, found  = slice.linear_search_proc(restOfLines, isLineEmpty) {
        
        append(&mapsStr, restOfLines[:i])
        restOfLines = restOfLines[i+1:]
    }
    append(&mapsStr, restOfLines[:])

    return slice.mapper(mapsStr[1:], parse_mapper)
}

apply_mapper :: proc(mapper: Mapper, num: int) -> int {
    for r in mapper.ranges {
        if num >= r.src && num - r.src < r.range do return num - r.src + r.dest
    }

    return num
}

p1 :: proc(input: []string) {
    maps := parse_mappers(input)
    defer {
        for m in maps do delete(m.ranges)
        delete(maps)
    }

    restSeeds := input[0][len("seeds: "):]
    min := 0x7fffffff

    for len(restSeeds) > 0 {
        seedLen := -1
        seed, seedOk := strconv.parse_int(restSeeds, 10, &seedLen)
        restSeeds = strings.trim_left_space(restSeeds[seedLen:])

        fmt.print(seed)
        for m in maps {
            seed = apply_mapper(m, seed)
            fmt.print(" ->", seed)
        }
        fmt.println()

        if seed < min do min = seed
    }

    fmt.println(min)
}

apply_mapper_reverse :: proc(mapper: Mapper, num: int) -> int {
    for r in mapper.ranges {
        if num >= r.dest && num - r.dest < r.range do return num - r.dest + r.src
    }

    return num
}

p2 :: proc(input: []string) {
    SeedRange :: struct {
        start: int,
        len: int,
    }

    seeds := make([dynamic]SeedRange)
    restSeeds := input[0][len("seeds: "):]

    for len(restSeeds) > 0 {
        seedLen := -1
        seedS, seedSOk := strconv.parse_int(restSeeds, 10, &seedLen)
        restSeeds = strings.trim_left_space(restSeeds[seedLen:])

        seedL, seedLOk := strconv.parse_int(restSeeds, 10, &seedLen)
        restSeeds = strings.trim_left_space(restSeeds[seedLen:])

        append(&seeds, SeedRange{seedS, seedL})
    }

    maps := parse_mappers(input)
    defer {
        for m in maps do delete(m.ranges)
        delete(maps)
    }

    for i := 0; true; i += 1 {
        rseed := i
        #reverse for m in maps {
            rseed = apply_mapper_reverse(m, rseed)
        }

        found := false
        for sr in seeds {
            if rseed >= sr.start && rseed < sr.start + sr.len {
                found = true
                break
            }
        }
        if found {
            fmt.println(i)
            break
        }
    }
}
[-] kartoffelsaft@programming.dev 5 points 1 year ago* (last edited 1 year ago)

There is the Anno series of games, which are technically RTS games but if I'm honest I find them the most fun when I go out of my way to avoid combat/micromanagement. I've only played 1404, 2070, and 2205, 2070 being the best in my opinion, but it has a bad history with DRM so I'd suggest 1404 (known as "Dawn of Discovery" in the US because us americans are afraid of numbers apparently).

Edit: looking at the steam page it looks like they decided to take 1404 down and made a new page where the game is (mostly) unchanged besides requiring you to jump through all the BS hoops that 2070 did, so I'd say if you're gonna spend money get 1404 on GOG, or if you are willing to do unspeakable things go with 2070.

[-] kartoffelsaft@programming.dev 8 points 1 year ago

Not really an answer to the question, but does anyone else think that the phrases "take a shit" and "give a shit" seem swapped? You say you're gonna take a shit when you are giving one to the toilet, and you say you don't give a shit when you are unwilling to take shit.

view more: next โ€บ

kartoffelsaft

joined 1 year ago