mirror of
https://github.com/Xevion/contest.git
synced 2025-12-15 06:11:26 -06:00
problem 7 finish
This commit is contained in:
36
uil/october-2013/7/.idea/workspace.xml
generated
36
uil/october-2013/7/.idea/workspace.xml
generated
@@ -2,10 +2,7 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="bb180874-2412-4c96-b84b-4eb63b971832" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/input.dat" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/problem7.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../6/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../6/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/problem7.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/problem7.java" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
@@ -24,25 +21,25 @@
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.open">
|
||||
<counts>
|
||||
<entry key="dat" value="1" />
|
||||
<entry key="dat" value="2" />
|
||||
<entry key="java" value="1" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.open">
|
||||
<counts>
|
||||
<entry key="JAVA" value="1" />
|
||||
<entry key="PLAIN_TEXT" value="1" />
|
||||
<entry key="PLAIN_TEXT" value="2" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.edit">
|
||||
<counts>
|
||||
<entry key="dat" value="532" />
|
||||
<entry key="java" value="1745" />
|
||||
<entry key="java" value="3129" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.edit">
|
||||
<counts>
|
||||
<entry key="JAVA" value="1745" />
|
||||
<entry key="JAVA" value="3129" />
|
||||
<entry key="PLAIN_TEXT" value="532" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
@@ -53,8 +50,8 @@
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/problem7.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="356">
|
||||
<caret line="29" lean-forward="true" selection-start-line="29" selection-end-line="29" />
|
||||
<state relative-caret-position="424">
|
||||
<caret line="51" selection-start-line="51" selection-end-line="51" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@@ -65,8 +62,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/input.dat">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="255">
|
||||
<caret line="15" column="17" selection-start-line="15" selection-start-column="9" selection-end-line="15" selection-end-column="17" />
|
||||
<state relative-caret-position="102">
|
||||
<caret line="6" column="29" lean-forward="true" selection-start-line="6" selection-start-column="29" selection-end-line="6" selection-end-column="29" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -80,6 +77,11 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>tortillas</find>
|
||||
</findStrings>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../.." />
|
||||
</component>
|
||||
@@ -128,7 +130,7 @@
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1568702269577" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1568703586398" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
@@ -207,15 +209,15 @@
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/input.dat">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="255">
|
||||
<caret line="15" column="17" selection-start-line="15" selection-start-column="9" selection-end-line="15" selection-end-column="17" />
|
||||
<state relative-caret-position="102">
|
||||
<caret line="6" column="29" lean-forward="true" selection-start-line="6" selection-start-column="29" selection-end-line="6" selection-end-column="29" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/problem7.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="356">
|
||||
<caret line="29" lean-forward="true" selection-start-line="29" selection-end-line="29" />
|
||||
<state relative-caret-position="424">
|
||||
<caret line="51" selection-start-line="51" selection-end-line="51" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
||||
Binary file not shown.
@@ -2,6 +2,7 @@ import static java.lang.System.*;
|
||||
import java.util.Arrays;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class problem7 {
|
||||
@@ -16,39 +17,38 @@ public class problem7 {
|
||||
for(int i = 0; i < lines; i++) {
|
||||
// Process all lines into primitive String arrays
|
||||
int listLines = read.nextInt();
|
||||
read.nextLine();
|
||||
String rawGroceryList = "";
|
||||
String rawReceiptList = "";
|
||||
for(int x = 0; x < listLines; x++) rawGroceryList += read.nextLine();
|
||||
for(int x = 0; x < listLines; x++) rawReceiptList += read.nextLine();
|
||||
String[] groceryList = rawGroceryList.split("\\s");
|
||||
String[] receiptList = rawReceiptList.split("\\s");
|
||||
out.println(Arrays.toString(groceryList));
|
||||
out.println(Arrays.toString(receiptList));
|
||||
}
|
||||
}
|
||||
|
||||
// Processes all words in
|
||||
static String[] processWords(String[] lines) {
|
||||
int length = 0;
|
||||
// Count how long the final array should be
|
||||
for (String line : lines) {
|
||||
Scanner counter = new Scanner(line);
|
||||
while (counter.hasNext()) {
|
||||
counter.next();
|
||||
length++;
|
||||
}
|
||||
}
|
||||
// Begin inserting into an array
|
||||
String[] output = new String[length];
|
||||
int i = 0;
|
||||
for (String line : lines) {
|
||||
Scanner reader = new Scanner(line);
|
||||
while (reader.hasNext()) {
|
||||
output[i] = reader.next();
|
||||
i++;
|
||||
read.nextLine();
|
||||
// Process all lines into words
|
||||
for(int x = 0; x < listLines; x++)
|
||||
rawGroceryList += read.nextLine() + "\n";
|
||||
for(int x = 0; x < listLines; x++)
|
||||
rawReceiptList += read.nextLine() + "\n";
|
||||
// Split by any whitespace sequence into ArrayLists
|
||||
List<String> groceryList = Arrays.asList(rawGroceryList.split("\\s+"));
|
||||
List<String> receiptList = Arrays.asList(rawReceiptList.split("\\s+"));
|
||||
// Find which to put back
|
||||
String putBack = "PUT BACK";
|
||||
for(String item : receiptList) {
|
||||
if(groceryList.indexOf(item) == -1)
|
||||
putBack += " " + item;
|
||||
}
|
||||
// Find which to buy more of
|
||||
String buyMore = "BUY MORE";
|
||||
for(String item : groceryList) {
|
||||
if(receiptList.indexOf(item) == -1)
|
||||
buyMore += " " + item;
|
||||
}
|
||||
// Process and return final putback/buymore consensus
|
||||
if(putBack.equals("PUT BACK") && buyMore.equals("BUY MORE"))
|
||||
out.println("OK");
|
||||
else if (!putBack.equals("PUT BACK") && buyMore.equals("BUY MORE"))
|
||||
out.println(putBack);
|
||||
else if (putBack.equals("PUT BACK") && !buyMore.equals("BUY MORE"))
|
||||
out.println(buyMore);
|
||||
else
|
||||
out.println(putBack + "\n" + buyMore);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user