2024-10-24 13:22:59 +02:00
|
|
|
const std = @import("std");
|
2024-10-27 00:44:48 +02:00
|
|
|
const writer = std.io.getStdOut().writer();
|
2024-10-27 00:16:29 +02:00
|
|
|
|
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 {
|
2024-10-27 00:16:29 +02:00
|
|
|
|
2024-10-24 13:22:59 +02:00
|
|
|
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-27 00:16:29 +02:00
|
|
|
|
|
|
|
try addMinutesToTimestamp(&testStamp, 175);
|
|
|
|
try printTimestamp(&testStamp);
|
2024-10-24 13:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Printet timestamp im Format HH:MM
|
|
|
|
pub fn printTimestamp(ts: *Timestamp) !void {
|
2024-10-27 00:16:29 +02:00
|
|
|
|
|
|
|
try writer.print("{0d:0>2}:{1d:0>2}", .{ ts.hours, ts.minutes });
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn addMinutesToTimestamp(ts: *Timestamp, min: u16) !void{
|
|
|
|
|
|
|
|
var addHours: u64 = min / 60;
|
|
|
|
var addMinutes: u64 = min%60;
|
|
|
|
|
|
|
|
|
|
|
|
if ((addMinutes + ts.minutes) >= 60){
|
|
|
|
addMinutes = (addMinutes + ts.minutes)%60;
|
|
|
|
addHours += 1;
|
2024-10-27 00:44:48 +02:00
|
|
|
ts.minutes = 0;
|
2024-10-27 00:16:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ts.hours += addHours;
|
2024-10-27 00:44:48 +02:00
|
|
|
ts.minutes += addMinutes;
|
2024-10-27 00:16:29 +02:00
|
|
|
|
2024-10-24 13:22:59 +02:00
|
|
|
}
|
2024-10-25 04:53:24 +02:00
|
|
|
|
|
|
|
pub fn printPlan() !void {
|
2024-10-27 00:16:29 +02:00
|
|
|
|
2024-10-25 04:53:24 +02:00
|
|
|
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;
|
|
|
|
}
|