Tariq Hook vor 6 Jahren
Commit
f03071a90e

+ 53
- 0
.gitignore Datei anzeigen

@@ -0,0 +1,53 @@
1
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
2
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3
+
4
+# User-specific stuff:
5
+.idea/**/workspace.xml
6
+.idea/**/tasks.xml
7
+.idea/dictionaries
8
+
9
+# Sensitive or high-churn files:
10
+.idea/**/dataSources/
11
+.idea/**/dataSources.ids
12
+.idea/**/dataSources.local.xml
13
+.idea/**/sqlDataSources.xml
14
+.idea/**/dynamic.xml
15
+.idea/**/uiDesigner.xml
16
+
17
+# Gradle:
18
+.idea/**/gradle.xml
19
+.idea/**/libraries
20
+
21
+.idea/**
22
+
23
+*.iml
24
+
25
+# CMake
26
+cmake-build-debug/
27
+cmake-build-release/
28
+
29
+# Mongo Explorer plugin:
30
+.idea/**/mongoSettings.xml
31
+
32
+## File-based project format:
33
+*.iws
34
+
35
+## Plugin-specific files:
36
+
37
+# IntelliJ
38
+out/
39
+
40
+# mpeltonen/sbt-idea plugin
41
+.idea_modules/
42
+
43
+# JIRA plugin
44
+atlassian-ide-plugin.xml
45
+
46
+# Cursive Clojure plugin
47
+.idea/replstate.xml
48
+
49
+# Crashlytics plugin (for Android Studio and IntelliJ)
50
+com_crashlytics_export_strings.xml
51
+crashlytics.properties
52
+crashlytics-build.properties
53
+fabric.properties

+ 6
- 0
.idea/vcs.xml Datei anzeigen

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

+ 20
- 0
pom.xml Datei anzeigen

@@ -0,0 +1,20 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <modelVersion>4.0.0</modelVersion>
6
+
7
+    <groupId>io.zipcoder</groupId>
8
+    <artifactId>FundamentalDrillsPart2</artifactId>
9
+    <version>1.0-SNAPSHOT</version>
10
+
11
+    <dependencies>
12
+        <dependency>
13
+            <groupId>junit</groupId>
14
+            <artifactId>junit</artifactId>
15
+            <version>4.12</version>
16
+            <scope>test</scope>
17
+        </dependency>
18
+    </dependencies>
19
+
20
+</project>

+ 64
- 0
src/main/java/io/zipcoder/StringsAndThings.java Datei anzeigen

@@ -0,0 +1,64 @@
1
+package io.zipcoder;
2
+
3
+public class StringsAndThings {
4
+
5
+    /**
6
+     * Given a string, count the number of words ending in 'y' or 'z' -- so the 'y' in "heavy" and the 'z' in "fez" count,
7
+     * but not the 'y' in "yellow" (not case sensitive). We'll say that a y or z is at the end of a word if there is not an alphabetic
8
+     * letter immediately following it. (Note: Character.isLetter(char) tests if a char is an alphabetic letter.)
9
+     * example : countYZ("fez day"); // Should return 2
10
+     *           countYZ("day fez"); // Should return 2
11
+     *           countYZ("day fyyyz"); // Should return 2
12
+     */
13
+    public Integer countYZ(String input){
14
+        return null;
15
+    }
16
+
17
+    /**
18
+     * Given two strings, base and remove, return a version of the base string where all instances of the remove string have
19
+     * been removed (not case sensitive). You may assume that the remove string is length 1 or more.
20
+     * Remove only non-overlapping instances, so with "xxx" removing "xx" leaves "x".
21
+     *
22
+     * example : withoutString("Hello there", "llo") // Should return "He there"
23
+     *           withoutString("Hello there", "e") //  Should return "Hllo thr"
24
+     *           withoutString("Hello there", "x") // Should return "Hello there"
25
+     */
26
+    public String withoutString(String base, String remove){
27
+        return null;
28
+    }
29
+
30
+    /**
31
+     * Given a string, return true if the number of appearances of "is" anywhere in the string is equal
32
+     * to the number of appearances of "not" anywhere in the string (case sensitive)
33
+     *
34
+     * example : equalIsNot("This is not")  // Should return false
35
+     *           equalIsNot("This is notnot") // Should return true
36
+     *           equalIsNot("noisxxnotyynotxisi") // Should return true
37
+     */
38
+    public Boolean equalIsNot(String input){
39
+        return null;
40
+    }
41
+
42
+    /**
43
+     * We'll say that a lowercase 'g' in a string is "happy" if there is another 'g' immediately to its left or right.
44
+     * Return true if all the g's in the given string are happy.
45
+     * example : gHappy("xxggxx") // Should return  true
46
+     *           gHappy("xxgxx") // Should return  false
47
+     *           gHappy("xxggyygxx") // Should return  false
48
+     */
49
+    public Boolean gIsHappy(String input){
50
+        return null;
51
+    }
52
+
53
+
54
+    /**
55
+     * We'll say that a "triple" in a string is a char appearing three times in a row.
56
+     * Return the number of triples in the given string. The triples may overlap.
57
+     * example :  countTriple("abcXXXabc") // Should return 1
58
+     *            countTriple("xxxabyyyycd") // Should return 3
59
+     *            countTriple("a") // Should return 0
60
+     */
61
+    public Integer countTriple(String input){
62
+        return null;
63
+    }
64
+}

