This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class NodeTree<T: Comparable> { | |
| var key: T? | |
| var leftNode:NodeTree? | |
| var rightNode: NodeTree? | |
| init(key:T, leftChild: NodeTree?, rightChild: NodeTree?) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ACTION = build | |
| AD_HOC_CODE_SIGNING_ALLOWED = NO | |
| ALTERNATE_GROUP = staff | |
| ALTERNATE_MODE = u+w,go-w,a+rX | |
| ALTERNATE_OWNER = grantdavis | |
| ALWAYS_SEARCH_USER_PATHS = NO | |
| ALWAYS_USE_SEPARATE_HEADERMAPS = YES | |
| APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer | |
| APPLE_INTERNAL_DIR = /AppleInternal | |
| APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| var str = "Anonymous Class in Swift" | |
| //https://stackoverflow.com/questions/24408068/anonymous-class-in-swift | |
| //There is no equivalent syntax. | |
| //Regarding equivalent techniques, theoretically you could use closures and define structs and classes inside them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import PlaygroundSupport | |
| import UIKit | |
| import Foundation | |
| PlaygroundPage.current.needsIndefiniteExecution = true | |
| URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| //Reference: | |
| //https://medium.com/@Dougly/recursion-with-a-binary-tree-swift-3-748bbefc2cec | |
| //Using Loop | |
| func countDownLoop(from number: Int) { | |
| var i = number | |
| while i > 0 { | |
| print(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| //Find matching pattern string as per input 'pattern' string | |
| //****Input: | |
| //var arStr = ["abbba"] //test 1 | |
| //var arStr = ["bbbaaa", "baaaa"] | |
| //var arStr = ["bbbaaa", "baaaa", "abbbc", "abbba"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| //Article: | |
| //https://www.raywenderlich.com/144083/swift-algorithm-club-swift-linked-list-data-structure | |
| //Use Generics | |
| public class Node<T> { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| //Swift --- Map -- Filter --- Reduce --- FlatMap | |
| //An example how to write these functions in shorter form: | |
| var HPs = [50, 60, 70] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import Foundation | |
| import UIKit | |
| //As reference: | |
| //https://spin.atomicobject.com/2015/03/24/evaluate-string-expressions-ios-objective-c-swift/ | |
| /** | |
| NSExpression |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Things to 'remember' about recursion: | |
| --- you can call a function inside of itself | |
| --- you always have at least "ONE BASE CASE" in order to prevent the function calling itself infinite times. | |
| */ | |
| func fibonacci(_ i: Int) -> Int { | |
| if i <= 2 { | |
| return 1 |