Skip to content

Instantly share code, notes, and snippets.

View B1Z0N's full-sized avatar
🐢
contemplating

Mykola Fedurko B1Z0N

🐢
contemplating
View GitHub Profile
@B1Z0N
B1Z0N / relation_builder.py
Last active April 10, 2020 15:29
Build full relation matrix based on minimal relations number interactively
# Build full relation matrix
# based on minimal relations number
# interactively
def floyd_warshall(graph, v):
"""
:param graph: 2D array calculated from weight[edge[i, j]]
:type graph: List[List[float]]
:param v: number of vertices
@B1Z0N
B1Z0N / OOD.md
Last active March 14, 2020 10:27
OO Design Principles

Creational design patterns

  • Abstract Factory - an instance of several families of classes
  • Builder - object construction from its representation
  • Factory Method - an instance of several derived classes
  • Object Pool - expensive acquisition and release of resources by recycling objects that are no longer in use
  • Prototype - fully initialized instance to be copied or cloned
  • Singleton - class of which only a single instance can exist

Structural design patterns

@B1Z0N
B1Z0N / competitive.cpp
Last active February 23, 2020 17:57 — forked from kodekracker/c++Template.cpp
Basic C++ Template for Competitive Programming
/*
___,,___
,d8888888888b,_
_,d889' 8888b,
_,d8888' 8888888b,
_,d8889' 888888888888b,_
_,d8889' 888888889'688888, /b
_,d8889' 88888889' `6888d 6,_
,d88886' _d888889' ,8d b888b, d\
,d889'888, d8889' 8d 9888888Y )
@B1Z0N
B1Z0N / bit_shortcuts.cpp
Created February 2, 2020 13:23
The collection of useful bit operations for speed and sanity purposes
// Number of leading zeroes: builtin_clz(x)
// Number of trailing zeroes : builtin_ctz(x)
// Number of 1-bits: __builtin_popcount(x)
// The parity (even or odd) of the number of ones: __builtin_parity(x)
// a * 2^n
constexpr int multiplyByPowerOf2(int a, int n) {
return a << n;
}
@B1Z0N
B1Z0N / currying.js
Created December 4, 2019 05:44
Some functional concepts implemented in js
'use strict';
const curry = (f) => {
const argc = f.length;
if (argc === 1) {
return f;
}
return (a) => curry(f.bind(null, a), argc - 1);
};
@B1Z0N
B1Z0N / cloudSettings
Last active December 3, 2019 21:19
Visual Studio Code Settings Sync Gist as of 3 of December 2019
{"lastUpload":"2019-12-03T21:06:53.375Z","extensionVersion":"v3.4.3"}
@B1Z0N
B1Z0N / trait_factory.cpp
Created July 24, 2019 21:27
Code for generation of predicate traits
// Code for generation of predicate traits
// compile with g++ -std=c++17 ...
#include <utility>
#include <vector>
#include <iostream>
// ***************IMPLEMENTATION***************
@B1Z0N
B1Z0N / template_traits.hpp
Created July 24, 2019 00:39
c++ template traits implemented for better understanding
#include <utility>
//*********************TRANSFORMATION*TRAITS***************************
// Remove reference
template <typename T>
@B1Z0N
B1Z0N / max_min_var.cpp
Last active July 19, 2019 11:41
finding maximal and minimal element in variadic number of arguments
// finding maximal and minimalelement in variadic number of arguments
#include <iostream>
namespace cmns {
// commons
// *************MAXIMAL*VALUE*FUNCTIONS****************
@B1Z0N
B1Z0N / container_printer.cpp
Last active July 19, 2019 11:41
customizable recursive container print
// code that looks common enough for me to write and post it here
// printing iterable of iterable/values of ... to ostream object
// works on any std conatiner and on any class that meets
// the requirements of Container(named requirement)
// ======================================================================
// compile with g++ container_printer.cpp -o container_printer -std=c++17
// other compilers not guaranteed to compile this
// ======================================================================