recursion-tree-visualizer icon indicating copy to clipboard operation
recursion-tree-visualizer copied to clipboard

Online: Error,Offline:Ok

Open Bollie15 opened this issue 3 years ago • 0 comments

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/, 1654048204(1)

Bollie15 avatar Jun 01 '22 01:06 Bollie15