Sudoku Solver v1

So 4 ‘sessions’ and I hit a snag. I then spend the next week working on code which solves most (non extremely difficult) puzzles.

And then I put the code aside.

A few things I learn’t along the way..

  1. It’s great to have a goal, but instead of stepping up to the plate and going for broke, plan a little.
  2. Remember to break it down in to multiple steps and then break those down even more.
  3. By following 2, it’s easier to go back and fix small parts of the code as opposed to rewriting the entirety.

In saying that, I still didn’t fully apply these lessons learned when completing version 1. I just realised them more after I had completed it.

What I’ve got now is code which will allow you to enter a puzzle, then using a few ‘solving’ selections, will start to fill out the form.

If you have read any content from the last 4 posts, especially the ending of the last one, you will see I was questioning the naming scheme of the cells.

I decided to simplify it to [row][column].

The only reason I was thinking of using a ‘subgrid’ in the naming scheme was to generate arrays which had the cells located in a respective ‘subgrid’. In the final version of the code, I hard coded the values in to the array. I applied the thought method of WORM (Write Once, Read Many).  I had issues with where the arrays were being generated because that information was read from more than one function.

The solving method.

Stepping through the puzzle:

  1. Work out all possible values for each cell.  Mark submitted values as solved.
  2. Start at 11 (first cell) and step through each cell, using the check conditions below. Repeat from 11 until either puzzle is solved or no cells after solved in a pass.

What I’m checking in each cell

  1. If only 1 possible value, set as solved value.
  2. If any value is unique in row.
  3. If any value is unique in column.
  4. If any value is unique in subgrid.

After each step I perform a clean up of possible values but removing the value from all cells in the row, column and subgrid.

Applying that logic, most puzzles can be solved.

Solving harder puzzles is where I’m at at the moment. Another step needs to be added when the puzzle isn’t solved and after passing the puzzle, 0 values are solved.

I’ve played a number of puzzles in a Sudoku app I have on my phone and I’ve documented, the best way I can describe it is ‘Worded Logic’ for what I need to check. So far I have this:

  1. Applying to each Row and Column – If 1-3 possible values are ONLY in one row/column of a subgrid, remove values from respective row/column in other subgrids.
  2. Where multiple cells in a row/column/subgrid have same possible numbers, and the count of those possible numbers = the number cells they appear in, remove possible numbers from other cells in that row/column/subgrid

There are additional checks which I need to work out how to word up, but I’ve been able to solve all but one (manually), using the steps above.


Currently, as I mentioned above, the solver is just generating a grid to display values/current state of the puzzle, and a basic output ‘Solving [cell] – [how it was solved]’.

Going forward, I’m going to have a ‘solve this’ button, and then an ‘analyse’ which will only solve one number at a time, which a check box to do one full pass.

After starting my solver, I did find one online which does the same thing, but to me, it’s more about working through to the solution.. even if there is already one available..

Sudoku Solver – 4th Session

This is just a stream of thought blog post as I’m coding a Sudoku solving program.  I’m a beginner coder, so the code won’t be the best, but I’m learning as I go.

Click here to see the first post
Click here to see the second post
Click here to see the third post

I’ll post code snippets and then the full code at the bottom of this post.

To me, the logic in solving an “EASY” Sudoku is easy.

  1. Look at all possible values of a cell
  2. If there is only one possible value, that’s the answer
  3. Rinse and repeat until the whole puzzle is solved

Harder puzzles require more working out to eliminate possible values

  1. Look at all possible values of a cell
  2. If there is only one possible value, that’s the answer
  3. Rinse and repeat until no more cells can be solved
  4. Use more advanced methods to remove possible values from cell
  5. Repeat until whole puzzle is solved

In the array I’m going to build from the initial submit, only ‘solved’ values will be present.

As that cell has only one value, the length of that string will be 1. That’s how I’m going to determine a solved cell.

Initially an cell has a length of 0, it’s unsolved, I need to loop though each number, 1-9 to check if it appears in either that row, column or sub-grid. If the doesn’t exist in that check, add it as a possible value. If there is only 1 possible value, the cell is solved, otherwise, I’ll have a string for that cell where the length is >1, meaning unsolved.

Just thinking forward here, I can place an additional check if a cell is solved to remove that value from other cells in the column/row/sub-grid. That will reduce the number of loops going forward.

I can also reduce loops by building a second array of ‘solved cells’ so when stepping through checking cells, solve cells are skipped.

Now, coming back to the cell naming convention I set up.



