reboot6675

joined 2 years ago
[–] reboot6675@sopuli.xyz 3 points 4 weeks ago* (last edited 4 weeks ago) (1 children)
  • One flew over the cuckoo's nest
  • Aftersun
  • The father
  • Manchester by the sea
  • Million dollar baby
[–] reboot6675@sopuli.xyz 2 points 1 month ago

Yeah, but back then no work, no responsibilities, friends not busy all the time...

[–] reboot6675@sopuli.xyz 2 points 2 months ago

Go

Now I'm behind by 1 day, will try to catch up.

For part 2 I spent a good while thinking about it, then when I convinced myself my plan could work, struggled a bit with the implementation. But it worked in the end. Basically grid[i][j] is how many different ways you can reach a cell. Start at 1 on the S cell, then propagate the values down and keep adding up the nums when you reach cells through different paths. The answer is the sum of the nums in the last row.

spoiler

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

	input := [][]rune{}

	for scanner.Scan() {
		line := []rune(scanner.Text())
		input = append(input, line)
	}

	m := len(input)
	n := len(input[0])
	grid := make([][]int, m)
	for i := range m {
		grid[i] = make([]int, n)
	}

	for i := range m {
		for j := range n {
			c := input[i][j]
			if i == 0 {
				if c == 'S' {
					grid[i][j] = 1
				}
				continue
			}
			if c == '^' {
				grid[i][j-1] += grid[i-1][j]
				grid[i][j+1] += grid[i-1][j]
			} else {
				grid[i][j] = grid[i][j] + grid[i-1][j]
			}
		}
	}

	paths := 0
	for j := range n {
		paths += grid[m-1][j]
	}

	fmt.Println(paths)
}

[–] reboot6675@sopuli.xyz 2 points 2 months ago

Go

Part 2: Read the whole input in a rune matrix. Scan it column by column, store the numbers as you go, ignoring all spaces, and store the operand when you find it. When you hit an empty column or the end, do the operation and add it to the total.

spoiler

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

	chars := [][]rune{}
	for scanner.Scan() {
		chars = append(chars, []rune(scanner.Text()))
	}

	m := len(chars)
	n := len(chars[0])
	var op rune
	nums := []int{}
	total := 0

	for j := range n {
		current := []rune{}
		for i := range m {
			if chars[i][j] == '+' || chars[i][j] == '*' {
				op = chars[i][j]
			} else if chars[i][j] != ' ' {
				current = append(current, chars[i][j])
			}
		}
		if len(current) > 0 {
			x, _ := strconv.Atoi(string(current))
			nums = append(nums, x)
		}
		if len(current) == 0 || j == n-1 {
			result := 0
			if op == '*' {
				result = 1
			}
			for _, x := range nums {
				if op == '+' {
					result = result + x
				} else {
					result = result * x
				}
			}
			total += result
			nums = []int{}
		}
	}

	fmt.Println(total)
}

[–] reboot6675@sopuli.xyz 2 points 2 months 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 5 points 2 months ago* (last edited 2 months 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 2 months 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 months ago

Borges mentioned. Amazing writer.

[–] reboot6675@sopuli.xyz 1 points 3 months ago

I've seen Strawberry mentioned a lot but I'm definitely not a fan of its looks haha. Gapless on the other hand looks pretty sleek. It's a bit less intuitive perhaps but I might give it a shot

[–] reboot6675@sopuli.xyz 3 points 3 months ago

Thanks for this tip also, will check it out

[–] reboot6675@sopuli.xyz 2 points 3 months ago

Quod Libet looks great, thanks! Probably going to go with this one. Looks pretty similar to Rhythmbox and also does #3 from my list

89
submitted 3 months ago* (last edited 3 months ago) by reboot6675@sopuli.xyz to c/opensource@lemmy.ml
 

Recently switched to Linux and have been looking for alternatives for Musicbee, which I used for ages in Windows. I guess I could make it work with Wine but thought I'd ask here for suggestions first. Features I'm looking for are not a lot to ask IMO:

  1. Music folder can be anywhere, not only ~/Music
  2. In the list of songs by a given artist, I can sort by album year, but the tracks within each album stay in the correct order
  3. The player remembers where I left off the next time I open it

I'm using Rhythmbox and it's great but unfortunately it doesn't do #3 (if I missed some setting let me know please).

Thanks in advance!

Edit: Best options from the comments were Strawberry and Quod Libet. I think I'll go with Quod Libet. Thanks all for the suggestions.

 

TLDR: Techbros in SF are wearing AI pins that record everything everyone says around them.

β€œMy general sense is that we should assume we are being recorded at all times,” said Clara Brenner, a partner at venture capital firm Urban Innovation Fund. β€œOf course, this is a horrible way to live your life.”

Damn right it is. Every day one step closer to dystopia. Fuck this shit.

 
19
submitted 8 months ago* (last edited 8 months ago) by reboot6675@sopuli.xyz to c/dumbphones@lemmy.world
 
 

Found this really cool and minimal Android launcher the other day.

For the past few months I've been using a side (smart)phone where I only installed Whatsapp and Spotify. Just an old Android I found in the bottom of a drawer. This has worked well for me, and Olauncher is a nice touch that makes it feel even more minimal. I sometimes go out only with the side phone or leave the main phone on my bag. As a result I get much less distracted than before.

I know this doesn't qualify as a dumphone, but I thought I could share in case someone who is not ready yet to make the switch to dumbphone finds it interesting.

 

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.

 

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

 

They turned around a 3-0, and won in penalties (6-5, went to sudden death)

I think more leagues should have relegation playoffs. One last chance of salvation for the upper team, one last chance of promotion for the lower team, and a thrilling game for the neutral fans.

 

So I joined a new gym last year and was pleasantly surprised. They gave me a smart card to get in and out, that's it, no app, no accounts, no nothing. Well, today I got to the gym and saw the announcement that they are phasing out the access with the smart card and starting to use, you guessed it, an app.

Now, I know this is not such a big deal in the grand scheme of things. But I'm just tired of this trend of replacing perfectly functioning systems with apps (public transport tickets come to mind). Just more ways to harvest people's data, I guess...

Ah and by the way, in my previous gym they not only required an app for accessing the place, they also incentivized people to track their workouts, meals and bodyweight using the gym's app (of course I never used any of these features).

view more: next β€Ί