WIP Day 7
Changes to be committed: new file: 2022/day07/Day07A.java new file: 2022/day07/Directory.java new file: 2022/day07/day07_algo.txt new file: 2022/day07/input.txt
This commit is contained in:
parent
7123ea76f5
commit
7fb3d31487
4 changed files with 1115 additions and 0 deletions
7
2022/day07/Day07A.java
Normal file
7
2022/day07/Day07A.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class Day07A {
|
||||||
|
|
||||||
|
}
|
51
2022/day07/Directory.java
Normal file
51
2022/day07/Directory.java
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Directory {
|
||||||
|
private String dirName;
|
||||||
|
private String parentDirName;
|
||||||
|
private ArrayList<Integer> files;
|
||||||
|
private ArrayList<Directory> subDirs;
|
||||||
|
|
||||||
|
public Directory(String name, String parent) {
|
||||||
|
this.dirName = name;
|
||||||
|
this.parentDirName = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public Directory (String name, String parent, int[] filesList, String[] dirsList){
|
||||||
|
this.dirName = name;
|
||||||
|
this.parentDirName = parent;
|
||||||
|
files.add(filesList);
|
||||||
|
subDirs.add();
|
||||||
|
} this is a really bad idea we'll leave it for later*/
|
||||||
|
|
||||||
|
public int getDirSize() {
|
||||||
|
int size = 0;
|
||||||
|
for (Directory dir : this.subDirs) {
|
||||||
|
size += dir.getDirSize();
|
||||||
|
}
|
||||||
|
for (int i : this.files) {
|
||||||
|
size += i;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDir(String s) {
|
||||||
|
this.subDirs.add(new Directory(s, this.dirName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFile(int i) {
|
||||||
|
this.files.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentDir() {
|
||||||
|
return this.parentDirName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDirName() {
|
||||||
|
return this.dirName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<> getAllSubDirs() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
38
2022/day07/day07_algo.txt
Normal file
38
2022/day07/day07_algo.txt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
It's java damnit EVERYTHING is an object
|
||||||
|
command format =
|
||||||
|
0. $
|
||||||
|
1. command string
|
||||||
|
2. argument string
|
||||||
|
|
||||||
|
file formats =
|
||||||
|
file
|
||||||
|
0. integer size
|
||||||
|
1. string name
|
||||||
|
dir
|
||||||
|
0. keyword "dir"
|
||||||
|
1. string dirName
|
||||||
|
|
||||||
|
===function Main
|
||||||
|
Create ArrayList of directory objects
|
||||||
|
Open file
|
||||||
|
Read line into buffer string array split on spaces
|
||||||
|
|
||||||
|
|
||||||
|
Loop while file has contents
|
||||||
|
|
||||||
|
Declare Class "directory"
|
||||||
|
- private string dirName
|
||||||
|
- private string parentDirName
|
||||||
|
- private ArrayList fileContents[]
|
||||||
|
- int fileSize
|
||||||
|
- private ArrayList subDirs[]
|
||||||
|
- yo mr. white we're recursin here
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
getDirSize - needs to step through subdirs, plus sum ints in file sizes
|
||||||
|
addDir - create new directory object and append to subDirs ArrayList
|
||||||
|
addFile - add to fileContents ArrayList
|
||||||
|
rmDir - remove specified dir from subDirs ArrayList - not necessary for this scope probably
|
||||||
|
getParentDir - name's on the tin
|
||||||
|
getDirName - ditto
|
||||||
|
getAllDirSizes - i mean while i'm here might as well make the class do it
|
1019
2022/day07/input.txt
Normal file
1019
2022/day07/input.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue