Solution to a recursive problem (code kata)

Source code

// str is the string that's been built so far.
// limit is the total number of bracket pairs
// e.g. initial call: brackets('', 3)
function brackets(str, limit)
    // rules
    // if brackets in str balance (includes empty str), must
    //   have open bracket
    // if all open bracket used, must have close bracket 
    // otherwise, can have either bracket

    if (str.length == 2 * limit)
        return str;

    var open = close = 0;

    for (i = 0; i < str.length; i++)
        if (str[i] == '(')
        else if (str[i] == ')')

    if (open == close)
        return brackets(str + '(', limit);
    else if (open == limit)
        return brackets(str + ')', limit);
        return new Array(brackets(str + '(', limit),
                         brackets(str + ')', limit));



Fri 12 Dec 2014 11:27

much does cialis cost

much does cialis cost said:

I am regular visitor, how are you everybody?

This post posted at this website is really


Sat 13 Dec 2014 18:02

canada cialis generic

canada cialis generic said:

Hi there, You have done a fantastic job. I’ll certainly digg it and personally

suggest to my friends. I’m sure they will be benefited from this

web site.

Tue 16 Dec 2014 13:57

buying cialis online canada

buying cialis online canada said:

My brother suggested I may like this website. He was totally right.

This submit truly made my day. You can not believe just how so much time I had spent for this info!


Tue 16 Dec 2014 19:09

cialis generic pharmacy

cialis generic pharmacy said:

When someone writes an piece of writing he/she maintains the plan of a

user in his/her brain that how a user can understand it. Therefore that’s why this post is amazing.


Thu 18 Dec 2014 09:35

canadian cialis

canadian cialis said:

You really make it appear really easy along with your presentation however I find this matter to be really something that I believe I’d never understand.

It seems too complex and very extensive for me. I’m taking a look ahead

to your next publish, I will attempt to get the cling of it!

Tue 23 Dec 2014 08:34

generic cialis from canada

generic cialis from canada said:

Definitely believe that which you said. Your favorite reason seemed to be on the web the simplest thing to be aware of.

I say to you, I certainly get irked while people consider

worries that they plainly don’t know about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects ,

people can take a signal. Will probably be back to get more.


Wed 24 Dec 2014 08:54

cialis dosage side effects

cialis dosage side effects said:

I think this is among the most vital information for me.

And i’m glad reading your article. But wanna remark on some general things, The web site style is perfect, the articles

is really great : D. Good job, cheers

Tue 30 Dec 2014 01:39

buy cialis canada

buy cialis canada said:

Very nice post. I just stumbled upon your blog and wished to say that I have really enjoyed surfing around your blog posts.

In any case I will be subscribing to your feed and I hope you write again soon!

Tue 30 Dec 2014 07:48

canadian pharmacy viagra

canadian pharmacy viagra said:

Thanks in support of sharing such a pleasant thinking, piece of

writing is pleasant, thats why i have read

it completely

Tue 30 Dec 2014 12:41

viagra for sale to canada

viagra for sale to canada said:

Pretty! This was a really wonderful article. Many thanks for supplying these details.

Thu 1 Jan 2015 02:12

drugstore online

drugstore online said:

Appreciation to my father who stated to me on the topic of this blog, this blog is really amazing.

Thu 8 Jan 2015 13:58

cialis in canada

cialis in canada said:

Heya i’m for the primary time here. I came across this board and I to find

It really useful & it helped me out a lot. I’m hoping to provide something back

and aid others like you helped me.

Sat 10 Jan 2015 16:25

cialis from canada

cialis from canada said:

Thanks for some other informative blog. Where else may I get that kind of information written in such a perfect approach?

I've a venture that I’m simply now working on, and I've been on the look

out for such information.

Mon 12 Jan 2015 07:01

canadian pharmacy

canadian pharmacy said:

Hi there! I know this is kind of off topic but I was wondering if you knew where I could

find a captcha plugin for my comment form? I’m using the

same blog platform as yours and I’m having problems finding one?

Thanks a lot!

Sat 17 Jan 2015 09:38

Viagra cialis levitra canada

Viagra cialis levitra canada said:

May I simply just say what a relief to uncover an individual who

actually understands what they’re discussing on the web.

You definitely realize how to bring a problem to light and make it important.

A lot more people need to read this and understand this side

of your story. I can’t believe you aren’t more popular since you certainly have the gift.

Tue 20 Jan 2015 23:17

buy cialis from canada online

buy cialis from canada online said:

Hello, just wanted to say, I enjoyed this post. It was practical.

Keep on posting!

Wed 21 Jan 2015 09:34

cialis canada

cialis canada said:

Good day! Do you know if they make any plugins to protect against hackers?

I’m kinda paranoid about losing everything I've worked hard on. Any


Fri 23 Jan 2015 11:16

north west pharmacy canada

north west pharmacy canada said:

The Generic pharmacy is basically reasonably priced regardless if you

are from whichever parts of the culture.

The cost is affordable for anyone and everyone; you will need to drive of buying it.

When decision is manufactured, look for the suitable store.

After purchasing the medication, you will have utilized it.

Just consume the products with plain mineral water.

drugs medications

Wed 4 Feb 2015 17:43

canadian pharmacy with cialis

canadian pharmacy with cialis said:

Hello there! I could have sworn I've been to this web site before but after browsing through a few of the articles I realized it’s new to

me. Regardless, I’m definitely delighted I came across it and

I’ll be book-marking it and checking back regularly!

Sun 15 Feb 2015 09:13

