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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from datetime import timedelta | |
from babelfish import Language | |
from subliminal import download_best_subtitles, region, save_subtitles, scan_videos | |
import sys | |
import os | |
""" |
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 Foundation | |
extension String { | |
func removeLetter(char: Character) -> String { | |
var newString = "" | |
var alreadyRemoved = false | |
for c in self.characters { | |
if c != char || (c == char && alreadyRemoved) { | |
newString.append(c) |
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 Queue<T> { | |
var queue: [T] = [] | |
func enqueue(object: T) { | |
self.queue.append(object) | |
} | |
func dequeue() -> T? { | |
if self.queue.count == 0 { | |
return 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
func insertionSort(arr: [Int]) -> [Int] { | |
var arr = arr | |
for i in 1..<arr.count { | |
var index = i | |
while index > 0 && arr[index] < arr[index - 1] { | |
swap(&arr[index], &arr[index - 1]) | |
index -= 1 | |
} |
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 | |
func checkPalindrome(str: String) -> Bool { | |
if str == "" || str.characters.count == 1 { | |
return true | |
} | |
else { | |
if str.characters.first == str.characters.last { | |
return checkPalindrome(str.substringWithRange(str.startIndex.successor() ..< str.endIndex.predecessor())) | |
} |
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 BTNode<T:Comparable> { | |
var value: T? | |
var left: BTNode? | |
var right: BTNode? | |
var parent: BTNode? | |
init(value: T) { | |
self.value = value | |
} |
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 Edge { | |
var neighbor: Node | |
init(n: Node) { | |
self.neighbor = n | |
} | |
} | |
class Node { | |
var edges: [Edge] = [] |
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 Node<T> { | |
var value: T? | |
var next: Node? | |
var previous: Node? | |
init(value: T) { | |
self.value = value | |
} | |
} |