Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.HashMap;
- import java.util.ArrayList;
- public class BitGenerator {
- @SuppressWarnings("unchecked")
- public static void main(String[] args) {
- String bits = "";
- HashMap test = new HashMap();
- Random r = new Random();
- ArrayList a = new ArrayList();
- int n = 4;
- do {
- for(int i = 0; i < 8; i++){
- int x = 0;
- if(r.nextBoolean()) {
- x = 1;
- }
- bits += x;
- }
- if(test.containsKey(bits)) {
- bits = "";
- continue;
- }
- else {
- test.put(bits, 'a');
- a.add(bits);
- bits = "";
- }
- } while(test.size() < 256);
- for(int i = 0; i < a.size(); i++) {
- System.out.println(a.get(i));
- }
- }
- }
Add Comment
Please, Sign In to add comment