Solved Why didn't it work ok there? At home it worked beautifully

March 23, 2020 at 16:17:51
Specs: Windows 10
Why didn't it work ok there? At home it worked beautifully

Hey, Hedda63 - at home it worked for multi strings - here's an example


reverse3 Mary had a little lamb it's fleece was green as grass the lamb went outside and fell on it's back foot
toof kcab s'ti no llef dna edistuo tnew bmal eht ssarg sa neerg saw eceelf s'ti bmal elttil a dah yraM

@echo off
:: reverse.bat

if [%1] neq [] goto start

echo Reverse Given Text
echo Usage: %0 text

goto :end

set _len=0
set _str=%*

:: Get the length of the sentence
set _subs=%_str%

if not defined _subs goto :result

::remove the first char
set _subs=%_subs:~1%
set /a _len+=1
goto loop

set /a _len-=1
for /l %%g in (0,1,%_len%) do (
call :build %%g

echo %s%

goto :end

:: get the next character
call set _digit=%%_str:~%1,1%%%
set s=%_digit%%s%


It should work on multi strings, as above

See More: Why didnt it work ok there? At home it worked beautifully

Reply ↓  Report •

March 23, 2020 at 16:27:47
✔ Best Answer
This might work. Note that the input has to be enclosed in double-quotes.
@echo off & setlocal
set k=%~1
if not defined k (
echo usage: %0 "string_to_be_reversed"
echo output is to stdout
goto :eof
set rev=
set rev=%rev%%k:~-1%
set k=%k:~0,-1%
if defined k goto :1
echo reversed string:
echo %rev%

Reply ↓  Report •

March 25, 2020 at 08:13:05
Nbrane's solution is pretty good.. This place sure has some sharp people there. Kudos to you all.
Give me a simple challenge, and it'll take a week or more, and I still probably wouldn't get it right - you guys, two days and you roll out masterpieces. You guys are the elites.

Reply ↓  Report •

March 25, 2020 at 09:14:01
I tend to be more of a machine gun, nbrane is a sniper.

I guess with age i'll get more precise and let impulsive.


Reply ↓  Report •
Related Solutions

Ask Question