Monty Hall Solution – Advanced!

Monty Hall Problem, Monty Hall Solution

Door 2 now has a 2/3 chance

This post “Monty Hall Solution” continues on from my previous post Monty Hall Problem – Can You Solve This Maths Puzzle? If you haven’t read that post, then read it now before reading this. Because I will now show you even more Monty Hall Solution coolness! We saw that you could increase (double) your chances of winning a car by understanding some maths, so let’s delve further into it and who knows, you might win something big (then again you might not, but hey!).

So what happens, if there are 4 doors instead of 3 doors? And what happens if there are 5 doors, 6 doors, hmmm, more code required – cool!

Checkout the code here Alan Cowap GitHub.

Does The Monty Hall Solution Hold True For 4 or More Doors?

For 4 doors we would expect that the odds would be 1/4 (25%) for not changing Vs 1.5/4 (37.5%) for changing; (with the remaining 1.5/4 (37.5%) chance of losing either way). “How did you get those figures?” I hear you ask. Well, with 4 doors, each door has a 25% chance of being correct. Our 1st chosen door has a 25% chance – the other 3 doors have a combined 75% chance. When Monty removes one of those 3 doors by opening it -the remaining 2 doors still have a combined 75% chance – which is now divided by the 2 remaining doors i.e. 37.50% chance each. Once again the figures from the 70 million simulations are very precise.

Doors in Game: 4

Unchanged Wins: 2498993, Changed Wins: 3750566
Unchanged Wins: 24.99%, Changed Wins: 37.51%

Unchanged Wins: 2498720, Changed Wins: 3750419
Unchanged Wins: 24.99%, Changed Wins: 37.50%

Unchanged Wins: 2500812, Changed Wins: 3748980
Unchanged Wins: 25.01%, Changed Wins: 37.49%

Unchanged Wins: 2499171, Changed Wins: 3747829
Unchanged Wins: 24.99%, Changed Wins: 37.48%

Unchanged Wins: 2499602, Changed Wins: 3749207
Unchanged Wins: 25.00%, Changed Wins: 37.49%

Unchanged Wins: 2497548, Changed Wins: 3748332
Unchanged Wins: 24.98%, Changed Wins: 37.48%

Unchanged Wins: 2499206, Changed Wins: 3749860
Unchanged Wins: 24.99%, Changed Wins: 37.50%

Monty Hall Solution with 5 Doors?

Continue reading

Monty Hall Problem – Can You Solve This Maths Puzzle?

Monty Hall Problem

The Monty Hall Problem

The Monty Hall Problem is an interesting Maths Puzzle – with a hotly disputed answer. Monty Hall is a well known American TV Show presenter, and this particular maths puzzle gained some notoriety on his TV Show – hence the name “Monty Hall Problem”. The puzzle is quite simple to understand, but as is so often the case it is a little more tricky (and fun) to figure out the answer.

World famous mathematicians have gone to their grave disputing the answer. But I’ll explain it in easy to understand language, and demonstrate a proof using a computer simulation I wrote which played no less than 70 million games. The source code for the simulation is available here Alan Cowap GitHub so you can review it yourself 🙂

Show Me The Monty Hall Problem Puzzle!

Monty shows you 3 doors which are closed. You are told that behind one of the doors is a car, behind the other 2 doors lies a Goat. If you choose the correct door you win the car. The doors are labelled 1, 2, and 3. Let’s say you choose Door 1. In an unexpected twist Monty opens say Door 3 – behind which stands a goat! Monty then asks you “Do you want to stick with Door 1, or do you want to choose Door 2 instead?”.

So do you stick or twist? You can stick with Door 1 or try your luck with Door 2. Monty is waiting. Your heart is racing. The crowd are shouting in equal measure “Door 1” and “Door 2”, some jokers are even shouting “Door 3” ]:> 😀

Show Me The Monty Hall Problem Answer.

Not so fast. The fun is figuring out the correct answer – if there is a correct answer. What I’m going to do is put forward an answer and explanation, then I’ll write a software program to simulate this scenario 70,000,000 (70 million) times and see if it agrees with my proposed answer. Is it better to stick or to twist – or does it make any difference? I’ll share the results (and the code) of this simulation with you. In the meantime, you can try to solve the puzzle by yourself. But before that, I’ll propose an answer – spoiler alert – don’t read the next paragraph if you don’t want to see the proposed answer.

The Monty Hall Problem Answer (SPOILER ALERT)

Ok then, you’ve racked your brains and thought through all sorts of statistical slight-of-hand and complex combinations and permutations and convinced yourself you have the correct answer. Stick or twist? Well , it turns out you should have …  Continue reading

Maths Puzzles are FUN !!

How hard can it be!

Can you solve the Snake Puzzle?

Maths Puzzles may not be everyones cup of tea, but I love puzzles and I love maths (and cups of tea). You can already see where this is going, right. Anyway I came across this simple enough puzzle and inevitably I started thinking about how to solve it. I say it’s simple because it only involves the numbers 1 to 9 with addition, subtraction, multiplication, and division. So, how hard can it be? Well…

Rules of the Puzzle

  1. You must use the numbers 1 to 9 inclusive
  2. Each number can only be used once
  3. Note that : symbolises division

This type of puzzle is one of my less favoured types of puzzle because it’s solved mostly through trial and error, with just a sprinkling of inspiration. I prefer puzzles that are solved through some (optionally mind-bending) inspirational insight. Eureka moments, I like them, they’re a natural high. But what can make this simple type of puzzle more interesting is to take it to another level. How? First, you can calculate how many permutations there are, i.e. how many different ways can 9 numbers be uniquely ordered. The answer is there are 362,880 permutations for 9 numbers (where there is no repetition, and order is important). Suddenly this simple puzzle doesn’t seem so simple. Another interesting twist is to calculate how many possible solutions there are, you didn’t assume there was just one possible answer did you? Oh dear, never assume! Hint: There is more than one solution, a lot more. I found 128 solutions.

You’re probably wondering how I found that many solutions and how long it took me to find them. It took less than 200 milliseconds to find all 128 solutions. That’s the power of writing software to do the donkey work for you 🙂 Writing the code took an hour or so and that was a much more enjoyable puzzle to solve, than manually solving the puzzle.

Get the Sourcecode

You can view and use the sourcecode which I have provided on GitHub under the GPLv2. Comments welcome, especially if you can see and errors or improvements. Enjoy!

View the Solutions

Below are a list of all 128 valid solutions. First number goes in the top-leftmost square and insert the numbers in order. Easy peasy.

I have also created a Google Sheet with the answers and formula on so you can check your answers. You can view and download the Answer sheet too.

Continue reading

Antipodes App now on Google Play

antipodesAntipodes App now on Google Play and it’s free  🙂

Ever wondered where or what is on the opposite side of Earth from where you are? Ok, maybe it’s just me, but since I’ve written the Anitpodes app, now you can find out for yourself.

“Antipodes” literally means “opposite feet”, and refers to the point on Earth exactly opposite your location.

Simply start the app, long press the Marker on the Map and drag it to your point of interest and WOOHOO it will draw a line to the other side of the Earth for you.
See if you can avoid the water, there is _lots_ of water on Earths surface 😀

If you tap a Marker it’ll popup and show you the GPS coordinates of that location.
As with all Google Maps, you can tap the ‘GPS icon’ in the top right corner and it’ll go to your current location (if available).
Long press any location on map to make it the Podes, the map will update accordingly with a new Antipodes.
If you drag the Podes or Antipodes, it’s GPS coordinates will be updated and displayed in real-time.

If you have any suggestions or improvements, comment below, and download Antipodes now.

Enjoy and have fun antipoding (I may have made that word up 😉 )
Alan 🙂

P.S. Thanks to for the free to use graphics which I modified.

Android Apps Published by my Amazing Students

Here come the Apps

Android Apps Published ! With 11 Apps developed for our Client Companies I think the class of 2014 can be super proud of their achievements. 6 of the Apps are publicly available on Google Play (links below), the others are either B2B or internal use. Without further ado, here they are:


GeoPal have their own successful app and were delighted with a library contribution which led to further work for the student who authored the library. Happy days!


Live at the Marquee App developed in collaboration with Clickworks on behalf of Aiken Promotions for the annual Live At The Marquee music festival.


Bedwetting App developed in collaboration with leading global pharmaceutical giant Ferring.


Sli Nua Careers are delighted with their App and are planning to add to it.


Clearview Coaching dipped their toe in the App arena, and their support paid off with this simple and effective app.


Hartley People got more than they bargained for with this feature rich App.


Other clients included Amnesty Interational (Ireland), Slattery Communications,  tech super-startup Kitman Labs, Beaumex, and Wattless.


And to think these Apps were all written in a 12 week development cycle from start to finish is all the more impressive. It was an absolute pleasure to work with 24 students who, with a heap of hard work and a dollop of tenacity, went from zero to hero. Well done guys 🙂

Hello Linux Ubuntu, Goodbye Windows XP Alternative


Ubuntu – XP Alternative

Like about 20% of people who use a desktop computer I have one, ok two, that still run Windows XP. Well, not anymore. The end of support for XP last Tuesday 8-April-2014 was just the “stressor” (nod to Criminal Minds) I was looking for. So what is a suitable XP alternative ? Like plenty of people I’ve dabbled in various flavours of Linux over the years; Red Hat, SUSE, Fedora to mention a few of the better known ones. But they’d mostly been a hackers curiosity for me. For real(TM) work I’m not ashamed to say I wanted the reliability, simplicity, and compatibility of a Dell machine with Microsoft and Intel internals (yeah really).

But Linux has come a long way since then, no more messing around with tarballs, gcc, and editing scripts; mostly done through command line interfaces. And that’d be fine, I’d hacked OS code in college, but for me as a software developer the OS is just another tool. I just want it to work and be invisible. So I’m going with Ubuntu.

As a quick pointer on the steps awaiting you as you consider your XP alternative:

Ubuntu is currently the most popular flavour of Linux, it’s free, it’s open source, it’s available on the Ubuntu website.

You can try Ubuntu without removing XP at all. In fact you can run Ubuntu from a memory stick plugged into a USB slot. You may have to tweak your BIOS settings to get this to work (because typically the computer will try to boot from hard drives, floppy drives, and dvd drives before it looks for a USB key). Info on how to create a bootable Ubuntu USB key from within Windows are available on the Ubuntu Website.

Be sure to make a backup of all your user files on your computer. Things like documents, photo’s, videos, music etc. These are the things you don’t want to lose!

As an aside, check this out if you’re concerned about Heartbleed on your Android device.

Happy hacking, Alan!



More Android Apps by More of my Students

Here come the Android Apps

Here come the Apps

Following on from the success of the Android Apps from the first course I gave on App Development I had another fine batch of graduates who published their Apps.

All the Apps are free to download and are ad-free. These guys are too kind to you, so be kind to them 🙂

Here’s a list of the Apps and links…


Simple Stretching Exercises – No wonder it’s already >5k downloads and rating well, it does exactly what it says. Simple stretches with graphics and a description. Go on, you know you want to.

Irish Post – Track your package, or calculate the cost of delivery with this powerful App. Another great app that does the job well.

QB Stats Calculator – American Football Quarterbacks and their coaches can get a birds eye view of how the Quarterback is doing with this App which makes it easy to keep track of vital stats and calculate the “Passer Rating”.

App Paw Tizer – Got a pet dog and want to know if a particular food is safe – this App is for you (and your dog).

Leaving Cert Economics – Studying for the Irish Leaving Cert? This Economics App will help with your studying! The National Debt is testament to the fact we need some decent economists – so please get studying 🙂

Tides Ireland – Got that sinking feeling that the tide is going out on your life? No worries, this App will tell you when the two daily high and low tides are due in your Area (Ireland only), it’ll also tell you the tide heights!

 RNG – Random Number Game – Finish off with a bit of craic while you play against your friends. Who has the highest number wins, loser has to .. well you decide!

7 weeks dev time is all these guys had, and for all of them it was their first time working through a software development life-cycle. They all became Oracle Certified Java Developers too. Onwards and upwards. Respect to those who do the do.

I’m currently working with 24 more students on 11 Apps for client companies, but more on that next month! Suffice to say, it’s super exciting…



Android Apps by my Students

GooglePlayI recently gave a course in Android App development and all the participants published their own Android Apps on Google Play. Below is a list of the Apps. Bear in mind some of these guys had never coded before. They had 13 weeks to prepare for the very robust and forensic Oracle Certified Professional – Java Programmer Certification. This was followed by 7 weeks of Android development. They conceived, designed, and wrote all the code themselves. Impressive. And the list…

Irish Grid Reference – A simple app to convert GPS latitude and Longitude from the phone to the Irish Grid reference system for use with a map

Simple Fun – A simple game where the goal is to remove circles from the screen, if you miss a circle more get created elsewhere.

Vehicle Maintenance Schedule – Application to track your vehicle’s mileage and inform you of services required by the vehicle as they arise.

Dead Man Switch – Just what you’d expect from a Dead Man switch.

Kodaline – This is the OFFICAL Kodaline app for the musical band Kodaline.

GAA Team Sheet – This app allows managers to choose a team for their upcoming matches and sends it via SMS.

Word Quiz Tastic – With Word Quiz Tastic you will learn new vocabulary to help you write more descriptive essays and poems

Practical Shopping List – This simple practical app allows users to create and delete shopping lists, and use them while planning their grocery shopping.

Txt 2 English –  This app translates written English into text speak(txt spk)and vice versa,also allows it to be sent as an SMS.

It’s an impressive list and shows what can be achieved in a relatively short space of time with a little guidance and a decent dob of coding effort. I should note that a couple more Apps aren’t included in this list because of Non-Disclosure-Agreements with client companies.

Internet Safety For Kids using a Tablet or Smartphone!

Better Safe Than Sorry

Good Times. Keep it that way.
(Image by davynin@flickr)

Internet Safety For Kids should be on every parents mind. The Internet is an example of everything that is great and terrible about humans. On the one hand – a brilliant resource, on the other hand – a terrible danger. Your childs tablet or smartphone is a portal to the Internet, such portals require gatekeepers. But who is the gatekeeper – you, your child, anyone? How can you help protect your child from the dangerous elements of the Internet?

The first thing is to recognise the dangers and inform yourself how to mitigate them. Good job, you’re doing that right now. There are a number of things YOU CAN DO to reduce the risks to your child, and I’ll describe them here. Note, this isn’t a How-To guide, with 1000’s of devices out there that’s an impossible task. But you will find out what YOU CAN DO:

1) Disable Internet Access

This is the most extreme case. The smart device will effectively become a dumb terminal. It’s designed to be a connected device, but with no internet access there’ll be no email, twiiter, facebook, etc. You can disable internet access on the device itself, whether via wifi or mobile network. See your device manual for details. With no internet connection, you won’t get updates to your Apps or your operating system. You can enable internet access and update the operating system and Apps, then disable internet access again.

2) Control Internet Access via your home router

If you’re a bit more tech savvy you can control internet access of the smart device using the settings on your home router. Many modern routers (and older ones) have the ability to control access to the internet using the MAC address (a unique number for every network device). You can setup the days and times that the device can access the internet – no surfing by gaslight! However, this can control internet access at your home, but not your childs friends house, or any WiFi network anywhere else in the world.

3) Safe Surfing with K9 Web Protection Browser

So you’ve given them internet access, how do you ensure they’re only looking at suitable websites? K9 web protection can help. Blue Coat Systems K9 Web Protection Browser (available on Google Play) allows you to configure which sites can be accessed – based on many categories of material (see K9 Web Protection Browser for more info).

4) Malware, Missing Device or worse Missing Child

