diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..7671a45 Binary files /dev/null and b/.DS_Store differ diff --git a/FindMyName/FindMyName.xcodeproj/project.pbxproj b/FindMyName/FindMyName.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3cdbb5f --- /dev/null +++ b/FindMyName/FindMyName.xcodeproj/project.pbxproj @@ -0,0 +1,246 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + BFC2CC2D1C5ABFAF000252A7 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC2CC2C1C5ABFAF000252A7 /* main.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + BFC2CC271C5ABFAF000252A7 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + BFC2CC291C5ABFAF000252A7 /* FindMyName */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = FindMyName; sourceTree = BUILT_PRODUCTS_DIR; }; + BFC2CC2C1C5ABFAF000252A7 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BFC2CC261C5ABFAF000252A7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + BFC2CC201C5ABFAE000252A7 = { + isa = PBXGroup; + children = ( + BFC2CC2B1C5ABFAF000252A7 /* FindMyName */, + BFC2CC2A1C5ABFAF000252A7 /* Products */, + ); + sourceTree = ""; + }; + BFC2CC2A1C5ABFAF000252A7 /* Products */ = { + isa = PBXGroup; + children = ( + BFC2CC291C5ABFAF000252A7 /* FindMyName */, + ); + name = Products; + sourceTree = ""; + }; + BFC2CC2B1C5ABFAF000252A7 /* FindMyName */ = { + isa = PBXGroup; + children = ( + BFC2CC2C1C5ABFAF000252A7 /* main.swift */, + ); + path = FindMyName; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BFC2CC281C5ABFAF000252A7 /* FindMyName */ = { + isa = PBXNativeTarget; + buildConfigurationList = BFC2CC301C5ABFAF000252A7 /* Build configuration list for PBXNativeTarget "FindMyName" */; + buildPhases = ( + BFC2CC251C5ABFAF000252A7 /* Sources */, + BFC2CC261C5ABFAF000252A7 /* Frameworks */, + BFC2CC271C5ABFAF000252A7 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = FindMyName; + productName = FindMyName; + productReference = BFC2CC291C5ABFAF000252A7 /* FindMyName */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BFC2CC211C5ABFAF000252A7 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0720; + LastUpgradeCheck = 0720; + ORGANIZATIONNAME = "Charles Kang"; + TargetAttributes = { + BFC2CC281C5ABFAF000252A7 = { + CreatedOnToolsVersion = 7.2; + }; + }; + }; + buildConfigurationList = BFC2CC241C5ABFAF000252A7 /* Build configuration list for PBXProject "FindMyName" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = BFC2CC201C5ABFAE000252A7; + productRefGroup = BFC2CC2A1C5ABFAF000252A7 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BFC2CC281C5ABFAF000252A7 /* FindMyName */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + BFC2CC251C5ABFAF000252A7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BFC2CC2D1C5ABFAF000252A7 /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + BFC2CC2E1C5ABFAF000252A7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + BFC2CC2F1C5ABFAF000252A7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + BFC2CC311C5ABFAF000252A7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + BFC2CC321C5ABFAF000252A7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BFC2CC241C5ABFAF000252A7 /* Build configuration list for PBXProject "FindMyName" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BFC2CC2E1C5ABFAF000252A7 /* Debug */, + BFC2CC2F1C5ABFAF000252A7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BFC2CC301C5ABFAF000252A7 /* Build configuration list for PBXNativeTarget "FindMyName" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BFC2CC311C5ABFAF000252A7 /* Debug */, + BFC2CC321C5ABFAF000252A7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = BFC2CC211C5ABFAF000252A7 /* Project object */; +} diff --git a/FindMyName/FindMyName.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/FindMyName/FindMyName.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..015b558 --- /dev/null +++ b/FindMyName/FindMyName.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/FindMyName/FindMyName.xcodeproj/project.xcworkspace/xcshareddata/FindMyName.xcscmblueprint b/FindMyName/FindMyName.xcodeproj/project.xcworkspace/xcshareddata/FindMyName.xcscmblueprint new file mode 100644 index 0000000..0ba4e3b --- /dev/null +++ b/FindMyName/FindMyName.xcodeproj/project.xcworkspace/xcshareddata/FindMyName.xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F99ED118-F946-491B-9E4D-CADBB75CBA04", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "FindMyName", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "FindMyName\/FindMyName.xcodeproj", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/FindMyName/FindMyName/main.swift b/FindMyName/FindMyName/main.swift new file mode 100644 index 0000000..ff3c593 --- /dev/null +++ b/FindMyName/FindMyName/main.swift @@ -0,0 +1,40 @@ +// +// main.swift +// FindMyName +// +// Created by Charles Kang on 1/28/16. +// Copyright © 2016 Charles Kang. All rights reserved. +// + +import Foundation + +func findFile(name: String, atPath: String) -> String { + let fileManager = NSFileManager.defaultManager() + let contents = + try! fileManager.contentsOfDirectoryAtPath(atPath) + for fileOrDir in contents { + var isDir = ObjCBool(false); + let fullPath = atPath + "/" + fileOrDir + let exists = fileManager.fileExistsAtPath(fullPath, isDirectory: &isDir) + if exists && Bool(isDir) { + + print("DIR: " + fileOrDir) + } else if exists { + // YOUR CODE HERE + print("FILE: " + fileOrDir) + } else { + print("NEITHER: " + fileOrDir) + } + } + return "NOT FOUND" +} + +print(findFile("awesome-idea.txt", atPath: "/Users/charleshyowonkang/Documents")) + + +func mergeSort(left: [Int], _ right: [Int]) -> [Int] { + return [] // change this +} + + + diff --git a/HWFrom1-17-16(Lists and Sorts).playground/Contents.swift b/HWFrom1-17-16(Lists and Sorts).playground/Contents.swift index 13cc14e..31c9057 100644 --- a/HWFrom1-17-16(Lists and Sorts).playground/Contents.swift +++ b/HWFrom1-17-16(Lists and Sorts).playground/Contents.swift @@ -11,16 +11,68 @@ Work on your solutions here. Link: https://docs.google.com/document/d/1INvOynuggw69yLRNg3y-TPwBiYb3lQZQiFUOxZKBwsY/edit#heading=h.za36ai6n5fth -1) - - - -2) - - - -3) - +1) +*/ +var sudokuBoard = [ + [5, 0, 8, 0, 7, 3, 1, 9, 0], + [9, 0, 0, 6, 0, 0, 4, 0, 8], + [0, 0, 0, 9, 0, 8, 0, 3, 5], + [0, 7, 0, 0, 0, 0, 0, 6, 0], + [0, 0, 2, 0, 0, 0, 9, 0, 0], + [0, 1, 0, 0, 0, 0, 0, 8, 0], + [1, 9, 0, 3, 0, 6, 0, 0, 0], + [2, 0, 3, 0, 0, 7, 0, 0, 9], + [0, 8, 7, 1, 9, 0, 3, 0, 4]] + +var rowNumbers = [[Int]]() +var columbNumbers = [[Int]]() +var potentialNumbers = [Int]() +var allNumbers = [Int]() + + +func getRowNumbers(sudokuBoard:[[Int]], row: Int, column: Int) -> [Int] { + for var i = 0; i <= sudokuBoard.count - 1; i++ { + for var j = 0; i <= sudokuBoard[i].count; j++ { + print(sudokuBoard[i][j]) + // allNumbers.append.[i] + } + } + return (sudokuBoard[0]) +} + + + +for i in sudokuBoard { + for j in i { + print(j) + } +} + +for (var k = 0; k < sudokuBoard.count; k++) { + for (var l = 0; l < k; l++) { + print(l) + + } +} + +// this is as far as I got with question 1. i think using a set and the exclusiveOr function could make this +// a lot easier to solve + +// 2) +var rotateArray = [ + [1,2,3,4], + [5,6,7,8], + [9,0,1,2], + [3,4,5,6]] + +func rotate90Degrees(rotateArray:[[Int]], row: Int, column: Int) -> [Int] { + for i in rotateArray { + for j in i { + print(j) + } + } + return [3,9,5,1] + +} -*/ diff --git a/HWFrom1-17-16(Lists and Sorts).playground/playground.xcworkspace/xcshareddata/HWFrom1-17-16(Lists and Sorts).xcscmblueprint b/HWFrom1-17-16(Lists and Sorts).playground/playground.xcworkspace/xcshareddata/HWFrom1-17-16(Lists and Sorts).xcscmblueprint new file mode 100644 index 0000000..e0b0b5a --- /dev/null +++ b/HWFrom1-17-16(Lists and Sorts).playground/playground.xcworkspace/xcshareddata/HWFrom1-17-16(Lists and Sorts).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "86FC27F0-DA27-4259-BA97-C66B429CB6A6", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWFrom1-17-16(Lists and Sorts)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWFrom1-17-16(Lists and Sorts).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWFrom1-24(Recursion).playground/Contents.swift b/HWFrom1-24(Recursion).playground/Contents.swift index 1c44504..ce81224 100644 --- a/HWFrom1-24(Recursion).playground/Contents.swift +++ b/HWFrom1-24(Recursion).playground/Contents.swift @@ -10,16 +10,45 @@ Homework link: https://docs.google.com/document/d/1INvOynuggw69yLRNg3y-TPwBiYb3l //Question 1 - - - - - +// http://stackoverflow.com/questions/28161197/swift-vs-objective-c-fibonacci-sequence-speed-comparison + +func fib(num: Int) -> Int{ + if(num == 0){ + return 0; + } + if(num == 1){ + return 1; + } + return fib(num - 1) + fib(num - 2); +} + +// cameron's code +//func fib(n: Int) -> Int { +// var a = 0 +// var b = 1 +// for _ in 0.. Bool { + let success = Int(arc4random_uniform(4)) > 0 + if (success) { + stepNum++ + print("Yay \(stepNum)") + } else { + stepNum-- + print("Noo \(stepNum)") + } + return success +} +// cameron's code - -//Question 3 \ No newline at end of file +//Question 3 diff --git a/HWFrom1-24(Recursion).playground/playground.xcworkspace/xcshareddata/HWFrom1-24(Recursion).xcscmblueprint b/HWFrom1-24(Recursion).playground/playground.xcworkspace/xcshareddata/HWFrom1-24(Recursion).xcscmblueprint new file mode 100644 index 0000000..fdff420 --- /dev/null +++ b/HWFrom1-24(Recursion).playground/playground.xcworkspace/xcshareddata/HWFrom1-24(Recursion).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "59B9B9C5-FD57-4334-B265-62F0807339F5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWFrom1-24(Recursion)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWFrom1-24(Recursion).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWFrom1-28-16(Merge Sort).playground/playground.xcworkspace/xcshareddata/HWFrom1-28-16(Merge Sort).xcscmblueprint b/HWFrom1-28-16(Merge Sort).playground/playground.xcworkspace/xcshareddata/HWFrom1-28-16(Merge Sort).xcscmblueprint new file mode 100644 index 0000000..ffe8f03 --- /dev/null +++ b/HWFrom1-28-16(Merge Sort).playground/playground.xcworkspace/xcshareddata/HWFrom1-28-16(Merge Sort).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "3C86CAB3-387B-4220-9D91-CF656162AB62", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWFrom1-28-16(Merge Sort)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWFrom1-28-16(Merge Sort).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWFrom1-30-16(QuickSort+Lists+Queues).playground/Contents.swift b/HWFrom1-30-16(QuickSort+Lists+Queues).playground/Contents.swift index bcf8eda..b7013cf 100644 --- a/HWFrom1-30-16(QuickSort+Lists+Queues).playground/Contents.swift +++ b/HWFrom1-30-16(QuickSort+Lists+Queues).playground/Contents.swift @@ -1,16 +1,56 @@ //: Playground - noun: a place where people can play +import Darwin + //Answer the questions in the homework below //https://docs.google.com/document/d/1KlK3PmRMybmHS5db_AP11uHXIcbIeM5vHuuAZOV3xME/edit# //1) -//2) +// My original answers compared to bigocheatsheet + +// Bubble: O(n^2), O(n) +// Insertion: O(2n), O(1) +// Selection: O(n^2) but why? O(1) +// Merge: O(n^2), O(nlogn) +// Quick: O(n^2), O(n^2) + + +// Bubble: O(n), O(1) +// Insertion: O(n), O(1) +// Selection: O(n^2), O(1) +// Merge: O(n log (n)), O(n) +// Quick: O(n log(n)), O(log (n)) + +//2) Partitioning makes quicksort more efficient by having 2 points, a leftMark and a rightMark. + +//3) Can't do it yet without looking but I can explain how to do it, sort of. + // Pick a pivot point, in our case, the element closest to the left + // Set a leftMark and rightMark on the indices of the array + // Swap the elements that are on the wrong side of the "wall" or pivot point + // Keep swapping elements until the rightMark crosses the leftMark + // Finally, swap rightMark with the pivot point so that all numbers to the left are < than pivot point, and numbers to the right are > than pivot point + +//4) Write a function to generate an array of random numbers bounded between 1..<10,000 of size 10,000. + +func generateNumbers() -> [Int] { +var int = 1 + Int(arc4random_uniform(UInt32(10000))) +// for int in Int { + // not sure how to run the for loop to generate random numbers each time. + return [] + } // why can't I return an array of ints even though I have it return an array of ints? + + +// https://www.quora.com/What-is-the-difference-between-quicksort-and-mergesort +//5) The difference between merge and quick sorts are the elements in the array are not completely sorted, just sorted based on the pivot point. Quicksort is generally much faster than merge sort because of the constant multiplier. Quicksort cannot be done iteratively -//3) +//6) -//4) +func isBalanced(paren: [String]) -> Bool { +return true + // think of it like a stack so that whatever enters last needs to be the closer. + // so whenever a symbol enters a stack, check if the first one entered is the closing brace/parenthesis, etc. (is this the right logic?!) -//5) +} -//6) \ No newline at end of file diff --git a/HWFrom1-30-16(QuickSort+Lists+Queues).playground/playground.xcworkspace/xcshareddata/HWFrom1-30-16(QuickSort+Lists+Queues).xcscmblueprint b/HWFrom1-30-16(QuickSort+Lists+Queues).playground/playground.xcworkspace/xcshareddata/HWFrom1-30-16(QuickSort+Lists+Queues).xcscmblueprint new file mode 100644 index 0000000..2302e77 --- /dev/null +++ b/HWFrom1-30-16(QuickSort+Lists+Queues).playground/playground.xcworkspace/xcshareddata/HWFrom1-30-16(QuickSort+Lists+Queues).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "4BE0D784-A81C-4D13-A4EF-7B14D546D3DB", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWFrom1-30-16(QuickSort+Lists+Queues)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWFrom1-30-16(QuickSort+Lists+Queues).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWFrom1-31-16(Sets and HashMaps).playground/Contents.swift b/HWFrom1-31-16(Sets and HashMaps).playground/Contents.swift index c5841b0..bca17c4 100644 --- a/HWFrom1-31-16(Sets and HashMaps).playground/Contents.swift +++ b/HWFrom1-31-16(Sets and HashMaps).playground/Contents.swift @@ -1,3 +1,5 @@ +import Foundation + //: https://docs.google.com/document/d/1T7tYRqpDPWoxarfmXqfRCHB-YqvA8-Qx_mEyy5smtfc @@ -14,7 +16,53 @@ //2) +let blackList: Set = ["crapple", "fandroid", "m$"] + + +func moderate(message : String) -> Bool { + let words = (message as NSString).componentsSeparatedByString(" ") + + for word in words { + if blackList.contains(word.lowercaseString) { + return false + } + } + return true +} + +moderate("I would never use a crApple product!") +moderate("something else") +//3) -//3) \ No newline at end of file +protocol PhoneBookProtocol { + mutating func addPerson(name: String, phoneNumber: String) + mutating func removePerson(name: String) + mutating func importFrom(oldPhonebook: [(String, String)]) + func findPerson(name: String) -> String? // Return phone # +} +classPhoneBook: PhoneBookProtocol { + var storage: [String : String] = [:] // @{} + //var storage = Dictionary() + func addPerson(name: String, phoneNumber: String) { + storage[name] = phoneNumber} + func removePerson(name: String) { + storage.removeValueForKey(name) } + func findPerson(name: String) -> String? { + return storage[name] + func importFrom(oldPhonebook: [(String, String)]) { + for entry in oldPhonebook { + addPerson(entry.0, phoneNumber: entry.1) + } + } + } + + + ​ + let oldData = [("Caleb", "501-555-1234"), ("Mike", "212-555-4321"), ("Jenny", "345-867-5309")] + + let phoneBook = PhoneBook() + phoneBook.importFrom(oldData) + + phoneBook.findPerson("Jenny") \ No newline at end of file diff --git a/HWFrom1-31-16(Sets and HashMaps).playground/playground.xcworkspace/xcshareddata/HWFrom1-31-16(Sets and HashMaps).xcscmblueprint b/HWFrom1-31-16(Sets and HashMaps).playground/playground.xcworkspace/xcshareddata/HWFrom1-31-16(Sets and HashMaps).xcscmblueprint new file mode 100644 index 0000000..2a25871 --- /dev/null +++ b/HWFrom1-31-16(Sets and HashMaps).playground/playground.xcworkspace/xcshareddata/HWFrom1-31-16(Sets and HashMaps).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "59C43B98-6376-4653-B9E9-410807607912", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWFrom1-31-16(Sets and HashMaps)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWFrom1-31-16(Sets and HashMaps).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWfrom1-09-16(SwiftIntro).playground/Contents.swift b/HWfrom1-09-16(SwiftIntro).playground/Contents.swift index 488e9ed..8af6dd5 100644 --- a/HWfrom1-09-16(SwiftIntro).playground/Contents.swift +++ b/HWfrom1-09-16(SwiftIntro).playground/Contents.swift @@ -2,22 +2,77 @@ import UIKit -var str = "Hello, playground" -/* +/* Use the link here to get the questions. Then code your solutions below. If it does not require code, just write your answer in comments. https://docs.google.com/document/d/1DQ2aCJ_yUZtazzCfb0PaS81bg61V2ZOSxpABh981xSo/edit +Given an integer N, there is a list of size N-1 that is missing one number from 1 - N(inclusive). Find that number. +*/ + +// 1) I really don't know how to do this one through code so I'm going to try and explain it through writing... Been at it for like 20 minutes and I don't even know where to start + +// Getting help from http://stackoverflow.com/questions/3492302/easy-interview-question-got-harder-given-numbers-1-100-find-the-missing-numbe -1) +let sum = (n + 1)(n / 2) +// then have a for loop that goes through the total sum +var totalSum = 0 +for i in numbers { + totalSum += i +} +return sum - totalSum // because the missing number will always be the difference of the sum and totalSum? -2) +// copy/paste from my other playground because we did these in class -3) +// 2)Given a list of size N containing numbers 1 - N (inclusive). return true if there are duplicates, false if not -4) +func checkForDuplicates() { + + for var i = 0; i < numbers.count; i++ { + for var n = 0; n < numbers.count; n++ { + if n != i { + if numbers[i] == numbers[n] { + return false + } + } + } + } + return true +} +/* Given two lists, find the smallest value that exists in both lists. +L1 = [1,2,5,9] +L2 = [9, 20 , 5] */ + + +// I doubt that this is even remotely correct but I think I understand it. You need to compare both arrays and have a for loop for each, going through each number and finding the smallest value. Once it does, the loop stops and it should return true(?) Not sure what it should be returning. +let arr1 = [1,2,5,9] +let arr2 = [9,20,5] + +func findSmallestValue() { + for var i = 0; i < arr1.count; i++ { + for var n = 0; n < arr2.count; n++ { + if i && n <= 5 { + return true + } + } + } +} + +// Check to see if an integer is a palindrome don’t use casting +// Still don't understand what casting is... this might help https://howtoprogramwithjava.com/java-cast/ + +func isPalindrome(var number : Int) -> Bool { +let originalNumber = number + var finalNum = 0 + while (number > 0) { + finalNum *= 10 + finalNum += number % 10 + number /= 10 + } +return finalNum == number +} diff --git a/HWfrom1-09-16(SwiftIntro).playground/playground.xcworkspace/xcshareddata/HWfrom1-09-16(SwiftIntro).xcscmblueprint b/HWfrom1-09-16(SwiftIntro).playground/playground.xcworkspace/xcshareddata/HWfrom1-09-16(SwiftIntro).xcscmblueprint new file mode 100644 index 0000000..db68f46 --- /dev/null +++ b/HWfrom1-09-16(SwiftIntro).playground/playground.xcworkspace/xcshareddata/HWfrom1-09-16(SwiftIntro).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "1E33E1B1-A81A-45F7-9378-1596FD355D53", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWfrom1-09-16(SwiftIntro)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWfrom1-09-16(SwiftIntro).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/accesscode-2-2\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWfrom1-10-016(BigO).playground/Contents.swift b/HWfrom1-10-016(BigO).playground/Contents.swift deleted file mode 100644 index 2040d38..0000000 --- a/HWfrom1-10-016(BigO).playground/Contents.swift +++ /dev/null @@ -1,30 +0,0 @@ -//: Playground - noun: a place where people can play - -import UIKit - -var str = "Hello, playground" - -/* - -Use the link here to get the questions. Then code your solutions below. If it does not require code, just write your answer in comments. - -https://docs.google.com/document/d/1aF1imJUVahCSJAuN1OEm5lQXwpSFaAmVmAETKMM6PLQ/edit#heading=h.za36ai6n5fth - - -1) - -2) - -3) - -4) - -5) - -6) - -7) - - -*/ - diff --git a/HWfrom1-10-016(BigO).playground/Pages/Untitled Page 2.xcplaygroundpage/Contents.swift b/HWfrom1-10-016(BigO).playground/Pages/Untitled Page 2.xcplaygroundpage/Contents.swift new file mode 100644 index 0000000..854a033 --- /dev/null +++ b/HWfrom1-10-016(BigO).playground/Pages/Untitled Page 2.xcplaygroundpage/Contents.swift @@ -0,0 +1,7 @@ +//: [Previous](@previous) + +import Foundation + +var str = "Hello, playground" + +//: [Next](@next) diff --git a/HWfrom1-10-016(BigO).playground/Pages/Untitled Page.xcplaygroundpage/Contents.swift b/HWfrom1-10-016(BigO).playground/Pages/Untitled Page.xcplaygroundpage/Contents.swift new file mode 100644 index 0000000..c97a6f6 --- /dev/null +++ b/HWfrom1-10-016(BigO).playground/Pages/Untitled Page.xcplaygroundpage/Contents.swift @@ -0,0 +1,68 @@ +//: Playground - noun: a place where people can play + +import UIKit + + +/* + +Use the link here to get the questions. Then code your solutions below. If it does not require code, just write your answer in comments. + +https://docs.google.com/document/d/1aF1imJUVahCSJAuN1OEm5lQXwpSFaAmVmAETKMM6PLQ/edit#heading=h.za36ai6n5fth + + +1) +memory access = 1 pico +math operations = 3 pico +storing data = 10 pico +time to run = 200 pico + +a) 241 picoseconds +b) O(n^2) +c) O(n^3) correct answer 0(n^4) because makeEvenMoreAwesome gets done twice? O(n^2)(2) + +2) +a) O(n^3), O(n^4) +b) O(n) +c) O(n^2 log(n)) +d) O(n^2) + + +3) +a) binary search tree +b) skip list correct answer: use arrays +c) maybe you could use two queues? one for storing searches as you type, and another for the searched music + answer to c: probably a tree + +4) I don't know the answer to this. What exercise 1? The one from Linus? Wording is confusing for me... + +5) +*/ +func multiplyOldSchool() { + var num = 3 + 3 + 3 + 3 + 3 = 15 + //time complexity = O(13)?! I have no idea +} + +/* +6) +*/ + +// usually when you divide something by two, it's usually O(log^n)... + +func russianMath() { + for (i = 0; i < 104; i++) { + 13 * 83 + } +} +// complexity should be O(n^2) + +// 7) I don't know how to answer this because I don't get question 4. There's only snippet in exercise 1? + +// http://stackoverflow.com/questions/24331566/objective-c-sort-an-array-of-strings-containing-numbers +// http://stackoverflow.com/questions/1063007/how-to-sort-an-array-of-integers-correctly +// http://stackoverflow.com/questions/11075644/sort-nsmutablearray-with-strings-that-contain-numbers + +// I don't even understand what these spreadsheet formulas are. Google spreadsheets? + + + + diff --git a/HWfrom1-10-016(BigO).playground/timeline.xctimeline b/HWfrom1-10-016(BigO).playground/Pages/Untitled Page.xcplaygroundpage/timeline.xctimeline similarity index 100% rename from HWfrom1-10-016(BigO).playground/timeline.xctimeline rename to HWfrom1-10-016(BigO).playground/Pages/Untitled Page.xcplaygroundpage/timeline.xctimeline diff --git a/HWfrom1-10-016(BigO).playground/contents.xcplayground b/HWfrom1-10-016(BigO).playground/contents.xcplayground index 5da2641..8d8c40c 100644 --- a/HWfrom1-10-016(BigO).playground/contents.xcplayground +++ b/HWfrom1-10-016(BigO).playground/contents.xcplayground @@ -1,4 +1,2 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/HWfrom1-10-016(BigO).playground/playground.xcworkspace/xcshareddata/HWfrom1-10-016(BigO).xcscmblueprint b/HWfrom1-10-016(BigO).playground/playground.xcworkspace/xcshareddata/HWfrom1-10-016(BigO).xcscmblueprint new file mode 100644 index 0000000..10d469c --- /dev/null +++ b/HWfrom1-10-016(BigO).playground/playground.xcworkspace/xcshareddata/HWfrom1-10-016(BigO).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "753DC18C-8FF3-4B5A-AF5C-E4D7AC27FE73", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWfrom1-10-016(BigO)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWfrom1-10-016(BigO).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWfrom1-14-16(Logic+Discrete_Math).playground/Contents.swift b/HWfrom1-14-16(Logic+Discrete_Math).playground/Contents.swift index bc0df91..e91638b 100644 --- a/HWfrom1-14-16(Logic+Discrete_Math).playground/Contents.swift +++ b/HWfrom1-14-16(Logic+Discrete_Math).playground/Contents.swift @@ -9,21 +9,58 @@ var str = "Hello, playground" Question 1: https://www.hackerrank.com/challenges/minimum-draws +// Could you write a for loop that keeps on looping until it finds the matching pair? Use n + 1 for each iteration until you find the right pair. + +var numberOfDraws = NSArray() + +// n + 1 until matching pair is found +// I do not know how to solve this with code...I can sort of understand and process it just by reading the question, +// but having to put it into code, especially swift, is really hard for me + +/* Copy and paste your code: What is the big O runtime of your code?: +O(n) since you only need 1 for loop and you cancel the other variables out which leaves O(n) + Question 2: https://www.hackerrank.com/challenges/handshake +use the non-repeating formula + +if there are 5 people shaking hands but only once and never repeating + +1 x 2 +1 x 3 +1 x 4 +1 x 5 += 4 handshakes + +n! / (r! * (n-r)!) + + Copy and paste your code: What is the big O runtime of your code?: +O((n^2) Question 3: https://www.hackerrank.com/challenges/connecting-towns Copy and paste your code: -What is the big O runtime of your code?: +I genuinely do not know the answers to these questions. Googling doesn't help because I can't find a decent solution and step by step process, and the fact that this is considered easy stresses me out like crazy... + +I'm assuming Gandalf will want to only go through each town once, so use the non-repeating combination formula: n! / (r!*(n-r)!) + +What is the big O runtime of your code? +O(n^2) + +*/ */ + +class Solution { + var int = 7 + +} diff --git a/HWfrom1-14-16(Logic+Discrete_Math).playground/playground.xcworkspace/xcshareddata/HWfrom1-14-16(Logic+Discrete_Math).xcscmblueprint b/HWfrom1-14-16(Logic+Discrete_Math).playground/playground.xcworkspace/xcshareddata/HWfrom1-14-16(Logic+Discrete_Math).xcscmblueprint new file mode 100644 index 0000000..8c67524 --- /dev/null +++ b/HWfrom1-14-16(Logic+Discrete_Math).playground/playground.xcworkspace/xcshareddata/HWfrom1-14-16(Logic+Discrete_Math).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "7F31043E-49E2-4216-A85D-57E0ECE2403C", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWfrom1-14-16(Logic+Discrete_Math)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWfrom1-14-16(Logic+Discrete_Math).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file diff --git a/HWfrom1-23-16(Recursion).playground/playground.xcworkspace/xcshareddata/HWfrom1-23-16(Recursion).xcscmblueprint b/HWfrom1-23-16(Recursion).playground/playground.xcworkspace/xcshareddata/HWfrom1-23-16(Recursion).xcscmblueprint new file mode 100644 index 0000000..da8be19 --- /dev/null +++ b/HWfrom1-23-16(Recursion).playground/playground.xcworkspace/xcshareddata/HWfrom1-23-16(Recursion).xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : 0, + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "231E4895-2E88-4557-B912-A294B20B917C", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "023C046D7BC226924BBAD83456E847BF59264631" : "..", + "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" : "unit-4-assignments\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "HWfrom1-23-16(Recursion)", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "HWfrom1-23-16(Recursion).playground", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-2-final-project-.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "023C046D7BC226924BBAD83456E847BF59264631" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/charleshkang\/unit-4-assignments.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC00B0370BF6CE50CF8D6B743E30CE9D4B9706A5" + } + ] +} \ No newline at end of file