From dae7c342651ecd6c648e847316ef90a22e5c939f Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Fri, 11 Dec 2020 22:25:14 +0100 Subject: [PATCH] Initial commit --- .gitignore | 1 + AdventOfCode2020.xcodeproj/project.pbxproj | 1236 +++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + common/LoadData.swift | 30 + common/Scanner+Extensions.swift | 26 + day1/main.swift | 21 + day10/main.swift | 64 + day11/main.swift | 116 ++ day2/main.swift | 39 + day3/main.swift | 32 + day4/main.swift | 99 ++ day5/main.swift | 35 + day6/main.swift | 34 + day7/main.swift | 74 + day8/main.swift | 134 ++ day9/main.swift | 45 + 17 files changed, 2001 insertions(+) create mode 100644 .gitignore create mode 100644 AdventOfCode2020.xcodeproj/project.pbxproj create mode 100644 AdventOfCode2020.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 AdventOfCode2020.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 common/LoadData.swift create mode 100644 common/Scanner+Extensions.swift create mode 100644 day1/main.swift create mode 100644 day10/main.swift create mode 100644 day11/main.swift create mode 100644 day2/main.swift create mode 100644 day3/main.swift create mode 100644 day4/main.swift create mode 100644 day5/main.swift create mode 100644 day6/main.swift create mode 100644 day7/main.swift create mode 100644 day8/main.swift create mode 100644 day9/main.swift diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6bd609f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.xcodeproj/**/xcuserdata/ diff --git a/AdventOfCode2020.xcodeproj/project.pbxproj b/AdventOfCode2020.xcodeproj/project.pbxproj new file mode 100644 index 0000000..543f8c1 --- /dev/null +++ b/AdventOfCode2020.xcodeproj/project.pbxproj @@ -0,0 +1,1236 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 26176242257DFD0800D00A66 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26176241257DFD0800D00A66 /* main.swift */; }; + 268D953D25781DD80030EC4D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 268D953C25781DD80030EC4D /* main.swift */; }; + 268D954B25781F740030EC4D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 268D954A25781F740030EC4D /* main.swift */; }; + 268D955C257904250030EC4D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 268D955B257904250030EC4D /* main.swift */; }; + 268D956A257A07B80030EC4D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 268D9569257A07B80030EC4D /* main.swift */; }; + 268D9579257B52290030EC4D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 268D9578257B52290030EC4D /* main.swift */; }; + 268D9589257CB8DA0030EC4D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 268D9588257CB8DA0030EC4D /* main.swift */; }; + 26E2ACD8257ECFFA00702405 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACD7257ECFFA00702405 /* main.swift */; }; + 26E2ACE6257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACE7257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACE8257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACE9257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACEA257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACEB257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACEC257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACED257ED09000702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2ACFD258009FE00702405 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACFC258009FE00702405 /* main.swift */; }; + 26E2AD0A25800A1400702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2AD2125816EE100702405 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD2025816EE100702405 /* main.swift */; }; + 26E2AD2F25816EE700702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2AD3B2581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD3C2581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD3D2581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD3E2581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD3F2581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD402581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD412581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD422581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD432581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD442581713A00702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; + 26E2AD56258343D800702405 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD55258343D800702405 /* main.swift */; }; + 26E2AD65258343E300702405 /* Scanner+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */; }; + 26E2AD71258343E600702405 /* LoadData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E2AD3A2581713A00702405 /* LoadData.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 2617623D257DFD0800D00A66 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 268D953725781DD80030EC4D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 268D954625781F740030EC4D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 268D9557257904250030EC4D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 268D9565257A07B80030EC4D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 268D9574257B52290030EC4D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 268D9584257CB8DA0030EC4D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 26E2ACD3257ECFFA00702405 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 26E2ACF8258009FE00702405 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 26E2AD1C25816EE100702405 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 26E2AD51258343D800702405 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2617623F257DFD0800D00A66 /* day7 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day7; sourceTree = BUILT_PRODUCTS_DIR; }; + 26176241257DFD0800D00A66 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 268D953925781DD80030EC4D /* day1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day1; sourceTree = BUILT_PRODUCTS_DIR; }; + 268D953C25781DD80030EC4D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 268D954825781F740030EC4D /* day2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day2; sourceTree = BUILT_PRODUCTS_DIR; }; + 268D954A25781F740030EC4D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 268D9559257904250030EC4D /* day3 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day3; sourceTree = BUILT_PRODUCTS_DIR; }; + 268D955B257904250030EC4D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 268D9567257A07B80030EC4D /* day4 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day4; sourceTree = BUILT_PRODUCTS_DIR; }; + 268D9569257A07B80030EC4D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 268D9576257B52290030EC4D /* day5 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day5; sourceTree = BUILT_PRODUCTS_DIR; }; + 268D9578257B52290030EC4D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 268D9586257CB8DA0030EC4D /* day6 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day6; sourceTree = BUILT_PRODUCTS_DIR; }; + 268D9588257CB8DA0030EC4D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 26E2ACD5257ECFFA00702405 /* day8 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day8; sourceTree = BUILT_PRODUCTS_DIR; }; + 26E2ACD7257ECFFA00702405 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Scanner+Extensions.swift"; sourceTree = ""; }; + 26E2ACFA258009FE00702405 /* day9 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day9; sourceTree = BUILT_PRODUCTS_DIR; }; + 26E2ACFC258009FE00702405 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 26E2AD1E25816EE100702405 /* day10 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day10; sourceTree = BUILT_PRODUCTS_DIR; }; + 26E2AD2025816EE100702405 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 26E2AD3A2581713A00702405 /* LoadData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadData.swift; sourceTree = ""; }; + 26E2AD53258343D800702405 /* day11 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = day11; sourceTree = BUILT_PRODUCTS_DIR; }; + 26E2AD55258343D800702405 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2617623C257DFD0800D00A66 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D953625781DD80030EC4D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D954525781F740030EC4D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9556257904250030EC4D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9564257A07B80030EC4D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9573257B52290030EC4D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9583257CB8DA0030EC4D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2ACD2257ECFFA00702405 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2ACF7258009FE00702405 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2AD1B25816EE100702405 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2AD50258343D800702405 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 26176240257DFD0800D00A66 /* day7 */ = { + isa = PBXGroup; + children = ( + 26176241257DFD0800D00A66 /* main.swift */, + ); + path = day7; + sourceTree = ""; + }; + 268D953025781DD80030EC4D = { + isa = PBXGroup; + children = ( + 26E2ACE4257ED07600702405 /* common */, + 268D953B25781DD80030EC4D /* day1 */, + 268D954925781F740030EC4D /* day2 */, + 268D955A257904250030EC4D /* day3 */, + 268D9568257A07B80030EC4D /* day4 */, + 268D9577257B52290030EC4D /* day5 */, + 268D9587257CB8DA0030EC4D /* day6 */, + 26176240257DFD0800D00A66 /* day7 */, + 26E2ACD6257ECFFA00702405 /* day8 */, + 26E2ACFB258009FE00702405 /* day9 */, + 26E2AD1F25816EE100702405 /* day10 */, + 26E2AD54258343D800702405 /* day11 */, + 268D953A25781DD80030EC4D /* Products */, + ); + sourceTree = ""; + }; + 268D953A25781DD80030EC4D /* Products */ = { + isa = PBXGroup; + children = ( + 268D953925781DD80030EC4D /* day1 */, + 268D954825781F740030EC4D /* day2 */, + 268D9559257904250030EC4D /* day3 */, + 268D9567257A07B80030EC4D /* day4 */, + 268D9576257B52290030EC4D /* day5 */, + 268D9586257CB8DA0030EC4D /* day6 */, + 2617623F257DFD0800D00A66 /* day7 */, + 26E2ACD5257ECFFA00702405 /* day8 */, + 26E2ACFA258009FE00702405 /* day9 */, + 26E2AD1E25816EE100702405 /* day10 */, + 26E2AD53258343D800702405 /* day11 */, + ); + name = Products; + sourceTree = ""; + }; + 268D953B25781DD80030EC4D /* day1 */ = { + isa = PBXGroup; + children = ( + 268D953C25781DD80030EC4D /* main.swift */, + ); + path = day1; + sourceTree = ""; + }; + 268D954925781F740030EC4D /* day2 */ = { + isa = PBXGroup; + children = ( + 268D954A25781F740030EC4D /* main.swift */, + ); + path = day2; + sourceTree = ""; + }; + 268D955A257904250030EC4D /* day3 */ = { + isa = PBXGroup; + children = ( + 268D955B257904250030EC4D /* main.swift */, + ); + path = day3; + sourceTree = ""; + }; + 268D9568257A07B80030EC4D /* day4 */ = { + isa = PBXGroup; + children = ( + 268D9569257A07B80030EC4D /* main.swift */, + ); + path = day4; + sourceTree = ""; + }; + 268D9577257B52290030EC4D /* day5 */ = { + isa = PBXGroup; + children = ( + 268D9578257B52290030EC4D /* main.swift */, + ); + path = day5; + sourceTree = ""; + }; + 268D9587257CB8DA0030EC4D /* day6 */ = { + isa = PBXGroup; + children = ( + 268D9588257CB8DA0030EC4D /* main.swift */, + ); + path = day6; + sourceTree = ""; + }; + 26E2ACD6257ECFFA00702405 /* day8 */ = { + isa = PBXGroup; + children = ( + 26E2ACD7257ECFFA00702405 /* main.swift */, + ); + path = day8; + sourceTree = ""; + }; + 26E2ACE4257ED07600702405 /* common */ = { + isa = PBXGroup; + children = ( + 26E2ACE5257ED09000702405 /* Scanner+Extensions.swift */, + 26E2AD3A2581713A00702405 /* LoadData.swift */, + ); + path = common; + sourceTree = ""; + }; + 26E2ACFB258009FE00702405 /* day9 */ = { + isa = PBXGroup; + children = ( + 26E2ACFC258009FE00702405 /* main.swift */, + ); + path = day9; + sourceTree = ""; + }; + 26E2AD1F25816EE100702405 /* day10 */ = { + isa = PBXGroup; + children = ( + 26E2AD2025816EE100702405 /* main.swift */, + ); + path = day10; + sourceTree = ""; + }; + 26E2AD54258343D800702405 /* day11 */ = { + isa = PBXGroup; + children = ( + 26E2AD55258343D800702405 /* main.swift */, + ); + path = day11; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2617623E257DFD0800D00A66 /* day7 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 26176245257DFD0800D00A66 /* Build configuration list for PBXNativeTarget "day7" */; + buildPhases = ( + 2617623B257DFD0800D00A66 /* Sources */, + 2617623C257DFD0800D00A66 /* Frameworks */, + 2617623D257DFD0800D00A66 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day7; + productName = day7; + productReference = 2617623F257DFD0800D00A66 /* day7 */; + productType = "com.apple.product-type.tool"; + }; + 268D953825781DD80030EC4D /* day1 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 268D954025781DD80030EC4D /* Build configuration list for PBXNativeTarget "day1" */; + buildPhases = ( + 268D953525781DD80030EC4D /* Sources */, + 268D953625781DD80030EC4D /* Frameworks */, + 268D953725781DD80030EC4D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day1; + productName = AdventOfCode2020; + productReference = 268D953925781DD80030EC4D /* day1 */; + productType = "com.apple.product-type.tool"; + }; + 268D954725781F740030EC4D /* day2 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 268D954C25781F740030EC4D /* Build configuration list for PBXNativeTarget "day2" */; + buildPhases = ( + 268D954425781F740030EC4D /* Sources */, + 268D954525781F740030EC4D /* Frameworks */, + 268D954625781F740030EC4D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day2; + productName = day2; + productReference = 268D954825781F740030EC4D /* day2 */; + productType = "com.apple.product-type.tool"; + }; + 268D9558257904250030EC4D /* day3 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 268D955F257904250030EC4D /* Build configuration list for PBXNativeTarget "day3" */; + buildPhases = ( + 268D9555257904250030EC4D /* Sources */, + 268D9556257904250030EC4D /* Frameworks */, + 268D9557257904250030EC4D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day3; + productName = day3; + productReference = 268D9559257904250030EC4D /* day3 */; + productType = "com.apple.product-type.tool"; + }; + 268D9566257A07B80030EC4D /* day4 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 268D956B257A07B80030EC4D /* Build configuration list for PBXNativeTarget "day4" */; + buildPhases = ( + 268D9563257A07B80030EC4D /* Sources */, + 268D9564257A07B80030EC4D /* Frameworks */, + 268D9565257A07B80030EC4D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day4; + productName = day4; + productReference = 268D9567257A07B80030EC4D /* day4 */; + productType = "com.apple.product-type.tool"; + }; + 268D9575257B52290030EC4D /* day5 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 268D957A257B52290030EC4D /* Build configuration list for PBXNativeTarget "day5" */; + buildPhases = ( + 268D9572257B52290030EC4D /* Sources */, + 268D9573257B52290030EC4D /* Frameworks */, + 268D9574257B52290030EC4D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day5; + productName = day5; + productReference = 268D9576257B52290030EC4D /* day5 */; + productType = "com.apple.product-type.tool"; + }; + 268D9585257CB8DA0030EC4D /* day6 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 268D958C257CB8DA0030EC4D /* Build configuration list for PBXNativeTarget "day6" */; + buildPhases = ( + 268D9582257CB8DA0030EC4D /* Sources */, + 268D9583257CB8DA0030EC4D /* Frameworks */, + 268D9584257CB8DA0030EC4D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day6; + productName = day6; + productReference = 268D9586257CB8DA0030EC4D /* day6 */; + productType = "com.apple.product-type.tool"; + }; + 26E2ACD4257ECFFA00702405 /* day8 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 26E2ACDB257ECFFA00702405 /* Build configuration list for PBXNativeTarget "day8" */; + buildPhases = ( + 26E2ACD1257ECFFA00702405 /* Sources */, + 26E2ACD2257ECFFA00702405 /* Frameworks */, + 26E2ACD3257ECFFA00702405 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day8; + productName = day8; + productReference = 26E2ACD5257ECFFA00702405 /* day8 */; + productType = "com.apple.product-type.tool"; + }; + 26E2ACF9258009FE00702405 /* day9 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 26E2ACFE258009FE00702405 /* Build configuration list for PBXNativeTarget "day9" */; + buildPhases = ( + 26E2ACF6258009FE00702405 /* Sources */, + 26E2ACF7258009FE00702405 /* Frameworks */, + 26E2ACF8258009FE00702405 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day9; + productName = day9; + productReference = 26E2ACFA258009FE00702405 /* day9 */; + productType = "com.apple.product-type.tool"; + }; + 26E2AD1D25816EE100702405 /* day10 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 26E2AD2425816EE100702405 /* Build configuration list for PBXNativeTarget "day10" */; + buildPhases = ( + 26E2AD1A25816EE100702405 /* Sources */, + 26E2AD1B25816EE100702405 /* Frameworks */, + 26E2AD1C25816EE100702405 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day10; + productName = day10; + productReference = 26E2AD1E25816EE100702405 /* day10 */; + productType = "com.apple.product-type.tool"; + }; + 26E2AD52258343D800702405 /* day11 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 26E2AD59258343D800702405 /* Build configuration list for PBXNativeTarget "day11" */; + buildPhases = ( + 26E2AD4F258343D800702405 /* Sources */, + 26E2AD50258343D800702405 /* Frameworks */, + 26E2AD51258343D800702405 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = day11; + productName = day11; + productReference = 26E2AD53258343D800702405 /* day11 */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 268D953125781DD80030EC4D /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1220; + LastUpgradeCheck = 1220; + TargetAttributes = { + 2617623E257DFD0800D00A66 = { + CreatedOnToolsVersion = 12.2; + }; + 268D953825781DD80030EC4D = { + CreatedOnToolsVersion = 12.2; + }; + 268D954725781F740030EC4D = { + CreatedOnToolsVersion = 12.2; + }; + 268D9558257904250030EC4D = { + CreatedOnToolsVersion = 12.2; + }; + 268D9566257A07B80030EC4D = { + CreatedOnToolsVersion = 12.2; + }; + 268D9575257B52290030EC4D = { + CreatedOnToolsVersion = 12.2; + }; + 268D9585257CB8DA0030EC4D = { + CreatedOnToolsVersion = 12.2; + }; + 26E2ACD4257ECFFA00702405 = { + CreatedOnToolsVersion = 12.2; + }; + 26E2ACF9258009FE00702405 = { + CreatedOnToolsVersion = 12.2; + }; + 26E2AD1D25816EE100702405 = { + CreatedOnToolsVersion = 12.2; + }; + 26E2AD52258343D800702405 = { + CreatedOnToolsVersion = 12.2; + }; + }; + }; + buildConfigurationList = 268D953425781DD80030EC4D /* Build configuration list for PBXProject "AdventOfCode2020" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 268D953025781DD80030EC4D; + productRefGroup = 268D953A25781DD80030EC4D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 268D953825781DD80030EC4D /* day1 */, + 268D954725781F740030EC4D /* day2 */, + 268D9558257904250030EC4D /* day3 */, + 268D9566257A07B80030EC4D /* day4 */, + 268D9575257B52290030EC4D /* day5 */, + 268D9585257CB8DA0030EC4D /* day6 */, + 2617623E257DFD0800D00A66 /* day7 */, + 26E2ACD4257ECFFA00702405 /* day8 */, + 26E2ACF9258009FE00702405 /* day9 */, + 26E2AD1D25816EE100702405 /* day10 */, + 26E2AD52258343D800702405 /* day11 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 2617623B257DFD0800D00A66 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACEC257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 26176242257DFD0800D00A66 /* main.swift in Sources */, + 26E2AD412581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D953525781DD80030EC4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACE6257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 268D953D25781DD80030EC4D /* main.swift in Sources */, + 26E2AD3B2581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D954425781F740030EC4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACE7257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 268D954B25781F740030EC4D /* main.swift in Sources */, + 26E2AD3C2581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9555257904250030EC4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACE8257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 268D955C257904250030EC4D /* main.swift in Sources */, + 26E2AD3D2581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9563257A07B80030EC4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACE9257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 268D956A257A07B80030EC4D /* main.swift in Sources */, + 26E2AD3E2581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9572257B52290030EC4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACEA257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 268D9579257B52290030EC4D /* main.swift in Sources */, + 26E2AD3F2581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 268D9582257CB8DA0030EC4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACEB257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 268D9589257CB8DA0030EC4D /* main.swift in Sources */, + 26E2AD402581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2ACD1257ECFFA00702405 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2ACED257ED09000702405 /* Scanner+Extensions.swift in Sources */, + 26E2ACD8257ECFFA00702405 /* main.swift in Sources */, + 26E2AD422581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2ACF6258009FE00702405 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2AD0A25800A1400702405 /* Scanner+Extensions.swift in Sources */, + 26E2ACFD258009FE00702405 /* main.swift in Sources */, + 26E2AD432581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2AD1A25816EE100702405 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2AD2F25816EE700702405 /* Scanner+Extensions.swift in Sources */, + 26E2AD2125816EE100702405 /* main.swift in Sources */, + 26E2AD442581713A00702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 26E2AD4F258343D800702405 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 26E2AD65258343E300702405 /* Scanner+Extensions.swift in Sources */, + 26E2AD56258343D800702405 /* main.swift in Sources */, + 26E2AD71258343E600702405 /* LoadData.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 26176243257DFD0800D00A66 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 26176244257DFD0800D00A66 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 268D953E25781DD80030EC4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 268D953F25781DD80030EC4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 268D954125781DD80030EC4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 268D954225781DD80030EC4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 268D954D25781F740030EC4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 268D954E25781F740030EC4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 268D955D257904250030EC4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 268D955E257904250030EC4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 268D956C257A07B80030EC4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 268D956D257A07B80030EC4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 268D957B257B52290030EC4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 268D957C257B52290030EC4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 268D958A257CB8DA0030EC4D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 268D958B257CB8DA0030EC4D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 26E2ACD9257ECFFA00702405 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 26E2ACDA257ECFFA00702405 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 26E2ACFF258009FE00702405 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 26E2AD00258009FE00702405 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 26E2AD2225816EE100702405 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 26E2AD2325816EE100702405 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 26E2AD57258343D800702405 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 26E2AD58258343D800702405 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 722B335UM5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 26176245257DFD0800D00A66 /* Build configuration list for PBXNativeTarget "day7" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 26176243257DFD0800D00A66 /* Debug */, + 26176244257DFD0800D00A66 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 268D953425781DD80030EC4D /* Build configuration list for PBXProject "AdventOfCode2020" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 268D953E25781DD80030EC4D /* Debug */, + 268D953F25781DD80030EC4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 268D954025781DD80030EC4D /* Build configuration list for PBXNativeTarget "day1" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 268D954125781DD80030EC4D /* Debug */, + 268D954225781DD80030EC4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 268D954C25781F740030EC4D /* Build configuration list for PBXNativeTarget "day2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 268D954D25781F740030EC4D /* Debug */, + 268D954E25781F740030EC4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 268D955F257904250030EC4D /* Build configuration list for PBXNativeTarget "day3" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 268D955D257904250030EC4D /* Debug */, + 268D955E257904250030EC4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 268D956B257A07B80030EC4D /* Build configuration list for PBXNativeTarget "day4" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 268D956C257A07B80030EC4D /* Debug */, + 268D956D257A07B80030EC4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 268D957A257B52290030EC4D /* Build configuration list for PBXNativeTarget "day5" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 268D957B257B52290030EC4D /* Debug */, + 268D957C257B52290030EC4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 268D958C257CB8DA0030EC4D /* Build configuration list for PBXNativeTarget "day6" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 268D958A257CB8DA0030EC4D /* Debug */, + 268D958B257CB8DA0030EC4D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 26E2ACDB257ECFFA00702405 /* Build configuration list for PBXNativeTarget "day8" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 26E2ACD9257ECFFA00702405 /* Debug */, + 26E2ACDA257ECFFA00702405 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 26E2ACFE258009FE00702405 /* Build configuration list for PBXNativeTarget "day9" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 26E2ACFF258009FE00702405 /* Debug */, + 26E2AD00258009FE00702405 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 26E2AD2425816EE100702405 /* Build configuration list for PBXNativeTarget "day10" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 26E2AD2225816EE100702405 /* Debug */, + 26E2AD2325816EE100702405 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 26E2AD59258343D800702405 /* Build configuration list for PBXNativeTarget "day11" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 26E2AD57258343D800702405 /* Debug */, + 26E2AD58258343D800702405 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 268D953125781DD80030EC4D /* Project object */; +} diff --git a/AdventOfCode2020.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/AdventOfCode2020.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/AdventOfCode2020.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/AdventOfCode2020.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/AdventOfCode2020.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/AdventOfCode2020.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/common/LoadData.swift b/common/LoadData.swift new file mode 100644 index 0000000..322be0f --- /dev/null +++ b/common/LoadData.swift @@ -0,0 +1,30 @@ +import Foundation + +func loadData(day: Int) -> String { + guard let session = getenv("SESSION") else { + fatalError("Missing session env var") + } + + var request = URLRequest(url: URL(string: "https://adventofcode.com/2020/day/\(day)/input")!) + request.setValue("session=\(String(cString: session))", forHTTPHeaderField: "Cookie") + + var result: String? = nil + + let group = DispatchGroup() + + group.enter() + let task = URLSession.shared.dataTask(with: request) { (data, response, error) in + guard error == nil, let data = data, let response = response as? HTTPURLResponse, response.statusCode == 200 else { + fatalError("Cannot get input from server") + } + + result = String(data: data, encoding: .utf8) + group.leave() + } + + task.resume() + + group.wait() + + return result! +} diff --git a/common/Scanner+Extensions.swift b/common/Scanner+Extensions.swift new file mode 100644 index 0000000..9a57bbd --- /dev/null +++ b/common/Scanner+Extensions.swift @@ -0,0 +1,26 @@ +import Foundation + +extension Scanner { + @discardableResult + func string(_ string: String) -> Bool { + return scanString(string) != nil + } + + func integers() -> [Int]? { + var numbers: [Int] = [] + while !isAtEnd { + guard let num = scanInt() else { return nil } + numbers.append(num) + } + return numbers + } +} + + +extension String { + func lines() -> [String] { + var result: [String] = [] + enumerateLines { line, _ in result.append(line) } + return result + } +} diff --git a/day1/main.swift b/day1/main.swift new file mode 100644 index 0000000..a70f62f --- /dev/null +++ b/day1/main.swift @@ -0,0 +1,21 @@ +import Foundation + +let input = Scanner(string: loadData(day: 1)).integers()! + +for i in 0.. $1 } +adapters.append(0) + + +let device = adapters[0] + 3 + +var current = device +var ones = 0 +var threes = 0 + +for adapter in adapters { + let step = current - adapter + if step == 3 { + threes += 1 + } else if step == 1 { + ones += 1 + } else if step != 2 { + print("fail") + } + current = adapter +} + +print("part 1", ones * threes) + +struct Key: Hashable { + var start: Int + var max: Int +} +var memo: [Key: Int] = [:] + +func findPaths(start: Int, max: Int) -> Int { + if let value = memo[Key(start: start, max: max)] { + return value + } + + let diff = max - adapters[start] + if diff > 3 || diff < 1 { + return 0 + } + + if start == adapters.count - 1 { + return 1 + } + + var result = 0 + for n in (start + 1)..<(adapters.count) { + let next = findPaths(start: n, max: adapters[start]) + if next == 0 { + break + } + result += next + } + + memo[Key(start: start, max: max)] = result + + return result +} + +print(findPaths(start: 0, max: device)) diff --git a/day11/main.swift b/day11/main.swift new file mode 100644 index 0000000..f8be0a0 --- /dev/null +++ b/day11/main.swift @@ -0,0 +1,116 @@ +import Foundation + +let input = loadData(day: 11) + +enum Spot: Equatable { + case empty + case occupied + case floor +} +typealias Map = [[Spot]] + +var map: Map = [] + +input.enumerateLines { (line, _) in + map.append(line.map { + switch $0 { + case ".": return .floor + case "#": return .occupied + case "L": return .empty + default: fatalError("Invalid input") + } + }) +} + + +let adjacents = [ + (-1, -1), + (0, -1), + (1, -1), + (-1, 0), + (1, 0), + (-1, 1), + (0, 1), + (1, 1) +] + +/* + func step(map: Map) -> Map { + var result = map + let width = map[0].count + + for i in 0..= 4: result[i][j] = .empty + default: break + } + } + } + + return result + } + + */ + +func occupiedInDirection(at pos: (Int, Int), map: Map, direction: (Int, Int)) -> Int { + var pos = pos + + let yRange = 0.. Map { + var result = map + let width = map[0].count + + for i in 0..= 5: result[i][j] = .empty + default: break + } + } + } + + return result +} + + +while true { + let next = step(map: map) + if next == map { + break + } + map = next +} + +let totalOccupieds = map.lazy.flatMap { $0 }.filter { $0 == .occupied }.count +print(totalOccupieds) diff --git a/day2/main.swift b/day2/main.swift new file mode 100644 index 0000000..54879b3 --- /dev/null +++ b/day2/main.swift @@ -0,0 +1,39 @@ +import Foundation + +let input = loadData(day: 2) + +var valids = 0 +var valid2 = 0 + +var scanner = Scanner(string: input) +while !scanner.isAtEnd { + guard let min = scanner.scanInt(), + scanner.scanString("-") != nil, + let max = scanner.scanInt(), + let character = scanner.scanCharacter(), + scanner.scanString(":") != nil, + let password = scanner.scanUpToCharacters(from: .newlines) + else { + fatalError("Invalid input"); + } + + + let count = password.lazy.filter { $0 == character }.count + + if min <= count && count <= max { + print("valid", min, max, character, password) + valids += 1 + } + + let first = password.index(password.startIndex, offsetBy: min - 1, limitedBy: password.endIndex).map { password[$0] } + let second = password.index(password.startIndex, offsetBy: max - 1, limitedBy: password.endIndex).map { password[$0] } + + if (first == character || second == character) && first != second { + print("valid 2", password) + valid2 += 1 + } + +} + +print("Valid old", valids) +print("Valid new", valid2) diff --git a/day3/main.swift b/day3/main.swift new file mode 100644 index 0000000..9f7392d --- /dev/null +++ b/day3/main.swift @@ -0,0 +1,32 @@ +let input = loadData(day: 3).lines() + +/// - returns true if a tree is at that position, false if it is empty +func get(x: Int, y: Int) -> Bool { + let line = input[y] + let index = line.index(line.startIndex, offsetBy: x % line.count) + return line[index] == "#" +} + +func calculate(dx: Int, dy: Int) -> Int { +var x = 0 +var y = 0 + +var trees = 0 + +while y < input.count { + if get(x: x, y: y) { + trees += 1 + } + + x += dx + y += dy +} + + return trees +} + +let trees = calculate(dx: 3, dy: 1) +print("trees", trees) + + +print("combined", calculate(dx: 1, dy: 1) * calculate(dx: 3, dy: 1) * calculate(dx: 5, dy: 1) * calculate(dx: 7, dy: 1) * calculate(dx: 1, dy: 2)) diff --git a/day4/main.swift b/day4/main.swift new file mode 100644 index 0000000..ae1542e --- /dev/null +++ b/day4/main.swift @@ -0,0 +1,99 @@ +import Foundation + +let input = loadData(day: 4) + +let scanner = Scanner(string: input) +scanner.charactersToBeSkipped = nil + +extension Scanner { + func field() -> (String, String)? { + guard let name = scanUpToString(":"), + scanString(":") != nil, + let value = scanUpToCharacters(from: .whitespacesAndNewlines) + else { return nil } + return (name, value) + } + + func passport() -> [String: String]? { + var fields = [(String, String)]() + while !isAtEnd && scanString("\n\n") == nil { + _ = scanner.scanCharacters(from: .whitespacesAndNewlines) + guard let field = field() else { return nil } + fields.append(field) + } + return try? Dictionary(fields, uniquingKeysWith: { _, _ in throw NSError(domain: "error", code: 1, userInfo: nil) }) + } +} + +var valids = 0 +var valid2 = 0 + +let requiredFields = [ + "byr", + "iyr", + "eyr", + "hgt", + "hcl", + "ecl", + "pid", +] + +func validHeight(_ height: String) -> Bool { + let scanner = Scanner(string: height) + guard let number = scanner.scanInt() else { return false } + if scanner.scanString("cm") != nil, 150...193 ~= number { + return true + } + + if scanner.scanString("in") != nil, 59...76 ~= number { + return true + } + + return false +} + +func validHairColor(_ hcl: String) -> Bool { + let scanner = Scanner(string: hcl) + guard scanner.scanString("#") != nil else { return false } + guard scanner.scanCharacters(from: CharacterSet(charactersIn: "0123456789abcdef"))?.count == 6 else { return falseĀ } + return scanner.isAtEnd +} + +let validEyeColors: Set = [ + "amb", + "blu", + "brn", + "gry", + "grn", + "hzl", + "oth" +] + +func isValidPassportId(_ pid: String) -> Bool { + return pid.count == 9 && Int(pid) != nil +} + +while !scanner.isAtEnd { + guard let passport = scanner.passport() else { fatalError() } + print(passport) + + let valid = requiredFields.allSatisfy { passport.keys.contains($0) } + if valid { + valids += 1 + } + + guard let year = passport["byr"].flatMap(Int.init), 1920...2002 ~= year else { continue } + guard let issueYear = passport["iyr"].flatMap(Int.init), 2010...2020 ~= issueYear else { continue } + guard let expireYear = passport["eyr"].flatMap(Int.init), 2020...2030 ~= expireYear else { continue } + guard let height = passport["hgt"], validHeight(height) else { continue } + guard let hairColor = passport["hcl"], validHairColor(hairColor) else { continue } + guard let eyeColor = passport["ecl"], validEyeColors.contains(eyeColor) else { continue } + guard let pid = passport["pid"], isValidPassportId(pid) else { continue } + + valid2 += 1 + +} + +print("valids", valids) +print("valid2", valid2) + diff --git a/day5/main.swift b/day5/main.swift new file mode 100644 index 0000000..687c52d --- /dev/null +++ b/day5/main.swift @@ -0,0 +1,35 @@ +let input = loadData(day: 5).lines() + +func decode(_ s: Substring, lower: Character, upper: Character, range: Range) -> (Int, Substring) +{ + var range = range + var start = s.startIndex + while start != s.endIndex && (s[start] == lower || s[start] == upper) { + let mid = (range.lowerBound + range.upperBound) / 2 + if s[start] == lower { + range = range.lowerBound.. Int { + let (row, rest) = decode(s[...], lower: "F", upper: "B", range: 0..<128) + let (column, _) = decode(rest, lower: "L", upper: "R", range: 0..<8) + let id = row * 8 + column + print(s, row, column, id) + return id +} + +let foundSeats = Set(input.map { decodeSeat($0) }) +print("max seat id", foundSeats.max() ?? -1) + +let allSeats = Set(0...(7+127*8)) +let freeSeats = allSeats.subtracting(foundSeats) + +let yours = freeSeats.first(where: { foundSeats.contains($0 + 1) && foundSeats.contains($0 - 1)}) +print("yours", yours ?? -1) diff --git a/day6/main.swift b/day6/main.swift new file mode 100644 index 0000000..5edf2f9 --- /dev/null +++ b/day6/main.swift @@ -0,0 +1,34 @@ +import Foundation + +var input = loadData(day: 6) + +let scanner = Scanner(string: input) +scanner.charactersToBeSkipped = nil + +var count = 0 +var countB = 0 +var currentGroup: [Character:Int] = [:] +var peopleInGroup = 0 + +repeat { + guard let answers = scanner.scanUpToString("\n") else { fatalError() } + peopleInGroup += 1 + _ = scanner.scanString("\n") + + for answer in answers { + currentGroup[answer, default: 0] += 1 + } + + if scanner.isAtEnd || scanner.scanString("\n") != nil { + count += currentGroup.count + + countB += currentGroup.lazy.filter { $1 == peopleInGroup }.count + + currentGroup.removeAll(keepingCapacity: true) + peopleInGroup = 0 + } + +} while !scanner.isAtEnd + +print("count", count) +print("part 2", countB) diff --git a/day7/main.swift b/day7/main.swift new file mode 100644 index 0000000..622a0ec --- /dev/null +++ b/day7/main.swift @@ -0,0 +1,74 @@ +import Foundation + +let input = loadData(day: 7) + + +let scanner = Scanner(string: input) + +struct Rule { + var count: Int + var color: String +} + +extension Scanner { + func scanRule() -> Rule? { + guard let count = scanInt(), + let color = scanUpToString(count == 1 ? " bag" : " bags"), + scanString(count == 1 ? "bag" : "bags") != nil + else { return nil } + return Rule(count: count, color: color) + } + + func scanRuleSet() -> (String, [Rule])? { + guard + let color = scanUpToString(" bags contain"), + scanString("bags contain") != nil else { return nil } + if scanString("no other bags.") != nil { + return (color, []) + } + + var rules: [Rule] = [] + repeat { + guard let rule = scanRule() else { return nil } + rules.append(rule) + } while scanString(",") != nil + + guard scanString(".") != nil else { return nil } + + return (color, rules) + } + + func scanAllRules() -> [String: [Rule]]? { + var result: [String: [Rule]] = [:] + while !isAtEnd { + guard let (color, rules) = scanRuleSet() else { return nil } + result[color] = rules + } + return result + } +} + +guard let rules = scanner.scanAllRules() else { fatalError() } +//print(rules) + +func findPath(rules: [String: [Rule]], from: String, to: String) -> Bool { + guard let from = rules[from] else { return false } + if from.contains(where: { $0.color == to }) { + return true + } + + return from.contains(where: { findPath(rules: rules, from: $0.color, to: to) }) +} + +let count = rules.lazy.filter { findPath(rules: rules, from: $0.key, to: "shiny gold") }.count + +print("count", count) + +func bagsInside(rules: [String: [Rule]], color: String) -> Int { + guard let from = rules[color] else { return 0 } + return from.reduce(0) { accum, bag in + accum + bag.count + bag.count * bagsInside(rules: rules, color: bag.color) + } +} + +print("total bags", bagsInside(rules: rules, color: "shiny gold")) diff --git a/day8/main.swift b/day8/main.swift new file mode 100644 index 0000000..bf93990 --- /dev/null +++ b/day8/main.swift @@ -0,0 +1,134 @@ +import Foundation + +let input = loadData(day: 8) + +let scanner = Scanner(string: input) + +enum Instruction: String { + case nop + case acc + case jmp +} + +struct Line { + var instruction: Instruction + var argument: Int +} + +extension Scanner { + func instruction() -> Instruction? { + guard let string = scanUpToCharacters(from: .whitespaces), + let instruction = Instruction(rawValue: string) + else { return nil } + return instruction + } + + func line() -> Line? { + guard let ins = instruction(), + let argument = scanInt() + else { return nil } + return Line(instruction: ins, argument: argument) + } + + func program() -> [Line]? { + var program = [Line]() + while !isAtEnd { + guard let line = self.line() else { return nil } + program.append(line) + } + return program + } +} + +class Computer { + var program: [Line] + var ip: Int = 0 + var acc: Int = 0 + + init(program: [Line]) { + self.program = program + } + + var visited: Set = [] + + func runLine() { + let line = program[ip] + switch line.instruction { + case .nop: + ip += 1 + + case .acc: + acc += line.argument + ip += 1 + + case .jmp: + ip += line.argument + } + } + + func run() { + ip = 0 + acc = 0 + + while ip < program.count { + let (inserted, _) = visited.insert(ip) + if !inserted { + print("Repeated instruction", acc) + return + } + + runLine() + } + print("Finished", acc) + } + + func find(ip: Int, acc: Int, changed: Bool, visited: Set) -> Int? + { + if ip >= program.count { + return acc + } + + if (visited.contains(ip)) { + return nil + } + + let newVisited = visited.union([ip]) + + let line = program[ip] + switch line.instruction { + case .acc: + return find(ip: ip + 1, acc: acc + line.argument, changed: changed, visited: newVisited) + + case .nop: + if let result = find(ip: ip + 1, acc: acc, changed: changed, visited: newVisited) { + return result + } + + if !changed, let result = find(ip: ip + line.argument, acc: acc, changed: true, visited: newVisited) { + print("Found result by changing nop to jmp at", ip) + return result + } + + case .jmp: + if let result = find(ip: ip + line.argument, acc: acc, changed: changed, visited: newVisited) { + return result + } + + if !changed, let result = find(ip: ip + 1, acc: acc, changed: true, visited: newVisited) { + print("Found result by changing jmp to nop at", ip) + return result + } + } + + return nil + } +} + +guard let program = scanner.program() else { fatalError() } +let computer = Computer(program: program) +computer.run() +if let found = computer.find(ip: 0, acc: 0, changed: false, visited: []) { + print("found solution", found) +} + + diff --git a/day9/main.swift b/day9/main.swift new file mode 100644 index 0000000..3dbf41a --- /dev/null +++ b/day9/main.swift @@ -0,0 +1,45 @@ +import Foundation + +let input = loadData(day: 9) +let scanner = Scanner(string: input) + +let numbers = scanner.integers()! + +var weakness: Int? = nil +outer: for i in 25.. max { max = n } + if sum == weakness { + print(min + max) + break outer + } + if sum > weakness { + break + } + } +}