SATURN  RING  STATION

At a distant space view post, we chat about codes.

r/dailyprogrammer series 001: generating Baum–Sweet sequence

I really like r/dailyprogrammer, started a series posting my solutions/thoughts.

 

 

[2017-12-11] Challenge #344 [Easy] Baum-Sweet Sequence

Wikipedia: Baum-Sweet sequence

 

 

get1 method is my first draft in Java, get2 is a better version by another redditor with similar approach.

 

 

Then I looked at the others’ stream approach utilizing the String split() method. Really learnt something here. For simplicity, it doesn’t handle the n = 0 special case.

 

Here is a JavaScript version with split() and arrow function.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

r/dailyprogrammer series 001: generating Baum–Sweet sequence