Skip to content

Instantly share code, notes, and snippets.

View Shogun89's full-sized avatar

Shogun89

  • New York, New York
View GitHub Profile
@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
@Shogun89
Shogun89 / day2_v2.py
Created December 11, 2022 20:32
Advent Of Code - Day 2 Part 2
def fetch_tournament(file) -> list[str]:
with open(file) as f:
lines = f.readlines()
return lines
def clean_game(game) -> str:
dic = {
'A' : 'Rock',
from math import sqrt
def get_triangle_area(a,b,c):
''' Given triangle side lengths a,b,c returns the area of the triangle '''
assert a > 0 and b > 0 and c > 0, "Side lengths must be positive"
s = (a+b+c)/2
area = sqrt(s*(s-a)*(s-b)*(s-c))
class Solution:
def countPoints(self, points: List[List[int]], queries: List[List[int]]) -> List[int]:
output = []
def point_distance(circ, point):
dist = ((circ[0] - point[0])**2 + (circ[1] - point[1])**2 )**(1/2)
return dist
for circ in queries: