GL1TCH3D

Icarus challenge

Jan 13th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. Title GL1TCH3D Challenge Submission for Icarus Lives' Challenge
  5. :top
  6. set /p number=What positive number would you like to start with?
  7. set num=%number: =%
  8. if not %num% GTR 0 cls&goto top
  9.  
  10. ::If your number is even, divide it by 2.
  11. ::If your number is odd, multiply it by 3, and add 1.
  12. ::Challenge ends when the script hits 1.
  13.  
  14. ::The process to be used for determining even or odd is that batch always rounds down.
  15. ::A number divided by two will be compared to the original number added with 3, divided by 2 then subtracted by 1.
  16. ::An odd number will go up by 1 while an even number will only go up by 0 after subtracting 1.
  17. set step0=%num%
  18. set prev=%num%
  19. for /l %%a in (1,1,100000) do (
  20. set step%%a=!prev!
  21. set /a tempnum1=!prev! / 2
  22. set /a tempnum2=!prev! + 3
  23. set /a tempnum2=!tempnum2! / 2
  24. set /a tempnum2=!tempnum2! - 1
  25. if !tempnum1!==!tempnum2! set /a step%%a=!step%%a! / 2
  26. if not !tempnum1!==!tempnum2! set /a step%%a=!step%%a! * 3 + 1
  27. if !step%%a!==1 set total=%%a & goto end
  28. set prev=!step%%a!
  29. )
  30.  
  31. :end
  32. echo Your chosen number = %number%
  33. echo The number of steps = %total%
  34. set list=%num%
  35. for /l %%b in (1,1,%total%) do (
  36. set list=!list!, !step%%b!
  37. )
  38. echo All steps = %list%
  39.  
  40. pause > nul
Advertisement
Add Comment
Please, Sign In to add comment