This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programming Diversions and the fly likes [Easy]hyphen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "[Easy]hyphen" Watch "[Easy]hyphen" New topic
Author

[Easy]hyphen

Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1888
This one is quite easy.Actually subproblem from one programming competition.
Input: any String(containing combination of letters from a to z)
Output:String array,each string contains hyphen at different position
example:1) Input :a
output:-a,a-
2)Input aqw
output: -aqw,a-qw,aq-w,aqw-
Write a program.


MH
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632

[ October 07, 2004: Message edited by: Michael Dunn ]
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1888
.I never thought of StringBuffer
Luis F Garcia
Greenhorn

Joined: Oct 20, 2004
Posts: 6
Hi there !!

I know I'm late, I just registered and hadn't seen this forum...

Hope you like this one:



Cheers !!
Luis F
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1888

I checked all above three ways for different inputs.and checked the CPU usage and execution time.They are almost same.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: [Easy]hyphen
 
It's not a secret anymore!