Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,11 @@
#!/bin/bash
sierpinski_carpet() {
local -i n="${1:-3}"
local carpet="${2:-#}"
while (( n-- )); do
local center="${carpet//#/ }"
carpet="$(paste -d ' ' <(echo "$carpet"$'\n'"$carpet"$'\n'"$carpet") <(echo "$carpet"$'\n'"$center"$'\n'"$carpet") <(echo "$carpet"$'\n'"$carpet"$'\n'"$carpet"))"
done
echo "$carpet"
}

View file

@ -0,0 +1,22 @@
sierpinski_carpet() {
typeset -i n=${1:-3}
if (( n < 1 )); then
return 1
fi
typeset -i size x y
typeset x1 y1
(( size = 3 ** n ))
for (( y=0; y<size; ++y )); do
y1=$(dc <<<"$y 3op")
for (( x=0; x<size; ++x )); do
x1=$(dc <<<"$x 3op")
if (( 2#${x1//2/0} & 2#${y1//2/0} )); then
printf ' '
else
printf '#'
fi
done
printf '\n'
done
}
sierpinski_carpet 3