Eric Foster 6 lat temu
rodzic
commit
225c289133
2 zmienionych plików z 33 dodań i 4 usunięć
  1. 1
    1
      .idea/vcs.xml
  2. 32
    3
      src/main/java/io/zipcoder/StringsAndThings.java

+ 1
- 1
.idea/vcs.xml Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project version="4">
3 3
   <component name="VcsDirectoryMappings">
4
-    <mapping directory="" vcs="Git" />
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5 5
   </component>
6 6
 </project>

+ 32
- 3
src/main/java/io/zipcoder/StringsAndThings.java Wyświetl plik

@@ -11,7 +11,22 @@ public class StringsAndThings {
11 11
      *           countYZ("day fyyyz"); // Should return 2
12 12
      */
13 13
     public Integer countYZ(String input){
14
-        return null;
14
+        Integer countYZ = 0;
15
+        for (int i=0; i<input.length()-1; i++){
16
+            char c = input.charAt(i);
17
+            char c1 = input.charAt(i+1);
18
+            if(c == 'y' || c == 'z'){
19
+                if(c1 == ' '){
20
+                    countYZ++;
21
+                }
22
+            }
23
+        }
24
+
25
+        if (input.charAt(input.length()-1) == 'y' ||
26
+                input.charAt(input.length()-1) == 'z') {
27
+            countYZ++;
28
+        }
29
+        return countYZ;
15 30
     }
16 31
 
17 32
     /**
@@ -24,7 +39,9 @@ public class StringsAndThings {
24 39
      *           withoutString("Hello there", "x") // Should return "Hello there"
25 40
      */
26 41
     public String withoutString(String base, String remove){
27
-        return null;
42
+        for (int i=0; i<base.length(); i++){
43
+            
44
+        }
28 45
     }
29 46
 
30 47
     /**
@@ -36,7 +53,19 @@ public class StringsAndThings {
36 53
      *           equalIsNot("noisxxnotyynotxisi") // Should return true
37 54
      */
38 55
     public Boolean equalIsNot(String input){
39
-        return null;
56
+        int numberOfIs = 0;
57
+        for (int i=0; i<input.length()-1; i++){
58
+            if (input.charAt(i) == 'i' && input.charAt(i+1) == 's'){
59
+                numberOfIs++;
60
+            }
61
+        }
62
+        int numberOfNot = 0;
63
+        for (int i=1; i<input.length()-1; i++){
64
+            if (input.charAt(i-1) == 'n' && input.charAt(i) == 'o' && input.charAt(i+1) == 't'){
65
+                numberOfNot++;
66
+            }
67
+        }
68
+        return (numberOfIs == numberOfNot);
40 69
     }
41 70
 
42 71
     /**