Skip to content

Instantly share code, notes, and snippets.

View ZechCodes's full-sized avatar
🏄‍♂️
Surfing on a space-time bubble

Zech Zimmerman ZechCodes

🏄‍♂️
Surfing on a space-time bubble
View GitHub Profile
@ZechCodes
ZechCodes / RockPaperScissors.py
Created July 2, 2019 20:49
Really basic rock, paper, scissors CLI game.
from __future__ import annotations
from typing import AnyStr, Callable, Container, Tuple, Union
class Choice:
def __init__(self, name: AnyStr, beats: Choice = None):
self._name = name
self._beats = beats
@property
@ZechCodes
ZechCodes / nlp-extract-topics.py
Created July 7, 2019 22:33
Further messing around with NLP and extracting topics, using PoS analysis
"""
Further messing around with NLP and extracting topics.
Built a class for analyzing text to determine topics. It allows for part of speech analysis and has a pipeline for
cleaning the data set. It then uses the Gensim LDA model to determine which words are the topics.
Using the Gensim part of speech analysis to filter out everything but nouns, in conjunction with my previous
lemmatization and stemming I was able to get results that seem much better even with still using only the SKLearn news
group data set.
"""
import csv
import pandas as pd
from functools import reduce
#input below
ranked_fighters = {'Leon Edwards': {'Rank': 7}, 'Rafael Dos Anjos': {'Rank': 16}, 'Walt Harris': {'Rank': 2}, 'Aleksei Oleinik': {'Rank': 9}, 'Juan Adams': {'Rank': 1}, 'Greg Hardy': {'Rank': 4}, 'Dan Hooker': {'Rank': 3}, 'James Vick': {'Rank': 15}, 'Alexander Hernandez': {'Rank': 6}, 'Francisco Trinaldo': {'Rank': 20}, 'Ben Rothwell': {'Rank': 10}, 'Andrei Arlovski': {'Rank': 14}, 'Alex Caceres': {'Rank': 19}, 'Steven Peterson': {'Rank': 11}, 'Irene Aldana': {'Rank': 8}, 'Raquel Pennington': {'Rank': 24}, 'Klidson Abreu': {'Rank': 5}, 'Sam Alvey': {'Rank': 21}, 'Jennifer Maia': {'Rank': 13}, 'Roxanne Modafferi': {'Rank': 22}, 'Ray Borg': {'Rank': 17}, 'Gabriel Silva': {'Rank': 23}, 'Dom Pilarte': {'Rank': 12}, 'Felipe Colares': {'Rank': 26}, 'Jinsoo Son': {'Rank': 18}, 'Mario Bautista': {'Rank': 25}}
all_combinations = [row for row in csv.reader(open("C:/Users/micha/Desktop/Python/Diversification_data.csv", "r"))]
@ZechCodes
ZechCodes / challeng-25.md
Last active June 12, 2020 08:18
Challenge #25 - Directionally Challenged

Challenge #25 - Directionally Challenged

Suppose you are directionally challenged, and get lost easily. As a result, sometimes you walk in circles or make U-turns. You might take a sub-optimal route. Create a function that returns the difference in length between your path and the optimal path. Both paths reach the same destination.

You start at (0,0) and reach your destination by the end of the input list.

A demonstration

Your route: ["N", "S", "E", "W", "E", "E", "E", "N"]  // 8
Optimal route: ["E", "E", "E", "N"] (or ["N", "E", "E", "E"], etc.) // 4

Challenge # 26 - Do All Bigrams Exist?

You are given an input array of bigrams, and an list of words.

Write a function that returns True if every single bigram from this list can be found at least once in a list of words.

Examples

can_find(["at", "be", "th", "au"], ["beautiful", "the", "hat"]) ➞ True

Challenge #27 - Shift & Multiple Validators

For this task, you will write two validators.

  • Shift Validator: Determines if each element is translated (added or subtracted) by a constant.
  • Multiple Validator: Determines if each element is multiplied by a positive or negative constant.

A few examples to illustrate these respective functions:

Examples

Challenge #28 - Growing & Shrinking Potions

There are two types of potions:

Growing potion: "A" Shrinking potion: "B"

  • If "A" immediately follows a digit, add 1 to the proceeding number.
  • If "B" immediately follows a digit, subtract 1 from the proceeding number.
@ZechCodes
ZechCodes / challenge-29.md
Created June 15, 2020 23:45
Challenge #29 - Swimming Pools

Challenge #29 - Swimming Pools

Suppose a swimming pool blueprint can be represented as a 2D list, where 1s represent the pool and 0s represent the rest of the backyard.

[[0, 0, 0, 0, 0, 0, 0, 0],
 [0, 1, 1, 1, 1, 1, 0, 0],
 [0, 1, 1, 1, 1, 1, 0, 0],
 [0, 1, 1, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0]]
@ZechCodes
ZechCodes / challenge-30.md
Created June 16, 2020 23:59
Challenge #30 - Reverse Coding

Challenge #30 - Reverse Coding

This is a reverse coding challenge. Normally you're given explicit directions of how to create a function. Here, you must create your own function to satisfy the relationship between the inputs and outputs.

Your task is to create a function that, when fed the inputs below, produces the sample outputs shown.

Examples

mystery_func(152) ➞ 10
@ZechCodes
ZechCodes / challenge-31.md
Created June 17, 2020 23:32
Challenge #31 - Mini Peaks

Challenge 31 - Mini Peaks

Write a function that returns all the elements in an array that are strictly greater than their adjacent left and right neighbors.

Examples

mini_peaks([4, 5, 2, 1, 4, 9, 7, 2]) ➞ [5, 9]

mini_peaks([1, 2, 1, 1, 3, 2, 5, 4, 4]) ➞ [2, 3, 5]