# [R], 133 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(lapply(seq(x),function(i)f(n-1,x=append(x,b,i))))))} [Try it online!][TIO-jo5xz5fi] [R]: https://www.r-project.org/ [TIO-jo5xz5fi]: https://tio.run/##PYy9CsJAEAafxau@hRUMWCl5CQv75LIHC2GT3A9cFJ/9DBZOM8XAxNZCH4r5rIvBeOw9HBw7csS1H@mtASejKLlEw0Om4gXrkLJcuBLd0xIziulW5NCsKWMe1nXekWRDJf7PlQLs3B3Xo4tNqDyy0o9Pe4rPS9SXIBC625XaFw "R – Try It Online"