Skip to content

Instantly share code, notes, and snippets.

View ggssh's full-sized avatar
🎯
Focusing

Yizhe Yuan ggssh

🎯
Focusing
  • China
  • 01:59 (UTC +08:00)
View GitHub Profile
@ggssh
ggssh / monkey_sort.rs
Created July 28, 2023 02:39
Monkey Sort
fn monkey_sort<T: Ord>(arr: &mut [T]) {
while !is_sorted(arr) {
arr.shuffle(&mut rand::thread_rng());
}
}
@ggssh
ggssh / sleep_sort.rs
Created September 15, 2021 12:40
Sleep sort in Rust
extern crate rand;
use rand::Rng;
use std::thread::{self, JoinHandle};
use std::time::Duration;
fn main() {
let mut v = Vec::<i32>::new();
let mut rng = rand::thread_rng();
for _ in 1..10 {