Skip to content

Instantly share code, notes, and snippets.

View izanbf1803's full-sized avatar

Izan Beltran izanbf1803

View GitHub Profile
#include <vector>
#include <iostream>
using namespace std;
const int abc_size = 26;
int main()
{
vector<int> lval(abc_size);
#include <iostream>
#include <vector>
using namespace std;
bool less_than(
const string& a,
int ai,
int bi,
int size
#include <vector>
#include <iostream>
using namespace std;
const int _1e6 = 1000000;
void print(const vector<vector<int> >& lines) {
cout << endl;
for (int i = 0; i < lines.size(); i++) {
#include <iostream>
#include <vector>
using namespace std;
const int _1e5 = 100000;
int abs(int n) { return (n < 0 ? -n : n); }
int main()
@izanbf1803
izanbf1803 / musical_notes.h
Created May 23, 2017 09:02
All musical notes to frequency
#define Do0 16
#define Do_0 17
#define Re0 18
#define Re_0 19
#define Mi0 20
#define Fa0 21
#define Fa_0 23
#define Sol0 24
#define Sol_0 25
#define La0 27
@izanbf1803
izanbf1803 / postfix_parser.cc
Last active November 12, 2017 20:26
Postfix notation (Reverse Polish notation) evaluator
#include <iostream>
#include <stack>
#include <vector>
#include <unordered_map>
#include <cassert>
#include <cmath>
using namespace std;
#define NUMBER 0
#define ARITHMETIC_OP 1
@izanbf1803
izanbf1803 / nCr.py
Last active August 26, 2019 17:02
Combinations formula fast implementation
def nCr(n, r):
if r > n // 2:
return nCr(n, n - r)
prod = 1
for i in range(1, r + 1):
prod *= (n - i + 1) / i
return int(prod)
@izanbf1803
izanbf1803 / install-opencv.sh
Created July 25, 2017 14:48
Install OpenCV in Linux with one script.
# Source: https://milq.github.io/install-opencv-ubuntu-debian/
######################################
# INSTALL OPENCV ON UBUNTU OR DEBIAN #
######################################
# | THIS SCRIPT IS TESTED CORRECTLY ON |
# |----------------------------------------------------|
# | OS | OpenCV | Test | Last test |
# |----------------|--------------|------|-------------|
@izanbf1803
izanbf1803 / MyForm.cpp
Created August 31, 2017 13:58
Default main() code required to initialize CLR UI Windows Forms with Visual Studio.
#include "[FORM NAME].h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
@izanbf1803
izanbf1803 / pyTriples.hs
Created September 1, 2017 01:32
Haskell comprehension list implementing Pythagorean triples calculation.
pyTriples :: Integer -> [(Integer, Integer, Integer)]
pyTriples n = [(a, b, c) | a <- [1..n], b <- [1..n], c <- [1..n], a^2 + b^2 == c^2]