Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,50 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Containers.Generic_Array_Sort;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
procedure Main is
type map_element is record
Num : Positive;
Word : Unbounded_String;
end record;
type map_list is array (Positive range <>) of map_element;
function "<" (Left, Right : map_element) return Boolean is
begin
return Left.Num < Right.Num;
end "<";
procedure list_sort is new Ada.Containers.Generic_Array_Sort
(Index_Type => Positive, Element_Type => map_element,
Array_Type => map_list);
procedure general_fizz_buzz (max : Positive; words : in out map_list) is
found : Boolean;
begin
list_sort (words);
for i in 1 .. max loop
found := False;
for element of words loop
if i mod element.Num = 0 then
found := True;
Put (element.Word);
end if;
end loop;
if not found then
Put (Item => i, Width => 1);
end if;
New_Line;
end loop;
end general_fizz_buzz;
fizzy : map_list :=
((3, To_Unbounded_String ("FIZZ")), (7, To_Unbounded_String ("BAXX")),
(5, To_Unbounded_String ("BUZZ")));
begin
general_fizz_buzz (20, fizzy);
end Main;

View file

@ -0,0 +1,16 @@
link factors
procedure main(A)
/A := [20,3,"Fizz",5,"Buzz",7,"Baxx"]
mtable := table()
limit := get(A)
while *A > 0 do mtable[integer(get(A))] := get(A)
mlist := sort([: key(mtable) :])
every i := 1 to limit do write((""~== fizzbuzz(i,mlist,mtable))|i)
end
procedure fizzbuzz(n,a,t)
every (s := "", n%(f := !a) = 0) do s ||:= t[f]
return s
end

View file

@ -0,0 +1,18 @@
srep(n, s) := block(
l: charlist(s),
lrep: map(lambda([c], smake(n, c)), l),
apply(sconcat, lrep)
)$
srep_zip(nums, strings) := block(
len: min(length(nums), length(strings)),
makelist(srep(nums[i], strings[i]), i, 1, len)
)$
genfizzbuzz(factors, words, n1, n2) := for i from n1 thru n2 do(
flags: map(lambda([k], charfun(mod(i, k)=0)), factors),
if member(1, flags) then sprint(apply(sconcat, srep_zip(flags, words))) else sprint(i),
if mod(i-n1+1, 10)=0 then newline()
)$
genfizzbuzz([3, 5, 7], ["Fizz", "Buzz", "Baxx"], 1, 105);

View file

@ -0,0 +1,30 @@
require "io2"
local n = io.readInt("Maximum number : ", 3)
local factors = {}
local words = {}
for i = 1, 3 do
while true do
local factor = io.readInt($"Factor {i} : ", 2)
if factor in factors then
print("Must be an unused integer > 1, try again.")
else
factors:insert(factor)
local word = io.readStr($" Word {i} : ", 1)
words[factor] = word
break
end
end
end
factors:sort()
print()
for i = 1, n do
local s = ""
for j = 1, 3 do
local factor = factors[j]
if i % factor == 0 then s ..= words[factor] end
end
if s == "" then s = tostring(i) end
print(s)
end

View file

@ -0,0 +1,19 @@
$limit = 20
$data = @("3 Fizz","5 Buzz","7 Baxx")
#An array with whitespace as the delimiter
#Between the factor and the word
for ($i = 1;$i -le $limit;$i++){
$outP = ""
foreach ($x in $data){
$data_split = $x -split " " #Split the "<factor> <word>"
if (($i % $data_split[0]) -eq 0){
$outP += $data_split[1] #Append the <word> to outP
}
}
if(!$outP){ #Is outP equal to NUL?
Write-HoSt $i
} else {
Write-HoSt $outP
}
}

View file

@ -0,0 +1,34 @@
'The Function
Function FizzBuzz(range, mapping)
data = Array()
'Parse the mapping and put to "data" array
temp = Split(mapping, ",")
ReDim data(UBound(temp),1)
For i = 0 To UBound(temp)
map = Split(temp(i), " ")
data(i, 0) = map(0)
data(i, 1) = map(1)
Next
'Do the loop
For i = 1 to range
noMatch = True
For j = 0 to UBound(data, 1)
If (i Mod data(j, 0)) = 0 Then
WScript.StdOut.Write data(j, 1)
noMatch = False
End If
Next
If noMatch Then WScript.StdOut.Write i
WScript.StdOut.Write vbCrLf
Next
End Function
'The Main Thing
WScript.StdOut.Write "Range? "
x = WScript.StdIn.ReadLine
WScript.StdOut.Write "Mapping? "
y = WScript.StdIn.ReadLine
WScript.StdOut.WriteLine ""
FizzBuzz x, y