Paul's Avatar

Paul

@trespaul.com

xenofeminist // chaostician // categorical abolitionist // cyberneticist // philosophy masters student // libre software enjoyer // functional programming enthusiast // he/they/any/none // @trespaul@tech.lgbt // trespaul.com //// Cape Town, South Africa

170
Followers
647
Following
171
Posts
19.11.2024
Joined
Posts Following

Latest posts by Paul @trespaul.com

i dont like cellular automata research because i know one of the rulesets is going to be isomorphic to the feed from a camera that doesnt exist which follows me around 24/7

01.03.2026 03:46 ๐Ÿ‘ 65 ๐Ÿ” 6 ๐Ÿ’ฌ 2 ๐Ÿ“Œ 0

This year, why not do the #AdventOfCode in #Haskell with your polycule?

02.12.2025 17:34 ๐Ÿ‘ 42 ๐Ÿ” 11 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 4
In this version, the function which calculates the max "joltage" in the line calculates each of the 12 digits separately. This makes it clear what changes in each operation: the starting index of each search is one more than the index of the previously found digit, and the end is the length of the input line minus how many digits are still to be found, which is the total, 12, counting down to 1. (It counts down to 1, not zero, because the length is one more than the index of the last digit.)

In this version, the function which calculates the max "joltage" in the line calculates each of the 12 digits separately. This makes it clear what changes in each operation: the starting index of each search is one more than the index of the previously found digit, and the end is the length of the input line minus how many digits are still to be found, which is the total, 12, counting down to 1. (It counts down to 1, not zero, because the length is one more than the index of the last digit.)

This is how I prototyped part 2 haha

03.12.2025 22:17 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Part 1: This Nushell code divides the input into lines, and find the max "joltage" in each line, summing up the totals. The max joltage is found by splitting the line into characters, and each character into and integer, and enumerating this list. The first value is the largest item in the list, but leaving out the last list item. This is done by reversing the list, dropping the first item, then reversing the list back again. The second value is the largest item among the remaining items, that is, from the index of the first value to the end of the list. The list which is to be searched is gotten by dropping all values from 0 to the index of the first value. The function that find the largest value is not a simple max function, because the list is enumerated. So, the special max function uses a reduce or fold operation, which compares adjacent items manually, and sets the largest index and its value in the accumulator.

Part 1: This Nushell code divides the input into lines, and find the max "joltage" in each line, summing up the totals. The max joltage is found by splitting the line into characters, and each character into and integer, and enumerating this list. The first value is the largest item in the list, but leaving out the last list item. This is done by reversing the list, dropping the first item, then reversing the list back again. The second value is the largest item among the remaining items, that is, from the index of the first value to the end of the list. The list which is to be searched is gotten by dropping all values from 0 to the index of the first value. The function that find the largest value is not a simple max function, because the list is enumerated. So, the special max function uses a reduce or fold operation, which compares adjacent items manually, and sets the largest index and its value in the accumulator.

Part 2: This problem is more complex than the first part, because now the "joltage" is made up out of 12 digits, not just 2. So, instead of finding each digit manually (although this is how I prototyped the algorithm) I use a reduce or fold operation on the sequence of digits counting down from 12 to 1. Each fold iteration then finds the largest digit in the line, in the range from the index in the accumulator (which is the index of the previous largest digit) to the length of the line minus the value of the sequence which counts down from 12. It then stores the index of this largest digit in the accumulator, and concatenates the digit onto the value field in the accumulator.

Part 2: This problem is more complex than the first part, because now the "joltage" is made up out of 12 digits, not just 2. So, instead of finding each digit manually (although this is how I prototyped the algorithm) I use a reduce or fold operation on the sequence of digits counting down from 12 to 1. Each fold iteration then finds the largest digit in the line, in the range from the index in the accumulator (which is the index of the previous largest digit) to the length of the line minus the value of the sequence which counts down from 12. It then stores the index of this largest digit in the accumulator, and concatenates the digit onto the value field in the accumulator.

#AdventOfCode Day 3 in #nushell

