Skip to content

Instantly share code, notes, and snippets.

@siosio
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save siosio/d97371dc16f1ec26d865 to your computer and use it in GitHub Desktop.

Select an option

Save siosio/d97371dc16f1ec26d865 to your computer and use it in GitHub Desktop.

Revisions

  1. siosio renamed this gist Nov 11, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. siosio revised this gist Nov 11, 2014. 1 changed file with 15 additions and 13 deletions.
    28 changes: 15 additions & 13 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    package gist;

    import java.io.Serializable;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Random;
    @@ -9,19 +10,17 @@ import java.util.stream.Stream;

    public class BonJobi {

    public static void main(String[] args) throws Exception {
    genBonjovi();
    }
    private int count = 0;
    private static final List<String> INPUT = Arrays.asList("ジョ", "ン", "ボ", "ヴィ");

    private static void genBonjovi() throws Exception {
    private static final Random RANDOM = new Random();

    public static void main(String[] args) throws Exception {

    List<String> input = Arrays.asList("ジョ", "ン", "ボ", "ヴィ");
    Supplier<String> supplier = () -> new Random().ints(0, input.size())
    MySupplier supplier = () -> RANDOM.ints(0, INPUT.size())
    .limit(2)
    .mapToObj(input::get)
    .mapToObj(INPUT::get)
    .collect(Collectors.joining());

    String result = Stream.iterate(supplier.get(), (s) -> s + '・' + supplier.get())
    .filter(s -> s.endsWith("ジョン・ボン・ジョヴィ"))
    .findFirst()
    @@ -30,8 +29,11 @@ public class BonJobi {
    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 ̄");
    "_人人人人人人人人人人人人人人_\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 {
    }
    }
    }
  3. siosio created this gist Nov 11, 2014.
    37 changes: 37 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    package gist;

    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 {

    public static void main(String[] args) throws Exception {
    genBonjovi();
    }
    private int count = 0;

    private static void genBonjovi() throws Exception {

    List<String> input = Arrays.asList("ジョ", "ン", "ボ", "ヴィ");
    Supplier<String> supplier = () -> new 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 ̄");
    }
    }