Another must-install app is Lookout Security & Antivirus. The Free Version provides Security & Antivirus, Find My Phone, and Backup & Restore capability. I don’t use the Backup & Restore feature because I use the one provided by Google Contacts. The Premium version also includes a Safe Browsing feature. So if your device is missing, you can find it using the Find My Phone feature, if your child is missing then just hope they’re somewhere near the device :-/

WARNING: There are apps out there that purport to be family monitors, call monitors etc. but they may be of questionable authenticity. Only install apps that you trust, have a quick read of this blog post: “Your Android Phone – Getting More Out Of It

5) Registering with Google

To get the most out of your Android device you’ll want to register with Google, this will require a gmail account. Choose a username wisely, perhaps not something that identifies your child like their actual name. Remember it’s an email address, that opens up inward and outward communication. You can setup your childs gmail to forward all incoming email to another email address (one that you monitor). Depending on your childs age this is either prudent parenting or Big Brother. It’s your call. Google+ now requests that users use their real name and not a pseudonym, however this is being challenged in courts over privacy issues.

Be mindful if you are signing up for Google+, there is an option “Instant Upload” that will automatically upload all photos to the Google+ account. By default they should be uploaded to a private album in your Google+ account. But they’re stored on “the cloud” i.e. a computer server somewhere on the internet that you don’t control. You can disable “Instant Upload”.

Big Brother is Watching 0_0

You may be surprised at how much information you provide to websites by just loading their page. Do you know your IP address, your ISP, your OS and web browser? Look at the image —> When you accept the permissions Apps can access much much more.

6) Common Sense

You know your kids are resourceful, right? And they have resourceful friends, they can find ways to circumvent the precautions you’ve taken. The kids need to be informed about the dangers, if they’re able to recognise the dangers and deal with them your job is already done. There’s many things you can stop your kids doing, but learning isn’t one of them. One way or another, they will learn, hopefully they learn the right stuff.

If you have any further precautions or know of useful apps please provide info in the comments below.



Your Android Phone – Getting More Out Of It

Whether you just got a new Android phone, or think you should be getting more out of your existing phone, I’ll tell you how to get it working for you. A smartphone should make your life easier, more enriched, and dare I say it more enjoyable. You shouldn’t have to work your smartphone, it should work for you. In this article I outline some of the most essential tips on how you can maximise the power and safety of your new Android smartphone.

Disclaimer: I have no association with Google or any other company or app in this article. All views expressed are my own. fwiw I have an app available free on the Android App market: Irish Safety Camera Locations 🙂

Hello Android

Hello Android


Tip 1: Use Google Play Market

There are several Android app markets you can download apps from. As a newcomer to the Android ecosystem it is my advice that you stick with Googles own app market. Unlike Apple who must vet all new apps before making them available, Android apps are uploaded and available immediately for download. This is of course open to abuse. However Android Apps are now regularly scanned once they are on the market:


Tip 2: Check the Permissions for each App

To give users control over what an app can and can’t do on their phone, the user must grant permission to every app they install. So when you install an app you will be asked to confirm you accept the permissions the app is requesting e.g. Your Location, Network Communication, Your Personal Information, Storage, System Tools, etc. Use your own judgement. If an app that says it is e.g. a stopwatch, but upon installation requests permission to access your Personal Information and Network Communication – then alarm bells should ring!


Tip 3: Read the Reviews of the App BEFORE Installing

In my experience reading reviews on the Android market, comments can be quite tough, and sometimes are simply unreasonable. The upside of this is that, as a user, you know if an app has 4 stars ore more then it’s likely to be pretty good. You should also check how many people have given it a rating, and check how many downloads it has – in both cases the more the better.


Tip 4: Protect your Smartphone

Get insurance if you want, definitely get some kind of screen protector, and definitely install a security app (I recommend one below – it should be the first app you install). No harm to have a password or swipe sequence on your phone too, it will be a target for the thieving scum.


Tip 5: Read my Guide to Essential Android Apps

Some apps I use all the time, almost essential apps! Coming shortly…