This file contains 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
function pickrand(col) | |
index = rand(1:length(col)) | |
col[index] | |
end | |
function isbusy(intern, busy, day_hours, day, hour) | |
for i = 1:length(busy[intern]) | |
if busy[intern][i][1] == day && (busy[intern][i][2]-day_hours) <= hour < (busy[intern][i][3]-day_hours) | |
return true | |
end |
This file contains 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
# our schedule is 3D array with (5 workdays, W workhours, P positions) for dimensions | |
day_start = 9 | |
day_end = 17 | |
day_hours = day_end - day_start | |
positions = 4 | |
people = 8 | |
position_hours = 8 | |
work_hours = 20 | |
new_schedule() = fill(0, 5, day_hours, positions) |
This file contains 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
# our schedule is 3D array with (5 workdays, W workhours, P positions) for dimensions | |
day_start = 7 | |
day_end = 19 | |
positions = 4 | |
people = 8 | |
position_hours = 8 | |
work_hours = 20 | |
# generate random schedule of each intern's busy times | |
busy = ntuple(people, i -> fill((0,0,0), rand(0:7))) |
This file contains 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
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort (x:xs) = | |
let smallerSorted = quicksort [a | a <- xs, a <= x] | |
biggerSorted = quicksort [a | a <- xs, a > x] | |
in smallerSorted ++ [x] ++ biggerSorted |
This file contains 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
<?php | |
$day_start = 7; | |
$day_end = 19; | |
$positions = 4; | |
$people = 8; | |
$position_hours = 8; | |
$work_hours = 20; | |
$busy = [[[3,16,19]], |
This file contains 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
(defn tree | |
[arr] | |
(if (empty? arr) | |
[] | |
[[(tree (rest arr))] | |
[(tree (reverse | |
(rest | |
(reverse arr))))]])) |
This file contains 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
<?php | |
include 'schedule.php'; | |
$day_start = (int)$_POST['day_start']; | |
$day_end = (int)$_POST['day_end']; | |
$positions = (int)$_POST['positions']; | |
$people = (int)$_POST['people']; | |
$position_hours = (int)$_POST['position_hours']; | |
$work_hours = (int)$_POST['work_hours']; | |
if ($day_start >= $day_end || |
This file contains 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
(defmacro pattern | |
[n predecessor] | |
(vec | |
(concat (repeat n '_) | |
predecessor | |
'(& r)))) | |
(defmacro my-match | |
[state predecessor] | |
(let [diff (- (count state) |
This file contains 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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
ch := make(chan int) | |
for i := 0; i < 100; i++ { |
This file contains 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
package main | |
import ( | |
"math" | |
"sync" | |
) | |
type Component interface { | |
Name() string | |
} |