Crestwave's recent activity

  1. Comment on Does Linux From Scratch actually teach you anything? in ~comp

    Crestwave
    Link
    LFS is great for learning about the system-level workings of a Linux distro. If you're interested in sysadmin stuff and build systems (packaging/porting/tinkering with software), then it could be...

    LFS is great for learning about the system-level workings of a Linux distro. If you're interested in sysadmin stuff and build systems (packaging/porting/tinkering with software), then it could be a good fit for you. I know it was for me.

    If you're interested in user-level stuff, then its teachings will likely just bounce off and prove not to be relevant.

    If you're interested in programming-level stuff (how do I make an OS?), then LFS probably won't provide you much, either—just a very basic overview of the possible layers of a complete OS.

    6 votes
  2. Comment on Day 4: Scratchcards in ~comp.advent_of_code

    Crestwave
    Link
    Feels more like a proper day 4 than the previous days did; simple and fun. I went the efficient route, although from @Crespyl's comment I'm guessing that it can be brute forced as well. Part 1...

    Feels more like a proper day 4 than the previous days did; simple and fun. I went the efficient route, although from @Crespyl's comment I'm guessing that it can be brute forced as well.

    Part 1
    #!/usr/bin/awk -f
    {
    	sub(/Card[ ]*[0-9]*: /, "")
    	split($0, card, "|")
    	card[2] = card[2] " "
    	$0 = card[1]
    	num = 0
    
    	for (i = 1; i <= NF; ++i)
    		if (match(card[2], "[^0-9]+" $i "[^0-9]+"))
    			num = num ? num * 2 : 1
    
    	total += num
    }
    
    END { print total }
    
    Part 2

    Due to past experience from Lanternfish and other exponential problems in the past, I decided to simply save their multipliers in a table instead of making actual copies of the cards.

    #!/usr/bin/awk -f
    {
    	mult[NR] += 1
    	sub(/Card[ ]*[0-9]*: /, "")
    	split($0, card, "|")
    	card[2] = card[2] " "
    	$0 = card[1]
    	num = 0
    
    	for (i = 1; i <= NF; ++i)
    		if (match(card[2], "[^0-9]+" $i "[^0-9]+"))
    			++num
    
    	for (i = 1; i <= num; ++i)
    		mult[NR + i] += 1 * mult[NR]
    
    	total += mult[NR]
    }
    
    END { print total }
    
    1 vote
  3. Comment on Day 3: Gear Ratios in ~comp.advent_of_code

    Crestwave
    Link
    Longer day 3 than expected; might be because it's a weekend. Part 2 was pretty simple, at least. Part 1 POSIX AWK doesn't seem to have a way to handle multiple matches so I had to manually...

    Longer day 3 than expected; might be because it's a weekend. Part 2 was pretty simple, at least.

    Part 1

    POSIX AWK doesn't seem to have a way to handle multiple matches so I had to manually implement it. Overall went pretty smoothly other than a couple off-by-one errors.

    #!/usr/bin/awk -f
    {
    	str = $0
    	len = 0
    	while (length(str) > 0) {
    		i = match(str, /[0-9]+/)
    		if (i == 0)
    			break
    		grid[i + len, NR] = substr(str, i, RLENGTH)
    		len += i + RLENGTH - 1
    		str = substr(str, i + RLENGTH)
    	}
    
    	str = $0
    	len = 0
    	while (length(str) > 0) {
    		i = match(str, /[^0-9.]/)
    		if (i == 0)
    			break
    		sym[i + len, NR] = substr(str, i, 1)
    		len += i + RLENGTH - 1
    		str = substr(str, i + RLENGTH)
    	}
    }
    
    END {
    	for (k in grid) {
    		split(k, xy, SUBSEP)
    		for (x = xy[1] - 1; x <= xy[1] + length(grid[k]); ++x)
    			for (y = xy[2] - 1; y <= xy[2] + 1; ++y)
    				if (sym[x, y])
    					total += grid[k]
    	}
    
    	print(total)
    }
    
    Part 2

    Very minor changes. The instructions specified "adjacent to exactly two part numbers", but I didn't have any that were more than two in my input so ¯\_(ツ)_/¯

    #!/usr/bin/awk -f
    {
    	str = $0
    	len = 0
    	while (length(str) > 0) {
    		i = match(str, /[0-9]+/)
    		if (i == 0)
    			break
    		grid[i + len, NR] = substr(str, i, RLENGTH)
    		len += i + RLENGTH - 1
    		str = substr(str, i + RLENGTH)
    	}
    
    	str = $0
    	len = 0
    	while (length(str) > 0) {
    		i = match(str, /[^0-9.]/)
    		if (i == 0)
    			break
    		sym[i + len, NR] = substr(str, i, 1)
    		len += i + RLENGTH - 1
    		str = substr(str, i + RLENGTH)
    	}
    }
    
    END {
    	for (k in grid) {
    		split(k, xy, SUBSEP)
    		for (x = xy[1] - 1; x <= xy[1] + length(grid[k]); ++x)
    			for (y = xy[2] - 1; y <= xy[2] + 1; ++y)
    				if (sym[x, y] == "*")
    					if (gear[x, y])
    						total += gear[x, y] * grid[k]
    					else
    						gear[x, y] = grid[k]
    	}
    
    	print(total)
    }
    
    1 vote
  4. Comment on Day 2: Cube Conundrum in ~comp.advent_of_code

    Crestwave
    Link
    Not much to say, pretty straightforward overall. AWK solutions: Part 1 #!/usr/bin/awk -f BEGIN { FS = "; " max["red"] = 12 max["green"] = 13 max["blue"] = 14 } { sub(/Game [0-9]*: /, "") for (i =...

    Not much to say, pretty straightforward overall. AWK solutions:

    Part 1
    #!/usr/bin/awk -f
    BEGIN {
    	FS = "; "
    	max["red"] = 12
    	max["green"] = 13
    	max["blue"] = 14
    }
    
    {
    	sub(/Game [0-9]*: /, "")
    	for (i = 1; i <= NF; ++i) {
    		split($i, set, ", ")
    		for (j in set) {
    			split(set[j], cube, " ")
    			if (max[cube[2]] < cube[1])
    				next
    		}
    	}
    
    	total += NR
    }
    
    END { print total}
    
    Part 2
    #!/usr/bin/awk -f
    BEGIN { FS = "; " }
    
    {
    	split("", max)
    	sub(/Game [0-9]*: /, "")
    
    	for (i = 1; i <= NF; ++i) {
    		split($i, set, ", ")
    		for (j in set) {
    			split(set[j], cube, " ")
    			if (cube[1] > max[cube[2]])
    				max[cube[2]] = cube[1]
    		}
    	}
    
    	total += max["red"] * max["green"] * max["blue"]
    }
    
    END { print total }
    
    1 vote
  5. Comment on Day 1: Trebuchet?! in ~comp.advent_of_code

    Crestwave
    Link
    Part 2 was much trickier than I expected. As usual, here's my hacky AWK solutions. Part 1 #!/usr/bin/awk -f { gsub(/[^0-9]/, "") total += substr($0, 1, 1) substr($0, length($0 - 1)) } END { print...

    Part 2 was much trickier than I expected. As usual, here's my hacky AWK solutions.

    Part 1
    #!/usr/bin/awk -f
    {
    	gsub(/[^0-9]/, "")
    	total += substr($0, 1, 1) substr($0, length($0 - 1))
    }
    
    END { print total }
    
    Part 2

    After spotting the overlapping problem, I initially just decided to parse it from left to right for some reason. The worst part is that it worked perfectly for the sample but not for my input... made things a lot harder for myself.

    #!/usr/bin/awk -f
    {
    	trans["one"] = 1
    	trans["two"] = 2
    	trans["three"] = 3
    	trans["four"] = 4
    	trans["five"] = 5
    	trans["six"] = 6
    	trans["seven"] = 7
    	trans["eight"] = 8
    	trans["nine"] = 9
    
    	do
    		for (k in trans)
    			if ($0 ~ "^[0-9]*" k)
    				sub(k, trans[k] k)
    	while (sub(/[^0-9]/, ""))
    
    	total += substr($0, 1, 1) substr($0, length($0 - 1))
    }
    
    END { print total }
    
    3 votes
  6. Comment on Listening to music with intent in ~music

    Crestwave
    (edited )
    Link
    I personally find that picking an album that matches my mood and listening to it completely gets me pretty focused due to the cohesiveness. Having the lyrics on hand can help, too.

    I personally find that picking an album that matches my mood and listening to it completely gets me pretty focused due to the cohesiveness. Having the lyrics on hand can help, too.

    3 votes
  7. Comment on Tildes multiplayer games in ~games

    Crestwave
    Link Parent
    They do not have access to your private server; chat is not routed through Mojang. The player that makes the report uploads them with the reporting tool and messages are signed by the sender to...

    They do not have access to your private server; chat is not routed through Mojang. The player that makes the report uploads them with the reporting tool and messages are signed by the sender to prevent forgery.

    Source

    25 votes
  8. Comment on Is pet ownership slavery? in ~humanities

    Crestwave
    Link Parent
    There are plenty of animals that are illegal to own as a pet. It is only logical to have different laws depending on the capability, intelligence and behavior of an animal; humans are not special...

    There are plenty of animals that are illegal to own as a pet. It is only logical to have different laws depending on the capability, intelligence and behavior of an animal; humans are not special in that regard. Dogs are kept as pets because they have been domesticated to achieve an effective symbiotic relationship with us.

    Again, I am definitely in support for tighter laws to prevent animal abuse; I just do not think pet ownership as a whole is slavery.

    5 votes
  9. Comment on Is pet ownership slavery? in ~humanities

    Crestwave
    (edited )
    Link
    If you disagree with me that houseplants are slaves, I will end this with a challenge: I claim that there can be no found no current law in America which defines a houseplant as anything other...

    If you disagree with me that houseplants are slaves, I will end this with a challenge: I claim that there can be no found no current law in America which defines a houseplant as anything other than property.

    You make some valid points regarding the mistreatment of animals, but they should be discussed in terms of animal rights and not human terminology, because pets are not humans.

    EDIT: s/animals are/pets are/

    12 votes
  10. Comment on Blizzard’s bringing its PC games to Steam, starting with Overwatch 2 in ~games

    Crestwave
    Link Parent
    It's been confirmed that it will launch directly through Steam. I've been having a lot of issues with Battle.net on Linux lately, so this is great news. Another thing people often overlook when...

    Unfortunately we still have to deal with stacking launchers, and I have no doubt that Blizzard games in Steam will just launch Battle.net which will then launch the game

    It's been confirmed that it will launch directly through Steam. I've been having a lot of issues with Battle.net on Linux lately, so this is great news.

    Just give me the game on Steam, please.

    Another thing people often overlook when comparing launchers is regional pricing; Steam has very generous regional prices, while most other launchers just don't have them at all.

    8 votes
  11. Comment on Is Apple's "walled garden" as bad as it was when the first few iPhones came out? in ~tech

    Crestwave
    Link Parent
    I have tried it before and there are more ads that go through than ones that are blocked; you would be better off using the built-in adblocker. The linked issue says that uBO is not supported but...

    I have it currently running on my phone in Orion.

    I have tried it before and there are more ads that go through than ones that are blocked; you would be better off using the built-in adblocker.

    Its GUI toolkit is not available .. The linked bug issue only says the same.

    The linked issue says that uBO is not supported but the settings should at least render. Here's another post from one of the devs confirming the lack of support.

  12. Comment on Is Apple's "walled garden" as bad as it was when the first few iPhones came out? in ~tech

    Crestwave
    Link Parent
    This is only the case for the Mac version (where you can use the full Firefox, anyway). uBlock Origin and most other extensions are not supported on iOS, just like other browsers. Their official...

    There is Orion-browser, downloadable simply from the app store that supports many chrome and firefox addons, ublock origin included.

    This is only the case for the Mac version (where you can use the full Firefox, anyway). uBlock Origin and most other extensions are not supported on iOS, just like other browsers.

    Their official FAQ used to say "Wait, are you saying I can run uBlock Origin and other Chrome/Firefox extensions in Orion?!" but they've since clarified it to "Wait, are you saying I can run uBlock Origin and other Chrome/Firefox extensions in Orion for Mac?!".

    7 votes
  13. Comment on I wrote a book. What are the site rules on self promotion? in ~tildes

    Crestwave
    (edited )
    Link Parent
    To clarify, @lou isn't suggesting to replace the current documentation format. The GNU manuals all have a paginated version like our current docs, in addition to the aforementioned single-page...

    To clarify, @lou isn't suggesting to replace the current documentation format. The GNU manuals all have a paginated version like our current docs, in addition to the aforementioned single-page version. Both have the same content and the user simply chooses whichever best suits their needs.

    In fact, the single-page Tildes docs can be made read-only to prevent editing problems.

    5 votes
  14. Comment on Overwatch 2: Invasion will cost $15 in ~games

    Crestwave
    Link
    Official Blogpost: https://overwatch.blizzard.com/en-us/news/23964186/ First Hands-On Review: https://www.gameinformer.com/preview/2023/06/12/exclusive-first-hands-on-with-the-pve-story-missions...

    Official Blogpost: https://overwatch.blizzard.com/en-us/news/23964186/
    First Hands-On Review: https://www.gameinformer.com/preview/2023/06/12/exclusive-first-hands-on-with-the-pve-story-missions


    This is pretty interesting. I initially thought the PvE would be sold separately but after the cancellation of Hero Missions, I assumed it would just be like the Archives events. The fact that they're charging for it must mean that they think it's good enough to stand on its own; otherwise, they probably would have just recouped the costs with skin sales. I guess we'll see soon enough.

    2 votes
  15. Comment on The woman bulldozing video games’ toughest DRM in ~games

    Crestwave
    Link Parent
    The article is two years old; it was a lot more accurate back then. At any rate, I'm glad that I just stick to legitimately bought indie games nowadays.

    The article is two years old; it was a lot more accurate back then.

    At any rate, I'm glad that I just stick to legitimately bought indie games nowadays.

  16. Comment on Day 11: Monkey in the Middle in ~comp

    Crestwave
    Link
    We just can't catch a break, huh. This had quite a few rules, and some worrying moments. But it was fun and never got too overwhelming as everything is pretty tidy despite all the monkey business....

    An operation like new = old * 5 means that your worry level after the monkey inspected the item is five times whatever your worry level was before inspection.

    We just can't catch a break, huh.

    This had quite a few rules, and some worrying moments. But it was fun and never got too overwhelming as everything is pretty tidy despite all the monkey business.

    Part 1
    #!/usr/bin/awk -f
    function eval(expr, old) {
    	gsub(/old/, old, expr)
    	split(expr, e, " ")
    
    	if (e[2] == "+")
    		return e[1] + e[3]
    	else if (e[2] == "-")
    		return e[1] - e[3]
    	else if (e[2] == "*")
    		return e[1] * e[3]
    	else if (e[2] == "/")
    		return e[1] / e[3]
    }
    
    /Monkey/ {
    	sub(/:/, "")
    	n = $2
    }
    /Starting/ {
    	sub(/.*: /, "")
    	items[n] = $0
    }
    /Operation/ {
    	sub(/.*new = /, "")
    	expr[n] = $0
    }
    /Test/ { test[n] = $(NF) }
    /If true/ { true[n] = $(NF) }
    /If false/ { false[n] = $(NF) }
    
    END {
    	for (i = 1; i <= 20; ++i)
    		for (j = 0; j <= n; ++j) {
    			split(items[j], item, ", ")
    			for (k in item) {
    				sum[j] += 1
    				w = item[k]
    				w = eval(expr[j], w)
    				w = int(w/3)
    
    				if (w % test[j] == 0)
    					l = true[j]
    				else
    					l = false[j]
    
    				if (items[l])
    					items[l] = items[l] ", " w
    				else
    					items[l] = w
    			}
    
    			items[j] = ""
    		}
    	
    	for (i in sum)
    		if (sum[i] > max[0]) {
    			max[1] = max[0]
    			max[0] = sum[i]
    		} else if (sum[i] > max[1]) {
    			max[1] = sum[i]
    		}
    
    	print(max[0] * max[1])
    }
    
    Part 2
    #!/usr/bin/awk -f
    function eval(expr, old) {
    	gsub(/old/, old, expr)
    	split(expr, e, " ")
    
    	if (e[2] == "+")
    		return e[1] + e[3]
    	else if (e[2] == "-")
    		return e[1] - e[3]
    	else if (e[2] == "*")
    		return e[1] * e[3]
    	else if (e[2] == "/")
    		return e[1] / e[3]
    }
    
    /Monkey/ {
    	sub(/:/, "")
    	n = $2
    }
    /Starting/ {
    	sub(/.*: /, "")
    	items[n] = $0
    }
    /Operation/ {
    	sub(/.*new = /, "")
    	expr[n] = $0
    }
    /Test/ { test[n] = $(NF) }
    /If true/ { true[n] = $(NF) }
    /If false/ { false[n] = $(NF) }
    
    END {
    	prime = 1
    
    	for (i in test)
    		prime *= test[i]
    
    	for (i = 1; i <= 10000; ++i)
    		for (j = 0; j <= n; ++j) {
    			split(items[j], item, ", ")
    			for (k in item) {
    				sum[j] += 1
    				w = item[k]
    				w = eval(expr[j], w)
    				w = w % prime
    
    				if (w % test[j] == 0)
    					l = true[j]
    				else
    					l = false[j]
    
    				if (items[l])
    					items[l] = items[l] ", " w
    				else
    					items[l] = w
    			}
    
    			items[j] = ""
    		}
    	
    	for (i in sum)
    		if (sum[i] > max[0]) {
    			max[1] = max[0]
    			max[0] = sum[i]
    		} else if (sum[i] > max[1]) {
    			max[1] = sum[i]
    		}
    
    	print(max[0] * max[1])
    }
    
    2 votes
  17. Comment on Day 9: Rope Bridge in ~comp

    Crestwave
    Link
    Well my attempts at shortcuts certainly didn't do me any favors in part 2. Part 1 The idea was basically to move to the previous position of the head if there are more than two spaces between...

    Well my attempts at shortcuts certainly didn't do me any favors in part 2.

    Part 1 The idea was basically to move to the previous position of the head if there are more than two spaces between them.
    #!/usr/bin/awk -f
    {
    	for (i = 1; i <= $2; ++i) {
    		_x = x
    		_y = y
    
    		if (/U/)
    			y -= 1
    		else if (/D/)
    			y += 1
    		else if (/L/)
    			x -= 1
    		else if (/R/)
    			x += 1
    
    		__x = X > x ? X-x : x-X
    		__y = Y > y ? Y-y : y-Y
    
    		if (__x > 1 || __y > 1) {
    			X = _x
    			Y = _y
    		}
    
    		grid[X, Y] = 1
    	}
    }
    
    END {
    	for (i in grid)
    		if (grid[i]) 
    			sum += 1
    
    	print(sum)
    }
    
    Part 2 I had to rewrite the logic for this part due to the more complex movements possible.
    #!/usr/bin/awk -f
    BEGIN {
    	for (i = 0; i <= 9; ++i) {
    		X[i] = 0
    		Y[i] = 0
    	}
    }
    
    {
    	for (i = 1; i <= $2; ++i) {
    		if (/U/)
    			Y[0] -= 1
    		else if (/D/)
    			Y[0] += 1
    		else if (/L/)
    			X[0] -= 1
    		else if (/R/)
    			X[0] += 1
    		
    		for (j = 1; j <= 9; ++j) {
    			x = X[j-1] - X[j]
    			y = Y[j-1] - Y[j]
    
    			if (x == 2)
    				X[j] = X[j-1] - 1
    			else if (x == -2)
    				X[j] = X[j-1] + 1
    			else if (y == 2 || y == -2)
    				X[j] = X[j-1]
    
    			if (y == 2)
    				Y[j] = Y[j-1] - 1
    			else if (y == -2)
    				Y[j] = Y[j-1] + 1
    			else if (x == 2 || x == -2)
    				Y[j] = Y[j-1]
    
    			if (j == 9)
    				grid[X[j], Y[j]] = 1
    		}
    	}
    
    }
    
    END {
    	for (i in grid)
    		if (grid[i]) 
    			sum += 1
    
    	print(sum)
    }
    
    1 vote
  18. Comment on Day 10: Cathode-Ray Tube in ~comp

    Crestwave
    Link
    I initially found part 2's instructions a bit confusing, but this was a cute one. Part 1 #!/usr/bin/awk -f function cycle(n,i) { for (i = 1; i <= n; ++i) { t += 1 if ((t - 20) % 40 == 0) sum += X...

    I initially found part 2's instructions a bit confusing, but this was a cute one.

    Part 1
    #!/usr/bin/awk -f
    function cycle(n,	i) {
    	for (i = 1; i <= n; ++i) {
    		t += 1
    		if ((t - 20) % 40 == 0)
    			sum += X * t
    	}
    }
    
    BEGIN { X = 1 }
    
    /noop/ { cycle(1) }
    /addx/ {
    	cycle(2)
    	X += $2
    }
    
    END { print(sum) }
    
    Part 2
    #!/usr/bin/awk -f
    function cycle(n,	i, j) {
    	for (i = 1; i <= n; ++i) {
    		j = t % 40
    
    		if (X == j - 1 || X == j || X == j + 1)
    			str = str "#"
    		else
    			str = str "."
    
    		if (j == 39)
    			str = str "\n"
    
    		t += 1
    	}
    }
    
    BEGIN { X = 1 }
    
    /noop/ { cycle(1) }
    /addx/ {
    	cycle(2)
    	X += $2
    }
    
    END { printf("%s", str) }
    
    5 votes
  19. Comment on Day 8: Treetop Tree House in ~comp

    Crestwave
    Link
    Not particularly elegant but it works. :P Part 1 #!/usr/bin/awk -f BEGIN { FS = "" } { for (x = 1; x <= NF; ++x) grid[x, NR] = $x } END { X = length($0) Y = NR for (x = 1; x <= X; ++x) { i = -1...

    Not particularly elegant but it works. :P

    Part 1
    #!/usr/bin/awk -f
    BEGIN { FS = "" }
    
    {
    	for (x = 1; x <= NF; ++x)
    		grid[x, NR] = $x
    }
    
    END {
    	X = length($0)
    	Y = NR
    
    	for (x = 1; x <= X; ++x) {
    		i = -1
    		for (y = 1; y <= Y; ++y) {
    			if (grid[x, y] < i)
    				continue
    			if (grid[x, y] > i)
    				visible[x, y] = 1
    			i = grid[x, y]
    		}
    	}
    
    	for (x = 1; x <= X; ++x) {
    		i = -1
    		for (y = Y; y >= 1; --y) {
    			if (grid[x, y] < i)
    				continue
    			if (grid[x, y] > i)
    				visible[x, y] = 1
    			i = grid[x, y]
    		}
    	}
    
    	for (y = 1; y <= Y; ++y) {
    		i = -1
    		for (x = 1; x <= X; ++x) {
    			if (grid[x, y] < i)
    				continue
    			if (grid[x, y] > i)
    				visible[x, y] = 1
    			i = grid[x, y]
    		}
    	}
    
    	for (y = 1; y <= Y; ++y) {
    		i = -1
    		for (x = X; x >= 1; --x) {
    			if (grid[x, y] < i)
    				continue
    			if (grid[x, y] > i)
    				visible[x, y] = 1
    			i = grid[x, y]
    		}
    	}
    
    	for (i in visible)
    		sum += 1
    
    	print(sum)
    }
    
    Part 2
    #!/usr/bin/awk -f
    function sight(x, y, _x, _y, X, Y,	i, sum) {
    	i = grid[x, y]
    	sum = 0
    
    	do {
    		x += _x
    		do {
    			y += _y
    			if (grid[x, y] != "") {
    				sum += 1
    				if (grid[x, y] >= i)
    					return sum
    			}
    		} while (y != Y)
    	} while (x != X)
    
    	return sum
    }
    
    BEGIN { FS = "" }
    
    {
    	for (x = 1; x <= NF; ++x)
    		grid[x, NR] = $x
    }
    
    END {
    	X = length($0)
    	Y = NR
    
    	for (x = 1; x <= X; ++x)
    		for (y = 1; y <= Y; ++y) {
    			score = sight(x, y, 0, -1, x, 1-1) * \
    				 sight(x, y, 0, +1, x, Y+1) * \
    				 sight(x, y, -1, 0, 1-1, y) * \
    				 sight(x, y, +1, 0, X+1, y)
    
    			if (score > max)
    				max = score
    		}
    
    	print(max)
    }
    
    2 votes