Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- title Spacing chalenge
- setlocal enabledelayedexpansion
- ::In response to Icarus's spacing challenge
- ::By Jahwi
- ::Another fun challenge.
- :a
- cls
- set /p input=Enter String:
- set space=
- set spacex=
- set v=
- ::determine the number of letters in the string
- echo !input!>!temp!\string.txt
- for %%? in (!temp!\string.txt) do ( set /a strlength=%%~z? - 2 )
- if !strlength! GTR 41 echo Invalid Input&&goto :a
- ::determine if length is even or odd and do stuff
- set /a tmpa=!strlength!/2
- set /a tmpb=!tmpa!*2
- if not "!tmpb!"=="!strlength!" set v=-1
- set /a tmpspace=41-!strlength!
- set /a spaceb=(!tmpspace!/2)!v!
- if "!tmpb!"=="!strlength!" (
- set /a spacec=!spaceb!-1
- )
- for /l %%a in (1,1,!spaceb!) do (
- set space=!space!
- )
- if not "!tmpb!"=="!strlength!" set spacex=!space!
- if "!tmpb!"=="!strlength!" (
- for /l %%b in (1,1,!spacec!) do (
- set spacex=!spacex!
- )
- )
- set variable=!input!
- ::if "!strlength!"=="
- echo #########################################
- echo # #
- echo # #
- echo # #
- echo # #
- echo # #
- echo # #
- echo # #
- echo #!space!!variable!!spacex!#
- echo # #
- echo # #
- echo # #
- echo # #
- echo # #
- echo # #
- echo # #
- echo # #
- echo #########################################
- pause
- goto :a
Advertisement
Add Comment
Please, Sign In to add comment