Easy Understanding Python DFS
\n\n        def dfs(cards):\n            if len(cards) == 1:\n                return math.isclose(cards[0], 24) # do NOT use \'==\'\n            \n            #
\n```\n        def dfs(cards):\n            if len(cards) == 1:\n                return math.isclose(cards[0], 24) # do NOT use \'==\'\n            \n            # allow to start with any card\n            for k in range(len(cards)):\n                cards[k], cards[0] = cards[0], cards[k]\n                \n                # allow to combine with any card afterward\n                for i in range(1, len(cards)):\n                    if dfs(cards[1:i] + cards[i+1:] + [cards[0] + cards[i]]):\n                        return True\n\n                    if dfs(cards[1:i] + cards[i+1:] + [cards[0] * cards[i]]):\n                        return True\n                    \n                    if dfs(cards[1:i] + cards[i+1:] + [cards[0] - cards[i]]):\n                        return True\n\n                    if dfs(cards[1:i] + cards[i+1:] + [cards[i] -cards[0]]):\n                        return True\n\n                    if cards[i] != 0 and dfs(cards[1:i] + cards[i+1:] + [cards[0]/cards[i]]):\n                        return True\n\n                    if cards[0] != 0 and dfs(cards[1:i] + cards[i+1:] + [cards[i]/cards[0]]):\n                        return True\n                    \n            return False\n\n        return dfs(cards)\n```
['Depth-First Search']