+ 120
- 0
src/test/java/io/zipcoder/StringsAndThingsTest.java Datei anzeigen

@@ -0,0 +1,120 @@
1
+package io.zipcoder;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+public class StringsAndThingsTest {
8
+
9
+    private StringsAndThings stringsAndThings;
10
+
11
+    @Before
12
+    public void setup(){
13
+        stringsAndThings = new StringsAndThings();
14
+    }
15
+
16
+    @Test
17
+    public void countYZTest1(){
18
+        String input = "fez day";
19
+        Integer expected = 2;
20
+        Integer actual = stringsAndThings.countYZ(input);
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+
24
+    @Test
25
+    public void countYZTest2(){
26
+        String input = "day fez";
27
+        Integer expected = 2;
28
+        Integer actual = stringsAndThings.countYZ(input);
29
+        Assert.assertEquals(expected, actual);
30
+    }
31
+
32
+
33
+    @Test
34
+    public void countYZTest3 (){
35
+        String input = "day fyyyz";
36
+        Integer expected = 2;
37
+        Integer actual = stringsAndThings.countYZ(input);
38
+        Assert.assertEquals(expected, actual);
39
+    }
40
+
41
+    @Test
42
+    public void withoutStringTest1(){
43
+        String expected = "He there";
44
+        String actual = stringsAndThings.withoutString("Hello there", "llo");
45
+        Assert.assertEquals(expected, actual);
46
+    }
47
+
48
+    @Test
49
+    public void withoutStringTest2(){
50
+        String expected = "Hllo thr";
51
+        String actual = stringsAndThings.withoutString("Hello there", "e");
52
+        Assert.assertEquals(expected, actual);
53
+    }
54
+
55
+    @Test
56
+    public void withoutStringTest3(){
57
+        String expected = "Hello there";
58
+        String actual = stringsAndThings.withoutString("Hello there", "x");
59
+        Assert.assertEquals(expected, actual);
60
+    }
61
+
62
+    @Test
63
+    public void equalIsNotTest1(){
64
+        Boolean actual = stringsAndThings.equalIsNot("This is not");
65
+        Assert.assertFalse(actual);
66
+    }
67
+
68
+    @Test
69
+    public void equalIsNotTest2(){
70
+        Boolean actual = stringsAndThings.equalIsNot("This is notnot");
71
+        Assert.assertTrue(actual);
72
+    }
73
+
74
+    @Test
75
+    public void equalIsNotTest3(){
76
+        Boolean actual = stringsAndThings.equalIsNot("noisxxnotyynotxisi");
77
+        Assert.assertTrue(actual);
78
+    }
79
+
80
+    @Test
81
+    public void gIsHappyTest1(){
82
+        Boolean actual = stringsAndThings.gIsHappy("xxggxx");
83
+        Assert.assertTrue(actual);
84
+    }
85
+
86
+    @Test
87
+    public void gIsHappyTest2(){
88
+        Boolean actual = stringsAndThings.gIsHappy("xxgxx");
89
+        Assert.assertFalse(actual);
90
+    }
91
+
92
+    @Test
93
+    public void gIsHappyTest3(){
94
+        Boolean actual = stringsAndThings.gIsHappy("xxggyygxx");
95
+        Assert.assertTrue(actual);
96
+    }
97
+
98
+    @Test
99
+    public void countTripleTest1(){
100
+        Integer expected = 1;
101
+        Integer actual = stringsAndThings.countTriple("abcXXXabc");
102
+        Assert.assertEquals(expected, actual);
103
+    }
104
+
105
+    @Test
106
+    public void countTripleTest2(){
107
+        Integer expected = 3;
108
+        Integer actual = stringsAndThings.countTriple("xxxabyyyycd");
109
+        Assert.assertEquals(expected, actual);
110
+    }
111
+
112
+    @Test
113
+    public void countTripleTest3(){
114
+        Integer expected = 0;
115
+        Integer actual = stringsAndThings.countTriple("a");
116
+        Assert.assertEquals(expected, actual);
117
+    }
118
+
119
+
120
+}