The Java Program: 7-library-puzzlers/puzzle-60/OneLiners.java

  1 import java.util.*;
  2 
  3 public class OneLiners {
  4     public static void main(String[] args) {
  5         // Part A
  6         String[] breakfast = { "spam", "sausage", "spam", "spam", "bacon",
  7                                "spam", "tomato", "spam" };
  8         System.out.println(withoutDuplicates(Arrays.asList(breakfast)));
  9 
 10         // Part B
 11         String weaponry = "fear, surprise,ruthless efficiency, an almost " +
 12             "fanatical devotion to the Pope, nice red uniforms";
 13         System.out.println(Arrays.asList(parse(weaponry)));
 14 
 15         // Part C
 16         int[][] magic = {{6, 7, 2}, {1, 5, 9}, {8, 3, 4}};
 17         System.out.println(arrayToString(magic));
 18 
 19         // Part D
 20         System.out.println(hasMoreBitsSet(0x0f0f0f0f, 0x88888888)); // true
 21         System.out.println(hasMoreBitsSet(0x88888888, 0x0f0f0f0f)); // false
 22     }
 23 
 24     // Part A
 25     static <E> List<E> withoutDuplicates(List<E> original) {
 26         // Your code goes here
 27     }
 28 
 29     // Part B
 30     static String[] parse(String string) {
 31         // Your code goes here
 32     }
 33 
 34     // Part C
 35     static String arrayToString(Object[] array) {
 36         // Your code goes here
 37     }
 38 
 39     // Part D
 40     static boolean hasMoreBitsSet(int i, int j) {
 41         // Your code goes here
 42     }
 43 }