Skip to content

Instantly share code, notes, and snippets.

@elkym
elkym / StringPercentageComparison
Last active December 23, 2020 18:42
Python string comparator from csv input
import csv
words = []
def charComp(a, b):
if a == b:
return ("100%")
tempW = ''
for count in range(len(a)):
if count >= len(a) or count >= len(b):
@elkym
elkym / recursive_tuple_even_and_odd_digit_adder.py
Created November 25, 2020 20:27
Recursive function-- takes a tuple of any size, totals the even and odd elements, and returns a (2-value) tuple of those totals.
l1 = (1,3,9,10,4,3,2,5,17,16,11)
def odd(num):
if num % 2 != 0:
return True
def addIt(t):
l = [0,0]
return addItR(t,l)
@elkym
elkym / recur_even_odd_list_split.py
Last active November 24, 2020 00:33
Python-thing-recursion-wonderings.py
l1 = [1,3,9,10,4,3,2,5,17,14,11]
def splitIt(x):
'''
This recursive function takes a list of positive integers
x as argument and returns a tuple of two lists: a list of the even integers
in x followed by a list of the odd integers in x.
E.g. x = [3,2,1,5,4,6] gives [1,3,5] [2,4,6]
x = [1,3,9] gives [1,3,9] []