Over a million developers have joined DZone.

Thursday Code Puzzler: Sentence Spacer

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

t's Thursday, so it's time for another code puzzler. The idea is simple: solve the coding problem as efficiently as you can, in any language or framework that you find suitable.

Note: Even though there really is nothing stopping you from finding a solution to this on the internet, try to keep honest, and come up with your own answer.  It's all about the participation!

Build up A Sentence From A Word Without Spaces 

Create a method that will take a string parameter with no spaces, and adds spaces in appropriate places to create a sentence. You can assume a dictionary of words is provided. 

Example input could be 'dzonepublishcodepuzzlerseverythursday' which would produce 'dzone publish code puzzlers every thursday'.

Keep in mind that, although you can take a simple approach, it would be cool if: 

  • Your solution realises that multiples (i.e. trailing 's') would probably not be in the dictionary 
  • Logic could be added to determine if the generated sentence makes sense or not.

Catch up on all our previous puzzlers here

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}