Skip to content

Instantly share code, notes, and snippets.

View bhakes's full-sized avatar

BHakes bhakes

View GitHub Profile
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
var button: UIButton?
override func loadView() {

Challenge

Create a function that takes a String and reverses the order of all of the vowels in the String and returns the mutated String without passing through the string more than once. Your solution should have a time complexity of O(n).

Examples:

"Hello" -> "Holle"
"Ben Sean Kat Cam" -> "Ban Saan Ket Cem"
import UIKit
import XCTest
/*
Thoughts/Assumptions:
- If we are going to try to find a solution with a time complexity of O(n), we are going to have to get creative.
- We could possibly use two converging indicies, one starting from the from of the string, the other starting from the end.
- Because were taking in a String and returning a String, we could make an extension on String.
- I should consider whether or not 'y' is included as a vowel.
// assumptions:
// - I will get passed an array of ints
// - ints can be positive, negative or zero
// - If only one item in the array is passed early return 0
import UIKit
// main function
func getProduct(for intArray: [Int])->[Int]{
// assumption:
// - I will only get passed ints
// - I can get passed both negative and positive ints
//
//
import Foundation
// main funct
func expandedNumber(_ number: Int) -> [Int]{
// I did this the hard way and it would have been a lot
// easier to do it using this Hint:
// Hint: In order for a word to be a palindrome, is needs to have an even amount of the same letters on each side with the exception of a single letter in the middle
// pseudo code of easier way:
// for each letter in the string
// save it to a key pair array
// key being letter
// pair being count
// if all key pairs have even values
import UIKit
func sumOf35Multiples(_ number: Int) -> Int {
// Check to make sure some joker didn't put zero or negative
// or a really big number. return -1 if it might be a joker
guard number > 0, number < 100000 else { return -1 }
// instantiate local vars
var matches: Array<Int> = []
import Cocoa
// trying to implement test cases
var intPairArray = [[],["",""],["",2],[2,""],[1,1],[1,1],[1,2],[1,3],[4,1]]
var intPairArray2 = [12,15]
// main function here
public func sumAndProduct(_ pIntPairArray: [Array<Int>])->[Int]{
for intPair in intPairArray{
/** iOS4CodeChallenge-18.11.06.md
* By Ben H
*/
// instantiate testing arrays
let stringArray = ["test", "test1", "test2", "test33"]
let stringArray2 = ["test", "test133", "test2", "test33"]
let stringArray3 = ["test", "test1", "test2", "test3"]
// function to find the longest string in a string array
AR Quick Look
https://developer.apple.com/videos/play/wwdc2018/603/
Preview 3D content in AR
Deeply integrated within the operating system.
available on iOS 12 on AR compatible devices
new 3D file format USDZ - invites you to 3D view your content and see what it looks like in your world.