├── example_test_cases.txt ├── code_stubs ├── sort.py ├── sort.js ├── sort.go ├── sort.rs ├── sort.cpp └── sort.java ├── example_sort.py └── README.md /example_test_cases.txt: -------------------------------------------------------------------------------- 1 | Paste these into stdin to test your sorting 2 | 3 | Test case 1: 4 | 7 3 10 1 9 4 6 8 2 5 5 | 6 | Test case 2: 7 | 74 49 40 7 68 2 20 17 46 15 71 91 60 55 10 70 13 66 76 8 93 35 83 61 78 64 95 69 84 33 18 30 77 44 85 11 99 6 34 22 57 82 37 27 90 62 5 96 73 81 65 42 92 4 58 50 32 23 87 98 3 28 48 52 12 36 63 41 9 21 19 67 89 53 79 88 56 31 25 86 100 14 38 75 24 16 43 47 54 59 80 26 39 1 72 94 45 29 51 97 -------------------------------------------------------------------------------- /code_stubs/sort.py: -------------------------------------------------------------------------------- 1 | def print_array(arr): 2 | print("{") 3 | print(" ".join(map(str, arr))) 4 | print("}") 5 | 6 | def sort(arr): 7 | # Your code goes here! 8 | 9 | print_array(arr) # Make sure to call this print after every iteration 10 | 11 | if __name__ == "__main__": 12 | arr = list(map(int, input("Enter numbers separated by spaces: ").split())) 13 | 14 | print_array(arr) 15 | sort(arr) 16 | print_array(arr) 17 | -------------------------------------------------------------------------------- /code_stubs/sort.js: -------------------------------------------------------------------------------- 1 | const readline = require('readline'); 2 | 3 | const rl = readline.createInterface({ 4 | input: process.stdin, 5 | output: process.stdout 6 | }); 7 | 8 | function printArray(arr) { 9 | console.log("{"); 10 | console.log(arr.join(" ")); 11 | console.log("}"); 12 | } 13 | 14 | function sortArray(arr) { 15 | // Your code goes here! 16 | 17 | printArray(arr); // Make sure to call this print after every iteration 18 | } 19 | 20 | rl.question("Enter numbers separated by spaces: ", (input) => { 21 | const arr = input.split(" ").map(Number); 22 | 23 | printArray(arr); 24 | sortArray(arr); 25 | printArray(arr); 26 | 27 | rl.close(); 28 | }); 29 | -------------------------------------------------------------------------------- /code_stubs/sort.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | func printArray(arr []int) { 10 | fmt.Println("{") 11 | fmt.Println(strings.Trim(strings.Join(strings.Fields(fmt.Sprint(arr)), " "), "[]")) 12 | fmt.Println("}") 13 | } 14 | 15 | func sortArray(arr []int) { 16 | // Your code goes here! 17 | 18 | printArray(arr) // Make sure to call this print after every iteration 19 | } 20 | 21 | func main() { 22 | fmt.Print("Enter numbers separated by spaces: ") 23 | var input string 24 | fmt.Scanln(&input) 25 | 26 | strs := strings.Split(input, " ") 27 | var arr []int 28 | for _, s := range strs { 29 | num, err := strconv.Atoi(s) 30 | if err == nil { 31 | arr = append(arr, num) 32 | } 33 | } 34 | 35 | printArray(arr) 36 | sortArray(arr) 37 | printArray(arr) 38 | } 39 | -------------------------------------------------------------------------------- /example_sort.py: -------------------------------------------------------------------------------- 1 | def print_array(arr): 2 | print("{") 3 | print(" ".join(map(str, arr))) 4 | print("}") 5 | 6 | def sort(arr): 7 | # Your code goes here! 8 | 9 | # Example using bubble sort. Replace this with your algorithm. 10 | # If you use this, I will be disappointed... 11 | n = len(arr) 12 | for i in range(n): 13 | swapped = False 14 | for j in range(0, n-i-1): 15 | if arr[j] > arr[j+1]: 16 | arr[j], arr[j+1] = arr[j+1], arr[j] 17 | print_array(arr) # Make sure to call this print after every iteration 18 | swapped = True 19 | if not swapped: 20 | break 21 | 22 | if __name__ == "__main__": 23 | arr = list(map(int, input("Enter numbers separated by spaces: ").split())) 24 | 25 | print_array(arr) 26 | sort(arr) 27 | print_array(arr) 28 | -------------------------------------------------------------------------------- /code_stubs/sort.rs: -------------------------------------------------------------------------------- 1 | use std::io; 2 | 3 | fn print_array(arr: &[i32]) { 4 | println!("{{"); 5 | for (i, &num) in arr.iter().enumerate() { 6 | if i == arr.len() - 1 { 7 | print!("{}", num); 8 | } else { 9 | print!("{} ", num); 10 | } 11 | } 12 | println!("\n}}"); 13 | } 14 | 15 | fn sort(arr: &mut Vec) { 16 | // Your code goes here! 17 | 18 | print_array(arr); // Make sure to call this print after every iteration 19 | } 20 | 21 | fn main() { 22 | println!("Enter numbers separated by spaces: "); 23 | let mut input = String::new(); 24 | io::stdin().read_line(&mut input).expect("Failed to read line"); 25 | 26 | let arr: Vec = input 27 | .trim() 28 | .split_whitespace() 29 | .map(|s| s.parse().expect("Parse error")) 30 | .collect(); 31 | 32 | print_array(&arr); 33 | let mut sortable_arr = arr.clone(); 34 | sort(&mut sortable_arr); 35 | print_array(&sortable_arr); 36 | } 37 | -------------------------------------------------------------------------------- /code_stubs/sort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void print_array(const std::vector& arr) { 6 | std::cout << "{" << std::endl; 7 | for (size_t i = 0; i < arr.size(); ++i) { 8 | std::cout << arr[i]; 9 | if (i != arr.size() - 1) { 10 | std::cout << " "; 11 | } 12 | } 13 | std::cout << std::endl << "}" << std::endl; 14 | } 15 | 16 | void sort(std::vector& arr) { 17 | // Your code goes here! 18 | 19 | print_array(arr); // Make sure to call this print after every iteration 20 | } 21 | 22 | int main() { 23 | std::cout << "Enter numbers separated by spaces: "; 24 | std::string line; 25 | std::getline(std::cin, line); 26 | std::istringstream stream(line); 27 | 28 | int number; 29 | std::vector arr; 30 | while (stream >> number) { 31 | arr.push_back(number); 32 | } 33 | 34 | print_array(arr); 35 | sort(arr); 36 | print_array(arr); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /code_stubs/sort.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class ArraySorter { 4 | 5 | public static void printArray(int[] arr) { 6 | System.out.println("{"); 7 | for (int i = 0; i < arr.length; i++) { 8 | System.out.print(arr[i]); 9 | if (i != arr.length - 1) { 10 | System.out.print(" "); 11 | } 12 | } 13 | System.out.println("\n}"); 14 | } 15 | 16 | public static void sort(int[] arr) { 17 | // Your code goes here! 18 | 19 | printArray(arr); // Make sure to call this print after every iteration 20 | } 21 | 22 | public static void main(String[] args) { 23 | Scanner scanner = new Scanner(System.in); 24 | System.out.print("Enter numbers separated by spaces: "); 25 | String input = scanner.nextLine(); 26 | 27 | String[] inputStrings = input.split(" "); 28 | int[] arr = new int[inputStrings.length]; 29 | 30 | for (int i = 0; i < inputStrings.length; i++) { 31 | arr[i] = Integer.parseInt(inputStrings[i]); 32 | } 33 | 34 | printArray(arr); 35 | sort(arr); 36 | printArray(arr); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The LaurieWired 2023 Halloween Sorting Challenge 🎃 2 | 3 |

4 | 5 | 6 | **Have you ever wanted your code roasted on a LaurieWired Youtube video? Do you like Neon Genesis Evangelion and think your personal sorting algorithm outclasses decades of computer science research? Do you also enjoy custom, low-quality prizes being sent to your house? Here's your chance!** 7 | 8 | ## Objective 9 | Sort a list of intgers from smallest to largest. Anything goes. 10 | 11 | ## 📜 Rules 12 | 13 | - You *must* use one of the codestubs contained in the code_stubs folder in this repository. 14 | - C++, Java, Python, Go, Javascript, and Rust are allowable entries. Other languages *may* be considered on a case-by-case basis. 15 | - You *must* call the included print function after each iteration/step/operation of your algorithm. This will be used to produce visualizations of your algorithm for the video. (see [example_sort.py](example_sort.py)) 16 | - Integers will be sent via stdin seperated by spaces. (see [example_test_cases.txt](example_test_cases.txt)) 17 | - If I need to use a non-standard method to compile your code, call it out in the code comments. 18 | 19 | ## 🕛 Deadline 20 | 21 | Submissions will close at approximately 23:59 PST on Saturday, 10/28/2023. 22 | 23 | ## 📥 How to Submit 24 | 25 | All submissions must be sent as a private gist via this form: 26 | 27 | [Submit Form](https://forms.gle/FBMndkJtg9SzhWP89) 28 | 29 | The most interesting submissions will be featured in a special upcoming Halloween LaurieWired video. 30 | 31 | ## 🎁 Prize 32 | All "finalists" (aka entries that get featured in the upcoming LaurieWired video) will recieve a special custom gift from LaurieWired, mailed to an address of their choosing. 33 | 34 | ## 🤓 but I'm built diFfErEnt! 35 | Oh, wow! Look at you, coding in something no one's ever heard of! You think that makes you unique? Please! 36 | 37 | If you're dead set on being "that guy" that codes in raw ASM or some offbeat programming language, at the very least, stick to the example code stubs' format. Accept input via stdin, output to stdout at each iteration, and if your code's a wild puzzle, provide clear compile and run instructions. 38 | 39 | Keep in mind, if it's extremely annoying to run, I probably won't use it in the video. 40 | --------------------------------------------------------------------------------