Advertisement
Guest User

Riddle

a guest
Sep 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.44 KB | None | 0 0
  1. import Foundation
  2.  
  3. var currentLampState = [Bool](count: 100, repeatedValue: false)
  4. var switchingLamp : [Bool] = []
  5. for i in 1 ... 100 {
  6.     for j in 1 ... 100 {
  7.         let switchState = (j % i) == 0
  8.         switchingLamp.append(switchState)
  9.     }
  10.     let newState = zip(currentLampState, switchingLamp).map{$0 != $1}
  11.     currentLampState = newState
  12.     switchingLamp.removeAll()
  13. }
  14. print("new state : \(currentLampState) EoN \n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement