Skip to content

Instantly share code, notes, and snippets.

View bruteforceboy's full-sized avatar

Chibuoyim (Wilson) Ogbonna bruteforceboy

View GitHub Profile
filetype detect
set nocompatible
set exrc
set mouse=a
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
#include <iostream>
#include <unordered_set>
#include <vector>
template <typename T>
std::vector<std::vector<T>> permute(std::vector<T> vec, int r) {
using PermTy = std::pair<std::unordered_set<int>, std::vector<T>>;
std::vector<PermTy> permutations{{}};
while (r-- > 0) {
@bruteforceboy
bruteforceboy / generic_seg.cpp
Created November 1, 2024 13:57
Somewhat Simple Generic SegmentTree
#include <bits/stdc++.h>
template <typename T> struct SegmentTree {
std::vector<T> st;
int n;
SegmentTree(int n) {
this->n = n;
st.resize(4 * n);
}
@bruteforceboy
bruteforceboy / climbing_stairs.py
Created July 22, 2024 09:06
WDSAP24-DP-I Code Snippets
# assuming we can take 1, 2, or 3 steps
n = int(input()) # the number of steps
k = int(input()) # the unmber of steps we can take
dp = [-1 for i in range(n + 1)]
# def number_of_ways(n):
# if n == 0:
# return 1
# if n == 1:
@bruteforceboy
bruteforceboy / lambdaEval.cpp
Created December 7, 2023 06:24
Lambda Equation Eval
#include <bits/stdc++.h>
using namespace std;
/*
@author: wilson
*/
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
@bruteforceboy
bruteforceboy / stress.sh
Created April 20, 2023 19:16
ubuntu stress
for i in {1..100} # modify for the number of tests
do
echo $i
./gen > input.txt
./code < input.txt > output.txt
./brute < input.txt > answer.txt
if ! cmp -s output.txt answer.txt
then
@bruteforceboy
bruteforceboy / stress.bat
Created April 20, 2023 19:16
windows stress
@echo off
for /l %%i in (1, 1, 100) do (
echo %%i
gen.exe %%i 4 5 > input.txt
code.exe < input.txt > output.txt
brute.exe < input.txt > answer.txt
fc output.txt answer.txt || goto :out
@bruteforceboy
bruteforceboy / longestNonRepeating.js
Created July 19, 2022 19:18
Longest string of non repeating characters problem
function longestNonRepeating(a, b, c) {
list = [
[a, 'a'],
[b, 'b'],
[c, 'c']
].sort()
if (list[2][0] > list[1][0] + list[0][0] + 1) {
return "none"
}
@bruteforceboy
bruteforceboy / Solution.java
Created June 17, 2022 15:44
Get Missing Dice Rolls Problem
public class Solution {
static int[] solution(int[] A, int F, int M) {
int aLength = A.length;
int aSum = 0;
for (int value : A) {
aSum += value; // sum of values in array A
}
int totalSum = M * (F + aLength); // the mean multiplied
@bruteforceboy
bruteforceboy / Solution.java
Last active June 11, 2022 15:23
DP Solution to the ATM Problem
import java.util.*;
public class Solution {
public static int[] getMinimumNotesCombination(int targetAmount, int[] notes) {
final int INF = Integer.MAX_VALUE;
int notesCount = notes.length;
int[][] dp = new int[targetAmount + 1][notesCount]; // represents
// a combination of notes with minimum sum that gives you some amount