Skip to content

Instantly share code, notes, and snippets.

View razimantv's full-sized avatar

Raziman T V razimantv

  • Imperial College London
  • London, United Kingdom
  • 19:36 (UTC +01:00)
  • X @razimantv
View GitHub Profile
@razimantv
razimantv / snakesandladders.py
Created July 8, 2024 18:20
Expected rolls to finish the Snakes and Ladders game
# Find the expected number of steps to solve snakes and ladders
# Author: Raziman T V (github.com/razimantv)
import numpy as np
N = 100
snakes_ladders = {
2: 23, 6: 45, 20: 59, 43: 17, 50: 5, 52: 72, 56: 8, 57: 96, 71: 92,
73: 15, 84: 63, 87: 49, 98: 40
}
@razimantv
razimantv / strikerates.ipynb
Created November 16, 2023 00:04
Strike rate statistics
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@razimantv
razimantv / superman.cpp
Last active November 12, 2023 14:35
Superman Diwali solution
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
@razimantv
razimantv / splitgame.cpp
Created September 25, 2023 09:50
Split game solver
/**
* Two-Player Split Game Solver
*
* This C++ program solves a two-player game played with two hands
*
* - Two players take turns, starting with two fingers out on each hand
* - Each turn, a player can add the number of fingers on one of their hands to
* that of their opponent (addition wraps around after 5)
* - If the numbers on a hand become 5, it resets to 0
* - If one hand is empty and the other has an even number, it can be split
@razimantv
razimantv / primes.cpp
Last active October 12, 2020 02:50
Comparing prime generation the old way and the C++20 way
#include <chrono>
#include <iostream>
#include <numeric>
#include <ranges>
#include <vector>
const int N = 10000000;
int main() {
auto t1 = std::chrono::steady_clock::now();
@razimantv
razimantv / towers.cpp
Created April 9, 2020 20:04
Solution to the towers puzzle
/******************************************************************************
* File: towers.cpp
*
* Author: Raziman T V
* Created: 04/09/20
* Description: Solving the Towers puzzle
*****************************************************************************/
#include <algorithm>
#include <cassert>
@razimantv
razimantv / Randomstrip.ipynb
Created February 18, 2019 19:05
Generate random points in an angle range around a given latitude and longitude
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@razimantv
razimantv / population_evolution.cpp
Last active November 20, 2018 21:50
Dependence of population evolution on age of giving birth
#include <fstream>
#include <iostream>
#include <random>
#include <set>
#include <string>
#include <tuple>
// Birth/death events
// If birth: time, +1, 0
// If death: time, -1, birthday
@razimantv
razimantv / Pi_MC.ipynb
Created October 4, 2018 12:37
Monte Carlo estimation of Pi
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.