Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3ada203

Browse files
committed
Day 11: Corporate Policy
1 parent 38a0f73 commit 3ada203

File tree

4 files changed

+392
-0
lines changed

4 files changed

+392
-0
lines changed

‎day11/day11.xcodeproj/project.pbxproj

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 50;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
06ED5D2621DE443D005A0299 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06ED5D2521DE443D005A0299 /* main.swift */; };
11+
/* End PBXBuildFile section */
12+
13+
/* Begin PBXCopyFilesBuildPhase section */
14+
06ED5D2021DE443D005A0299 /* CopyFiles */ = {
15+
isa = PBXCopyFilesBuildPhase;
16+
buildActionMask = 2147483647;
17+
dstPath = /usr/share/man/man1/;
18+
dstSubfolderSpec = 0;
19+
files = (
20+
);
21+
runOnlyForDeploymentPostprocessing = 1;
22+
};
23+
/* End PBXCopyFilesBuildPhase section */
24+
25+
/* Begin PBXFileReference section */
26+
06ED5D2221DE443D005A0299 /* day11 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day11; sourceTree = BUILT_PRODUCTS_DIR; };
27+
06ED5D2521DE443D005A0299 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
28+
/* End PBXFileReference section */
29+
30+
/* Begin PBXFrameworksBuildPhase section */
31+
06ED5D1F21DE443D005A0299 /* Frameworks */ = {
32+
isa = PBXFrameworksBuildPhase;
33+
buildActionMask = 2147483647;
34+
files = (
35+
);
36+
runOnlyForDeploymentPostprocessing = 0;
37+
};
38+
/* End PBXFrameworksBuildPhase section */
39+
40+
/* Begin PBXGroup section */
41+
06ED5D1921DE443D005A0299 = {
42+
isa = PBXGroup;
43+
children = (
44+
06ED5D2421DE443D005A0299 /* day11 */,
45+
06ED5D2321DE443D005A0299 /* Products */,
46+
);
47+
sourceTree = "<group>";
48+
};
49+
06ED5D2321DE443D005A0299 /* Products */ = {
50+
isa = PBXGroup;
51+
children = (
52+
06ED5D2221DE443D005A0299 /* day11 */,
53+
);
54+
name = Products;
55+
sourceTree = "<group>";
56+
};
57+
06ED5D2421DE443D005A0299 /* day11 */ = {
58+
isa = PBXGroup;
59+
children = (
60+
06ED5D2521DE443D005A0299 /* main.swift */,
61+
);
62+
path = day11;
63+
sourceTree = "<group>";
64+
};
65+
/* End PBXGroup section */
66+
67+
/* Begin PBXNativeTarget section */
68+
06ED5D2121DE443D005A0299 /* day11 */ = {
69+
isa = PBXNativeTarget;
70+
buildConfigurationList = 06ED5D2921DE443D005A0299 /* Build configuration list for PBXNativeTarget "day11" */;
71+
buildPhases = (
72+
06ED5D1E21DE443D005A0299 /* Sources */,
73+
06ED5D1F21DE443D005A0299 /* Frameworks */,
74+
06ED5D2021DE443D005A0299 /* CopyFiles */,
75+
);
76+
buildRules = (
77+
);
78+
dependencies = (
79+
);
80+
name = day11;
81+
productName = day11;
82+
productReference = 06ED5D2221DE443D005A0299 /* day11 */;
83+
productType = "com.apple.product-type.tool";
84+
};
85+
/* End PBXNativeTarget section */
86+
87+
/* Begin PBXProject section */
88+
06ED5D1A21DE443D005A0299 /* Project object */ = {
89+
isa = PBXProject;
90+
attributes = {
91+
LastSwiftUpdateCheck = 1010;
92+
LastUpgradeCheck = 1010;
93+
ORGANIZATIONNAME = "Tyler Kieft";
94+
TargetAttributes = {
95+
06ED5D2121DE443D005A0299 = {
96+
CreatedOnToolsVersion = 10.1;
97+
};
98+
};
99+
};
100+
buildConfigurationList = 06ED5D1D21DE443D005A0299 /* Build configuration list for PBXProject "day11" */;
101+
compatibilityVersion = "Xcode 9.3";
102+
developmentRegion = en;
103+
hasScannedForEncodings = 0;
104+
knownRegions = (
105+
en,
106+
);
107+
mainGroup = 06ED5D1921DE443D005A0299;
108+
productRefGroup = 06ED5D2321DE443D005A0299 /* Products */;
109+
projectDirPath = "";
110+
projectRoot = "";
111+
targets = (
112+
06ED5D2121DE443D005A0299 /* day11 */,
113+
);
114+
};
115+
/* End PBXProject section */
116+
117+
/* Begin PBXSourcesBuildPhase section */
118+
06ED5D1E21DE443D005A0299 /* Sources */ = {
119+
isa = PBXSourcesBuildPhase;
120+
buildActionMask = 2147483647;
121+
files = (
122+
06ED5D2621DE443D005A0299 /* main.swift in Sources */,
123+
);
124+
runOnlyForDeploymentPostprocessing = 0;
125+
};
126+
/* End PBXSourcesBuildPhase section */
127+
128+
/* Begin XCBuildConfiguration section */
129+
06ED5D2721DE443D005A0299 /* Debug */ = {
130+
isa = XCBuildConfiguration;
131+
buildSettings = {
132+
ALWAYS_SEARCH_USER_PATHS = NO;
133+
CLANG_ANALYZER_NONNULL = YES;
134+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
135+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
136+
CLANG_CXX_LIBRARY = "libc++";
137+
CLANG_ENABLE_MODULES = YES;
138+
CLANG_ENABLE_OBJC_ARC = YES;
139+
CLANG_ENABLE_OBJC_WEAK = YES;
140+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
141+
CLANG_WARN_BOOL_CONVERSION = YES;
142+
CLANG_WARN_COMMA = YES;
143+
CLANG_WARN_CONSTANT_CONVERSION = YES;
144+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
145+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
146+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
147+
CLANG_WARN_EMPTY_BODY = YES;
148+
CLANG_WARN_ENUM_CONVERSION = YES;
149+
CLANG_WARN_INFINITE_RECURSION = YES;
150+
CLANG_WARN_INT_CONVERSION = YES;
151+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
152+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
153+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
154+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
155+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
156+
CLANG_WARN_STRICT_PROTOTYPES = YES;
157+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
158+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
159+
CLANG_WARN_UNREACHABLE_CODE = YES;
160+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
161+
CODE_SIGN_IDENTITY = "-";
162+
COPY_PHASE_STRIP = NO;
163+
DEBUG_INFORMATION_FORMAT = dwarf;
164+
ENABLE_STRICT_OBJC_MSGSEND = YES;
165+
ENABLE_TESTABILITY = YES;
166+
GCC_C_LANGUAGE_STANDARD = gnu11;
167+
GCC_DYNAMIC_NO_PIC = NO;
168+
GCC_NO_COMMON_BLOCKS = YES;
169+
GCC_OPTIMIZATION_LEVEL = 0;
170+
GCC_PREPROCESSOR_DEFINITIONS = (
171+
"DEBUG=1",
172+
"$(inherited)",
173+
);
174+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
175+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
176+
GCC_WARN_UNDECLARED_SELECTOR = YES;
177+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
178+
GCC_WARN_UNUSED_FUNCTION = YES;
179+
GCC_WARN_UNUSED_VARIABLE = YES;
180+
MACOSX_DEPLOYMENT_TARGET = 10.14;
181+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
182+
MTL_FAST_MATH = YES;
183+
ONLY_ACTIVE_ARCH = YES;
184+
SDKROOT = macosx;
185+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
186+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
187+
};
188+
name = Debug;
189+
};
190+
06ED5D2821DE443D005A0299 /* Release */ = {
191+
isa = XCBuildConfiguration;
192+
buildSettings = {
193+
ALWAYS_SEARCH_USER_PATHS = NO;
194+
CLANG_ANALYZER_NONNULL = YES;
195+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
196+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
197+
CLANG_CXX_LIBRARY = "libc++";
198+
CLANG_ENABLE_MODULES = YES;
199+
CLANG_ENABLE_OBJC_ARC = YES;
200+
CLANG_ENABLE_OBJC_WEAK = YES;
201+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
202+
CLANG_WARN_BOOL_CONVERSION = YES;
203+
CLANG_WARN_COMMA = YES;
204+
CLANG_WARN_CONSTANT_CONVERSION = YES;
205+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
206+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
207+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
208+
CLANG_WARN_EMPTY_BODY = YES;
209+
CLANG_WARN_ENUM_CONVERSION = YES;
210+
CLANG_WARN_INFINITE_RECURSION = YES;
211+
CLANG_WARN_INT_CONVERSION = YES;
212+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
213+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
214+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
215+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
216+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
217+
CLANG_WARN_STRICT_PROTOTYPES = YES;
218+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
219+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
220+
CLANG_WARN_UNREACHABLE_CODE = YES;
221+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
222+
CODE_SIGN_IDENTITY = "-";
223+
COPY_PHASE_STRIP = NO;
224+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
225+
ENABLE_NS_ASSERTIONS = NO;
226+
ENABLE_STRICT_OBJC_MSGSEND = YES;
227+
GCC_C_LANGUAGE_STANDARD = gnu11;
228+
GCC_NO_COMMON_BLOCKS = YES;
229+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
230+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
231+
GCC_WARN_UNDECLARED_SELECTOR = YES;
232+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
233+
GCC_WARN_UNUSED_FUNCTION = YES;
234+
GCC_WARN_UNUSED_VARIABLE = YES;
235+
MACOSX_DEPLOYMENT_TARGET = 10.14;
236+
MTL_ENABLE_DEBUG_INFO = NO;
237+
MTL_FAST_MATH = YES;
238+
SDKROOT = macosx;
239+
SWIFT_COMPILATION_MODE = wholemodule;
240+
SWIFT_OPTIMIZATION_LEVEL = "-O";
241+
};
242+
name = Release;
243+
};
244+
06ED5D2A21DE443D005A0299 /* Debug */ = {
245+
isa = XCBuildConfiguration;
246+
buildSettings = {
247+
CODE_SIGN_STYLE = Automatic;
248+
PRODUCT_NAME = "$(TARGET_NAME)";
249+
SWIFT_VERSION = 4.2;
250+
};
251+
name = Debug;
252+
};
253+
06ED5D2B21DE443D005A0299 /* Release */ = {
254+
isa = XCBuildConfiguration;
255+
buildSettings = {
256+
CODE_SIGN_STYLE = Automatic;
257+
PRODUCT_NAME = "$(TARGET_NAME)";
258+
SWIFT_VERSION = 4.2;
259+
};
260+
name = Release;
261+
};
262+
/* End XCBuildConfiguration section */
263+
264+
/* Begin XCConfigurationList section */
265+
06ED5D1D21DE443D005A0299 /* Build configuration list for PBXProject "day11" */ = {
266+
isa = XCConfigurationList;
267+
buildConfigurations = (
268+
06ED5D2721DE443D005A0299 /* Debug */,
269+
06ED5D2821DE443D005A0299 /* Release */,
270+
);
271+
defaultConfigurationIsVisible = 0;
272+
defaultConfigurationName = Release;
273+
};
274+
06ED5D2921DE443D005A0299 /* Build configuration list for PBXNativeTarget "day11" */ = {
275+
isa = XCConfigurationList;
276+
buildConfigurations = (
277+
06ED5D2A21DE443D005A0299 /* Debug */,
278+
06ED5D2B21DE443D005A0299 /* Release */,
279+
);
280+
defaultConfigurationIsVisible = 0;
281+
defaultConfigurationName = Release;
282+
};
283+
/* End XCConfigurationList section */
284+
};
285+
rootObject = 06ED5D1A21DE443D005A0299 /* Project object */;
286+
}

