Skip to content

Instantly share code, notes, and snippets.

View vitorventurin's full-sized avatar
🏠
Working from home

Vitor Venturin vitorventurin

🏠
Working from home
View GitHub Profile
@vitorventurin
vitorventurin / Hackerrank_RepeatedString.playground
Created March 2, 2021 10:28
Hackerrank - Repeated String
import Foundation
func getLetterCount(s: String) -> Int {
return s.filter { $0 == "a" }.count
}
func repeatedString(s: String, n: Int) -> Int {
let stringCount = s.count
let remainder = n % stringCount
let multiplier = n / stringCount
@vitorventurin
vitorventurin / RomanNumbers.playground
Created February 23, 2021 09:39
Legionaries: In the range 1-13 (1,2,3,4,5,6,7,8,9,10,11,12,13) the digit 1 occurs 6 times. In the range, 1 - 2,660 (half the number of Romans in a legion), expressed in Roman numerals, how many times does the numeral “X” occur?
import Foundation
func toRoman(number: Int) -> String {
let romanValues = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
let arabicValues = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
var romanValue = ""
var startingValue = number
for (index, romanChar) in romanValues.enumerated() {
@vitorventurin
vitorventurin / Favorite_Extensions_Swift
Created February 23, 2021 09:33
My favorite extensions from Swift Language / iOS Cocoa UIKit
// The version of Swift is 4.0.
// Get a class name
public protocol ClassNameProtocol {
static var className: String { get }
var className: String { get }
}
public extension ClassNameProtocol {
public static var className: String {
import UIKit
protocol PropertyStoring {
associatedtype T
func getAssociatedObject(_ key: UnsafeRawPointer, defaultValue: T) -> T
}
extension PropertyStoring {
func getAssociatedObject(_ key: UnsafeRawPointer, defaultValue: T) -> T {
guard let value = objc_getAssociatedObject(self, key) as? T else {
@vitorventurin
vitorventurin / airport-distances
Created January 29, 2021 16:37
airport distances
This file has been truncated, but you can view the full file.
AAL ✈️ ABQ | Distance: 8195.183652584217 km
AAL ✈️ ABZ | Distance: 730.2386543388001 km
AAL ✈️ ACC | Distance: 5777.147943540879 km
AAL ✈️ AES | Distance: 644.8547502389752 km
AAL ✈️ AGP | Distance: 2507.4437035749943 km
AAL ✈️ AKL | Distance: 17510.039331730943 km
AAL ✈️ ALA | Distance: 4809.780861544547 km
AAL ✈️ ALC | Distance: 2226.079743224819 km
AAL ✈️ AMM | Distance: 3457.963091935342 km
//
// ViewController.swift
//
// Created by Vitor Venturin Linhalis on 26/11/16.
// Copyright © 2016 Vitor Venturin Linhalis. All rights reserved.
//
import UIKit
import Moya
import RxSwift
//
// Place.swift
//
// Created by Vitor Venturin Linhalis on 27/11/16.
// Copyright © 2016 Vitor Venturin Linhalis. All rights reserved.
//
import Foundation
import Mapper
//
// PlaceViewModel.swift
// RxPlaces
//
// Created by Vitor Venturin Linhalis on 17/01/17.
// Copyright © 2017 Vitor Venturin Linhalis. All rights reserved.
//
import UIKit
import RxSwift
//
// Type.swift
// RxPlaces
//
// Created by Vitor Venturin Linhalis on 12/12/16.
// Copyright © 2016 Vitor Venturin Linhalis. All rights reserved.
//
import Foundation
//
// Product
//
// Created by Vitor Venturin Linhalis.
// Copyright © 2016 Vitor Venturin Linhalis. All rights reserved.
//
import Foundation
import Mapper