problem 10 11 12

This commit is contained in:
Xevion
2019-09-19 07:35:53 -05:00
parent a34a4bacb7
commit d3d823f6c3
26 changed files with 402 additions and 10 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<projectDescription>
<name>10</name>
<comment/>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@@ -0,0 +1,11 @@
{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - problem10",
"request": "launch",
"mainClass": "problem10",
"projectName": "10"
}
]
}

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -0,0 +1,10 @@
4
this paragraph was fun to write i love to write fun assignments
having work to do is very fun my favorite subject is english but
i also love to write programs which is a close second but not
bad this bad assignment was bad bad bad bad and bad
4
fun diverting festive
love enjoy relish
write scribe code
bad horrible bitter terrible evil base rancid

View File

@@ -0,0 +1,94 @@
import static java.lang.System.*;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
class Synonym {
int index = 0;
List<String> synonyms;
Synonym(String[] synonyms) {
this.synonyms = Arrays.asList(synonyms);
}
String next() {
return synonyms.get(this.index++ % synonyms.size());
}
}
class SynonymOrganizer {
Map<String, Integer> points = new HashMap<String, Integer>();
List<Synonym> synonyms = new ArrayList<Synonym>();
// Takes lines of synonyms
SynonymOrganizer(String[] synlines) {
int creationIndex = 0;
// Iterate over each line and process synonyms
for(String line : synlines) {
// Get all words in synonym list
String[] words = line.split("\\s");
for(String word : words) {
// Can switch off to using Map<String, ArrayList<Integer>> for multi-value synonyms instead of singular
if(points.containsKey(word))
out.println("Word \"" + word + "\" already used for previous synonym, overwriting.");
points.put(word, creationIndex);
}
// Add the list of synonyms with new Synonym object
synonyms.add(new Synonym(words));
// Increment for next pointer
creationIndex++;
}
}
boolean hasSynonym(String word) {
return points.containsKey(word);
}
// Gets a synonym, increments synonym object index
String getSynonym(String word) {
// Pointless in a perfect world
if(!points.containsKey(word)) {
out.println("Word\"" + word + "\"had no synonyms!");
}
// Retriever integer map pointer, then return next synonym
int pointer = points.get(word);
return synonyms.get(pointer).next();
}
}
public class problem10 {
public static void main(String[] args) throws FileNotFoundException {
// Initial Constants
File input = new File("input.dat");
Scanner read = new Scanner(input);
// Read paragraph lines
String[] rawParagraph = new String[Integer.parseInt(read.nextLine())];
for(int i = 0; i < rawParagraph.length; i++)
rawParagraph[i] = read.nextLine();
// Read synonym lines
String[] synonymLines = new String[Integer.parseInt(read.nextLine())];
for(int i = 0; i < synonymLines.length; i++)
synonymLines[i] = read.nextLine();
// Start processing the paragraph
SynonymOrganizer organizer = new SynonymOrganizer(synonymLines);
for(String line : rawParagraph) {
String[] words = line.split("\\s");
for(int i = 0; i < words.length; i++) {
// Replace if organizer has a synonym
if(organizer.hasSynonym(words[i])) {
words[i] = organizer.getSynonym(words[i]);
}
}
out.println(String.join(" ", words));
}
read.close();
}
}

26
uil/october-2013/11/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - problem11",
"request": "launch",
"mainClass": "problem11"
},
{
"type": "java",
"name": "CodeLens (Launch) - problem9",
"request": "launch",
"mainClass": "problem9"
},
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
}
]
}

View File

@@ -0,0 +1,3 @@
1
2
3

View File

Binary file not shown.

View File

@@ -0,0 +1,14 @@
import static java.lang.System.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class problem11 {
public static void main(String[] args) throws FileNotFoundException {
File input = new File("input.dat");
Scanner read = new Scanner(input);
while(read.hasNextInt())
out.println(read.nextInt() * 3);
read.close();
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<projectDescription>
<name>12</name>
<comment/>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

11
uil/october-2013/12/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - problem12",
"request": "launch",
"mainClass": "problem12",
"projectName": "12"
}
]
}

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -0,0 +1,9 @@
1
B B
B B B
B B B
B B
B B R
R R R R
R R R R
R R R

View File

