Browse Source

add project template for ccc oct/2023

master
Andy 2 years ago
parent
commit
7825c25b84
  1. 3
      .idea/.gitignore
  2. 9
      .idea/ccc-2023.iml
  3. 6
      .idea/jpa-buddy.xml
  4. 9
      .idea/misc.xml
  5. 8
      .idea/modules.xml
  6. 6
      .idea/vcs.xml
  7. 38
      CloudflightCodingContest/.gitignore
  8. 3
      CloudflightCodingContest/.idea/.gitignore
  9. 7
      CloudflightCodingContest/.idea/encodings.xml
  10. 6
      CloudflightCodingContest/.idea/jpa-buddy.xml
  11. 16
      CloudflightCodingContest/.idea/misc.xml
  12. 124
      CloudflightCodingContest/.idea/uiDesigner.xml
  13. 6
      CloudflightCodingContest/.idea/vcs.xml
  14. 180
      CloudflightCodingContest/files/level1/chat_gpt_prompt_for_level1.txt
  15. BIN
      CloudflightCodingContest/files/level1/level1.pdf
  16. 7
      CloudflightCodingContest/files/level1/level1_0.in
  17. 1
      CloudflightCodingContest/files/level1/level1_0.out
  18. 1
      CloudflightCodingContest/files/level1/level1_0.sol
  19. 12
      CloudflightCodingContest/files/level1/level1_1.in
  20. 1
      CloudflightCodingContest/files/level1/level1_1.out
  21. 1
      CloudflightCodingContest/files/level1/level1_1.sol
  22. 27
      CloudflightCodingContest/files/level1/level1_2.in
  23. 1
      CloudflightCodingContest/files/level1/level1_2.out
  24. 1
      CloudflightCodingContest/files/level1/level1_2.sol
  25. 42
      CloudflightCodingContest/files/level1/level1_3.in
  26. 1
      CloudflightCodingContest/files/level1/level1_3.out
  27. 1
      CloudflightCodingContest/files/level1/level1_3.sol
  28. 62
      CloudflightCodingContest/files/level1/level1_4.in
  29. 1
      CloudflightCodingContest/files/level1/level1_4.out
  30. 1
      CloudflightCodingContest/files/level1/level1_4.sol
  31. 112
      CloudflightCodingContest/files/level1/level1_5.in
  32. 1
      CloudflightCodingContest/files/level1/level1_5.out
  33. 1
      CloudflightCodingContest/files/level1/level1_5.sol
  34. 242
      CloudflightCodingContest/files/level1/level1_6.in
  35. 1
      CloudflightCodingContest/files/level1/level1_6.out
  36. 1
      CloudflightCodingContest/files/level1/level1_6.sol
  37. BIN
      CloudflightCodingContest/files/level2/level2.pdf
  38. 12
      CloudflightCodingContest/files/level2/level2_0.in
  39. 1
      CloudflightCodingContest/files/level2/level2_0.out
  40. 1
      CloudflightCodingContest/files/level2/level2_0.sol
  41. 12
      CloudflightCodingContest/files/level2/level2_1.in
  42. 1
      CloudflightCodingContest/files/level2/level2_1.out
  43. 1
      CloudflightCodingContest/files/level2/level2_1.sol
  44. 27
      CloudflightCodingContest/files/level2/level2_2.in
  45. 1
      CloudflightCodingContest/files/level2/level2_2.out
  46. 42
      CloudflightCodingContest/files/level2/level2_3.in
  47. 1
      CloudflightCodingContest/files/level2/level2_3.out
  48. 62
      CloudflightCodingContest/files/level2/level2_4.in
  49. 1
      CloudflightCodingContest/files/level2/level2_4.out
  50. 112
      CloudflightCodingContest/files/level2/level2_5.in
  51. 1
      CloudflightCodingContest/files/level2/level2_5.out
  52. 252
      CloudflightCodingContest/files/level2/level2_6.in
  53. 1
      CloudflightCodingContest/files/level2/level2_6.out
  54. 255
      CloudflightCodingContest/files/level2/level2_notes.txt
  55. 30
      CloudflightCodingContest/pom.xml
  56. 135
      CloudflightCodingContest/src/main/java/at/salento/Car.java
  57. 12
      CloudflightCodingContest/src/main/java/at/salento/CccException.java
  58. 25
      CloudflightCodingContest/src/main/java/at/salento/ComputationBase.java
  59. 63
      CloudflightCodingContest/src/main/java/at/salento/FileIoBase.java
  60. 14
      CloudflightCodingContest/src/main/java/at/salento/Main.java
  61. 119
      CloudflightCodingContest/src/main/java/at/salento/level1/Level1ComputationSimulation.java
  62. 10
      CloudflightCodingContest/src/main/java/at/salento/level1/Level1Io.java
  63. 188
      CloudflightCodingContest/src/main/java/at/salento/level2/Level2Computation.java
  64. 9
      CloudflightCodingContest/src/main/java/at/salento/level2/Level2Io.java
  65. 79
      CloudflightCodingContest/src/test/java/at/salento/level1/Level1Testcases.java
  66. 110
      CloudflightCodingContest/src/test/java/at/salento/level1/Level2Testcases.java

3
.idea/.gitignore

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

9
.idea/ccc-2023.iml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/jpa-buddy.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="renamerInitialized" value="true" />
</component>
</project>

9
.idea/misc.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>

8
.idea/modules.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ccc-2023.iml" filepath="$PROJECT_DIR$/.idea/ccc-2023.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

38
CloudflightCodingContest/.gitignore

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

3
CloudflightCodingContest/.idea/.gitignore

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

7
CloudflightCodingContest/.idea/encodings.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

6
CloudflightCodingContest/.idea/jpa-buddy.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="renamerInitialized" value="true" />
</component>
</project>

16
CloudflightCodingContest/.idea/misc.xml

@ -0,0 +1,16 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>

124
CloudflightCodingContest/.idea/uiDesigner.xml

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
CloudflightCodingContest/.idea/vcs.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

180
CloudflightCodingContest/files/level1/chat_gpt_prompt_for_level1.txt

