Navigation Menu

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
  • 11:21 (UTC +01:00)
  • X @razimantv
View GitHub Profile
@razimantv
razimantv / solarirradiance.cpp
Last active December 21, 2017 13:23
Compute total solar irradiance at different latitudes on different days
/* solar.cpp: Calculates the solar energy received by places at different
* latitudes over the year. It is assumed that the earth revolves around the
* sun in a circular orbit taking exactly 365 days
*
* Author: Raziman T V
*
* License:
* You may use this document for whatever purpose you desire, as long as the
* following conditions are satisfied:
* 1) You do not use it in a way that suggests that I endorse the use.
"" vimrc file
" contains settings for vim and gvim
"Vundle=========================================================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'mileszs/ack.vim'
Plugin 'vim-scripts/Conque-GDB'
@razimantv
razimantv / tmux.conf
Last active April 10, 2017 20:31
Tmux configuration
set -g default-terminal "screen-256color"
set -g update-environment "TERM_PROGRAM"
bind C-y run "tmux save-buffer - | xclip -selection clipboard"
set -g mouse on
# Toggle mouse on with ^B m
bind m \
set -g mouse on \;\
display 'Mouse: ON'
@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());
@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 / 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 / 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 / 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 / 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 / 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;