SHARE
TWEET

Untitled

a guest Feb 27th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var str = "Hello, playground"
  2. var lRzecz = 1.12
  3. let individualScores = [75, 43, 103, 87, 12]
  4.  
  5. let stala1: Int = 1
  6. let stala2: Int = 2
  7. let stala3: Int = 4
  8.  
  9.  
  10. let a1 = str + " " + "\(stala1)"
  11. let a2 = str + " " + String(stala1)
  12. let a3 = "\(str) \(stala1)"
  13. var t1 = [75, 43, 103, 87, 12]
  14. let t2 = ["ala": 1, "lala": 2]
  15.  
  16. t1.append(23)
  17.  
  18. var lotto = ["29-11-14": [12, 32, 22, 42, 6, 4],
  19.     "29-11-15": [12, 14,15,15,1,2]]
  20.  
  21. var emptyT = [Character:Int]()
  22.  
  23. for k in 0...9{
  24.     emptyT[Character(UnicodeScalar(64 + k)!)] = k + 1
  25. }
  26.  
  27. print(emptyT)
  28.  
  29. for i in lotto.keys{
  30.     print("Losowanie z dnia \(i) \n")
  31.     for el in lotto[i]!{
  32.         print("\(el) \n")
  33.     }
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. func NWD(a_in: Int, b_in: Int) -> Int{
  42.     var a = a_in
  43.     var b = b_in
  44.     repeat
  45.     {
  46.         if (a>b) {a=a-b}
  47.         if (b>a) {b=b-a}
  48.        
  49.     }
  50.         while (a != b)
  51.     return a
  52. }
  53.  
  54. print("NDW 15 35: \(NWD(a_in:15, b_in:35))")
  55.  
  56.  
  57.  
  58. func NWDEX(a_in: Int, b_in: Int) -> (Int, Int, Int){
  59.     var a = a_in
  60.     var b = b_in
  61.     repeat
  62.     {
  63.         if (a>b) {a=a-b}
  64.         if (b>a) {b=b-a}
  65.        
  66.     }
  67.         while (a != b)
  68.     return (a, a_in / a, b_in / a)
  69. }
  70.  
  71. print("NDWEX 15 35: \(NWDEX(a_in:15, b_in:35))")
  72.  
  73. func coder(a:Character) -> Character{
  74.    
  75.     switch a {
  76.     case "G":
  77.         return "A"
  78.     case "D":
  79.         return "E"
  80.     case "R":
  81.         return "Y"
  82.     case "P":
  83.         return "O"
  84.     case "L":
  85.         return "U"
  86.     case "K":
  87.         return "I"
  88.     default:
  89.         return a
  90.     }
  91.    
  92. }
  93.  
  94.  
  95.  
  96. func cipher(msg: String, function: (Character) -> Character) -> String {
  97.     var upMsg = msg.uppercased()
  98.     var out = ""
  99.     for i in upMsg{
  100.         out = out + String(coder(a:i))
  101.     }
  102.     return out
  103. }
  104.  
  105. var message = "PALE ALE"
  106. print("Encoding message PALE ALE: \(cipher(msg: message, function: coder))")
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