Skip to content

Instantly share code, notes, and snippets.

@jakab922
jakab922 / catpuccin.kdl
Created August 24, 2023 20:32
Zellij config
themes {
catppuccin-frappe {
fg 198 208 245
bg 98 104 128
black 41 44 60
red 231 130 132
green 166 209 137
yellow 229 200 144
blue 140 170 238
magenta 244 184 228
void calc(vector<int> &d1, vector<int> &d2, const string &s, int n) {
for (int i = 0, l = 0, r = -1; i < n; i++) {
int k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1);
while (0 <= i - k && i + k < n && s[i - k] == s[i + k]) {
k++;
}
d1[i] = k--;
if (i + k > r) {
l = i - k;
r = i + k;
@jakab922
jakab922 / boggle_board.cc
Last active November 28, 2020 14:59
Boggle board solver in C++
#include <bits/stdc++.h>
using namespace std;
struct Node {
vector<int> endings;
unordered_map<char, Node*> followers;
};
void insert_trie(Node *node, const string &word, int index) {
int ws = word.size();
@jakab922
jakab922 / .tmux.conf
Created July 27, 2020 10:17
My tmux config
# Package manager settings
set -g @plugin 'tmux-plugins/tpm'
# Installs themes
set -g @plugin 'jimeh/tmux-themepack'
# Selects a theme
set -g @themepack 'powerline/block/cyan'
# Add resurrect and continuum to save tmux sessions automatically
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDsj3PW9mukC8pS0LyA8T3jbljvWqerPANMASkN8gwdtRy9+3v3QdvidlsxA1T4zkbktoYAMfbQzklidILDuSjYY4WyMos5hiGF4pJ3asZ55l/jL6cA1BBPU9edYdep30/A5qaxyjSVCEm6IIX5FBki9LkxrVtQ8f3yGWL5qkVQtylQgmZay4OLC2T5bJTLwjs8jcys6eEbbM2eA0R5omnJreUOpPxvOHHLO3U2Lq+Gdi2VhparuqISsKky47ggdMIwengPl2ScFZAN6i8qLvlzM7FFXWR8ODHGI33NKznk/y4APcRdjwZF2nfJanIaj2vNxd15S/KLFnPFqQT/zE1n65UAhJnnh+mU6MjXa7d/oNlqv450ui+SQ5HcEbe+6qdD6Rh+HqiYHpSohA4Gz+JLF+hJ/iuY0yoqETvoimKT2gYbX5k6Kxriyzl9MxLQM4Qo8Ygl2sYvIzxXKAGG9TAwgQdKUNP+tqGn1TMr4lntjN97FZTWelWVdawkHWbPmuE= dani@sigil-laptop
@jakab922
jakab922 / brute.py
Last active May 1, 2020 13:22
Finding the smallest lower/upper balanced substring in a string consisting of a-z A-Z in linear time
def check(substr):
lower = [False for i in range(26)]
upper = [False for i in range(26)]
for c in substr:
o = ord(c)
if o > 90:
lower[o - 97] = True
else:
@jakab922
jakab922 / smart_pointer.cc
Last active April 22, 2020 11:07
C++ smart pointer implementation
#include <bits/stdc++.h>
using namespace std;
template <typename T>
class my_shared_ptr {
T *data;
int *ref_count;
void _possibly_destroy() {
if (*ref_count == 0) {
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
struct segment_tree {
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
namespace prime {
/*
First I try to figure out what are the elements from 1 to 2 ** g - 1. In the end the value at node i(val[i]) is the following:
- If i > 2 ** g - 1 then 0
- If it isn't than the minimal value from it's subtree such that it's bigger than max(val[2 * i], val[2 * i + 1]) that is the value of the roots of its subtrees since the heap property is preserved
during the operations.
Since we know which values should be in the heap in the end and since calling f on an index means removing the associated value we call f on the indices whose value we don't need(all values are different) back
to front. And that's it.
*/