INSERT GRAPHIC HERE (include hyperlink in image)
Subtitle or Short Description Goes Here
def missing_ints(numbers): | |
"""Given a list of ordered integers with some of the | |
numbers missing (and with possible duplicates), find | |
the missing numbers. | |
""" | |
if not numbers: | |
return [] | |
missing_numbers = [n for n in range(min(numbers), max(numbers)) | |
if n not in numbers] | |
return missing_numbers |
from math import sqrt | |
def determine_primes(given_numbers): | |
"""Determines prime numbers in a list of integers.""" | |
primes = [] | |
for possible_prime in given_numbers: | |
is_prime = True | |
for num in range(2, int(sqrt(possible_prime)) + 1): | |
if possible_prime % num == 0: |
def and_gate(x, y): | |
"""The AND gate gives an output of 1 if both | |
the two inputs are 1, it gives 0 otherwise. | |
""" | |
if x == 1 and y == 1: | |
return 1 | |
return 0 | |
def or_gate(x, y): |
class User: | |
def __init__(self, user_name): | |
self.user_name = user_name | |
self.tweets = [] | |
self.follows = [] | |
def __str__(self): | |
return self.user_name | |
"""This is a simple script that simulates a text editor.""" | |
import re | |
import os.path | |
from datetime import datetime | |
class TextEditor: | |
"""A tentative of representing a simple text editor. |
def num_chars(s: str, c: str): | |
"""Returns the number of occurrences of c in s.""" | |
return s.lower().count(c.lower()) |
def stock_buy_sell(prices: list): | |
"""Returns the 2 days when you should buy and sell the stock for the | |
highest profit. | |
""" | |
buy_day = prices.index(min(prices)) + 1 | |
sell_day = prices.index(max(prices[buy_day:])) + 1 | |
return f'Buy on day {buy_day}, sell on day {sell_day}' | |
if __name__ == '__main__': |
def _to_pig_latin(word: str): | |
"""Converts the word into Pig Latin.""" | |
VOWELS = 'aeiou' | |
if word[0].lower() in VOWELS: | |
return f'{word}yay' | |
consonants = 0 | |
for letter in word.lower(): | |
if letter not in VOWELS: | |
consonants += 1 |
def fibonacci_like(arr: list): | |
"""Returns the length of the longest fibonacci-like subsequence of the | |
arr. | |
If one does not exist, returns 0. | |
""" | |
seen_arr = set(arr) | |
max_length = 0 | |
for i in range(len(arr)): | |
for j in range(i + 1, len(arr)): |