recursion-tree-visualizer
recursion-tree-visualizer copied to clipboard
Online: Error,Offline:Ok
Old Bug:https://github.com/brpapa/recursion-tree-visualizer/issues/8#issue-974653096
Here is my code:
from functools import lru_cache
matchsticks =[5,5,5,5,16,4,4,4,4,4,3,3,3,3,4]
width=18
@lru_cache(None)
def fn(state,currEdgeWidth):
if state == (1 << len(matchsticks)) - 1:
return True
ans = False
for i in range(len(matchsticks)):
if not ((state >> i) & 1) and matchsticks[i] + currEdgeWidth <= width:
ans |= fn(state | (1 << i), (currEdgeWidth + matchsticks[i]) % width)
return ans
print(fn(0, 0))
It run ok on my local python
C:\Users\007>python
Python 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
But I get an Error in https://recursion.vercel.app/,
