This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
/** | |
* A class that simulates a Tic-Tac-Toe game. | |
* | |
* @author Noble Mushtak | |
* @version 1.1 (8 Oct 2016) | |
*/ | |
public class TicTacToe | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
/** | |
* Description | |
* | |
* @author Noble Mushtak | |
* @version 1.0 (DATE) | |
*/ | |
public class Template { | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |