Skip to content

Commit

Permalink
wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
s50600822 committed Nov 24, 2023
1 parent 4a0ce64 commit 47148b0
Show file tree
Hide file tree
Showing 5 changed files with 750 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import java.util.Arrays;
import java.io.*;


class Solution {
/**
Expand Down Expand Up @@ -53,5 +55,40 @@ public static void main(String[] args) {
self.productExceptSelf(new int[]{2,3,4,5}),
new int[]{60,40, 30,24}
);

int[] huge = readArrayFromFile("i.txt");


writeArrayToFile(self.productExceptSelf(huge), "huge_out.txt");
}

private static int[] readArrayFromFile(String filePath) {
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
String line = reader.readLine();
String[] elements = line.split(",");
int[] array = new int[elements.length];
for (int i = 0; i < elements.length; i++) {
array[i] = Integer.parseInt(elements[i]);
}
return array;
} catch (IOException e) {
e.printStackTrace();
return new int[0]; // Handle the error according to your needs
}
}

private static void writeArrayToFile(int[] array, String filePath) {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
for (int i = 0; i < array.length; i++) {
writer.write(String.valueOf(array[i]));

// Add a comma after each element except the last one
if (i < array.length - 1) {
writer.write(",");
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 47148b0

Please sign in to comment.