11const std = @import ("std" );
22const Allocator = std .mem .Allocator ;
3+ const ArrayList = std .ArrayList ;
34const string = []const u8 ;
45
56/// Task 1 -
67///
78/// Arguments:
89/// - `contents`: Input file contents.
10+ /// - `main_allocator`: Base allocator for everything.
911///
1012/// Returns:
1113/// - Solution for task 1.
12- pub fn solution_1 (contents : string ) ! i32 {
13- var arena = std .heap .ArenaAllocator .init (std . heap . page_allocator );
14+ pub fn solution_1 (contents : string , main_allocator : Allocator ) ! i32 {
15+ var arena = std .heap .ArenaAllocator .init (main_allocator );
1416 defer arena .deinit ();
1517
1618 const allocator = arena .allocator ();
@@ -23,12 +25,16 @@ pub fn solution_1(contents: string) !i32 {
2325///
2426/// Arguments:
2527/// - `contents`: Input file contents.
28+ /// - `main_allocator`: Base allocator for everything.
2629///
2730/// Returns:
2831/// - Solution for task 2.
29- pub fn solution_2 (contents : string ) ! i32 {
30- const lines = std .mem .split (u8 , contents , "\n " );
31- _ = lines ;
32+ pub fn solution_2 (contents : string , main_allocator : Allocator ) ! i32 {
33+ var arena = std .heap .ArenaAllocator .init (main_allocator );
34+ defer arena .deinit ();
35+
36+ const allocator = arena .allocator ();
37+ _ = try parse (contents , allocator );
3238
3339 return 1 ;
3440}
@@ -39,6 +45,7 @@ pub fn solution_2(contents: string) !i32 {
3945///
4046/// Arguments:
4147/// - `contents`: Input file contents.
48+ /// - `main_allocator`: Base allocator for everything.
4249/// - `allocator`: Allocator for the containers.
4350///
4451/// Returns:
0 commit comments