The next bit might sound strange, increasing row to check column and increasing column to check row, it it works.

  • Check a column – Set row number to 1 (aka second digit in four digit length), then add 100 to the CelliD
  • Check a row – Set column number to 1 (aka first digit in four digit length), then add 1000 to the CelliD
  • Check a sub-grid box —–

***** at this point I just realised I might be better to change the order the CelliD to being [Cell],[Row],[Column],[Subgrid] or even just identifying each cell as just a [Row],[Column] and have a separate array to hold the cell reference that appears in each Subgrid.

OK, no code this time.. rewrite required..

Sudoku Solver – 1st Session

This is just a stream of thought blog post as I’m coding a Sudoku solving program.  I’m a beginner coder, so the code won’t be the best, but I’m learning as I go.


It’s been a while since I’ve worked in PHP and to be truthful, in the past it’s been a lot of copy and paste.

Sudoku has always been a timewaster of mine and I’ve been thinking more and more about writing a solver.

I could write it in python or C++, one language I have no idea about (Python) and the other I’m just starting out.. very slowly.

So.. let me start my thought process.. hopefully it will end with a product that can solve a Sudoku puzzle.

Read moreSudoku Solver – 1st Session

Over a year since I posted..

A lot has happened, then again, a lot hasn’t happened.

I actually had 2 posts planned when I last posted. they were mostly drafted up.  One was on Pokemon Go (which I started off way too hard and then lost interest in) and a VR vs AR post.

Pokemon Go

I had a love/hate relationship with this game. As soon as it was announced (ie, within an hour), it was installed and I was playing it.  That night we drove around the town and played more until the servers started playing up due to load.

All the ‘Pokestops’ were at the same locations as a lot of the early Ingress portals, so I knew them well.

The next day, I was walking the street playing, then I stopped for a while and just walked. Every second person was looking down at their screen with the application open.

Walking at lunch around the Opera House, it was more like 9 out of every 10 people were playing it.

Then there were the news articles:

Around this time, my parents were in Perth.  They visited Kings Park and were annoyed that all these people were out playing a game, ignoring their surroundings, and subsequently blocking my parents view.

Then a week or so later, there were reports of a park where there were a number of Pokestops clustered. All through the night people were gathered around a kids playground, basically blocking access to kids using the facilities and then leaving it like a pigsty.

I had tweeted at a writer who was a advocate for the game about it, hoping it would prompt her to write about the negative side as well to increase peoples awareness, but the response was less than I expected: “this is a downside of any crowd gathering anywhere for any reason. People just need to be better”.  I agree, but ‘with great power comes great responsibility’, I had hoped that a ‘look after your environment’ post might have been appropriate.

In saying that, the next week, I was playing for my son and my wife was playing. We actually did go for a walk around Bicentennial Park.  Walking amongst the mangroves was pleasant, but also made me aware of, even there, how people are spoiling the environments by littering.

I personally only lasted about a week playing it.  I hit games pretty hard and sometimes have problems knowing when to stop (thank you Rocket League).

VR vs AR

When I was writing the latter post, I was in a situation where I had not tried VR before, not had I tried AR. I actually booked myself in to the Microsoft Store in Sydney to try out VR the day after I started the post.  I was one of the first people to try out the Trials on Tatooine experience which was released a day or two earlier.  The highlight of that experience was (spoiler alert) when R2D2 rolled out of the Millennium Falcon.  I remember getting down low on the ground to get a closer look at him.  People outside could have seen what I was looking at thanks to a tv on the wall.. and would have been able to see the massive smile on my face.

Using VR, the only issue I had was whether or not to wear my glasses under them. Being a year ago, I can’t remember, but I think I did.

I’m yet to experience AR in the ‘Hololense’ sense. The closest I got was inquiring about a weekend preview of the device, however was told (by the same store I tested the VR out in) that it was more aimed at business people who want to use the device. So I’m yet to try them out.

Mixed Reality was announced more recently, and last week I did get the opportunity to try it out.  The Microsoft Store no longer preview the Vive.  I chose to try the Dell over the Acer, purely as there was a nose piece in it which I didn’t think would sit well with my glasses. As I had power-walked there, the lenses started to fog up.  That did clear up overtime and aside from a couple of teething issues (got a BSoD and then the glasses didn’t recognise the area.. a simple ‘step to the right’ fixed that), the experience was pretty cool.  The images were crisp and the experiences I tried were impressive.  I’m looking forward to the next couple of weeks to hear how the SteamVR support plays out.

Other Stuff

Well, I took WAY too long animating a video for a song I released under my ‘Project’.. I thought it turned out pretty good.  The initial idea started just after my last blog post and I finished it up about a year later, with a majority of the work happening over the last month.

The family has acquired a number of tools over the last year as well, which will lead to some wood projects. I have LOTS of ideas and little time.  But more on those later.

Next project, I’m going to write a Sudoku solver.

Indiana Jones – Rebooting the reboot?

There was a post on Reddit last year which was around the time that Indiana Jones 5 was being announced.  At the time, it was confirmed by Frank Marshall that Indy would be played by Harrison Ford again.  And he mentioned that he wouldn’t be doing the “Bond” thing where the character would be played by different actors, even though to date, Indian Jones has actually be played by 10 actors and 7 ‘faces’. Source: – search for Behind the Scenes.

A couple of days ago, it appears that the story has changed, sort of. Disney’s CEO, Bob Iger, is now saying that after Indy 5, the series is going to be rebooted. I find the way he described the progression of movies amusing: “Right now, we’re focused on a reboot, or a continuum and then a reboot of some sort,”… “Well, we’ll bring [Harrison Ford] back, then we have to figure out what comes next. That’s what I mean. It’s not really a reboot, it’s a boot — a reboot. I don’t know.”

Rebooting the reboot 😀

My response to the Reddit post put forth an idea which would allow the series to go on with Indy not just being replaced (as such), with my idea of how you could introduce a ‘new’ character who could play Indy in a ‘continuum’ type set up, and to reboot the franchise.

Indiana Jones is sitting in a nursing home where he’s reluctantly spending the rest of his days. Marion has passed away and his son, Mutt, rarely visits.

A passionate archaeology student visits him there and after introducing himself, sits down with him to have a chat.

The visitor brings up events of Indy’s past, some which are known and some which Indy had tried to keep secret.

At the end of the conversation the visitor tells Indy how much of an impression which he has left on his life and he wants his legacy to live on. He asks if he can take on his name so that the name Indiana Jones can live on in the field of archaeology.

Indy sits there for a moment before he stands up and walks to the door.  He closes it slowly.  On the back of it hangs his fedora, whip and jacket. He picks up his hat and puts it on his head, taking a final look in the mirror before turning around, taking his hat off and putting it on the students head “So what’s your first adventure Indiana?”

Queue the Indiana Jones theme song.

Or at least something like that.

At least that way, ANYONE could play him.   Yes, it’s someone assuming his name, but it allows for the legend to live, not on a ‘Bond’ way, but in a “Prince Bride” type way with the “Dread Pirate Roberts”.

Think that might work?

R and P – Makes me happy!

R & P are two letters which have been around me for ages and it was only a couple of days ago I realised how important they are to me. I don’t know why it took me so long to realise, but when I did, I felt tall (strange saying this at 6’3″, but it’s true) and elated!


  • Firstly, they are my son’s initials.
  • Secondly, I’ve been obsessed about a game which I played about 20 years ago called “Red Planet”. It was part of the Virtual Worlds section at the Intencity video game arcades when they were ‘big’ in Australia.  Unfortunately I believe all installations were destroyed. I’ve had many thoughts and ideas in trying to make a computer/console sequel to it.. (I can dream!)
  • Thirdly, I’ve been on a website/forum for almost 12 years… its initials: RP : The Recording Project

Now what kicked this realisation off was that 2 days ago, I took over the hosting of Recording Project.  It has been in the works for a few weeks, but at that point 2 days ago, as the site was migrated to my account, it finally felt ‘real’.  It’s also the reason I haven’t posted a blog in the last couple of days.

I had been stressed the week prior with all the hoops in transferring the domain and account and sorting everything out (along with issues in getting my phone fixed), but the afternoon after it had been migrated, and a new phone was in my hands I felt happy… really happy.

So a little ‘pitch’ as to what the site is.  Recording Project is a website/forum for musicians and music makers, hobbyists and professionals to communicate, share information, share music and have it reviewed.  The idea for the site started in 2003, and the site went public in late 2004.

In 2008, the original creators decided to move on, and one of the members took it over and hosted it.  In the following year, there was a problem with the site on the host to do with the number of files in one directory, so I ended up updating a mod (it runs phpBB) to resolve an issue.  In acknowledgement, I was made a Moderator and then not long after, an Admin of the board.

In 2008 I had put my hand up to take over the board, but missed the opportunity.

Earlier this month the user who was hosting it questioned “Does anybody care if I shut this place down?”.  I instantly messaged him and asking some details about the site.  Turned out the domain was due to expire at the end of the month. He had hosting and then offered for me to pay for just the domain or to pay for the domain and hosting. My personal hosting was up next month and I’ve been looking to change hosts for the last few years. I just bit the bullet.

