Want to get involved? We're always looking for ideas and content for Weekly Challenges.
SUBMIT YOUR IDEAI brute forced this one, would like to come back and use the iterative approach to properly construct the Euclid's algorithm method as outlined here https://www.cuemath.com/numbers/greatest-common-divisor-gcd/ but will have to revisit when I have more time :)
I have used Python to solve this.
This is the Python code, I am using:
from ayx import Alteryx
import pandas as pd
import math
data = Alteryx.read("#1")
df = pd.DataFrame(data, columns=['Material', 'Volume'])
def findgcd(x, y):
while(y):
x, y = y, x % y
return x
l = df.Volume.values
num1=l[0]
num2=l[1]
gcd=findgcd(num1,num2)
for i in range(2,len(l)):
gcd=findgcd(gcd,l[i])
result = gcd
output = pd.DataFrame([gcd], columns = ['Material A'])
Alteryx.write(output,1)
Here's the solution!
I wonder if my solution is sufficiently robust, but I think it would
the silliest thing happened though because the summarize tool produces a value that is not the minimum in the set...
Here's my solution.