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
| class SortingAlgorithms: | |
| def selectionSort(self, lst): | |
| for i in range(0, len(lst)-1): | |
| minIndex = i | |
| for j in range(i+1, len(lst)): # linearly traverse the unsorted portion of the list searching for the smallest number | |
| if lst[j] < lst[minIndex]: | |
| minIndex = j | |
| tmp = lst[i] # swap the smallest number with the first element in the unsorted region after every linear traversal | |
| lst[i] = lst[minIndex] |
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
| class SortingAlgorithms: | |
| def bubbleSort(self, lst): | |
| unsortedEnd = len(lst)-1 # variable that represents the end of the unsorted region of the list | |
| while unsortedEnd > 0: | |
| for i in range(0, unsortedEnd): # traverse the list from 0 to the end if the unsorted region of the list | |
| if lst[i] > lst[i+1]: # if the current element is larger than the next element, then swap them | |
| tmp = lst[i+1] | |
| lst[i+1] = lst[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
| # Use a Python dictionary to act as an adjacency list for the directed | |
| # graph. Key:Value pair where Key is a node directed towards Value | |
| directedGraph = { | |
| 0 : [1,2], | |
| 1 : [3, 4], | |
| 2 : [5], | |
| 3 : [], | |
| 4 : [5], | |
| 5 : [] | |
| } |
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
| func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
| guard let windowScene = (scene as? UIWindowScene) else { return } | |
| window = UIWindow(frame: windowScene.coordinateSpace.bounds) | |
| window?.windowScene = windowScene | |
| window?.makeKeyAndVisible() | |
| let vc = ViewController() | |
| window?.rootViewController = vc | |
| } |
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 ViewController: UIViewController { | |
| private var label: UILabel = { | |
| let label = UILabel(frame: CGRect(x: 0, y: UIScreen.main.bounds.height/2, width: UIScreen.main.bounds.width, height: 50)) | |
| label.textAlignment = .center | |
| label.text = "No Storyboard!" | |
| return label | |
| }() |
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 ViewController: UIViewController { | |
| var scrollView: UIScrollView! | |
| var images = [UIImageView]() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
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 ViewController: UIViewController { | |
| var scrollView: UIScrollView! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Set the scrollView's frame to be the size of the screen |
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 ViewController: UIViewController { | |
| private var mainScrollView: UIScrollView! | |
| private var profilePicturesScrollView: UIScrollView! | |
| private var profilePicturesContainer: UIView! | |
| private var profilePictures = [UIImageView]() | |
| override func viewDidLoad() { |
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
| func sceneDidBecomeActive(_ scene: UIScene) { | |
| // Enter your code here to be executed whenever the app comes into the foreground | |
| print("App entered foreground") | |
| } |
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
| func sceneDidEnterBackground(_ scene: UIScene) { | |
| // Enter your code here to be executed when the app enters the background | |
| print("App entered background") | |
| } | |