reboot6675

joined 2 years ago
[โ€“] reboot6675@sopuli.xyz 2 points 1 day ago

First I tried to to part 2 with a very poor regex strategy and the performance was abysmal. Switched to plain substrings and boom, instant result.

Golang

func part1() {
	ranges := readInput()
	invalidSum := 0

	for _, r := range ranges {
		parts := strings.Split(r, "-")
		start, _ := strconv.Atoi(parts[0])
		end, _ := strconv.Atoi(parts[1])

		for num := start; num <= end; num++ {
			current := strconv.Itoa(num)
			n := len(current)
			if n%2 != 0 {
				continue
			}
			left := current[:n/2]
			right := current[n/2:]
			if left == right {
				invalidSum += num
			}
		}
	}

	fmt.Println(invalidSum)
}

func part2() {
	ranges := readInput()
	invalidSum := 0

	for _, r := range ranges {
		parts := strings.Split(r, "-")
		start, _ := strconv.Atoi(parts[0])
		end, _ := strconv.Atoi(parts[1])

		for num := start; num <= end; num++ {
			current := strconv.Itoa(num)
			n := len(current)

			for index := 1; index <= n/2; index++ {
				if n%index != 0 {
					continue
				}

				left := 0
				right := index
				prefix := current[left:right]
				isRepeated := true
				for left < n && right < n {
					left = right
					right = right + index
					next := current[left:right]
					if next != prefix {
						isRepeated = false
						break
					}
				}

				if isRepeated {
					invalidSum += num
					break
				}
			}
		}
	}

	fmt.Println(invalidSum)
}
[โ€“] reboot6675@sopuli.xyz 3 points 2 days ago* (last edited 2 days ago)

Golang

func part1() {
	// file, _ := os.Open("sample.txt")
	file, _ := os.Open("input.txt")
	defer file.Close()

	scanner := bufio.NewScanner(file)
	n := 100
	current := 50
	pointingAt0 := 0

	for scanner.Scan() {
		line := scanner.Text()
		num, _ := strconv.Atoi(line[1:])
		if line[0] == 'L' {
			current = ((current-num)%n + n) % n
		} else {
			current = (current + num) % n
		}
		if current == 0 {
			pointingAt0++
		}
	}

	fmt.Println(pointingAt0)
}

func part2() {
	// file, _ := os.Open("sample.txt")
	file, _ := os.Open("input.txt")
	defer file.Close()

	scanner := bufio.NewScanner(file)
	n := 100
	current := 50
	pointingAt0 := 0

	for scanner.Scan() {
		line := scanner.Text()
		num, _ := strconv.Atoi(line[1:])

		rounds := num / n
		pointingAt0 += rounds
		num = num % n
		new := -1

		if line[0] == 'L' {
			new = ((current-num)%n + n) % n
			if current != 0 && (new > current || new == 0) {
				pointingAt0++
			}
		} else {
			new = (current + num) % n
			if current != 0 && (new < current || new == 0) {
				pointingAt0++
			}
		}

		current = new
	}

	fmt.Println(pointingAt0)
}
[โ€“] reboot6675@sopuli.xyz 2 points 1 week ago (1 children)

Ohh so it was possible to use floats for this! I was "worried" that it would lead to precision errors haha so I ended up "cheating" with BigInt (Golang) to make all the multiplications first and one division at the end

[โ€“] reboot6675@sopuli.xyz 3 points 3 weeks ago

Borges mentioned. Amazing writer.

[โ€“] reboot6675@sopuli.xyz 17 points 1 month ago

Oh man good memories from Simpsons Hit & Run, this is awesome!

[โ€“] reboot6675@sopuli.xyz 6 points 1 month ago (1 children)

Just pointing out that these 2 are not necessarily contradicting statements. Just because it hasn't taken any jobs yet, doesn't mean it won't take any in the next 10 years. Not that I really want to believe those numbers though. But yeah as others have pointed out, these studies need to be taken with a grain of salt.

[โ€“] reboot6675@sopuli.xyz 9 points 1 month ago (1 children)

Just yesterday I came across some Sora generated memes and damn, it was obviously fake (to me) but it looked so real, I am sure some people out there will totally believe this stuff. Misinformation is going to get wild

[โ€“] reboot6675@sopuli.xyz 17 points 2 months ago (7 children)

Been having similar case with dev teams who have coded every error to be 500. User typed the wrong URL? 500. User tried to access a page without logging in? 500... Makes detecting real errors a pain

[โ€“] reboot6675@sopuli.xyz 47 points 3 months ago (3 children)

I once read the first 3 chapters of the Git book and my coworkers think I'm some kind of Git wizard

 
[โ€“] reboot6675@sopuli.xyz 47 points 4 months ago (13 children)

When I was a kid I encountered this problem when I wondered what would happen if I half-empty a bottle of soda, re-fill it with water, and repeat. Will it eventually become just water or will there always be some soda left? It boggled my mind for a while, then I forgot about it until I reached university calculus haha

[โ€“] reboot6675@sopuli.xyz 3 points 5 months ago

Reading it in Spanish is a pain in the ass even for a native speaker, book is from the 1600s so you can imagine the language is really different to what it is today. I imagine there must be some version in "current language", but in school we were told to read the original and it was a pain, didn't get past the first quarter then and never tried reading it again

 
 

GOAT

 

Came across this paper the other day. I'm yet to read it fully, but its existence is interesting already. Dumbphones have now gathered attention from the media and the academic world too.

3
Smile! (sopuli.xyz)
 

We're all gonna end up in one of those aren't we...

 

Stumbled upon this article about the rising popularity of dumbphones.

Hope this community starts getting more traction :)

As for my journey, I am still on a "dumb smartphone" phase, an old phone with only Whatsapp and Spotify. I've been considering making the switch to a dumb phone or at least a candybar smartphone like the Qin F21.

 
 

Context: the creator of Linux is from Finland

 

Context: this is a legit screenshot I took on my workplace around 1.5 years ago. Hopefully it's been patched by now? Completely ridiculous behavior

 

Had it saved on my hard drive for years and recently re-discovered it. Seems to be from 2011 (!!)

Google is getting worse by the year, but it seems even back then some people were already seeing where things were going.

(Credits to the original author whoever it might be)

view more: next โ€บ