#WEEKLY but different [[FIXED]]
Almost everyone did inverse division, but I did not I used no packages only default python and made my solution it is unique and not copied down hope you enjoy
UPDATE: it can now do float*float (this is the only place where I did double division) also put the bigger numbers in number 2 or it will give recursion error.
You are NOT ALLOWED to use the multiplication operator (*) or loops(for, while or any other that your prefered language may support, goto also counts as a loop).
this is illegal according to the rules. recursion or any similar construct in any language would count as a form of looping
@superwhiskers While recursion can emulate a loop, it is not a loop structure. The thing with goto does not include gosub (like in BASIC) which is the equivalent of functions in that sort of language. Additionally, if using JS, an interval is not a loop technically and same with requestAnimationFrame. Loop structures are not allowed, not necessarily loop emulations (recursion, intervals, animations, etc.), but a goto function is essentially a loop without being explicitly defined as a loop by going to a previous line and then reading from that line to the goto command, following the structure of a loop. However, recursion, intervals, and requestAnimationFrame are not following this structure, although it would be best to use recursion in this case due to the very close similarities between intervals and animation frames.
while yes, it isn't a loop, it is functionally equivalent in many ways. to further this argument, i would like to point out that there is something called tail-call optimization, which optimizes recursive functions into goto loops, which only highlights the similarities. if that isn't enough for you, i would also like to point out that it is extremely trivial to convert an imperative looping construct into a recursive definition, making it all more important that if you want to block looping, you cannot only disallow the common, imperative looping constructs.
@Lord_Poseidon if you couldn't use recursion, it would sorta kill the competition since it would just encourage only doing double division. multiplication is a fundamentally iterative operation, and even division is implemented through repetition- at a low level it also uses loops to get a result. disallowing strict imperative loops (for, while, loop, goto) but allowing things like recursion encourage more creative and more varied solutions. someone who would just do a for loop to sum integers will have to think outside the box for this competition, which might lead to them learning about recursion. and if you can learn something from the weekly challenge, you've already benefitted, regardless of how well you do. so recursion is cool
@qsa I totally understand. A solution may not be arrived at without looping/recursion of any kind. Recursion may not encourage more creativity as there's only so many ways you can add numbers. Blocking recursion might give even more diverse solutions out of the desire to be different from the inverse croud. Something like @PYer 's logarithm addition
That said. It is theoritically impossible to achieve multiplication without loops. This question is more about finding loopholes than writing algorithms smh
@Lord_Poseidon lmao yeah it's not really an algorithm type question. you could do something like that if you wanted to i guess. and yeah there's obviously the easy way out w recursion, and you can just use recursion for any loop, does make it relatively easy for integers. log addition is clever, i approached the problem from a more technical standpoint than math
@Lord_Poseidon that looks neat, i love how concise that python is. i went pretty heavy on the binary math lmao, made debugging a nightmare https://repl.it/@qsa/mulc
also if some value is like randomly 2x higher than it should be, lmk because that's happened a few times recently but i've caught all the bugs so far
Nice! However, I'd recommend using callback functions for modularity. Also, you can create your own method of float multiplication kind of like what I did in my submission (in JS though).
Traceback (most recent call last): File "main.py", line 31, in <module> start() File "main.py", line 29, in start print(multiply(x,y)) File "main.py", line 24, in multiply return(repeat(x,y,y)) File "main.py", line 5, in repeat return(repeat(times-1,multiple+baseline,baseline)) NameError: name 'baseline' is not defined