Skip to content

Instantly share code, notes, and snippets.

View muhammadmuzzammil1998's full-sized avatar
📚
Focusing on studies

Mohammad Muzammil Khan muhammadmuzzammil1998

📚
Focusing on studies
View GitHub Profile
@muhammadmuzzammil1998
muhammadmuzzammil1998 / CarlFriedrichGauss.c
Created September 15, 2017 14:47
Carl Friedrich Gauss's anecdote of how he summed up 1 to 100 in an interesting manner using a for loop.
/*
* I was reading about Carl Friedrich Gauss's anecdote of how he summed up 1 to 100
* in an interesting manner. So, I wanted to make it with a loop (I know, I am a
* lazy guy) and came up with this pretty quickly... so quickly that I thought I did
* it wrong but the output was same as the great mathematician. But I think that
* there is some another and easy way to do this, right?
*/
#include <stdio.h>
@omern1
omern1 / sleep_sort.rs
Last active May 23, 2021 10:19
A naive implementation of a strange sorting algorithm
//https://twitter.com/fermatslibrary/status/937687947041701888
use std::{thread, time};
use std::sync::{Arc, Barrier};
fn main() {
let elements = vec![9,8,7,6,5,4,3,2,1,0];
sleep_sort(elements);
}
fn sleep_sort(dataset: Vec<i32>) {
@muhammadmuzzammil1998
muhammadmuzzammil1998 / groups.js
Last active June 4, 2021 14:52
A simple script used to allocate students to random groups without biasness or discrimination.
const fs = require("fs"),
names = fs.readFileSync("./names.txt").toString().split("\r\n"),
noOfStudents = names.length,
studentsPerGroup = 6,
noOfGroups = Math.ceil(noOfStudents / studentsPerGroup)
let groups = []
for (i = 0; i < noOfGroups; i++) {
groups.push([])