03.12.2025 22:17 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0
Part 1: This code takes the input string, splits it into rows and "from" and "to" columns, and casts the strings to integers. Then, in parallel, the sequence of integers from "from" to "to" is filtered to only keep those numbers that are even (so they can be split cleanly in half) and then for which each of the two halves are equal. The latter check uses a function to split each number in half by taking a substring from 0 to the middle (which is the length integer divided by 2) and the substring from the middle to the end.

Part 1: This code takes the input string, splits it into rows and "from" and "to" columns, and casts the strings to integers. Then, in parallel, the sequence of integers from "from" to "to" is filtered to only keep those numbers that are even (so they can be split cleanly in half) and then for which each of the two halves are equal. The latter check uses a function to split each number in half by taking a substring from 0 to the middle (which is the length integer divided by 2) and the substring from the middle to the end.

Part 2: This code parses the input similarly to Part 1, but only checks if there are repeats in each number. This check divides the number (as a string) into chunks of varying width, from width 1 to half of the length of the string. For each chunked number, a window function checks if all adjacent chunks and therefore all chunks are equal.

Part 2: This code parses the input similarly to Part 1, but only checks if there are repeats in each number. This check divides the number (as a string) into chunks of varying width, from width 1 to half of the length of the string. For each chunked number, a window function checks if all adjacent chunks and therefore all chunks are equal.

#AdventOfCode Day 2 in #nushell
Unoptimised and runs quite slowly, but I've had worse so ...

02.12.2025 22:28 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Part 1: A nushell function which reads a file, splits it into lines, then performs a fold or reduce on the lines. Starting with a sum of 50 and a zero count of 0, each line is split into an operation (L or R) and a value. The value is added or subtracted from the sum depending on the operation, and mod 100 is taken of the result, giving the new sum. Then, the number of zeroes is calculated by adding 1 to the old zeroes if the new sum is 0. The sum and zeroes are returned in the accumulator of the reduce. Lastly, the zeroes field of the accumulator is returned.

Part 1: A nushell function which reads a file, splits it into lines, then performs a fold or reduce on the lines. Starting with a sum of 50 and a zero count of 0, each line is split into an operation (L or R) and a value. The value is added or subtracted from the sum depending on the operation, and mod 100 is taken of the result, giving the new sum. Then, the number of zeroes is calculated by adding 1 to the old zeroes if the new sum is 0. The sum and zeroes are returned in the accumulator of the reduce. Lastly, the zeroes field of the accumulator is returned.

Part 2: This nushell code is similar to that in the previous screenshot, but, this time, mod 100 is not immediately done on the sum. Instead, the "raw" sum is calculated by only doing the "operation" on the accumulated sum. The additional zeroes value is then calculated by integer dividing the absolute value of the raw sum by 100, and adding an extra 1 if the raw sum is less than 0 and the starting sum was not 0.

Part 2: This nushell code is similar to that in the previous screenshot, but, this time, mod 100 is not immediately done on the sum. Instead, the "raw" sum is calculated by only doing the "operation" on the accumulated sum. The additional zeroes value is then calculated by integer dividing the absolute value of the raw sum by 100, and adding an extra 1 if the raw sum is less than 0 and the starting sum was not 0.

#AdventOfCode Day 1 in #nushell

02.12.2025 21:12 ๐Ÿ‘ 2 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
16.10.2025 07:19 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
15.10.2025 15:16 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
15.10.2025 11:23 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
15.10.2025 07:24 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
14.10.2025 15:51 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
14.10.2025 11:23 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
14.10.2025 07:22 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
09.10.2025 07:19 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
08.10.2025 15:16 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
08.10.2025 11:23 ๐Ÿ‘ 2 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
08.10.2025 07:24 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
07.10.2025 15:51 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
07.10.2025 11:23 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
07.10.2025 07:22 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
06.10.2025 15:54 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
06.10.2025 11:23 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
06.10.2025 07:31 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
05.10.2025 13:56 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
05.10.2025 11:23 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
05.10.2025 09:03 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
04.10.2025 13:02 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
04.10.2025 11:23 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
04.10.2025 09:30 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Post image
03.10.2025 15:57 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0