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
#!/bin/bash | |
P=$(pwd) | |
for d in $(find . -type d); do | |
cd "$P/$d" | |
for f in *.class; do | |
yes n | jad -s '.java' "$f" | |
done | |
done |
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
object Perm extends App { | |
def time[A](f: => A) = { | |
val start = System.nanoTime | |
val ret = f | |
val dt = (System.nanoTime - start) / 1e6 | |
dt | |
} | |
class Permutations[T](implicit ord: Ordering[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
// "we can not declare that function as accepting a pointer-to-pointer" (c) https://www.eskimo.com/~scs/cclass/int/sx9a.html | |
// Instead we can do this ugly thing | |
#include <stdio.h> | |
#include <stdlib.h> | |
void printStackArray(const int* const arr, const size_t n, const size_t m) | |
{ | |
size_t i, j; | |
for (i = 0; i < n; i++) |
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
// clang++ -Wall -std=c++11 primes_benchmark.cc -o primes_benchmark -O3 && ./primes_benchmark | |
#include <cassert> | |
#include <chrono> | |
#include <functional> | |
#include <iostream> | |
#include <string> | |
#include <unordered_set> | |
#include <vector> | |
#include <utility> |
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
#!/bin/bash | |
# pip2 install toml | |
# wget https://raw.githubusercontent.com/rust-lang/rust/master/src/etc/ctags.rust -O ~/.config/ctags.rust | |
SRCDIR=src | |
RUSTFLAGS="-C target-cpu=core-avx2" | |
#PROJECT="${PWD##*/}" | |
PROJECT=$(python2 -c 'import toml; print toml.loads(file("Cargo.toml").read())["package"]["name"]') |
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
// find a common area of two (probably intersected) rectangles | |
object CommonRectsArea extends App { | |
type Coord = (Int, Int) | |
class Rect(val bottomLeft: Coord, val topRight: Coord) { | |
def width: Int = topRight._1 - bottomLeft._1 | |
def height: Int = topRight._2 - bottomLeft._2 | |
def area: Int = width * height |
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
// https://leetcode.com/problems/reconstruct-itinerary/ | |
// Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the (longest) itinerary in order. | |
import scala.collection.immutable.{HashMap, HashSet} | |
object LongestAirPath extends App { | |
type Ticket = (String, String) | |
type TicketsFromMap = HashMap[String, List[String]] |
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
// find common area of given list of rectangles | |
object CommonAreaRects extends App { | |
type Coord = (Int, Int) | |
class Rect(val bottomLeft: Coord, val topRight: Coord) { | |
override def toString: String = s"Rect($bottomLeft, $topRight)" | |
def ==(other: Rect): Boolean = bottomLeft == other.bottomLeft && topRight == other.topRight |
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
def is_letter (x) | |
return x.ord >= "a".ord && x.ord <= "z".ord | |
end | |
def encrypt (text, key, n, offset) | |
encrypted_text = "" | |
text.each_char do |x| | |
if is_letter(x) | |
code = (x.ord + key - offset) % n + offset | |
encrypted_text += code.chr |
OlderNewer