Last active
August 29, 2015 14:09
-
-
Save siosio/d97371dc16f1ec26d865 to your computer and use it in GitHub Desktop.
こっちかな
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 gist; | |
import java.io.Serializable; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.function.Supplier; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
public class BonJobi { | |
private static final List<String> INPUT = Arrays.asList("ジョ", "ン", "ボ", "ヴィ"); | |
private static final Random RANDOM = new Random(); | |
public static void main(String[] args) throws Exception { | |
MySupplier supplier = () -> RANDOM.ints(0, INPUT.size()) | |
.limit(2) | |
.mapToObj(INPUT::get) | |
.collect(Collectors.joining()); | |
String result = Stream.iterate(supplier.get(), (s) -> s + '・' + supplier.get()) | |
.filter(s -> s.endsWith("ジョン・ボン・ジョヴィ")) | |
.findFirst() | |
.get(); | |
System.out.println(result); | |
System.out.println(result.split("・").length + " Bon Jovis"); | |
System.out.println("\n" + | |
"_人人人人人人人人人人人人人人_\n" + | |
"> You Give Love a Bad Name <\n" + | |
" ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄"); | |
} | |
interface MySupplier extends Supplier<String>, Serializable { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment