Alien
1
A while ago I started doing this with Python:
Today it dawned on me that maybe I could do it in Dynamo.
So I just had a go.
Problem #1 is super easy in Dynamo! So much easier than I found it in Python.
However Problem #2 would be a total monster in Dynamo I think so I cheated and used a Python node.
The logic of #3 was shockingly easy in Dynamo, however I got to see a new (to me) error message:
I just tried a work around but I think I have killed Dynamo
I thought some of you may fancy having a go at these challenges too… But watch out for #3
1 Like
@Aparajit_Pratap
it looks like this message it thrown when the process runs out of memory, when OutOfMemoryException Class (System) | Microsoft Docs is thrown…
Alien
3
I’ve never seen it before. Always fun seeing new errors, I must be getting better
3 Likes
@Alien can you share the Dynamo graph that produced this warning?
Alien
5
The error happens in the first couple of nodes, not surprising though if you look at the challenge:
That’s a large number.
Had the same issue trying to stick it into a Python node too:
It kills regular (not in Dyno) python too… I think I need to rethink my logic
Daan
6
What about not starting at 2 but at n - 10.000 or so?
Also, you could skip over all even numbers by starting on an uneven number and doing something like this:
N-10000…N…2;
Alien
7
Yeah, I tried a few variations. It hates anything over 6-7 figures though so I’m rethinking the strategy.
1 Like
Alien
8
Got it working in a Python node but don’t think I can Dynamo it without murdering Dynamo.
Not really. Done in a flash.
def fb(a:var[]..[])
{
b = Math.Sum(List.TakeItems(a,-2));
return List.AddItemToEnd(b,a);
};
def fib(a)
{
b = fb(1..2);
return [Imperative]
{
c = [];
while (List.LastItem(b) < a)
{
c = fb(b);
b = c;
}
return List.DropItems(c,-1);
}
};
f1 = fib(4000001);
f2 = f1 % 2 == 0;
Math.Sum(List.FilterByBoolMask(f1,f2)["in"]);
3 Likes
Alien
10
I did it in Python in Dyno.
By Dyno, I mean actual code blocks.
While I don’t really understand designscript, what I can make out looks like we used the same logic.
1 Like