Skip to content

Instantly share code, notes, and snippets.

View jaideepheer's full-sized avatar
🕹️

Jaideep Singh Heer jaideepheer

🕹️
View GitHub Profile
@jaideepheer
jaideepheer / GM_Cyclic_Config.js
Last active January 17, 2022 18:05
Userscript Snippets
// ...
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// ...
class GM_Cyclic_Config {
constructor({
key,
#include <iostream>
#include <cmath>
using namespace std;
/**
* @brief Fibonacci min heap.
*/
template <typename T>
class FibbHeap
// I don't like null
#include <optional>
// For to_string()
#include <string>
#include <sstream>
template <typename T>
class SinglyLinkedList
{
private:
struct SLLNode
@jaideepheer
jaideepheer / arduinoSerialBasic.cpp
Created August 4, 2018 17:32
snailyArduinoProg.
char data = 0;
bool flip = true;
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
@jaideepheer
jaideepheer / InferenceAI.py
Created September 18, 2018 11:07
Inference AI // 01
# define knowledge base
class knowledgeBase:
class mappingIterator:
def __init__(self, key, mappings):
self.mappings = mappings
self.key = key
self.maxlevel = 0
self.curlevel = -1
self.isEmpty = not key in mappings
if self.isEmpty:
@jaideepheer
jaideepheer / snailyProg.py
Last active September 12, 2020 09:54
Write a program that repeatedly prompts a user for integer numbers untill the user enters 'done'. Once 'done' is entered print out the largest and smallest of the numbers. If user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10 and 4 and match the …
"""
Write a program that repeatedly prompts a user for integer numbers untill the user enters 'done'.
Once 'done' is entered print out the largest and smallest of the numbers.
If user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number.
Enter 7, 2, bob, 10 and 4 and match the output.
Invalid input
Maximum is 10
Minimum is 2
"""
/**
* Question found here: https://www.codechef.com/OCT18B/problems/MINDSUM
*
* You are given positive integers N and D.
* You may perform operations of the following two types:
* add D to N, i.e. change N to N+D
* change N to digitsum(N)
* Here, digitsum(x) is the sum of decimal digits of x.
* For example, digitsum(123)=1+2+3=6 and digitsum(100)=1+0+0=1.
*
T = int(input())
while(T>0):
T-=1
inp = input()
prevRange = 0
dist = 55 # max dist. (=infinity) for first robot
collision = False
# iterate through input string
for c in inp:
// Example program
#include <iostream>
#include <string>
using namespace std;
class Person
{
public:
Person(){}
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class SaltedSBox {
private final Random rand;