Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- let signedInt: Int8 = -1
- print(UInt8(bitPattern: signedInt))
- print(String(UInt8(bitPattern: signedInt), radix: 2))
- func quadraticEquation(a: Int, b: Int, c: Int) -> [Any] {
- let k = Double(b*b - 4*a*c)
- return k < 0 ? [] : Set(
- [ -1, 1 ].map{
- (-Double(b) + $0*sqrt(k))/Double(2*a)
- }
- ).sorted()
- }
- let newArrUsingMap = arrayOfInt.map { $0 * 10 }
- let bookAmount = [“harrypotter”:100.0, “junglebook”:1001.0]
- let filteredArrayOnDict = bookAmount.filter { $1 > 100}
- let reducedNumberSum = numbers.reduce(0,+) // returns 10
- let a:[Int] = [1, 2, 3]
- let b:[Int] = [2, 3, 4]
- zip([0,2,4,6], [1,3,5,7]).forEach {
- print($0,$1)
- }
- let arrayA: [Float] = [1,2,3,4]
- let arrayB: [Float] = [10,20,30,40]
- print(zip(arrayA,arrayB).map() {$0 + $1})
- print(zip(arrayA,arrayB).map(+))
- func assignment1(_ a: [Int]) -> Int {
- return zip(a, a[1...]).map(*).max()!
- }
- func assignment2(_ n: Int) -> Bool {
- let s = "\(n)".utf8.map{Int($0)}
- return s.reduce(0, +) == s[0..<s.count/2].reduce(0, +) * 2
- }
- func assignment3(_ a: String, _ b: String) -> Int {
- return Set(a).reduce(0) { $0 + min(a.components(separatedBy: "\($1)").count, b.components(separatedBy: "\($1)").count) - 1 }
- }
- func assignment4(_ s: String) -> Any {
- return s == "" + s.reversed()
- }
- var a:[Int] = (0..<10).map{ _ in .random(in: 1...20) }
- print(a)
- func test(_ n: Int) {
- for i in 1...n {
- if n % i == 0 {
- var a = i + n
- var b = n * n / i + n
- print((a, b))
- if a != b {
- print((b, a))
- }
- }
- }
- }
- test(7)
- import Foundation
- struct Origin {
- var x:Int
- var y:Int
- }
- struct Circle {
- var origin:Origin
- var radius:Int
- func getDT() -> Double {
- return Double(self.radius) * Double(self.radius) * Double.pi
- }
- func getLeftRight() -> [Int] {
- return [self.origin.x - self.radius, self.origin.x + self.radius]
- }
- func getTopBottom() -> [Int] {
- return [self.origin.y - self.radius, self.origin.y + self.radius]
- }
- }
- struct Rectangle {
- var origin:Origin
- var width:Int
- var height:Int
- func getDT() -> Double {
- return Double(self.width * self.height)
- }
- func getLeftRight() -> ClosedRange<Int> {
- return (self.origin.x ... self.origin.x + self.width)
- }
- func getTopBottom() -> ClosedRange<Int> {
- return (self.origin.y - self.height ... self.origin.y)
- }
- }
- func compare(circle:Circle, rectangle:Rectangle) {
- print(circle.getDT() > rectangle.getDT() ? "dien tich hinh tron lon hon" :
- circle.getDT() == rectangle.getDT() ? "dien tich hinh tron bang hinh chu nhat" : "dien tich hinh tron be hon")
- }
- func circleInRectangle(circle:Circle, rectangle:Rectangle) {
- let a = circle.getLeftRight().map{rectangle.getLeftRight().contains($0)}.allSatisfy({$0})
- let b = circle.getTopBottom().map{rectangle.getTopBottom().contains($0)}.allSatisfy({$0})
- print(a && b ? "hinh tron nam trong hinh chu nhat" : "hinh tron khong nam trong hinh chu nhat")
- }
- let circle = Circle(origin: Origin(x: 3, y: 3), radius: 2)
- let rectangle = Rectangle(origin: Origin(x: 0, y: 5), width: 5, height: 6)
- compare(circle:circle, rectangle:rectangle)
- circleInRectangle(circle:circle, rectangle:rectangle)
- /////////////////////////////////
- import Foundation
- class Person {
- var id: Int
- var name: String?
- var age: Int?
- var gender: String?
- var mate:Person?
- var closeFriends:[Person] = []
- init(id: Int) {
- self.id = id
- self.name = randomName()
- self.age = Int.random(in: 18...40)
- self.gender = Int.random(in: 0...1) == 1 ? "Male" : "Female"
- }
- func randomName() -> String {
- return randomString("QWRTPSDFGHJKLXCVBNM", 1) + randomString("EYUIOA", 2) + randomString("TPGHNM", 1)
- }
- func randomString(_ letters: String, _ length: Int) -> String {
- return String((0..<length).map{ _ in letters.randomElement()! })
- }
- func isRelated(id: Int) -> Bool {
- return (self.mate?.id == id) || (self.closeFriends.filter{ $0.id == id }.count == 1)
- }
- deinit {
- print("deinit id: \(id)")
- }
- }
- var personArr = Array(1...100).map{ Person(id: $0) }
- var maleArr = personArr.filter{ $0.gender == "Male" }.shuffled()
- var femaleArr = personArr.filter{ $0.gender == "Female" }.shuffled()
- for i in 0..<[maleArr.count, femaleArr.count, 30].min()! {
- maleArr[i].mate = femaleArr[i]
- femaleArr[i].mate = maleArr[i]
- //print("Couple \(i + 1): \(maleArr[i].id) - \(femaleArr[i].id)")
- }
- var random30 = Array(personArr.shuffled().prefix(30))
- for person in random30 {
- // if closeFriends.count == 2 continue
- var filterPersons = personArr.filter { $0.closeFriends.count < 2 && $0.id != person.id && $0.id != person.mate?.id }.shuffled()
- var k = 2
- if person.closeFriends.count == 1 {
- filterPersons = filterPersons.filter { $0.id != person.closeFriends[0].id }
- k = 1
- }
- person.closeFriends += Array((0..<k).map{ _ in filterPersons.randomElement()! })
- // for var i = 0; i < ; i++
- for i in (2 - k)...1 {
- person.closeFriends[i].closeFriends.append(person)
- }
- }
- var lonelyPersons = personArr.filter {$0.mate == nil && $0.closeFriends.count == 0 }
- func deletePerson(_ id: Int) {
- personArr.removeAll{ $0.id == id }
- maleArr.removeAll{ $0.id == id }
- femaleArr.removeAll{ $0.id == id }
- random30.removeAll{ $0.id == id }
- lonelyPersons.removeAll{ $0.id == id }
- for i in personArr {
- if i.mate?.id == id {
- i.mate = nil
- }
- i.closeFriends.removeAll{ $0.id == id }
- }
- }
- deletePerson(2)
- print(personArr[0].isRelated(id: 3))
Advertisement
Add Comment
Please, Sign In to add comment