Skip to main content


Friday Quiz maths question, 24 Jun 2022, a day late.

  There is just one pair of numbers (x,y)   where  when you add them together, mult iply them t ogether or divide x by y , the answers are all equal .   What are those numbers ? If you'd like to have a go at finding the answer, please do, and I'd love to hear how you did it. Below are my thoughts, experiments and answer. I should have found the answer sooner than I did.  First of all I used BASIC, set up a couple of loops for x and y and tested for meeting the conditions. That didn't produce an answer and so I did try smaller steps and included negative numbers. I now know that I should have found the answer then but for some reason my program didn't produce the result.  Wanting to at least find the ballpark , I thought about ways to plot these three conditions on a graph. A 2d graph wouldn't really do it because we want to test all values of x and y. I tried using some 3d graphing systems to plot z=x+y, z=x*y and z=x/y,  to see where they all intersected.  But it w
Recent posts

Friday quiz problem 10 Jun, an exercise in the mod function

T oday's Friday Quiz question seems to have been devised as an exercise in writing a computer program using the mod() function: A pl a toon of soldiers is lining up for a parade.   When they line up in rows of 3, one soldier is left over.  When they line up in rows of 4,  two soldiers are left over.  When they line up in rows of 5,  three soldiers are left over.  When they line up in rows of 6, four soldiers are left over.  However, they can line up in rows of  7  with no-one left over.  What is the smallest possible number o f soldiers in the platoon ? Spoiler alert: my answer is in the video. But writing the program is the fun part for me, not coming up with the answer. As I say in the video, any language should have the mod() function. If not, you can write your own function / routine / word ,  it's the remainder after dividing one number by another.  Which is basically what the question is asking for. The lowest number where n mod 3 = 1, n mod 4 = 2 etc. Here's my progr

Friday Quiz problem 20 May - ?prime in Forth

T oday's question is:  In the Quarante Republic, every month contains 40 days, numbered 1 to 40.  Any day whose number is divisible by 6 is a holiday, and any day whose number is a prime is also a holiday.  How many times in a month does a single working day occur between two holidays? This lends itself very well to a Forth program. The first interesting challenge is to write a ?prime word in Forth. I don't remember doing this before. Google tells me that someone has published a Forth program for exactly this word but it looks unnecessarily complex for our purposes today.  I didn't know this, but you can find out whether a number is prime by trying to divide it by each prime up to the square root of your number. In our case that's only 2, 3 and 5. And only then if those primes are smaller than our number. The solution I have right now is less efficient, but does the job. I'll be looking to improve this. Please  share your own code if you have something more elegant

Writing a binary (bcd) clock in Forth for RC2014 and Minstrel 4th

 A nother idea I had for using the 8x8 LED Matrix is a binary clock.  It fits very neatly into 8x8 pixels  (The 8x8 matrix looks way better in real life than it does in these videos. It's very difficult to photograph or film.) Eventually I want to learn to use interrupts on the RC2014. An interrupt routine would update a counter very accurately and independently of the main program, which could be divided for accurate seconds, minutes and hours. In the absence of that and no counter (as far as I'm aware) in CP/M (the OS I use on my RC2014) it was necessary to write a 'jiffy clock' that you'd call from your main loop. Here it is: The idea is that you call clinc every 1/60 second and it gives you hrs mins and secs words for access to those numbers. If you can't call it exactly every 1/60s, then it allows for calibration and by coincidence, the main loop of my program happens to loop almost at that rate, hence the number 62 at line 27.  I was trying to be clev

Knitwear Designer for the BBC Micro, project part 2

I n part 1 I wrote about using Kendall Down's Knitwear Designer on a BBC micro to generate my knitting pattern. That was November 2020. I'm not a fast knitter. I tend to just knit a few rows each day rather than spending hours at a time on it. Plus I spun the yarn for this project.  Here it is done. I don't have a record of the exact measurements I fed into the program, but the fit is fantastic, so top marks to Kendall Down.  For those interested in the details of the spinning and knitting, I made quite a chunky yarn. (The gauge I gave the program was 5 stitches per inch, which I got on 4.5mm needles). I made a 4-ply yarn with 3 plies of Devonia from John Arbon , which is a blend of British sheep breeds, and one ply of Tussah silk dyed 'cyclamen' by Katie of Hilltop Cloud The pattern just gives you stitches and allows you to work in your own choice of colourwork or stitch pattern. 

Friday Quiz problem 18 Mar 22 - how many beans make 5?

H ere's today's question: I played 40 games of backgammon and scored 25 points.  A win counts as one point, a draw counts as half a point, and a loss counts as zero points.  How many more games did I win than lose? At first glance it looks as if you can 'formularise' this (ie w + d/2 + 0l = 25)  but you can't solve that, it seems as if there are many values that could work. My title refers to an old kids' joke - "how many beans make 5?" The answer I knew was "two beans, a bean and a half, half a bean and a bean" (said quickly!) But other kids had their own version of this and you can have many combinations of beans and half-beans.    The question is curiously-worded. "how many more times did I win than lose?"   My starting point was that if you could see all the possible values of w, d and l  that total 25 points, the pattern would be obvious. So the problem becomes one of printing out these values. The easiest brute-force way is to

Friday quiz problem 11 Mar 2022 - floating point in Forth

T odays' Friday Quiz maths problem is as follows:  At the Animal Olympics, Charlie Cheetah ran at 90 kilometres per hour, whilst Sid Snail slithered along at 20 hours per kilometre.  Charlie kept it up for 18 seconds.  How long would it take Sid to cover the same distance as Charlie? This is not very difficult to work out as long as you make sure to take account of all of the units; hours and seconds, kph vs hpk. I won't spoil it in case you want to work it out for yourself. despite being a simple calculation, it occurred to me that it would be fun to find the answer by running a simulation - ie show the race graphically, with a clock, and stop the clock when the snail reaches the cheetah.  And that it would be fun to run that simulation in real-time (slight spoiler, the answer is a number of hours). My Minstrel (Jupiter Ace clone) is on my desk at the mo, and I really am getting a lot out of working in Forth. What makes this project particularly interesting is that it needs fl