I started with awk and then looked into the array based language J. It’s crazy how short the code can be.
brennesel
- 0 Posts
- 16 Comments
brennesel@discuss.tchncs.deto
Lemmy Shitpost@lemmy.world•Move over powered milk, it onion time
8·1 month agoFor anyone wondering if real piss is involved, this is from the Wiki:
There is a misconception that century eggs are prepared by soaking eggs in horse urine, but this is not true. In Thai and Lao, the common word for century egg translates to “horse urine egg”, due to this misconception or due to the eggs’ ammonia odor:
Thai: ไข่เยี่ยวม้า [kʰàj jîaw máː] (RTGS: khai yiao ma)
Lao: ໄຂ່ຍ່ຽວມ້າ [kʰāj ɲīaw mâː]
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Battery costs have declined by 99% in the last three decades, making electrified transport a realityEnglish
32·8 months agoThe energy density steadily increased over time while prices decreased: This article includes some interesting background info and the following chart.

brennesel@discuss.tchncs.detoMicroblog Memes@lemmy.world•nation of professional protestersEnglish
611·9 months agoThey don’t specifically follow the tram tracks, but in major European cities, tram tracks are simply everywhere. As the route of the protest has to be registered in advance, it’s very easy to plan for this.
With standard wheels on the barbecue, it would be far too bumpy to barbecue properly. And the risk of everything tipping over is 100 times greater.
I think it’s a brilliant solution.
I did a bit of research. As near as I can tell, there’s one (one!) paleontologist listed in the Epstein Files as “having contact with the Epstein organization,” Dr. Jack Horner.
What does “I did a bit of research” even mean? Couldn’t it be that DinoCon was told about other cases that he is not aware of?
Banning people for being in the Epstein Files is stupid.
Sounds like a typical straw man argument to me. “engaged in correspondence” is not the same as “being in the files”.
I’m in the Epstein Files
Maybe he felt that it applied to himself and therefore did not read the announcement carefully.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Gentoo Linux Begins Codeberg Migration In Moving Away From GitHub, Avoiding CopilotEnglish
2·10 months agoIf the poster wants nuance, they are free to provide it themselves.
And that is the statement where I have to say that we must agree to disagree. I would find it a shame if the Fediverse just became Reddit 2.0.
Frankly I don’t know of any software company using Github Enterprise on-prem …
Self-hosted does not automatically mean on-prem. Most companies will not have their own server racks on site, but will either rent them or, most likely, use their own managed hyperscaler cloud. Github Enterprise Cloud, on the other hand, always runs on Azure and is managed by Microsoft.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Gentoo Linux Begins Codeberg Migration In Moving Away From GitHub, Avoiding CopilotEnglish
13·10 months agoWhat vibes do you think I’m going off?
What I meant was that you read the comments, identified inconsistencies from your point of view, and then responded in a confrontational manner without including the whole context.
You do have some good points. But instead of opposing everything that has been said, you could have differentiated much better.
For example:
- Public repositories on github.com are definitely used for AI training
- Private repositories on github.com are suspected of being used for training
- Github Enterprise Cloud is probably contractually protected
- Github Enterprise Server is the most secure of all options due to contracts and self-hosting (and therefore the
only validbest option for enterprises with proprietary code)
All of the responses are saying that Github reads all code.
The first comment explicitly mentions “hosted on GitHub”, which at least excludes GitHub Enterprise Server, which is self-hosted.
The article is about an open source project that, by definition, uses public repositories.
Github public and Github enterprise are products of the same organisation.
Coming from someone who tells others that they first need to deal with “adult life”, I find this statement surprising. I work for an international company and manage several Github orgas with hundreds of repos. Whether the code is stored on github.com or on our own Github Enterprise server is highly relevant and makes a huge difference.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Gentoo Linux Begins Codeberg Migration In Moving Away From GitHub, Avoiding CopilotEnglish
371·10 months agoWhy are you referring all your answers to GitHub Enterprise and corporate contracts? Nobody here is talking about that, as the news is about an open source project. Public GitHub and GitHub Enterprise are fundamentally different.
You accuse others of responding based solely on “vibes,” but you do exactly the same thing in the opposite direction. And yet, of all people, you’re saying we don’t act like adults.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•European Commission has a "Wifi4EU" initative, provides 93k high-speed private access points across the EU, free of charge.English
1·1 year agoSorry, that wasn’t meant to sound so accusatory. I guess I (and probably a lot of other downvoters) are just very frustrated because your assumption doesn’t hold true, at least for Germany. I’m very envious of the Internet infrastructure that has been built in Latvia and Romania, for example. I would like to see the same here, but the government already considers 50 MBit DSL to be progressive.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•European Commission has a "Wifi4EU" initative, provides 93k high-speed private access points across the EU, free of charge.English
5·1 year agomost having infinite data
That’s a bold claim. Do you have some official figures to back that up? Where I live, I don’t know of anyone with truly unlimited mobile internet.
The cheaper unlimited tariffs cost around €30, but have at least one of the following restrictions:
- Speed limit after x volume used
- Poor network coverage
- <15MBit/s speed
- Significantly increased costs after 2 years of contract term
- Cancellation by provider if consumption is too high
- only a few Gb at full speed included in EU roaming
Genuine unlimited contracts with stable network coverage and 300 Mbit/s usually cost around €80-100 per month here. And unlimited EU roaming is still not included by default.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Linux Reaches 5% Desktop Market Share In USAEnglish
1·1 year agoI had the same experience with Ubuntu many years ago. And I can’t speak for Pop!_OS since I never used it. Most developers only provide commands for Ubuntu, Debian or Fedora on their websites. So they don’t work all the time in derived distros.
At least in Bazzite there is an “App Store” called Bazaar, containing many popular apps as flatpaks --> 1 click install. I generally like using the command line, but it was not necessary at all so far.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Linux Reaches 5% Desktop Market Share In USAEnglish
1·1 year agoIt’s so much easier than I had anticipated. Funnily enough, the most complicated thing was organizing a 16Gb USB stick to boot because I only had 20 year old ones with 4Gb. On a newly purchased bare AMD PC, I was able to set everything up after work and play games with my buddies the same evening.
I opted for Bazzite and everything ran right out of the box without any additional hardware drivers: gaming mouse, wifi, wireless PS4 controller, printer, NAS, Android phone. The game libraries from Steam, Epic, gog etc. can all be easily connected via Lutris and so far all the games I’ve tried have run. For programs that are only offered for other distributions, I have installed BoxBuddy, where you can create Distroboxes. For most Windows native programs Wine just works.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Linux Reaches 5% Desktop Market Share In USAEnglish
2·1 year agoI did the same this month. My hardware wasn’t supported by Win11, so I installed Bazzite. It works so smoothly that I’ve already installed it on another PC and will do so on every PC in my household. I’ve been able to run every single game so far, whether they were from Steam, Ubisoft Connect, GOG, Battle.net or the EA app. I had no idea we were at this point already.
brennesel@discuss.tchncs.deto
Technology@lemmy.world•Kickstarter adds a 'tariff manager' to let creators add surcharges to previously funded projectsEnglish
7·2 years agoThat’s already been reversed: DHL lifts suspension of high-value deliveries to US
I’m sure you’re referring to these Opalithplättchen, aren’t you?
Impressive that you could remember the name. I’m German and had to look it up since I never heard about Opalith before.


That’s true. The more concise the solution, the harder it is to understand and remember. Even if you came up with it yourself. That’s why I’ve included explanations for my solutions below.
On Day 1, a list of numbers had to be sorted by how frequently each number appeared. The three most frequent numbers should then be multiplied together.
In awk, this is quite simple:
awk '{s[$1]++}END{for(i in s)print s[i],i}' in | sort -nr | awk -vp=1 'NR<4{p*=$2}END{print p}'(in is the file containing the numerical values)
• Create an array with the number of values
• Print the number of values and the values themselves
• Sort in descending order by frequency
• Filter the first 3 values
• Multiply them together
In J, it’s much easier if you pass the values as a list:
*/3{.(~.\:#/.~) in•
#/.~displays the frequency of the numbers•
~.displays a list of the different values•
\:sorts the values in the list on the right in descending order and displays the values from the list on the left•
3{.takes the first 3 elements of the list•
*/multiplies all elements of the listPart 2 of Day 1 is trivial, since you just need to reverse the sorting order.
So use
sort -ninstead ofsort -nrfor the awk solution, and/:instead of\:for the J solution.Day 2 is already a tiny bit more interesting. The task was to calculate the distance for a defined sequence of colors.
Here’s how I solved it in awk:
echo "groovyyoyo" | fold -w1 | awk -vl=1 '{i=index("roygbv",$1);s+=(i-l+5)%6+1;l=i}END{print s}'• For line-by-line processing in awk, the string is split into lines using
fold -w1• Determine the index of the current character
• Subtract the distance from the last character (l starts at 1)
• Modulo 6 accounts for the fact that the sequence starts with r again after v; adding 5 prevents negative values
• Add 1 at the end so that the values range from 1 to 6 instead of 0 to 5
• All values are added up continuously, and the sum is printed at the end
In J, the same algorithm can be used and looks like this:
+/1+6|5+(}.-}:)0,'roygbv'i. in•
'roygbv' i.determines the index (starting at 0)•
0,adds the initial value 0 to the front•
(}.-}:)is the difference between two consecutive list elements•
5+adds 5 to each element•
6|calculates modulo 6 for each element•
1+adds 1 to each element•
+/sums all elementsPart 2 has the greatest potential for optimization so far. The goal is to get the greatest possible distance.
First, I counted how often each letter appeared and subtracted the distance only at the transitions between colors:
echo "roygbv" | fold -w1 | awk -vl=1 '{x[index("rvbgyo",$1)]++}END{for(i in x){s+=(6*x[i]-i+l);l=i}print s}'• In the array, I counted how often each letter appears
• One trick is that I get the distance directly by reversing the list of color values and using the index
• Then I take advantage of the fact that the for loop outputs the indices in ascending order, so that I can start with r for the longest distance and then work through the colors from the end
• For each color, I calculate the number count * 6 minus the distance to the previous color to determine the color transitions
• Finally, print the sum
Then I realized that, in the end, it doesn’t matter at all how many different colors there are. The only thing that matters is which one is farthest from r. So you just need to subtract that maximum distance, and otherwise you can always assume a distance of 6 for each element.
That makes it even easier:
echo "groovyyoyo" | fold -w1 | awk '{i=index("rvbgyo",$1)-1;m=i>m?i:m}END{print 6*NR-m}'•
m=i>m?i:mdetermines the maximum index (starting at 0)•
6 * NR - mcalculates 6 times the number of numbers in the list minus the maximum distance from rThe same procedure is even shorter in J:
((6*#)-[:>./'rvbgyo'&i.) in•
>./determines the maximum index•
[:in J ensures that the function on the left-hand side receives the same input, i.e. the number list•
6*#determines the number of elements in the list and multiplies it by 6• Finally, the difference between the two values is calculated
I can hardly imagine a shorter solution.
But now I’m curious how your solutions look like in OCaml.