‎day11/day11.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

‎day11/day11/main.swift

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//
2+
// main.swift
3+
// day11
4+
//
5+
// Created by Tyler Kieft on 1/3/19.
6+
// Copyright © 2019 Tyler Kieft. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
var password = "cqjxjnds"
12+
13+
func incrementAscii(_ c: Character) -> String {
14+
let scalars = c.unicodeScalars
15+
return String(UnicodeScalar(scalars[scalars.startIndex].value + 1)!)
16+
}
17+
18+
func increment(_ string: String) -> String {
19+
var newString = String()
20+
var increment = true
21+
var index = string.endIndex
22+
23+
repeat {
24+
index = string.index(before: index)
25+
26+
let c = string[index]
27+
28+
if (increment) {
29+
if (c == "z") {
30+
newString.append("a")
31+
} else {
32+
newString.append(incrementAscii(c))
33+
increment = false
34+
}
35+
} else {
36+
newString.append(c)
37+
}
38+
} while index > string.startIndex
39+
40+
return String(newString.reversed())
41+
}
42+
43+
func isValid(_ password: String) -> Bool {
44+
if password.contains("i") { return false }
45+
if password.contains("l") { return false }
46+
if password.contains("o") { return false }
47+
48+
var foundIncrease = false
49+
var increaseLength = 0
50+
51+
var pairs = 0
52+
53+
var lastPairC: Character? = nil
54+
var lastC: Character? = nil
55+
56+
for c in password {
57+
if c == lastPairC {
58+
pairs += 1
59+
lastPairC = nil // so we don't overlap pairs
60+
} else {
61+
lastPairC = c
62+
}
63+
64+
if lastC != nil && c.unicodeScalars[c.unicodeScalars.startIndex].value == lastC!.unicodeScalars[lastC!.unicodeScalars.startIndex].value + 1 {
65+
increaseLength = increaseLength + 1
66+
if increaseLength == 3 {
67+
foundIncrease = true
68+
}
69+
} else {
70+
increaseLength = 1
71+
}
72+
73+
lastC = c
74+
}
75+
76+
return foundIncrease && (pairs >= 2)
77+
}
78+
79+
func nextPassword(_ password: String) -> String {
80+
var pass = password
81+
repeat {
82+
pass = increment(pass)
83+
} while !isValid(pass)
84+
85+
return pass
86+
}
87+
88+
password = nextPassword(password)
89+
print (password)
90+
password = nextPassword(password)
91+
print(password)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /