-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGettSwift.swift
116 lines (103 loc) · 3.82 KB
/
GettSwift.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// GettSwift.swift
// GettSwift
//
// Created by Shai Mishali.
// Copyright © 2020 Gett. All rights reserved.
//
// MMMMMMMMMMMMMMMMMMMMMMMMMNXOolxXMMMMMMMM
// MMMMMMMMMMMMMMMMMMMMMMMMMNx'.,kNMMMMMMMM
// MMMMMMMMMMMMMMMMMMMMMMMMMMk.,0MMMMMMMMMM
// MMMMMMMMMMMMMMWKxokNMMMMMK;.dWMMMMMMMMMM
// MMMMMMMMMMMMMWk' .l0XMMX: :XMMMMMMMMMMM
// MMMMMMMMMMMMMWk. .cON0: .kMMMMMMMMMMMM
// MMMMMMMMMMMMMMW0; .,:;. :XMMMMMMMMMMMM
// MMMMMMMMMWNNNNKx, .xNNNWMMMMMMMMM
// MMMMMMMWX00Od;. ,x0000XWMMMMMMM
// MMMMMMMN0OOd' ;kOOOO0NMMMMMMM
// MMMMMMMX0OOl. ;kOOOO0NMMMMMMM
// MMMMMMMX0OOl. .. ;kOOOO0NMMMMMMM
// MMMMMMMX0Ok; ,l' ;kOOOO0NMMMMMMM
// MMMMMMMX0Od..cd' 'dOOOO0NMMMMMMM
// MMMMMMMX0Oo.'xd. .dOOOO0NMMMMMMM
// MMMMMMMX0Oo.;kl. 'xOOOO0NMMMMMMM
// MMMMMMMX0Od,;dc .dOOOO0NMMMMMMM
// MMMMMMMX0OOxdx; .oOOOO0NMMMMMMM
// MMMMMMMN0OOOOx, .;c' .cOOOOKWMMMMMMM
// MMMMMMMWNK000k;...;xOl....lO00KNMMMMMMMM
//
// ########################################
// ######### Gett iOS Challenge ###########
// ########################################
//
// Fix the code below so the tests pass.
// Please carefully read the rules and in-line comments below.
//
// You may:
// - Add any code to the BEGINNING of the test bodies (but not to the middle or end of them).
// - Add any code outside of the test bodies.
//
// You must not:
// - Remove any code from the tests.
// - Add a fake XCTAssert, an early-return, or other means to "short circuit" the test execution.
//
// To test your solution, go to Product ▶ Test (or use ⌘ + U)
import XCTest
extension Int {
subscript(customStringConvertible: CustomStringConvertible, _ closure: () -> String) -> String {
let result = closure()
.components(separatedBy: " ")
.map { String($0.reversed()).capitalized }
.joined(separator: " ")
let repeated = String(repeating: customStringConvertible.description, count: self)
return "\(result)\(repeated.isEmpty ? "" : " \(repeated)")"
}
}
final class GettSwiftTests: XCTestCase {
let 👋: (Int) -> Int = { $0 }
func testGettChallenge1() {
// Do not edit below this line
XCTAssertEqual(👋(3)["a"]{ "tteg a ixat !" }, "Gett A Taxi ! aaa")
}
func testGettChallenge2() {
let 🔜 = 1
// Do not edit below this line
XCTAssertEqual(👋(🔜)["🚕"]{ "tteg a ixat !" }, "Gett A Taxi ! 🚕")
}
func testGettChallenge3() {
let 🔜 = 5
let 🌈 = "🌈"
// Do not edit below this line
XCTAssertEqual(👋(🔜)[🌈]{ "tteg a ixat !" }, "Gett A Taxi ! 🌈🌈🌈🌈🌈")
}
func testGettChallenge4() {
let 🔜 = 2
let 📱 = "📱"
// Do not edit below this line
XCTAssertEqual(👋(🔜)[📱]{ "tteg a ixat !" }, "Gett A Taxi ! 📱📱")
}
func testGettChallenge5() {
let 🔜 = 2
// Do not edit below this line
XCTAssertEqual(👋(🔜)["hey"]{ "tteg a ixat !" }, "Gett A Taxi ! heyhey")
}
func testGettChallenge6() {
let 🔜 = 2
// Do not edit below this line
XCTAssertEqual(👋(🔜)[pow(2, 3)]{ "tteg a ixat !" }, "Gett A Taxi ! 88")
}
func testGettChallenge7() {
let 🔜 = 0
// Do not edit below this line
XCTAssertEqual(👋(🔜)[6 ^ 3 ^ 2]{ "tteg a ixat !" }, "Gett A Taxi !")
}
func testGettChallenge8() {
let 🔜 = 3
// Do not edit below this line
let randomString = UUID().uuidString
XCTAssertEqual(👋(🔜)[randomString]{ "tteg a ixat !" }, "Gett A Taxi ! \(randomString)\(randomString)\(randomString)")
}
// Do not modify these 2 lines
override func setUp() {}
override func tearDown() {}
}