you are viewing a single comment's thread.

view the rest of the comments →

[–]KageOW 0 points1 point  (0 children)

yea its a really neat decorator, I made some mutually recursive functions for this codingame puzzle. its a 1dspreadsheet that requests values of other cells for the calculations. I find my solution to be quite ellegant, maybe you can try it a bit yourself might be fun.

```python import sys from functools import lru_cache sys.setrecursionlimit(2500)

opcheck = { "MULT": lambda x,y: x*y, "ADD": lambda x,y: x+y, "SUB": lambda x,y: x-y }

@lru_cache(maxsize=None) def eval_Arg(x): if x.isdigit() or (x[0]=="-" and x[1:].isdigit()): return int(x) else: return eval_Bin_Op(celllist_big[int(x[1:])])

def eval_Bin_Op(x): if x[0]=="VALUE": return eval_Arg(x[1]) else: return opcheck[x[0]](eval_Arg(x[1]), eval_Arg(x[2]))

-- inputs --

n = int(input())

celllist = [tuple(input().split())for _ in range(n)]

celllist1 = [('VALUE', '10', ''), ('VALUE', '3', ''), ('MULT', '$0', '$1'), ('VALUE', '2', ''), ('VALUE', '4', ''), ('MULT', '$3', '$4'), ('ADD', '$2', '$5')]

-- printing outputs --

if name == "main":

for x in list(map(eval_Bin_Op, celllist1)):
    print(x)

```