Skip to content

Instantly share code, notes, and snippets.

View isaiah-perumalla's full-sized avatar

isaiah isaiah-perumalla

View GitHub Profile
--------------------------- MODULE concurrent_map ---------------------------
EXTENDS TLC, Integers, FiniteSets, Sequences
ReaderCount == 2
Readers == 1..ReaderCount

Keybase proof

I hereby claim:

  • I am isaiah-perumalla on github.
  • I am isaiah_p (https://keybase.io/isaiah_p) on keybase.
  • I have a public key ASB2WZfQUWqLR4Aci20nORmizByne74eM-xm_t-EX9diowo

To claim this, I am signing this object:

package com.company;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {
public static final int INF = Integer.MAX_VALUE;
public static void main(String[] args) {
package practice;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import practice.BinarySearchTree.Node;
public class BSTPrint {
@isaiah-perumalla
isaiah-perumalla / functions.py
Last active November 26, 2019 16:20
some python functions
def calc_avg(items):
if not items:
return 0
total = sum(items)
return float(total)/len(items)
def std_deviation(items):
if not items: return 0
mean = calc_avg(items)
@isaiah-perumalla
isaiah-perumalla / q-funcs.q
Last active November 6, 2019 20:10
some q functions
//function return all subset of a list
sset: {[xs] (enlist ()) {x, (y,) each x }/ xs}
//or using the map each right /:
sset: {[xs] (enlist ()) {x, y ,/: x }/ xs}
//q)sset (1; 2; 3;`a)
()
,1
,2
2 1

Keybase proof

I hereby claim:

  • I am isaiah-perumalla on github.
  • I am isaiahperumalla (https://keybase.io/isaiahperumalla) on keybase.
  • I have a public key whose fingerprint is E099 3317 C358 C9E7 6CD6 12C8 B55B AF0E 50E1 63B1

To claim this, I am signing this object:

@isaiah-perumalla
isaiah-perumalla / change.fs
Last active December 20, 2015 04:09
make change algorithm. compute change with using minimum number of coins
[<Measure>] type p
let count ps = let rec countcs acc = function
|[] -> acc
|(_, qty)::xs -> (countcs (acc+qty) xs)
in countcs 0 ps
let lessThan (x:int<p>) xs = List.filter (fun (coin, _) -> x >= coin) xs
let num_coins (coin:int<p>, qty:int) (amt:int<p>) = min qty (int(amt/coin))
let better ps bs =
@isaiah-perumalla
isaiah-perumalla / subpalindrome.py
Last active December 19, 2015 09:39
simple linear time algorithm for finding longest palindome substring in a give string
def longest_subpalindrome_slice(s):
longest=(0,0)
start_idx=0 #index of palindrone ending at i
repeated = True
#loop invariant we know longest palindrome in s[0:i]
#and we know longest palidrom ending at i
for i in xrange(1,len(s)):
if(start_idx != 0 and s[start_idx-1] == s[i]) :
start_idx = start_idx-1
repeated = False
#include <pthread.h>
#include <stdio.h>
int x, y = 0;
int r0, r1;
void *core0 (void *arg)
{
x = 1;
asm volatile ("mfence" ::: "memory"); // ensure compiler or hardware will not reorder, store buffer is drained