attemps from before

This commit is contained in:
2022-11-25 22:36:13 +01:00
commit 680da5cc2c
17 changed files with 5703 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
const std = @import("std");
pub fn main() anyerror!void{
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
//format:
//[d-d] [c]: [password]
//[minamount [sperator] maxamount] [character]: [password]
var file = try std.fs.cwd().openFile("input2", .{});
defer file.close();
const file_size:u64 = try file.getEndPos();
std.debug.print("{0} \n", .{file_size});
//var buffer = try allocator.alloc(u8, file_size);
//var reader = file.reader();
//var size = try reader.read(buffer);
//std.debug.print("{0} \n", .{buffer});
try file.seekTo(0);
const contents = try file.reader().readAllAlloc(
allocator,
file_size
);
defer allocator.free(contents);
// const passBuffer = try allocator.alloc(u8, 40); //get a 40 char buffer
// defer allocator.free(passBuffer);
const ArrayList = std.ArrayList;
var list = ArrayList(u8).init(allocator);
defer list.deinit();
for(contents)|char,index|{
if(char == 12){
std.debug.print("\n", .{});
//end of line, so clear everything
continue;
}
if(char == 45){
//current char is (-), so we take the input so far
//and set it as the min
for(list)|didget|{
}
}
list.append(char);
//put byte in buffer
//is current byte a dash (-)?
//yes, then this is min
//read untill space
//from (-) until the space, is the max
std.debug.print("{c}", .{char});
}
}
pub fn isPassValid(char:u8, amountMin:i32, amountMax:i32, input: []u8 )bool{
//in here check if password is valid
return false;
}
+1000
View File
File diff suppressed because it is too large Load Diff