Skip to content

Instantly share code, notes, and snippets.

View JustinStitt's full-sized avatar
👻
learning something new everyday!

Justin Stitt JustinStitt

👻
learning something new everyday!
View GitHub Profile
#include <bits/stdc++.h>
using namespace std;
int bfs(map<int, set<int>>& M, unordered_map<int, size_t>& lookup) {
priority_queue<int, std::vector<int>, std::greater<int>> min_heap;
set<int> visited;
min_heap.push(0);
int total{};
#include <bits/stdc++.h>
using namespace std;
struct MinHeap {
bool operator()(pair<int, int> a, pair<int, int> b) {
return a.second > b.second;
}
};
@JustinStitt
JustinStitt / lonerook.py
Created February 28, 2022 23:09
for ICPC 21-22 prob 4
import sys
import math
(r, c) = [int(x) for x in input().split(' ')]
'''
states:
0 -> empty
1-> knight
2-> attacked by knight
3 -> goal (target)
#include <bits/stdc++.h>
using std::vector;
namespace compare {
struct OddThenEven {
bool operator()(int a, int b) {
bool ao = (a & 1), bo = (b & 1);
if (ao and bo) return a < b;
else if (ao and !bo) return 1;
@JustinStitt
JustinStitt / graph_assembly.py
Created March 22, 2022 10:51
for a ctf. idk
from collections import defaultdict
dump = open('./dump.nasm.txt')
def where_next(amnt, _from):
return _from + amnt * 106
def calculate_paths(curr):
NORTH = -51; EAST = 1; SOUTH = 51; WEST = -1
dirs = {1: NORTH, 2: WEST, 3: EAST, 4: SOUTH}
paths = []
@JustinStitt
JustinStitt / polymorphism.cc
Created March 23, 2022 04:24
Sorta? shows polymorphism in cc
#include <bits/stdc++.h>
struct Shape {
virtual double area() {
std::cout << "I am a Shape\n";
return 0.0;
}// non-pure virtual
};
#include <bits/stdc++.h>
struct Node {
int data;
Node* next;
Node(int _data) : data(_data) {}
};
class SinglyLinkedList {
private:
@JustinStitt
JustinStitt / content-copy.js
Created May 13, 2022 03:59
on click copy text content
document.addEventListener('click', () => {
let question = document.getElementsByClassName('_3vK03yy396dmBwrrRmeApE')[0];
console.log(question.textContent);
navigator.clipboard.writeText(question.textContent);
});
@JustinStitt
JustinStitt / ifelse.bf
Created October 16, 2022 03:30
my take at an if-else in BrainF**k . Checks for input of '5'
// accept input
, // at cell 1
// subtract ascii '5' (53) from input
>++++++++++[<----->-]<--- // at cell 1
// if inp == '5'
>+ // set zero flag to 1 (cell 2)
>+< // set else flag to 1
<[>-<[-]] // change zero flag if inp not '5' (at cell 1)
@JustinStitt
JustinStitt / graph.py
Created November 8, 2022 07:29
Quick Graph Demo in Python
class Vertex:
def __init__(self, data):
self.data = data
def __repr__(self):
return f"{self.data}"
class Graph:
def __init__(self):