Skip to content

Instantly share code, notes, and snippets.

View dittoslash's full-sized avatar

Raine dittoslash

View GitHub Profile
@dittoslash
dittoslash / trainicator.py
Last active February 21, 2020 20:30
RealTimeTrains Discord bot
import discord
import requests
import asyncio
from requests.auth import HTTPBasicAuth as authBasic
import datetime
import math
import time
TOKEN = "Discord bot token"
rttauth = authBasic("rttapi_username", "rttapi_password")
rttbase = "https://api.rtt.io/api/v1/json/search/"
@dittoslash
dittoslash / 9.py
Created December 23, 2019 18:51
Advent of Code 2019
import requests
import math
#this should all be pretty extendable. hopefully there's more puzzles using this thing
#programming this thing was pretty fun lol
#parse puzzle input
pinput = requests.get("https://adventofcode.com/2019/day/9/input", headers={"Cookie": "session=[nope]"}).text
puzzle_input = pinput.split(",")
for i in range(0, len(puzzle_input)):
puzzle_input[i] = int(puzzle_input[i])
@dittoslash
dittoslash / 8.py
Created December 23, 2019 18:44
Advent of Code 2019
w = open("input.txt")
bounds_x, bounds_y = 25, 6
image = []
done = False
def draw(img):
for row in img:
for i in row:
if i == "0": print(".." , end="")
elif i == "1": print("##" , end="")
@dittoslash
dittoslash / 7-2.py
Created December 23, 2019 18:36
Advent of Code 2019
import requests
import math
from itertools import permutations
#had to make an entirely different file for this because i need to mess with it so much
#==Intcode Computer code (from day 5), slightly modified==
#parse puzzle input
pinput = requests.get("https://adventofcode.com/2019/day/7/input", headers={"Cookie": "session=[nope]"}).text
puzzle_input = pinput.split(",")
for i in range(0, len(puzzle_input)):
@dittoslash
dittoslash / 7.py
Created December 23, 2019 18:35
Advent of Code 2019
import requests
import math
from itertools import permutations
#==Intcode Computer code (from day 5), slightly modified==
#parse puzzle input
pinput = requests.get("https://adventofcode.com/2019/day/7/input", headers={"Cookie": "session=[nope]"}).text
puzzle_input = pinput.split(",")
for i in range(0, len(puzzle_input)):
puzzle_input[i] = int(puzzle_input[i])
@dittoslash
dittoslash / 6.py
Created December 23, 2019 18:34
Advent of Code 2019
connections_raw = []
with open("input.txt") as f:
for line in f:
connections_raw.append(line.strip().split(")"))
print_orbits = False
print_santafind = False
satellites = {}
for conn in connections_raw:
@dittoslash
dittoslash / 5.py
Last active December 5, 2019 18:57
Advent of Code 2019
import requests
import math
#this should all be pretty extendable. hopefully there's more puzzles using this thing
#programming this thing was pretty fun lol
#parse puzzle input
pinput = requests.get("https://adventofcode.com/2019/day/5/input", headers={"Cookie": "session=[nope]"}).text
puzzle_input = pinput.split(",")
for i in range(0, len(puzzle_input)):
puzzle_input[i] = int(puzzle_input[i])
@dittoslash
dittoslash / 4.py
Created December 4, 2019 11:45
Advent of Code 2019
puzzleinput = [] #insert your input here as an array, e.g. [11111, 22222]
validPasswords = 0
for n in range(puzzleinput[0], puzzleinput[1]):
last_d = -1
anyDoubles = False
notDecreasing = True
occurances = {}
for digit in str(n):
digit = int(digit)
if digit < last_d: notDecreasing = False
@dittoslash
dittoslash / 3.py
Created December 4, 2019 11:44
Advent of Code 2019
#difficulty spike.png
with open("input.txt") as f: #this one uses a file instead of a request
wire_a = f.readline()
wire_b = f.readline()
#parse instructions
wire_a_arr = wire_a.split(",")
wire_a_instruct = []
for i in wire_a_arr:
direction = i[0]
@dittoslash
dittoslash / 2.py
Created December 2, 2019 08:29
Advent of Code 2019
import requests
pinput = requests.get("https://adventofcode.com/2019/day/2/input", headers={"Cookie": "session=[nope]"}).text
ogstate = pinput.split(",")
for i in range(0, len(ogstate)):
ogstate[i] = int(ogstate[i])
n = -1
v = -1