Skip to content

Instantly share code, notes, and snippets.

View KushalVenkatesh's full-sized avatar

kvenkat KushalVenkatesh

View GitHub Profile
@KushalVenkatesh
KushalVenkatesh / WeightedQuickUnionFind.java
Created March 12, 2019 12:24
Weighted Quick Union Find algorithm (Union-by-Size/Union-by-Height)
public class WeightedQuickUnionFind{
private int[] id;
private int[] sz;
private int[] height; // this is for union-by-height
private int count; // the number of connected components
private int[] maximum; // keep track of the maximum object in each connected component
public WeightedQuickUnionFind(int N){
id = new int[N];
sz = new int[N];
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd
app = dash.Dash()
df = pd.read_csv(
'https://gist.githubusercontent.com/chriddyp/'

What is Python? State some programming language features of Python.

Python is a modern powerful interpreted language with objects, modules, threads, exceptions, and automatic memory managements. Python was introduced to the world in the year 1991 by Guido van Rossum Salient features of Python are

  • Simple & Easy: Python is simple language & easy to learn.
  • Free/open source: it means everybody can use python without purchasing license.
  • High level language: when coding in Python one need not worry about low-level details.
  • Portable: Python codes are Machine & platform independent.
  • Extensible: Python program supports usage of C/ C++ codes.
@KushalVenkatesh
KushalVenkatesh / rmagic_example.ipynb
Created July 23, 2018 11:36 — forked from simecek/rmagic_example.ipynb
How to add R code to your (IPython) Jupyter Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KushalVenkatesh
KushalVenkatesh / surprise_tutorial.py
Created June 13, 2018 12:10 — forked from mahermalaeb/surprise_tutorial.py
The easy guide for building python collaborative filtering recommendation system in 2017
import zipfile
from surprise import Reader, Dataset, SVD, evaluate
# Unzip ml-100k.zip
zipfile = zipfile.ZipFile('ml-100k.zip', 'r')
zipfile.extractall()
zipfile.close()
# Read data into an array of strings
with open('./ml-100k/u.data') as f:
@KushalVenkatesh
KushalVenkatesh / multimanager.py
Created January 21, 2018 03:47 — forked from lamarmarshall/multimanager.py
python multiprocessing manager / queue
import multiprocessing
def worker(dict, key, item):
dict[key] = item
if __name__ == '__main__':
mgr = multiprocessing.Manager()
dictionary = mgr.dict()
jobs = [multiprocessing.Process(target=worker, args=(dictionary, i, i*2)) \
@KushalVenkatesh
KushalVenkatesh / Elevator.js
Created January 21, 2018 03:46 — forked from mwmcode/Elevator.js
Simple elevator algorithm (return total stops of elevator)
// A [] queue of ppl and their weights
// B [] floors each person is going to
// M maximum floors of building
// X maximum people on elv
// Y maximum wight on elv
function solution(A, B, M, X, Y) {
// if queue had one person and is going to a reachable floor
if (A.length === 1 && B[0] <= M) {
return 2;
@KushalVenkatesh
KushalVenkatesh / tests_for_toptal_on_codility.py
Last active January 17, 2018 16:57 — forked from 1st/tests_for_toptal_on_codility.py
My answers for tests on http://codility.com that I passed for company http://toptal.com I use Python language to solve problems.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Test that I passed on codility.com for TopTal company
#
# Task #1
def binary_gap(N):
from __future__ import print_function
import os
import numpy as np
from keras.layers import RepeatVector
from keras.layers.core import Dropout
from keras.layers.recurrent import LSTM
from keras.models import Sequential
from keras.models import load_model
@KushalVenkatesh
KushalVenkatesh / download-url-to-file.rb
Created November 15, 2016 16:24 — forked from johnjohndoe/download-url-to-file.rb
Ruby script to download a number of files from individual URLs via HTTP/HTTPS/FTP specified in an external file.
#!/usr/bin/env ruby
#
# Ruby script to download a number of files
# from individual URLs via HTTP/HTTPS/FTP
# specified in an external file.
#
# Author: Tobias Preuss
# Revision: 2013-04-18 16:26 +0100 UTC
# License: Creative Commons Attribution-ShareAlike 3.0 Unported