@echo off

rem =============================
rem =                           =
rem =    Test descriptions      =
rem =                           =
rem =============================

rem Tests   1-2      sample

SET PROBLEM_NAME=number
SET FIRST_GENERATED_TEST=3
SET EXECUTABLE=a.exe
SET MAXIMUM_TESTS=200

rem =============================
rem =                           =
rem =         Compiling         =
rem =                           =
rem =============================

echo Compiling...

dcc32 -CC gen_random >nul

rem =============================
rem =                           =
rem =       Delete files        =
rem =                           =
rem =============================

echo Deleting old files

del "%~dp0*.out" > nul

for /l %%i in (%FIRST_GENERATED_TEST%,1,%MAXIMUM_TESTS%) do (
  if exist %%i.in (
    del %%i.in > nul
  )
)

rem =============================
rem =                           =
rem =     Generating tests      =
rem =                           =
rem =============================

echo Generating tests...


gen_random 12 1234
gen_random 1 1234
gen_random 89 1
gen_random 89 99999
gen_random 89 99997
gen_random 02468 99997
gen_random 135 99997
gen_random 0123456789 99991
gen_random 0123456789 99997
gen_random 0123456789 77777
gen_random 012 99991
gen_random 56 99991
gen_random 45 99991
gen_random 179 99992
gen_random 123 99991
gen_random 123 1212
gen_random 369 7569
gen_random 025679 100
gen_random 025679 100000
gen_random 456 11117
gen_random 456 39117
gen_random 1789 98766
gen_random 15789 99766
gen_random 079 97758
gen_random 179 99999
gen_random 023456789 1
gen_random


rem =============================
rem =                           =
rem =      Making answers       =
rem =                           =
rem =============================

echo Getting answers with model solution

for /l %%i in (1,1,%MAXIMUM_TESTS%) do (
  if exist %%i.in (
    copy %%i.in %PROBLEM_NAME%.in > nul
    %EXECUTABLE% > nul
    copy %PROBLEM_NAME%.out %%i.out > nul
    del %PROBLEM_NAME%.in > nul
    del %PROBLEM_NAME%.out > nul
  )
)