#!/bin/bash
set -Eeuo pipefail
shopt -s extglob
max_clauses=$1
n_groups=$2
mkdir -p $3
for n_clauses in $(seq 2 $max_clauses)
do
  min_vars=$(echo "l($n_clauses)/l(2)" | bc -l | awk '{print int($1)+($1!=int($1)&&$1>0)}')
  max_vars=$(($n_clauses-2))
  for n_variables in $(seq $min_vars $max_vars)
  do
    for group_id in $(seq 0 $(($n_groups-1)))
    do
      basepath="$3/$n_clauses-$n_variables-$group_id-$n_groups"
      echo "-cAtd3:2" > "$basepath.txt"
      echo "-X6" >> "$basepath.txt"
      echo "$((2*$n_variables))" >> "$basepath.txt"
      echo "$n_clauses" >> "$basepath.txt"
      echo "$group_id/$n_groups" >> "$basepath.txt"
      echo "$basepath.graph" >> "$basepath.txt"
    done
  done
done
