From ccafb619f1b71d11381cf8e77a5a168cbeda114d Mon Sep 17 00:00:00 2001 From: ANELLY KOVALSKI SANTANA <124692976+anellykovalski@users.noreply.github.com> Date: Thu, 1 May 2025 21:03:34 -0300 Subject: [PATCH] Add files via upload --- Randomized/pom.xml | 32 +++++++++ .../examples/ClosestPairRandomized.java | 37 ++++++++++ .../examples/ClosestPairRandomizedTest.java | 34 +++++++++ .../ClosestPairRandomized$Point.class | Bin 0 -> 554 bytes .../examples/ClosestPairRandomized.class | Bin 0 -> 1966 bytes .../compile/default-compile/createdFiles.lst | 2 + .../compile/default-compile/inputFiles.lst | 1 + .../default-testCompile/createdFiles.lst | 1 + .../default-testCompile/inputFiles.lst | 1 + ...est.examples.ClosestPairRandomizedTest.xml | 65 ++++++++++++++++++ ...est.examples.ClosestPairRandomizedTest.txt | 4 ++ .../examples/ClosestPairRandomizedTest.class | Bin 0 -> 1525 bytes 12 files changed, 177 insertions(+) create mode 100644 Randomized/pom.xml create mode 100644 Randomized/src/main/java/learningspace/swtest/examples/ClosestPairRandomized.java create mode 100644 Randomized/src/test/java/learningspace/swtest/examples/ClosestPairRandomizedTest.java create mode 100644 Randomized/target/classes/learningspace/swtest/examples/ClosestPairRandomized$Point.class create mode 100644 Randomized/target/classes/learningspace/swtest/examples/ClosestPairRandomized.class create mode 100644 Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 Randomized/target/surefire-reports/TEST-learningspace.swtest.examples.ClosestPairRandomizedTest.xml create mode 100644 Randomized/target/surefire-reports/learningspace.swtest.examples.ClosestPairRandomizedTest.txt create mode 100644 Randomized/target/test-classes/learningspace/swtest/examples/ClosestPairRandomizedTest.class diff --git a/Randomized/pom.xml b/Randomized/pom.xml new file mode 100644 index 000000000000..ed0c84275113 --- /dev/null +++ b/Randomized/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + br.com.exemplo + meu-projeto + 1.0-SNAPSHOT + + + 1.8 + 1.8 + + + + + org.junit.jupiter + junit-jupiter + 5.10.2 + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + + diff --git a/Randomized/src/main/java/learningspace/swtest/examples/ClosestPairRandomized.java b/Randomized/src/main/java/learningspace/swtest/examples/ClosestPairRandomized.java new file mode 100644 index 000000000000..d1b6f80b530a --- /dev/null +++ b/Randomized/src/main/java/learningspace/swtest/examples/ClosestPairRandomized.java @@ -0,0 +1,37 @@ +package learningspace.swtest.examples; + +import java.util.*; + +public class ClosestPairRandomized { + + public static class Point { + double x, y; + public Point(double x, double y) { + this.x = x; + this.y = y; + } + } + + public static double distance(Point a, Point b) { + return Math.hypot(a.x - b.x, a.y - b.y); + } + + public static double closestPair(Point[] points, int samples) { + Random rand = new Random(); + List shuffled = new ArrayList<>(Arrays.asList(points)); + Collections.shuffle(shuffled, rand); + + double minDist = Double.MAX_VALUE; + for (int i = 0; i < samples; i++) { + Point p1 = shuffled.get(rand.nextInt(shuffled.size())); + Point p2 = shuffled.get(rand.nextInt(shuffled.size())); + if (p1 != p2) { + double d = distance(p1, p2); + if (d < minDist) { + minDist = d; + } + } + } + return minDist; + } +} diff --git a/Randomized/src/test/java/learningspace/swtest/examples/ClosestPairRandomizedTest.java b/Randomized/src/test/java/learningspace/swtest/examples/ClosestPairRandomizedTest.java new file mode 100644 index 000000000000..e51a265189e2 --- /dev/null +++ b/Randomized/src/test/java/learningspace/swtest/examples/ClosestPairRandomizedTest.java @@ -0,0 +1,34 @@ +package learningspace.swtest.examples; + + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +public class ClosestPairRandomizedTest { + + @Test + public void testRandomizedClosestPair() { + ClosestPairRandomized.Point[] points = { + new ClosestPairRandomized.Point(0, 0), + new ClosestPairRandomized.Point(3, 4), + new ClosestPairRandomized.Point(1, 1), + new ClosestPairRandomized.Point(2, 2) + }; + + double result = ClosestPairRandomized.closestPair(points, 10000); + double expectedMinDist = Math.sqrt(2); // Entre (1,1) e (2,2) + assertTrue(result <= expectedMinDist + 0.5, "Distância deve ser próxima ou menor que esperado"); + } + + @Test + public void testWithIdenticalPoints() { + ClosestPairRandomized.Point[] points = { + new ClosestPairRandomized.Point(1, 1), + new ClosestPairRandomized.Point(1, 1), + new ClosestPairRandomized.Point(2, 2) + }; + + double result = ClosestPairRandomized.closestPair(points, 1000); + assertEquals(0.0, result, 0.001); + } +} diff --git a/Randomized/target/classes/learningspace/swtest/examples/ClosestPairRandomized$Point.class b/Randomized/target/classes/learningspace/swtest/examples/ClosestPairRandomized$Point.class new file mode 100644 index 0000000000000000000000000000000000000000..1c2aa51455f2f9c516dbb45218b89f2707cafacb GIT binary patch literal 554 zcmbVJO-}+b6r94s3a*0qjUF^H5jeO9y%>xah=~bNqK3p{fd)&KF4I8d?Q2tw8+ZKY5L(vzp4JwyjNWye;-bwp1RW3 zz5H+O$xuE^4>^=QWZ`;Pg6m>W;Cx|Yfue2d2ht4u+wM^Hc&~KDKF#R@O>xMV&+t1^ z430>Ios!58;N*GYGP6gd=XHhJ2Sn|7hE%OOL;9UZDR{&Z8-W6ck{l(gWLL->PzV&5 duW_|IYa`}6Ym}zG#4Lq%6uDYM2ivU6{Q^TeeoX)X literal 0 HcmV?d00001 diff --git a/Randomized/target/classes/learningspace/swtest/examples/ClosestPairRandomized.class b/Randomized/target/classes/learningspace/swtest/examples/ClosestPairRandomized.class new file mode 100644 index 0000000000000000000000000000000000000000..b9716a5300fe75bb481471f6ebf53c163992e4bb GIT binary patch literal 1966 zcmbtVTW=dh6#mAyv7K$3v`Mg=aw#;yPLrD601f(M?EDjrcKL{cgtp7}GpgGBgdoyczJQ@qm5oH=LCH|I8I|NQs2-vL}fHI7l_ zVi-YQPw&PtkM|_5#}P(O;zk_rqY#HgF^&&#Q{uzOw}0*V-w-}RNuRr=soN6eI8I?f zVo_pAAiUhL98bU~IgZ&X*vfTHS0IwN9Lt**2&U3&0--{qW(u4rTaLNd-l~|byQ*T7 zbF$p1Dtk?}EWO`nhP+LS7+1@-salTZ)ZM14ni=>CWQ*Hp&bWuPkfk7~cP!Sla_Pi9hp1L=HRVCl7 z8i8qEpm|YGm$rs4|0isbh`;++FQ(vPVz(bNM+idWoNpX(phph+YcVt zCgsC@@-lNrsob)hB1wVq=PRVsJgAa|Lt6O(A~Vk`kF9#D`qhGJ`c)_~!}lSvED&F9 zv|Cm4rlkw^^b4!*f_BirOGp^FgDC?mn37mEa2Frbzr*eeoa(V|v|6g8-IiE0@Cnv6 z&W6ON2JYehfwrxjdZyTD^Oevj1E1k@17F}v0}3pY>=B+yx6BQ^f>#AD9|7Pw+m?&ldWU3(`@iSI8`j_%Ipi19~0e1l-mWFWa0b3zJB+v zT>4N2Fp0@jAFt4`ZQ5itoSbe#V?E1y5?&(rD^XywU)!(5KD7PH_1l@tR^#_JJ{#$n z+g?fcz)-4`CL>rkxf$c;|0d%so98HdG7yB&1;aVXU52aR8lK*PctRq8)0`t+CMHN5 z`}7&S%w0_9jU26fi{}Dd$ESZm;5CGLS!8)U&$h8=iEy`T_p`&)69x29d5>uq|xJa$D{L^Wj6sai3 z3euQn4CyJ(V}`4yX31lpf`bc8Pk=X9@D}xhyk#Aih!?_Tp455i%C1m$m7EC#_Xr!2 km=h9jOS}_gZvVmUzxf{xAj=~GT%#jEoXR7ti7~|f18|G+kN^Mx literal 0 HcmV?d00001 diff --git a/Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 000000000000..49545dde3538 --- /dev/null +++ b/Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,2 @@ +learningspace\swtest\examples\ClosestPairRandomized.class +learningspace\swtest\examples\ClosestPairRandomized$Point.class diff --git a/Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 000000000000..7cd48bf3e5d1 --- /dev/null +++ b/Randomized/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +C:\Users\anell\Downloads\trabalho\Guess the number\src\main\java\learningspace\swtest\examples\ClosestPairRandomized.java diff --git a/Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 000000000000..fe8fef47336c --- /dev/null +++ b/Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +learningspace\swtest\examples\ClosestPairRandomizedTest.class diff --git a/Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 000000000000..2de3b5fa266a --- /dev/null +++ b/Randomized/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +C:\Users\anell\Downloads\trabalho\Guess the number\src\test\java\learningspace\swtest\examples\ClosestPairRandomizedTest.java diff --git a/Randomized/target/surefire-reports/TEST-learningspace.swtest.examples.ClosestPairRandomizedTest.xml b/Randomized/target/surefire-reports/TEST-learningspace.swtest.examples.ClosestPairRandomizedTest.xml new file mode 100644 index 000000000000..68d129d81711 --- /dev/null +++ b/Randomized/target/surefire-reports/TEST-learningspace.swtest.examples.ClosestPairRandomizedTest.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Randomized/target/surefire-reports/learningspace.swtest.examples.ClosestPairRandomizedTest.txt b/Randomized/target/surefire-reports/learningspace.swtest.examples.ClosestPairRandomizedTest.txt new file mode 100644 index 000000000000..73903dfd9b83 --- /dev/null +++ b/Randomized/target/surefire-reports/learningspace.swtest.examples.ClosestPairRandomizedTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: learningspace.swtest.examples.ClosestPairRandomizedTest +------------------------------------------------------------------------------- +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.074 s -- in learningspace.swtest.examples.ClosestPairRandomizedTest diff --git a/Randomized/target/test-classes/learningspace/swtest/examples/ClosestPairRandomizedTest.class b/Randomized/target/test-classes/learningspace/swtest/examples/ClosestPairRandomizedTest.class new file mode 100644 index 0000000000000000000000000000000000000000..7a150a3a4ae26231bfecd1a9bda4296890dbc3f7 GIT binary patch literal 1525 zcmbu9&vV;E6vw}^6)9DOlNysY{76+O)M-ftv}p-R8izQ{WX6U}lL=GcvbJ}U4YuU0 zq>|yvg+GA{7cQM184k_BzyWT|^uk}jk!$ar4&RmCItNZchuybNZ{L1DZ=dw%)1Q9> za07J@6O@1cNePHmiCK2B}wnK78*;cbK--od-h>fZz3INtMc9XFiStyc4|#}A&E z)q;zgE^b+HmQ|$E+ZKw|xm^qPdfbr~CL1b}A7{Om)H|ZprKjA8+oHQGv@+|V(@ytQ zVqvk-l|n}<+DrPPEyLuiR3>RCk3_HEl}WhXjT1Vygwl6J)QNlQYuVYMXUW2h2_1P) zgi>2SR#D0W#3740vZqMyUM2q^YW7Nx2ucU7WTg|#S(Q<17TqL^13vEB<0GFFpgU!_uqqOZas z=Q+dqsY>@ZJCZqA%UlLGdfRcP+wvo2$~=3b0Hdmy9M=xSJ>laeOuKlWH9tkk2jnKl zqK^-->d1aTJhWEAV*Fq45y`cjKd z>|)hN4QoC=#JYuBr_f~3EKC`=uq&dy@RQa7@4>?LQzT=jRO@xq#}n;Q&snHd|4*lE z&appABZWVBD-5SI=Ia zI)=B&^)V(E?do}M^V{Ej57)jAyI3wAW70?~=F+AyMtg#NSH=dZn&fJc$Vj~c+sGM8 zUBO#;4FM%@V3rklowA!0{{}4^ml)}z@DyLTc(YinS&SZlU*>F~`W*9HVw$|So#&WC zlpJ$t=ZIt&VHN)|Sfy$O+B+Kz%FJX4D5HQ5>x UV2;rRGGE~AQE`F)?pd7q7s%;%j{pDw literal 0 HcmV?d00001