import java.time.LocalDateTime; import java.util.*; public class LongRangeKnownMethods { void testIndexOf(String s) { int idx = s.indexOf("xyz"); if(idx >= 0) { System.out.println("Found"); } else if(idx == -1) { System.out.println("Not found"); } } void testLocalDateTime(LocalDateTime ldt) { if(ldt.getHour() == 24) System.out.println(1); if(ldt.getMinute() >= 0) System.out.println(2); if(ldt.getSecond() >= 60) System.out.println(3); } private static int twiceIndexOf(String text, int start, int end) { int paragraphStart = text.lastIndexOf("\n\n", start); int paragraphEnd = text.indexOf("\n\n", end); if (paragraphStart >= paragraphEnd) { return text.length(); } return (paragraphStart >= 0 ? paragraphStart + 2 : 0) + (paragraphEnd < 0 ? text.length() : paragraphEnd); } void test(String s) { if (s.isEmpty() && s.length() > 2) { System.out.println("Never"); } } void test2(String s) { if (s.isEmpty() && s.length() == 0) { System.out.println("Ok"); } } void test3(String s) { if (s.startsWith("xyz") && s.length() < 3) { System.out.println("Impossible"); } } void testEmpty(String s) { if (s.isEmpty() && s.startsWith("xyz")) { System.out.println("Impossible"); } } void testOk(String s) { if (s.length() <= 3 && s.endsWith("xyz")) { System.out.println("Possible"); } } void testInterfere(String s, String s2) { if (!s.isEmpty() && s2.startsWith(s)) { if(s2.isEmpty()) { System.out.println(); } } } void test4() { String s = "abcd"; if (s.startsWith("efg")) { System.out.println("Impossible"); } } void testEquals(boolean b, boolean c) { String s1 = b ? "x" : "y"; String s2 = c ? "x" : "b"; if(s1.equals(s2) && b) { System.out.println("B is always true"); } } void testEqualsIgnoreCase(String s) { if(s.equalsIgnoreCase("xyz") && s.isEmpty()) { System.out.println("Never"); } } void testIndexOfUpperBound(String s) { int idx = "abcdefgh".indexOf(s); if(idx > 8) { System.out.println("Impossible"); } } void testMax(int x) { x = Math.max(x, 0); if (x > -1) { System.out.println("Always"); } if (x > 0) { System.out.println("Not always"); } } void testMin(long x, long y) { if (x < 10 && y > 10) { y = Long.min(x, y); if (y > 20) { System.out.println("Impossible"); } } if (y > 20) { System.out.println("Possible"); } } void testMinMax(List rows) { int start = Integer.MAX_VALUE; int end = -1; for (int i = 0; i < rows.size(); i++) { String row = rows.get(i); if (!row.isEmpty()) { start = Math.min(start, i); end = Math.max(end, i); } } if(end >= 0 && start < Integer.MAX_VALUE) { System.out.println("Ok"); } } void testAbs(long x, int y) { x = Math.abs(x); y = Math.abs(y); if (x == Long.MIN_VALUE) { System.out.println("possible"); } if (x == Long.MIN_VALUE + 1) { System.out.println("impossible"); } if (x == Integer.MIN_VALUE) { System.out.println("impossible"); } if (y == Integer.MIN_VALUE) { System.out.println("possible"); } else if(y < 0) { System.out.println("impossible"); } } void testStringComparison(String name) { // Parentheses misplaced -- found in AndroidStudio if (!(name.equals("layout_width") && !(name.equals("layout_height")) && !(name.equals("id")))) { System.out.println("ok"); } } void testFlush(MyReader r) { if(r.getValue().equals("abc")) { r.readNext(); if(r.getValue().equals("abcd")) { System.out.println("ok"); } } } void testNoFlush(MyReader r) { if(r.getValue().equals("abc")) { if(r.getValue().equals("abcd")) { System.out.println("ok"); } } } static class MyReader { private String value = ""; final String getValue() { return value; } void readNext() { value = new Scanner(System.in).next(); } } void testEmptyList(List list) { if (list.get(0).isEmpty() && list.isEmpty()) { System.out.println("impossible"); } } void testEmptyListGet(List list) { if (list.isEmpty()) { System.out.println(list.get(0)); } } void testBoundError(List list) { if (list.size() < 10) { System.out.println(list.get(10)); } } void testCollectionArray(Set currentElements, Object[] elements) { if(!currentElements.isEmpty() && elements.length == currentElements.size()) { if (elements.length > 0) { System.out.println("Yes"); } } } public String getOrThrow(int index, List localVariables) { if (index < localVariables.size()) { return localVariables.get(index); } else if (index < 0) { throw new IndexOutOfBoundsException(); } else return ""; } void testSetFirst(TreeSet set) { if (set.first() == 0 && set.size() > 0) { System.out.println("Impossible"); } } void testMap(HashMap map) { if(map.isEmpty() && map.containsKey("xyz")) { System.out.println("Impossible"); } } void testMapContainsValue(TreeMap map) { if(map.containsValue(1) && map.size() < 1) { System.out.println("Impossible"); } } void testMapEquals(Map map, Map otherMap) { if(map.isEmpty() && otherMap.equals(map) && otherMap.containsValue("xyz")) { System.out.println("Impossible"); } } void testListIndexOf(List list) { if(list.size() == 10 && list.indexOf("xyz") == 15) { System.out.println("Impossible"); } } void testGetUnknown(List list, int index) { if(list.get(index).isEmpty() && list.isEmpty()) { System.out.println("Impossible"); } } }