Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.util.ArrayList;
- import java.util.Collections;
- /**
- * Created by Alexander Ressl on 27.04.2018 09:21.
- */
- public class StartBits {
- public static void main(String[] args) {
- Level1();
- }
- public static void Level1() {
- int count = 999;
- int imageCount;
- int sizeX = 0;
- ArrayList<Integer> sort = new ArrayList<>();
- boolean inImage = false;
- boolean imageValid = false;
- int puffer = 0;
- try (BufferedReader br = new BufferedReader(new FileReader("resources/lvl1-2.inp"))) {
- String line;
- while ((line = br.readLine()) != null) {
- if (count == 999) {
- imageCount = Integer.parseInt(line);
- } else {
- if (!inImage) {
- puffer = Integer.parseInt(line.split(" ")[0]);
- count = Integer.parseInt(line.split(" ")[1]);
- //System.out.println(" --- " +count);
- // System.out.println(count);
- inImage = true;
- }else{
- for(String blub : line.split(" ")){
- int stuff = Integer.parseInt(blub);
- if(stuff != 0){
- imageValid = true;
- }
- }
- //System.out.println("line " + line);
- //System.out.println("count " + count);
- if(count == 0){
- System.out.println("ok");
- if(imageValid){
- imageValid = false;
- sort.add(puffer);
- }
- inImage = false;
- continue;
- }
- }
- }
- count--;
- }
- } catch (Exception e) {
- System.out.println(e);
- System.out.println("no");
- }
- Collections.sort(sort);
- for(int test : sort){
- System.out.println(test);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement