Fixed zig formatting (via auto zig formatter).

master
Tomasz Polgrabia 2025-02-01 00:55:11 +01:00
parent 7b3f9036a5
commit de09e40bc9
1 changed files with 6 additions and 6 deletions

View File

@ -16,16 +16,16 @@ test "simple partition #1" {
defer { defer {
allocator.free(arr); allocator.free(arr);
} }
const res = bipartition(arr, 0, @as(u64, arr.len-1), 2); const res = bipartition(arr, 0, @as(u64, arr.len - 1), 2);
std.log.warn("Res {}", .{res}); std.log.warn("Res {}", .{res});
try expect(res == 1); try expect(res == 1);
} }
pub fn bipartition(arr: []u64, t1: u64, t2: u64, v: u64) u64 { pub fn bipartition(arr: []u64, t1: u64, t2: u64, v: u64) u64 {
std.log.warn("Arr called with {}, {}, {}", .{t1, t2, v}); std.log.warn("Arr called with {}, {}, {}", .{ t1, t2, v });
var x1:u64 = t1; var x1: u64 = t1;
var x2:u64 = t2; var x2: u64 = t2;
var x:u64 = undefined; var x: u64 = undefined;
if (arr.len <= 0) { if (arr.len <= 0) {
return x1; return x1;
@ -40,7 +40,7 @@ pub fn bipartition(arr: []u64, t1: u64, t2: u64, v: u64) u64 {
} }
while (x1 < x2 - 1) { while (x1 < x2 - 1) {
std.log.warn("Round {},{}", .{t1, t2}); std.log.warn("Round {},{}", .{ t1, t2 });
x = (x1 + x2) / 2; x = (x1 + x2) / 2;
if (arr[x] < v) { if (arr[x] < v) {
x1 = x; x1 = x;