Nasamos

Birthday problem (reworked)

Nov 11th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.66 KB | None | 0 0
  1. :init
  2. @echo off
  3. setlocal EnableDelayedExpansion
  4. cls
  5. color 0F
  6. goto vars
  7.  
  8. :vars
  9. set loop=0
  10. set count=0
  11. set variable[]=0
  12. set increment=0
  13. goto start
  14.  
  15. :start
  16. for /l %%a in (0, 1, 23) do (
  17.     set /a variable[%%a]=!random! %%365 +1
  18. )
  19.  
  20. :compare
  21. if !increment! GEQ 24 (
  22.     set /a increment=0
  23.     set /a count+=1
  24. )
  25. if !count! GEQ 24 (
  26. goto nosuccess
  27. )
  28. if !count! EQU !increment! (
  29.     set /a increment+=1
  30.     goto compare
  31. )
  32. if !variable[%count%]! EQU !variable[%increment%]! (
  33. goto success
  34. ) else (
  35.     set /a increment+=1
  36.     goto compare
  37. )
  38.  
  39. :success
  40. color 02
  41. echo match found!
  42. pause
  43. goto init
  44.  
  45. :nosuccess
  46. color 04
  47. echo no match found!
  48. pause
  49. goto init
Advertisement
Add Comment
Please, Sign In to add comment