drugs canada

drugs canada said:

I am not sure where you are getting your information, but great topic.

I needs to spend some time learning much more or understanding more.

Thanks for wonderful information I was looking for this info for

my mission.

Fri 20 Feb 2015 14:04

buy cialis in canada online

buy cialis in canada online said:

Hmm is anyone else having problems with the images on this blog loading?

I’m trying to find out if its a problem on my end or if it’s the blog.

Any suggestions would be greatly appreciated.

Mon 23 Feb 2015 00:30

how to buy cialis in canada

how to buy cialis in canada said:

I’ll right away take hold of your rss as I can not to find your email subscription link

or e-newsletter service. Do you have any? Kindly allow me know so that I could subscribe.


Tue 24 Feb 2015 02:04

online prescription

online prescription said:

It’s not my first time to visit this web site, i am visiting

this web page dailly and take fastidious information from here daily.

Sun 15 Mar 2015 09:31

canadian pharmacy

canadian pharmacy said:

I every time spent my half an hour to read this website’s articles

or reviews all the time along with a mug of coffee.

Wed 25 Mar 2015 14:33

online prescription

online prescription said:

Way cool! Some extremely valid points! I appreciate you writing this article

and the rest of the website is also really good.

Thu 2 Apr 2015 13:56

ed treatments

ed treatments said:

What’s up mates, its impressive post about educationand

completely explained, keep it up all the time.

Thu 2 Apr 2015 17:57


levitra said:

It’s in reality a great and helpful piece of information. I’m satisfied

that you shared this helpful information with us. Please

stay us up to date like this. Thank you for sharing.

Thu 2 Apr 2015 21:07

buy cialis online

buy cialis online said:

I have been surfing on-line more than three hours today,

but I never found any attention-grabbing article like

yours. It is lovely value sufficient for me. In my opinion, if all webmasters and bloggers made excellent content material as you

probably did, the internet can be much more helpful than ever before.

Fri 3 Apr 2015 04:40

levitra coupon

levitra coupon said:

you’re in point of fact a just right webmaster. The site

loading velocity is incredible. It seems that you

are doing any unique trick. Moreover, The contents

are masterwork. you have done a great task on this topic!

Mon 6 Apr 2015 16:33

ed medication

ed medication said:

Whats up are using Wordpress for your blog platform?

I’m new to the blog world but I’m trying to get started

and create my own. Do you require any html coding expertise

to make your own blog? Any help would be greatly appreciated!

Sat 11 Apr 2015 03:44

dyson dc62

dyson dc62 said:

Hi, i feel that i noticed you visited my blog thus i got here to go back the

choose?.I am trying to to find issues to improve my website!I assume its good enough to use a few

of your ideas!!

Wed 29 Apr 2015 17:34

canada pharmacy online viagra

canada pharmacy online viagra said:

Hello, I enjoy reading through your article. I like to write a little comment to

support you.

Tue 5 May 2015 04:57

Dyson Vacuum

Dyson Vacuum said:

Hurrah, that’s what I was seeking for, what a

material! existing here at this website, thanks admin of this site.

Wed 6 May 2015 00:43

Canada cialis sale

Canada cialis sale said:

Excellent goods from you, man. I have understand your stuff previous to and

you’re just too great. I really like what you have acquired here, certainly like what you are stating and the way in which

you say it. You make it entertaining and you still care for to

keep it smart. I cant wait to read much more from you.

This is actually a tremendous website.

Thu 7 May 2015 03:27

Best canadian pharmacy for cialis

Best canadian pharmacy for cialis said:

I blog often and I seriously appreciate your content. This great article has really peaked my interest.

I’m going to take a note of your website and keep checking for new details about once a week.

I opted in for your RSS feed too.

Fri 8 May 2015 13:23

Canadian pills

Canadian pills said:

Helpful information. Fortunate me I found your web site by chance,

and I’m stunned why this twist of fate did not happened in advance!

I bookmarked it.

Sat 9 May 2015 19:14

Canada pharmacy cialis online

Canada pharmacy cialis online said:

Howdy! This blog post could not be written much better!

Reading through this post reminds me of my previous roommate!

He constantly kept talking about this. I will send this post to him.

Pretty sure he’s going to have a great read. Thank you for sharing!

Sat 9 May 2015 19:51

Canadian viagra cheap

Canadian viagra cheap said:

Helpful information. Fortunate me I found your website accidentally,

and I’m stunned why this accident didn’t happened in advance!

I bookmarked it.

Fri 15 May 2015 14:48

daily use cialis cost

daily use cialis cost said:

Howdy! This article couldn’t be written much better!

Going through this article reminds me of my previous roommate!

He continually kept preaching about this. I am

going to forward this post to him. Pretty sure he'll have a very good read.

Thank you for sharing!

Sat 16 May 2015 12:01

Canadian Pharmacy

Canadian Pharmacy said:

Hi there! Someone in my Facebook group shared this website with us so I came to look

it over. I’m definitely enjoying the information.

I’m book-marking and will be tweeting this to my followers!

Excellent blog and wonderful design and style.

Sun 17 May 2015 12:56

canadian pharmacy

canadian pharmacy said:

Thanks for another wonderful article. The place else may

anyone get that kind of information in such a perfect means of

writing? I have a presentation subsequent week, and I am at the look

for such information.

Tue 19 May 2015 21:42

www cvspharmacy com

www cvspharmacy com said:

Hi mates, how is the whole thing, and what you wish for to

say concerning this article, in my view its truly

amazing for me.

Leave a comment