Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gΓ³ra standardowo
- File plik = new File("instrukcje.txt");
- Scanner scan = new Scanner(plik);
- List<String> instructions = new ArrayList<>();
- List<Character> letters = new ArrayList<>();
- String command;
- char character;
- int counter = 0;
- Map<Integer, String> instructionsInRow = new HashMap<>();
- while (scan.hasNext()) {
- command = scan.next();
- instructions.add(command);
- character = scan.next().charAt(0);
- letters.add(character);
- }
- for (int i = 1; i < instructions.size(); i++) {
- if ((instructions.get(i-1)).equals(instructions.get(i))) {
- counter++;
- i++;
- while ((instructions.get(i-1)).equals(instructions.get(i))) {
- if ((instructions.get(i)).equals(instructions.get(i+1))) {
- instructionsInRow.put(counter, instructions.get(i));
- counter = 0;
- break;
- }
- counter++;
- i++;
- }
- }
- }
- System.out.println(instructionsInRow.get(60));
- Set<Integer> keys = instructionsInRow.keySet();
- for (Integer key : keys) {
- System.out.println(key);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement