# [R], 134 bytes This recursive approach is probably not the shortest way to do it, but it was fun to code up. <!-- language-all: lang-r --> f=function(n,b=c("(",")"),x=b){if(!n)return(Reduce(paste0,x));sort(unique(unlist(sapply(0:(n+1),function(i)f(n-1,x=append(b,x,i))))))} [Try it online!][TIO-jo5wcz6i] [R]: https://www.r-project.org/ [TIO-jo5wcz6i]: https://tio.run/##PYy9CsJAEAafxau@xRUSsIrkJSzsk8seLIRNvB9IFJ/9DBZOM80wsdbQh2I@62IwHnsPB8eOHPHWj/TWgJNRlFyi4S5T8YJ1SFka3ohuaYkZxfRZ5NCsKSMN6zrvaDrYuSX@35UC7NIe2yMQmzDyxko/PvUhPi9RX4JAaLsr1S8 "R – Try It Online"