@@ -0,0 +1,52 @@
import static java.lang.System.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
class Point {
int x;
int y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
}
class CheckerBoard {
Point[] offsets = {Point(1, 1), Point(-1, -1), Point(-1, 1), Point(1, -1)};
CheckerBoard(String[][] matrix) {
}
int[][] getPossible(int x, int y) {
return getPossible(x, y, new int[0][0]);
}
int[][] getPossible(int x, int y, List<Point> blacklist) {}
}
class problem12 {
public static void main(String[] args) throws FileNotFoundException {
// Constants
File input = new File("input.dat");
Scanner read = new Scanner(input);
int lines = Integer.parseInt(read.nextLine());
// Start reading and processing the matrix into
for(int i = 0; i < lines; i++) {
String[][] rawMatrix = new String[8][8];
for(int x = 0; x < 8; x++) {
String line = read.nextLine();
for(int y = 0; y < 8; y++)
rawMatrix[x][y] = line.substring(y, y+1);
}
out.println(Arrays.deepToString(rawMatrix));
CheckerBoard cb = new CheckerBoard(rawMatrix);
out.println(cb.scan());
}
read.close();
}
}

View File

@@ -0,0 +1,10 @@
{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch) - problem3",
"request": "launch",
"mainClass": "problem3"
}
]
}

View File

@@ -0,0 +1,20 @@
F
F
F
XXX
F
F
UUUUULL
UULULUL
UUUUUURUULL
DRDRDD

View File

@@ -2,18 +2,90 @@ import static java.lang.System.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
class Point {
int x;
int y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
}
class Maze {
int[][] offsets = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
String[][] rawMatrix;
Set<Point> snake;
Set<Point> pellets;
Maze(String[][] rawMatrix) {
this.rawMatrix = rawMatrix;
snake = new ArrayList<Point>();
for(int x = 0; x < 15; x++) {
for(int y = 0; y < 15; y++) {
switch(rawMatrix[x][y]) {
case " ":
break;
case "X":
snake.add(new Point(x, y));
break;
case "F":
pellets.add(new Point(x, y));
break;
default:
out.println("Possibly faulty Maze Input with item \"" + rawMatrix[x][y] + "\" found.");
break;
}
}
}
}
// Simulate the snake game using instructions
String simulate(String input) {
return "";
}
boolean inBounds(int x, int y) {
return x >= 0 && y >= 0 && x < 15 && y < 15;
}
// Prints a string representation of the Maze
String toString() {
String[] lines = new String[15];
for(int x = 0; x < 15; x++) {
String[] temp = "";
for(int y = 0; y < 15; y++) {
temp[y] = rawMatrix[x][y];
}
lines[x] = String.join(" - ", temp);
}
return String.join("\n", lines);
}
}
public class problem3 {
public static void main(String[] args ) throws FileNotFoundException {
// Constants
File input = new File("input1.dat");
File input = new File("input.dat");
Scanner read = new Scanner(input);
int lines = read.nextInt();
read.nextLine();
// Driver Code
for (int i = 0; i < lines; i++)
out.println(read.nextLine().length() <= 140 ? "tweet" : "not a tweet");
// Read the maze into a String matrix
char[][] rawMatrix = new String[15][15];
for(int x = 0; x < 15; x++) {
String line = read.nextLine();
for(int y = 0; y < 15; y++) {
rawMatrix[x][y] = line.charAt(y);
}
}
// Read each of the inputs and process inside the maze
int lines = Integer.parseInt(read.nextLine());
String[] inputs = new String[lines];
for(int i = 0; i < lines; i++)
inputs[i] = read.nextLine();
}
}

View File

@@ -18,6 +18,7 @@
<session id="-929831496">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.closed" value="1" />
<entry key="project.open.time.1" value="1" />
<entry key="project.opened" value="1" />
</counts>
@@ -119,7 +120,7 @@
</panes>
</component>
<component name="PropertiesComponent">
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1568706140528" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1568706145579" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
@@ -162,7 +163,6 @@
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Image Layers" />
<window_info id="Designer" />
@@ -177,7 +177,7 @@
<window_info anchor="bottom" id="Messages" weight="0.32939914" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32939914" />
<window_info anchor="bottom" id="Run" order="2" weight="0.32939914" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />