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
# top-most EditorConfig file | |
root = true | |
[*] | |
charset = utf-8 | |
end_of_line = lf | |
insert_final_newline = true | |
indent_style = space | |
tab_width=8 |
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.Arrays; | |
public class HashCodeFunctions | |
{ | |
private final static short DEFAULT_PRIME_NUMBER = 31; | |
private HashCodeFunctions() | |
{ | |
throw new AssertionError("Could not be instantiated."); | |
} |
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 fupfin; | |
import static fupfin.Tuples.*; | |
import java.util.*; | |
import java.util.concurrent.ConcurrentHashMap; | |
public class MapBuilder<K, V> { | |
private Map<K, V> map = new ConcurrentHashMap<K, V>(); |
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.List; | |
import java.util.function.Function; | |
import java.util.stream.Collectors; | |
import org.javatuples.*; | |
public class Schwartz { | |
public static <T> List<T> transform(List<T> list, Function<T, Integer>fn) { | |
return list.stream() |
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
(defn count-change-for-us [amount] (count-change amount [1 5 10 25 50])) | |
(defn count-change [amount coins] | |
(cond (= amount 0) 1 | |
(< amount 0) 0 | |
(empty? coins) 0 | |
:else (+ (count-change (- amount (first coins)) coins) | |
(count-change amount (rest coins))) | |
)) |
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 ChangeCounter { | |
int cents[] = { 50, 25, 10, 5, 1 }; | |
public int count(int amount) { | |
return count(amount, 0); | |
} | |
private int count(int amount, int idx) { | |
if (amount == 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
object MinSumCombination { | |
def findMin(nums: Array[Int]): Int = { | |
val result = tryCombinations(nums, 0) | |
if (result < Int.MaxValue) result else -1 | |
} | |
private def tryCombinations(nums: Array[Int], fixPos:Int): Int = { | |
//println((nums).mkString(",")) | |
if(fixPos >= nums.length - 1) Int.MaxValue |
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.fupfin.groovybase64 | |
import java.nio.ByteBuffer | |
class Base64 { | |
static RAW_CHUNK_SIZE = 3 | |
static ENC_CHUNK_SIZE = 4 | |
static encChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes() |
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 static java.lang.System.out; | |
import com.google.code.jyield.*; | |
public class GeneratorDemo { | |
public static void main(String args[]) { | |
for(int n: YieldUtils.toIterable(take(25, sequenceOf(integers())))) | |
out.println(n); | |
} | |
public static Generator<Integer> take(int count, Generator<Integer> source) { |
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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.springframework.samples</groupId> | |
<artifactId>myfirstspring</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<properties> | |
<!-- Generic properties --> |
NewerOlder