SHARE
TWEET

Untitled

a guest Oct 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func Euler19() {
  2.    
  3.     var dayOfWeek = 3
  4.     var month = 1
  5.     var date = 1
  6.     var year = 1901
  7.     var count = 0
  8.     for _ in 1...36525 {
  9.        
  10.         if dayOfWeek == 7 {
  11.         dayOfWeek == 1
  12.         }
  13.         else  {
  14.             dayOfWeek += 1
  15.         }
  16.        
  17.         if month == 12 {
  18.         month == 1
  19.         }
  20.        
  21.         if date == 31 && (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10) {
  22.         month += 1
  23.         }
  24.         else if date == 30 && (month == 4 || month == 6 || month == 9 || month == 11) {
  25.             month += 1
  26.         }
  27.         else if date == 28 && month == 2 && year % 4 != 0 {
  28.             month += 1
  29.         }
  30.         else if date == 29 && month == 2 && year % 4 == 0 {
  31.             month += 1
  32.         }
  33.         else if date == 31 && month == 12 {
  34.             month == 1
  35.             year += 1
  36.         }
  37.        
  38.         if dayOfWeek == 1 && month == 1 {
  39.             count += 1
  40.         }
  41.        
  42.         if year == 2000 && date == 31 && month == 12 {
  43.             print(count)
  44.             break
  45.         }
  46.        
  47.     }
  48.    
  49. }
  50.  
  51. Euler19()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top