{{ message }}

Instantly share code, notes, and snippets.

# Jyotirmoy Bhattacharyajmoy

Last active Aug 16, 2019
Solving a puzzle using the Isabelle proof assistant
View Friends.thy
 section ‹A Simple Graph Problem› text ‹ We shall prove the following: "In a finite group of people, some of whom are friends with some of the others there must be at least two people who have the same number of friends." › theory Friends imports Main Finite_Set
Created Jun 6, 2019
Three Counters
View three-count.py
 counters = {key:collections.Counter() for key in ['child','mother','father']} with open("day2/names.csv") as f: rdr = csv.DictReader(f) for r in rdr: for key in counters: l = r[key].split() if len(l)>0: counters[key][l[0]] += 1 commonize = lambda ctr,N: {t[0] for t in ctr.most_common(N)}
Created Jun 6, 2019
Session 1 in Python
View degrees.py
 with open("code/test2.txt") as fin: sbj_counts = {} for l in fin: l = l.strip() m = re.fullmatch(r"((?:\w|\.)+)\s+in\s+(\w+)",l) if m: degree,subject = m.group(1,2) print(f"{degree} ({subject})") if subject in sbj_counts: sbj_counts[subject].add(degree)
Created Feb 25, 2011
Get Wikipedia watchlist as an RSS/ATOM feed
View wikiwatch.py
 """Get Wikipedia watchlist as an RSS/ATOM feed (c) Jyotirmoy Bhattacharya, 2007 Usage: wikiwatch [format] [format] is either 'rss' or 'atom' """ import sys import xml.sax,xml.sax.handler
Last active Jan 29, 2019
Solving a puzzle using Isabelle: 2nd attempt
View Friends2.thy
 section ‹A Simple Graph Problem: Second Attempt› text ‹ We shall prove the following: "In a finite group of people, some of whom are friends with some of the others there must be at least two people who have the same number of friends." › theory Friends imports Main Finite_Set
Last active Nov 18, 2018
Why soap bubbles are colorful and windowpanes are not
View thin-film.ipynb
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Last active Aug 28, 2018
Solving the competitive storage model using collocation
View CompetitiveStoragePython.ipynb
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Created Jun 7, 2017
View causal1.py
 import numpy as np import numpy.random as nr def gen(N): X = nr.choice([0,1],size=N,p=[0.6,0.4]) D = nr.choice([0,1],size=N,p=[0.6,0.4]) epsi = nr.uniform(0,2,N) Y = X+D*epsi return X,D,epsi,Y def estim(D,Y):
Last active May 29, 2017
River crossing puzzle
View thugs_suitcase.py
 import itertools as it NTHUGS = 3 NCASES = 2 BOATCAP = 3 thugs = set() cases = set() owner = dict() nresults = 0
Last active Oct 9, 2016
Value Function Iteration Using OpenCL
View CL_RBC.py
 # Basic RBC model with full depreciation # U(c) = log(c) # F(K) = Z k^\alpha # where Z is a finite-state Markov chain # # Original version: # Jesus Fernandez-Villaverde # Haverford, July 3, 2013 # https://github.com/jesusfv/Comparison-Programming-Languages-Economics/blob/master/RBC_Python.py #
You can’t perform that action at this time.