Solved Choosing from set list with batch file?

December 4, 2012 at 20:10:53
Specs: Windows 7
I need a batch file that generates a random 5 of the following:
x, xx, xxx, xxxx, xxxxx, xxxxxx, xxxxxxx, xxxxxxxx, xxxxxxxxx
If possible i would rather the ones with fewer x's to have a higher chance of being chosen.

An example outcome could be: xxx xxxxx xx xx x

See More: Choosing from set list with batch file?

Report •

December 4, 2012 at 22:06:06
✔ Best Answer
No clue how to weigh the results towards smaller values (I flunked statistics 101).
Here's a stab at a possible attempt at an approach to a solution that won't work:
::===== begin batchscript
@echo off & setlocal enabledelayedexpansion
set x=xxxxxxxxx
set u=
for /L %%j in (1,1,5) do (
for /L %%i in (1,1,9) do (
set a=%%i
if %%i equ 9 set a=5
if %%i equ 1 set a=9
if %%i equ 4 set a=7
call :xx
goto :display
set /a z=%random%"%%"a
set /a z+=1
set t=!x:~0,%z%!
set u=%u% %t%
goto :eof

echo %u%

Report •

December 5, 2012 at 13:57:23
Thanks! Works perfectly.

Report •
Related Solutions

Ask Question