2024-10-24 13:22:59 +02:00
|
|
|
const std = @import("std");
|
2024-10-25 04:53:24 +02:00
|
|
|
const writer = std.io.getStdOut().writer();
|
2024-10-24 13:22:59 +02:00
|
|
|
|
|
|
|
const Timestamp = struct {
|
|
|
|
hours: u64,
|
|
|
|
minutes: u64,
|
|
|
|
};
|
|
|
|
|
2024-10-24 15:02:23 +02:00
|
|
|
const testees:[]const []const u8 = &[_][] const u8 {
|
2024-10-25 04:53:24 +02:00
|
|
|
"1",
|
|
|
|
"2",
|
|
|
|
"3",
|
|
|
|
"4",
|
|
|
|
"5",
|
|
|
|
"6",
|
|
|
|
"7",
|
|
|
|
"8"
|
2024-10-24 15:02:23 +02:00
|
|
|
};
|
2024-10-25 04:53:24 +02:00
|
|
|
|
|
|
|
const number_of_testees: u64 = testees.len; // len von testees
|
|
|
|
const total_minutes: u64 = 60; // Gesamte Dauer in min
|
|
|
|
const pause_minutes: u64 = 2; // Länge der Pause zwischen 2 Testaten
|
2024-10-24 13:22:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
pub fn main () !void {
|
|
|
|
var testStamp = Timestamp {
|
|
|
|
.hours = 13,
|
|
|
|
.minutes = 5,
|
|
|
|
};
|
|
|
|
|
2024-10-25 04:53:24 +02:00
|
|
|
try writer.print("Amount tests: {d} \n\n", .{number_of_testees});
|
2024-10-24 15:02:23 +02:00
|
|
|
|
2024-10-24 13:22:59 +02:00
|
|
|
try printTimestamp(&testStamp);
|
2024-10-25 04:53:24 +02:00
|
|
|
try writer.print("\n", .{});
|
|
|
|
try printPlan();
|
2024-10-24 13:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Printet timestamp im Format HH:MM
|
|
|
|
pub fn printTimestamp(ts: *Timestamp) !void {
|
|
|
|
try writer.print("{d}:{d}", ts.*);
|
|
|
|
}
|
2024-10-25 04:53:24 +02:00
|
|
|
|
|
|
|
pub fn printPlan() !void {
|
|
|
|
const rand = std.crypto.random;
|
|
|
|
|
|
|
|
const noneNumber:u64 = number_of_testees+1;
|
|
|
|
|
|
|
|
var testees_order: [number_of_testees]u8 = undefined;
|
|
|
|
|
|
|
|
// Fill order array with noneNumber
|
|
|
|
for (testees_order, 0..) |_, index| {
|
|
|
|
testees_order[index] = noneNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Fill order array with a random order
|
|
|
|
for (testees, 0..) |_, blockIndex| {
|
|
|
|
while(true) {
|
|
|
|
const randIndex:u8 = rand.intRangeLessThan(u8, 0, number_of_testees);
|
|
|
|
|
|
|
|
if (arrayContains(&testees_order, randIndex)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
testees_order[blockIndex] = randIndex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (testees_order, 0..) |elem, index| {
|
|
|
|
try writer.print("Nr.{d}: {s} \n", .{index, testees[elem]});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn arrayContains(arr: []u8, q: i64) bool {
|
|
|
|
for (arr) |element| {
|
|
|
|
if (element == q) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|