Skip to content

Instantly share code, notes, and snippets.

View rep-movsd's full-sized avatar

Vivek rep-movsd

View GitHub Profile
@rep-movsd
rep-movsd / day01_part1.cpp
Last active December 2, 2025 05:09
Advent Of Code 2025
#include <fstream>
#include <string>
#include <iostream>
#include <vector>
#include <iterator>
#include <ranges>
#include <algorithm>
using std::string, std::vector, std::plus;
using std::ifstream, std::istream_iterator, std::cout, std::endl;
@rep-movsd
rep-movsd / day01_part2.cpp
Created December 2, 2025 04:34
Advent Of Code 2025
// Exactly same code as day01_part1.cpp except this
auto rotator = [&state](int i) {
auto next = state + i % 100;
auto ret = ((state > 0 && next <= 0) || next >= 100) + abs(i) / 100;
state = (next + 100) % 100;
return ret;
};
#!/usr/bin/python3
'''
This script parses the HTML file from https://www.moneycontrol.com/stocks/marketinfo/dividends_declared/index.php and
creates a CSV file with relevant data
Sheet will contain all upcoming dividends after the current date, and those whose percentage is declared
It calculates the net percentage earning per rupee invested if you buy the stock at current price and hold it till the record date
To run this script, you need to first create:
@rep-movsd
rep-movsd / bench.cpp
Last active December 4, 2022 13:48
Benchmark code for the indexed iterator (see comments for results)
#include <algorithm>
#include <numeric>
#include <vector>
#include "benchmark/benchmark.h"
#include "buf_idx_iter.hpp"
template <typename T>
void BM_std_sort(benchmark::State& state)
{
@rep-movsd
rep-movsd / buf_idx_iter.hpp
Created December 4, 2022 13:39
A C++ iterator class that uses integer indices rather than pointers
template<typename T>
class buf_idx_iter
{
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = T;
using difference_type = std::ptrdiff_t;
using pointer = T*;
using reference = T&;
@rep-movsd
rep-movsd / gpt_iter.cpp
Last active December 4, 2022 11:49
Trying to get GPT to write an iterator class conformant with the C++ std lib
//========================================================================================================================================
// Write an template iterator class with just the tags in it
//========================================================================================================================================
template<typename T>
class iterator
{
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = T;
I am attesting that this GitHub handle rep-movsd is linked to the Tezos account tz1WdmziqzcmqdRPPg5N1NBME8NrqZAVDaGq for tzprofiles
sig:edsigtmoEDmGt45vS6Ja1KC3m9XNS4kZhaaVCkHnNkQYPnc8CcVdkgaEm65bmQgYDfdUt8Pjj7bLH8PXaBFBDLxfTkPDotKrtgu
I am attesting that this GitHub handle rep-movsd is linked to the Tezos account tz1W4jq35csgLVWHSk9fVw1DL24SnZ8ZP1ny for tzprofiles
sig:edsigtaaJH4DkB3dF1ucgApS9Qv3J1jXzPQZCP1QwkhBxoGfTHdUaFLXna7e1bpSjBGrav1Xukov2odTEQiX3i6XGQrrUmPFLJZ
#!/usr/bin/python
# Abcdexter, 7/7/2021, 1142
############################
# imports
############################
import sys
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
@rep-movsd
rep-movsd / puzzle.py
Last active May 16, 2021 10:00
Word puzzle checker
#/usr/bin/python
import sys
import json
# open grid file
with open(sys.argv[1]) as f:
lines = [line.rstrip('\n') for line in f]
# make the grid but padded on left right and bottom sides with a sentinel like this (makes it easy to grab diagonals)