Advertisement
GL1TCH3D

maze

Jan 20th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. ::This is all used to take the text from the file and parse it into individual lines
  5. ::temp.t is used because if the file name has spaces, it will create an error
  6. ::in the for loop
  7. set linenum=0
  8. copy "%~1" "temp.t" /Y >nul
  9. set file=%~1
  10. for /f "tokens=*" %%a in (temp.t) do (
  11. set /a linenum=!linenum!+1
  12. set line!linenum!=%%a
  13. )
  14. del temp.t
  15. for /l %%b in (1,1,%linenum%) do (
  16. echo !line%%b!
  17. )
  18. set /a linetemp=1
  19. :calculate
  20. for /l %%z in (0,1,10000) do (
  21. if "!line%linetemp%:~%%z,1!"=="" set total!linetemp!=%%z &goto next1
  22. )
  23. :next1
  24. echo !total%linetemp%!
  25. if "%linetemp%"=="%linenum%" goto next2
  26. set /a linetemp+=1
  27. goto calculate
  28.  
  29. :next2
  30. for /l %%e in (%linenum%,-1,1) do (
  31. set /a tempnum=%%e-1
  32. for /l %%f in (1,1,!tempnum!) do (
  33. if not "!total%%e!"=="!total%%f!" goto notrectangle
  34. )
  35. )
  36.  
  37. pause
  38.  
  39. ::Since I know for later scripting it will be easier if each character is set to a variable
  40. ::All the variables will be set according to a row / column set
  41. ::mrXcY
  42. ::The var total is calculated from earlier and is the length of the first line of the maze
  43. ::The following for loop will set the lines based on the length of the first line calculated
  44. ::This introduces a slight flaw that if the first line is
  45.  
  46. for /l %%c in (1,1,%linenum%) do (
  47. for /l %%d in (1,1,!total%%c!) do (
  48.  
  49.  
  50.  
  51. pause > nul
  52. exit /b
  53.  
  54. :notrectangle
  55. echo Bitch that ain't no rectangular maze.
  56. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement