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 / 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 / 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 / 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 / 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 / Template.java
Last active October 30, 2016 14:34
APCS Template.java
import java.util.*;
/**
* Description
*
* @author Noble Mushtak
* @version 1.0 (DATE)
*/
public class Template {
/**
@Noble-Mushtak
Noble-Mushtak / record.c
Created October 11, 2016 21:59
How to Convert Record ID into Record Side and Record Number -- https://github.com/retepsmada/Rockola477Arduino
#include <stdio.h>
#include <stdlib.h>
//This is a datatype that can be either "A" or "B".
enum side { A, B };
typedef enum side side;
//This is a datatype representing a record.
//It has both a side and a record number.
typedef struct {
side side;
@Noble-Mushtak
Noble-Mushtak / Expression.java
Created October 6, 2016 15:53
APCS Unit 3 Design a Class Project
/**
* A class that models mathematical expressions.
*
* @author Noble H. Mushtak
* @version 1.0 (6 Oct 2016)
*/
public class Expression
{
/**
* These are the five operations allowed in our expressions.
def implies(x, y):
'''Tells us if x --> y'''
return ((not x) or y)
def digits(num, base=10):
'''Converts num to an array containing its digits from base specified'''
if num < base: return [num]
return digits((num-(num % base))//base, base)+[num % base]
# Answer for part d
@Noble-Mushtak
Noble-Mushtak / test.py
Created April 18, 2016 23:31
Does a prime h^2+1 divide (2p)^2+1 for all prime p?
from math import sqrt
max = 800000
smallest_prime_factor = []
for num in range(max): smallest_prime_factor.append(0)
for num in range(2, max):
if smallest_prime_factor[num] == 0:
smallest_prime_factor[num] = num
for num2 in range(max//num):
if smallest_prime_factor[num*num2] == 0:
@Noble-Mushtak
Noble-Mushtak / Calculator.lua
Last active April 8, 2024 16:56
Simple Calculator for Lua
function characterPresent(stringParam, character)
--[[
This function returns true if and only if character is in stringParam.
]]--
--Loop through stringParam:
for i=1, #stringParam do
--If the current character is character, return true.
if stringParam:sub(i, i) == character then return true end
end
--If we go through the whole string without returning true, we get to this point.