SHARE
TWEET

Untitled

a guest Oct 21st, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func Euler19() {
  2.    
  3.     var dayOfWeek = 3
  4.     var count = 0
  5.     var febDays = 28
  6.     let daysInMonth = [31, febDays, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  7.    
  8.  
  9.        
  10.         for y in 1901...2000 {
  11.         for m in 1...12 {
  12.         for d in 1...7 {
  13.  
  14.             if m == 2 && y % 4 == 0 {
  15.                 febDays = 29
  16.             }
  17.             else {
  18.                 febDays = 28
  19.             }
  20.            
  21.             dayOfWeek = (d+daysInMonth[m]) % 7
  22.            
  23.             if dayOfWeek == 0 {
  24.                 count += 1
  25.             }
  26.  
  27.             }
  28.             }
  29.     }
  30.    
  31.     print(count)
  32.    
  33. }
  34.  
  35. 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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top