This file contains 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
def perm(text): | |
if len(text) == 1: | |
return [text] | |
else: | |
sub_perm = perm(text[1:]) | |
first = text[0] | |
permutations = list() | |
for subset in sub_perm: | |
for i in range(len(subset)+1): | |
permutations.append(subset[:i]+ first+subset[i:]) |
This file contains 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
def mult (a, b): | |
if b == 1: return a | |
elif b == 0: return 0 | |
elif b < 0: return mult (-a, -b) | |
else: return a + mult (a, b-1) | |
This file contains 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
# Python 3.4 Solution to Matrix Script Problem by Kurtis Mackey | |
# https://www.hackerrank.com/challenges/matrix-script | |
import re | |
# Import original script | |
matrix = list() | |
for _ in range(int(input().split()[0])): | |
matrix.append(list(input())) |
This file contains 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 unittest | |
def ispalindrome(string): | |
"""Given a string, returns True if it is a Palindrome. | |
Notes: Case insensitive, | |
Spaces considered: (' aba ') == True | |
""" | |
string = string.lower() | |
return string == string[::-1] # Returns True if Palindrome |
This file contains 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
# Written in Python 3.51 by Kurtis Mackey (Developed Test First) | |
# Binary Search | |
import unittest | |
def binary_search(array, num): | |
"""Given a sorted array of numbers, | |
return True of num is in the array | |
using Binary Search. | |
""" |
This file contains 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
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Diagnostics; | |
using System.Linq; | |
public static class Program | |
{ | |
static void Main() |