How to resolve the algorithm Eban numbers step by step in the Tailspin programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Eban numbers step by step in the Tailspin programming language
Table of Contents
Problem Statement
An eban number is a number that has no letter e in it when the number is spelled in English. Or more literally, spelled numbers that contain the letter e are banned.
The American version of spelling numbers will be used here (as opposed to the British). 2,000,000,000 is two billion, not two milliard.
Only numbers less than one sextillion (1021) will be considered in/for this task. This will allow optimizations to be used.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Eban numbers step by step in the Tailspin programming language
Source code in the tailspin programming language
templates isEban
def number: $;
'$;' -> \(<'([246]|[3456][0246])(0[03456][0246])*'> $ !\) -> $number !
end isEban
templates isEban
def number: $;
$ -> \(<1..> $!\) -> #
when <=0> do $number !
when ($ mod 1000 <=0|=2|=4|=6|30..66?($ mod 10 <=0|=2|=4|=6>)>)> do $ ~/ 1000 -> #
end isEban
def small: [1..1000 -> isEban];
$small -> !OUT::write
'
There are $small::length; eban numbers up to and including 1000
' -> !OUT::write
def next: [1000..4000 -> isEban];
$next -> !OUT::write
'
There are $next::length; eban numbers between 1000 and 4000 (inclusive)
' -> !OUT::write
'
There are $:[1..10000 -> isEban] -> $::length; eban numbers up to and including 10 000
' -> !OUT::write
'
There are $:[1..100000 -> isEban] -> $::length; eban numbers up to and including 100 000
' -> !OUT::write
'
There are $:[1..1000000 -> isEban] -> $::length; eban numbers up to and including 1 000 000
' -> !OUT::write
'
There are $:[1..10000000 -> isEban] -> $::length; eban numbers up to and including 10 000 000
' -> !OUT::write
You may also check:How to resolve the algorithm Sorting algorithms/Permutation sort step by step in the R programming language
You may also check:How to resolve the algorithm Bitcoin/address validation step by step in the Julia programming language
You may also check:How to resolve the algorithm A+B step by step in the Quackery programming language
You may also check:How to resolve the algorithm RCRPG step by step in the Nim programming language
You may also check:How to resolve the algorithm Sorting algorithms/Cocktail sort with shifting bounds step by step in the Phix programming language