Skip to content

Instantly share code, notes, and snippets.

View Noble-Mushtak's full-sized avatar

Noble Mushtak Noble-Mushtak

View GitHub Profile
@Noble-Mushtak
Noble-Mushtak / TicTacToe.java
Created October 23, 2016 22:14
APCS Unit 3 Design a Class Project
import java.util.*;
/**
* A class that simulates a Tic-Tac-Toe game.
*
* @author Noble Mushtak
* @version 1.1 (8 Oct 2016)
*/
public class TicTacToe
{
@Noble-Mushtak
Noble-Mushtak / EasyInput.java
Last active November 5, 2016 19:08
Java container for Scanner
import java.util.*;
/**
* A class that makes input for numbers and booleans easier.
*
* @author Noble Mushtak
* @version 1.1 (3 Nov 2016)
*/
public class EasyInput {
/**
@Noble-Mushtak
Noble-Mushtak / maml-sorting.js
Created January 30, 2017 23:01
Sorts Scores of MAML Students
//Run in JavaScript console on maml.net/indv.htm
//Then, run sortStudents(n) where n is the number of the meet, i.e. sortStudents(1), sortStudents(2), ... sortStudents(5)
//Run sortStudents(6) to get back to original sorting.
//Get the table body:
var tableBody = document.querySelector("tbody");
//Get the rows from the table of students:
var scoreRows = tableBody.children;
//Get the true rows, not including the header:
var trueRows = Array.prototype.slice.call(scoreRows, 1, scoreRows.length);
@Noble-Mushtak
Noble-Mushtak / isValidSudoku.cpp
Created May 14, 2017 16:44
Checks if a 9x9 array is a valid sudoku board
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
bool isValidSudoku(int board[9][9]) {
//board[i][j] represents ith row, jth column
//goodBoard[i][j][k][l] represents ith group of 3 rows, jth row in that group, kth group of 3 columns, lth column in that group
//goodBoard[i][j][k][l] == board[3*i+j][3*k+l];
int (*goodBoard)[3][3][3] = (int (*)[3][3][3])board;
@Noble-Mushtak
Noble-Mushtak / .gitignore
Last active June 21, 2017 22:18
Qt Widgets Application for Four-Function Calculator
calculator.pro.user
% Finds min between two numbers.
min_nums(X,Y,X) :- X =< Y.
min_nums(X,Y,Y) :- Y =< X.
% Finds min of list.
% Obviously, if there's only one item, then that's the minimum.
min([Item|[]],Item).
% If there's more than one item, find the minimum of the tail,
% then take the minimum of the tail's minimum and the head element.
min([Head|Tail],Min) :-
from math import pi, sqrt, atan2, asin
def count_collisions(ratio):
masses = [1, ratio]
vels = [0, -1]
collisions = 0
angles = []
while vels[0] < 0 or vels[1] < vels[0]:
collisions += 1
@Noble-Mushtak
Noble-Mushtak / mouse_keys_simulator.c
Last active August 5, 2019 15:05
Emulates Mouse Keys and uses 0/period on numpad to slow/speed up mouse movements
//Based off https://gist.github.com/matthewaveryusa/a721aad80ae89a5c69f7c964fa20fec1 and https://www.kernel.org/doc/html/latest/input/uinput.html
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
@Noble-Mushtak
Noble-Mushtak / Markov.hs
Last active July 30, 2019 23:29 — forked from atcol/Markov.hs
Fixed bugs in simple tri-state Markov Chain generator
#!/usr/bin/env stack
-- stack --resolver lts-13.30 script --package random
import Control.Monad (foldM)
import Data.List (elemIndex, minimumBy)
import Data.Maybe (fromMaybe)
import Debug.Trace (trace)
import System.IO (getLine)
import System.Random (randomIO, randomRIO)
@Noble-Mushtak
Noble-Mushtak / ackermann.py
Last active December 2, 2019 14:28
Iterative Implementation of Ackermann Function
import unittest
UNKNOWN = None
def ackermann(m, n):
last_answer = None
stack = []
stack.append((m, n))
while len(stack) > 0: