Perl, 78 bytes ====== Includes `+2` for `lp` The input on STDIN is the sequence number, so `1` for `2` seats, `2` for 4 seats, `3` for `8` seats etc. perl -lpe '$"="\\ ";@F=($n=@F+1,map{;"{0,$n}+$_",$n}@F)for 1..$_}for(<@F>){s/\S+/$&/gee' <<< 3 This doesn't feel optimal at all... (assuming it is even correct)