Skip to content

Instantly share code, notes, and snippets.

def longestSeq(array):
longestLen = 0
longestLenIndex = 0
currentLen = 0
currentIndex = 0
for i in range(len(array)):
if array[i] == 1 and array[i-1] == 0 or i == 0:
currentIndex = i
if array[i] == 1:
currentLen += 1
def longestString(inpStr):
currIndex = maxIndex = maxLen = 0
currLen = inpStr[0]
for i in range(1,len(inpStr)):
if inpStr[i] and not inpStr[i-1]:
currIndex = i
currLen = 1
if inpStr[i]:
currLen += 1
if currLen > maxLen:
#(5#%)#Skriv#metoden#new_level#som#tar#inn#en#liste#(endimensjonal#tabell),#
list,#bestående#av#15#heltall#i#tilfeldig#rekkefølge#som#vist#i#figur#3.#Metoden#skal#
returnere#en#4x4Utabell#der#tallene#i#list#er#satt#inn#fortløpende,#radvis,#fra#rad#0,#
kolonne#0,#til#rad#3,#kolonne#2.#Elementet#med#indeks#3,3#skal#ha#verdien#0.
#input: a table with 15 elements, each element is between 1 and 15, all elements are unique
def new_level(table):
a = [[] for i in range(4)]
package chess;
import chess.ChessPiece;
import chess.Color;
import chess.PiecePosition;
import java.util.Scanner;
public class GameEnginge {
static CheckBoard chessBoard = new CheckBoard();
GameEnginge () {
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 oving8.highscore;
import java.util.List;
import java.util.ArrayList;
import oving8.highscore.HighscoreListener;
import oving8.highscore.HighscoreListListener;
public class HighscoreList {
private int maxSize;
@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 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 / 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
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