Files
adventofcode/2016/day-10/create-graph.sh
Bert Peters 213ceb6f85 Create graph visualisation for input.
Needed to check if the graph is actually a DAG and whether the degrees
are correct.
2016-12-13 14:05:03 +01:00

16 lines
385 B
Bash
Executable File

#!/bin/bash
echo "digraph bots {"
while IFS=' ' read -r -a data; do
if [[ ${data[0]} == "value" ]]; then
echo "I${data[1]} -> B${data[5]};"
else
[[ ${data[5]} == "bot" ]] && kind1="B" || kind2="O"
[[ ${data[10]} == "bot" ]] && kind2="B" || kind2="O"
echo "B${data[1]} -> $kind1${data[6]} [label=lo];"
echo "B${data[1]} -> $kind2${data[11]} [label=hi];"
fi
done
echo "}"