Perl Weekly Challenge 52: Stepping Numbers and Lucky Winner
These are some answers to the Week 52 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Task 1: Stepping Numbers
Write a script to accept two numbers between 100 and 999. It should then print all Stepping Numbers between them.
A number is called a stepping number if the adjacent digits have a difference of 1. For example, 456 is a stepping number but 129 is not.
Just to make things slightly clearer, I would say that all adjacent digits should have an absolute difference of 1, so that 542, 454, or 654 are also stepping numbers.
Stepping Numbers in Perl
Given that the range is quite small, we can use a brute force approach on all numbers between the input values: check for every number in the range whether it fits the definition.