Skip to content

Instantly share code, notes, and snippets.

View tmathmeyer's full-sized avatar
🤧
Achoo

Ted tmathmeyer

🤧
Achoo
  • Google
  • kirkland
View GitHub Profile
each.rankings.map(function(each){
return each.rank
}).reduce(+));
#include <iostream>
using namespace std;
class BankEvent
{
private:
int time;
public:
int getTime()
{
@tmathmeyer
tmathmeyer / gist:6020921
Created July 17, 2013 14:15
super logarithm
long long log_epic(long long a)
{ // takes the log base 2 of a in log(log(a)) time
long temp = a;
int low = 0;
int high = 0;
int shift = 32;
while(shift > 0)
{
while(temp > 0)
{
@tmathmeyer
tmathmeyer / gist:6005040
Last active December 19, 2015 19:18
fast exponentiation (properly tabbed)
#include <iostream>
using namespace std;
long long log_epic(long long a)
{
long temp = a;
int low = 0;
int high = 0;
int shift = 32;
@tmathmeyer
tmathmeyer / gist:5906491
Created July 2, 2013 02:59
lksfjdaghkadjga
public class SudokuData
{
int[][] values = new int[9][9];
public JTextField[][] convertToJTF()
{
//you implement this, it's REALLY easy
}
@tmathmeyer
tmathmeyer / gist:5906083
Last active December 19, 2015 05:39
lol omesh
public class RPSGame extends JFrame implements ActionListener
{
int wins = 0;
int ties = 0;
int total = 0;
JPanel scores;
public RPSGame(String title)
{
@tmathmeyer
tmathmeyer / gist:5893974
Last active December 19, 2015 03:59
fermat's theorem (doesnt work on numbers less than three), but checks all primes in O((log(n)^2)
boolean isPrime(long n)
{//fermats :D
if (n%2==0 || n%3==0)
{
return false;
}
boolean res = true;
for (long a = 2; a<n; a*=2)
{
res = res&&exp_mod_itr(a,n,n)==a;
package edu.wpi.tmathmeyer.euler;
public class Probs {
public static void problem30(){
int[] fives = new int[10];
for(int i = 0; i < 10; i++)
{
fives[i] = pow(i, 5);
System.out.println(fives[i]);
}
@tmathmeyer
tmathmeyer / gist:5884634
Last active December 19, 2015 02:39
works, but takes abt 7 days
package edu.wpi.tmathmeyer.euler;
public class Problem433 {
int[][] mem = new int[50000][];
int size = 500000;
public static void main(String[] args){
new Problem433().problem();
}
/*******************************************************************************
* Copyright (c) 2013 Ted Meyer.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ted Meyer - being a generally kickass person
******************************************************************************/