Skip to content

Instantly share code, notes, and snippets.

View sandeshbhusal's full-sized avatar
💭
Learning

Sandesh Bhusal sandeshbhusal

💭
Learning
View GitHub Profile
#include <cstring>
#include <iostream>
using namespace std;
int main(){
string s;
string t;
s = "ABBCADEEFAHASGFASFASJJJEF";
t = "SFASJJ";
// Naive String matching algorithm.
@sandeshbhusal
sandeshbhusal / boyermoore.cpp
Created February 11, 2019 14:38
Demonstration of Boyer Moore Algorithm for string matching.
#include <iostream>
#include <cstring>
#include <fstream>
#include <map>
int main(void){
std::string text;
std::string pattern;
// Read the text from the file.
@sandeshbhusal
sandeshbhusal / bwt.cpp
Created February 18, 2019 07:36
Burrows Wheeler Transformation
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
bool sortFunction(std::string s1, std::string s2){
if(s1[0] < s2[0]) return true;
if(s2[0] < s1[0]) return false;
int i = 0;
int min = s1.size() < s2.size() ? s1.size() : s2.size();
@sandeshbhusal
sandeshbhusal / Reverse BWT.cpp
Created February 18, 2019 07:38
Reverse Burrows Wheeler Transformation
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
bool sortFunction(std::string s1, std::string s2){
if(s1[0] < s2[0]) return true;
if(s2[0] < s1[0]) return false;
int i = 0;
int min = s1.size() < s2.size() ? s1.size() : s2.size();
import numpy as np
import pandas as pd
from scipy.ndimage.interpolation import shift
import cv2
from matplotlib import pyplot as plt
input_photo_path = "/kaggle/input/84474892_2612930752149692_1911641796866211840_o.jpg"
// Author : Sandesh Bhusal
// Date Feb 23, 2021
// You may copy, download and modify the source code according to your requirements :)
// Happy Spoofing!
// Original Code Lives at https://gist.github.com/sandeshbhusal/c8fa09546ffc076e5103456dd4e3742d
package main
import (
"flag"
// Author : Sandesh Bhusal
// Date Feb 23, 2021
// You may copy, download and modify the source code according to your requirements :)
// Happy Spoofing!
// Original Code Lives at https://gist.github.com/sandeshbhusal/c8fa09546ffc076e5103456dd4e3742d
package main
import (
"flag"
@sandeshbhusal
sandeshbhusal / ADC_2020_2_1.rs
Created August 15, 2021 14:08
Advent of Code 2020 Problem 2 Solution #1 RUST Solution
use scan_fmt::{scan_fmt};
use std::{fs::File, io:: {BufRead, BufReader}};
fn main(){
let file_path : String = String::from("src/input.txt");
let bufreader = BufReader::new(File::open(file_path).expect("Could not open file"));
let correct_passwords = bufreader.lines().map(|_line| {
match scan_fmt!(&_line.unwrap(), "{}-{} {}: {}" , i32, i32, char, String) {
Ok((a, b, c, d)) => {
if a <= d.chars().map(|k| { if c == k {1} else {0} } ).sum::<i32>() && b>= d.chars().map(|k| { if c == k {1} else {0} } ).sum::<i32>() {
1
@sandeshbhusal
sandeshbhusal / gridworld.py
Created October 23, 2023 03:26
A simple implementation of gridworld. There is a certain modification - stepping into state '9' gets a +3 reward, and every action from state '9' goes to state '3'. This can be changed in the transition map as required.
from typing import *
class State(object):
'''
Terminal states do not change their values
'''
def __init__(self, id: int, value: int, transitions: List[int], is_terminal: bool) -> None:
self.id = id
self.value = value
self.transitions = transitions
@sandeshbhusal
sandeshbhusal / gridworld_final.py
Created December 11, 2023 20:13
Gridworld final exam
grid = [[-1] * 5 for i in range(0, 4)]
grid[0][2] = -100000
grid[0][4] = 1000
grid[1][2] = -100000
grid[3][3] = -100
final_states = [
(0, 2),
(0, 4),