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
package com.wcang; | |
import java.time.Duration; | |
import java.time.Instant; | |
import java.util.List; | |
import java.util.function.Function; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
public class Main { |
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.math.max | |
fun add(left: List<Int>, right: List<Int>) : List<Int> { | |
val l = left.asReversed() | |
val r = right.asReversed() | |
val result = mutableListOf<Int>() | |
val max = max(l.size, r.size) | |
var carry = 0 | |
repeat(max) { |
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 Finally { | |
public static int tryFinally() { | |
try { | |
return 1; | |
} finally { | |
System.out.println("Finally block"); | |
} | |
} |
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
package board | |
import board.Direction.* | |
fun createSquareBoard(width: Int): SquareBoard = ConcreteSquareBoard(width) | |
fun <T> createGameBoard(width: Int): GameBoard<T> = ConcreteGameBoard(createSquareBoard(width)) | |
private fun Cell.coordinate(direction: Direction) = | |
when (direction) { |
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
open class Something<WTF>(val wtf: WTF) | |
{ | |
init { | |
println("init something") | |
} | |
} | |
interface Blargh<T> { | |
fun getArg(): T | |
} |
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
<style> | |
/* Defines a cleaner look for tables */ | |
table { border-collapse: collapse; } | |
td, th { border: 1px solid black; padding: 3px 8px; } | |
th { text-align: left; } | |
</style> | |
<script> | |
var MOUNTAINS = [ | |
{name: "Kilimanjaro", height: 5895, country: "Tanzania"}, |
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
// Your code here. | |
function Vector(x, y) { | |
this.x = x; | |
this.y = y; | |
this.plus = function(v) { | |
var res = new Vector(this.x, this.y); | |
res.x += v.x; | |
res.y += v.y; | |
return res; |
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
function deepEqual(obj1, obj2) | |
{ | |
if (obj1 === obj2) { | |
return true; | |
} | |
if (typeof(obj1) == typeof(obj2)) { | |
if (typeof(obj1) == 'object') { | |
var obj1Prop = 0; | |
var obj2Prop = 0; |
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
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <errno.h> | |
static void child_process(int fd) |
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
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <netinet/in.h> /* this is needed for struct sockaddr_in (IPv4 address) */ | |
#include <unistd.h> /* close syscall */ | |
#include <arpa/inet.h> /* for inet_ntop */ |
NewerOlder