Skip to content

Instantly share code, notes, and snippets.

@NathanBaulch
Last active August 14, 2022 11:35
Show Gist options
  • Save NathanBaulch/8668695a19ac9fbfc78fa3cc24b83b0b to your computer and use it in GitHub Desktop.
Save NathanBaulch/8668695a19ac9fbfc78fa3cc24b83b0b to your computer and use it in GitHub Desktop.
Benchmark submissions to APS #038 unique words with unique letters
#!/bin/bash
# This script will download, configure, compile, run and compare 20 code responses to Matt
# Parker's "Can you find: five five-letter words with twenty-five unique letters?" video.
# Please run the script twice with the first execution elevated (sudo).
## INSTALL SYSTEM DEPENDENCIES
if [ "$EUID" -eq 0 ]
then
apt update && apt upgrade -y
apt install -y dos2unix hyperfine golang python3 python3-tqdm openjdk-18-jdk cmake
if ! command -v julia &> /dev/null
then
curl -O https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.3-linux-x86_64.tar.gz
tar -xvzf julia-1.7.3-linux-x86_64.tar.gz
mv julia-1.7.3/ /opt/
ln -s /opt/julia-1.7.3/bin/julia /usr/local/bin/julia
fi
if ! command -v dotnet &> /dev/null
then
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install -y dotnet-sdk-6.0
fi
exit
fi
if ! command -v cargo &> /dev/null
then
curl https://sh.rustup.rs -sSf | sh -s -- -y
source "$HOME/.cargo/env"
fi
## FETCH CODE
[ ! -d Diggsey ] && git clone https://github.com/Diggsey/five_words Diggsey
[ ! -d He3lixxx ] && git clone https://github.com/He3lixxx/five-words-five-letters He3lixxx
[ ! -d NathanBaulch ] && curl https://gist.githubusercontent.com/NathanBaulch/cc26755dc89685fa209bf958e484c60d/raw/main.go --output NathanBaulch/main.go
[ ! -d ae6nr ] && git clone https://github.com/ae6nr/25letters ae6nr
[ ! -d alexrecuenco ] && git clone https://github.com/alexrecuenco/five_clique alexrecuenco
[ ! -d bpaassen ] && git clone https://gitlab.com/bpaassen/five_clique bpaassen
[ ! -d davidad ] && git clone https://github.com/davidad/five-letters davidad
[ ! -d encody ] && git clone https://github.com/encody/jotto-problem encody
[ ! -d gweijers ] && git clone https://github.com/gweijers/wordle_cover gweijers
[ ! -d holmesrichards ] && git clone https://github.com/holmesrichards/nclique holmesrichards
[ ! -d ilyanikolaevsky ] && git clone https://github.com/ilyanikolaevsky/five_words ilyanikolaevsky
[ ! -d kristinpaget ] && git clone https://github.com/kristinpaget/fivewords kristinpaget
[ ! -d miniBill ] && git clone https://github.com/miniBill/parkerrust miniBill
[ ! -d neilcoffey ] && git clone https://github.com/neilcoffey/FunStuff neilcoffey
[ ! -d oisyn ] && git clone https://github.com/oisyn/parkerwords oisyn
[ ! -d orlp ] && git clone https://github.com/orlp/matt-parker-five-letter-clique orlp
[ ! -d palday ] && git clone https://github.com/palday/FiveLetterWorda.jl palday
[ ! -d phire ] && git clone https://github.com/phire/five_clique phire
[ ! -d pyaggi ] && git clone https://github.com/pyaggi/WordStats pyaggi
[ ! -d remygrandin ] && git clone https://github.com/remygrandin/fivewords remygrandin
## DISTRIBUTE WORD FILE (just to be fair)
[ ! -f words_alpha.txt ] && curl -O https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt && dos2unix words_alpha.txt
for d in */; do cp words_alpha.txt "$d"words_alpha.txt; done
cp words_alpha.txt Diggsey/wordlist.txt
## BUILD CODE (where applicable)
export CARGO_INCREMENTAL=1
export RUSTFLAGS="-C target-cpu=native"
cargo build -r --manifest-path=Diggsey/Cargo.toml
cargo build -r --manifest-path=davidad/Cargo.toml
cargo build -r --manifest-path=miniBill/Cargo.toml
cargo build -r --manifest-path=orlp/Cargo.toml
cd NathanBaulch; GO111MODULE=off go build .; cd -
cmake -B pyaggi -S pyaggi; make -C pyaggi
gcc -O3 -Wall -Werror -o kristinpaget/fivewords kristinpaget/fivewords.c
gcc ilyanikolaevsky/non_intersecting_words.cpp -lstdc++ -o ilyanikolaevsky/non_intersecting_words
gcc oisyn/parkerwords.cpp -lstdc++ -std=c++20 -o oisyn/parkerwords
julia --project=palday -e'using Pkg; Pkg.instantiate()'
make -C He3lixxx
sed -i "s| -flto=full||" ./gweijers/Makefile; make -C gweijers
sed -i "s|/Users/jacob/Downloads|$PWD|" ./encody/src/main.rs; cargo build -r --manifest-path=encody/Cargo.toml
sed -i "s|wordleWords.txt|words_alpha.txt|" ./remygrandin/fivewords/Program.cs; dotnet build --source ./remygrandin/fivewords --configuration Release
## RUMBLE!
export TIMEOUT=2m
hyperfine \
-r2 \
-i \
-n Diggsey "timeout $TIMEOUT ./Diggsey/target/release/five_words" \
-n He3lixxx "timeout $TIMEOUT ./He3lixxx/five_words < words_alpha.txt" \
-n NathanBaulch "timeout $TIMEOUT ./NathanBaulch/NathanBaulch words_alpha.txt" \
-n ae6nr "timeout $TIMEOUT python3 ./ae6nr/backtrack.py" \
-n alexrecuenco "timeout $TIMEOUT python3 ./alexrecuenco/five_cliques.py" \
-n bpaassen "timeout $TIMEOUT sh -c 'python3 ./bpaassen/generate_graph.py && python3 ./bpaassen/five_clique.py'" \
-n davidad "timeout $TIMEOUT ./davidad/target/release/five-letters" \
-n encody "timeout $TIMEOUT ./encody/target/release/jotto-problem" \
-n gweijers "timeout $TIMEOUT ./gweijers/wordle_cover words_alpha.txt" \
-n holmesrichards "timeout $TIMEOUT sh -c 'python3 ./holmesrichards/generate_graph.py words_alpha.txt 5 && python3 ./holmesrichards/n_clique.py'" \
-n ilyanikolaevsky "timeout $TIMEOUT ./ilyanikolaevsky/non_intersecting_words" \
-n kristinpaget "timeout $TIMEOUT ./kristinpaget/fivewords ../words_alpha.txt $(grep processor -c /proc/cpuinfo)" \
-n miniBill "timeout $TIMEOUT ./miniBill/target/release/parkerrust" \
-n neilcoffey "timeout $TIMEOUT java -classpath ./neilcoffey/WordleFiveWordFinder/src WordleFiveWordFinder" \
-n oisyn "timeout $TIMEOUT ./oisyn/parkerwords" \
-n orlp "timeout $TIMEOUT ./orlp/target/release/wordle_unique" \
-n palday "timeout $TIMEOUT julia --project=palday --threads=auto -e'using FiveLetterWorda; main();'" \
-n phire "timeout $TIMEOUT python3 ./phire/five_cliques.py" \
-n pyaggi "timeout $TIMEOUT ./pyaggi/wordstats words_alpha.txt /dev/null" \
-n remygrandin "timeout $TIMEOUT dotnet ./remygrandin/fivewords/bin/Release/net6.0/fivewords.dll" \
--export-csv report.csv \
--export-json report.json \
--export-markdown report.md \
--export-asciidoc report.adoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment