4 ms·
I'm doing in COBOL: https://github.com/GaloisGirl/Coding/tree/master/AdventOfCode2020 https://github.com/GaloisGirl/Coding/tree/master/AdventOfCod... I'm havin
by galoisgirl 6y ago
I'm doing in COBOL: https://github.com/GaloisGirl/Coding/tree/master/AdventOfCode2020 https://github.com/GaloisGirl/Coding/tree/master/AdventOfCod...
I'm having a problem with day 7 with the lack of hash tables.
Care to share your BASIC solutions?
- Jtsummers 6y agoYou can do it without hash tables. 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.
- galoisgirl 6y agoThanks! I'll give that a try over the week-end.
- thequux 6y agoSo was I! https://thequux.github.io/posts/advent-of-cobol/advent-of-cobol-day-1/ https://thequux.github.io/posts/advent-of-cobol/advent-of-co... Sadly, I got jammed up with dealing with stream files on day 4, and then a C3 talk got accepted, so I haven't gotten much time to work on it since
- Mister_Snuggles 6y agoVery nice - I'll have to take a look at your COBOL when I've got some free time. My AOC code is also on GitHub: https://github.com/kimmeld/AOC2020 https://github.com/kimmeld/AOC2020 There are two things to keep in mind here: 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.
- nulbyte 6y agoThank 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.