Skip to content

Instantly share code, notes, and snippets.

View sharmaeklavya2's full-sized avatar
📚
Not coding actively anymore. Doing math instead.

Eklavya Sharma sharmaeklavya2

📚
Not coding actively anymore. Doing math instead.
View GitHub Profile
@sharmaeklavya2
sharmaeklavya2 / cp_syllabus.md
Last active March 29, 2024 12:24
Competitive Programming Syllabus

Competitive Programming Syllabus

Geometry

  • Problems - Refer the article for a list of problems which can be solved using Rotating Calipers technique.
@sharmaeklavya2
sharmaeklavya2 / lptTightApprox.py
Last active February 19, 2024 23:54
Use code2dtree to find the tight approximation factor for the LPT algorithm for makespan minimization
#!/usr/bin/env python3
"""
Uses code2dtree (https://github.com/sharmaeklavya2/code2dtree) to find
the tight approximation factor of the LPT algorithm for makespan minimization
for a given number of jobs and machines.
Specifically, for every possible scenario, we find out the maximum load
a machine in the LPT schedule can have if the optimal makespan is at most 1.
@sharmaeklavya2
sharmaeklavya2 / segtree.cpp
Last active January 27, 2024 09:13
Generic SegTree
// See codechef FLIPCOIN for an example
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <vector>
/*
Output of segment tree range queries are modelled as elements of a monoid.
Updates on the segment tree are functions on the monoid.
@sharmaeklavya2
sharmaeklavya2 / time-chart.py
Last active January 25, 2024 16:48
Track how a noisy quantity changes over time (e.g. my body weight)
#!/usr/bin/env python3
"""
Visualize how a quantity varies with time.
Reads a CSV file where first column is timestamp.
Plots the data points and a weighted average of a sliding window.
"""
import csv
import math
@sharmaeklavya2
sharmaeklavya2 / my-math-substs.plist
Created July 26, 2023 20:29
macOS math text substitutions
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>phrase</key>
<string>₋</string>
<key>shortcut</key>
<string>_-</string>
</dict>
@sharmaeklavya2
sharmaeklavya2 / lolcode_tutorial.md
Last active May 19, 2023 19:38
LOLCODE tutorial

LOLCODE

LOLCODE is an esoteric programming language inspired by lolcat memes on the internet. The language was created in 2007 by Adam Lindsay, researcher at Lancaster University's Computing Department.

Here I have explained basics of LOLCODE with complete examples. However, you may have questions even after reading them because I have not included all details. For an exhaustive reference, read the official documentation.

Hello World

HAI 1.2
BTW This is the famous 'Hello World' program
@sharmaeklavya2
sharmaeklavya2 / CP1.md
Last active May 10, 2023 21:26
Getting started with Competitive Programming

Starting out with Competitive Programming

(This guide is meant for beginners. If you have solved 100+ problems and are looking for guidance on how to solve problems involving algorithms and data structures, this document is not for you.)

Competitive Programming is an interesting activity which mixes problem solving with programming. It is not only enjoyable but also very demanded in placements. Competitive programming will make you very good at writing efficient programs quickly.

@sharmaeklavya2
sharmaeklavya2 / linreg.py
Last active December 12, 2022 21:37
Linear regression on 1 variable with confidence intervals
#!/usr/bin/env python3
"""
Takes a CSV file as input and performs linear regression on the data.
"""
import sys
import ast
import argparse
import numpy as np
@sharmaeklavya2
sharmaeklavya2 / float2frac.py
Last active November 24, 2022 23:23
float to nearest fraction
#!/usr/bin/env python3
"""
Convert a float to the nearest fraction.
"""
import math
import ast
import argparse
from fractions import Fraction as F
@sharmaeklavya2
sharmaeklavya2 / download-latex-files.py
Last active October 5, 2022 03:09
Downloads style/class files necessary to compile a LaTeX paper.
#!/usr/bin/env python3
"""Downloads style/class files necessary to compile a LaTeX paper."""
import sys
import os
from os.path import join as pjoin
import argparse
from urllib.request import urlopen
from zipfile import ZipFile