Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
class KumiteFoo: def __init__(self, p): self.condition = ('No', 'Yes')[len(p) and not sum(map(ord, p.lower())) % 324] def solution(self): return self.condition
- class KumiteFoo:
- def __init__(self, p):
self.p = pself.condition = ['No', 'Yes'][len(self.p) and not sum(map(ord, self.p.lower())) % 324]- self.condition = ('No', 'Yes')[len(p) and not sum(map(ord, p.lower())) % 324]
- def solution(self):
- return self.condition
class TemperatureConverter: def __init__(self, temp: float) -> None: self.temp = temp self._celsius_to_fahrenheit_factor = 9/5 self._celsius_to_fahrenheit_offset = 32 def fahrenheit_to_celsius(self) -> float: celsius = (self.temp - 32) * (5/9) return round(celsius, 2) def celsius_to_fahrenheit(self) -> float: fahrenheit = (self.temp * self._celsius_to_fahrenheit_factor) + self._celsius_to_fahrenheit_offset return round(fahrenheit, 2)
- class TemperatureConverter:
def __init__(self, temp):- def __init__(self, temp: float) -> None:
- self.temp = temp
self._k1 = 5 / 9self._k2 = self._k1 * 32- self._celsius_to_fahrenheit_factor = 9/5
- self._celsius_to_fahrenheit_offset = 32
def fahrenheit_to_celsius(self):return round(self.temp * self._k1 - self._k2, 2)- def fahrenheit_to_celsius(self) -> float:
- celsius = (self.temp - 32) * (5/9)
- return round(celsius, 2)
def celsius_to_fahrenheit(self):return round((self.temp + self._k2) / self._k1, 2)- def celsius_to_fahrenheit(self) -> float:
- fahrenheit = (self.temp * self._celsius_to_fahrenheit_factor) + self._celsius_to_fahrenheit_offset
- return round(fahrenheit, 2)
import java.util.ArrayList; public class HowManySongYouCanPlay { static int optimo = 0; public static int playSongs(int[] songs, int remanente, int contador, int maxTime) { if (contador == songs.length || optimo == maxTime) { optimo =maxTime-remanente; } else { if (remanente >= songs[contador]) { playSongs(songs, remanente - songs[contador], contador + 1, maxTime); } else { playSongs(songs, remanente, contador + 1, maxTime); } } return optimo; } }
- import java.util.ArrayList;
- public class HowManySongYouCanPlay {
public static int playSongs(Integer[] songDuration, ArrayList<Integer> songList, ArrayList<Integer> songTestedList,boolean status) {int maxTime = 60;if (status) {int optimalDuration = sumDuration(songList);int currentDuration = sumDuration(songTestedList);if (currentDuration > optimalDuration) {ArrayList<Integer> aux = songTestedList;songList.clear();for (Integer element : aux) {if (element != null) {songList.add(element);}}}} else {for (int i = 0; i < songDuration.length; i++) {if (!songTestedList.contains(songDuration[i])) {if (maxTime > sumDuration(songTestedList) + songDuration[i]) {songTestedList.add(songDuration[i]);playSongs(songDuration, songList, songTestedList, false);songTestedList.remove(songDuration[i]);} else {playSongs(songDuration, songList, songTestedList, true);}}}}return sumDuration(songList);}public static int sumDuration(ArrayList<Integer> list){int sum = 0;for (int i = 0; i < list.size(); i++) {if (i == list.size()-1){sum += list.get(i);- static int optimo = 0;
- public static int playSongs(int[] songs, int remanente, int contador, int maxTime) {
- if (contador == songs.length || optimo == maxTime) {
- optimo =maxTime-remanente;
- } else {
- if (remanente >= songs[contador]) {
- playSongs(songs, remanente - songs[contador],
- contador + 1, maxTime);
- } else {
sum += list.get(i)+60;- playSongs(songs, remanente, contador + 1, maxTime);
- }
- }
return sum;- return optimo;
- }
- }
import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.Random; import java.util.ArrayList; class SolutionTest { @Test @Tag("BasicTest") void BasicTest() { String[] reverseLetterHellowWorld = { "eello world", "Hlllo world", "Hello world", "Heloo world", "Hellw world", "Hello oorld", "Hello wrrld", "Hello wolld", "Hello wordd", "Hello worlH" }; assertArrayEquals(reverseLetterHellowWorld, Kata.replaceLetter("Hello world", 1)); String[] reverseLeterHello = { "lello", "hollo", "hehlo", "heleo", "helll" }; assertArrayEquals(reverseLeterHello, Kata.replaceLetter("hello", 3)); String[] reverseLeterBye = { "eye", "bbe", "byy" }; assertArrayEquals(reverseLeterBye, Kata.replaceLetter("bye", 2)); String[] reverseLeterThanks = { "Thanks", "Thanks", "Thanks", "Thanks", "Thanks", "Thanks" }; assertArrayEquals(reverseLeterThanks, Kata.replaceLetter("Thanks", 0)); String[] reverseLetterWhiteSpaceFinal = { "SSs " , "Mss " , "MSM " }; assertArrayEquals(reverseLetterWhiteSpaceFinal, Kata.replaceLetter("MSs ", 1)); } @Test @Tag("SpecialCase") void SpecialCase() { String[] reverseLeterVoid = {}; assertArrayEquals(reverseLeterVoid, Kata.replaceLetter("", 2)); assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 2)); assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 0)); } @Tag("RandomTest") @RepeatedTest(10) @DisplayName("RandomWord") void RandomTest() { String word = generate(new Random().nextInt(15) + 1); int letterRandom = new Random().nextInt(word.length()); assertArrayEquals(replaceLetter(word, letterRandom), Kata.replaceLetter(word, letterRandom)); } public static String generate(int length) { String strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ^*¨_:;=?¿"; StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { int nRandom = new Random().nextInt(strChars.length()); sb.append(strChars.charAt(nRandom)); } return sb.toString(); } private static String[] replaceLetter(String str, int n) { ArrayList<String> arr = new ArrayList<>(); StringBuilder strFinal = new StringBuilder(str); for (int i = 0; i < str.length(); i++) { int nextIndex = (i + n) % str.length(); if (str.charAt(i) != ' ') { if (str.charAt(nextIndex) != ' ') { strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex))); arr.add(strFinal.toString()); strFinal.replace(0, str.length(), str); } else { while (str.charAt(nextIndex) == ' ') { if (nextIndex == str.length() - 1) { nextIndex = 0; } else { nextIndex++; } } strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex))); arr.add(strFinal.toString()); strFinal.replace(0, str.length(), str); } } } return arr.toArray(new String[arr.size()]); } }
- import static org.junit.jupiter.api.Assertions.*;
- import org.junit.jupiter.api.DisplayName;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.Tag;
- import org.junit.jupiter.api.Test;
- import java.util.Random;
- import java.util.ArrayList;
- class SolutionTest {
- @Test
- @Tag("BasicTest")
- void BasicTest() {
- String[] reverseLetterHellowWorld = { "eello world", "Hlllo world", "Hello world", "Heloo world", "Hellw world", "Hello oorld", "Hello wrrld", "Hello wolld", "Hello wordd", "Hello worlH" };
- assertArrayEquals(reverseLetterHellowWorld, Kata.replaceLetter("Hello world", 1));
- String[] reverseLeterHello = { "lello", "hollo", "hehlo", "heleo", "helll" };
- assertArrayEquals(reverseLeterHello, Kata.replaceLetter("hello", 3));
- String[] reverseLeterBye = { "eye", "bbe", "byy" };
- assertArrayEquals(reverseLeterBye, Kata.replaceLetter("bye", 2));
- String[] reverseLeterThanks = { "Thanks", "Thanks", "Thanks", "Thanks", "Thanks", "Thanks" };
- assertArrayEquals(reverseLeterThanks, Kata.replaceLetter("Thanks", 0));
- String[] reverseLetterWhiteSpaceFinal = { "SSs " , "Mss " , "MSM " };
- assertArrayEquals(reverseLetterWhiteSpaceFinal, Kata.replaceLetter("MSs ", 1));
- }
- @Test
- @Tag("SpecialCase")
- void SpecialCase() {
- String[] reverseLeterVoid = {};
- assertArrayEquals(reverseLeterVoid, Kata.replaceLetter("", 2));
- assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 2));
- assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 0));
- }
- @Tag("RandomTest")
- @RepeatedTest(10)
- @DisplayName("RandomWord")
- void RandomTest() {
- String word = generate(new Random().nextInt(15) + 1);
- int letterRandom = new Random().nextInt(word.length());
- assertArrayEquals(replaceLetter(word, letterRandom), Kata.replaceLetter(word, letterRandom));
- }
- public static String generate(int length) {
- String strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ^*¨_:;=?¿";
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < length; i++) {
- int nRandom = new Random().nextInt(strChars.length());
- sb.append(strChars.charAt(nRandom));
- }
- return sb.toString();
- }
public static String[] replaceLetter(String str, int n) {- private static String[] replaceLetter(String str, int n) {
- ArrayList<String> arr = new ArrayList<>();
- StringBuilder strFinal = new StringBuilder(str);
- for (int i = 0; i < str.length(); i++) {
- int nextIndex = (i + n) % str.length();
- if (str.charAt(i) != ' ') {
- if (str.charAt(nextIndex) != ' ') {
- strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex)));
- arr.add(strFinal.toString());
- strFinal.replace(0, str.length(), str);
- } else {
- while (str.charAt(nextIndex) == ' ') {
- if (nextIndex == str.length() - 1) {
- nextIndex = 0;
- } else {
- nextIndex++;
- }
- }
- strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex)));
- arr.add(strFinal.toString());
- strFinal.replace(0, str.length(), str);
- }
- }
- }
- return arr.toArray(new String[arr.size()]);
- }
- }
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import java.util.TreeSet; import java.util.Iterator; import java.util.Random; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; class SumOfPrimesTest { public static Integer[] solution(int start, int end) { TreeSet<Integer> primes = new TreeSet<Integer>(); TreeSet<Integer> result = new TreeSet<Integer>(); boolean[] table = new boolean[end + 1]; table[0] = true; table[1] = true; for (int i = start; i < table.length; i++) { if (!table[i]) { for (int j = i + i; j < table.length; j += i) { table[j] = true; } int minusResult = Integer.MIN_VALUE; int minus = 0; Iterator<Integer> iterator = primes.descendingIterator(); boolean isPrime = false; while (minusResult < minus && iterator.hasNext() && !isPrime) { minus = iterator.next(); minusResult = i - minus; isPrime = primes.contains(minusResult); } if (isPrime) result.add(i); primes.add(i); } } return result.toArray(new Integer[0]); } @Test void exampleTests() { assertArrayEquals(new Integer[] { 7, 11, 17, 23, 41, 47 }, AncientPrimes.sumOfPrimes(3, 50)); assertArrayEquals(new Integer[] { 21, 23, 25, 27, 29, 31, 35, 37, 41, 43, 47, 49 }, AncientPrimes.sumOfPrimes(10, 50)); assertArrayEquals(new Integer[] { 9, 11, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71, 73, 79, 83, 89 }, AncientPrimes.sumOfPrimes(4, 100)); assertArrayEquals( new Integer[] { 23, 25, 27, 29, 31, 35, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 }, AncientPrimes.sumOfPrimes(11, 100)); } @Test void mediumTest() { assertArrayEquals(new Integer[] { 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 335, 337, 341, 343, 347, 349, 353, 355, 359, 361, 365, 367, 371, 373, 377, 379, 383, 385, 389, 391, 395, 397, 401, 403, 407, 409, 413, 415, 419, 421, 425, 427, 431, 433, 437, 439, 443, 445, 449, 451, 455, 457, 461, 463, 467, 469, 473, 475, 479, 481, 485, 487, 491, 493, 497, 499, 503, 505, 509, 511, 515, 517, 521, 523, 527, 529, 533, 535, 539, 541, 545, 547, 551, 553, 557, 559, 563, 569, 571, 577, 581, 583, 587, 589, 593, 599, 601, 607, 611, 613, 617, 619, 623, 629, 631, 637, 641, 643, 647, 649, 653, 659, 661, 667, 671, 673, 677, 679, 683, 689, 691, 697, 701, 703, 707, 709, 713, 719, 721, 727, 731, 733, 737, 739, 743, 749, 751, 757, 761, 763, 767, 769, 773, 779, 781, 787, 793, 797, 799, 803, 809, 811, 817, 821, 823, 827, 829, 839, 841, 851, 853, 857, 859, 863, 869, 871, 877, 881, 883, 887, 893, 899, 901, 907, 911, 913, 919, 923, 929, 937, 941, 943, 947, 949, 953, 961, 967, 971, 977, 979, 983, 989, 991, 997, 1003, 1007, 1009, 1013, 1019, 1021, 1027, 1031, 1033, 1037, 1039, 1049, 1051, 1061, 1063, 1067, 1069, 1073, 1079, 1081, 1087, 1091, 1093, 1097, 1103, 1109, 1111, 1117, 1121, 1123, 1129, 1133, 1139, 1147, 1151, 1153, 1157, 1159, 1163, 1171, 1177, 1181, 1187, 1189, 1193, 1199, 1201, 1207, 1213, 1217, 1219, 1223, 1229, 1231, 1237, 1241, 1247, 1249, 1259, 1261, 1271, 1273, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1313, 1319, 1321, 1327, 1333, 1339, 1343, 1349, 1357, 1361, 1363, 1367, 1369, 1373, 1381, 1387, 1391, 1399, 1403, 1409, 1411, 1417, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1457, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1501, 1511, 1513, 1517, 1523, 1531, 1537, 1541, 1543, 1549, 1553, 1559, 1567, 1571, 1577, 1579, 1583, 1591, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1633, 1637, 1643, 1649, 1657, 1663, 1667, 1669, 1679, 1681, 1691, 1693, 1697, 1699, 1709, 1711, 1717, 1721, 1723, 1733, 1739, 1741, 1747, 1751, 1753, 1759, 1763, 1769, 1777, 1783, 1787, 1789, 1801, 1811, 1817, 1819, 1823, 1829, 1831, 1843, 1847, 1849, 1853, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1891, 1901, 1907, 1909, 1913, 1919, 1927, 1931, 1933, 1943, 1949, 1951, 1957, 1961, 1973, 1979, 1987, 1993, 1997, 1999 }, AncientPrimes.sumOfPrimes(110, 2000)); assertArrayEquals(new Integer[] { 11, 13, 17, 19, 23, 29, 31, 37, 43, 47, 53, 59, 61, 67, 73, 79, 89, 97, 103, 107, 109, 113, 137, 139, 157, 163, 173, 179, 181, 197, 199, 229, 233, 239, 241, 257, 263, 269, 271, 277, 283, 313, 317, 337, 353, 359, 367, 373, 379, 389, 397, 409, 439, 449, 457, 463, 467, 487, 499, 509, 547, 563, 569, 571, 577, 593, 599, 601, 607, 613, 619, 647, 653, 659, 661, 683, 691, 709, 727, 733, 739, 751, 757, 769, 827, 829, 859, 863, 883, 887, 919, 937, 947, 953, 977, 983, 991, 997, 1019, 1021, 1039, 1069, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1171, 1187, 1193, 1201, 1223, 1229, 1231, 1237, 1283, 1289, 1291, 1297, 1303, 1307, 1327, 1367, 1373, 1381, 1429, 1433, 1439, 1447, 1453, 1459, 1487, 1489, 1493, 1499, 1531, 1549, 1559, 1567, 1579, 1607, 1609, 1613, 1619, 1621, 1627, 1663, 1669, 1699, 1741, 1747, 1753, 1759, 1783, 1789, 1831, 1867, 1873, 1877, 1879, 1907, 1913, 1979, 1987, 1993, 1999, 2003, 2011, 2017, 2069, 2087, 2089, 2137, 2143, 2161, 2213, 2221, 2243, 2251, 2273, 2281, 2287, 2293, 2339, 2341, 2347, 2357, 2377, 2383, 2389, 2399, 2417, 2423, 2447, 2467, 2473, 2539, 2549, 2551, 2557, 2617, 2663, 2671, 2677, 2683, 2689, 2693, 2699, 2707, 2713, 2719, 2749, 2797, 2803, 2843, 2851, 2857, 2887, 2903, 2909, 2917, 2963, 2969, 2971, 3019, 3049, 3067, 3089, 3169, 3187, 3209, 3217, 3229, 3257, 3259, 3307, 3313, 3319, 3329, 3331, 3413, 3457, 3463, 3467, 3469, 3499, 3517, 3533, 3539, 3541, 3547, 3613, 3623, 3631, 3637, 3643, 3677, 3697, 3709, 3727, 3733, 3739, 3767, 3769, 3803, 3853, 3889, 3917, 3919, 3923, 3929, 3931, 4007, 4013, 4019, 4021, 4027, 4057, 4079, 4099, 4133, 4139, 4159, 4217, 4219, 4259, 4261, 4289, 4297, 4357, 4363, 4397, 4447, 4457, 4463, 4513, 4519, 4523, 4567, 4591, 4597, 4603, 4643, 4649, 4651, 4657, 4663, 4679, 4729, 4759, 4789, 4793, 4799, 4801, 4877, 4909, 4937, 4943, 4951, 4957, 4973, 4993, 4999, 5009, 5011, 5059, 5087, 5107, 5113, 5119, 5153, 5179, 5197, 5233, 5237, 5279, 5281, 5303, 5309, 5387, 5393, 5399, 5407, 5413, 5419, 5437, 5443, 5449, 5477, 5479, 5483, 5507, 5527, 5563, 5569, 5581, 5647, 5653, 5657, 5659, 5689, 5701, 5717, 5743, 5749, 5791, 5807, 5813, 5821, 5827, 5849, 5851, 5857, 5867, 5869, 5903, 5987, 6037, 6043, 6053, 6073, 6079, 6121, 6151, 6203, 6211, 6217, 6229, 6263, 6269, 6271, 6277, 6317, 6323, 6329, 6337, 6343, 6359, 6361, 6367, 6373, 6379, 6397, 6427, 6481, 6529, 6553, 6569, 6571, 6577, 6607, 6659, 6661, 6679, 6709, 6829, 6833, 6841, 6863, 6869, 6871, 6907, 6917, 6967, 6977, 6983, 6991, 6997, 7019, 7027, 7109, 7127, 7129, 7159, 7193, 7213, 7219, 7237, 7243, 7253, 7417, 7457, 7459, 7487, 7489, 7507, 7523, 7529, 7537, 7547, 7549, 7583, 7589, 7591, 7649, 7681, 7687, 7699, 7723, 7759, 7823, 7829, 7873, 7879, 7883, 7907, 7927, 7933, 8017, 8059, 8087, 8089, 8093, 8101, 8117, 8123, 8167, 8179, 8237, 8243, 8269, 8293, 8297, 8317, 8369, 8377, 8429, 8431, 8467, 8521, 8527, 8543, 8581, 8629, 8647, 8669, 8677, 8689, 8699, 8707, 8713, 8719, 8737, 8747, 8753, 8761, 8837, 8839, 8867, 8893, 8929, 8941, 8969, 8971, 9007, 9013, 9049, 9067, 9109, 9133, 9157, 9181, 9187, 9209, 9227, 9283, 9319, 9343, 9349, 9377, 9397, 9403, 9419, 9421, 9437, 9439, 9467, 9473, 9479, 9497, 9539, 9547, 9619, 9629, 9631, 9649, 9697, 9739, 9749, 9787, 9811, 9817, 9839, 9857, 9859, 9907, 9929, 9931, 9949, 9973, 10067, 10069, 10099, 10111, 10139, 10141, 10159, 10169, 10177, 10253, 10259, 10267, 10273, 10321, 10337, 10343, 10399, 10433, 10459, 10463, 10567, 10597, 10607, 10613, 10639, 10657, 10663, 10729, 10739, 10789, 10837, 10853, 10859, 10861, 10867, 10889, 10891, 10909, 10957, 10979, 10987, 10993, 11093, 11119, 11177, 11251, 11257, 11279, 11287, 11317, 11329, 11399, 11443, 11489, 11491, 11497, 11503, 11527, 11587, 11593, 11689, 11783, 11789, 11807, 11813, 11821, 11827, 11833, 11839, 11903, 11909, 11933, 11939, 11941, 11959, 11987, 12043, 12049, 12107, 12109, 12113, 12119, 12149, 12157, 12163, 12203, 12211, 12269, 12277, 12289, 12329, 12379, 12409, 12421, 12457, 12479, 12487, 12497, 12503, 12511, 12517, 12547, 12553, 12577, 12583, 12589, 12619, 12647, 12653, 12659, 12697, 12703, 12721, 12763, 12799, 12829, 12899, 12907, 12917, 12919, 12923, 12959, 12967, 12973, 12979, 13007, 13009, 13043, 13049, 13099, 13109, 13127, 13159, 13171, 13177, 13183, 13249, 13267, 13297, 13337, 13339, 13417, 13457, 13463, 13469, 13477, 13597, 13619, 13627, 13633, 13687, 13693, 13697, 13729, 13757, 13759, 13763, 13789, 13807, 13879, 13883, 13907, 13913, 13921, 14057, 14087, 14149, 14159, 14249, 14251, 14327, 14347, 14407, 14419, 14431, 14437, 14543, 14549, 14551, 14557, 14563, 14627, 14629, 14633, 14639, 14723, 14731, 14737, 14747, 14753, 14759, 14767, 14779, 14821, 14827, 14851, 14887, 14897, 14929, 14947, 14957, 15061, 15083, 15091, 15107, 15137, 15139, 15193, 15199, 15233, 15241, 15269, 15271, 15277, 15307, 15313, 15319, 15383, 15391, 15451, 15467, 15473, 15559, 15607, 15647, 15649, 15667, 15679, 15733, 15737, 15739, 15767, 15773, 15797, 15803, 15809, 15817, 15823, 15887, 15889, 15907, 15913, 15919, 16007, 16063, 16067, 16069, 16073, 16097, 16103, 16111, 16189, 16193, 16223, 16229, 16231, 16273, 16339, 16369, 16417, 16427, 16433, 16453, 16487, 16493, 16553, 16561, 16567, 16573, 16657, 16699, 16747, 16829, 16831, 16879, 16889, 16927, 16937, 16943, 16987, 16993, 17027, 17029, 17033, 17041, 17047, 17053, 17099, 17107, 17123, 17167, 17189, 17191, 17209, 17239, 17299, 17327, 17333, 17341, 17359, 17383, 17389, 17393, 17401, 17449, 17477, 17483, 17489, 17491, 17497, 17579, 17581, 17713, 17737, 17789, 17791, 17909, 17911, 17929, 17977, 17987, 17989, 18047, 18049, 18097, 18127, 18133, 18149, 18199, 18217, 18223, 18229, 18257, 18307, 18313, 18379, 18433, 18439, 18451, 18457, 18523, 18593, 18679, 18719, 18749, 18757, 18793, 18803, 18917, 18919, 18979, 19009, 19037, 19079, 19081, 19087, 19163, 19213, 19219, 19237, 19267, 19273, 19309, 19379, 19381, 19387, 19423, 19427, 19429, 19433, 19441, 19447, 19463, 19469, 19471, 19477, 19483, 19489, 19507, 19559, 19577, 19583, 19603, 19609, 19687, 19717, 19759, 19801, 19819, 19861, 19867, 19919, 19927, 19979, 19997 }, AncientPrimes.sumOfPrimes(5, 20000)); } @Test void hardTests() { assertArrayEquals(new Integer[] { 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241, 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643, 661, 811, 823, 829, 859, 883, 1021, 1033, 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429, 1453, 1483, 1489, 1609, 1621, 1669, 1699, 1723, 1789, 1873, 1879, 1933, 1951, 1999, 2029, 2083, 2089, 2113, 2131, 2143, 2239, 2269, 2311, 2341, 2383, 2551, 2593, 2659, 2689, 2713, 2731, 2791, 2803, 2971, 3001, 3121, 3169, 3253, 3259, 3301, 3331, 3361, 3373, 3391, 3463, 3469, 3529, 3541, 3559, 3583, 3673, 3769, 3823, 3853, 3919, 3931, 4003, 4021, 4051, 4093, 4129, 4159, 4219, 4231, 4243, 4261, 4273, 4339, 4423, 4483, 4519, 4549, 4639, 4651, 4723, 4789, 4801, 4933, 4969, 5011, 5023, 5101, 5233, 5281, 5419, 5443, 5479, 5503, 5521, 5641, 5653, 5659, 5743, 5851, 5869, 5881, 6091, 6133, 6199, 6271, 6301, 6361, 6451, 6553, 6571, 6661, 6691, 6703, 6763, 6781, 6793, 6829, 6871, 6949, 6961, 7129, 7213, 7309, 7333, 7351, 7459, 7489, 7549, 7561, 7591, 7759, 7879, 7951, 8011, 8089, 8221, 8233, 8293, 8389, 8431, 8539, 8599, 8629, 8821, 8839, 8863, 8971, 9001, 9013, 9043, 9241, 9283, 9343, 9421, 9433, 9439, 9463, 9631, 9679, 9721, 9769, 9859, 9931, 10009, 10039, 10069, 10093, 10141, 10273, 10303, 10333, 10429, 10459, 10501, 10531, 10711, 10861, 10891, 10939, 11059, 11071, 11119, 11161, 11173, 11353, 11491, 11551, 11701, 11719, 11779, 11833, 11941, 11971, 12043, 12073, 12109, 12163, 12241, 12253, 12379, 12541, 12613, 12823, 12919, 13003, 13009, 13219, 13339, 13399, 13681, 13693, 13711, 13723, 13759, 13831, 13879, 13903, 13933, 13999, 14011, 14083, 14251, 14323, 14389, 14449, 14551, 14563, 14593, 14629, 14869, 15139, 15271, 15289, 15331, 15361, 15583, 15643, 15649, 15733, 15739, 15889, 15973, 16063, 16069, 16141, 16189, 16231, 16363, 16453, 16633, 16651, 16693, 16831, 16903, 16981, 17029, 17191, 17209, 17293, 17389, 17419, 17491, 17581, 17599, 17659, 17683, 17749, 17791, 17839, 17911, 17923, 17959, 17989, 18043, 18049, 18061, 18121, 18133, 18253, 18289, 18313, 18523, 18541, 18913, 18919, 19081, 19141, 19183, 19213, 19381, 19423, 19429, 19471, 19543, 19699, 19753, 19843, 19891, 19963, 19993, 20023, 20149, 20233, 20359, 20443, 20479, 20509, 20551, 20641, 20719, 20749, 20773, 20809, 20899, 20983, 21013, 21019, 21061, 21193, 21319, 21379, 21493, 21523, 21559, 21589, 21601, 21613, 21649, 21739, 21841, 22039, 22093, 22111, 22159, 22273, 22279, 22369, 22483, 22543, 22573, 22621, 22639, 22699, 22741, 22861, 22963, 23029, 23041, 23059, 23203, 23293, 23371, 23539, 23563, 23629, 23671, 23689, 23743, 23833, 23911, 24109, 24181, 24373, 24421, 24919, 24979, 25033, 25171, 25303, 25309, 25411, 25471, 25579, 25603, 25801, 25849, 25933, 25999, 26113, 26251, 26263, 26683, 26701, 26713, 26731, 26863, 26881, 26893, 26953, 27061, 27109, 27241, 27283, 27409, 27481, 27529, 27541, 27583, 27691, 27739, 27751, 27793, 27919, 27943, 28099, 28111, 28183, 28279, 28309, 28351, 28411, 28549, 28573, 28621, 28663, 28753, 29023, 29131, 29209, 29389, 29401, 29569, 29671, 29761, 29881, 30013, 30091, 30139, 30271, 30391, 30469, 30493, 30559, 30841, 30853, 30871, 31081, 31123, 31153, 31183, 31249, 31321, 31393, 31513, 31543, 31723, 31729, 31771, 31849, 32029, 32059, 32119, 32143, 32191, 32299, 32323, 32371, 32413, 32443, 32533, 32563, 32611, 32719, 32803, 32833, 32911, 32941, 32971, 33073, 33151, 33181, 33289, 33331, 33349, 33589, 33601, 33619, 33751, 33769, 33811, 33829, 34033, 34129, 34159, 34213, 34261, 34303, 34369, 34471, 34501, 34513, 34591, 34651, 34759, 34843, 34849, 34963, 35053, 35083, 35281, 35449, 35509, 35533, 35593, 35731, 35803, 35839, 35899, 36013, 36109, 36343, 36469, 36529, 36781, 36793, 36901, 36931, 37021, 37201, 37309, 37339, 37363, 37549, 37573, 37591, 37693, 37783, 37813, 37993, 38239, 38329, 38449, 38461, 38569, 38611, 38653, 38671, 38713, 38749, 38923, 39043, 39163, 39229, 39241, 39343, 39373, 39511, 39829, 39841, 40039, 40129, 40153, 40429, 40531, 40639, 40699, 40849, 41143, 41179, 41203, 41233, 41389, 41413, 41521, 41611, 41761, 41851, 41959, 41983, 42019, 42073, 42181, 42223, 42283, 42409, 42463, 42571, 42643, 42703, 42841, 42901, 43051, 43321, 43399, 43543, 43579, 43609, 43651, 43783, 43789, 43891, 43963, 44029, 44089, 44131, 44203, 44269, 44281, 44383, 44533, 44623, 44701, 44773, 45121, 45139, 45181, 45319, 45343, 45589, 45823, 46051, 46093, 46183, 46273, 46309, 46351, 46441, 46591, 46681, 46771, 46819, 46831, 47059, 47149, 47353, 47389, 47419, 47659, 47701, 47713, 47743, 47779, 47809, 48121, 48313, 48409, 48481, 48541, 48649, 48679, 48733, 48781, 48823, 48859, 48871, 48991, 49033, 49123, 49171, 49201, 49279, 49333, 49369, 49393, 49411, 49531, 49549, 49669, 49741, 49789, 49921, 49939, 49993, 50023, 50053, 50131, 50263, 50461, 50551, 50593, 50893, 50971, 51061, 51133, 51199, 51241, 51343, 51349, 51421, 51439, 51481, 51721, 51769, 51829, 51871, 51973, 52069, 52183, 52291, 52363, 52543, 52711, 52861, 52903, 53089, 53149, 53173, 53233, 53269, 53281, 53551, 53593, 53611, 53719, 53899, 54013, 54403, 54421, 54499, 54541, 54583, 54631, 54919, 55051, 55219, 55333, 55339, 55441, 55621, 55633, 55663, 55819, 55903, 55933, 56041, 56101, 56209, 56239, 56269, 56479, 56503, 56533, 56599, 56713, 56809, 56893, 56911, 56923, 57193, 57223, 57271, 57331, 57349, 57529, 57559, 57793, 57901, 58111, 58153, 58171, 58231, 58369, 58393, 58441, 58453, 58603, 58789, 58909, 59011, 59023, 59053, 59209, 59221, 59359, 59419, 59443, 59473, 59629, 59671, 60091, 60103, 60169, 60259, 60649, 60661, 60763, 60889, 60901, 60919, 61153, 61333, 61381, 61471, 61561, 61981, 62131, 62143, 62191, 62299, 62929, 62971, 62983, 62989, 63031, 63199, 63313, 63391, 63421, 63589, 63601, 63649, 63691, 63841, 64153, 64189, 64303, 64453, 64579, 64663, 64783, 64879, 64921, 65029, 65101, 65173, 65269, 65449, 65521, 65539, 65581, 65701, 65719, 65731, 65839, 65929, 65983, 66109, 66361, 66571, 66751, 66853, 66949, 67141, 67189, 67213, 67219, 67273, 67411, 67429, 67579, 67759, 67933, 68113, 68209, 68281, 68449, 68491, 68713, 68821, 68881, 68899, 69031, 69151, 69193, 69259, 69403, 69493, 69499, 69739, 69763, 69829, 69859, 69931, 70003, 70123, 70141, 70183, 70201, 70381, 70459, 70489, 70573, 70621, 70843, 70879, 70921, 70951, 70981, 70999, 71263, 71329, 71341, 71389, 71413, 71473, 71551, 71713, 71809, 71881, 72091, 72103, 72169, 72223, 72229, 72253, 72271, 72469, 72649, 72673, 72871, 73039, 73063, 73363, 73609, 73681, 73849, 74101, 74161, 74203, 74383, 74413, 74509, 74611, 74719, 74731, 74761, 75013, 75169, 75211, 75391, 75403, 75541, 75619, 75709, 75991, 76003, 76081, 76159, 76261, 76369, 76423, 76543, 76651, 76831, 76873, 76963, 77239, 77263, 77269, 77419, 77479, 77491, 77551, 77689, 77713, 78139, 78193, 78439, 78511, 78541, 78571, 78781, 78889, 78979, 79153, 79231, 79399, 79561, 79633, 79693, 79699, 79813, 79843, 79903, 79999, 80149, 80209, 80233, 80449, 80473, 80491, 80629, 80671, 80683, 80749, 80779, 80833, 80911, 81019, 81043, 81049, 81199, 81283, 81373, 81553, 81649, 81703, 81901, 81931, 81973, 82009, 82039, 82141, 82219, 82351, 82471, 82531, 82561, 82723, 82729, 82759, 82813, 82891, 83221, 83233, 83269, 83341, 83401, 83563, 83641, 83719, 84061, 84181, 84223, 84319, 84349, 84391, 84523, 84631, 84811, 84859, 84871, 84979, 85093, 85201, 85333, 85363, 85429, 85453, 85621, 85669, 85819, 85831, 85933, 86029, 86113, 86293, 86353, 86371, 86533, 86629, 86929, 87013, 87121, 87151, 87181, 87223, 87253, 87511, 87541, 87559, 87589, 87631, 87643, 87721, 87961, 88003, 88261, 88339, 88471, 88591, 88609, 88663, 88801, 88813, 88819, 89071, 89521, 89563, 89599, 89659, 89671, 89821, 89899, 90019, 90073, 90199, 90373, 90403, 90439, 90529, 90619, 90679, 90823, 91081, 91099, 91129, 91141, 91153, 91369, 91459, 91573, 91813, 91969, 92179, 92221, 92383, 92401, 92461, 92569, 92641, 92671, 92683, 92791, 92863, 92959, 93133, 93241, 93253, 93283, 93481, 93493, 93559, 93703, 93763, 93811, 93889, 93913, 94009, 94111, 94153, 94309, 94351, 94399, 94441, 94531, 94543, 94561, 94651, 94849, 94951, 95089, 95191, 95233, 95443, 95791, 95803, 95959, 95989, 96181, 96223, 96331, 96589, 96739, 96799, 96823, 97003, 97159, 97171, 97303, 97369, 97381, 97501, 97549, 97579, 97609, 97651, 97789, 97843, 97849, 97861, 98011, 98299, 98323, 98389, 98563, 98641, 98713, 98731, 98809, 98869, 98899, 98911, 98929, 99133, 99139, 99259, 99349, 99529, 99709, 99721, 99991, 100153, 100363, 100393, 100519, 100549, 100801, 101113, 101119, 101161, 101209, 101281, 101503, 101533, 101749, 101839, 102001, 102061, 102079, 102103, 102199, 102253, 102301, 102409, 102499, 102679, 102763, 102913, 102931, 103069, 103093, 103291, 103393, 103423, 103813, 103843, 103969, 103981, 103993, 104089, 104149, 104233, 104311, 104383, 104473, 104551, 104683, 104761, 104803, 104851, 105229, 105253, 105361, 105529, 105769, 106033, 106123, 106189, 106219, 106279, 106321, 106453, 106543, 106621, 106663, 106753, 106783, 106861, 106963, 107071, 107101, 107509, 107719, 107839, 108013, 108109, 108193, 108289, 108379, 108463, 108499, 108709, 108793, 108883, 108949, 108961, 109141, 109171, 109201, 109453, 109471, 109519, 109621, 109663, 109831, 109843, 109849, 110323, 110479, 110503, 110569, 110731, 110821, 110881, 110923, 111031, 111121, 111229, 111271, 111493, 111733, 111781, 111829, 111871, 112069, 112249, 112291, 112339, 112363, 112573, 112603, 112759, 112921, 113023, 113041, 113083, 113149, 113161, 113173, 113329, 113359, 113383, 113539, 113623, 113719, 113761, 113779, 114043, 114199, 114601, 114643, 114661, 114691, 114799, 115021, 115153, 115303, 115321, 115363, 115471, 115603, 115771, 115783, 115861, 115879, 115903, 115933, 115981, 116101, 116191, 116533, 116539, 116689, 116791, 116929, 117043, 117193, 117241, 117331, 117373, 117499, 117541, 117619, 117673, 117703, 117811, 117841, 117883, 117979, 117991, 118171, 118213, 118249, 118411, 118621, 118801, 118903, 119089, 119101, 119131, 119293, 119299, 119419, 119551, 119659, 119689, 119701, 119773, 119851, 119923, 119983, 120049, 120079, 120691, 120739, 120919, 120943, 121021, 121063, 121171, 121351, 121369, 121441, 121579, 121609, 121633, 121789, 121951, 122029, 122041, 122053, 122149, 122203, 122209, 122323, 122389, 122401, 122503, 122599, 122611, 122653, 122743, 122869, 123379, 123493, 123553, 123583, 123733, 124123, 124183, 124249, 124303, 124339, 124351, 124429, 124543, 124771, 124783, 124909, 124981, 125119, 125221, 125509, 125641, 125791, 125899, 125929, 126013, 126229, 126493, 126613, 126859, 127033, 127081, 127219, 127249, 127291, 127609, 127681, 127711, 127819, 128113, 128203, 128239, 128341, 128413, 128521, 128551, 128659, 128749, 128833, 128941, 128971, 128983, 129121, 129223, 129289, 129403, 129499, 129529, 129589, 129631, 129643, 129919, 130201, 130261, 130369, 130411, 130621, 130633, 130651, 130843, 131011, 131113, 131251, 131449, 131479, 131641, 131713, 131779, 131839, 131893, 131941, 132049, 132331, 132439, 132529, 132709, 132751, 132763, 132859, 132949, 133279, 133321, 133351, 133543, 133633, 133711, 133813, 133981, 134089, 134293, 134341, 134371, 134401, 134593, 134683, 134839, 134923, 135019, 135211, 135283, 135349, 135391, 135433, 135463, 135469, 135601, 135649, 135721, 135913, 135979, 136069, 136399, 136483, 136603, 136651, 136693, 136711, 136753, 136813, 136861, 136951, 136993, 137089, 137119, 137341, 137869, 137911, 138079, 138181, 138241, 138373, 138403, 138451, 138571, 138799, 139123, 139201, 139303, 139369, 139459, 139591, 139663, 139969, 140071, 140419, 140551, 140629, 140683, 140731, 140761, 140839, 140869, 140893, 141181, 141223, 141499, 141511, 141679, 141709, 141769, 141853, 141961, 142099, 142159, 142591, 142609, 142699, 142759, 142789, 142873, 142981, 143113, 143263, 143503, 143569, 143653, 143833, 143881, 144073, 144163, 144169, 144409, 144481, 144541, 144889, 145009, 145513, 145549, 145603, 145681, 145723, 145759, 145933, 145969, 146011, 146023, 146059, 146299, 146383, 146521, 146683, 146893, 146989, 147031, 147139, 147211, 147229, 147451, 147673, 148063, 148153, 148201, 148303, 148471, 148669, 148693, 148723, 148783, 148861, 148933, 149059, 149101, 149113, 149161, 149251, 149419, 149491, 149521, 149533, 149563, 149629, 149713, 149731, 149839, 149911, 149971 }, AncientPrimes.sumOfPrimes(2, 150000)); } @Test void failTest() { assertArrayEquals(new Integer[0], AncientPrimes.sumOfPrimes(40, 39)); } @RepeatedTest(200) void testRandom() { Random random = new Random(); int randomStart = random.nextInt(20); int randomEnd = random.nextInt(10000); assertArrayEquals(solution(randomStart,randomEnd), AncientPrimes.sumOfPrimes(randomStart,randomEnd)); } }
- import static org.junit.jupiter.api.Assertions.assertArrayEquals;
- import java.util.TreeSet;
- import java.util.Iterator;
- import java.util.Random;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;// TODO: Replace examples and use TDD by writing your own tests- class SumOfPrimesTest {
- public static Integer[] solution(int start, int end) {
- TreeSet<Integer> primes = new TreeSet<Integer>();
- TreeSet<Integer> result = new TreeSet<Integer>();
- boolean[] table = new boolean[end + 1];
- table[0] = true;
- table[1] = true;
- for (int i = start; i < table.length; i++) {
- if (!table[i]) {
- for (int j = i + i; j < table.length; j += i) {
- table[j] = true;
- }
- int minusResult = Integer.MIN_VALUE;
- int minus = 0;
- Iterator<Integer> iterator = primes.descendingIterator();
- boolean isPrime = false;
- while (minusResult < minus && iterator.hasNext() && !isPrime) {
- minus = iterator.next();
- minusResult = i - minus;
- isPrime = primes.contains(minusResult);
- }
- if (isPrime)
- result.add(i);
- primes.add(i);
- }
- }
- return result.toArray(new Integer[0]);
- }
- @Test
- void exampleTests() {
- assertArrayEquals(new Integer[] { 7, 11, 17, 23, 41, 47 }, AncientPrimes.sumOfPrimes(3, 50));
- assertArrayEquals(new Integer[] { 21, 23, 25, 27, 29, 31, 35, 37, 41, 43, 47, 49 }, AncientPrimes.sumOfPrimes(10, 50));
- assertArrayEquals(new Integer[] { 9, 11, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71, 73, 79, 83, 89 },
- AncientPrimes.sumOfPrimes(4, 100));
- assertArrayEquals(
- new Integer[] { 23, 25, 27, 29, 31, 35, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 },
- AncientPrimes.sumOfPrimes(11, 100));
- }
- @Test
- void mediumTest() {
- assertArrayEquals(new Integer[] { 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249,
- 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291,
- 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 335,
- 337, 341, 343, 347, 349, 353, 355, 359, 361, 365, 367, 371, 373, 377, 379, 383, 385, 389, 391, 395, 397,
- 401, 403, 407, 409, 413, 415, 419, 421, 425, 427, 431, 433, 437, 439, 443, 445, 449, 451, 455, 457, 461,
- 463, 467, 469, 473, 475, 479, 481, 485, 487, 491, 493, 497, 499, 503, 505, 509, 511, 515, 517, 521, 523,
- 527, 529, 533, 535, 539, 541, 545, 547, 551, 553, 557, 559, 563, 569, 571, 577, 581, 583, 587, 589, 593,
- 599, 601, 607, 611, 613, 617, 619, 623, 629, 631, 637, 641, 643, 647, 649, 653, 659, 661, 667, 671, 673,
- 677, 679, 683, 689, 691, 697, 701, 703, 707, 709, 713, 719, 721, 727, 731, 733, 737, 739, 743, 749, 751,
- 757, 761, 763, 767, 769, 773, 779, 781, 787, 793, 797, 799, 803, 809, 811, 817, 821, 823, 827, 829, 839,
- 841, 851, 853, 857, 859, 863, 869, 871, 877, 881, 883, 887, 893, 899, 901, 907, 911, 913, 919, 923, 929,
- 937, 941, 943, 947, 949, 953, 961, 967, 971, 977, 979, 983, 989, 991, 997, 1003, 1007, 1009, 1013, 1019,
- 1021, 1027, 1031, 1033, 1037, 1039, 1049, 1051, 1061, 1063, 1067, 1069, 1073, 1079, 1081, 1087, 1091,
- 1093, 1097, 1103, 1109, 1111, 1117, 1121, 1123, 1129, 1133, 1139, 1147, 1151, 1153, 1157, 1159, 1163,
- 1171, 1177, 1181, 1187, 1189, 1193, 1199, 1201, 1207, 1213, 1217, 1219, 1223, 1229, 1231, 1237, 1241,
- 1247, 1249, 1259, 1261, 1271, 1273, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1313, 1319,
- 1321, 1327, 1333, 1339, 1343, 1349, 1357, 1361, 1363, 1367, 1369, 1373, 1381, 1387, 1391, 1399, 1403,
- 1409, 1411, 1417, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1457, 1459, 1471, 1481, 1483, 1487,
- 1489, 1493, 1499, 1501, 1511, 1513, 1517, 1523, 1531, 1537, 1541, 1543, 1549, 1553, 1559, 1567, 1571,
- 1577, 1579, 1583, 1591, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1633, 1637, 1643, 1649, 1657,
- 1663, 1667, 1669, 1679, 1681, 1691, 1693, 1697, 1699, 1709, 1711, 1717, 1721, 1723, 1733, 1739, 1741,
- 1747, 1751, 1753, 1759, 1763, 1769, 1777, 1783, 1787, 1789, 1801, 1811, 1817, 1819, 1823, 1829, 1831,
- 1843, 1847, 1849, 1853, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1891, 1901, 1907, 1909, 1913, 1919,
- 1927, 1931, 1933, 1943, 1949, 1951, 1957, 1961, 1973, 1979, 1987, 1993, 1997, 1999 },
- AncientPrimes.sumOfPrimes(110, 2000));
- assertArrayEquals(new Integer[] { 11, 13, 17, 19, 23, 29, 31, 37, 43, 47, 53, 59, 61, 67, 73, 79, 89, 97, 103,
- 107, 109, 113, 137, 139, 157, 163, 173, 179, 181, 197, 199, 229, 233, 239, 241, 257, 263, 269, 271, 277,
- 283, 313, 317, 337, 353, 359, 367, 373, 379, 389, 397, 409, 439, 449, 457, 463, 467, 487, 499, 509, 547,
- 563, 569, 571, 577, 593, 599, 601, 607, 613, 619, 647, 653, 659, 661, 683, 691, 709, 727, 733, 739, 751,
- 757, 769, 827, 829, 859, 863, 883, 887, 919, 937, 947, 953, 977, 983, 991, 997, 1019, 1021, 1039, 1069,
- 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1171, 1187, 1193, 1201, 1223, 1229, 1231, 1237, 1283, 1289,
- 1291, 1297, 1303, 1307, 1327, 1367, 1373, 1381, 1429, 1433, 1439, 1447, 1453, 1459, 1487, 1489, 1493,
- 1499, 1531, 1549, 1559, 1567, 1579, 1607, 1609, 1613, 1619, 1621, 1627, 1663, 1669, 1699, 1741, 1747,
- 1753, 1759, 1783, 1789, 1831, 1867, 1873, 1877, 1879, 1907, 1913, 1979, 1987, 1993, 1999, 2003, 2011,
- 2017, 2069, 2087, 2089, 2137, 2143, 2161, 2213, 2221, 2243, 2251, 2273, 2281, 2287, 2293, 2339, 2341,
- 2347, 2357, 2377, 2383, 2389, 2399, 2417, 2423, 2447, 2467, 2473, 2539, 2549, 2551, 2557, 2617, 2663,
- 2671, 2677, 2683, 2689, 2693, 2699, 2707, 2713, 2719, 2749, 2797, 2803, 2843, 2851, 2857, 2887, 2903,
- 2909, 2917, 2963, 2969, 2971, 3019, 3049, 3067, 3089, 3169, 3187, 3209, 3217, 3229, 3257, 3259, 3307,
- 3313, 3319, 3329, 3331, 3413, 3457, 3463, 3467, 3469, 3499, 3517, 3533, 3539, 3541, 3547, 3613, 3623,
- 3631, 3637, 3643, 3677, 3697, 3709, 3727, 3733, 3739, 3767, 3769, 3803, 3853, 3889, 3917, 3919, 3923,
- 3929, 3931, 4007, 4013, 4019, 4021, 4027, 4057, 4079, 4099, 4133, 4139, 4159, 4217, 4219, 4259, 4261,
- 4289, 4297, 4357, 4363, 4397, 4447, 4457, 4463, 4513, 4519, 4523, 4567, 4591, 4597, 4603, 4643, 4649,
- 4651, 4657, 4663, 4679, 4729, 4759, 4789, 4793, 4799, 4801, 4877, 4909, 4937, 4943, 4951, 4957, 4973,
- 4993, 4999, 5009, 5011, 5059, 5087, 5107, 5113, 5119, 5153, 5179, 5197, 5233, 5237, 5279, 5281, 5303,
- 5309, 5387, 5393, 5399, 5407, 5413, 5419, 5437, 5443, 5449, 5477, 5479, 5483, 5507, 5527, 5563, 5569,
- 5581, 5647, 5653, 5657, 5659, 5689, 5701, 5717, 5743, 5749, 5791, 5807, 5813, 5821, 5827, 5849, 5851,
- 5857, 5867, 5869, 5903, 5987, 6037, 6043, 6053, 6073, 6079, 6121, 6151, 6203, 6211, 6217, 6229, 6263,
- 6269, 6271, 6277, 6317, 6323, 6329, 6337, 6343, 6359, 6361, 6367, 6373, 6379, 6397, 6427, 6481, 6529,
- 6553, 6569, 6571, 6577, 6607, 6659, 6661, 6679, 6709, 6829, 6833, 6841, 6863, 6869, 6871, 6907, 6917,
- 6967, 6977, 6983, 6991, 6997, 7019, 7027, 7109, 7127, 7129, 7159, 7193, 7213, 7219, 7237, 7243, 7253,
- 7417, 7457, 7459, 7487, 7489, 7507, 7523, 7529, 7537, 7547, 7549, 7583, 7589, 7591, 7649, 7681, 7687,
- 7699, 7723, 7759, 7823, 7829, 7873, 7879, 7883, 7907, 7927, 7933, 8017, 8059, 8087, 8089, 8093, 8101,
- 8117, 8123, 8167, 8179, 8237, 8243, 8269, 8293, 8297, 8317, 8369, 8377, 8429, 8431, 8467, 8521, 8527,
- 8543, 8581, 8629, 8647, 8669, 8677, 8689, 8699, 8707, 8713, 8719, 8737, 8747, 8753, 8761, 8837, 8839,
- 8867, 8893, 8929, 8941, 8969, 8971, 9007, 9013, 9049, 9067, 9109, 9133, 9157, 9181, 9187, 9209, 9227,
- 9283, 9319, 9343, 9349, 9377, 9397, 9403, 9419, 9421, 9437, 9439, 9467, 9473, 9479, 9497, 9539, 9547,
- 9619, 9629, 9631, 9649, 9697, 9739, 9749, 9787, 9811, 9817, 9839, 9857, 9859, 9907, 9929, 9931, 9949,
- 9973, 10067, 10069, 10099, 10111, 10139, 10141, 10159, 10169, 10177, 10253, 10259, 10267, 10273, 10321,
- 10337, 10343, 10399, 10433, 10459, 10463, 10567, 10597, 10607, 10613, 10639, 10657, 10663, 10729, 10739,
- 10789, 10837, 10853, 10859, 10861, 10867, 10889, 10891, 10909, 10957, 10979, 10987, 10993, 11093, 11119,
- 11177, 11251, 11257, 11279, 11287, 11317, 11329, 11399, 11443, 11489, 11491, 11497, 11503, 11527, 11587,
- 11593, 11689, 11783, 11789, 11807, 11813, 11821, 11827, 11833, 11839, 11903, 11909, 11933, 11939, 11941,
- 11959, 11987, 12043, 12049, 12107, 12109, 12113, 12119, 12149, 12157, 12163, 12203, 12211, 12269, 12277,
- 12289, 12329, 12379, 12409, 12421, 12457, 12479, 12487, 12497, 12503, 12511, 12517, 12547, 12553, 12577,
- 12583, 12589, 12619, 12647, 12653, 12659, 12697, 12703, 12721, 12763, 12799, 12829, 12899, 12907, 12917,
- 12919, 12923, 12959, 12967, 12973, 12979, 13007, 13009, 13043, 13049, 13099, 13109, 13127, 13159, 13171,
- 13177, 13183, 13249, 13267, 13297, 13337, 13339, 13417, 13457, 13463, 13469, 13477, 13597, 13619, 13627,
- 13633, 13687, 13693, 13697, 13729, 13757, 13759, 13763, 13789, 13807, 13879, 13883, 13907, 13913, 13921,
- 14057, 14087, 14149, 14159, 14249, 14251, 14327, 14347, 14407, 14419, 14431, 14437, 14543, 14549, 14551,
- 14557, 14563, 14627, 14629, 14633, 14639, 14723, 14731, 14737, 14747, 14753, 14759, 14767, 14779, 14821,
- 14827, 14851, 14887, 14897, 14929, 14947, 14957, 15061, 15083, 15091, 15107, 15137, 15139, 15193, 15199,
- 15233, 15241, 15269, 15271, 15277, 15307, 15313, 15319, 15383, 15391, 15451, 15467, 15473, 15559, 15607,
- 15647, 15649, 15667, 15679, 15733, 15737, 15739, 15767, 15773, 15797, 15803, 15809, 15817, 15823, 15887,
- 15889, 15907, 15913, 15919, 16007, 16063, 16067, 16069, 16073, 16097, 16103, 16111, 16189, 16193, 16223,
- 16229, 16231, 16273, 16339, 16369, 16417, 16427, 16433, 16453, 16487, 16493, 16553, 16561, 16567, 16573,
- 16657, 16699, 16747, 16829, 16831, 16879, 16889, 16927, 16937, 16943, 16987, 16993, 17027, 17029, 17033,
- 17041, 17047, 17053, 17099, 17107, 17123, 17167, 17189, 17191, 17209, 17239, 17299, 17327, 17333, 17341,
- 17359, 17383, 17389, 17393, 17401, 17449, 17477, 17483, 17489, 17491, 17497, 17579, 17581, 17713, 17737,
- 17789, 17791, 17909, 17911, 17929, 17977, 17987, 17989, 18047, 18049, 18097, 18127, 18133, 18149, 18199,
- 18217, 18223, 18229, 18257, 18307, 18313, 18379, 18433, 18439, 18451, 18457, 18523, 18593, 18679, 18719,
- 18749, 18757, 18793, 18803, 18917, 18919, 18979, 19009, 19037, 19079, 19081, 19087, 19163, 19213, 19219,
- 19237, 19267, 19273, 19309, 19379, 19381, 19387, 19423, 19427, 19429, 19433, 19441, 19447, 19463, 19469,
- 19471, 19477, 19483, 19489, 19507, 19559, 19577, 19583, 19603, 19609, 19687, 19717, 19759, 19801, 19819,
- 19861, 19867, 19919, 19927, 19979, 19997 }, AncientPrimes.sumOfPrimes(5, 20000));
- }
- @Test
- void hardTests() {
- assertArrayEquals(new Integer[] { 5, 7, 13, 19, 31, 43, 61, 73, 103, 109, 139, 151, 181, 193, 199, 229, 241,
- 271, 283, 313, 349, 421, 433, 463, 523, 571, 601, 619, 643, 661, 811, 823, 829, 859, 883, 1021, 1033,
- 1051, 1063, 1093, 1153, 1231, 1279, 1291, 1303, 1321, 1429, 1453, 1483, 1489, 1609, 1621, 1669, 1699,
- 1723, 1789, 1873, 1879, 1933, 1951, 1999, 2029, 2083, 2089, 2113, 2131, 2143, 2239, 2269, 2311, 2341,
- 2383, 2551, 2593, 2659, 2689, 2713, 2731, 2791, 2803, 2971, 3001, 3121, 3169, 3253, 3259, 3301, 3331,
- 3361, 3373, 3391, 3463, 3469, 3529, 3541, 3559, 3583, 3673, 3769, 3823, 3853, 3919, 3931, 4003, 4021,
- 4051, 4093, 4129, 4159, 4219, 4231, 4243, 4261, 4273, 4339, 4423, 4483, 4519, 4549, 4639, 4651, 4723,
- 4789, 4801, 4933, 4969, 5011, 5023, 5101, 5233, 5281, 5419, 5443, 5479, 5503, 5521, 5641, 5653, 5659,
- 5743, 5851, 5869, 5881, 6091, 6133, 6199, 6271, 6301, 6361, 6451, 6553, 6571, 6661, 6691, 6703, 6763,
- 6781, 6793, 6829, 6871, 6949, 6961, 7129, 7213, 7309, 7333, 7351, 7459, 7489, 7549, 7561, 7591, 7759,
- 7879, 7951, 8011, 8089, 8221, 8233, 8293, 8389, 8431, 8539, 8599, 8629, 8821, 8839, 8863, 8971, 9001,
- 9013, 9043, 9241, 9283, 9343, 9421, 9433, 9439, 9463, 9631, 9679, 9721, 9769, 9859, 9931, 10009, 10039,
- 10069, 10093, 10141, 10273, 10303, 10333, 10429, 10459, 10501, 10531, 10711, 10861, 10891, 10939, 11059,
- 11071, 11119, 11161, 11173, 11353, 11491, 11551, 11701, 11719, 11779, 11833, 11941, 11971, 12043, 12073,
- 12109, 12163, 12241, 12253, 12379, 12541, 12613, 12823, 12919, 13003, 13009, 13219, 13339, 13399, 13681,
- 13693, 13711, 13723, 13759, 13831, 13879, 13903, 13933, 13999, 14011, 14083, 14251, 14323, 14389, 14449,
- 14551, 14563, 14593, 14629, 14869, 15139, 15271, 15289, 15331, 15361, 15583, 15643, 15649, 15733, 15739,
- 15889, 15973, 16063, 16069, 16141, 16189, 16231, 16363, 16453, 16633, 16651, 16693, 16831, 16903, 16981,
- 17029, 17191, 17209, 17293, 17389, 17419, 17491, 17581, 17599, 17659, 17683, 17749, 17791, 17839, 17911,
- 17923, 17959, 17989, 18043, 18049, 18061, 18121, 18133, 18253, 18289, 18313, 18523, 18541, 18913, 18919,
- 19081, 19141, 19183, 19213, 19381, 19423, 19429, 19471, 19543, 19699, 19753, 19843, 19891, 19963, 19993,
- 20023, 20149, 20233, 20359, 20443, 20479, 20509, 20551, 20641, 20719, 20749, 20773, 20809, 20899, 20983,
- 21013, 21019, 21061, 21193, 21319, 21379, 21493, 21523, 21559, 21589, 21601, 21613, 21649, 21739, 21841,
- 22039, 22093, 22111, 22159, 22273, 22279, 22369, 22483, 22543, 22573, 22621, 22639, 22699, 22741, 22861,
- 22963, 23029, 23041, 23059, 23203, 23293, 23371, 23539, 23563, 23629, 23671, 23689, 23743, 23833, 23911,
- 24109, 24181, 24373, 24421, 24919, 24979, 25033, 25171, 25303, 25309, 25411, 25471, 25579, 25603, 25801,
- 25849, 25933, 25999, 26113, 26251, 26263, 26683, 26701, 26713, 26731, 26863, 26881, 26893, 26953, 27061,
- 27109, 27241, 27283, 27409, 27481, 27529, 27541, 27583, 27691, 27739, 27751, 27793, 27919, 27943, 28099,
- 28111, 28183, 28279, 28309, 28351, 28411, 28549, 28573, 28621, 28663, 28753, 29023, 29131, 29209, 29389,
- 29401, 29569, 29671, 29761, 29881, 30013, 30091, 30139, 30271, 30391, 30469, 30493, 30559, 30841, 30853,
- 30871, 31081, 31123, 31153, 31183, 31249, 31321, 31393, 31513, 31543, 31723, 31729, 31771, 31849, 32029,
- 32059, 32119, 32143, 32191, 32299, 32323, 32371, 32413, 32443, 32533, 32563, 32611, 32719, 32803, 32833,
- 32911, 32941, 32971, 33073, 33151, 33181, 33289, 33331, 33349, 33589, 33601, 33619, 33751, 33769, 33811,
- 33829, 34033, 34129, 34159, 34213, 34261, 34303, 34369, 34471, 34501, 34513, 34591, 34651, 34759, 34843,
- 34849, 34963, 35053, 35083, 35281, 35449, 35509, 35533, 35593, 35731, 35803, 35839, 35899, 36013, 36109,
- 36343, 36469, 36529, 36781, 36793, 36901, 36931, 37021, 37201, 37309, 37339, 37363, 37549, 37573, 37591,
- 37693, 37783, 37813, 37993, 38239, 38329, 38449, 38461, 38569, 38611, 38653, 38671, 38713, 38749, 38923,
- 39043, 39163, 39229, 39241, 39343, 39373, 39511, 39829, 39841, 40039, 40129, 40153, 40429, 40531, 40639,
- 40699, 40849, 41143, 41179, 41203, 41233, 41389, 41413, 41521, 41611, 41761, 41851, 41959, 41983, 42019,
- 42073, 42181, 42223, 42283, 42409, 42463, 42571, 42643, 42703, 42841, 42901, 43051, 43321, 43399, 43543,
- 43579, 43609, 43651, 43783, 43789, 43891, 43963, 44029, 44089, 44131, 44203, 44269, 44281, 44383, 44533,
- 44623, 44701, 44773, 45121, 45139, 45181, 45319, 45343, 45589, 45823, 46051, 46093, 46183, 46273, 46309,
- 46351, 46441, 46591, 46681, 46771, 46819, 46831, 47059, 47149, 47353, 47389, 47419, 47659, 47701, 47713,
- 47743, 47779, 47809, 48121, 48313, 48409, 48481, 48541, 48649, 48679, 48733, 48781, 48823, 48859, 48871,
- 48991, 49033, 49123, 49171, 49201, 49279, 49333, 49369, 49393, 49411, 49531, 49549, 49669, 49741, 49789,
- 49921, 49939, 49993, 50023, 50053, 50131, 50263, 50461, 50551, 50593, 50893, 50971, 51061, 51133, 51199,
- 51241, 51343, 51349, 51421, 51439, 51481, 51721, 51769, 51829, 51871, 51973, 52069, 52183, 52291, 52363,
- 52543, 52711, 52861, 52903, 53089, 53149, 53173, 53233, 53269, 53281, 53551, 53593, 53611, 53719, 53899,
- 54013, 54403, 54421, 54499, 54541, 54583, 54631, 54919, 55051, 55219, 55333, 55339, 55441, 55621, 55633,
- 55663, 55819, 55903, 55933, 56041, 56101, 56209, 56239, 56269, 56479, 56503, 56533, 56599, 56713, 56809,
- 56893, 56911, 56923, 57193, 57223, 57271, 57331, 57349, 57529, 57559, 57793, 57901, 58111, 58153, 58171,
- 58231, 58369, 58393, 58441, 58453, 58603, 58789, 58909, 59011, 59023, 59053, 59209, 59221, 59359, 59419,
- 59443, 59473, 59629, 59671, 60091, 60103, 60169, 60259, 60649, 60661, 60763, 60889, 60901, 60919, 61153,
- 61333, 61381, 61471, 61561, 61981, 62131, 62143, 62191, 62299, 62929, 62971, 62983, 62989, 63031, 63199,
- 63313, 63391, 63421, 63589, 63601, 63649, 63691, 63841, 64153, 64189, 64303, 64453, 64579, 64663, 64783,
- 64879, 64921, 65029, 65101, 65173, 65269, 65449, 65521, 65539, 65581, 65701, 65719, 65731, 65839, 65929,
- 65983, 66109, 66361, 66571, 66751, 66853, 66949, 67141, 67189, 67213, 67219, 67273, 67411, 67429, 67579,
- 67759, 67933, 68113, 68209, 68281, 68449, 68491, 68713, 68821, 68881, 68899, 69031, 69151, 69193, 69259,
- 69403, 69493, 69499, 69739, 69763, 69829, 69859, 69931, 70003, 70123, 70141, 70183, 70201, 70381, 70459,
- 70489, 70573, 70621, 70843, 70879, 70921, 70951, 70981, 70999, 71263, 71329, 71341, 71389, 71413, 71473,
- 71551, 71713, 71809, 71881, 72091, 72103, 72169, 72223, 72229, 72253, 72271, 72469, 72649, 72673, 72871,
- 73039, 73063, 73363, 73609, 73681, 73849, 74101, 74161, 74203, 74383, 74413, 74509, 74611, 74719, 74731,
- 74761, 75013, 75169, 75211, 75391, 75403, 75541, 75619, 75709, 75991, 76003, 76081, 76159, 76261, 76369,
- 76423, 76543, 76651, 76831, 76873, 76963, 77239, 77263, 77269, 77419, 77479, 77491, 77551, 77689, 77713,
- 78139, 78193, 78439, 78511, 78541, 78571, 78781, 78889, 78979, 79153, 79231, 79399, 79561, 79633, 79693,
- 79699, 79813, 79843, 79903, 79999, 80149, 80209, 80233, 80449, 80473, 80491, 80629, 80671, 80683, 80749,
- 80779, 80833, 80911, 81019, 81043, 81049, 81199, 81283, 81373, 81553, 81649, 81703, 81901, 81931, 81973,
- 82009, 82039, 82141, 82219, 82351, 82471, 82531, 82561, 82723, 82729, 82759, 82813, 82891, 83221, 83233,
- 83269, 83341, 83401, 83563, 83641, 83719, 84061, 84181, 84223, 84319, 84349, 84391, 84523, 84631, 84811,
- 84859, 84871, 84979, 85093, 85201, 85333, 85363, 85429, 85453, 85621, 85669, 85819, 85831, 85933, 86029,
- 86113, 86293, 86353, 86371, 86533, 86629, 86929, 87013, 87121, 87151, 87181, 87223, 87253, 87511, 87541,
- 87559, 87589, 87631, 87643, 87721, 87961, 88003, 88261, 88339, 88471, 88591, 88609, 88663, 88801, 88813,
- 88819, 89071, 89521, 89563, 89599, 89659, 89671, 89821, 89899, 90019, 90073, 90199, 90373, 90403, 90439,
- 90529, 90619, 90679, 90823, 91081, 91099, 91129, 91141, 91153, 91369, 91459, 91573, 91813, 91969, 92179,
- 92221, 92383, 92401, 92461, 92569, 92641, 92671, 92683, 92791, 92863, 92959, 93133, 93241, 93253, 93283,
- 93481, 93493, 93559, 93703, 93763, 93811, 93889, 93913, 94009, 94111, 94153, 94309, 94351, 94399, 94441,
- 94531, 94543, 94561, 94651, 94849, 94951, 95089, 95191, 95233, 95443, 95791, 95803, 95959, 95989, 96181,
- 96223, 96331, 96589, 96739, 96799, 96823, 97003, 97159, 97171, 97303, 97369, 97381, 97501, 97549, 97579,
- 97609, 97651, 97789, 97843, 97849, 97861, 98011, 98299, 98323, 98389, 98563, 98641, 98713, 98731, 98809,
- 98869, 98899, 98911, 98929, 99133, 99139, 99259, 99349, 99529, 99709, 99721, 99991, 100153, 100363,
- 100393, 100519, 100549, 100801, 101113, 101119, 101161, 101209, 101281, 101503, 101533, 101749, 101839,
- 102001, 102061, 102079, 102103, 102199, 102253, 102301, 102409, 102499, 102679, 102763, 102913, 102931,
- 103069, 103093, 103291, 103393, 103423, 103813, 103843, 103969, 103981, 103993, 104089, 104149, 104233,
- 104311, 104383, 104473, 104551, 104683, 104761, 104803, 104851, 105229, 105253, 105361, 105529, 105769,
- 106033, 106123, 106189, 106219, 106279, 106321, 106453, 106543, 106621, 106663, 106753, 106783, 106861,
- 106963, 107071, 107101, 107509, 107719, 107839, 108013, 108109, 108193, 108289, 108379, 108463, 108499,
- 108709, 108793, 108883, 108949, 108961, 109141, 109171, 109201, 109453, 109471, 109519, 109621, 109663,
- 109831, 109843, 109849, 110323, 110479, 110503, 110569, 110731, 110821, 110881, 110923, 111031, 111121,
- 111229, 111271, 111493, 111733, 111781, 111829, 111871, 112069, 112249, 112291, 112339, 112363, 112573,
- 112603, 112759, 112921, 113023, 113041, 113083, 113149, 113161, 113173, 113329, 113359, 113383, 113539,
- 113623, 113719, 113761, 113779, 114043, 114199, 114601, 114643, 114661, 114691, 114799, 115021, 115153,
- 115303, 115321, 115363, 115471, 115603, 115771, 115783, 115861, 115879, 115903, 115933, 115981, 116101,
- 116191, 116533, 116539, 116689, 116791, 116929, 117043, 117193, 117241, 117331, 117373, 117499, 117541,
- 117619, 117673, 117703, 117811, 117841, 117883, 117979, 117991, 118171, 118213, 118249, 118411, 118621,
- 118801, 118903, 119089, 119101, 119131, 119293, 119299, 119419, 119551, 119659, 119689, 119701, 119773,
- 119851, 119923, 119983, 120049, 120079, 120691, 120739, 120919, 120943, 121021, 121063, 121171, 121351,
- 121369, 121441, 121579, 121609, 121633, 121789, 121951, 122029, 122041, 122053, 122149, 122203, 122209,
- 122323, 122389, 122401, 122503, 122599, 122611, 122653, 122743, 122869, 123379, 123493, 123553, 123583,
- 123733, 124123, 124183, 124249, 124303, 124339, 124351, 124429, 124543, 124771, 124783, 124909, 124981,
- 125119, 125221, 125509, 125641, 125791, 125899, 125929, 126013, 126229, 126493, 126613, 126859, 127033,
- 127081, 127219, 127249, 127291, 127609, 127681, 127711, 127819, 128113, 128203, 128239, 128341, 128413,
- 128521, 128551, 128659, 128749, 128833, 128941, 128971, 128983, 129121, 129223, 129289, 129403, 129499,
- 129529, 129589, 129631, 129643, 129919, 130201, 130261, 130369, 130411, 130621, 130633, 130651, 130843,
- 131011, 131113, 131251, 131449, 131479, 131641, 131713, 131779, 131839, 131893, 131941, 132049, 132331,
- 132439, 132529, 132709, 132751, 132763, 132859, 132949, 133279, 133321, 133351, 133543, 133633, 133711,
- 133813, 133981, 134089, 134293, 134341, 134371, 134401, 134593, 134683, 134839, 134923, 135019, 135211,
- 135283, 135349, 135391, 135433, 135463, 135469, 135601, 135649, 135721, 135913, 135979, 136069, 136399,
- 136483, 136603, 136651, 136693, 136711, 136753, 136813, 136861, 136951, 136993, 137089, 137119, 137341,
- 137869, 137911, 138079, 138181, 138241, 138373, 138403, 138451, 138571, 138799, 139123, 139201, 139303,
- 139369, 139459, 139591, 139663, 139969, 140071, 140419, 140551, 140629, 140683, 140731, 140761, 140839,
- 140869, 140893, 141181, 141223, 141499, 141511, 141679, 141709, 141769, 141853, 141961, 142099, 142159,
- 142591, 142609, 142699, 142759, 142789, 142873, 142981, 143113, 143263, 143503, 143569, 143653, 143833,
- 143881, 144073, 144163, 144169, 144409, 144481, 144541, 144889, 145009, 145513, 145549, 145603, 145681,
- 145723, 145759, 145933, 145969, 146011, 146023, 146059, 146299, 146383, 146521, 146683, 146893, 146989,
- 147031, 147139, 147211, 147229, 147451, 147673, 148063, 148153, 148201, 148303, 148471, 148669, 148693,
- 148723, 148783, 148861, 148933, 149059, 149101, 149113, 149161, 149251, 149419, 149491, 149521, 149533,
- 149563, 149629, 149713, 149731, 149839, 149911, 149971 }, AncientPrimes.sumOfPrimes(2, 150000));
- }
- @Test
- void failTest() {
- assertArrayEquals(new Integer[0], AncientPrimes.sumOfPrimes(40, 39));
- }
- @RepeatedTest(200)
- void testRandom() {
- Random random = new Random();
- int randomStart = random.nextInt(20);
- int randomEnd = random.nextInt(10000);
- assertArrayEquals(solution(randomStart,randomEnd), AncientPrimes.sumOfPrimes(randomStart,randomEnd));
class SolutionTest {@Testvoid exampleTests() {// assertEquals("expected", "actual");}- }
- }