Skip to content

Instantly share code, notes, and snippets.

View amandaroos's full-sized avatar

Amanda Roos amandaroos

View GitHub Profile
@amandaroos
amandaroos / Quicksort2.py
Created April 20, 2020 03:21
Quicksort 2
"""Implement quick sort in Python.
Input a list.
Output a sorted list."""
def quicksort(array):
low = 0
high = len(array)-1
partition(array, low, high)
return array
def partition(array, low, high):
#n is generations, m is pairs of rabbits born per litter
#b is pairs of baby bunnies, B is pairs of adult bunnies
def get_rabbits(n,m):
if n == 1:
return 1, 0
else:
b, B = get_rabbits(n-1, m)
return(B*m, B + b)
@amandaroos
amandaroos / FibonacciRabbits.py
Created April 30, 2020 21:09
Non-recursive way of solving Fibonacci rabbits: http://rosalind.info/problems/fib/
#n is generations, m is pairs of rabbits born per litter
#b is pairs of baby bunnies, B is pairs of adult bunnies
def get_rabbits(n, m):
b, B = 1, 0
for i in range(1, n):
b, B = B * m, B + b
return B + b
#Open string resource file, remove last line, add new translated line, for all language codes provided
from TranslationsFunctionReturnDictionary import translate
print ("starting!")
###UPDATE words_to_translate, codes, and myBasePath if necessary###
#word : resource name
words_to_translate = {
"Change Calculator":"app_name"
}
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
def translate(word, codes):
#Choose phrase to translate and enter the array of language codes you would like the phrase to be translated to
text= word
@amandaroos
amandaroos / bluepacman.py
Created September 20, 2020 06:23
blue pacman ghost for Pi Sense hat LEDs
from sense_hat import SenseHat
import time
sense = SenseHat()
sense.rotation = 90
L = [0,0,200] #Blue
D = [0,0,100] #Dark Blue
W = [100, 100, 100] # White
B = [0,0,0] #Black