Skip to content

Instantly share code, notes, and snippets.

View Shogun89's full-sized avatar

Shogun89

  • New York, New York
View GitHub Profile
"""
1) python -m venv selenium_test
2) /selenium_test/Scripts/activate
3) pip install selenium
"""
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://www.google.com')
from itertools import groupby
def run_length_encoding(s: str) -> str:
return ''.join(f"{len(list(group))}{key}" for key, group in groupby(s))
s = "aaabbccccdeee"
grouped = groupby(s)
for key, group in grouped:
print(f"Key: {key}, Group: {list(group)}")
@Shogun89
Shogun89 / point_in_triangle.py
Created July 18, 2024 22:07
Checks if points are in a triangle and draws it
import math
import matplotlib.pyplot as plt
def distance(x1, y1, x2, y2):
return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
def is_triangle_non_degenerate(ax, ay, bx, by, cx, cy):
# Calculate the lengths of the sides
@Shogun89
Shogun89 / order_numbers.py
Created February 19, 2024 23:33
Orders list of numbers by their word version
from num2words import num2words
numbers = list(range(10,100))
number_to_word_dict = {num : num2words(num) for num in numbers}
sorted_numbers = sorted(numbers, key = lambda x : number_to_word_dict[x])
print(sorted_numbers)
@Shogun89
Shogun89 / github_info.py
Created June 25, 2023 21:54
Fetch GitHub org repo info
import pandas as pd
import github as Github
def get_repo_information(org_name, access_token):
git = Github(access_token)
org = git.get_organization(org_name)
repositories = org.get_repos()
data = []
@Shogun89
Shogun89 / d11_input.txt
Last active December 20, 2022 09:26
Advent of Code - Day 11 part 1
Monkey 0:
Starting items: 78, 53, 89, 51, 52, 59, 58, 85
Operation: new = old * 3
Test: divisible by 5
If true: throw to monkey 2
If false: throw to monkey 7
Monkey 1:
Starting items: 64
Operation: new = old + 7
def fetch_input(file) -> str:
''' Fetches the txt file input for the current challenge '''
with open(file, 'r') as file:
data = file.read().replace('\n', '')
return data
def check_start_of_packet(txt,window_length) -> bool:
''' Determine if current text is all unique characters '''
@Shogun89
Shogun89 / d4_input.txt
Created December 12, 2022 00:08
Advent of Code - Day 4
16-80,80-87
4-9,10-97
6-94,93-93
31-73,8-73
4-72,5-73
6-63,4-5
3-44,4-45
89-96,95-95
56-95,29-95
5-22,5-22
@Shogun89
Shogun89 / d3_input.txt
Created December 11, 2022 22:11
Advent of Code - Day 3
BdbzzddChsWrRFbzBrszbhWMLNJHLLLLHZtSLglFNZHLJH
nnfMwqpQTMffHlNNLllHnZSS
cGpcMwfppfqcjcTCBBzWDsDbDrjzWz
LhfjhcdjcGdhFfdGfdjdvwCCZMvvLvWwMLCLSwZC
rDnsbmptPmlbQMCrQWQQBZQW
gltgVPngDPbptPsbPzVgmDldfTdfczThjJJjfMcJdFHjjH
dGlgDflTLLLrRLTLVdQLcQMnbvHbbFzNNvMbnHHn
sZjWJJCSjWqfCqSjSmJSbFvCzBMBBzHncHNvMBHN
twqqwpZwfrlwRwDGDR
zCGGFTQMQrsNRNGZdR
@Shogun89
Shogun89 / d3_input.txt
Created December 11, 2022 21:34
Advent of Code - Day 3 Part 1
BdbzzddChsWrRFbzBrszbhWMLNJHLLLLHZtSLglFNZHLJH
nnfMwqpQTMffHlNNLllHnZSS
cGpcMwfppfqcjcTCBBzWDsDbDrjzWz
LhfjhcdjcGdhFfdGfdjdvwCCZMvvLvWwMLCLSwZC
rDnsbmptPmlbQMCrQWQQBZQW
gltgVPngDPbptPsbPzVgmDldfTdfczThjJJjfMcJdFHjjH
dGlgDflTLLLrRLTLVdQLcQMnbvHbbFzNNvMbnHHn
sZjWJJCSjWqfCqSjSmJSbFvCzBMBBzHncHNvMBHN
twqqwpZwfrlwRwDGDR
zCGGFTQMQrsNRNGZdR