Category: This website

So no response to the programming challenge

So no response to the programming challenge

Pen and paper
Image by Karolina Grabowska from Pixabay

A month ago I set a programming challenge but have had no response.  This could be not enough visitors (about 15-20 a day), or the nature of me posting daily on a WordPress blog where entries vanish.

That challenge was to identify the 100,000th number in a sequence of nine digits numbers that start at 1234567879 and finish at 987654321 where each digit only appears once. It’s relatively easy to program.

It’s also not that difficult to do manually if you think of factorials. As each digit appears once there 9! different numbers possible. There are 9 possibilities for the first digit then 8 for the second and so on. 362,880 in total. (I think…).

So of all the numbers in the range the first 8! (40,320) must start with 1, the 2nd 8! with 2, the 3rd 8! with 3. So the 100,000th is going to start with a 3 as it occurs somewhere between the 80,640th and the 120,960th. You can then apply the same logic to work out where the 2nd digit is going to lie and so on. I did it on a piece of paper and it took me about 20 minutes to figure.

You don’t need maths (or math as US readers will be familiar with) to program computers but on occasions it can come in handy. Especially with games and random numbers, combinations and so on.

Some awesome listings

Some awesome listings

Awesome stamp
Image by Pete Linforth from Pixabay

It has become a thing to label a big collection (usually open source) as awesome and there are several such collections around for many programming languages. In fact the C code collection’s first entry is to one of them.

That said they are pretty awesome, often having links to many related and useful open source projects. My only problem with the likes of GitHub and SourceForge etc. is the sheer quantity of excellent stuff on there. These awesome links are one way to “tame” them.

So now there’s a new link up top for C# and MonoGame links and a couple of entries to start it off.


Another extension to the scope of this blog

Another extension to the scope of this blog

MonoGame application running on AndroidWhen I started this blog at the end of February it was to assist sales of my ebooks. The one written and the one being written. Things have changed a bit and the one being written is now the Raspberry Pi book. That book is still being written but it’s not as high a priority now.

But I also have another side project underway which is to do with mobile game development (and maybe eventually Raspberry Pi).  The only thing is, this project uses C# not C or C++. However it is games related and as its my blog, I’ve decided that I shall write about it here as well as the C stuff. So get used to hearing about MonoGame, XNA and Xamarin.

Just so you know. Xamarin is the company (bought by Microsoft a few years back) that was formed by the founder of the Mono Project (Miguel de Icaza)  and is an excellent cross-platform technology for iOS and Android development based on C#.  I wrote two mobile apps (both sadly derailed by events) one of which was the equivalent of the Uber app. I managed to store every one of the 29 million UK postal addresses in the RAM of an iPhone 6.

XNA was a Microsoft technology for creating games on Xbox, Windows and Windows Phone some ten years ago. It reached version 4 but was then dropped by Microsoft. However the MonoGame project took it over and MonoGame is XNA reincarnated.  It’s cross-platform and runs at 60 fps.

The only technology that I believe can rival Xamarin is Google’s Flutter but it is still too new and doesn’t do games. The C# code runtime adds 3.5 MB to the overall executable but is very efficient and fast.

The image is an Android phone I have running an app. It doesn’t look much but that menu will display with the same height and width on any Android phone.  The problem with Android development (compared to iOS)  that there’s over 20,000 different size screens compared to a dozen or so on iOS. My program is scaled to a fixed virtual size and then tranforms that to the real size. MonoGame lets you do that.

A simple programming challenge

A simple programming challenge

Image by Arek Socha from Pixabay


Around 1981, a British computer magazine (Personal Computer World) had a programming contest and this was one of the puzzles.

There are many 9-digit integers in the range 123456789 to 987654321 where each digit only ever appears once. What is the 100,000th number in this sequence?


The first number is 123456789, the second is 123456798, the third is 123456879 and so on. No digit can repeat so 122345675 is not a valid number in this sequence.

The problem was “Write a program in C or C++ that outputs the 100,000th number as fast as possible. Use any algorithm, except you cannot pre-calculate the answer and then write a program that just prints the result (Somebody actually tried it). Your entry must calculate the number!”.  I’ll give this a month so the deadline is August 14th 2020. Please don’t copy any of the existing answers- you can with a bit of poking around and yesterday’s blog entry find some answers to this.


Er fame and glory and a mention on here!


It’s possible to solve this by hand. I did, back in 1981. It took me 20 minutes with a pen and paper. I also wrote a 6502 assembly language version of it than ran on a Vic-20. It took something like 10 hours to count up to the correct answer.

Slight change of pace

Slight change of pace

Image by Gordon Johnson from Pixabay

I’ve managed one blog entry per day for the last 134 days but a change in side project (I was writing a book to be published, not an Ebook)  but that has to be delayed by at least a year because of an issue at the publisher. In fact I may just publish what I’ve done as my 2nd Ebook.

I’m currently working on networking on a Raspberry Pi. Unfortunately it has to be in C# not C. Networking is a lot easier in C#- you have OOP, task parallel library (far easier than threads), thread pools,. concurrency with async/await and a lot more.  And I can use C# with .NET core or Mono on the Pi.

That said, I will still continue on with game development on the PI. I’ve got my Match Three game half done; I’m quite proud of it and want to get it finished. But I may switch to a slightly less frequent blog posting schedule…


Slight change in direction – more C++ and Pi

Slight change in direction – more C++ and Pi

Raspberry Pi
Image by planet_fox from Pixabay

As I said recently, writing about C and games probably isn’t enough to sustain this site, but if I extend it to include C++ and Raspberry Pi and still maintain the overall direction of writing about game development then that I think will do it.

So I’ve added a new page for C++. I’m currently working on the C++ version of Asteroids and making good progress.

I’m striving to write it in modern C++. To that end, the first entry in the C++ page is a link to a very long document: C++ Core Guidelines written by two luminaries of the C++ world Herb Sutter and Bjarne Stroustrup (creator of C++). You should definitely give it a read.

Interesting fact about the Raspberry PI. Did you know that in March 2020, they sold 640,000! That’s pretty amazing! And while that article says that AAA game playing isn’t something you can do on a Pi, we now know that you can run simple 2D arcade quality games on a Raspberry Pi 4.