Skip to content

Instantly share code, notes, and snippets.

@sleepless-p03t sleepless-p03t/oof.bat
Last active Oct 22, 2019

Embed
What would you like to do?
Batch roundabout sys32
@echo off
:: Patterns for setting and expanding variables, based on a depth of 5
:: V(n) is a set representing the variable depth
:: V(0) = 0
:: V(1) = 1
:: V(2) = !1 -> V(2-1) * 3 - 2 = 1 * 3 - 2 = 1
:: V(3) = !5 -> V(3-1) * 3 + 2 = 1 * 3 + 2 = 5
:: V(4) = !13 -> V(4-1) * 3 - 2 = 5 * 3 - 2 = 13
:: V(n) = V(n-1) * 3 - 2; n is even; n > 1
:: V(n) = V(n-1) * 3 + 2; n is odd; n > 1
:: E(n) is a set representing variable expansion depth
:: E(0) = !(1)
:: E(1) = 3 -> E(1-1) * 2 + 1 = 1 * 2 + 1 = 3
:: E(2) = 7 -> E(2-1) * 2 + 1 = 3 * 2 + 1 = 7
:: E(3) = 15 -> E(3-1) * 2 + 1 = 7 * 2 + 1 = 15
:: E(4) = 31 -> E(4-1) * 2 + 1 = 15 * 2 + 1 = 31
:: E(n) = E(n-1) * 2 + 1; n > 0
:: Level 3
echo Level 3:
setlocal EnableDelayedExpansion
set a0=win
set %a0%=sys
call set !%a0%!=dir
call call set x=!a0!%%%a0%%%%%%%%%%a0%%%%%%%
for /f %%n in ('call echo %%%x%%%') do (
echo %%n
)
echo.
echo Level 4:
:: Level 4
setlocal EnableDelayedExpansion
set a0=wi
set %a0%=n
call set !%a0%!=sys
call call set !%%%%%a0%%%%%!=dir
call call call set x=!a0!%%%a0%%%%%%%%%%a0%%%%%%%%%%%%%%%%%%%%%%a0%%%%%%%%%%%%%%%
for /f %%n in ('call echo %%%x%%%') do (
echo %%n
)
echo.
echo Level 5:
:: Level 5
setlocal EnableDelayedExpansion
set a0=w
set %a0%=i
call set !%a0%!=n
call call set !%%%%%a0%%%%%!=sys
call call call set !%%%%%%%%%%%%%a0%%%%%%%%%%%%%!=dir
call call call call set x=!a0!%%%a0%%%%%%%%%%a0%%%%%%%%%%%%%%%%%%%%%%a0%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%a0%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for /f %%n in ('call echo %%%x%%%') do (
echo %%n
)
exit /B
:: Result %%n is the value of winsysdir in every instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.