This file contains 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
public class ReverseLinkedList { | |
static class Node { | |
int value; | |
Node next; | |
Node(int value, Node next) { | |
this.value = value; | |
this.next = next; | |
} | |
@Override public String toString() { |
This file contains 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 kotlin.contracts.ExperimentalContracts | |
import kotlin.contracts.InvocationKind | |
import kotlin.contracts.contract | |
class Foo { | |
fun foo() {} | |
} | |
@ExperimentalContracts | |
inline fun Foo.bar(block: Foo.() -> Unit) { |
This file contains 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.Stack | |
fun parse(s: String): MutableList<Any> { | |
val stack = Stack<MutableList<Any>>() | |
stack.add(mutableListOf()) | |
var i = 0 | |
while (i < s.length) { | |
val ch = s[i] | |
when (ch) { | |
'[' -> stack.push(mutableListOf()) |
This file contains 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.math.BigInteger; | |
public class LucasTest { | |
public static void main(String[] args) { | |
int p = 521; | |
System.out.println(lucas(p - 1, BigInteger.valueOf(2).pow(p).subtract(BigInteger.ONE))); | |
} | |
static BigInteger lucas(int n, BigInteger mod) { | |
return lucasIter(BigInteger.valueOf(4), n, mod); |
This file contains 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.lang.IllegalStateException | |
class MyLinkedList : Iterable<Any> { | |
var head: Node = Node(Any()) | |
fun add(value: Any) { | |
var n: Node = head | |
while (n.next != null) { | |
n = n.next!! | |
} |
This file contains 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.io.ByteArrayOutputStream | |
@ExperimentalUnsignedTypes | |
inline class Unicode(val point: Int) | |
@ExperimentalUnsignedTypes | |
object UTF8Encoder { | |
fun encode(unicodes: Array<Unicode>): ByteArray { | |
val array = ByteArrayOutputStream() | |
for (code in unicodes) { |
This file contains 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
class DrawSpiral { | |
public static void main(String[] args) { | |
int size = 15; | |
double cx = size / 2.d; | |
double cy = size / 2.d; | |
double tmax = 6 * Math.PI; | |
double a = size / 2.d / tmax; | |
boolean[][] res = new boolean[size][size]; |
This file contains 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.ArrayList; | |
import java.util.Arrays; | |
import java.util.Comparator; | |
import java.util.List; | |
class Covered { | |
public static void main(String[] args) { | |
final int[][] input = new int[][] { | |
{1, 5}, {2, 8}, {9, 10}, {10, 15}, {3, 6}, {18, 20} | |
}; |
This file contains 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 sys | |
import time | |
from os import environ | |
import elasticsearch | |
import twitter | |
def sanitise_place(place): | |
if place is None or 'bounding_box' not in place or place['bounding_box']['type'] != 'Polygon': |
This file contains 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": { | |
"cluster":"test_cluster" | |
}, | |
"jobs": [ | |
{ | |
"job_id": "job1", | |
"concurrency": 1, | |
"driver": "queries", | |
"cycle_operations": true, |