Skip to content

Instantly share code, notes, and snippets.

View SharanSMenon's full-sized avatar
🎯
Focusing

SharanSMenon

🎯
Focusing
View GitHub Profile
def gcd(a, b):
"""
An efficient algorithm to compute GCD \n
a is a number \n
b is the other number \n
no other arguments
"""
if b == 0:
return a
ap = a % b
def gcd(a, b):
"""
An efficient algorithm to compute GCD \n
a is a number \n
b is the other number \n
no other arguments
"""
if b == 0:
return a
ap = a % b
@SharanSMenon
SharanSMenon / fibonacci.js
Created April 21, 2018 23:25
This is a fibonacci number thing. It is a extremely efficient algorithm
class Fibonacci {
/**
* Fibonacci class
* A collection of functions
*/
constructor() {
/**
* No variables for this constructor
*/
console.log("Welcome to the Fibonacci class");
from numbers import *
from strings import *
def print_instructions():
print("Welcome")
print("0 - Print instructions")
print("1 - Choose a number function")
print("2 - Choose a string function")
print("3 - Exit the program")
@SharanSMenon
SharanSMenon / change.py
Created April 28, 2018 23:01
A greedy algorithm for calculating change used by cashiers all over the world
# Uses python3
import sys
from functools import reduce
def get_change(m):
"""
:type m: int
:param m:
:return: int
@SharanSMenon
SharanSMenon / BinarySearch.java
Created May 2, 2018 16:13
Implements the binary search algorithm
package com.sharan;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* There is nothing for lists yet except for an empty
* constructor
@SharanSMenon
SharanSMenon / binary_search.py
Created May 2, 2018 16:20
Implements the binary search algorithm in Python 3
def sort(l):
"""
Sorts a list
:param l:
:return: l_sorted
"""
l_copy = l.copy()
l_sorted = []
for i in range(0, len(l_copy)):
minimum = reduce(min, l_copy)
class BarChart {
constructor(_element, _data, _x, _y, _title, _xs, _ys) {
this.element = _element;
this.parent = $(_element)
this.data = _data;
this.xv = _x;
this.yv = _y;
this.title = _title;
this.xs = _xs;
this.ys = _ys;
@SharanSMenon
SharanSMenon / .block
Last active June 21, 2018 17:44
Stacked area with D3 brush
license: mit
border: no
scrolling: yes
@SharanSMenon
SharanSMenon / .block
Created June 21, 2018 17:38
fresh block
license: mit
border: no
scrolling: yes