Skip to content

Instantly share code, notes, and snippets.

@colrichie
Created October 11, 2023 09:14
Show Gist options
  • Save colrichie/33fa6d518cd1760f2535da46067f554b to your computer and use it in GitHub Desktop.
Save colrichie/33fa6d518cd1760f2535da46067f554b to your computer and use it in GitHub Desktop.
Nabeatsu's Aho Rate Calculator (24 threads shell script)
#!/bin/sh
: > results.txt
seq -f '%.0f' 1 178956971 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "01",a,n;}' >> results.txt &
seq -f '%.0f' 178956972 357913943 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "02",a,n;}' >> results.txt &
seq -f '%.0f' 357913944 536870916 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "03",a,n;}' >> results.txt &
seq -f '%.0f' 536870917 715827890 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "04",a,n;}' >> results.txt &
seq -f '%.0f' 715827891 894784865 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "05",a,n;}' >> results.txt &
seq -f '%.0f' 894784866 1073741841 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "06",a,n;}' >> results.txt &
seq -f '%.0f' 1073741842 1252698818 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "07",a,n;}' >> results.txt &
seq -f '%.0f' 1252698819 1431655796 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "08",a,n;}' >> results.txt &
seq -f '%.0f' 1431655797 1610612775 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "09",a,n;}' >> results.txt &
seq -f '%.0f' 1610612776 1789569755 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "10",a,n;}' >> results.txt &
seq -f '%.0f' 1789569756 1968526736 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "11",a,n;}' >> results.txt &
seq -f '%.0f' 1968526737 2147483718 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "12",a,n;}' >> results.txt &
seq -f '%.0f' 2147483719 2326440701 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "13",a,n;}' >> results.txt &
seq -f '%.0f' 2326440702 2505397685 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "14",a,n;}' >> results.txt &
seq -f '%.0f' 2505397686 2684354670 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "15",a,n;}' >> results.txt &
seq -f '%.0f' 2684354671 2863311656 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "16",a,n;}' >> results.txt &
seq -f '%.0f' 2863311657 3042268643 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "17",a,n;}' >> results.txt &
seq -f '%.0f' 3042268644 3221225631 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "18",a,n;}' >> results.txt &
seq -f '%.0f' 3221225632 3400182620 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "19",a,n;}' >> results.txt &
seq -f '%.0f' 3400182621 3579139610 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "20",a,n;}' >> results.txt &
seq -f '%.0f' 3579139611 3758096601 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "21",a,n;}' >> results.txt &
seq -f '%.0f' 3758096602 3937053593 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "22",a,n;}' >> results.txt &
seq -f '%.0f' 3937053594 4116010586 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "23",a,n;}' >> results.txt &
seq -f '%.0f' 4116010587 4294967296 | awk 'BEGIN{n=0;a=0;}; /3/{a++;next;}; $1%3==0{a++;next;}; {n++;}; END{print "24",a,n;}' >> results.txt &
wait
cat results.txt | sort -bk 1,1
echo '***'
awk '{a+=$2;n+=$3;}; END{print a,n;print a/(a+n);};' results.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment