const std = @import("std"); const writer = std.io.getStdOut().writer(); const Timestamp = struct { hours: u64, minutes: u64, }; const testees:[]const []const u8 = &[_][] const u8 { "1", "2", "3", "4", "5", "6", "7", "8" }; 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 pub fn main () !void { var testStamp = Timestamp { .hours = 13, .minutes = 5, }; try writer.print("Amount tests: {d} \n\n", .{number_of_testees}); try printTimestamp(&testStamp); try writer.print("\n", .{}); try printPlan(); try addMinutesToTimestamp(&testStamp, 175); try printTimestamp(&testStamp); } // Printet timestamp im Format HH:MM pub fn printTimestamp(ts: *Timestamp) !void { 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; ts.minutes = 0; } ts.hours += addHours; ts.minutes += addMinutes; } 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; }