@ -0,0 +1,180 @@
we want a java code for the following coding challenge: a road is divided into segments numbered from 1 to n
‐ within each segment, at any moment there can be at
most one car
‐ a car can change segments at every full second
‐ a segment can be entered only when during the past
second there was no car in it
‐ if it is not possible for a car to proceed it waits
‐ all segment changes occur simultanously
‐ each car has to perform a trip which consists of entering
the road at a given start segment, subsequently moving
from one segment to the next, and leaving the road at a
given end segment
‐ the arrival time of a car is when it finishes its trip
‐ all trips within a test case will have different start
segments Calculate the arrival times of a number of cars, which perform
trips on one simple road.
- all trips start at time=1
Input:
Note: lines are separated by newline (\n)
number road segments (n)
number of cars (m)
startsegment,endsegment for car 1
startsegment,endsegment for car m
Example input
100
5
3,99
40,75
20,99
28,76
1,100
Example output
98,37,81,50,101
1 < n < 1000
1 < m < 1000
1 <= startsegment < endsegment <= n
Result:
arrival times of the cars, separated by comma, in the order of
the input
Lets assume we already have the following data structures:
package at.salento;
public class Car {
private int startSegment;
private int endSegment;
private int arrivalTime;
private int order;
private int earliestStartTime; // introduced in level 2
private int delay;
private boolean entered = false;
private boolean toRemove = false; // not used at the moment
public Car() {
this.startSegment = 0;
this.endSegment = 0;
this.arrivalTime = 0;
this.order = 0;
this.delay = 0;
}
public Car(int start, int end, int duraction) {
this.startSegment = start;
this.endSegment = end;
this.arrivalTime = duraction;
this.order = 0;
this.delay = 0;
}
public Car(int start, int end, int duration, int order) {
this.startSegment = start;
this.endSegment = end;
this.arrivalTime = duration;
this.order = order;
this.delay = 0;
}
public int getStartSegment() {
return startSegment;
}
public void setStartSegment(int startSegment) {
this.startSegment = startSegment;
}
public int getEndSegment() {
return endSegment;
}
public void setEndSegment(int endSegment) {
this.endSegment = endSegment;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public int getArrivalTime() {
return arrivalTime;
}
public void setArrivalTime(int arrivalTime) {
this.arrivalTime = arrivalTime;
}
public void increaseArrivalTime() {
this.arrivalTime++;
}
public int getDelay() {
return delay;
}
public void increaseDelay() {
this.delay++;
}
public void setDelay(int delay) {
this.delay = delay;
}
public int getTotalArrivalTime() {
return this.arrivalTime + this.delay;
}
public boolean isEntered() {
return entered;
}
public void setEntered(boolean entered) {
this.entered = entered;
}
public boolean isToRemove() {
return toRemove;
}
public void setToRemove(boolean toRemove) {
this.toRemove = toRemove;
}
public int getEarliestStartTime() {
return earliestStartTime;
}
public void setEarliestStartTime(int earliestStartTime) {
this.earliestStartTime = earliestStartTime;
}
@Override
public String toString() {
String viz = "";
for (int i = 0; i< startSegment; i++) viz += " ";
viz += "|";
for (int i = startSegment +1; i < endSegment; i++) viz += "-";
viz += "|";
// for (int i=)
return String.format(" Car(start: %02d", startSegment)
+ String.format(", end: %02d", endSegment)
+ String.format(", arr.t.: %02d", arrivalTime)
+ String.format(", delay: %02d", delay)
+ String.format(", est: %02d", earliestStartTime)
+ String.format(", tot.arr.t: %02d", getTotalArrivalTime())
+ String.format(", order: %02d", order)
+ ") " + "\n";
}
}
and we have filled an private ArrayList<Car> cars; in a class Level1ComputationCGT. we now need a method that performs the required calculation

BIN
CloudflightCodingContest/files/level1/level1.pdf

Binary file not shown.

7
CloudflightCodingContest/files/level1/level1_0.in

@ -0,0 +1,7 @@
100
5
3,99
40,75
20,99
28,76
1,100

1
CloudflightCodingContest/files/level1/level1_0.out

@ -0,0 +1 @@
98,37,81,50,101

1
CloudflightCodingContest/files/level1/level1_0.sol

@ -0,0 +1 @@
98,37,81,50,101

12
CloudflightCodingContest/files/level1/level1_1.in

@ -0,0 +1,12 @@
40
10
24,30
17,20
30,37
16,32
8,10
6,33
22,31
2,6
20,32
4,33

1
CloudflightCodingContest/files/level1/level1_1.out

@ -0,0 +1 @@
8,5,9,19,4,29,11,6,14,31

1
CloudflightCodingContest/files/level1/level1_1.sol

@ -0,0 +1 @@
8,5,9,19,4,29,11,6,14,31

27
CloudflightCodingContest/files/level1/level1_2.in

@ -0,0 +1,27 @@
80
25
68,72
42,60
63,67
51,62
54,72
3,44
61,62
35,68
24,42
64,73
22,51
19,25
33,55
52,74
31,43
2,6
15,49
32,40
34,65
21,42
28,61
14,35
37,57
47,49
45,70

1
CloudflightCodingContest/files/level1/level1_2.out

@ -0,0 +1 @@
6,20,7,14,20,43,3,35,21,11,32,9,26,24,18,7,36,13,34,25,38,24,22,4,27

1
CloudflightCodingContest/files/level1/level1_2.sol

@ -0,0 +1 @@
6,20,7,14,20,43,3,35,21,11,32,9,26,24,18,7,36,13,34,25,38,24,22,4,27

42
CloudflightCodingContest/files/level1/level1_3.in

@ -0,0 +1,42 @@
80
40
25,46
31,33
2,34
58,71
40,54
1,42
33,38
29,66
21,64
48,80
67,80
39,77
24,60
41,58
34,52
4,76
52,58
30,59
44,62
64,69
36,39
19,62
60,62
70,74
14,55
7,25
37,75
20,72
35,61
13,17
47,75
57,62
61,69
45,66
23,24
42,57
54,61
10,76
27,69
49,50

1
CloudflightCodingContest/files/level1/level1_3.out

@ -0,0 +1 @@
31,8,37,16,21,47,15,47,53,35,15,46,47,23,27,77,9,38,23,7,10,55,5,6,50,24,46,63,34,7,32,9,10,25,5,20,10,73,52,3

1
CloudflightCodingContest/files/level1/level1_3.sol

@ -0,0 +1 @@
31,8,37,16,21,47,15,47,53,35,15,46,47,23,27,77,9,38,23,7,10,55,5,6,50,24,46,63,34,7,32,9,10,25,5,20,10,73,52,3

62
CloudflightCodingContest/files/level1/level1_4.in

@ -0,0 +1,62 @@
100
60
21,57
3,95
11,97
80,81
75,82
57,91
85,90
54,71
13,64
43,93
60,93
51,75
22,91
81,84
83,100
87,91
55,65
63,78
89,100
68,89
49,71
50,83
15,19
31,98
16,19
42,43
34,94
70,90
76,97
66,80
36,62
79,98
19,68
77,84
27,97
35,80
29,71
6,59
65,85
53,98
74,99
23,96
52,57
7,24
8,48
56,93
30,95
62,89
38,51
14,23
37,80
24,66
82,97
32,82
71,85
78,96
47,94
59,85
5,60
61,97

1
CloudflightCodingContest/files/level1/level1_4.out

@ -0,0 +1 @@
60,112,106,6,17,50,7,36,71,70,48,44,92,7,19,6,28,27,13,32,44,54,7,87,5,4,79,31,30,25,43,25,73,15,92,63,64,72,32,65,36,95,18,24,59,54,86,40,24,13,59,63,18,69,24,25,69,42,75,50

1
CloudflightCodingContest/files/level1/level1_4.sol

@ -0,0 +1 @@
60,112,106,6,17,50,7,36,71,70,48,44,92,7,19,6,28,27,13,32,44,54,7,87,5,4,79,31,30,25,43,25,73,15,92,63,64,72,32,65,36,95,18,24,59,54,86,40,24,13,59,63,18,69,24,25,69,42,75,50

112
CloudflightCodingContest/files/level1/level1_5.in

@ -0,0 +1,112 @@
300
110
177,217
133,226
188,196
169,292
286,290
174,272
102,133
181,206
289,299
254,270
124,281
5,208
11,89
250,289
43,288
100,259
139,265
189,283
213,238
48,166
108,290
268,274
89,101
115,188
157,260
61,185
247,260
261,288
178,270
193,282
167,253
217,278
32,33
62,198
22,189
67,245
121,139
228,238
105,146
226,265
190,284
2,38
76,227
207,219
129,201
218,281
140,227
58,232
10,155
101,130
37,49
65,156
202,211
227,285
70,175
85,116
203,272
97,190
201,300
233,294
183,191
198,246
196,203
110,223
26,288
12,73
256,259
163,252
63,168
130,238
145,241
164,250
20,71
265,299
134,171
282,297
92,226
223,281
280,299
236,287
135,272
104,199
77,273
66,97
170,220
24,140
238,294
162,291
239,279
144,202
161,282
231,294
149,187
235,246
123,150
150,182
246,274
3,59
159,222
277,295
224,250
229,290
52,216
151,264
180,263
53,271
96,225
109,300
84,99
285,298

1
CloudflightCodingContest/files/level1/level1_5.out

@ -0,0 +1 @@
44,97,12,126,6,101,35,27,12,18,159,205,81,41,247,165,129,97,29,120,186,8,15,75,108,130,15,29,95,91,89,67,3,141,169,180,21,15,44,46,96,39,154,14,76,68,89,179,149,34,14,95,12,64,107,33,71,98,103,65,10,51,10,115,264,63,5,92,109,111,98,88,53,36,40,17,138,66,21,54,139,99,198,34,52,118,59,133,42,61,126,67,42,15,30,35,31,58,68,20,33,65,167,115,86,220,135,194,18,16

1
CloudflightCodingContest/files/level1/level1_5.sol

@ -0,0 +1 @@
44,97,12,126,6,101,35,27,12,18,159,205,81,41,247,165,129,97,29,120,186,8,15,75,108,130,15,29,95,91,89,67,3,141,169,180,21,15,44,46,96,39,154,14,76,68,89,179,149,34,14,95,12,64,107,33,71,98,103,65,10,51,10,115,264,63,5,92,109,111,98,88,53,36,40,17,138,66,21,54,139,99,198,34,52,118,59,133,42,61,126,67,42,15,30,35,31,58,68,20,33,65,167,115,86,220,135,194,18,16

242
CloudflightCodingContest/files/level1/level1_6.in

@ -0,0 +1,242 @@
400
240
66,266
30,70
119,395
240,308
343,382
34,237
107,261
355,377
114,374
286,396
235,247
139,393
173,183
208,231
362,376
302,358
309,375
312,389
278,322
304,316
29,201
89,133
258,383
353,361
284,316
55,393
338,366
198,246
62,350
120,147
201,292
187,197
46,315
106,371
252,350
259,391
231,304
169,287
121,170
244,250
155,216
385,392
13,216
151,337
168,242
103,204
219,231
154,158
144,209
247,320
64,382
146,147
251,277
366,375
157,245
189,224
225,226
379,400
80,279
83,353
202,365
137,275
288,325
306,350
93,178
297,332
265,331
104,258
205,241
63,363
97,112
77,342
218,300
290,338
294,342
26,27
175,295
206,285
197,311
14,99
248,371
33,329
260,320
273,350
156,230
267,304
152,345
31,208
185,224
72,311
79,149
181,203
367,396
45,317
20,23
371,382
300,377
327,383
41,99
384,392
227,264
230,239
95,252
373,399
377,393
233,305
241,338
191,390
303,332
324,358
69,373
133,134
222,320
145,232
263,329
17,59
129,216
19,283
125,219
136,281
194,304
162,299
108,170
24,103
345,390
166,174
128,151
211,215
364,375
212,354
261,299
50,120
40,290
61,171
289,361
49,333
356,378
193,303
282,338
344,399
178,283
224,327
11,369
42,162
70,145
274,389
322,331
266,344
387,399
102,252
301,374
188,324
48,288
298,346
262,285
134,266
269,352
254,268
253,347
47,171
358,382
341,346
349,354
271,399
183,324
370,393
57,325
332,397
74,247
53,76
27,358
335,356
239,271
109,252
58,390
6,105
3,40
174,356
234,385
200,310
87,286
352,387
71,261
342,400
94,148
52,302
186,227
36,129
51,188
389,390
92,214
337,391
307,310
238,336
196,391
375,386
143,174
213,352
105,274
2,393
323,345
161,336
4,393
116,267
236,337
293,320
54,222
390,400
59,323
365,384
299,394
32,209
130,150
138,201
348,384
292,327
277,362
215,220
23,185
223,248
276,400
142,363
209,398
28,186
321,362
207,371
229,354
177,364
369,378
123,156
1,170
199,374
314,333
115,234
250,331
272,359
99,284
243,339
68,269
117,270

1
CloudflightCodingContest/files/level1/level1_6.out

@ -0,0 +1 @@
216,70,285,91,45,231,165,28,272,123,26,269,25,37,21,61,68,79,55,15,203,59,148,14,45,359,33,71,306,35,111,26,297,277,119,154,99,139,57,12,80,10,233,205,96,116,27,9,81,97,334,3,48,14,105,58,3,23,211,283,182,155,50,47,100,45,84,168,53,317,26,278,105,59,57,11,143,100,138,114,146,325,81,91,92,53,211,208,64,251,83,42,33,301,5,13,84,58,87,12,63,23,170,28,18,98,119,225,33,36,319,4,123,102,84,72,102,295,107,163,135,155,72,111,49,12,31,8,18,163,58,94,280,129,84,309,27,136,69,60,127,128,388,148,89,128,13,95,15,166,79,161,266,57,42,150,99,26,114,151,29,11,8,144,166,26,289,70,185,41,364,27,56,152,352,126,60,206,176,131,214,42,203,65,68,272,65,121,160,4,138,60,5,123,220,13,43,159,182,418,25,194,416,161,126,37,190,12,283,25,103,207,26,79,41,46,97,9,195,44,137,237,209,190,46,184,151,210,13,40,197,197,21,130,104,102,200,118,217,162

1
CloudflightCodingContest/files/level1/level1_6.sol

@ -0,0 +1 @@
216,70,285,91,45,231,165,28,272,123,26,269,25,37,21,61,68,79,55,15,203,59,148,14,45,359,33,71,306,35,111,26,297,277,119,154,99,139,57,12,80,10,233,205,96,116,27,9,81,97,334,3,48,14,105,58,3,23,211,283,182,155,50,47,100,45,84,168,53,317,26,278,105,59,57,11,143,100,138,114,146,325,81,91,92,53,211,208,64,251,83,42,33,301,5,13,84,58,87,12,63,23,170,28,18,98,119,225,33,36,319,4,123,102,84,72,102,295,107,163,135,155,72,111,49,12,31,8,18,163,58,94,280,129,84,309,27,136,69,60,127,128,388,148,89,128,13,95,15,166,79,161,266,57,42,150,99,26,114,151,29,11,8,144,166,26,289,70,185,41,364,27,56,152,352,126,60,206,176,131,214,42,203,65,68,272,65,121,160,4,138,60,5,123,220,13,43,159,182,418,25,194,416,161,126,37,190,12,283,25,103,207,26,79,41,46,97,9,195,44,137,237,209,190,46,184,151,210,13,40,197,197,21,130,104,102,200,118,217,162

BIN
CloudflightCodingContest/files/level2/level2.pdf

Binary file not shown.

12
CloudflightCodingContest/files/level2/level2_0.in

@ -0,0 +1,12 @@
40
10
11,13,28
30,37,62
4,24,102
6,33,138
27,30,154
20,32,170
11,19,196
2,20,209
18,21,239
23,24,273

1
CloudflightCodingContest/files/level2/level2_0.out

@ -0,0 +1 @@
31,70,123,166,158,183,205,228,243,275

1
CloudflightCodingContest/files/level2/level2_0.sol

@ -0,0 +1 @@
31,70,123,166,158,183,205,228,243,275

12
CloudflightCodingContest/files/level2/level2_1.in

@ -0,0 +1,12 @@
40
10
11,13,54
30,37,15
4,24,11
6,33,12
27,30,47
20,32,12
8,30,44
12,33,42
5,33,28
22,29,29

1
CloudflightCodingContest/files/level2/level2_1.out

@ -0,0 +1 @@
57,23,33,40,51,25,67,64,57,40

1
CloudflightCodingContest/files/level2/level2_1.sol

@ -0,0 +1 @@
57,23,33,40,51,25,67,64,57,40

27
CloudflightCodingContest/files/level2/level2_2.in

@ -0,0 +1,27 @@
80
25
61,62,41
68,78,30
64,73,9
37,68,52
33,55,28
31,43,7
66,67,32
19,40,34
34,65,44
32,68,26
22,74,14
13,41,4
47,49,39
25,70,20
58,60,21
21,30,29
1,42,54
29,66,38
42,78,21
67,80,25
48,52,29
24,60,49
40,44,41
52,58,3
39,76,5

1
CloudflightCodingContest/files/level2/level2_2.out

@ -0,0 +1 @@
44,41,19,84,56,20,36,58,78,67,69,33,42,67,24,39,96,77,58,39,34,86,47,10,43

42
CloudflightCodingContest/files/level2/level2_3.in

@ -0,0 +1,42 @@
80
40
50,51,4
12,52,19
19,62,47
62,74,10
60,80,4
23,44,4
17,47,32
20,72,10
58,63,34
13,17,36
48,66,22
70,77,28
61,69,49
39,47,27
11,65,21
25,42,5
4,27,40
21,39,27
10,76,53
14,29,7
9,72,11
41,46,18
55,62,6
45,70,27
65,78,29
3,10,46
43,48,40
42,71,45
63,80,1
36,63,47
2,4,10
49,66,20
34,43,35
6,21,52
67,70,37
68,78,5
26,71,45
40,51,41
16,42,21
37,57,39

1
CloudflightCodingContest/files/level2/level2_3.out

@ -0,0 +1 @@
6,60,91,23,25,27,65,63,40,41,41,36,58,36,79,23,64,49,122,23,76,24,14,54,43,54,46,81,20,79,13,38,45,69,41,16,91,63,48,79

62
CloudflightCodingContest/files/level2/level2_4.in

@ -0,0 +1,62 @@
100
60
41,100,37
29,71,5
1,93,41
43,94,30
44,92,43
85,93,26
21,76,40
80,87,3
8,48,28
9,83,36
3,34,5
36,62,26
38,51,22
89,96,26
37,80,17
24,36,54
22,44,34
32,82,46
83,89,2
64,72,51
78,96,5
82,100,27
60,72,28
25,45,39
61,97,45
58,94,12
46,76,19
62,93,54
28,67,46
14,50,21
45,83,9
7,22,31
63,84,14
69,87,45
49,86,45
53,88,54
48,66,28
39,84,43
23,41,35
81,91,48
74,91,37
52,53,55
2,40,48
57,85,22
68,77,31
26,65,26
54,55,55
66,70,42
87,95,17
72,86,19
70,77,17
40,75,8
90,91,14
77,85,47
15,17,50
50,85,22
65,81,19
67,82,8
33,38,41
86,97,46

1
CloudflightCodingContest/files/level2/level2_4.out

@ -0,0 +1 @@
100,55,134,88,96,35,99,11,73,111,37,60,36,35,66,67,57,99,9,62,24,46,46,64,89,49,56,89,88,58,51,47,36,65,88,94,54,95,56,61,57,62,87,57,41,73,58,52,26,36,25,47,16,59,53,61,38,24,48,58

112
CloudflightCodingContest/files/level2/level2_5.in

@ -0,0 +1,112 @@
300
110
110,223,15
192,250,11
2,216,50
163,252,25
25,180,18
254,291,18
46,60,25
20,71,22
67,256,12
14,164,15
203,246,2
92,226,23
43,208,18
236,287,54
57,112,55
77,273,54
17,248,31
170,220,42
144,176,9
162,291,24
250,259,41
244,247,35
10,241,27
85,294,23
235,246,23
69,124,43
246,274,7
208,299,53
159,222,37
3,13,47
229,290,2
189,260,51
151,264,21
133,250,35
96,225,46
84,99,44
265,291,8
13,73,50
150,269,37
78,247,35
211,243,55
215,252,31
56,300,34
97,196,40
99,199,14
182,296,2
66,297,52
138,254,15
256,283,44
89,244,13
277,283,3
238,282,48
155,273,26
8,170,13
184,200,32
181,287,52
119,268,7
276,277,19
218,293,42
101,239,15
126,175,9
274,280,32
275,282,30
279,289,43
129,231,41
263,270,52
135,169,9
261,295,52
33,292,17
42,182,12
11,287,44
29,98,31
113,121,27
16,117,5
280,299,14
148,176,48
191,262,52
217,227,55
123,274,48
86,245,37
1,272,21
87,237,25
241,268,42
50,298,7
76,113,44
95,146,50
24,231,38
41,240,38
154,278,18
193,226,20
30,185,6
72,140,42
28,149,32
213,262,36
102,287,18
136,160,49
253,277,46
223,245,12
140,277,44
286,292,17
137,272,55
290,299,37
252,287,5
117,209,48
183,268,15
127,269,51
132,151,13
243,259,24
45,132,12
21,23,38

1
CloudflightCodingContest/files/level2/level2_5.out

@ -0,0 +1 @@
130,71,265,120,174,58,42,77,202,166,46,158,184,106,112,255,263,98,45,155,51,41,260,233,38,102,36,146,104,58,64,126,136,153,176,61,35,111,157,207,88,69,284,140,118,119,285,134,72,169,10,93,147,180,49,163,158,23,120,156,59,39,38,54,144,61,44,88,278,154,321,102,38,107,34,77,124,67,203,198,295,178,70,256,83,102,248,238,148,54,165,114,157,87,208,75,72,35,182,24,195,47,41,143,101,196,33,41,100,44

252
CloudflightCodingContest/files/level2/level2_6.in

@ -0,0 +1,252 @@
400
250
233,341,17
19,283,30
99,303,25
136,281,6
324,357,24
93,153,42
24,103,40
152,245,9
166,174,45
81,99,28
45,284,46
212,354,10
201,338,21
40,290,30
297,387,4
368,370,6
49,333,54
356,378,9
343,352,38
175,399,21
178,283,26
245,356,54
42,162,25
225,234,45
322,331,24
266,344,33
363,381,47
227,388,12
139,400,51
234,297,13
114,282,18
262,285,1
182,223,44
269,352,27
250,263,39
185,252,48
344,392,35
246,249,53
349,354,19
293,392,1
29,400,33
57,325,33
25,234,27
53,76,14
27,358,43
216,272,10
239,271,43
209,289,49
58,390,19
145,253,21
156,262,4
111,114,21
87,286,10
191,362,23
31,200,22
352,387,33
71,261,9
342,400,4
345,384,12
194,274,27
244,348,44
80,145,3
341,392,51
353,366,36
51,188,24
23,297,4
337,391,22
279,390,2
196,391,36
36,385,45
143,174,31
267,282,23
278,298,24
323,345,25
4,393,21
251,289,16
218,268,41
70,243,1
54,222,28
10,257,5
103,240,14
299,394,54
347,349,32
230,318,30
304,358,12
140,177,18
292,327,22
277,362,42
286,381,52
59,265,35
223,248,29
326,375,36
142,363,24
20,391,41
28,186,23
320,387,11
229,354,48
302,303,7
177,311,22
146,239,5
203,271,18
373,383,23
199,374,53
102,202,20
309,329,9
77,197,54
44,329,15
108,141,40
291,319,1
272,359,37
94,329,50
173,360,11
213,259,20
243,339,16
253,347,13
117,270,22
283,286,24
60,84,4
376,400,36
259,302,9
86,304,2
132,150,6
149,245,54
106,229,10
100,152,13
7,291,11
228,287,35
365,388,14
331,382,41
66,135,34
386,393,7
226,260,28
236,240,46
126,141,23
163,333,44
289,369,3
128,372,16
242,295,16
184,339,45
183,248,33
281,299,11
200,232,14
237,245,20
204,356,47
123,227,1
82,209,1
192,317,49
104,312,20
98,181,43
338,394,1
107,176,38
325,373,16
235,290,51
195,359,22
164,173,54
172,272,32
232,369,21
125,143,13
130,141,22
67,260,53
380,391,35
287,292,30
275,285,2
46,316,24
359,394,25
336,361,42
22,232,27
176,380,5
131,287,54
328,337,4
288,290,12
61,286,29
73,236,15
141,340,35
383,389,17
354,387,38
21,236,48
314,317,13
5,132,18
231,296,17
270,377,3
361,398,4
179,191,26
321,346,47
222,346,48
305,335,54
190,244,5
255,347,45
135,395,14
110,265,26
41,182,48
35,337,26
208,370,29
220,267,44
224,238,30
273,293,12
308,350,19
310,331,4
327,384,20
379,396,34
116,128,49
9,113,46
85,250,6
89,162,9
17,56,38
301,305,50
78,100,39
74,102,52
193,239,7
360,384,55
181,399,41
189,194,45
138,386,3
167,257,12
357,396,7
319,323,11
72,353,36
32,177,9
375,391,39
157,363,37
1,143,2
252,399,23
12,49,38
154,294,8
76,140,13
186,203,29
118,272,49
37,323,27
312,319,51
14,284,21
91,143,18
389,394,45
264,373,11
265,312,6
238,301,5
254,318,15
155,344,48
171,336,34
119,259,2
274,323,24
390,394,38
137,343,25
371,399,55
296,358,15
105,161,9
112,241,25
382,397,44
30,371,6
247,296,11
68,307,8

1
CloudflightCodingContest/files/level2/level2_6.out

@ -0,0 +1 @@
128,318,253,173,59,120,144,127,56,58,299,154,176,295,96,9,350,34,50,263,145,170,163,62,38,119,68,177,326,82,200,25,103,112,57,130,87,59,25,111,423,316,255,38,397,70,79,139,361,147,132,29,234,206,207,69,222,64,56,120,152,98,105,50,169,296,82,117,243,414,76,39,46,50,436,62,100,198,205,268,164,152,37,120,69,65,60,130,151,252,60,92,267,436,199,80,178,9,169,123,93,37,240,140,32,182,308,84,36,131,298,208,77,120,109,186,30,30,62,56,236,25,165,151,75,318,103,38,97,112,15,66,54,41,231,92,284,78,215,108,30,51,29,210,123,149,185,246,140,62,120,70,110,199,71,158,165,32,39,257,51,36,13,311,68,68,263,222,223,14,16,261,201,254,24,76,283,17,169,87,112,42,41,75,182,87,70,140,297,195,207,346,200,101,50,35,71,29,85,52,67,162,196,100,99,59,65,89,59,83,273,52,276,113,48,17,326,170,61,263,162,178,94,166,97,47,214,326,59,317,94,52,123,58,78,82,254,224,165,79,43,251,84,83,69,169,63,360,62,270

255
CloudflightCodingContest/files/level2/level2_notes.txt

@ -0,0 +1,255 @@
/home/andy/.jdks/openjdk-21/bin/java -javaagent:/snap/intellij-idea-community/456/lib/idea_rt.jar=43773:/snap/intellij-idea-community/456/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /home/andy/IdeaProjects/CloudflightCodingContest/target/classes:/home/andy/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.10.0/junit-jupiter-api-5.10.0.jar:/home/andy/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/home/andy/.m2/repository/org/junit/platform/junit-platform-commons/1.10.0/junit-platform-commons-1.10.0.jar:/home/andy/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar at.salento.Main
61,62,41
68,78,30
64,73,9
37,68,52
33,55,28
31,43,7
66,67,32
19,40,34
34,65,44
32,68,26
22,74,14
13,41,4
47,49,39
25,70,20
58,60,21
21,30,29
1,42,54
29,66,38
42,78,21
67,80,25
48,52,29
24,60,49
40,44,41
52,58,3
39,76,5
Queue:[ Car(start: 61, end: 62, arr.t.: 00, delay: 00, est: 41, tot.arr.t: 00, order: 00)
, Car(start: 68, end: 78, arr.t.: 00, delay: 00, est: 30, tot.arr.t: 00, order: 01)
, Car(start: 64, end: 73, arr.t.: 00, delay: 00, est: 09, tot.arr.t: 00, order: 02)
, Car(start: 37, end: 68, arr.t.: 00, delay: 00, est: 52, tot.arr.t: 00, order: 03)
, Car(start: 33, end: 55, arr.t.: 00, delay: 00, est: 28, tot.arr.t: 00, order: 04)
, Car(start: 31, end: 43, arr.t.: 00, delay: 00, est: 07, tot.arr.t: 00, order: 05)
, Car(start: 66, end: 67, arr.t.: 00, delay: 00, est: 32, tot.arr.t: 00, order: 06)
, Car(start: 19, end: 40, arr.t.: 00, delay: 00, est: 34, tot.arr.t: 00, order: 07)
, Car(start: 34, end: 65, arr.t.: 00, delay: 00, est: 44, tot.arr.t: 00, order: 08)
, Car(start: 32, end: 68, arr.t.: 00, delay: 00, est: 26, tot.arr.t: 00, order: 09)
, Car(start: 22, end: 74, arr.t.: 00, delay: 00, est: 14, tot.arr.t: 00, order: 10)
, Car(start: 13, end: 41, arr.t.: 00, delay: 00, est: 04, tot.arr.t: 00, order: 11)
, Car(start: 47, end: 49, arr.t.: 00, delay: 00, est: 39, tot.arr.t: 00, order: 12)
, Car(start: 25, end: 70, arr.t.: 00, delay: 00, est: 20, tot.arr.t: 00, order: 13)
, Car(start: 58, end: 60, arr.t.: 00, delay: 00, est: 21, tot.arr.t: 00, order: 14)
, Car(start: 21, end: 30, arr.t.: 00, delay: 00, est: 29, tot.arr.t: 00, order: 15)
, Car(start: 01, end: 42, arr.t.: 00, delay: 00, est: 54, tot.arr.t: 00, order: 16)
, Car(start: 29, end: 66, arr.t.: 00, delay: 00, est: 38, tot.arr.t: 00, order: 17)
, Car(start: 42, end: 78, arr.t.: 00, delay: 00, est: 21, tot.arr.t: 00, order: 18)
, Car(start: 67, end: 80, arr.t.: 00, delay: 00, est: 25, tot.arr.t: 00, order: 19)
, Car(start: 48, end: 52, arr.t.: 00, delay: 00, est: 29, tot.arr.t: 00, order: 20)
, Car(start: 24, end: 60, arr.t.: 00, delay: 00, est: 49, tot.arr.t: 00, order: 21)
, Car(start: 40, end: 44, arr.t.: 00, delay: 00, est: 41, tot.arr.t: 00, order: 22)
, Car(start: 52, end: 58, arr.t.: 00, delay: 00, est: 03, tot.arr.t: 00, order: 23)
, Car(start: 39, end: 76, arr.t.: 00, delay: 00, est: 05, tot.arr.t: 00, order: 24)
]
sec: 1:
sec: 2:
sec: 3: (23)
sec: 4: (11) (23)
sec: 5: (11) (24) (23)
sec: 6: (11) (24) (23)
sec: 7: (11) (05) (24) (23)
sec: 8: (11) (05) (24) (23)
sec: 9: (11) (05) (24) (23) (02)
sec: 10: (11) (05) (24) (02)
sec: 11: (11) (05) (24) (02)
sec: 12: (11) (05) (24) (02)
sec: 13: (11) (05) (24) (02)
sec: 14: (11) (05) (24) (02)
sec: 15: (10) (11) (05) (24) (02)
sec: 16: (10) (11) (05) (24) (02)
sec: 17: (10) (11) (05) (24) (02)
sec: 18: (10) (11) (05) (24) (02)
sec: 19: (10) (11) (05) (24)
sec: 20: (13) (10) (11) (24)
sec: 21: (13) (10) (11) (18) (24) (14)
sec: 22: (13) (10) (11) (18) (24) (14)
sec: 23: (13) (10) (11) (18) (24) (14)
sec: 24: (13) (10) (11) (18) (24)
sec: 25: (13) (10) (11) (18) (24) (19)
sec: 26: (13) (10) (11) (18) (24) (19)
sec: 27: (13) (10) (11) (18) (24) (19)
sec: 28: (13) (10) (11) (18) (24) (19)
sec: 29: (15) (09) (13) (10) (11) (20) (18) (24) (19)
sec: 30: (15) (09) (13) (10) (11) (20) (18) (24) (01) (19)
sec: 31: (15) (09) (13) (10) (11) (20) (18) (24) (01) (19)
sec: 32: (15) (04) (09) (13) (10) (11) (20) (18) (24) (01) (19)
sec: 33: (15) (04) (09) (13) (10) (20) (18) (24) (01) (19)
sec: 34: (15) (04) (09) (13) (10) (18) (06) (24) (01) (19)
sec: 35: (07) (15) (04) (09) (13) (10) (18) (06) (24) (01) (19)
sec: 36: (07) (15) (04) (09) (13) (10) (18) (24) (01) (19)
sec: 37: (07) (15) (04) (09) (13) (10) (18) (24) (01) (19)
sec: 38: (07) (15) (04) (09) (13) (10) (18) (24) (01)
sec: 39: (07) (17) (04) (09) (13) (10) (12) (18) (24) (01)
sec: 40: (07) (17) (04) (09) (13) (10) (12) (18) (24) (01)
sec: 41: (07) (17) (22) (04) (09) (13) (10) (12) (18) (24)
sec: 42: (07) (17) (22) (04) (09) (13) (10) (00) (18) (24)
sec: 43: (07) (17) (22) (04) (09) (13) (10) (00) (18)
sec: 44: (07) (17) (22) (04) (09) (13) (10) (18)
sec: 45: (07) (17) (22) (04) (09) (13) (10) (18)
sec: 46: (07) (08) (17) (22) (04) (09) (13) (10) (18)
sec: 47: (07) (08) (17) (04) (09) (13) (10) (18)
sec: 48: (07) (08) (17) (04) (09) (13) (10) (18)
sec: 49: (21) (07) (08) (17) (04) (09) (13) (10) (18)
sec: 50: (21) (07) (08) (17) (04) (09) (13) (10) (18)
sec: 51: (21) (07) (08) (17) (04) (09) (13) (10) (18)
sec: 52: (21) (07) (03) (08) (17) (04) (09) (13) (10) (18)
sec: 53: (21) (07) (03) (08) (17) (04) (09) (13) (10) (18)
sec: 54: (16) (21) (07) (03) (08) (17) (04) (09) (13) (10) (18)
sec: 55: (16) (21) (07) (03) (08) (17) (04) (09) (13) (10) (18)
sec: 56: (16) (21) (07) (03) (08) (17) (09) (13) (10) (18)
sec: 57: (16) (21) (07) (03) (08) (17) (09) (13) (10) (18)
sec: 58: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 59: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 60: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 61: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 62: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 63: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 64: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 65: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 66: (16) (21) (03) (08) (17) (09) (13) (10)
sec: 67: (16) (21) (03) (08) (17) (10)
sec: 68: (16) (21) (03) (08) (17) (10)
sec: 69: (16) (21) (03) (08) (17)
sec: 70: (16) (21) (03) (08) (17)
sec: 71: (16) (21) (03) (08) (17)
sec: 72: (16) (21) (03) (08) (17)
sec: 73: (16) (21) (03) (08) (17)
sec: 74: (16) (21) (03) (08) (17)
sec: 75: (16) (21) (03) (08) (17)
sec: 76: (16) (21) (03) (08) (17)
sec: 77: (16) (21) (03) (08)
sec: 78: (16) (21) (03)
sec: 79: (16) (21) (03)
sec: 80: (16) (21) (03)
sec: 81: (16) (21) (03)
sec: 82: (16) (21) (03)
sec: 83: (16) (21) (03)
sec: 84: (16) (21)
sec: 85: (16) (21)
sec: 86: (16)
sec: 87: (16)
sec: 88: (16)
sec: 89: (16)
sec: 90: (16)
sec: 91: (16)
sec: 92: (16)
sec: 93: (16)
sec: 94: (16)
sec: 95: (16)
sec: 96:
Copy Cars: [ Car(start: 61, end: 62, arr.t.: 44, delay: 00, est: 41, tot.arr.t: 44, order: 00)
, Car(start: 68, end: 78, arr.t.: 41, delay: 00, est: 30, tot.arr.t: 41, order: 01)
, Car(start: 64, end: 73, arr.t.: 19, delay: 00, est: 09, tot.arr.t: 19, order: 02)
, Car(start: 37, end: 68, arr.t.: 84, delay: 00, est: 52, tot.arr.t: 84, order: 03)
, Car(start: 33, end: 55, arr.t.: 56, delay: 00, est: 28, tot.arr.t: 56, order: 04)
, Car(start: 31, end: 43, arr.t.: 20, delay: 00, est: 07, tot.arr.t: 20, order: 05)
, Car(start: 66, end: 67, arr.t.: 36, delay: 00, est: 32, tot.arr.t: 36, order: 06)
, Car(start: 19, end: 40, arr.t.: 58, delay: 00, est: 34, tot.arr.t: 58, order: 07)
, Car(start: 34, end: 65, arr.t.: 78, delay: 00, est: 44, tot.arr.t: 78, order: 08)
, Car(start: 32, end: 68, arr.t.: 67, delay: 00, est: 26, tot.arr.t: 67, order: 09)
, Car(start: 22, end: 74, arr.t.: 69, delay: 00, est: 14, tot.arr.t: 69, order: 10)
, Car(start: 13, end: 41, arr.t.: 33, delay: 00, est: 04, tot.arr.t: 33, order: 11)
, Car(start: 47, end: 49, arr.t.: 42, delay: 00, est: 39, tot.arr.t: 42, order: 12)
, Car(start: 25, end: 70, arr.t.: 67, delay: 00, est: 20, tot.arr.t: 67, order: 13)
, Car(start: 58, end: 60, arr.t.: 24, delay: 00, est: 21, tot.arr.t: 24, order: 14)
, Car(start: 21, end: 30, arr.t.: 39, delay: 00, est: 29, tot.arr.t: 39, order: 15)
, Car(start: 01, end: 42, arr.t.: 96, delay: 00, est: 54, tot.arr.t: 96, order: 16)
, Car(start: 29, end: 66, arr.t.: 77, delay: 00, est: 38, tot.arr.t: 77, order: 17)
, Car(start: 42, end: 78, arr.t.: 58, delay: 00, est: 21, tot.arr.t: 58, order: 18)
, Car(start: 67, end: 80, arr.t.: 39, delay: 00, est: 25, tot.arr.t: 39, order: 19)
, Car(start: 48, end: 52, arr.t.: 34, delay: 00, est: 29, tot.arr.t: 34, order: 20)
, Car(start: 24, end: 60, arr.t.: 86, delay: 00, est: 49, tot.arr.t: 86, order: 21)
, Car(start: 40, end: 44, arr.t.: 47, delay: 00, est: 41, tot.arr.t: 47, order: 22)
, Car(start: 52, end: 58, arr.t.: 10, delay: 00, est: 03, tot.arr.t: 10, order: 23)
, Car(start: 39, end: 76, arr.t.: 43, delay: 00, est: 05, tot.arr.t: 43, order: 24)
]
Cars in initial order:[ Car(start: 61, end: 62, arr.t.: 44, delay: 00, est: 41, tot.arr.t: 44, order: 00)
, Car(start: 68, end: 78, arr.t.: 41, delay: 00, est: 30, tot.arr.t: 41, order: 01)
, Car(start: 64, end: 73, arr.t.: 19, delay: 00, est: 09, tot.arr.t: 19, order: 02)
, Car(start: 37, end: 68, arr.t.: 84, delay: 00, est: 52, tot.arr.t: 84, order: 03)
, Car(start: 33, end: 55, arr.t.: 56, delay: 00, est: 28, tot.arr.t: 56, order: 04)
, Car(start: 31, end: 43, arr.t.: 20, delay: 00, est: 07, tot.arr.t: 20, order: 05)
, Car(start: 66, end: 67, arr.t.: 36, delay: 00, est: 32, tot.arr.t: 36, order: 06)
, Car(start: 19, end: 40, arr.t.: 58, delay: 00, est: 34, tot.arr.t: 58, order: 07)
, Car(start: 34, end: 65, arr.t.: 78, delay: 00, est: 44, tot.arr.t: 78, order: 08)
, Car(start: 32, end: 68, arr.t.: 67, delay: 00, est: 26, tot.arr.t: 67, order: 09)
, Car(start: 22, end: 74, arr.t.: 69, delay: 00, est: 14, tot.arr.t: 69, order: 10)
, Car(start: 13, end: 41, arr.t.: 33, delay: 00, est: 04, tot.arr.t: 33, order: 11)
, Car(start: 47, end: 49, arr.t.: 42, delay: 00, est: 39, tot.arr.t: 42, order: 12)
, Car(start: 25, end: 70, arr.t.: 67, delay: 00, est: 20, tot.arr.t: 67, order: 13)
, Car(start: 58, end: 60, arr.t.: 24, delay: 00, est: 21, tot.arr.t: 24, order: 14)
, Car(start: 21, end: 30, arr.t.: 39, delay: 00, est: 29, tot.arr.t: 39, order: 15)
, Car(start: 01, end: 42, arr.t.: 96, delay: 00, est: 54, tot.arr.t: 96, order: 16)
, Car(start: 29, end: 66, arr.t.: 77, delay: 00, est: 38, tot.arr.t: 77, order: 17)
, Car(start: 42, end: 78, arr.t.: 58, delay: 00, est: 21, tot.arr.t: 58, order: 18)
, Car(start: 67, end: 80, arr.t.: 39, delay: 00, est: 25, tot.arr.t: 39, order: 19)
, Car(start: 48, end: 52, arr.t.: 34, delay: 00, est: 29, tot.arr.t: 34, order: 20)
, Car(start: 24, end: 60, arr.t.: 86, delay: 00, est: 49, tot.arr.t: 86, order: 21)
, Car(start: 40, end: 44, arr.t.: 47, delay: 00, est: 41, tot.arr.t: 47, order: 22)
, Car(start: 52, end: 58, arr.t.: 10, delay: 00, est: 03, tot.arr.t: 10, order: 23)
, Car(start: 39, end: 76, arr.t.: 43, delay: 00, est: 05, tot.arr.t: 43, order: 24)
]
Ordered due to start segment: [ Car(start: 01, end: 42, arr.t.: 96, delay: 00, est: 54, tot.arr.t: 96, order: 16)
, Car(start: 13, end: 41, arr.t.: 33, delay: 00, est: 04, tot.arr.t: 33, order: 11)
, Car(start: 19, end: 40, arr.t.: 58, delay: 00, est: 34, tot.arr.t: 58, order: 07)
, Car(start: 21, end: 30, arr.t.: 39, delay: 00, est: 29, tot.arr.t: 39, order: 15)
, Car(start: 22, end: 74, arr.t.: 69, delay: 00, est: 14, tot.arr.t: 69, order: 10)
, Car(start: 24, end: 60, arr.t.: 86, delay: 00, est: 49, tot.arr.t: 86, order: 21)
, Car(start: 25, end: 70, arr.t.: 67, delay: 00, est: 20, tot.arr.t: 67, order: 13)
, Car(start: 29, end: 66, arr.t.: 77, delay: 00, est: 38, tot.arr.t: 77, order: 17)
, Car(start: 31, end: 43, arr.t.: 20, delay: 00, est: 07, tot.arr.t: 20, order: 05)
, Car(start: 32, end: 68, arr.t.: 67, delay: 00, est: 26, tot.arr.t: 67, order: 09)
, Car(start: 33, end: 55, arr.t.: 56, delay: 00, est: 28, tot.arr.t: 56, order: 04)
, Car(start: 34, end: 65, arr.t.: 78, delay: 00, est: 44, tot.arr.t: 78, order: 08)
, Car(start: 37, end: 68, arr.t.: 84, delay: 00, est: 52, tot.arr.t: 84, order: 03)
, Car(start: 39, end: 76, arr.t.: 43, delay: 00, est: 05, tot.arr.t: 43, order: 24)
, Car(start: 40, end: 44, arr.t.: 47, delay: 00, est: 41, tot.arr.t: 47, order: 22)
, Car(start: 42, end: 78, arr.t.: 58, delay: 00, est: 21, tot.arr.t: 58, order: 18)
, Car(start: 47, end: 49, arr.t.: 42, delay: 00, est: 39, tot.arr.t: 42, order: 12)
, Car(start: 48, end: 52, arr.t.: 34, delay: 00, est: 29, tot.arr.t: 34, order: 20)
, Car(start: 52, end: 58, arr.t.: 10, delay: 00, est: 03, tot.arr.t: 10, order: 23)
, Car(start: 58, end: 60, arr.t.: 24, delay: 00, est: 21, tot.arr.t: 24, order: 14)
, Car(start: 61, end: 62, arr.t.: 44, delay: 00, est: 41, tot.arr.t: 44, order: 00)
, Car(start: 64, end: 73, arr.t.: 19, delay: 00, est: 09, tot.arr.t: 19, order: 02)
, Car(start: 66, end: 67, arr.t.: 36, delay: 00, est: 32, tot.arr.t: 36, order: 06)
, Car(start: 67, end: 80, arr.t.: 39, delay: 00, est: 25, tot.arr.t: 39, order: 19)
, Car(start: 68, end: 78, arr.t.: 41, delay: 00, est: 30, tot.arr.t: 41, order: 01)
]
Ordered due to earliest start times: [ Car(start: 52, end: 58, arr.t.: 10, delay: 00, est: 03, tot.arr.t: 10, order: 23)
, Car(start: 13, end: 41, arr.t.: 33, delay: 00, est: 04, tot.arr.t: 33, order: 11)
, Car(start: 39, end: 76, arr.t.: 43, delay: 00, est: 05, tot.arr.t: 43, order: 24)
, Car(start: 31, end: 43, arr.t.: 20, delay: 00, est: 07, tot.arr.t: 20, order: 05)
, Car(start: 64, end: 73, arr.t.: 19, delay: 00, est: 09, tot.arr.t: 19, order: 02)
, Car(start: 22, end: 74, arr.t.: 69, delay: 00, est: 14, tot.arr.t: 69, order: 10)
, Car(start: 25, end: 70, arr.t.: 67, delay: 00, est: 20, tot.arr.t: 67, order: 13)
, Car(start: 58, end: 60, arr.t.: 24, delay: 00, est: 21, tot.arr.t: 24, order: 14)
, Car(start: 42, end: 78, arr.t.: 58, delay: 00, est: 21, tot.arr.t: 58, order: 18)
, Car(start: 67, end: 80, arr.t.: 39, delay: 00, est: 25, tot.arr.t: 39, order: 19)
, Car(start: 32, end: 68, arr.t.: 67, delay: 00, est: 26, tot.arr.t: 67, order: 09)
, Car(start: 33, end: 55, arr.t.: 56, delay: 00, est: 28, tot.arr.t: 56, order: 04)
, Car(start: 21, end: 30, arr.t.: 39, delay: 00, est: 29, tot.arr.t: 39, order: 15)
, Car(start: 48, end: 52, arr.t.: 34, delay: 00, est: 29, tot.arr.t: 34, order: 20)
, Car(start: 68, end: 78, arr.t.: 41, delay: 00, est: 30, tot.arr.t: 41, order: 01)
, Car(start: 66, end: 67, arr.t.: 36, delay: 00, est: 32, tot.arr.t: 36, order: 06)
, Car(start: 19, end: 40, arr.t.: 58, delay: 00, est: 34, tot.arr.t: 58, order: 07)
, Car(start: 29, end: 66, arr.t.: 77, delay: 00, est: 38, tot.arr.t: 77, order: 17)
, Car(start: 47, end: 49, arr.t.: 42, delay: 00, est: 39, tot.arr.t: 42, order: 12)
, Car(start: 61, end: 62, arr.t.: 44, delay: 00, est: 41, tot.arr.t: 44, order: 00)
, Car(start: 40, end: 44, arr.t.: 47, delay: 00, est: 41, tot.arr.t: 47, order: 22)
, Car(start: 34, end: 65, arr.t.: 78, delay: 00, est: 44, tot.arr.t: 78, order: 08)
, Car(start: 24, end: 60, arr.t.: 86, delay: 00, est: 49, tot.arr.t: 86, order: 21)
, Car(start: 37, end: 68, arr.t.: 84, delay: 00, est: 52, tot.arr.t: 84, order: 03)
, Car(start: 01, end: 42, arr.t.: 96, delay: 00, est: 54, tot.arr.t: 96, order: 16)
]
Result: 44,41,19,84,56,20,36,58,78,67,69,33,42,67,24,39,96,77,58,39,34,86,47,10,43
Process finished with exit code 0

30
CloudflightCodingContest/pom.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>at.salento</groupId>
<artifactId>CloudflightCodingContest</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

135
CloudflightCodingContest/src/main/java/at/salento/Car.java

@ -0,0 +1,135 @@
package at.salento;
public class Car {
private int startSegment;
private int endSegment;
private int arrivalTime;
private int order;
private int earliestStartTime; // introduced in level 2
private int delay;
private boolean entered = false;
private boolean toRemove = false; // not used at the moment
public Car() {
this.startSegment = 0;
this.endSegment = 0;
this.arrivalTime = 0;
this.order = 0;
this.delay = 0;
}
public Car(int start, int end, int duraction) {
this.startSegment = start;
this.endSegment = end;
this.arrivalTime = duraction;
this.order = 0;
this.delay = 0;
}
public Car(int start, int end, int duration, int order) {
this.startSegment = start;
this.endSegment = end;
this.arrivalTime = duration;
this.order = order;
this.delay = 0;
}
public int getStartSegment() {
return startSegment;
}
public void setStartSegment(int startSegment) {
this.startSegment = startSegment;
}
public int getEndSegment() {
return endSegment;
}
public void setEndSegment(int endSegment) {
this.endSegment = endSegment;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public int getArrivalTime() {
return arrivalTime;
}
public void setArrivalTime(int arrivalTime) {
this.arrivalTime = arrivalTime;
}
public void increaseArrivalTime() {
this.arrivalTime++;
}
public int getDelay() {
return delay;
}
public void increaseDelay() {
this.delay++;
}
public void setDelay(int delay) {
this.delay = delay;
}
public int getTotalArrivalTime() {
return this.arrivalTime + this.delay;
}
public boolean isEntered() {
return entered;
}
public void setEntered(boolean entered) {
this.entered = entered;
}
public boolean isToRemove() {
return toRemove;
}
public void setToRemove(boolean toRemove) {
this.toRemove = toRemove;
}
public int getEarliestStartTime() {
return earliestStartTime;
}
public void setEarliestStartTime(int earliestStartTime) {
this.earliestStartTime = earliestStartTime;
}
@Override
public String toString() {
String viz = "";
for (int i = 0; i< startSegment; i++) viz += " ";
viz += "|";
for (int i = startSegment +1; i < endSegment; i++) viz += "-";
viz += "|";
// for (int i=)
return String.format(" Car(start: %02d", startSegment)
+ String.format(", end: %02d", endSegment)
+ String.format(", arr.t.: %02d", arrivalTime)
+ String.format(", delay: %02d", delay)
+ String.format(", est: %02d", earliestStartTime)
+ String.format(", tot.arr.t: %02d", getTotalArrivalTime())
+ String.format(", order: %02d", order)
+ ") " + "\n";
}
}

12
CloudflightCodingContest/src/main/java/at/salento/CccException.java

@ -0,0 +1,12 @@
package at.salento;
public class CccException extends RuntimeException {
public CccException(String msg, Throwable t) {
super(msg, t);
}
public CccException(String msg) {
super(msg);
}
}

25
CloudflightCodingContest/src/main/java/at/salento/ComputationBase.java

@ -0,0 +1,25 @@
package at.salento;
public abstract class ComputationBase {
protected int level;
public ComputationBase(int level) {
this.level = level;
}
public void start(int fromLevel, int toLevel) {
String inputFilenameTemplate = "files/level" + level + "/level" + level + "_";
String outputFilenameTemplate = "files/level" + level + "/level" + level + "_";
for (int i=fromLevel; i<=toLevel; i++) {
String inputFilename = inputFilenameTemplate + i + ".in";
String outputFilename = outputFilenameTemplate + i + ".out";
startForInstance(inputFilename,outputFilename);
}
}
protected abstract void startForInstance(String inputFilename, String outputFilename);
}

63
CloudflightCodingContest/src/main/java/at/salento/FileIoBase.java

@ -0,0 +1,63 @@
package at.salento;
import java.io.*;
import java.util.ArrayList;
public class FileIoBase {
protected String inputFileName;
protected String outputFileName;
protected ArrayList<String> lines = new ArrayList<>();
public ArrayList<String> result = new ArrayList<>();
public FileIoBase(String inputFileName, String outputFileName) {
this.inputFileName = inputFileName;
this.outputFileName = outputFileName;
}
public void readData() {
try (BufferedReader br = new BufferedReader(new FileReader(inputFileName))) {
String line = br.readLine();
while (line != null) {
lines.add(line);
line = br.readLine();
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void writeToFile() {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(outputFileName))) {
for (String line : result) {
bw.write(line + "\n");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String getLine(int idx) {
if (lines != null) {
if (idx >= 0 && idx < lines.size()) {
return lines.get(idx);
} else {
throw new CccException("Invalid index: " + idx + " in method getLine.");
}
} else {
throw new CccException("Error: lines is null!");
}
}
@Override
public String toString() {
String ret = "Inputfile\n";
for (int i=0; i<lines.size(); i++) {
ret += String.format("Line %03d", i) + ": " + lines.get(i) + "\n";
}
return ret;
}
}

14
CloudflightCodingContest/src/main/java/at/salento/Main.java

@ -0,0 +1,14 @@
package at.salento;
import at.salento.level2.Level2Computation;
public class Main {
public static void main(String[] args) {
// ComputationBase l1 = new Level1ComputationNew();
// l1.start(2, 2);
ComputationBase l2 = new Level2Computation();
l2.start(3, 3);
}
}

119
CloudflightCodingContest/src/main/java/at/salento/level1/Level1ComputationSimulation.java

@ -0,0 +1,119 @@
package at.salento.level1;
import at.salento.Car;
import at.salento.ComputationBase;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class Level1ComputationSimulation extends ComputationBase {
private Level1Io level1Io;
private int nSegments;
private int nLines;
private ArrayList<Car> cars;
private ArrayList<Car> copyCars;
public Level1ComputationSimulation() {
super(1);
}
protected void startForInstance(String input, String computed) {
level1Io = new Level1Io(input, computed);
level1Io.readData();
nSegments = Integer.valueOf(level1Io.getLine(0));
nLines = Integer.valueOf(level1Io.getLine(1));
prepareCars();
simulate();
System.out.println("Copy Cars: " + copyCars);
List<Car> c3 = copyCars.stream()
.filter(x -> x != null)
.collect(Collectors.toList());
c3.sort(Comparator.comparing(Car::getOrder));
System.out.println("Cars in initial order:" + c3);
ArrayList<Car> orderedStartSegmentCars = new ArrayList<>(c3);
orderedStartSegmentCars.sort(Comparator.comparing(Car::getStartSegment));
System.out.println("Ordered due to start segment: " + orderedStartSegmentCars);
String strResult = buildResultString(c3);
System.out.println("Result: " + strResult);
level1Io.result.add(strResult);
level1Io.writeToFile();
}
private void prepareCars() {
cars = new ArrayList<>(Collections.nCopies(nSegments+1, null));
int order = 0;
for (int i=2; i < nLines+2; i++) {
Car c = createCarFromString(level1Io.getLine(i));
c.setOrder(order++);
cars.set(c.getStartSegment(), c);
}
copyCars = new ArrayList<>(cars);
System.out.println("Cars:" + cars);
}
private void simulate() {
for (int sec=1; sec < (2*nSegments+2); sec++) {
for (int i=0; i<=nSegments; i++) {
if (cars.get(i) != null) {
cars.get(i).increaseArrivalTime();
if (i < cars.get(i).getEndSegment()) {
if (cars.get(i + 1) == null) {
cars.set(i + 1, cars.get(i));
cars.set(i, null);
i++;
}
} else {
cars.set(i, null);
}
}
}
}
}
private static Car createCarFromString(String line) {
String[] tokens = line.split(",");
int start = Integer.valueOf(tokens[0]);
int end = Integer.valueOf(tokens[1]);
// int result = end - start + 2;
return new Car(start, end, 1);
}
private String buildResultString(List<Car> cars) {
String strResult = "";
boolean first = true;
for (int i=0; i<cars.size(); i++) {
if (cars.get(i) != null) {
if (!first) {
strResult += ",";
} else {
first = false;
}
strResult += cars.get(i).getTotalArrivalTime();
}
}
return strResult;
}
}

10
CloudflightCodingContest/src/main/java/at/salento/level1/Level1Io.java

@ -0,0 +1,10 @@
package at.salento.level1;
import at.salento.FileIoBase;
public class Level1Io extends FileIoBase {
public Level1Io(String inputFileName, String outputFileName) {
super(inputFileName, outputFileName);
}
}

188
CloudflightCodingContest/src/main/java/at/salento/level2/Level2Computation.java

@ -0,0 +1,188 @@
package at.salento.level2;
import at.salento.Car;
import at.salento.ComputationBase;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class Level2Computation extends ComputationBase {
private Level2Io level2Io;
private int nSegments;
private int nLines;
private ArrayList<Car> queue;
private ArrayList<Car> cars;
private ArrayList<Car> copyCars;
public Level2Computation() {
super(2);
}
protected void startForInstance(String input, String computed) {
level2Io = new Level2Io(input, computed);
level2Io.readData();
nSegments = Integer.valueOf(level2Io.getLine(0));
nLines = Integer.valueOf(level2Io.getLine(1));
prepareCars();
simulate();
System.out.println("Copy Cars: " + copyCars);
List<Car> c3 = copyCars.stream()
.filter(x -> x != null)
.collect(Collectors.toList());
c3.sort(Comparator.comparing(Car::getOrder));
System.out.println("Cars in initial order:" + c3);
ArrayList<Car> orderedStartSegmentCars = new ArrayList<>(c3);
orderedStartSegmentCars.sort(Comparator.comparing(Car::getStartSegment));
ArrayList<Car> orderedStartTimes = new ArrayList<>(c3);
orderedStartTimes.sort(Comparator.comparing(Car::getEarliestStartTime));
System.out.println("Ordered due to start segment: " + orderedStartSegmentCars);
System.out.println("Ordered due to earliest start times: " + orderedStartTimes);
String strResult = buildResultString(c3);
System.out.println("Result: " + strResult);
level2Io.result.add(strResult);
level2Io.writeToFile();
}
private void prepareCars() {
cars = new ArrayList<>(Collections.nCopies(nSegments+1, null));
queue = new ArrayList<>();
int order = 0;
for (int i=2; i < nLines+2; i++) {
Car c = createCarFromString(level2Io.getLine(i));
c.setOrder(order++);
queue.add(c);
}
copyCars = new ArrayList<>(queue);
System.out.println("Queue:" + queue);
}
private void simulate() {
int sec = 0;
do {
sec++;
// place new cars
for (int i = 0; i < queue.size(); i++) {
Car c = queue.get(i);
int nextSeg = c.getStartSegment();
// if (nextSeg < nSegments) nextSeg++;
int lastSeg = c.getStartSegment();
if (lastSeg > 0) lastSeg--;
if (c.getEarliestStartTime() <= sec
&& cars.get(c.getStartSegment()) == null
&& cars.get(nextSeg) == null
&& cars.get(lastSeg) == null
)
{
// System.out.println("in second " + sec + " placing car " + c);
queue.remove(i);
cars.set(c.getStartSegment(), c);
c.setEntered(true);
}
}
System.out.println("befor sim sec: " + sec + ": " + buildCarString());
// simulate for current second
for (int i = 1; i <= nSegments; i++) {
Car c = cars.get(i);
if (c != null) {
if (!c.isEntered()) {
if (i < c.getEndSegment()) {
if (cars.get(i + 1) == null) {
cars.set(i + 1, c);
cars.set(i, null);
i++;
}
} else {
c.setToRemove(true);
c.setArrivalTime(sec);
cars.set(i, null);
}
} else {
c.setEntered(false);
}
}
}
System.out.println("after sim sec: " + sec + ": " + buildCarString());
} while (!(cars.stream().filter(e -> (e != null)).count() == 0 && queue.isEmpty()));
}
/*
this example shows, that car (9) enters segment wrongly, as it was not empty in previous second!
sec: 28: (8) (2) (3)
sec: 29: (8) (2) (9) (3)
sec: 30: (8) (2) (9) (3)
sec: 31: (8) (2) (9) (3)
with this bugfix 2_1 works
*/
private static Car createCarFromString(String line) {
String[] tokens = line.split(",");
System.out.println(line);
int start = Integer.valueOf(tokens[0]);
int end = Integer.valueOf(tokens[1]);
int startTime = Integer.valueOf(tokens[2]);
// int result = end - start + 2;
Car c = new Car(start, end, 0);
c.setEarliestStartTime(startTime);
return c;
}
private String buildResultString(List<Car> cars) {
String strResult = "";
boolean first = true;
for (int i=0; i<cars.size(); i++) {
if (cars.get(i) != null) {
if (!first) {
strResult += ",";
} else {
first = false;
}
strResult += cars.get(i).getTotalArrivalTime();
}
}
return strResult;
}
private String buildCarString() {
String str = "";
for (int i=0; i<nSegments; i++) {
if (cars.get(i) != null) {
str += "(" + String.format("%02d", cars.get(i).getOrder()) + ") ";
} else {
str += " ";
}
}
return str;
}
}

9
CloudflightCodingContest/src/main/java/at/salento/level2/Level2Io.java

@ -0,0 +1,9 @@
package at.salento.level2;
import at.salento.FileIoBase;
public class Level2Io extends FileIoBase {
public Level2Io(String inputFileName, String outputFileName) {
super(inputFileName, outputFileName);
}
}

79
CloudflightCodingContest/src/test/java/at/salento/level1/Level1Testcases.java

@ -0,0 +1,79 @@
package at.salento.level1;
import at.salento.ComputationBase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.*;
class Level1Testcases {
private ComputationBase comp;
@BeforeEach
void setUp() {
comp = new Level1ComputationSimulation();
}
@Test
void validateInstance1() {
comp.start(1, 1);
Path out = Path.of("files/level1/level1_1.out");
Path sol = Path.of("files/level1/level1_1.sol");
try {
long fileCompare = filesCompareByByte(out, sol);
assertEquals(-1L, fileCompare); // !?
} catch (IOException e) {
fail("Exception in file handling: " + e.getMessage());
}
}
@ParameterizedTest
@CsvSource({"1,1", "1,2", "1,3", "1,4", "1, 5", "1, 6"})
void validateInstance2(int level, int testcase) {
String p1 = "files/level" + level + "/level" + level + "_";
String f1 = p1 + testcase + ".out";
String f2 = p1 + testcase + ".sol";
comp.start(testcase, testcase);
Path out = Path.of(f1);
Path sol = Path.of(f2);
try {
long fileCompare = filesCompareByByte(out, sol);
assertEquals(-1L, fileCompare); // !?
} catch (IOException e) {
fail("Exception in file handling: " + e.getMessage());
}
}
// Source: https://www.baeldung.com/java-compare-files
long filesCompareByByte(Path path1, Path path2) throws IOException {
try (BufferedInputStream fis1 = new BufferedInputStream(new FileInputStream(path1.toFile()));
BufferedInputStream fis2 = new BufferedInputStream(new FileInputStream(path2.toFile()))) {
int ch = 0;
long pos = 1;
while ((ch = fis1.read()) != -1) {
if (ch != fis2.read()) {
return pos;
}
pos++;
}
if (fis2.read() == -1) {
return -1;
}
else {
return pos;
}
}
}
}

110
CloudflightCodingContest/src/test/java/at/salento/level1/Level2Testcases.java

@ -0,0 +1,110 @@
package at.salento.level1;
import at.salento.ComputationBase;
import at.salento.level2.Level2Computation;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
class Level2Testcases {
private ComputationBase comp;
@BeforeEach
void setUp() {
comp = new Level2Computation();
}
@Test
void validateInstance0() {
comp.start(0, 0);
Path out = Path.of("files/level2/level2_0.out");
Path sol = Path.of("files/level2/level2_0.sol");
try {
long fileCompare = filesCompareByByte(out, sol);
assertEquals(-1L, fileCompare); // !?
} catch (IOException e) {
fail("Exception in file handling: " + e.getMessage());
}
}
@Test
void validateInstance1() {
comp.start(1, 1);
Path out = Path.of("files/level2/level2_1.out");
Path sol = Path.of("files/level2/level2_1.sol");
try {
long fileCompare = filesCompareByByte(out, sol);
assertEquals(-1L, fileCompare); // !?
} catch (IOException e) {
fail("Exception in file handling: " + e.getMessage());
}
}
@Test
void validateInstance2() {
comp.start(2, 2);
Path out = Path.of("files/level2/level2_2.out");
Path sol = Path.of("files/level2/level2_2.sol");
try {
long fileCompare = filesCompareByByte(out, sol);
assertEquals(-1L, fileCompare); // !?
} catch (IOException e) {
fail("Exception in file handling: " + e.getMessage());
}
}
@Disabled
@ParameterizedTest
@CsvSource({"1,1", "1,2", "1,3", "1,4", "1, 5", "1, 6"})
void validateInstance2(int level, int testcase) {
String p1 = "files/level" + level + "/level" + level + "_";
String f1 = p1 + testcase + ".out";
String f2 = p1 + testcase + ".sol";
comp.start(testcase, testcase);
Path out = Path.of(f1);
Path sol = Path.of(f2);
try {
long fileCompare = filesCompareByByte(out, sol);
assertEquals(-1L, fileCompare); // !?
} catch (IOException e) {
fail("Exception in file handling: " + e.getMessage());
}
}
// Source: https://www.baeldung.com/java-compare-files
long filesCompareByByte(Path path1, Path path2) throws IOException {
try (BufferedInputStream fis1 = new BufferedInputStream(new FileInputStream(path1.toFile()));
BufferedInputStream fis2 = new BufferedInputStream(new FileInputStream(path2.toFile()))) {
int ch = 0;
long pos = 1;
while ((ch = fis1.read()) != -1) {
if (ch != fis2.read()) {
return pos;
}
pos++;
}
if (fis2.read() == -1) {
return -1;
}
else {
return pos;
}
}
}
}
Loading…
Cancel
Save