frazer
frazer
ATApache TinkerPop
Created by frazer on 12/31/2023 in #questions
Beginner Gremlin Questions
Hello - I am trying to do an Advent of Code challenge as a graph problem to learn some Gremlin, and am running into some walls. I'm working on Part 2 of Day 4. The conceit is that there are scratchcards, and that for the number of matches you have on a given card you win copies of other cards (e.g. a card with ID 3 that has two matches would win copies of the next two cards with ID 4 and 5, recursively generating more copies of cards if those two cards also had matches), and you're trying to count the total number of cards won for a given input of cards. I've attached the graph that I'm working with (the sample input from the challenge, visible at the link above). I've parsed the input into Card vertices with a cardId property, and CardNumber and WinningNumber vertices each with a value property and a fromCard edge pointing to the card they are from.
5 replies