I mean Python. This is a code question so basic that it doesn't deserve a thread.
I'm writing a Python script to generate the number of distinct outcomes for the board-game Pentago, which most of you have probably never heard of. Long story short, I need to find this:
f(x) = ax + x * f(x - 1)
When x = 36 and a = 8.
I made it work, but now I'm rewriting it to be a bit more open ended so that I can plug in different sized boards.
These are the two key functions.
:
def func(num, mul):
if num > 0:
return mul*num + num*func(num-1)
else:
return 0
def runScript():
print("How many 3x3 qudrants are in this board?")
quads = input(input_char + " ")
quads = int(quads)
mul_num = quads * 2
print()
area = quads * 9
print("Function will be run " + str(area) + " times")
print("Are you sure? (y/n)")
area = int(area)
b = input(input_char + " ")
if b == "y":
out = func(area, mul_num)
print()
print("This Pentago board has the following number of possible outcomes:")
print()
print(out)
else:
print()
print ("Ok!")
Whenever I run it I get an error in the highlighted line:
"func() is missing one positional argument: mul"
My initial thought was that I wasn't converting from a string properly, but not realising it because Python is stupid like that. I know shit all about coding in Python, but this was still much easier than the equivalent Java code as far as I'm concerned.
This is completely undocumented and will seem strange to anyone who doesn't know the game, but you can get the gist of what's happening there. Can anyone explain what's gone wrong?