Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. Newton

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. Newton
View GitHub Profile
@thinkphp
thinkphp / gist:5778e4fd4d3119c49eed
Created September 12, 2014 09:58
A dead simple python that generates a file.out with randomly integers between -1024 and +1024 without duplicates
#
# A dead simple python that generates a file.out with randomly integers between -1024 and +1024 without duplicates.
# I use it when sorting something in c++
#
# Usage:
#
# python genvec 10
#
# ->[9,8,7,6,5,4,3,2,1,0]
#
@thinkphp
thinkphp / kruskal.cpp
Created September 25, 2014 07:11
Minimum Spanning Tree - Kruskal Algorithm
/*
* @ Description: Kruskal's Algorithm.
* @ Author: Adrian Statescu <mergesortv@gmail.com>, <http://thinkphp.ro>
* @ License: MIT
*
* @ using vector<pair <int, pair<int,int> > > and iterator for display
*/
#include <cstdio>
#include <algorithm>
#include <vector>
@thinkphp
thinkphp / kosaraju.cpp
Last active September 5, 2015 19:29
Kosaraju's Algorithm
/*
* @ Description: Kosaraju's Algorithm.
* @ Author: Adrian Statescu <mergesortv@gmail.com>, <http://thinkphp.ro>
* @ License: MIT
*
* @ using Depth First Search and DFS Reverse
*/
#include <cstdio>
#include <vector>
#include <stack>
/**
* Filename : dijkstra.cpp
* Author : Adrian Statescu <http://thinkphp.ro>
* Description : Dijkstra's Algorithm for Shortest Path Directed Graph.
*/
#include <cstdio>
#include <vector>
#include <queue>
#define FIN "dijkstra.in"
#define FOUT "dijkstra.out"
@thinkphp
thinkphp / connected.cpp
Created September 7, 2015 08:14
Strongly Connected Components
#include <stdio.h>
#define MAXN 100005
#define FIN "ctc.in"
#define FOUT "ctc.out"
struct Node {
int y;
Node *next;
} *L1[ MAXN ], //first list
*L2[ MAXN ], //second list
@thinkphp
thinkphp / Kosaraju.cpp
Created September 7, 2015 08:19
Kosaraju's Algorithm
#include <stdio.h>
#define MAXN 100005
#define FIN "ctc.in"
#define FOUT "ctc.out"
struct Node {
int y;
Node *next;
} *L1[ MAXN ], //first list
*L2[ MAXN ], //second list
@thinkphp
thinkphp / HeapSort.rb
Last active September 13, 2015 07:31
Heap Sort with removeHeap
/**
* HeapSort.py - Heap Sort Algorithm Sorting an array of randomly permuted values
* Copyright (c) 2015, Adrian Statescu (MIT License) <http://thinkphp.ro>, <mergesortv@gmail.com>
*/
class HeapSort
def initialize( filename, output )
@sizeHeap = 0
@thinkphp
thinkphp / heapsort.py
Created September 13, 2015 09:18
HeapSort in Python Language
#
# HeapSort.py - Heap Sort Algorithm Sorting an array of randomly permuted of values.
# Website <http://thinkphp.ro>(MIT License).
# Email <mergesortv@gmail.com>.
# Copyright (c) 2015, Adrian Statescu.
#
class HeapSort:
def __init__(self, arr):
@thinkphp
thinkphp / complex.cpp
Last active September 24, 2015 13:46
A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers and i is the imaginary unit.
/**
* A complex number is a number that can be expressed in the form a + bi,
* where a and b are real numbers and i is the imaginary unit,
* that satisfies the equation i^2 = -1.
*/
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#define FIN "complex.in"
@thinkphp
thinkphp / complex.py
Created September 25, 2015 05:20
A simple Class for Numbers Complex in Python.
import math
class Complex:
def __init__( self, a, b ):
self.a = a
self.b = b
def getModule( self ):