Skip to content
Snippets Groups Projects
Verified Commit 7eee4aae authored by mirabilos's avatar mirabilos Committed by mirabilos
Browse files

ok, but part 2… WTF?

parent 484e5533
No related branches found
No related tags found
No related merge requests found
#!/bin/mksh
if [[ $1 = prod ]]; then
file=i
w=101
h=103
else
file=c
w=11
h=7
fi
{
print -r -- "h=$h"
print -r -- "u=$w"
cat <<-\EOF
a=0
b=0
c=0
d=0
e=(u-1)/2
f=(h-1)/2
define void r(s,t,v,w) {
auto x, y
x = (s + 100 * v) % u
if (x < 0) x += u
y = (t + 100 * w) % h
if (y < 0) y += h
print "(", s, ",", t, ") → (", x, ",", y, ")\n"
# print v,",",w," :: ", (s + 100 * v), " - ", (t + 100 * w), "\n"
if (x<e) {
if (y<f) {
a+=1
} else if (y>f) {
b+=1
}
} else if (x>e) {
if (y<f) {
c+=1
} else if (y>f) {
d+=1
}
}
}
EOF
sed -e 's/p=/r(/' -e 's/ v=/,/' -e 's/$/)/' <"$file"
cat <<-\EOF
a
b
c
d
a*b*c*d
EOF
} | bc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment