This seems like a great candidate for a future Advent of Code! Old languages have a special place in my heart, so doing Advent of Code with them is kind of fun.
I'm doing this year's in UniVerse BASIC[0] which traces its roots back to Pick[1] which is only six years newer than COBOL, but manages to be less well-known.
If you're able to create a graph structure with references/access/pointer types or whatever COBOL uses you can have records with contents similar to:
record Bag:
string : Description
array of Bag Pointer : Children
array of Integer : Count
Where the indexes into the two arrays correlate. Since, as you parse, you don't know where the children may be, you can use an array to store the bags as you read them in. And in a second pass construct the graph proper. You may also want a set of pointers up to the bags containing a bag, but it's not, strictly, needed.
If I were doing this year's in C, I'd have done something like that since it, also, doesn't have a built-in hash table/dictionary.
First, UniVerse BASIC isn't the old BASIC like you'd find on an Apple ][ or C-64, nor is it the QBasic you'd find in MS-DOS. It has its own unique features, such as dynamic arrays.
Second, I'm taking advantage of UniVerse features where they make sense. When I do this I document it since the code only has a portion of the solution. So far, I've done these for an alternate version of day 4 and for day 7. In particular, I used a UniVerse file in place of a hash table for day 7.
Thank you for sharing! I tried this one year on one challenge, but was barely familiar with writing COBOL programs, so I didn't continue with it. But after seeing your repo, I might go back and try this alongside the Lisp and Python I've been doing this year.
I'm doing this year's in UniVerse BASIC[0] which traces its roots back to Pick[1] which is only six years newer than COBOL, but manages to be less well-known.
[0] https://news.ycombinator.com/item?id=25250582
[1] https://en.wikipedia.org/wiki/Pick_operating_system