This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Arrays.toString(range(4))); | |
| } | |
| static int[] range(int x) { | |
| int [] range = new int[x]; | |
| int num = 0; | |
| while (num < x) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Arrays.toString(reverserange(4))); | |
| } | |
| static int[] reverserange(int x) { | |
| int [] range = new int[x]; | |
| int num = x; | |
| int counter = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(maxval(lst)); | |
| } | |
| static int[] lst = {1, 2, 3}; | |
| static int maxval(int[] x) { | |
| int size = x.length; | |
| int counter = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Arrays.toString(reversed(lst))); | |
| } | |
| static int[] lst = {1, 2, 3, 4, 5}; | |
| static int[] reversed(int[] x){ | |
| int size = x.length; | |
| int[] xcopy = new int[size]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Arrays.toString(swapitem(lst, 3, 1))); | |
| } | |
| static int[] lst = {2, 3, 1, 5, 6, 7}; | |
| static int[] swapitem(int[] x, int y, int z) { | |
| int temp = x[y]; | |
| x[y] = x[z]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(issorted(lst)); | |
| } | |
| static int[] lst = {1, 0, 2, 3}; | |
| static boolean issorted(int[] x) { | |
| int size = x.length; | |
| for(int i=0; i<size-1; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Arrays.toString(sortthree(lst))); | |
| } | |
| static int[] lst = {8, 5000, 6}; | |
| static int[] sortthree(int[] x) { | |
| while (issorted(x) == false) { | |
| if (x[0] > x[1]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Arrays.toString(slicearray(lst, 3, 6))); | |
| } | |
| static int[] lst = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | |
| static int[] slicearray(int[] x, int start, int end) { | |
| int size = (end - start) + 1; | |
| int[] slice = new int[size]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(wordcount(statement)); | |
| } | |
| static String statement = "The apples are red."; | |
| static int wordcount(String x) { | |
| char[] charlist = x.toCharArray(); | |
| int count = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from strmodfunctions import * | |
| #linked list that links togeter a sentence. | |
| class Word (object): | |
| def __init__(self, first=None, rest=None): | |
| self.first = first | |
| self.rest = rest | |
| def get_data(self): | |
| return self.first |