• 0 Posts
  • 11 Comments
Joined 1 year ago
cake
Cake day: June 20th, 2023

help-circle

  • 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.


  • I agree pretty strongly with this generally. The farside has a way of having jokes that are so simple on it’s face that I’m left thinking “surely I’ve missed something?” Usually it turns out that no, in fact, I got the joke and was just vastly underwhelmed.

    For whatever reason I found this one to be mildly funny. Couldn’t tell you why. Perhaps it’s the idea that the people who built the atomic bomb weren’t that smart after all?





  • The thing that finally got businesses to finally get off IE wasn’t from the browser being worse than every other option. Heck, it wasn’t even because it was a decrepit piece of software that lost it’s former market dominance (and if anything businesses see that as a positive, not a negative).

    What finally did that was microsoft saying there won’t be any security updates. That’s what finally got them off their ass; subtly threatening them with data breaches, exploits, etc. if they continue to use it. I don’t see google doing this anytime soon, at least not without a “sequel” like microsoft had with edge.





  • 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
            }
        }
    }