Advertisement
DulcetAirman

encodeArray

Sep 24th, 2015
123
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   public static int[] encodeArray(final int i) {
  2.     return Integer.toString(i).chars().map(x -> x - '0').flatMap(digit -> {
  3.       if (digit < 0) return IntStream.of(-1); // sign: '-'
  4.       final Builder builder = IntStream.builder();
  5.       for (int x = 0; x < digit; x++) builder.accept(0);
  6.       builder.accept(1);
  7.       return builder.build();
  8.     }).toArray();
  9.   }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement