Skip to content

Instantly share code, notes, and snippets.

View joonas-yoon's full-sized avatar
🎃
Focusing

Joona Yoon joonas-yoon

🎃
Focusing
View GitHub Profile
@joonas-yoon
joonas-yoon / 5e47f43ad9126d.gif
Last active April 26, 2021 09:28
marker load async
5e47f43ad9126d.gif
@joonas-yoon
joonas-yoon / heuristics.js
Created January 26, 2021 07:36
s0af.panty.run
(() => {
const cvs = document.getElementById('cvs');
const ctx = cvs.getContext('2d');
function toHex(r, g, b){
return "#" + ("000000" + ((r << 16) | (g << 8) | b).toString(16)).slice(-6);
}
function getColor(ctx, x, y) {
let w = cvs.width / 8, h = cvs.height / 15;
@joonas-yoon
joonas-yoon / quicksort.cpp
Created December 21, 2020 06:32
quick sort
// [l, r]
template <typename T>
void qsort(T a[], int left, int right) {
if (left >= right) return;
T mid = a[(left + right) / 2];
int l = left, r = right;
while (l <= r) {
while (a[l] < mid) l++;
while (mid < a[r]) --r;
if (l <= r) {
@joonas-yoon
joonas-yoon / print_json_as_tree.py
Last active September 24, 2020 05:30
Python print json as tree
import sys
sys.setrecursionlimit(10 ** 6)
def is_json(json):
return type(json) == type({})
def is_list(lst):
return type(lst) == type([])
@joonas-yoon
joonas-yoon / uva-136-ugly-numbers.cpp
Created July 6, 2020 07:10
UVa 136, POJ 1338 - Ugly Numbers
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
typedef long long lld;
struct node {
node(lld d, int p) : data(d), prev(p) {}
lld data;
@joonas-yoon
joonas-yoon / boj-11012.cpp
Last active June 9, 2020 18:01
BOJ 11012 - Egg
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<(n); ++i)
#define REP(i, a, b) for(int i=(a); i<(b); ++i)
#define all(v) (v).begin(), (v).end()
#define SIZE(v) ((int)(v).size())
typedef long long lld;
typedef pair<int, int> ii;
@joonas-yoon
joonas-yoon / hot-brains-e95-4.py
Last active June 9, 2020 11:57
문제적 남자 95화 - 리모트 뷰잉 뇌풀기 - 4번 문제
from itertools import permutations
# AB*C = DE-F = GH/I
def validate(a):
ABC = (10*a[0] + a[1]) * a[2]
DEF = (10*a[3] + a[4]) - a[5]
if ABC != DEF:
return False
GH, I = 10*a[6] + a[7], a[8]
if GH % I != 0 or ABC != (GH / I):
@joonas-yoon
joonas-yoon / gtest.rb
Last active June 4, 2020 02:25 — forked from Kronuz/gtest.rb
Homebrew Formula for Google Test
# Homebrew Formula for Google Test
# Usage: brew install --HEAD https://gist.githubusercontent.com/joonas-yoon/9ec4ce1c1374ba8b8473020ced3879d8/raw/gtest.rb
require 'formula'
class Gtest < Formula
desc "Google Test"
homepage "https://github.com/google/googletest"
head "git://github.com/google/googletest.git", :using => :git
@joonas-yoon
joonas-yoon / boj-3640.cpp
Created May 24, 2020 11:55
BOJ 3640 - 제독
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef pair<int, int> ii;
const int INF = 0x3f3f3f3f;
const lld LNF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
@joonas-yoon
joonas-yoon / boj-15480.cpp
Created May 15, 2020 10:55
BOJ 15480 - LCA와 쿼리
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100001
#define MAX_DEP 18
int N;
vector<int> adj[MAX_N];
int depth[MAX_N];
int parent[MAX_N][MAX_DEP]; // N번째 노드의 2^K번째 부모 노드