junbjn98

Untitled

Jul 2nd, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. I would like to talk about a job that I would like to do in my future. Now I am junior at DNN of FL and my major is ET. So the job I want to do is an ET at secondary or high school. To get the job, first of all, I think I have good English skills such as pronoun grammar, listening and reading. Furthermore, I believe teacher need to demonstrate patience, particularly when dealing with difficult classroom situations. Moreover, communication is the most thing I would need to become an ET. As you know, teaching is a form of communication, so it follows that a teacher must have excellent communication skills. And I hope I will be an ET after graduating. Finally, I would like to share my reason why I want to do this job. I really love children and teach them about many interesting thing in English and help them understand about English culture.
  2.  
  3. let signedInt: Int8 = -1
  4. print(UInt8(bitPattern: signedInt))
  5. print(String(UInt8(bitPattern: signedInt), radix: 2))
  6.  
  7. func quadraticEquation(a: Int, b: Int, c: Int) -> [Any] {
  8. let k = Double(b*b - 4*a*c)
  9. return k < 0 ? [] : Set(
  10. [ -1, 1 ].map{
  11. (-Double(b) + $0*sqrt(k))/Double(2*a)
  12. }
  13. ).sorted()
  14.  
  15. }
  16.  
  17. let newArrUsingMap = arrayOfInt.map { $0 * 10 }
  18.  
  19. let bookAmount = [“harrypotter”:100.0, “junglebook”:1001.0]
  20. let filteredArrayOnDict = bookAmount.filter { $1 > 100}
  21.  
  22. let reducedNumberSum = numbers.reduce(0,+) // returns 10
  23.  
  24. let a:[Int] = [1, 2, 3]
  25. let b:[Int] = [2, 3, 4]
  26.  
  27. zip([0,2,4,6], [1,3,5,7]).forEach {
  28. print($0,$1)
  29. }
  30.  
  31. let arrayA: [Float] = [1,2,3,4]
  32. let arrayB: [Float] = [10,20,30,40]
  33.  
  34. print(zip(arrayA,arrayB).map() {$0 + $1})
  35. print(zip(arrayA,arrayB).map(+))
  36.  
  37. func assignment1(_ a: [Int]) -> Int {
  38. return zip(a, a[1...]).map(*).max()!
  39. }
  40.  
  41. func assignment2(_ n: Int) -> Bool {
  42. let s = "\(n)".utf8.map{Int($0)}
  43. return s.reduce(0, +) == s[0..<s.count/2].reduce(0, +) * 2
  44. }
  45.  
  46. func assignment3(_ a: String, _ b: String) -> Int {
  47. return Set(a).reduce(0) { $0 + min(a.components(separatedBy: "\($1)").count, b.components(separatedBy: "\($1)").count) - 1 }
  48. }
  49.  
  50. func assignment4(_ s: String) -> Any {
  51. return s == "" + s.reversed()
  52. }
  53.  
  54. var a:[Int] = (0..<10).map{ _ in .random(in: 1...20) }
  55.  
  56. print(a)
  57.  
  58. func test(_ n: Int) {
  59. for i in 1...n {
  60. if n % i == 0 {
  61. var a = i + n
  62. var b = n * n / i + n
  63. print((a, b))
  64. if a != b {
  65. print((b, a))
  66. }
  67. }
  68. }
  69. }
  70.  
  71. test(7)
  72.  
  73. import Foundation
  74.  
  75. struct Origin {
  76. var x:Int
  77. var y:Int
  78. }
  79.  
  80. struct Circle {
  81. var origin:Origin
  82. var radius:Int
  83.  
  84. func getDT() -> Double {
  85. return Double(self.radius) * Double(self.radius) * Double.pi
  86. }
  87.  
  88. func getLeftRight() -> [Int] {
  89. return [self.origin.x - self.radius, self.origin.x + self.radius]
  90. }
  91.  
  92. func getTopBottom() -> [Int] {
  93. return [self.origin.y - self.radius, self.origin.y + self.radius]
  94. }
  95. }
  96.  
  97. struct Rectangle {
  98. var origin:Origin
  99. var width:Int
  100. var height:Int
  101.  
  102. func getDT() -> Double {
  103. return Double(self.width * self.height)
  104. }
  105.  
  106. func getLeftRight() -> ClosedRange<Int> {
  107. return (self.origin.x ... self.origin.x + self.width)
  108. }
  109.  
  110. func getTopBottom() -> ClosedRange<Int> {
  111. return (self.origin.y - self.height ... self.origin.y)
  112. }
  113. }
  114.  
  115. func compare(circle:Circle, rectangle:Rectangle) {
  116. print(circle.getDT() > rectangle.getDT() ? "dien tich hinh tron lon hon" :
  117. circle.getDT() == rectangle.getDT() ? "dien tich hinh tron bang hinh chu nhat" : "dien tich hinh tron be hon")
  118. }
  119.  
  120. func circleInRectangle(circle:Circle, rectangle:Rectangle) {
  121. let a = circle.getLeftRight().map{rectangle.getLeftRight().contains($0)}.allSatisfy({$0})
  122. let b = circle.getTopBottom().map{rectangle.getTopBottom().contains($0)}.allSatisfy({$0})
  123. print(a && b ? "hinh tron nam trong hinh chu nhat" : "hinh tron khong nam trong hinh chu nhat")
  124. }
  125.  
  126. let circle = Circle(origin: Origin(x: 3, y: 3), radius: 2)
  127. let rectangle = Rectangle(origin: Origin(x: 0, y: 5), width: 5, height: 6)
  128.  
  129. compare(circle:circle, rectangle:rectangle)
  130. circleInRectangle(circle:circle, rectangle:rectangle)
  131.  
  132. /////////////////////////////////
  133.  
  134.  
  135. import Foundation
  136.  
  137. class Person {
  138. var id: Int
  139. var name: String?
  140. var age: Int?
  141. var gender: String?
  142. var mate:Person?
  143. var closeFriends:[Person] = []
  144.  
  145. init(id: Int) {
  146. self.id = id
  147. self.name = randomName()
  148. self.age = Int.random(in: 18...40)
  149. self.gender = Int.random(in: 0...1) == 1 ? "Male" : "Female"
  150. }
  151.  
  152. func randomName() -> String {
  153. return randomString("QWRTPSDFGHJKLXCVBNM", 1) + randomString("EYUIOA", 2) + randomString("TPGHNM", 1)
  154. }
  155.  
  156. func randomString(_ letters: String, _ length: Int) -> String {
  157. return String((0..<length).map{ _ in letters.randomElement()! })
  158. }
  159.  
  160. func isRelated(id: Int) -> Bool {
  161. return (self.mate?.id == id) || (self.closeFriends.filter{ $0.id == id }.count == 1)
  162. }
  163.  
  164. deinit {
  165. print("deinit id: \(id)")
  166. }
  167.  
  168. }
  169.  
  170. var personArr = Array(1...100).map{ Person(id: $0) }
  171.  
  172. var maleArr = personArr.filter{ $0.gender == "Male" }.shuffled()
  173. var femaleArr = personArr.filter{ $0.gender == "Female" }.shuffled()
  174.  
  175. for i in 0..<[maleArr.count, femaleArr.count, 30].min()! {
  176. maleArr[i].mate = femaleArr[i]
  177. femaleArr[i].mate = maleArr[i]
  178. //print("Couple \(i + 1): \(maleArr[i].id) - \(femaleArr[i].id)")
  179. }
  180.  
  181. var random30 = Array(personArr.shuffled().prefix(30))
  182. for person in random30 {
  183. // if closeFriends.count == 2 continue
  184. var filterPersons = personArr.filter { $0.closeFriends.count < 2 && $0.id != person.id && $0.id != person.mate?.id }.shuffled()
  185. var k = 2
  186. if person.closeFriends.count == 1 {
  187. filterPersons = filterPersons.filter { $0.id != person.closeFriends[0].id }
  188. k = 1
  189. }
  190. person.closeFriends += Array((0..<k).map{ _ in filterPersons.randomElement()! })
  191. // for var i = 0; i < ; i++
  192. for i in (2 - k)...1 {
  193. person.closeFriends[i].closeFriends.append(person)
  194. }
  195. }
  196.  
  197. var lonelyPersons = personArr.filter {$0.mate == nil && $0.closeFriends.count == 0 }
  198.  
  199. func deletePerson(_ id: Int) {
  200. personArr.removeAll{ $0.id == id }
  201. maleArr.removeAll{ $0.id == id }
  202. femaleArr.removeAll{ $0.id == id }
  203. random30.removeAll{ $0.id == id }
  204. lonelyPersons.removeAll{ $0.id == id }
  205.  
  206. for i in personArr {
  207. if i.mate?.id == id {
  208. i.mate = nil
  209. }
  210. i.closeFriends.removeAll{ $0.id == id }
  211. }
  212. }
  213. deletePerson(2)
  214.  
  215. print(personArr[0].isRelated(id: 3))
Advertisement
Add Comment
Please, Sign In to add comment