HN user

fjfaase

1,826 karma

Software engineer with more than 30 years experience writing software in mostly C++. Interest in parsers, interpreters and combinatorics problems.

* https://www.iwriteiam.nl/ * https://github.com/FransFaase * https://fjfaase.at.hn

Posts10
Comments920
View on HN

There are some simple ways to improve bubble sort. The first is to move in two directions. The second is to first start comparing elements at a large distance than one and reduce the distance on how often element needed to be swapped.

I once used code duplication to implement a fourth type of dialog that looked somewhat similar to the others, that were sharing a lot of code, because I felt that although it looked much the same as the others, there was some fundamental difference. Took me about a day to implement. When some other engineer saw this, he spend the next three weeks trying to integrate all of them with some shared class. His work was not completely worthless, because he did find some small bug during all his efforts to avoid any possible code duplication. I already had predicted that it would take a lot effort, but I did not object, because I hoped that he would learn something from it and the next time think twice before always trying to avoid code duplication.

I think that if you as 60+ person cannot bike without support your brain is probably also not fit enough anymore for the speed you are going to ride at. So, I advice older people not to use an e-bike. I am not going to use one. Maybe a trike is a safe option at speeds not exceeding 10km/h.

Is comparing a signed integer with an unsigned integer UB? I resently wrote some code and compiled it with gcc to x86_64 (without optimization) that returned an incorrect answer.

Question: I once heard somebody talk about a micro-controller (with a minimal instruction set) where every register could be the program counter. It did not have jump or call instructions. You had 'emulate' those with the instruction (possibly conditionally) that changed the assignment of the program counter to one of the instructions. If I am not mistaken, it had eight registers. Does this ring a bell?

Really strange the the C JSON parser has to use malloc where the RUST version does not. As if it is not possible to write a JSON parser in C that does use malloc. I presume that the syntax of the commands that the device will accept is known, and than there is no reason why you have to build a DOM of the JSON before you can process it. Apparently, the RUST version can do it. I really begin to question the abilities of two teams if the one team failed to implement a JSON parser solution without using memory allocations.

I developed a similar language as an intermediate language for a C-compiler that I wrote. It uses reverse Polish notation instead of Polish notation [1], because it is easier to compile reverse Polish notation to machine code. I call the language Stack-C. See [2]. There are 32 bit and 64 bit compilers for x86 assembly and there is a memory safe interpreter for the language with a (rather limited) built-in debugger.

[1] https://en.wikipedia.org/wiki/Polish_notation

[2] https://github.com/FransFaase/MES-replacement/blob/main/Stac...

How to correct errors? I found some museum with the name that matches a city (but not exactly) to be placed in that city while it is in a city at the other side of the country. I guess some AI has been used.

Also some markers refer to areas and they are just placed at the center of that area. The marker for a country just placed in some random field.

I dislike developers who make needless refractions such as changing the names of methods or moving parts of the code to different files all because then they understand it beter in that case.

Interesting idea, but the problem is that being connected and being non-cyclic (properties you want for a perfect maze where you can reach every location and where there is exactly one route between every two locations) are global conditions that are difficult to implement with function collapse algorithm that are local.

I maze that grows in one direction can be generated with Eller's or the Sidewinder algorithms (as also mentioned by the user John Tromp in one of the other replies).

Great idea. However it is infinite in one direction. Could be made infinite in two directions (I guess) by extending along a diagonal line that get long with each step. Probably could also make it infinite in all directions with a square that gets extended with each step. However, that would mean that if one walks away from the origin, the maze has to be generated in all directions. For practical applications it would be nice to only generate the part of the maze that is 'visible' from a certain point of view (either from the top or while walking inside the maze up to a certain distance).

Please explain how to deal with slightly overlapping tiles and still create a maze that has no cycles and locations that cannot be reached from any other location. These are properties that go tiles.

I do know of an algorithm with 'nesting' that generate mazes but results in very long walls and thus does not feel random.