Skip to content

Instantly share code, notes, and snippets.

@andymccurdy
Created August 9, 2016 01:15
Show Gist options
  • Save andymccurdy/ec110381a2dab1f689e995c198030ae2 to your computer and use it in GitHub Desktop.
Save andymccurdy/ec110381a2dab1f689e995c198030ae2 to your computer and use it in GitHub Desktop.
def purify(numbers):
return [i for i in numbers if i % 2 == 0]
@jbwhite85
Copy link

jbwhite85 commented Aug 9, 2016

..

@jbwhite85
Copy link

def purify(x):
    total = []
    if x in total is int.odd:
        x -= int.odd
    else:
        x += total

@jbwhite85
Copy link

def product(x, y):
    x = int(x)
    y = int(y)
    numbers = []
    for i in numbers:
        numbers *= ??

@jbwhite85
Copy link

def product(numbers):
    numbers = []
    for i in numbers:
        numbers *= numbers.append[]
    return numbers

@andymccurdy
Copy link
Author

def product(numbers):
    start = 1
    for i in numbers:
        start *= i
    return start

@jbwhite85
Copy link

def remove_duplicates(x):
    new_list = []
    if x == the same thing that is already x:
        fucking remove it
    add the single digits to the new_list
    return new_list

@andymccurdy
Copy link
Author

def remove_duplicates(numbers):
    new_list = []
    for x in numbers:
        if x not in new_list:
            new_list.append(x)
    return new_list

@jbwhite85
Copy link

def median(x):
    med_list = []
    for i in x:
        if x not in med_list:
            med_list.append(x)
    med_list = sorted(med_list)

Essentially, I need to put the numbers that come through 'x' into a list. Next I need to sort said list...which I believe i've done both. Now what I don't know how to do is take the middle number, or if it's an even value of numbers, taking the middle two numbers, dividing them, and outputting the median.

@jbwhite85
Copy link

def median(x):
    med_list = sorted(x)
    if len(med_list) % 2 == 1:
        return the middle index
    else:
        figure out how to divide the middle indexes and return it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment