Skip to content

Instantly share code, notes, and snippets.

View Aniruddha-Deb's full-sized avatar

Aniruddha Deb Aniruddha-Deb

View GitHub Profile
@Aniruddha-Deb
Aniruddha-Deb / ProbablePi.c
Created June 16, 2017 17:38
C program to calculate the (approximate) value of Pi using probability
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
double genRand() {
return (double)rand()/RAND_MAX*2.0-1.0;
}
int main() {
@Aniruddha-Deb
Aniruddha-Deb / ECommerce.java
Created July 15, 2017 17:21
The code for my ICSE computer project
import java.io.*;
public class ECommerce {
// Constants to be used for the brands
public String availableBrands[] = {
"Samsung",
"Apple",
"OnePlus",
"LG",
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
/**
This is my custom comeptitive programming setup.
@author Aniruddha Deb
*/
@Aniruddha-Deb
Aniruddha-Deb / libsdltest.c
Last active August 24, 2020 14:50
Testing some SDL Graphics by making a bouncing ball
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#include <SDL2/SDL.h>
typedef struct {
int x;
int y;
int r;
@Aniruddha-Deb
Aniruddha-Deb / OpSolverGreedy.java
Created November 6, 2020 09:58
Greedy algorithm to solve operations required for answer
package com.sensei.algorithms.numeric;
import java.util.Scanner;
public class OpSolverGreedy {
public static final double EPSILON = 0.005;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
@Aniruddha-Deb
Aniruddha-Deb / tut_scrape.sh
Created March 19, 2021 15:19
Scrape Math Tutorial Solutions using Screenshots
#!/bin/zsh
set -e
cp $HOME/Desktop/*.png .
# delete all screen 1 screenshots
find . -name '*PM.png' -delete
# convert images one by one
@Aniruddha-Deb
Aniruddha-Deb / rand_gen.c
Last active May 9, 2021 06:58
Generate random numbers following a given discrete distribution
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
double rand_gen(double *classes, double *probabilities, int n) {
double class = ((double)rand())/RAND_MAX;
double prob_sum = 0;
int class_index = 0;
for (; class_index<n; class_index++) {
if (prob_sum < class && prob_sum+probabilities[class_index] > class) {
@Aniruddha-Deb
Aniruddha-Deb / gentest.c
Last active March 5, 2022 14:12
generate VHDL test benches from an assembly file
#include <stdio.h>
#include <stdlib.h>
typedef char byte;
typedef unsigned int word;
char* header =
"-- TESTCASE AUTOGENERATED by gentest\n"
"library ieee;\n"
"use ieee.std_logic_1164.all;\n"
@Aniruddha-Deb
Aniruddha-Deb / queue_logger.py
Created June 30, 2022 08:23
Logger for queue (entry/exit time)
# Person, queue_in_time, queue_out_time, timedelta
# <int>, <time> , <time> , <timedelta>
import datetime
import curses
import pandas as pd
import os
def main(win):
win.nodelay(False)
@Aniruddha-Deb
Aniruddha-Deb / sudoku.cpp
Created September 4, 2022 12:02
sudoku solver
// CP hath spoiled me, I'm too lazy to write headers out.
// atleast not lazy enough to use namespace std :P
#include <bits/stdc++.h>
// Sudoku bitboard:
struct board_t {
uint8_t data[324];
uint8_t gs[90];
uint8_t rs[90];
uint8_t cs[90];