Skip to content

Instantly share code, notes, and snippets.

import math
from math import cos, sin
#### DEFINE THE mass, length and gravitational constant #####
#playing around with the gravity constant and mass ratios might cause a resonant system, which is pretty cool
m1,m2 = 2,1
L1,L2 = 1,2
g = 9.81
########
@kvalv
kvalv / .py
Created October 30, 2015 12:37
def parse_command():
from sys import stdin as f
n_tests = int(f.readline().strip())
test_num = 0
while test_num < n_tests:
n_cities = int(f.readline().strip())
cities = [int(x) for x in f.readline().strip().split()]
W = []
for _ in range(n_cities):
line = [float("inf") if int(x) == -1 else int(x) for x in f.readline().strip().split()]
def parse_command():
from sys import stdin as f
n_tests = int(f.readline().strip())
test_num = 0
while test_num < n_tests:
n_cities = int(f.readline().strip())
cities = [int(x) for x in f.readline().strip().split()]
W = []
for _ in range(n_cities):
line = [float("inf") if int(x) == -1 else int(x) for x in f.readline().strip().split()]
from sys import stdin, stderr
import traceback
adj_mx = [[0,1,1,0,0,0],[0,0,0,1,0,0],[0,0,0,1,1,0],[0,0,0,0,0,1],[0,1,0,1,0,1],[0,0,0,1,0,0]]
class Node():
def __init__(self, num):
self.points_to = []
self.num = num
self.d = 0
@kvalv
kvalv / oving.py
Created September 22, 2015 16:32
from sys import stdin, stderr
import traceback
adj_mx = [[0,1,1,0,0,0],[0,0,0,1,0,0],[0,0,0,1,1,0],[0,0,0,0,0,1],[0,1,0,1,0,1],[0,0,0,1,0,0]]
class Node():
def __init__(self, num):
self.points_to = []
self.num = num
self.d = 0
package oving5.person;
import java.util.Iterator;
import java.util.function.BinaryOperator;
import java.lang.Double;
public class BinaryComputingIterator implements Iterator<Double>{
private Iterator<Double> firstIterator;
private Iterator<Double> secondIterator;
private BinaryOperator<Double> binaryOperator;
@kvalv
kvalv / ny
Last active August 29, 2015 14:17
void run () throws NumberFormatException{
Scanner scan = new Scanner(System.in);
scan.useDelimiter("[0-9]+");
while ( true ) {
try {
String inputLine = scan.nextLine();
int parseInt = Integer.parseInt(inputLine);
System.out.println("input was: " + Integer.toString(parseInt));
} catch (NumberFormatException e) {
System.out.println( e.toString() );
package oving8.highscore;
import java.util.List;
import java.util.ArrayList;
import oving8.highscore.HighscoreListener;
import oving8.highscore.HighscoreListListener;
public class HighscoreList {
private int maxSize;
package oving7.sudoku;
import java.util.Scanner;
import java.util.Random;
import java.util.Stack;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import oving7.sudoku.Board;
package chess;
import chess.ChessPiece;
import chess.Color;
import chess.PiecePosition;
import java.util.Scanner;
public class GameEnginge {
static CheckBoard chessBoard = new CheckBoard();
GameEnginge () {