# [R], 132 bytes This recursive approach is probably not the shortest way to do it, but it was fun to code up. -1 thanks @Giuseppe <!-- 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,,append(x,b,i))))))} [Try it online!][TIO-jo5ynbh9] [R]: https://www.r-project.org/ [TIO-jo5ynbh9]: https://tio.run/##PYy9CsJAEAafxau@hRUMWCl5CQv75LIHC2GT3A9cFJ/9DBZOM8XAxNZCH4r5rIvBeOw9HBw7csS1H@mtASejKLlEw0Om4gXrkLJcuBLd0xIziulW5NCsKWMe1nXekWRDJf7PlQLs3DEfWWxC5ZGVfnzaU3xeor4EgdDdrtS@ "R – Try It Online"