Nowadays supermarket customers can check out themselves and scan products themselves. Many obviously pay by card but I was interested to see how a cash dispensing till would work.

I have written some Python code to simulate the whole setup. We start with a till that has a distibution of coins (1000 1p etc). The key function is change(), which given a price and total paid (difference rem) has to issue the right coin change. It finds the largest coin below the rem and then works from largest to smallest to issue correct change. This way we try to avoid running out of small coins. This large-to-small algorithm is very simple and probably close how humans would do it. One improvement could be to under-sample coins that we have few off in the till.

The trickiest bit (draw()) is simulating what a customer would give in change. I had to add some randomness to it to stock up small coins (10% of time customer gives exact change in 1, 2 or 5p coins). Without this part the till will run out of change very quickly.

I work a lot with global variables in this example as I don’t have to handle function IO so much.

 

We used Ocado for many years for our food shopping and got very used to their website. The Waitrose website despite some improvements is still behind. It is quite slow and the login page has some bugs.

It doesn’t even have an auto-fill basket option. This github page has some simple Python code to predict items that should be auto-filled: Github¬†Hopefully a Waitrose developer will get inspired.