Guest User

Untitled

a guest
Jan 6th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.HashMap;
  3. import java.util.ArrayList;
  4.  
  5. public class BitGenerator {
  6.  
  7. @SuppressWarnings("unchecked")
  8. public static void main(String[] args) {
  9. String bits = "";
  10. HashMap test = new HashMap();
  11. Random r = new Random();
  12. ArrayList a = new ArrayList();
  13. int n = 4;
  14. do {
  15. for(int i = 0; i < 8; i++){
  16. int x = 0;
  17. if(r.nextBoolean()) {
  18. x = 1;
  19. }
  20. bits += x;
  21. }
  22. if(test.containsKey(bits)) {
  23. bits = "";
  24. continue;
  25. }
  26. else {
  27. test.put(bits, 'a');
  28. a.add(bits);
  29. bits = "";
  30. }
  31. } while(test.size() < 256);
  32.  
  33. for(int i = 0; i < a.size(); i++) {
  34. System.out.println(a.get(i));
  35. }
  36. }
  37. }
Add Comment
Please, Sign In to add comment