Oops, it can run off the end of the buffer when ignoring lines that don't start with a letter, like the very last line doesKira added a newline to the end of the buffer just incase there wasn't one. This is the real error, I thought a newline was added to the end, the loops terminate correctly if the very last character is a newline. The only time it checks if it is at the end is at the start of a word/line but Kira had put \0 as the last character rather than \n so the buffer over-ran looking for the end of line.
Change this line in readWordFile() so as to write '\n' rather than '\0'

// change this line in readWordFile() from
newWords[fileSize] = '\0'; // Make sure last word is terminated
// to
newWords[fileSize] = '\n'; // Make sure last word is terminated

<edited the above fix, simpler than what I originally thought, and is what was intended. Note to self: don't write programs when you haven't slept>

Not sure why your RPi is faster, maybe yours jumped to max speed earlier than mine? Mine's on a pretty much vanilla Buster at the moment, I'll change back to Stretch later and run it on that, I have gcc 9.1 installed on the Stretch SD card too.

I was surprised that Kira's binary tree beat C++'s hashmap, especially as there is no balancing being done on the tree. I haven't taught Kira about red-black trees and didn't feel like adding it for him as the bluetooth keyboard I have for the RPi is horrible to type on for anything other than quick edits. I wonder how balanced that tree is currently? Casper said he'll run up it later and tell me, he likes climbing trees but is no good at typing.

Last edited by Paeryn on Tue Jul 30, 2019 1:14 pm, edited 3 times in total.

I really want a browser based solution to sit alongside the prime one, so I can test on various devices.

Trust me, that notion already crossed my mind

It's not going to happen. Unlike the browser based fibo challenge the anagram challenge has the issue of getting the nearly 7 megabytes of input data into the browser and producing a gigantic output. Not impossible, just crazy! It requires creating I/O plumping that I don't want to spend time fiddling with.

...when you get bored then ...

Compared to a click-bait web site, you input and output are nothing for a web browser to deal with

I still surprised the Pi4 is so slow on the fibo-browser bench. I'd have thought 5 or so years and the large steps in architecture would have increased the speed. But the old defunct ARM/Intel tablet setups still cut the mustard.
It a shame these tablets are completely locked down that they cannot be rooted and no alternative modern OS can be put on them, so resigned to the electrical rotting heap next to my none recyclable packaging.

I was surprised that Kira's binary tree beat C++'s hashmap, especially as there is no balancing being done on the tree. I haven't taught Kira about red-black trees and didn't feel like adding it for him as the bluetooth keyboard I have for the RPi is horrible to type on for anything other than quick edits. I wonder how balanced that tree is currently? Casper said he'll run up it later and tell me, he likes climbing trees but is no good at typing.

As a Pi 4 is not available, I have created the Insane British Anagram Bar Chart of Fame using a Raspberry Pi 3B+.

Remember the goal is to avoid the digital apocalypse by writing code that works. Provided the code runs fast enough to finish before the reboot, speed is secondary.

To save work some of the timing results were taken from the forum. If you think there is an error or don't like the color assigned to your name, please let me know so I can change things. The files used to make the chart are available here. The chart and files will be updated as time goes on.

All code including managram.c is provided at the link appearing at the end of the bar-chart post. For reference the same C choice was posted earlier here. The letter m was added to the original filename to indicate the use of a merge sort for the anagram keys.

It seems the Rust provisions for concurrent memory safety may not be properly followed by the code.

You need to use rustup to get the latest version of the compiler (1.36 at the time of writing) rather than relying on Raspbian's version, 1.24 was released back in March 2018 so is over a year old. The borrow checker was improved around 1.31 to be smarter about what is valid.

Casper has come down from the top of the anagram tree and reported that Kira's basic binary tree implementation has a maximum depth of 61 nodes and on average it has to search to a depth of 34 so balancing it might be worth it. And my new modem finally turned up just before 5pm!

This shows that formatting is now correct, but all the two-letter anagrams are still missing. Without those two-letter words it's not clear the resulting anagram list is enough insane to prevent the deep-learning convolutional neural networks from taking over the world.

This shows that formatting is now correct, but all the two-letter anagrams are still missing. Without those two-letter words it's not clear the resulting anagram list is enough insane to prevent the deep-learning convolutional neural networks from taking over the world.

I wonder what happened to Haskell, Smalltalk and the Scheme interpreters. Would it be possible to complete the insane British anagram challenge using Scratch?

I've been considering writing a version in Haskell, I'll see what I can come up with.

Haskell is usually a compiled language rather than interpreted one. The Glasgow Haskell Compiler is the primary implementation and produces executable code, though it is capable of compiling to bytecode which is used in the interactive environment GHCi.

I took it into my head that all those variable length Stings and Vectors and all that pushing and inserting smelled to much like memory allocations that surely must be slowing things down. So I got rid of most of them. Rewriting the Rust more in the style of C with fixed sized arrays and structures and the like.

Only after examining the code did I notice that Fido was foaming at the mouth. I'm a little worried what will happen next, but not really because the above story--as realistic as it sounds--was actually made up.