Skip to content

Instantly share code, notes, and snippets.

View mlliarm's full-sized avatar

Michail Liarmakopoulos mlliarm

View GitHub Profile
@mlliarm
mlliarm / factoring.md
Last active February 25, 2022 06:21
Factoring 10...01

Factoring 10...01

Tools

GNU/Linux factor Bash tool and python3.

Code & results

# bash shell
 $ factor 101
@mlliarm
mlliarm / goodcode.cpp
Created February 11, 2022 18:17 — forked from Maltysen/goodcode.cpp
Good Code
//header
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
@mlliarm
mlliarm / Installing Python 3.7 from source on Ubuntu 18.04.md
Created January 12, 2022 23:56
Installing Python 3.7 from source on Ubuntu 18.04

Installing Python 3.7 from source on Ubuntu 18.04

# update system
sudo apt update && sudo apt upgrade -y

# install build tools and python prerequisites
sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev

# download and extract python
@mlliarm
mlliarm / pycordic.md
Created December 24, 2021 09:36
A python implementation of the CORDIC algorithm.

What

According to the lemma in the English Wikipedia:

CORDIC (for COordinate Rotation DIgital Computer), also known as Volder's algorithm, or: Digit-by-digit method Circular CORDIC (Jack E. Volder),[1][2] Linear CORDIC, Hyperbolic CORDIC (John Stephen Walther),[3][4] and Generalized Hyperbolic CORDIC (GH CORDIC) (Yuanyong Luo et al.),[5][6] is a simple and efficient algorithm to calculate trigonometric functions, hyperbolic functions, square roots, multiplications, divisions, and exponentials and logarithms with arbitrary base, typically converging with one digit (or bit) per iteration. CORDIC is therefore also an example of digit-by-digit algorithms. CORDIC and closely related methods known as pseudo-multiplication and pseudo-division or factor combining are commonly used when no hardware multiplier is available (e.g. in simple microcontrollers and FPGAs), as the only operations it requires are additions, subtractions, bitshift and lookup tables. As

@mlliarm
mlliarm / whitney.c
Last active December 23, 2021 16:45 — forked from anonymous/gist:f72e5c4a432492abce59
Arthur Whitney's J interpreter, decompressed
// Link to the original: http://www.jsoftware.com/jwiki/Essays/Incunabulum
// Found at https://news.ycombinator.com/item?id=8533843
typedef char C;
typedef long I;
typedef struct a {
I t,r,d[3],p[2];
}* A;
@mlliarm
mlliarm / gist:261037e635c0b8942fd6b939e2608922
Created December 23, 2021 06:24 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@mlliarm
mlliarm / combinators_for_logic.hs
Created December 23, 2021 04:47
Combinators for logic programming (Haskell98)
-- Authors: Mike Spivey and Silvija Seres
-- Taken from: https://www.cs.ox.ac.uk/publications/books/fop/dist/fop/chapters/9/Logic.hs,
-- "The fun of programming book", https://www.cs.ox.ac.uk/publications/books/fop/,
-- Chapter 9, Combinators for logic programming
-- Haskell 98 compliant.
module Logic where
import List
-- Section 9.2
@mlliarm
mlliarm / sympy-test.md
Last active December 22, 2021 22:10
Testing SymPy

Testing SymPy

What

I've been a great fan of Mathematica since the first time I've used it back in 2000.

After a couple discussions of one of the creators of SymPy over Twitter, I decided to look deeper in this interesting project.

Tests

This is the Python version: