Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
175
Task/Eban-numbers/Ada/eban-numbers.ada
Normal file
175
Task/Eban-numbers/Ada/eban-numbers.ada
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
-- Rosetta Code Task written in Ada
|
||||
-- Eban numbers
|
||||
-- https://rosettacode.org/wiki/Eban_numbers
|
||||
-- Inspired (mostly) by the Nim and Go solutions
|
||||
-- August 2024, R. B. E.
|
||||
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
|
||||
|
||||
procedure Eban_Numbers is
|
||||
|
||||
function Is_Eban (Candidate : Natural) return Boolean is
|
||||
N : Natural := Candidate;
|
||||
B, R, M, T : Natural;
|
||||
begin
|
||||
if (N = 0) then
|
||||
return False;
|
||||
end if;
|
||||
B := N / 1_000_000_000;
|
||||
R := N mod 1_000_000_000;
|
||||
M := R / 1_000_000;
|
||||
R := R mod 1_000_000;
|
||||
T := R / 1_000;
|
||||
R := R mod 1_000;
|
||||
|
||||
case M is
|
||||
when 30..66 => M := M mod 10;
|
||||
when others => null;
|
||||
end case;
|
||||
|
||||
case T is
|
||||
when 30..66 => T := T mod 10;
|
||||
when others => null;
|
||||
end case;
|
||||
|
||||
case R is
|
||||
when 30..66 => R := R mod 10;
|
||||
when others => null;
|
||||
end case;
|
||||
|
||||
if ((B = 0) or (B = 2) or (B = 4) or (B = 6)) then
|
||||
if ((M = 0) or (M = 2) or (M = 4) or (M = 6)) then
|
||||
if ((T = 0) or (T = 2) or (T = 4) or (T = 6)) then
|
||||
if ((R = 0) or (R = 2) or (R = 4) or (R = 6)) then
|
||||
return True;
|
||||
else
|
||||
return False;
|
||||
end if;
|
||||
else
|
||||
return False;
|
||||
end if;
|
||||
else
|
||||
return False;
|
||||
end if;
|
||||
else
|
||||
return False;
|
||||
end if;
|
||||
end Is_Eban;
|
||||
|
||||
Group_Total : Natural;
|
||||
Loop_Starts_At, Loop_Stops_At : Natural;
|
||||
|
||||
begin
|
||||
Loop_Starts_At := 0;
|
||||
Loop_Stops_At := 1_000;
|
||||
Put ("eban numbers up to and including: ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
New_Line;
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Put (I, 0);
|
||||
Put (" ");
|
||||
end if;
|
||||
end loop;
|
||||
New_Line (2);
|
||||
|
||||
Loop_Starts_At := 1_000;
|
||||
Loop_Stops_At := 4_000;
|
||||
Put ("eban numbers between ");
|
||||
Put (Loop_Starts_At, 3);
|
||||
Put (" and ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
Put_Line (" (inclusive):");
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Put (I, 0);
|
||||
Put (" ");
|
||||
end if;
|
||||
end loop;
|
||||
New_Line (2);
|
||||
|
||||
Group_Total := 0;
|
||||
Loop_Starts_At := 0;
|
||||
Loop_Stops_At := 10_000;
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Group_Total := Group_Total + 1;
|
||||
end if;
|
||||
end loop;
|
||||
Put ("Number of eban numbers up to and including ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
Put (": ");
|
||||
Put (Group_Total, 4);
|
||||
New_Line (2);
|
||||
|
||||
Group_Total := 0;
|
||||
Loop_Starts_At := 0;
|
||||
Loop_Stops_At := 100_000;
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Group_Total := Group_Total + 1;
|
||||
end if;
|
||||
end loop;
|
||||
Put ("Number of eban numbers up to and including ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
Put (": ");
|
||||
Put (Group_Total, 4);
|
||||
New_Line (2);
|
||||
|
||||
Group_Total := 0;
|
||||
Loop_Starts_At := 0;
|
||||
Loop_Stops_At := 1_000_000;
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Group_Total := Group_Total + 1;
|
||||
end if;
|
||||
end loop;
|
||||
Put ("Number of eban numbers up to and including ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
Put (": ");
|
||||
Put (Group_Total, 4);
|
||||
New_Line (2);
|
||||
|
||||
Group_Total := 0;
|
||||
Loop_Starts_At := 0;
|
||||
Loop_Stops_At := 10_000_000;
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Group_Total := Group_Total + 1;
|
||||
end if;
|
||||
end loop;
|
||||
Put ("Number of eban numbers up to and including ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
Put (": ");
|
||||
Put (Group_Total, 4);
|
||||
New_Line (2);
|
||||
|
||||
Group_Total := 0;
|
||||
Loop_Starts_At := 0;
|
||||
Loop_Stops_At := 100_000_000;
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Group_Total := Group_Total + 1;
|
||||
end if;
|
||||
end loop;
|
||||
Put ("Number of eban numbers up to and including ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
Put (": ");
|
||||
Put (Group_Total, 4);
|
||||
New_Line (2);
|
||||
|
||||
Group_Total := 0;
|
||||
Loop_Starts_At := 0;
|
||||
Loop_Stops_At := 1_000_000_000;
|
||||
for I in Loop_Starts_At .. Loop_Stops_At loop
|
||||
if Is_Eban (I) then
|
||||
Group_Total := Group_Total + 1;
|
||||
end if;
|
||||
end loop;
|
||||
Put ("Number of eban numbers up to and including ");
|
||||
Put (Loop_Stops_At, 3);
|
||||
Put (": ");
|
||||
Put (Group_Total, 4);
|
||||
New_Line (2);
|
||||
end Eban_Numbers;
|
||||
42
Task/Eban-numbers/BASIC256/eban-numbers.basic
Normal file
42
Task/Eban-numbers/BASIC256/eban-numbers.basic
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
call eban (2, 1000, 1)
|
||||
call eban (1000, 4000, 1)
|
||||
call eban (2, 10000, 0)
|
||||
call eban (2, 100000, 0)
|
||||
call eban (2, 1000000, 0)
|
||||
call eban (2, 10000000, 0)
|
||||
call eban (2, 100000000, 0)
|
||||
print "Run time: " + (Msec/1000) + " seconds."
|
||||
end
|
||||
|
||||
subroutine eban (start, ended, printable)
|
||||
contar = 0
|
||||
if start = 2 then
|
||||
print "eban numbers up to and including "; ended; ":"
|
||||
else
|
||||
print "eban numbers between "; start; " and "; ended; " (inclusive):"
|
||||
end if
|
||||
|
||||
for i = start to ended step 2
|
||||
b = int(i / 1000000000)
|
||||
r = (i % 1000000000)
|
||||
m = int(r / 1000000)
|
||||
r = (i % 1000000)
|
||||
t = int(r / 1000)
|
||||
r = (r % 1000)
|
||||
if m >= 30 and m <= 66 then m = (m % 10)
|
||||
if t >= 30 and t <= 66 then t = (t % 10)
|
||||
if r >= 30 and r <= 66 then r = (r % 10)
|
||||
if b = 0 or b = 2 or b = 4 or b = 6 then
|
||||
if m = 0 or m = 2 or m = 4 or m = 6 then
|
||||
if t = 0 or t = 2 or t = 4 or t = 6 then
|
||||
if r = 0 or r = 2 or r = 4 or r = 6 then
|
||||
if printable then print i + " ";
|
||||
contar += 1
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
next i
|
||||
if printable then print
|
||||
print "count = "; contar & chr(10)
|
||||
end subroutine
|
||||
42
Task/Eban-numbers/Chipmunk-Basic/eban-numbers.basic
Normal file
42
Task/Eban-numbers/Chipmunk-Basic/eban-numbers.basic
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
100 cls
|
||||
110 t0 = timer
|
||||
120 eban(2,1000,1)
|
||||
130 eban(1000,4000,1)
|
||||
140 eban(2,10000,0)
|
||||
150 eban(2,100000,0)
|
||||
160 eban(2,1000000,0)
|
||||
170 eban(2,10000000,0)
|
||||
180 eban(2,100000000,0)
|
||||
190 print "Run time: ";(timer-t0);"seconds."
|
||||
200 end
|
||||
210 sub eban(start,ended,printable)
|
||||
220 contar = 0
|
||||
230 if start = 2 then
|
||||
240 print "eban numbers up to and including ";ended;":"
|
||||
250 else
|
||||
260 print "eban numbers between ";start;"and ";ended;"(inclusive):"
|
||||
270 endif
|
||||
280 for i = start to ended step 2
|
||||
290 b = int(i/1000000000)
|
||||
300 r = (i mod 1000000000)
|
||||
310 m = int(r/1000000)
|
||||
320 r = (i mod 1000000)
|
||||
330 t = int(r/1000)
|
||||
340 r = (r mod 1000)
|
||||
350 if m >= 30 and m <= 66 then m = (m mod 10)
|
||||
360 if t >= 30 and t <= 66 then t = (t mod 10)
|
||||
370 if r >= 30 and r <= 66 then r = (r mod 10)
|
||||
380 if b = 0 or b = 2 or b = 4 or b = 6 then
|
||||
390 if m = 0 or m = 2 or m = 4 or m = 6 then
|
||||
400 if t = 0 or t = 2 or t = 4 or t = 6 then
|
||||
410 if r = 0 or r = 2 or r = 4 or r = 6 then
|
||||
420 if printable then print i;
|
||||
430 contar = contar+1
|
||||
440 endif
|
||||
450 endif
|
||||
460 endif
|
||||
470 endif
|
||||
480 next i
|
||||
490 if printable then print
|
||||
500 print "count = ";contar;chr$(10)
|
||||
510 end sub
|
||||
54
Task/Eban-numbers/Gambas/eban-numbers.gambas
Normal file
54
Task/Eban-numbers/Gambas/eban-numbers.gambas
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
Public Sub Main()
|
||||
|
||||
Dim tiempo As Float = Timer
|
||||
|
||||
eban(2, 1000, 1)
|
||||
eban(1000, 4000, 1)
|
||||
eban(2, 10000, 0)
|
||||
eban(2, 100000, 0)
|
||||
eban(2, 1000000, 0)
|
||||
eban(2, 10000000, 0)
|
||||
eban(2, 100000000, 0)
|
||||
|
||||
tiempo = Timer - tiempo
|
||||
Print "Run time: " & (tiempo) & " seconds."
|
||||
|
||||
End
|
||||
|
||||
Public Sub eban(start As Integer, ended As Integer, printable As Integer)
|
||||
|
||||
Dim count As Integer
|
||||
Dim i As Long, b As Long, r As Long, m As Long, t As Long
|
||||
|
||||
If start = 2 Then
|
||||
Print "eban numbers up to and including "; ended; ":"
|
||||
Else
|
||||
Print "eban numbers between "; start; " and "; ended; " (inclusive):"
|
||||
End If
|
||||
|
||||
count = 0
|
||||
For i = start To ended Step 2
|
||||
b = Int(i / 1000000000)
|
||||
r = (i Mod 1000000000)
|
||||
m = Int(r / 1000000)
|
||||
r = (i Mod 1000000)
|
||||
t = Int(r / 1000)
|
||||
r = (r Mod 1000)
|
||||
If m >= 30 And m <= 66 Then m = (m Mod 10)
|
||||
If t >= 30 And t <= 66 Then t = (t Mod 10)
|
||||
If r >= 30 And r <= 66 Then r = (r Mod 10)
|
||||
If b = 0 Or b = 2 Or b = 4 Or b = 6 Then
|
||||
If m = 0 Or m = 2 Or m = 4 Or m = 6 Then
|
||||
If t = 0 Or t = 2 Or t = 4 Or t = 6 Then
|
||||
If r = 0 Or r = 2 Or r = 4 Or r = 6 Then
|
||||
If printable Then Print i; " ";
|
||||
count += 1
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
If printable Then Print
|
||||
Print "count = "; count & Chr(10)
|
||||
|
||||
End
|
||||
68
Task/Eban-numbers/Rust/eban-numbers.rs
Normal file
68
Task/Eban-numbers/Rust/eban-numbers.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
use std::ops::{Div, Rem};
|
||||
use std::println;
|
||||
|
||||
fn iseban(n: i64) -> bool {
|
||||
let b = n.div(1_000_000_000);
|
||||
let mut r = n.rem(1_000_000_000);
|
||||
let m = r.div(1_000_000);
|
||||
r = r.rem(1_000_000);
|
||||
let t = r.div(1000);
|
||||
r = r.rem(1000);
|
||||
let mut arr: Vec<_> = [m, t, r]
|
||||
.iter()
|
||||
.map(|x| {
|
||||
if &30 <= x && x <= &66 {
|
||||
(*x).rem(10)
|
||||
} else {
|
||||
*x
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
arr.push(b);
|
||||
return arr.iter().all(|x| [0, 2, 4, 6].contains(x));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("Eban numbers up to and including 1000:");
|
||||
println!(
|
||||
"{}",
|
||||
(1..=1_00_i64)
|
||||
.filter(|x| iseban(*x))
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
);
|
||||
println!("Eban numbers between 1000 and 4000 (inclusive):");
|
||||
println!(
|
||||
"{}",
|
||||
(1000..=4_000_i64)
|
||||
.filter(|x| iseban(*x))
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
);
|
||||
println!(
|
||||
"Eban numbers up to and including 10_000: {}",
|
||||
(1..=10000).map(|x| iseban(x) as i32).sum::<i32>()
|
||||
);
|
||||
println!(
|
||||
"Eban numbers up to and including 100_000: {}",
|
||||
(1..=100000).map(|x| iseban(x) as i32).sum::<i32>()
|
||||
);
|
||||
println!(
|
||||
"Eban numbers up to and including 1_000_000: {}",
|
||||
(1..=1000000).map(|x| iseban(x) as i32).sum::<i32>()
|
||||
);
|
||||
println!(
|
||||
"Eban numbers up to and including 10_000_000: {}",
|
||||
(1..=10000000).map(|x| iseban(x) as i32).sum::<i32>()
|
||||
);
|
||||
println!(
|
||||
"Eban numbers up to and including 100_000_000: {}",
|
||||
(1..=100000000).map(|x| iseban(x) as i32).sum::<i32>()
|
||||
);
|
||||
println!(
|
||||
"Eban numbers up to and including 1_000_000_000: {}",
|
||||
(1..=1000000000).map(|x| iseban(x) as i32).sum::<i32>()
|
||||
);
|
||||
}
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
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 -> #
|
||||
isEban templates
|
||||
number is $;
|
||||
'$;' -> if <|'([246]|[3456][0246])(0[03456][0246])*'> -> $number !
|
||||
end isEban
|
||||
|
|
|
|||
|
|
@ -1,29 +1,6 @@
|
|||
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
|
||||
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
|
||||
|
|
|
|||
6
Task/Eban-numbers/Tailspin/eban-numbers-4.tailspin
Normal file
6
Task/Eban-numbers/Tailspin/eban-numbers-4.tailspin
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
isEban templates
|
||||
number is $;
|
||||
$ -> if <|1..> -> # !
|
||||
when <|=0> do $number !
|
||||
when <|?($ mod 1000 matches <|=0|=2|=4|=6|30..66?($ mod 10 matches <|=0|=2|=4|=6>)>)> do $ ~/ 1000 -> # !
|
||||
end isEban
|
||||
29
Task/Eban-numbers/Tailspin/eban-numbers-5.tailspin
Normal file
29
Task/Eban-numbers/Tailspin/eban-numbers-5.tailspin
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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
|
||||
29
Task/Eban-numbers/Tailspin/eban-numbers-6.tailspin
Normal file
29
Task/Eban-numbers/Tailspin/eban-numbers-6.tailspin
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
small is [1..1000 -> isEban];
|
||||
$small !
|
||||
'
|
||||
There are $small::length; eban numbers up to and including 1000
|
||||
|
||||
' !
|
||||
|
||||
next is [1000..4000 -> isEban];
|
||||
$next !
|
||||
'
|
||||
There are $next::length; eban numbers between 1000 and 4000 (inclusive)
|
||||
|
||||
' !
|
||||
'
|
||||
There are $:[1..10000 -> isEban] -> $::length; eban numbers up to and including 10 000
|
||||
|
||||
' !
|
||||
'
|
||||
There are $:[1..100000 -> isEban] -> $::length; eban numbers up to and including 100 000
|
||||
|
||||
' !
|
||||
'
|
||||
There are $:[1..1000000 -> isEban] -> $::length; eban numbers up to and including 1 000 000
|
||||
|
||||
' !
|
||||
'
|
||||
There are $:[1..10000000 -> isEban] -> $::length; eban numbers up to and including 10 000 000
|
||||
|
||||
' !
|
||||
Loading…
Add table
Add a link
Reference in a new issue