From e27ea5c9a84c40e83b1e528558158ffb7dfc512d Mon Sep 17 00:00:00 2001 From: Adam Blank <blank@sneetch.local> Date: Tue, 10 May 2016 18:10:01 -0700 Subject: [PATCH] Adds more input files --- tests/README.md | 2 ++ tests/hashcode.input | 3 +++ tests/identity.input | 3 +++ tests/sort.input | 20 ++++++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 tests/README.md create mode 100644 tests/hashcode.input create mode 100644 tests/identity.input create mode 100644 tests/sort.input diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..d83ef1e --- /dev/null +++ b/tests/README.md @@ -0,0 +1,2 @@ +To test your code on other inputs, replace the P.input file with another file. We have provided +three examples for you which we will use to test your code. diff --git a/tests/hashcode.input b/tests/hashcode.input new file mode 100644 index 0000000..9cdbd01 --- /dev/null +++ b/tests/hashcode.input @@ -0,0 +1,3 @@ +public static void P(String input) { + System.out.print(input.hashCode()); +} diff --git a/tests/identity.input b/tests/identity.input new file mode 100644 index 0000000..b75fad8 --- /dev/null +++ b/tests/identity.input @@ -0,0 +1,3 @@ +public static void P(String input) { + System.out.print(input); +} diff --git a/tests/sort.input b/tests/sort.input new file mode 100644 index 0000000..0c065b2 --- /dev/null +++ b/tests/sort.input @@ -0,0 +1,20 @@ + public static void P(String input) { + /* Stupid Bubble Sort! */ + char[] array = input.toCharArray(); + boolean swapped = true; + int j = 0; + char tmp; + while (swapped) { + swapped = false; + j++; + for (int i = 0; i < array.length - j; i++) { + if (array[i] > array[i + 1]) { + tmp = array[i]; + array[i] = array[i + 1]; + array[i + 1] = tmp; + swapped = true; + } + } + } + System.out.println(new String(array)); + } -- GitLab