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
  • 23:32 (UTC +01:00)
  • X @razimantv
View GitHub Profile
@razimantv
razimantv / battleship.cpp
Created February 25, 2018 23:19
Given the shape of a ship and the location of one cell, bomb the remaining cells in minimum attempts
#include <iostream>
#include <map>
#include <random>
#include <tuple>
#include <vector>
std::random_device rd;
std::mt19937 gen(rd());
typedef std::vector<std::string> pattern;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@razimantv
razimantv / covfefe.ipynb
Created January 5, 2018 10:51
Solving the covfefe problem
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@razimantv
razimantv / unruly.cpp
Last active July 13, 2021 08:06
Solution for the "Unruly" game from Simon Tatham's puzzle collection
#include <iostream>
#include <iterator>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
bool notblocked(const std::string& str, char c) {
int L = str.size();
if (L < 2) return true;
@razimantv
razimantv / circles.cpp
Created December 30, 2017 11:52
Convert an image into one made out of coloured circles with mean pixel values
#include <algorithm>
#include <cmath>
#include <iostream>
#include <random>
#include <string>
#include <vector>
// RGB values
// Add arithmetic operations to take means squared deviations
struct rgb {
@razimantv
razimantv / primes.py
Created December 10, 2017 21:44
Prime tree elements
primes = [2, 3, 5, 7]
parent = [-1, -1, -1, -1]
digits = [1, 3, 7, 9]
def isprime(N):
i = 2
while i * i <= N:
if N % i == 0:
return False
i += 1
@razimantv
razimantv / prisonersubset.cpp
Created November 21, 2017 18:24
Subset-based solution to the 3-prisoner number sum problem
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>
typedef std::vector<int> triplet;
// List all ways to choose K-element subsets of an N-element vector
// By abusing next_permutation
@razimantv
razimantv / BullsandCowsAI.cpp
Created April 8, 2017 21:28
AI for the "Bulls and Cows" game
#include <algorithm>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <vector>
std::string all = "0123456789";
std::random_device rd;
std::mt19937 gen(rd());
@razimantv
razimantv / signpost.cpp
Last active March 22, 2017 17:28
Signpost solver
/* Signpost solver
* Author: Raziman T V
*
* (Game can be found at
* http://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/signpost.html)
*
* Board is to be input as
* H W
* v_i dir_i
* where v_i is the value of ith cell (0 for unknown)
@razimantv
razimantv / circlewallpapergen.cpp
Last active January 24, 2016 07:00
Generate a wallpaper from random non-intersecting circles
#include <cmath>
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;
random_device rd;
mt19937_64 gen(rd());