Below is a simple calculator that can help you to find missing numbers in an integer sequence. Let's suppose you have a text file of consecutive numbers, such as below, with each number on its own line:
However, there are some missing numbers and gaps. In the example above, 5 is missing, and there are two gaps: between 8 and 11 and also between 14 and 17.
Of course, in this example it is easy to see the problems just by looking at it, but if we were talking about thousands of numbers, it would be too cumbersome to locate the gaps by eye. That's why I've created this calculator. You can paste in a list of numbers, and it will display all the missing numbers and gaps it was able to find in the sequence, bounded by the first and the last line of the list.
I have also added a couple of options:
- You can set "Collapse gaps" checkbox to output gaps in a collapsed form, in other words, taking 8 - 11 as an example, the 8 is the start of the gap and 11 is the end. This option is turned on by default. If you uncheck it, you will get a list of all numbers in a gap, i.e. 8, 9, 10, 11.
- You can set the "Use regular expression to parse number" checkbox to parse the line of your text file with regular expression.
The reason for the second option is that your list is unlikely to include just numbers. Your text file will probably include additional text, something like:
1 Paper beats stone
2 Scissors beat paper
3 Stone beats scissors
For that case, you can use regular expression to extract the number from the line and then check the sequence. You need to set the "Use regular expression to parse number" checkbox and enter regular expression and match group, which will be used to extract the number.
Default regular expression matches the line where the number is placed at the beginning of the line.