Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Alyssa_MyPictureList.zip
Binary file not shown.
23 changes: 23 additions & 0 deletions Challenge 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Main {
public static void main(String[] args) {
int numbers[] = {8, 4, 5, 3, 4, 1, 6};
System.out.println(firstDuplicateIn(numbers));
}

public static int firstDuplicateIn(int[] numbers) {
int result= 0;
for (int i = 0; i < numbers.length; i++){
int first = numbers[i];
for (int a = i + 1; a < numbers.length - 1; a++){
int second = numbers[a];
if (first == second) {
result = first;
break;
}
}

}
return result;
}

}
36 changes: 36 additions & 0 deletions Challenge 1 # 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class Main {
public static void main(String[] args) {
//System.out.println("racecar is " + isPalindrome("racecar"));
//System.out.println("jis is " + isPalindrome("jis") );
System.out.println("haiiniah is " + isPalindrome("haiiniah") );
}


static boolean isPalindrome(String testString) {
int numberOfTimes;
if (testString.length()%2 == 0){
numberOfTimes = testString.length() / 2;
System.out.println("numberOfTimes:" + numberOfTimes);
}
else {
numberOfTimes = (testString.length() / 2);
System.out.println("numberOfTimes:" +numberOfTimes);
}
for(int i=0; i < numberOfTimes; i++){
// System.out.println("i=" +i);
//System.out.println("testString at i: " +testString.charAt(i));
//System.out.println(testString.length());
if (testString.charAt(i) == testString.charAt(testString.length()- i - 1)) {
System.out.println(testString.charAt(i));
return true;
}
else {
return false;
}
}

return false;
}
}