Skip to content

Instantly share code, notes, and snippets.

View thien's full-sized avatar
🏗️
making things

@thien thien

🏗️
making things
View GitHub Profile
@thien
thien / Recursive SelectionSort
Last active September 16, 2020 06:15
A recursive SelectionSort algorithm written in python
def selection(list, i, j, flag):
size = len(list)
if (i < size - 1):
if (flag):
j = i + 1;
if (j < size):
if (list[i] > list[j]):
list[i], list[j] = list[j], list[i]
selection(list, i, j + 1, 0);
selection(list, i + 1, 0, 1);
@thien
thien / Binary Search
Created May 19, 2016 09:20
An iterative and recursive approach to BinarySearch in Python.
@thien
thien / strassen.py
Created December 2, 2016 13:16
Strassen's Algorithm for a 2x2 Matrix
x=[[0,2],[0,1]]
y=[[0,0],[3,4]]
def strassen(a,b):
S = [b[0][1] - b[1][1],
a[0][0] + a[0][1],
a[1][0] + a[1][1],
b[1][0] - b[0][0],
a[0][0] + a[1][1],
b[0][0] + b[1][1],
a[0][1] - a[1][1],
@thien
thien / fib.py
Created December 4, 2016 21:09
Fibonacci
def fib(n):
if n is 0:
return 0
if n is 1:
return 1
else:
return fib(n-1) + fib(n-2)
for i in range(0,10):
print(fib(i))
@thien
thien / keybase.md
Last active May 14, 2017 14:43
keybase

Keybase proof

I hereby claim:

  • I am thien on github.
  • I am thien (https://keybase.io/thien) on keybase.
  • I have a public key ASCA1rbMKEBEIVc2vwp32Wsc9S433KjiE9Q7m6F1nYntqgo

To claim this, I am signing this object:

@thien
thien / multicast.md
Created May 13, 2017 16:16
multicast notes

Multicasting

Before send/receiving IP multicast data, the network needs to support it: - hosts must be configured to send/receive multicast data - routers must support IGMP, multicast forwarding, and routing protocols.

You would send it to a Class D IP address

  • to join, you would contact a local router to join the group.
  • You'd use the IGMP to join a multicast group.
  • routers uses a multicast routing protocol to determine which subnets to forward to.
@thien
thien / tensor.py
Created October 18, 2017 17:44
My first Tensor
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf
"""
Input > weight > hidden layer 1 (activation function) > weights > hidden l 2.
repeat until output layer.
compare output to intended output > cost function (cross entropy)
@thien
thien / simplex.py
Last active April 6, 2018 20:05
Simplex Algorithm implementation in Python (3.x)
import numpy as np
def simplex(c, A, b, basis):
z = 0
tableau = None
foundOptimal = False
numRound = 1
# we'll be using tableau because it's easier and makes more sense.

Artificial Intelligence, Machine Learning, Neural Networks, Neuroevolution, Genetic Algorithms, Draughts, Checkers, Crossover, Monte Carlo Tree Search

Introduction

The intention of this project is to explore the effectiveness of genetic algorithms to improve the neurons of a neural network. Neural networks can be used to evaluate the performance of two players in a zero-sum

@thien
thien / seq_alignment.py
Created April 18, 2018 17:15
needleman-wunch and smith-waterman algorithms
from termcolor import *
# simplicity values
def sub(a,b):
# substitute
if a == b:
return 0
else:
return 1