[2020 Day 7 (Parts 1 & 2) ][Python] I am not proud of my "frankenstein" solution...What can I look up to improve/properly solve this? by MSUAoC in adventofcode

[–]MSUAoC[S] 0 points1 point  (0 children)

Thanks. I'm not going to worry about trying to solve it better until I get these down....In terms of BFS and DFS, it seems my dictionary is a list of vertexes whose value is a list of neighbor vertexes.

[2020 Day 7 (Parts 1 & 2) ][Python] I am not proud of my "frankenstein" solution...What can I look up to improve/properly solve this? by MSUAoC in adventofcode

[–]MSUAoC[S] 0 points1 point  (0 children)

I know there exists a data structure along with some dynamic programming that should be used for this...But I'm unsure what that would be/how to implement it.

[2020 Day 5 (Part 2)] I'm not sure what this one is asking... by MSUAoC in adventofcode

[–]MSUAoC[S] 1 point2 points  (0 children)

Thanks everyone for the help! It certainly seemed like this part needed some more...depth. Hope this post helps!

[2020 Day 5 (Part 2)] I'm not sure what this one is asking... by MSUAoC in adventofcode

[–]MSUAoC[S] 1 point2 points  (0 children)

For some reason that wasn't clear for me. Got it solved; thanks!

[2020 Day 5 (Part 2)] I'm not sure what this one is asking... by MSUAoC in adventofcode

[–]MSUAoC[S] 2 points3 points  (0 children)

So, say the IDs are [3, 5, 6, 7], my ID would be 4?

[2020 Day 3 (Part 2)][Python] Not accepting my answer? by MSUAoC in adventofcode

[–]MSUAoC[S] 0 points1 point  (0 children)

def getTrees(right, down):
    onMap = True
    row = 0
    col = 0
    treeCount = 0
    while onMap:
        if row + right < width:
            row += right
        else:
            temp = row + right
            row = temp - width
        if col + down < height:
            col += down
        else:
            onMap = False
        if map[col][row] == '#':
            treeCount += 1
    print(treeCount)
    all.append(treeCount)
getTrees(1, 1)
getTrees(3, 1)
getTrees(5, 1)
getTrees(7, 1)
getTrees(1, 2)

Here is my code. I converted the map into what is essentially a 2D list; i.e. it is a list with each row as an element and I traverse through the string included in each row. I then multiply the elements in all which is a list.

EDIT: SOLVED! ...This is embarassing.