Code: Select all
@echo off
set /a iteration=0
:S
echo #
echo # #
echo # #
echo # #
echo # DISCO! #
echo # #
echo # #
echo # #
echo #
call :col %iteration%
set /a iteration=%iteration% + 1
cls
if %iteration% == 6 set iteration=0
goto s
:col
if %~1 == 0 color a
if %~1 == 1 color b
if %~1 == 2 color c
if %~1 == 3 color d
if %~1 == 4 color e
if %~1 == 5 color f
ping 127.0.0.1 -n 1 >nul
exit /b 0
It's simple, easy to read, and easy to understand what it's doing. However, it comes in at around 593 bytes!
My goal is to ask how you would potentially compress it down as much as possible.
Please compress the above batch file, and then share what you did to compress it down as much as possible, and the byte size. File must use \r\n as newlines, I'm considering removing \r as cheating.
Here's my take on it, and an example as to what your posts should be:
Code: Select all
@echo off
set "s= set/a i="&set n=^&echo&set "e= == "&set "c= color "&set "a= "&set "p=%a% "
%s%0
:s
echo%p%%a% #%n%%p%%a% # #%n%%p% #%a% #%n%%p% #%a%%a% #%n%%p%#%a%DISCO! #%n%%p% #%a%%a% #%n%%p% # %a%#%n%%p%%a% # #%n%%p%%a% #
if %i%%e%0%c%a
if %i%%e%1%c%b
if %i%%e%2%c%c
if %i%%e%3%c%d
if %i%%e%4%c%e
if %i%%e%5%c%f
ping ::1 -n 1 >nul&%s%%i%+1
cls&if %i%%e%6%s%0
goto s
As you can see, I've declared at the top of the file, a large chunk of sets. These are to set variables to save on space, e.g. replacing 13 charecter spaces with 3 byte variables.
I've replaced the condition if statements, %e% to represent ' == ' and %c% to represent ' color '. This assists on saving some bytes. I set %s% to ' set/a i=' to assist with the last conditional if statement, as well as any other instances where setting the iteration would be useful. 'iteration' has been shortened down to 'i', and all the 'echo's are shoved into one line. I removed the call :col statement, however by doing that that increases the speed of the application, making the lights flash faster then needed. I suppose you could still have a :call though.
I don't remember what else I did though, but in total, it went from 593 bytes down to 410! I was almost able to get it down to 406 but the application didn't work at that point.
------------
So does anybody wanna try take on this 'challenge'? I'd like to see how you'd approach this problem.