TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The “Split Strings” Challenge Using Java

1 pointsby aoglalmost 5 years ago

1 comment

oldandtiredalmost 5 years ago
in unicon&#x2F;icon it would be<p>procedure StringSplit(str)<p><pre><code> # # define a local to hold an initial empty list # local l := list() # # if the length of the string is odd then concatenate an &quot;_&quot; character # str ||:= ((*str % 2 = 1) &amp; &quot;_&quot;) # # scan the string and put each two characters onto the end of the list # created above, fail when you reach the end of the string # str ? while put(l, move(2)) # # return the list to the calling program # return l end </code></pre> and for an example string of &quot;this is a string&quot; it will return the list [&quot;th&quot;, &quot;is&quot;, &quot; i&quot;, &quot;s &quot;, &quot;a &quot;, &quot;st&quot;, &quot;ri&quot;, &quot;ng&quot;]<p>and for an example string of &quot;this is a string2&quot; it will return the list [&quot;th&quot;, &quot;is&quot;, &quot; i&quot;, &quot;s &quot;, &quot;a &quot;, &quot;st&quot;, &quot;ri&quot;, &quot;ng&quot;, &quot;2_&quot;]<p>Nice and simple compared to the example given in Java.