Fixed zig formatting (via auto zig formatter).
parent
7b3f9036a5
commit
de09e40bc9
|
@ -16,16 +16,16 @@ test "simple partition #1" {
|
|||
defer {
|
||||
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});
|
||||
try expect(res == 1);
|
||||
}
|
||||
|
||||
pub fn bipartition(arr: []u64, t1: u64, t2: u64, v: u64) u64 {
|
||||
std.log.warn("Arr called with {}, {}, {}", .{t1, t2, v});
|
||||
var x1:u64 = t1;
|
||||
var x2:u64 = t2;
|
||||
var x:u64 = undefined;
|
||||
std.log.warn("Arr called with {}, {}, {}", .{ t1, t2, v });
|
||||
var x1: u64 = t1;
|
||||
var x2: u64 = t2;
|
||||
var x: u64 = undefined;
|
||||
|
||||
if (arr.len <= 0) {
|
||||
return x1;
|
||||
|
@ -40,7 +40,7 @@ pub fn bipartition(arr: []u64, t1: u64, t2: u64, v: u64) u64 {
|
|||
}
|
||||
|
||||
while (x1 < x2 - 1) {
|
||||
std.log.warn("Round {},{}", .{t1, t2});
|
||||
std.log.warn("Round {},{}", .{ t1, t2 });
|
||||
x = (x1 + x2) / 2;
|
||||
if (arr[x] < v) {
|
||||
x1 = x;
|
||||
|
|
Loading…
Reference in New Issue