Skip to content

Instantly share code, notes, and snippets.

View svineet's full-sized avatar

Sai Vineet svineet

View GitHub Profile
@svineet
svineet / README.txt
Created November 16, 2021 10:36
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
import math
DEBUG = False
def generate_input_sample(params):
population = COVIDPopulation(params["N"], params["K"])
return population
from bisect import bisect_left, bisect_right
class COVIDPopulation:
def __init__(self, N, K):
"""
K is the number of infected persons in N number of people.
It's not a percentage.
"""
self.N = N
@svineet
svineet / tic_tac_toe_solved.py
Last active May 20, 2020 03:32
A program that solves tic tac toe using the Minimax algorithm. Can defeat or draw always.
import time
import sys
print "Maximizer is X and Minimizer O"
class Position:
def __init__(self, parent_):
self.parent = parent_
self.children = []
self.best_eval = []
@svineet
svineet / BFS.py
Last active August 29, 2015 14:03
BFS to solve shortest path in maze
#!/usr/bin/env python
adj = {}
m = """012
345
678
"""
# Contruct adj list
@svineet
svineet / tic-tac-toe-tomek.py
Created September 21, 2013 09:33
Google Code Jam problem - "Tic-Tac-Toe-Tomek" Link to problem - https://code.google.com/codejam/contest/2270488/dashboard
#!/usr/bin/python
X = "X"
O = "O"
T = "T"
cases = ["",
"X won",
"Draw",
"Game has not completed",
"O won"]
@svineet
svineet / VerEx.rb
Created August 17, 2013 07:01
Method -chaining implementation of [VerEx](http://verbalexpressions.github.io/) in Ruby. The other [implementation](https://github.com/ryan-endacott/verbal_expressions) uses DSL. This is just a emperiment. May have a lot of bugs, and is not by any means complete.
# This is a program trying to implement Verbal Expressions
# See this for more info - http://verbalexpressions.github.io/
def VerEx
return VerExClass.new
end
class VerExClass
@regex = "" # The main regex variable
@svineet
svineet / pi.py
Created April 16, 2013 11:32
Pi calculator. It's accurate for 5 digits after decimal.
def main():
print "Calculating pi. Calm down,bro!"
acc = 0.0
for i in range(1,1000001,4):
acc += 4/float(i)
acc -= 4/float(i+2)
print i
@svineet
svineet / main.py
Created April 6, 2013 08:23
A gist to gather the whole merchant of venice explanation from 'SparkNotes' named website.
import requests
import BeautifulSoup
def main():
print "Hey! Let's start Doing things"
done=False; i = 0 ; acc = "<html><body>"
while (i<=50):
i = i + 2
print "Getting {0}".format(i)
r = requests.get(
@svineet
svineet / IMOresults.py
Last active February 4, 2023 11:13
A script that checks imo results for kinshuks result.
import requests
uri = "http://www.sofworld.org/imo-second-level-result/JH02800800"
for i in range(1,10):
print i
r = requests.get( uri+str(i) )
if "KINSHUK" in r.content:
print "Found it! I'm opening it in the browser now"
import webbrowser