Mexi 6 years ago
parent
commit
5fa38addea

+ 16
- 0
.idea/compiler.xml View File

@@ -0,0 +1,16 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="CompilerConfiguration">
4
+    <annotationProcessing>
5
+      <profile name="Maven default annotation processors profile" enabled="true">
6
+        <sourceOutputDir name="target/generated-sources/annotations" />
7
+        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
8
+        <outputRelativeToContentRoot value="true" />
9
+        <module name="FundamentalDrills-Part1" />
10
+      </profile>
11
+    </annotationProcessing>
12
+    <bytecodeTargetLevel>
13
+      <module name="FundamentalDrills-Part1" target="1.5" />
14
+    </bytecodeTargetLevel>
15
+  </component>
16
+</project>

+ 13
- 0
.idea/misc.xml View File

@@ -0,0 +1,13 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="MavenProjectsManager">
4
+    <option name="originalFiles">
5
+      <list>
6
+        <option value="$PROJECT_DIR$/pom.xml" />
7
+      </list>
8
+    </option>
9
+  </component>
10
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="10" project-jdk-type="JavaSDK">
11
+    <output url="file://$PROJECT_DIR$/classes" />
12
+  </component>
13
+</project>

+ 8
- 0
.idea/modules.xml View File

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/FundamentalDrills-Part1.iml" filepath="$PROJECT_DIR$/FundamentalDrills-Part1.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
.idea/vcs.xml View File

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

+ 16
- 0
FundamentalDrills-Part1.iml View File

@@ -0,0 +1,16 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
4
+    <output url="file://$MODULE_DIR$/target/classes" />
5
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
+    <content url="file://$MODULE_DIR$">
7
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
9
+      <excludeFolder url="file://$MODULE_DIR$/target" />
10
+    </content>
11
+    <orderEntry type="inheritedJdk" />
12
+    <orderEntry type="sourceFolder" forTests="false" />
13
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
14
+    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
15
+  </component>
16
+</module>

+ 42
- 5
src/main/java/io/zipcoder/ArrayDrills.java View File

@@ -3,6 +3,7 @@ package io.zipcoder;
3 3
 public class ArrayDrills {
4 4
 
5 5
 
6
+
6 7
     /**
7 8
      * Given an array of ints, return true if value appears as either the first or last element in the array.
8 9
      * The array will be length 1 or more.
@@ -10,8 +11,21 @@ public class ArrayDrills {
10 11
      *           firstLast(6, [1,2,3]); // Should return false
11 12
      */
12 13
     public Boolean firstLast(Integer value, Integer[] input){
13
-        return null;
14
-    }
14
+
15
+         if(input[0] == value){
16
+
17
+            return true;
18
+
19
+        } else {
20
+
21
+
22
+         }
23
+            return false;
24
+        }
25
+
26
+
27
+
28
+
15 29
 
16 30
     /**
17 31
      * Given an array of ints, return true if the array is length 1 or more, and the first element and the last element are equal.
@@ -19,7 +33,15 @@ public class ArrayDrills {
19 33
      *           sameFirstLast([1,2,1]); // Should return true
20 34
      */
21 35
     public Boolean sameFirstLast(Integer[] input){
22
-        return null;
36
+        if (input.length >1 && input[0] == input[input.length-1]){
37
+
38
+            return true;
39
+
40
+        } else{
41
+
42
+        }
43
+
44
+        return false;
23 45
     }
24 46
 
25 47
 
@@ -30,7 +52,14 @@ public class ArrayDrills {
30 52
      *           commonEnd([1, 2, 3], [7, 3, 2]); // Should return false
31 53
      */
32 54
     public Boolean commonEnd(Integer[] input1, Integer[] input2){
33
-        return null;
55
+        if (input1[input1.length-1] == input2[input2.length-1]){
56
+
57
+            return true;
58
+        } else{
59
+
60
+
61
+        }
62
+        return false;
34 63
     }
35 64
 
36 65
     /**
@@ -39,10 +68,18 @@ public class ArrayDrills {
39 68
      *           rotateLeft([5, 11, 9]); // Should return [11,9,5]
40 69
      */
41 70
     public Integer[] rotateLeft(Integer[] input){
42
-        return null;
71
+        Integer[] arr = new Integer[input.length-1];
72
+        arr[0] = input[input.length-1];
73
+        for(int i=1;i<input.length;i++) {
74
+             arr[i] = input[i - 1];
75
+
76
+            }
77
+      return null;
43 78
     }
44 79
 
45 80
 
81
+
82
+
46 83
     /**
47 84
      * Given an array of ints, figure out which is element in the array is largest,
48 85
      * and set all the other elements to be that value. Return the changed array.

+ 1
- 1
src/test/java/io/zipcoder/ArrayDrillsTest.java View File

@@ -1,6 +1,6 @@
1 1
 package io.zipcoder;
2 2
 
3
-import com.sun.tools.corba.se.idl.InterfaceGen;
3
+//import com.sun.tools.corba.se.idl.InterfaceGen;
4 4
 import org.junit.Assert;
5 5
 import org.junit.Before;
6 6
 import org.junit.Test;