From d3d823f6c326e32a0672e29eb5179e80c218a8ae Mon Sep 17 00:00:00 2001 From: Xevion Date: Thu, 19 Sep 2019 07:35:53 -0500 Subject: [PATCH] problem 10 11 12 --- uil/october-2013/10/10/.classpath | 6 ++ uil/october-2013/10/10/.project | 17 ++++ .../10/.settings/org.eclipse.jdt.core.prefs | 7 ++ uil/october-2013/10/10/.vscode/launch.json | 11 ++ uil/october-2013/10/10/bin/Synonym.class | Bin 0 -> 773 bytes .../10/10/bin/SynonymOrganizer.class | Bin 0 -> 2318 bytes uil/october-2013/10/10/bin/problem10.class | Bin 0 -> 1832 bytes uil/october-2013/10/10/input.dat | 10 ++ uil/october-2013/10/10/src/problem10.java | 94 ++++++++++++++++++ uil/october-2013/11/.vscode/launch.json | 26 +++++ uil/october-2013/11/input.dat | 3 + .../11/out/production/11/problem11.class | Bin 0 -> 1296 bytes uil/october-2013/11/src/problem11.java | 14 +++ uil/october-2013/12/.classpath | 6 ++ uil/october-2013/12/.project | 17 ++++ .../12/.settings/org.eclipse.jdt.core.prefs | 7 ++ uil/october-2013/12/.vscode/launch.json | 11 ++ uil/october-2013/12/bin/CheckerBoard.class | Bin 0 -> 1335 bytes uil/october-2013/12/bin/Point.class | Bin 0 -> 342 bytes uil/october-2013/12/bin/problem12.class | Bin 0 -> 550 bytes uil/october-2013/12/input.dat | 9 ++ uil/october-2013/12/src/problem12.java | 52 ++++++++++ uil/october-2013/3/java/.vscode/launch.json | 10 ++ uil/october-2013/3/java/input.dat | 20 ++++ uil/october-2013/3/java/src/problem3.java | 86 ++++++++++++++-- uil/october-2013/9/.idea/workspace.xml | 6 +- 26 files changed, 402 insertions(+), 10 deletions(-) create mode 100644 uil/october-2013/10/10/.classpath create mode 100644 uil/october-2013/10/10/.project create mode 100644 uil/october-2013/10/10/.settings/org.eclipse.jdt.core.prefs create mode 100644 uil/october-2013/10/10/.vscode/launch.json create mode 100644 uil/october-2013/10/10/bin/Synonym.class create mode 100644 uil/october-2013/10/10/bin/SynonymOrganizer.class create mode 100644 uil/october-2013/10/10/bin/problem10.class create mode 100644 uil/october-2013/10/10/input.dat create mode 100644 uil/october-2013/10/10/src/problem10.java create mode 100644 uil/october-2013/11/.vscode/launch.json create mode 100644 uil/october-2013/11/input.dat create mode 100644 uil/october-2013/11/out/production/11/problem11.class create mode 100644 uil/october-2013/11/src/problem11.java create mode 100644 uil/october-2013/12/.classpath create mode 100644 uil/october-2013/12/.project create mode 100644 uil/october-2013/12/.settings/org.eclipse.jdt.core.prefs create mode 100644 uil/october-2013/12/.vscode/launch.json create mode 100644 uil/october-2013/12/bin/CheckerBoard.class create mode 100644 uil/october-2013/12/bin/Point.class create mode 100644 uil/october-2013/12/bin/problem12.class create mode 100644 uil/october-2013/12/input.dat create mode 100644 uil/october-2013/12/src/problem12.java create mode 100644 uil/october-2013/3/java/.vscode/launch.json create mode 100644 uil/october-2013/3/java/input.dat diff --git a/uil/october-2013/10/10/.classpath b/uil/october-2013/10/10/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/uil/october-2013/10/10/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/uil/october-2013/10/10/.project b/uil/october-2013/10/10/.project new file mode 100644 index 0000000..a3e3a53 --- /dev/null +++ b/uil/october-2013/10/10/.project @@ -0,0 +1,17 @@ + + + 10 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/uil/october-2013/10/10/.settings/org.eclipse.jdt.core.prefs b/uil/october-2013/10/10/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/uil/october-2013/10/10/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/uil/october-2013/10/10/.vscode/launch.json b/uil/october-2013/10/10/.vscode/launch.json new file mode 100644 index 0000000..73488eb --- /dev/null +++ b/uil/october-2013/10/10/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - problem10", + "request": "launch", + "mainClass": "problem10", + "projectName": "10" + } + ] +} \ No newline at end of file diff --git a/uil/october-2013/10/10/bin/Synonym.class b/uil/october-2013/10/10/bin/Synonym.class new file mode 100644 index 0000000000000000000000000000000000000000..bb4d8b9a1c10ca6c88e7c01d33830fe65394a802 GIT binary patch literal 773 zcmZuvTWb?R6#mX;n{ARc*EU-3t*vgh+Enl@r67V3SQLx|)R#`uAx=qV%kD-Rf0aUu z)(7#~A0?jIY$2^a?6Bv|cfQMEe*gLL6Tma%Z>B>%n>eru)g$pqw8uh^+OG#k za+na7ls=Rv1nLr&<2g2FWROCqi5j;96(=1+p{GV#B-2O|Hm_Xo&Fhr8mqbdBI{Q45 z-&0y8`-G5^`RvUjU)*VhQ;oR?u{?dSN~F^E`^gEOv1n zH&{Z%#vftplEge-r**|=$57vN;b56i36z$vrjvn;-ipDPW7UIjD8_veDN|=nJNc-1 zBZVN_B`Q3fYWykwB^FbHrFG` zjH_OEkuuBX;K{{W7L*9ZUO0`0@})9~%EwX2Q6^7!cZ@FXbN(DZ4~swEFP|{W;BJBc zEELn55?tl za%FH1?lCXe#d^jcunW`K@K3SkzdJ?ky?tO*xID)O;rJY$gAfkL3wVzC9$ZL*{b>2BO?T8b#n z$T;JhFFxpu4~#SN;sZF+Qkh|V_SxTKJ$JK76I!Oz-M#nw?)RO0&bc@L{P)*O0LSo+ zf`CBhZz}IMOiu}f&e{b-MG&1DG;9+HrqWXiwhL@q-^~TRGRGaM zh@mqAR@2aib_H(;Y+uhh?Kt|9gr#CvEpLy82-Gn43IuLcRCHs%f@BMeH7FW-a6q7~ zQZAXK^k8Zeu$yckinnl3L9f7;br=MyA%(O+G;dq3Zd#Q~#*#q1xoAziY0J03Xp~rGUJ4XlNjbAy<9e|g23Ts%=Od_-1z;nVT=e2_9XQZ!4;O0)rwI_ z-m;x!*)bMOyIM*5Ryvfl7Yt|7FjR1hlT~#wi6KvY~%GR7_w}3bG}Nk8w=_&%)Mq6G8O{AjWt;<7l-K`%7>4gke$Oo;kgcwCuXWD*L5yJcwVwA%*N9&{F#KGD+8v`zjV_NBU?= zI)pV+=`ktQU0KsR&MkiN>q%L^)No&VIb<1k*;euHXM-@*NxSOgjdP}yZ)@4HsoVVE zz!6C;lDyY~y#E9I=jFzc;*G+5@)B!|qh1z$!@O->EYtAUBR(Lcp1lISw5C=Y8j_%nO)CuZWXy8u04#1cqFbq zT6@mO?iZMtPADt*Xcboj3PPeefSlJ@EdcU@RFSIYP9qD6xVTsZ~65pZjz!d{D{x+Icd#c z5jtks^Ehne8C6($7zNISVQ|g&Xj?-XiUOg4SAvi)U=4eq`Ev@oy;&J(ga$^9!B$y)RY6|mW40x`HO0N4oQGRDaz~fFD1sL==*jY+jA3D9R5zS+f6o03n>9oY5_0XWKFjwyK%D-s;`}K zMqZt9eB{MGGWgIkbnJ^SjwAnp|AXT{VEoRe4Jj=?>^WzDx9@lP&iUitC))t7pr9cn z5UqIbQpqY`zNA4BIJ{zhZKg`5Q%ub)typC+KPy+F+n>R}frf19l9iiec+f{*Bwh1`QU}e*G1desz&OQUq`JU|* zhb5Rkb}w&LeA{)Z8sY+{0xR21joT$_+V#iXnp0@nXgDfhw3bTBo zdB!W6j{S|yybpsi^Nt8E354!cb@X7!z-zc7pjIm-n>ZH_YQ_OGkx1@Q-z%Z`TylDAN^9u*z?Qd2T*Kl3KJA12Lt@>8kz`GbBC*7KCQ^S=LnI(06 z_QNvE!x7vN5NBn*;|6YGf_z(XCEvzc;YXKEFK2yKvz)v&+*A>|$!J0w%Csfh;;9W>&gkKEY#ry5YEn|H#AJR8Ow1@PcV=m{I$H!P?<416xvF3Oh!|_0-67>t*W@MGvqm2G3$GCySQhE5G#JaFWC9VgJ%Ds0GOb)13zoLu7rBLsy&orxLy Z)f##NgGP{(p*nN@pD3()iMfT4{|`7ApZx#; literal 0 HcmV?d00001 diff --git a/uil/october-2013/10/10/input.dat b/uil/october-2013/10/10/input.dat new file mode 100644 index 0000000..a28a893 --- /dev/null +++ b/uil/october-2013/10/10/input.dat @@ -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 \ No newline at end of file diff --git a/uil/october-2013/10/10/src/problem10.java b/uil/october-2013/10/10/src/problem10.java new file mode 100644 index 0000000..88f043e --- /dev/null +++ b/uil/october-2013/10/10/src/problem10.java @@ -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 synonyms; + Synonym(String[] synonyms) { + this.synonyms = Arrays.asList(synonyms); + } + + String next() { + return synonyms.get(this.index++ % synonyms.size()); + } +} + + +class SynonymOrganizer { + Map points = new HashMap(); + List synonyms = new ArrayList(); + + // 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> 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(); + } +} diff --git a/uil/october-2013/11/.vscode/launch.json b/uil/october-2013/11/.vscode/launch.json new file mode 100644 index 0000000..ef6c5d0 --- /dev/null +++ b/uil/october-2013/11/.vscode/launch.json @@ -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}" + } + ] +} \ No newline at end of file diff --git a/uil/october-2013/11/input.dat b/uil/october-2013/11/input.dat new file mode 100644 index 0000000..5f5fbe7 --- /dev/null +++ b/uil/october-2013/11/input.dat @@ -0,0 +1,3 @@ +1 +2 +3 \ No newline at end of file diff --git a/uil/october-2013/11/out/production/11/problem11.class b/uil/october-2013/11/out/production/11/problem11.class new file mode 100644 index 0000000000000000000000000000000000000000..2e52de70a503b1705d61b2dc47011878d72ff1dd GIT binary patch literal 1296 zcmZux+fx%)9R5zS$qCDHOGqjpYEd+(CE8M21@XqEXb9?3r}Xl0NOoW~+0AS=9enRU zL7#kZh8JGi2XJ(ze?b45K6V^2erH1zXMD)H{I1{k`_AUycdz~dFohpY^y6!ZZ&H{t z5yQ6<(m@(0Z*)H6`TnaZ+xMkut?nvB~m={RSx}F=(3B>agj|Ggo ze#H^!E4rRjYSuQKU`=gQX-OCTvZ_8-fvfLFMkCyE8v<6e*kRy$n=`tD*yeAUzh`XjHf(2`2k|o#Rj|oona|`2BwVlF3JeT}iW8DJBe5W{NZbqCWv3pxzSodg z5|D1=LEzTN*2phU5RxDf)ApM|+0pG-utRiGbF(mjw15@yJc1<96+xY>s8IWV5EzL3 z$DwJ*vW0uNZ=r}4iIRm?Jh1Q;CM6zPcm$gu?1i7!DNJc~jfgF*>0+r40)hUI^IhF| z;*>d_Oa}^icp<0msM;riZ6O3kJAs;4$qyI(rdRne4uNd`^Xd&8**gMgMa?bMC^_5V zvPT4bMjV{DC??Vt#fVeX(WYec&=c45S) z6Mv&So7h1rZS5kF?%7B0ZtIl>6^}rTA;ohFCP8G-jbTC?M-P_Ji*@q*l?*lDIf6RP z?|B#_%pB(*z)7AA#-%ZeQ~cZsnGt8Wo3J^XF;dL%m7T>oQX8jz9?3&wB+g4*IK&kp zZiyD#Bqj1~qYxaN#6*j!pIT$IN?iP(eJ-(*!GOy|%@-SW0cz|Kqi1N?sLYNSFEB7X zQvVZ)_}(9)wcGm7*rT&eITwK)B;hOx<|y1CRX7pR%&~|;*qWx6aEM}#aM$on#NWaY O)*I#vT%jd~tM37K75YX1 literal 0 HcmV?d00001 diff --git a/uil/october-2013/11/src/problem11.java b/uil/october-2013/11/src/problem11.java new file mode 100644 index 0000000..c715c30 --- /dev/null +++ b/uil/october-2013/11/src/problem11.java @@ -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(); + } +} \ No newline at end of file diff --git a/uil/october-2013/12/.classpath b/uil/october-2013/12/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/uil/october-2013/12/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/uil/october-2013/12/.project b/uil/october-2013/12/.project new file mode 100644 index 0000000..b50b807 --- /dev/null +++ b/uil/october-2013/12/.project @@ -0,0 +1,17 @@ + + + 12 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/uil/october-2013/12/.settings/org.eclipse.jdt.core.prefs b/uil/october-2013/12/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/uil/october-2013/12/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/uil/october-2013/12/.vscode/launch.json b/uil/october-2013/12/.vscode/launch.json new file mode 100644 index 0000000..1dfdcba --- /dev/null +++ b/uil/october-2013/12/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - problem12", + "request": "launch", + "mainClass": "problem12", + "projectName": "12" + } + ] +} \ No newline at end of file diff --git a/uil/october-2013/12/bin/CheckerBoard.class b/uil/october-2013/12/bin/CheckerBoard.class new file mode 100644 index 0000000000000000000000000000000000000000..e0336f37f8e53a166ff3418f614666e32069d5c3 GIT binary patch literal 1335 zcmds1O>fgc5Pcg$oVaPy2KqtyTHumM6&0u_66HVvDUyLo36+pfjc2J zb-H|?lW1_6@TnSzNGkG=wBeR)?c0gq%Q^j@5JO>)b&^QpX~D=o_he#Q8BOg5kBp92 zQ^Jjigh{y7*?BApNDXJyr4Vi@l{^fT(w6rH+0Uy)9zkaJ6RQbX*8jR5E?iX0aInF! zRbSmWRga4LVjA~_=>?P{L(S7+Fg^*4O!fI@-i{Nof^t``^Q;pK635MsEC^kPcF{l;u12r zT|G6ScqUVZEAz2?@bG>*tPbwb0H-MQNIajlNRNgq0SCh+dO{d|mr)>@Y7UCDQ=-)& z={fqlAK|{PmEWWCnY0`>Nft7%P1I;z&ekrj;3{dr7PglVQp_2`&I*Lx-ymG0d-ljP dhwF=2@(ZLJE0Fe9Amwl?!?=yR^v_dN{5vKDa0mbZ literal 0 HcmV?d00001 diff --git a/uil/october-2013/12/bin/Point.class b/uil/october-2013/12/bin/Point.class new file mode 100644 index 0000000000000000000000000000000000000000..1ffdf68decc2a480894e8b2d5811cfcf0569da7c GIT binary patch literal 342 zcmXX>O-sX25S*8!NlnwF#!t{gk8KVX#hcB&MQ2%R>=7_yhb= z;=Jf#hTUOjXZQQ(^9#T+b{!Z3z3W<4tpiJ7G?y=OR?6yOc9qSGycH0yL`=L1*r%#e z?HMhTIG&~g)_HwjxG>>)=wm2gPNwM^1Og8|*t%Nx;J~JmsH(VJF0!Jzm04K`gh`#t zGL?#NxGv>1l*f?+2qBA(iZ=zsX4niJUY;qV$1-OuNVaL$k1tILG+;y za9Q1PLeB-!2L{pJ3VyV|!swlnfsh=+BD>@PO&)vNBW0jdmJMV2zrxk_crxO3Cj$uK9t616h|omp$_ zB$gTOuCwkx Otf*l5;tcCWY~vTLU3)_S literal 0 HcmV?d00001 diff --git a/uil/october-2013/12/input.dat b/uil/october-2013/12/input.dat new file mode 100644 index 0000000..4ed0810 --- /dev/null +++ b/uil/october-2013/12/input.dat @@ -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 \ No newline at end of file diff --git a/uil/october-2013/12/src/problem12.java b/uil/october-2013/12/src/problem12.java new file mode 100644 index 0000000..f98ece6 --- /dev/null +++ b/uil/october-2013/12/src/problem12.java @@ -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 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(); + } +} \ No newline at end of file diff --git a/uil/october-2013/3/java/.vscode/launch.json b/uil/october-2013/3/java/.vscode/launch.json new file mode 100644 index 0000000..cb957fb --- /dev/null +++ b/uil/october-2013/3/java/.vscode/launch.json @@ -0,0 +1,10 @@ +{ + "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - problem3", + "request": "launch", + "mainClass": "problem3" + } + ] +} \ No newline at end of file diff --git a/uil/october-2013/3/java/input.dat b/uil/october-2013/3/java/input.dat new file mode 100644 index 0000000..e44cf9f --- /dev/null +++ b/uil/october-2013/3/java/input.dat @@ -0,0 +1,20 @@ + + F + F + + F + + + + + XXX + + + + F + F + +UUUUULL +UULULUL +UUUUUURUULL +DRDRDD \ No newline at end of file diff --git a/uil/october-2013/3/java/src/problem3.java b/uil/october-2013/3/java/src/problem3.java index 9307636..6a3c6d1 100644 --- a/uil/october-2013/3/java/src/problem3.java +++ b/uil/october-2013/3/java/src/problem3.java @@ -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 snake; + Set pellets; + + Maze(String[][] rawMatrix) { + this.rawMatrix = rawMatrix; + snake = new ArrayList(); + + 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(); } } \ No newline at end of file diff --git a/uil/october-2013/9/.idea/workspace.xml b/uil/october-2013/9/.idea/workspace.xml index 77257f2..be4612b 100644 --- a/uil/october-2013/9/.idea/workspace.xml +++ b/uil/october-2013/9/.idea/workspace.xml @@ -18,6 +18,7 @@ + @@ -119,7 +120,7 @@ - + - @@ -177,7 +177,7 @@ - +