Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5.  
  6. /**
  7. * Created by Alexander Ressl on 27.04.2018 09:21.
  8. */
  9. public class StartBits {
  10.  
  11. public static void main(String[] args) {
  12. Level1();
  13. }
  14.  
  15. public static void Level1() {
  16. int count = 999;
  17. int imageCount;
  18. int sizeX = 0;
  19.  
  20. ArrayList<Integer> sort = new ArrayList<>();
  21. boolean inImage = false;
  22. boolean imageValid = false;
  23. int puffer = 0;
  24. try (BufferedReader br = new BufferedReader(new FileReader("resources/lvl1-2.inp"))) {
  25. String line;
  26. while ((line = br.readLine()) != null) {
  27. if (count == 999) {
  28. imageCount = Integer.parseInt(line);
  29. } else {
  30. if (!inImage) {
  31. puffer = Integer.parseInt(line.split(" ")[0]);
  32. count = Integer.parseInt(line.split(" ")[1]);
  33. //System.out.println(" --- " +count);
  34. // System.out.println(count);
  35. inImage = true;
  36. }else{
  37. for(String blub : line.split(" ")){
  38. int stuff = Integer.parseInt(blub);
  39. if(stuff != 0){
  40. imageValid = true;
  41. }
  42. }
  43. //System.out.println("line " + line);
  44. //System.out.println("count " + count);
  45. if(count == 0){
  46. System.out.println("ok");
  47. if(imageValid){
  48. imageValid = false;
  49. sort.add(puffer);
  50. }
  51. inImage = false;
  52. continue;
  53. }
  54. }
  55. }
  56. count--;
  57. }
  58. } catch (Exception e) {
  59. System.out.println(e);
  60. System.out.println("no");
  61. }
  62. Collections.sort(sort);
  63. for(int test : sort){
  64. System.out.println(test);
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement