Skip to content

Instantly share code, notes, and snippets.

View chmllr's full-sized avatar

Christian Müller chmllr

View GitHub Profile
public class Solution {
interface Operation {public int op(int a, int b);}
class Add implements Operation{public int op(int a, int b){return a+b;}}
class Sub implements Operation{public int op(int b, int a){return a-b;}}
class Mul implements Operation{public int op(int a, int b){return a*b;}}
class Div implements Operation{public int op(int b, int a){return a/b;}}
public Operation getOp(String t) {
switch(t){
case "+": return new Add();
case "-": return new Sub();
### Keybase proof
I hereby claim:
* I am chmllr on github.
* I am mllr (https://keybase.io/mllr) on keybase.
* I have a public key whose fingerprint is AB1C D595 F657 ED01 E94D 9B83 F1F6 360E EA40 67EF
To claim this, I am signing this object:
var combinationSum = function (candidates, target) {
candidates.sort(function (a, b) { return a - b });
var C = {};
var f = function (n) {
if (n in C) return C[n];
var result = [];
if (n > 0)
candidates.forEach(function (cand) {
if (n == cand) result.push([cand]);
else f(n - cand).forEach(function (comb) {
var containsNearbyAlmostDuplicate = function (nums, k, t) {
if (k < 1 || t < 0 || nums.length < 2) return false;
var B = {}, MIN = -1 * 2147483648;
for (var i = 0; i < nums.length; ++i) {
var N = nums[i] - MIN;
var bucket = Math.floor(N / t);
var list = B[bucket] || [];
var cands = list.concat(B[bucket - 1] || [], B[bucket + 1] || []);
for (var i = 0; i < cands.length; ++i) {
var x = cands[i];
var containsNearbyAlmostDuplicate = function (nums, k, t) {
if (k < 1 || t < 0 || nums.length < 2) return false;
var B = {}, MIN = -1 * 2147483648;
for (var i = 0; i < nums.length; ++i) {
var N = nums[i] - MIN;
var bucket = Math.floor(N / (t+1));
if (bucket in B ||
(bucket - 1) in B && Math.abs(B[bucket - 1] - N) <= t ||
(bucket + 1) in B && Math.abs(B[bucket + 1] - N) <= t)
return true;
var numbers = readLine.split(" ").map(_.toInt).toList.sorted
numbers = numbers.distinct ++ (numbers diff numbers.distinct)
def solve(acc: Int, list: List[Int]):Int = list match{
case (h::Nil) => acc
case (h::t) => if (h+1 == t.head) solve(acc,t) else solve(acc+1,h+1::t.slice(0,t.size-1))
}
println(solve(0,numbers))
var n = readline();
var houses = readline().split(" ");
var max = -1, L = houses.length, result = new Array(n);
for (var i = L-1; i>=0; --i) {
var T = houses[i];
result[i] = T > max ? 0 : max - T + 1;
max = Math.max(T, max);
}
; for i > 2
(defn prime? [i]
(not (some
#(= 0 (mod i %))
(cons 2 (range 3 (inc (Math/sqrt i)) 2)))))
<html>
<body>
<div id="box1">1</div>
<div id="box2">2</div>
<div id="box3">3</div>
<div id="box4">4</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
type="text/javascript"></script>
<script>
for (var i = 1; i < 5; i++) {
@chmllr
chmllr / Haiku.clj
Last active December 15, 2015 04:19
(defn wlk
[nodelist [tag attrs & nodes]]
(if (= (:class attrs) "r")
(conj nodelist (:href (second (first nodes))))
(reduce wlk nodelist (filter coll? nodes))))