GoldMindNugget

LOL

Feb 28th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. import java.io.*;
  2. import java.nio.charset.StandardCharsets;
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5.  
  6. public class Simulator {
  7.  
  8. public static void main(String[] args) throws IOException {
  9.  
  10.  
  11. String[] inputs = {"a_example", "b_small", "c_medium", "d_big"} ;
  12.  
  13. for (String in: inputs) {
  14. Pizza pizza = new Pizza();
  15. pizza.parse(in+ ".in");
  16. pizza.calculate();
  17. pizza.print(in+".out");
  18. }
  19. }
  20. }
  21.  
  22. ////////////////
  23. class Slice{
  24. int r1, c1, r2, c2;
  25. char[][] matrix;
  26. int min;
  27.  
  28. public Slice(int r1, int c1, int r2, int c2, char matrix[][]) {
  29. this.r1 = r1;
  30. this.c1 = c1;
  31. this.r2 = r2;
  32. this.c2 = c2;
  33. this.matrix = matrix;
  34. }
  35.  
  36. boolean checkMatrix(){
  37. int rows = Math.abs(r2 - r1);
  38. int cols = Math.abs(c2 - c1);
  39. int counterT=0;
  40. int counterM=0;
  41. for(int i=0; i<rows; i++)
  42. {
  43. for(int j=0; j<cols; j++)
  44. {
  45. if(matrix[i][j] == 'T')
  46. counterT++;
  47. if(matrix[i][j] == 'M')
  48. counterM++;
  49. }
  50. }
  51. return (counterM < min || counterT < min);
  52. }
  53. }
  54.  
  55. ///////////////////
  56. import java.io.BufferedReader;
  57. import java.io.FileReader;
  58. import java.io.IOException;
  59. import java.io.PrintWriter;
  60. import java.nio.charset.StandardCharsets;
  61. import java.util.ArrayList;
  62.  
  63. class Pizza{
  64. int rows; //number of rows
  65. int cols; //number of columns
  66. int minIng; //Minimum number of ingredients that a slice must have
  67. int maxCells; //Maximum number of cells a slice can have
  68. Character [][] matrix;
  69. ArrayList<Slice> slices;
  70.  
  71.  
  72. void parse(String filename) throws IOException {
  73. int lineCount = 0;
  74. BufferedReader bufferedReader = null;
  75. slices = new ArrayList<>();
  76. try {
  77. bufferedReader = new BufferedReader(new FileReader("HashCode/Input/" + filename));
  78. String line = bufferedReader.readLine();
  79.  
  80. String[] firstLine = line.split(" ");
  81.  
  82. rows = Integer.parseInt(firstLine[0]);
  83. cols = Integer.parseInt(firstLine[1]);
  84. minIng = Integer.parseInt(firstLine[2]);
  85. maxCells = Integer.parseInt(firstLine[3]);
  86. matrix = new Character[rows][cols];
  87. for (int i=0; i<rows; i++)
  88. {
  89. line = bufferedReader.readLine();
  90. char[] currentLine = line.toCharArray();
  91. for(int j=0; j<cols; j++)
  92. {
  93. matrix[i][j] = currentLine[j];
  94. }
  95. }
  96. }
  97. catch (IOException e){
  98. e.printStackTrace();
  99. }
  100. }
  101.  
  102. void calculate(){
  103. /*
  104.  
  105. for(int i=0; i<rows; i++)
  106. {
  107. for(int j=0; j<cols; j++)
  108. {
  109. if()
  110. }
  111. }
  112. */
  113. }
  114.  
  115. void print(String filename){
  116. PrintWriter writer = null;
  117. try {
  118. writer = new PrintWriter("HashCode/Output/" + filename, StandardCharsets.UTF_8);
  119.  
  120. for(int i=0; i<rows; i++)
  121. {
  122. for(int j=0; j<cols; j++)
  123. {
  124. writer.print(matrix[i][j]+" ");
  125. }
  126. writer.print("\n");
  127. }
  128.  
  129. writer.close();
  130. } catch (IOException e) {
  131. e.printStackTrace();
  132. }
  133. //1637
  134. }
  135.  
  136. }
Add Comment
Please, Sign In to add comment