Skip to content

Instantly share code, notes, and snippets.

View SansPapyrus683's full-sized avatar
😀
a minor inconvenience

SansPapyrus683 SansPapyrus683

😀
a minor inconvenience
View GitHub Profile
@SansPapyrus683
SansPapyrus683 / day15.rs
Created April 26, 2024 03:24
incomplete advent of code 2018 day 15
use itertools::Itertools;
use std::collections::{HashMap, HashSet, VecDeque};
use std::fs;
fn neighbors(r: usize, c: usize) -> Vec<(usize, usize)> {
let (ir, ic) = (r as i32, c as i32);
vec![(ir + 1, ic), (ir - 1, ic), (ir, ic + 1), (ir, ic - 1)]
.iter()
.filter(|(r, c)| *r >= 0 && *c >= 0)
.map(|(r, c)| (*r as usize, *c as usize))
@SansPapyrus683
SansPapyrus683 / twitter.py
Created February 26, 2024 21:17
download all your twitter anime girls!
import json
import re
import os
import shutil
import requests
def load_twt_obj(file: str) -> list:
raw = open(file).read()
return json.loads(raw[raw.find("=") + 1:])
@SansPapyrus683
SansPapyrus683 / suff_arr.cpp
Created January 15, 2024 03:07
Suffix Array Implementation
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using std::cout;
using std::endl;
using std::vector;
using std::string;
@SansPapyrus683
SansPapyrus683 / .vimrc
Last active March 28, 2024 04:27
some config files (linux and windows)
" https://stackoverflow.com/a/234578/12128483
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab " set expandtab& to just indent w/ tabs
" https://vi.stackexchange.com/a/4250
set softtabstop=4
@SansPapyrus683
SansPapyrus683 / conventions.md
Last active August 1, 2023 10:54
code conventions to satisfy dustin

general code stuff

  • comments
    • inline comments should be two spaces after the line of code
    • if a single comment takes over two lines, use a multiline comment
  • sols should have nearly the same structure, same names, etc. to avoid confusion
  • avoid global variables
  • for the brace languages, always use braces & space em out like: for (int i = 0; i < 2; i++) {
  • an if-else should be like this:
@SansPapyrus683
SansPapyrus683 / LCATree.java
Created May 19, 2022 04:48
Tree with LCA capabilities (C++ and Java)
import java.util.*;
/** Tree class with LCA capabilities and some other handy functions. */
public class LCATree {
private final int[] par;
private final int[][] pow2Ends;
private final int[] depth;
private final int log2Dist;
/**
@SansPapyrus683
SansPapyrus683 / drought_gold.md
Last active August 9, 2023 09:47
Solution for "Drought" (2022 USACO Gold)

bro i could passed gold lmao
i actually knew how to solve 2 problems

but anyways, here's the gold p1 editorial on request (actual problem here, i won't bother explaining it myself, just read the darn thing)

so it would be absolute cancer to try and actually calculate if each tuple can get to a level where all cows have the same hunger level
not only that, calculating all the possible tuples themselves...

@SansPapyrus683
SansPapyrus683 / kruznice.md
Created January 28, 2022 05:39
Solution for "KRUZNICE"

so yknow i was on the dp grind when someone posted this problem on the github issues for the usaco guide (you can test here, but prepare google translate)

so we have a buncha circles, intervals really
and we wanna remove some so that none of them intersect (they can be tangent tho)

so let's define min_remove[s][e] as the minimum amount of circles we have to remove given that the only circles we consider are the ones that are completely

@SansPapyrus683
SansPapyrus683 / game_master.md
Created January 16, 2022 01:24
solution for game master on cf

"Domination". Look it up.

— Scout, TF2

after the dec contest, i have come to the conclusion that i suck a** at dp
so i was grinding cf and i came upon this problem that had the tag dp
but my solution was anything but that, so lemme just share my sol

@SansPapyrus683
SansPapyrus683 / hilo.md
Created December 29, 2021 17:46
Solution for "HILO" (2021 USACO Gold)

hi
december contest ptsd again
this problem again

since the problem explanation is too complicated, i'll just let you read the problem yourself, there's no way i'm going to explain it myself

ok i'll assume you read the thing

anyway just the first thing i did was write a brute force python script to