Page 1 of 1

Fast String Reversal

Posted: Wed Dec 31, 2008 4:06 pm
by MagneticMonopole
Reverse an input string of length 100 in 60 cycles?
I am very, very amazed.

Posted: Wed Dec 31, 2008 6:43 pm
by therethinker
The trick: threading. It takes only 1 cycle to run thousands of threads.

Posted: Wed Dec 31, 2008 8:21 pm
by efe
But you can only create 32 threads!
How can you keep them synchronized?

Posted: Wed Dec 31, 2008 8:26 pm
by therethinker
Good point. I guess I was being a bit too dramatic :P

I think I have a basic understanding of how it's done, but I won't spoil the fun ;-)

Posted: Wed Dec 31, 2008 9:42 pm
by ShardFire
I did a rewrite of the program using a superior technique and cut 20% more off that time. It may be possible to make it even shorter still using some sort of hybrid/alternative method or other optimizations, but I think I'll stay with what I've got for now... :wink: I'm sure someone will still be able to beat me while I have a suboptimal solution, so until then...!

Posted: Wed Jan 06, 2016 4:30 pm
by Hippo
My first threaded functional version uses 34 cycles ... % is count as a cycle as well :(

I have some trick in sleeve ... not working in java version, but getting under 27 ?!

OK, I am on 33 now. And now on 32.

Codding in excell is more convenienet than in notepad ...
I have finished SuperHack debugger in Excell VBA, it helps in debugging, but not producing codding ideas.

(32 works for inputs of length upto 108)

I could probably evolve to 31, but I should make higher changes to reach required 29.

Already on 30 :) ... works for inputs of length upto 112 ... and now till 120 and now 122 ... 124

:) I had to add several blank lines to my code :)
And I have 29 ... upto 96

So finally on 29,117 ... and the input length could be prolonged a bit.

Oops php implementation differs from what I have expected :( ... back to codding
... no that was just wrongly sent solution...