What prompted me this time, well, for starts, the board members.  I’ve got some life long friends, who I have never met in person, who I met on that board. I also feel like I can do something with it.

Also, since the site changed hands back in 2008, it’s been static. Along with that, the active user base has dropped significantly. The software hasn’t been updated (mostly due to mods) and some more ‘modern’ type features are missing from the board.  I’m sure I can upgrade everything to work which will make the user experience better.  It’s just going to take a while to clean everything up as mods have been added/removed, files renamed/numbered and when comparing files, looks like the editors added tabs for formatting which makes the software I use to compare files pick up a lot more differences.

But the board in general.  I’ve also got some ideas to give the board more life.  I believe in this site.  It’s been good to me and I’m going to be good back to it and make it better!  It’s not going to happen over night, ti’s going to take a lot of baby steps to get there.

So yeah, I’m now the proud owner of a website with the initials RP, which I’ve visited for years!

Time again to brush up my PHP!

Blog posts, my creativity, my fears and resolve?

As you might have noticed, I’ve been publishing a blog post, every day, for the last few days. I’ve set myself a ‘mini goal’, with the hopes that doing this might help my creativity.  Not only in blog posts, but my general creativity.

There is a method to my madness. Or I’m at least mad (we already know that 😉 ) and this is a different method than what I’ve tried in the past.

For too long I’ve had a large number of thoughts in my head which I’ve wanted to share, but I’ve been afraid to share them. Afraid that people might not like my views, which I’m coming to accept will be the case, and that’s OK. Afraid that by sharing an idea, someone else might take it, run with it.. and actually succeed with it. I’d see that as my loss.  Whilst that is a downside, at least someone would make something of it, and I wouldn’t have to think about it anymore.

I worry myself that if I present my thoughts and creativity endeavours, what if after I’ve said a few things, I can’t find anything else to say?

At this point of the post, you can probably tell I’m rambling. But I am getting to a point.

The other though is that if the ideas that have been gestating in my head are out, I can think about other things and generate new ideas. I feel like my brain is a full box and with all the current thoughts, I can’t escape.

Now, I know creativity works differently for everyone and I can only hope my latter theory proves true for myself.

For instance, I’ve been working on a songwriting project for a few years now. Writing, setting up ‘virtual’ infrastructure, gestating. Looking back at some of my original notes, that idea was born in 2012.

I haven’t done anything or shown anyone outside of my family it yet. Actually, I lie, I did do one performance of a new song, once, to a smallish crowd.  That’s it. But I have big plans and dreams.  In only the last few days, in doing these posts, have I felt like I can actually make this happen.

And here is the crazy thing.  I’m scared.  Not about actually presenting and performing what I’m working on. I’m actually scared that I might succeed.  I know some people have stage fright. In the times I’ve performed, I haven’t.  I guess I think too much about possible outcomes, which is something in itself. I over analyse.

I’m wondering if I’m alone in this feeling? People being scared, not about performing or getting up in front of people, but actually succeeding in what they want to achieve.

I need to apply myself to the “The Cult of Done Manifesto“, at least with songs, because songs are never finished, but they get to a point where they can be made public.

So what is my point that I promised mid-ramble?

I need to trust myself more. I need to believe in myself more. I need to share more of my ideas and thoughts.

In closing myself off with my thoughts and actions, I’ve closed myself off to opportunities I should have taken ages ago.


My thoughts on professional gaming – e-sports #ESL

I personally haven’t seen too many e-sport events, partly because I’m not in to a number of the bigger games which are played at that level, but in the most reason, and this might sound strange, I feel too old.  Sure, I’m close to 40, but if you look at a majority of the players, they are all in their late teens/early 20’s.

I was watching a documentary on Netflix “All Work All Play” and it indicated that most gamers retire between the ages of 20-25.  Sadly, I knew the age was close to this, but still.. I have to say it: WTF?

I had 2 thoughts at that point: 1 – how can I reverse my age back to 20 again; 2 – why don’t they introduce aged competitions like they do with kids sports, like Under 12’s, or Under 15’s, but in this case, Open (all ages), Under 25’s, Under 35’s, (and I shudder with this one) Veterans >35.

Asides from making each competition possibly bigger, would including those ages in the competitions increase viewership?  The game play would be different, potentially more tactical vs speed.  My interpretation is that ‘younger’ gamers (most times) are able to beat older ones mostly due to response times, so if older gamers played each other with their ‘slower response times’.

Call it a handicap that would open the competition to more ages and in doing so, make it a fairer playing ground, allowing multiple generations to be exposed more to e-sports.

Granted, this idea is coming from a ‘grumpy older gamer’..