Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Exploring blockchain tech! :D

Ashwin Narayan RationalAsh

💭
Exploring blockchain tech! :D
View GitHub Profile
View cryptopangrams.hs
import Data.List (sort, group)
import qualified Data.Map as M
import Control.Monad
sampleStr = "CJQUIZKNOWBEVYOFDPFLUXALGORITHMS" :: String
sampleN = 103 :: Integer
sampleNums = [217, 1891, 4819, 2291, 2987, 3811, 1739, 2491, 4717, 445, 65, 1079, 8383, 5353, 901, 187, 649, 1003, 697, 3239, 7663, 291, 123, 779, 1007, 3551, 1943, 2117, 1679, 989, 3053] :: [Integer]
sampleNums2 = [9, 9, 9, 21, 217, 1891, 4819, 2291, 2987, 3811, 1739, 2491, 4717, 445, 65, 1079, 8383, 5353, 901, 187, 649, 1003, 697, 3239, 7663, 291, 123, 779, 1007, 3551, 1943, 2117, 1679, 989, 3053] :: [Integer]
sampleNums3 = [15, 15, 15, 35, 217, 1891, 4819, 2291, 2987, 3811, 1739, 2491, 4717, 445, 65, 1079, 8383, 5353, 901, 187, 649, 1003, 697, 3239, 7663, 291, 123, 779, 1007, 3551, 1943, 2117, 1679, 989, 3053] :: [Integer]
@RationalAsh
RationalAsh / ycgyow.hs
Created April 13, 2019 06:53
Haskell Solution to Google Code Jam 2019 Qualifying Round Problem 2.
View ycgyow.hs
import Control.Monad
sampleMoves = "EESSSESE"
applyMove :: (Int, Int) -> Char -> (Int, Int)
applyMove (row, col) move
| move == 'S' = (row+1, col)
| move == 'E' = (row, col+1)
| otherwise = (row, col)
@RationalAsh
RationalAsh / foregone-solution.hs
Created April 11, 2019 09:30
Solution to the Google Code Jam Qualification Round Problem #1
View foregone-solution.hs
import Control.Monad
getA :: [Char] -> [Char]
getA n = map (\x -> if x == '4' then '2' else '0') n
getB :: [Char] -> [Char]
getB n = map (\x -> if x == '4' then '2' else x) n
solveCase :: [Char] -> (String, String)
solveCase n = (getA n, getB n)
@RationalAsh
RationalAsh / som.py
Last active March 30, 2016 04:25
Implementation of self organizing maps.
View som.py
#!/usr/bin/python
#My implementation of self organizing maps
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial.distance import pdist, cdist
import time
View logistic_classifier.py
#!/usr/bin/python
import numpy as np
from numpy import dot, random
import matplotlib.pyplot as plt
import time
def softmax(x):
exps = np.nan_to_num(np.exp(x))
return exps/np.nan_to_num(np.sum(exps))
@RationalAsh
RationalAsh / prime_spiral.py
Created November 20, 2015 16:48
Creates an Ulam Spiral as a square matrix of size N.
View prime_spiral.py
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
def create_number_spiral(N):
'''Creates a number spiral as
a square matrix of size N'''
X = np.ndarray((N,N))
View lin_reg.py
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import square
#Mean Square error function
def costf(X, y, theta):
m = y.shape[0]
#print m
@RationalAsh
RationalAsh / The Technical Interview Cheat Sheet.md
Last active September 10, 2015 03:10 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.
View The Technical Interview Cheat Sheet.md

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.