Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. import Foundation
  2.  
  3. // July 1, 2019
  4. print([109, 111, 105, 110].map { String(UnicodeScalar($0)) }.joined())
  5.  
  6. // July 2, 2019
  7. var hex: UInt32 = 0x6E696F6D
  8. let data = Data(bytes: &hex, count: MemoryLayout<UInt32>.size)
  9. String(data: data, encoding: String.Encoding.ascii)
  10.  
  11. // July 3, 2019
  12. import PeriodicTable
  13. (Elements.molybdenum.symbolValue + Elements.indium.symbolValue).lowercased()
  14.  
  15. // July 4, 2019
  16. print("npjo".map { String(UnicodeScalar(($0.asciiValue ?? 0).advanced(by: -1))) }.joined())
  17.  
  18. // July 5, 2019
  19. var str = "cosmo sagt: einen guten morgen euch allen"
  20. .replacingOccurrences(of: "[a-h|j-l|p-z|:|\\s]*", with: "", options: .regularExpression)
  21. print(str[str.index(str.startIndex, offsetBy: 1)..<str.index(str.startIndex, offsetBy: 5)])
  22.  
  23. // July 6, 2019
  24. var parts = Array("nimo")
  25. repeat { parts.shuffle() } while Data(String(parts).utf8).base64EncodedString() != "bW9pbg=="
  26. print(String(parts))
  27.  
  28. // July 7, 2019
  29. print(["monstrous", "objectionable", "insipiring", "nonsense"].reduce("") { $0 + $1.prefix(1) })
  30.  
  31. // July 8, 2019
  32. let symbols: [Character] = ["🤑", "👌", "📥", "🤢"]
  33. print(symbols.reduce("") { $0 + ($1.unicodeScalars.first?.properties.name?.prefix(1))! }.lowercased())
  34.  
  35. // July 9, 2019
  36. "bier".replacingOccurrences(of: "bier", with: "moin")
  37.  
  38. // July 10, 2019
  39. var str = NSURLCredentialStorageRemoveSynchronizableCredentials
  40. .lowercased()
  41. .replacingOccurrences(of: "[a-h|j-l|p-z]*", with: "", options: .regularExpression)
  42. str.removeFirst(1)
  43. str.removeLast(7)
  44. print(String(str.reversed()))
  45.  
  46. // July 11, 2019
  47. print([["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]].map { $0.count }.reduce("", { $0 + String(UnicodeScalar($1)!) }))
  48.  
  49. // July 12, 2019
  50. print(([Int(1), Int(2), Int(3), Int(4)].map({
  51. if $0 == 1 { return $0 << 6 + $0 << 5 + 13 }
  52. else if $0 == 2 { return $0 * 3 + 105 }
  53. else if $0 == 3 { return $0 * 35 }
  54. else { return $0 / 2 * 55 }
  55. }) as [Int]).reduce("", { $0 + String(UnicodeScalar($1)!) }))
  56.  
  57. // July 13, 2019
  58. String("niom".reversed())
  59.  
  60. // July 14, 2019
  61. var array = [5]
  62. array.insert(array.first! - 1, at: 0)
  63. array.insert(array.first! + 2, at: 1)
  64. array.insert(0, at: 2)
  65. print(array.reduce("", { $0 + String(UnicodeScalar($1 + 105)!) }))
  66.  
  67. // July 15, 2019
  68. var str = "montag"
  69. str = String(str.prefix(3))
  70. str.insert("i", at: str.index(str.startIndex, offsetBy: 2))
  71. print(str)
  72.  
  73. // July 16, 2019 — Contributed by Marius Landwehr @mRs-
  74. "👨‍👩‍👧‍👦".unicodeScalars
  75. .reduce([UnicodeScalar]()) { scalars, char in
  76. var s = scalars
  77. s.append(char)
  78. return s
  79. }
  80. .enumerated()
  81. .compactMap({ (offset, element) -> UnicodeScalar? in
  82. switch offset {
  83. case 0:
  84. return UnicodeScalar(element.value - UInt32(127_995))
  85. case 2:
  86. return UnicodeScalar(element.value - UInt32(127_994))
  87. case 4:
  88. return UnicodeScalar(element.value - UInt32(127_998))
  89. case 6:
  90. return UnicodeScalar(element.value - UInt32(127_992))
  91. default:
  92. return nil
  93. }
  94. })
  95. .reduce("") { $0 + String(Character.init($1)) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement