Skip to content

Instantly share code, notes, and snippets.

View kozake's full-sized avatar

Shinichi Kozake kozake

View GitHub Profile
@kozake
kozake / caesarCipher.js
Created April 27, 2019 22:40
シーザー暗号
if (process.argv.length < 4) {
console.log('usage: node caesarCipher [cipherText] [key(number)]');
return;
}
const cipherText = process.argv[2];
const key = parseInt(process.argv[3]);
const charCodeA = 'a'.charCodeAt(0);
const plainText = cipherText
@kozake
kozake / gist:df659e28c135a3de2fb8
Last active August 29, 2015 14:23
mapOfItemsToSuppliersByStream
static class Tuple<F, S> {
private F first;
private S second;
public static <F, S> Tuple<F, S> pair(F f, S s) {
return new Tuple<F, S>(f, s);
}
private Tuple(F first, S second) {
this.first = first;
@kozake
kozake / gist:0f7b50617fb5f17351d9
Last active August 29, 2015 14:23
mapOfItemsToSuppliersByGSCollections
@Test
public void mapOfItemsToSuppliersByGSCollections()
{
final MutableMultimap<String, Supplier> itemsToSuppliers =
ArrayAdapter.adapt(this.company.getSuppliers())
.groupByEach(s -> ArrayAdapter.adapt(s.getItemNames()));
Verify.assertIterableSize(
"should be 2 suppliers for sofa",
2,
@kozake
kozake / gist:d937137057fca5329b6c
Last active August 29, 2015 14:23
mapOfItemsToSuppliers
@Test
public void mapOfItemsToSuppliers()
{
final MutableMap<String, List<Supplier>> itemsToSuppliers
= UnifiedMap.newMap();
for (Supplier supplier : this.company.getSuppliers())
{
for (String itemName : supplier.getItemNames())
{
@kozake
kozake / Main.kt
Last active August 29, 2015 14:11
Kotlin Advent Calendar 2014 のソース(Main)
package syobochim.kotlin
import java.math.BigDecimal
import kotlin.math.*
inline val String.bd : BigDecimal get() = BigDecimal(this)
data class 可能性<T> (val 選択肢 : T, val 確率 : BigDecimal)
enum class しょぼちむ {
@kozake
kozake / Main.java
Last active August 29, 2015 14:10
しょぼちむ Advent Calendar 2014 のソース(Main)
package syobochim;
import java.util.Map;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
Map m = しょぼちむ.とは()
.flatMap(支払い::どうする)
@kozake
kozake / おこづかい.java
Last active August 29, 2015 14:10
しょぼちむ Advent Calendar 2014 のソース(おこづかい)
package syobochim;
import java.math.BigDecimal;
import java.util.stream.Stream;
public enum おこづかい {
金欠("金欠だ~ヽ(;▽;)ノ"),
金ならあるんだ("金ならあるんだ!!(((o(*゚▽゚*)o)))")
;
@kozake
kozake / 支払い.java
Last active August 29, 2015 14:10
しょぼちむ Advent Calendar 2014 のソース(支払い)
package syobochim;
import java.math.BigDecimal;
import java.util.stream.Stream;
public enum 支払い {
おごるよ, ごちになります, 割り勘;
public static Stream<可能性<支払い>> どうする(
@kozake
kozake / しょぼちむ.java
Last active August 29, 2015 14:10
しょぼちむ Advent Calendar 2014 のソース(しょぼちむ)
package syobochim;
import java.math.BigDecimal;
import java.util.stream.Stream;
public enum しょぼちむ {
バイトの女の子, ようおっさん, 二年目女子SE, おまえ誰だ, まじレッドキング;
public static Stream<可能性<しょぼちむ>> とは() {
@kozake
kozake / 可能性.java
Last active August 29, 2015 14:10
しょぼちむ Advent Calendar 2014 のソース(可能性)
package syobochim;
import java.math.BigDecimal;
public final class 可能性<T> {
public final T 選択肢;
public final BigDecimal 確率;
private 可能性(final T 選択肢, final BigDecimal 確率) {