|
1 | | -@@ -1,40 +1,35 @@ |
2 | | - const std = @import("std"); |
3 | | - var stdin = std.fs.File.stdin().readerStreaming(&.{}); |
| 1 | +@@ -3,39 +3,34 @@ |
| 2 | + var stdin_buffer: [4096]u8 = undefined; |
| 3 | + var stdin_reader = std.fs.File.stdin().readerStreaming(&stdin_buffer); |
| 4 | + const stdin = &stdin_reader.interface; |
4 | 5 |
|
5 | 6 | fn matchPattern(input_line: []const u8, pattern: []const u8) bool { |
6 | 7 | if (pattern.len == 1) { |
|
25 | 26 |
|
26 | 27 | - // You can use print statements as follows for debugging, they'll be visible when running tests. |
27 | 28 | - std.debug.print("Logs from your program will appear here!\n", .{}); |
28 | | -+ var input_buffer: [1024]u8 = undefined; |
29 | | -+ const input_len = try stdin.read(&input_buffer); |
30 | | -+ const input_slice = input_buffer[0..input_len]; |
| 29 | ++ const input_slice = try stdin.takeDelimiter('\n'); |
31 | 30 |
|
32 | 31 | - // TODO: Uncomment the code below to pass the first stage |
33 | 32 | - // |
34 | | -- // var input_buffer: [1024]u8 = undefined; |
35 | | -- // const input_len = try stdin.read(&input_buffer); |
36 | | -- // const input_slice = input_buffer[0..input_len]; |
| 33 | +- // const input_slice = try stdin.takeDelimiter('\n'); |
37 | 34 | - // |
38 | 35 | - // const pattern = args[2]; |
39 | | -- // if (matchPattern(input_slice, pattern)) { |
| 36 | +- // if (matchPattern(input_slice.?, pattern)) { |
40 | 37 | - // std.process.exit(0); |
41 | 38 | - // } else { |
42 | 39 | - // std.process.exit(1); |
43 | 40 | - // } |
44 | 41 | + const pattern = args[2]; |
45 | | -+ if (matchPattern(input_slice, pattern)) { |
| 42 | ++ if (matchPattern(input_slice.?, pattern)) { |
46 | 43 | + std.process.exit(0); |
47 | 44 | + } else { |
48 | 45 | + std.process.exit(1); |
|
0 commit comments