5 added 11 characters in body

Thanks @nimi for saving a few bytes!

import Data.List
f n=head.(n=iterate h[[""]]!!n)$iterate h[[""]]!!0  First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion. This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words between paranthesis, or by concatenating from shorter Dyck words. This approach however does generate duplicates, that is why we filter for unique elements using nub. As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules. # Haskell, 140 bytes import Data.List h s|m<-length s=nub[k|l<-head s,k<-("("++l++")"):[u++v|n<-[0..m-2],u<-s!!n,v<-s!!(m-2-n)]]:s f n=head.(!!n)$iterate h[[""]]


First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion.

This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words between paranthesis, or by concatenating from shorter Dyck words. This approach however does generate duplicates, that is why we filter for unique elements using nub.

As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules.

Thanks @nimi for saving a few bytes!

import Data.List
h s|m<-length s=nub[k|l<-s!!0,k<-('(':l++")"):[u++v|n<-[0..m-2],u<-s!!n,v<-s!!(m-2-n)]]:s
f n=iterate h[[""]]!!n!!0


First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion.

This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words between paranthesis, or by concatenating from shorter Dyck words. This approach however does generate duplicates, that is why we filter for unique elements using nub.

As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules.

Post Undeleted by flawr
4 added 52 characters in body

import Data.List
f n=head.(!!n)$iterate h[""]h[[""]]  First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion. This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words after, in between paranthesis, or before a pair of opening and closing parenthesisby concatenating from shorter Dyck words. This approach however does generate duplicates, that is why we filter for unique elements using nub. With the elimination of duplicates at each recursion step (duplicates among a list of length 3) this approach is quite efficient. As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules. # Haskell, 84 bytes import Data.List h s=[k|l<-s,k<-nub["()"++l,"("++l++")",l++"()"]] (!!)$iterate h[""]


First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion.

This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words after, in between or before a pair of opening and closing parenthesis. This approach however does generate duplicates, that is why we filter for unique elements using nub. With the elimination of duplicates at each recursion step (duplicates among a list of length 3) this approach is quite efficient.

As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules.

import Data.List
f n=head.(!!n)$iterate h[[""]]  First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion. This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words between paranthesis, or by concatenating from shorter Dyck words. This approach however does generate duplicates, that is why we filter for unique elements using nub. As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules. Post Deleted by flawr 3 added 156 characters in body # Haskell, 84 bytes import Data.List h s=[k|l<-s,k<-nub["()"++l,"("++l++")",l++"()"]] (!!)$iterate h[""]


First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion.

This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words after, in between or before a pair of opening and closing parenthesis. This approach however does generate duplicates, that is why we filter for unique elements using nub. With the elimination of duplicates at each recursion step (duplicates among a list of length 3) this approach is quite efficient.

As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules.

import Data.List
h s=[k|l<-s,k<-nub["()"++l,"("++l++")",l++"()"]]
(!!)$iterate h[""]  First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion. This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words after, in between or before a pair of opening and closing parenthesis. This approach however does generate duplicates, that is why we filter for unique elements using nub. With the elimination of duplicates at each recursion step (duplicates among a list of length 3) this approach is quite efficient. # Haskell, 84 bytes import Data.List h s=[k|l<-s,k<-nub["()"++l,"("++l++")",l++"()"]] (!!)$iterate h[""]


First of all: iterate does create a recursion sequecnce of h, but this is a builtin, and by the rules we may use builtins that use recursion.

This is just a very simple recursive approach, we can generate the n-Dyck-words by putting (n-1)-Dyck-words after, in between or before a pair of opening and closing parenthesis. This approach however does generate duplicates, that is why we filter for unique elements using nub. With the elimination of duplicates at each recursion step (duplicates among a list of length 3) this approach is quite efficient.

As Haskell is a functional language, it is almost impossible to do this without recursion. There is an even more direct approach, but that one is banned under the current rules.

Post Undeleted by flawr
2 added 156 characters in body
Post Deleted by flawr
1