And welcome back.
You've just seen GPT four zero spectacularly failed to work on our hard Python conversion problem.
And now we're going to see how Claude handles the same problem.
So we run the optimize method.
We get back a bunch of stuff from Claude.
Here it is.
And now we will run the clang optimized, uh, the method to compile and optimize this code and run
it and see what we get.
Oh, it was still generating.
And so a lot happened there.
And the reason that there was a long pause is that it hadn't yet finished producing the code, as I
just saw that it was like halfway finished, but it did just finish and then it compiled, and then
it ran and it got the correct answer.
And wowzer look at how fast that is.
Look at the difference.
Not only did Claude do this, but Claude has just done shockingly well.
That you will notice, is two milliseconds, two milliseconds Compared to the time that the Python code
have to go up to the Python code again.
Uh, and where did we do the Python code?
Here we go.
The Python code got the same answer in 27 seconds.
So, uh, I'm going to need to get a calculator here just to quickly, uh, tell myself 27.
It's something like 13,000 times faster.
Wow, wow.
So you should be blown away by that.
Uh, sometimes GPT four hasn't failed and has managed to generate some code.
And when it does, the code that it's generated, for me at least, um, has been faster, but more
like, uh, 10 or 100 times faster.
Not like Claude.
So how on earth has Claude been able to do this?
Uh, how has it managed to make such highly optimized code?
Like, is there something wrong with Python that, I mean, there must be something very wrong with
Python if it can be so, so much faster.
Well, no, there is a little bit more to the tale.
Um, if we look at the optimized code that Claude generated.
Hang on.
I think I have to close this and double click again to see it.
Here we go.
Um, there is a bit more to the tale.
There is a bit more to the tale.
What has happened?
What has happened is that, Claude, the direction that we gave Claude was to make sure that the same
response was generated, identical response in the fastest possible time.
And the prompt was very careful to say re-implement in C plus plus.
And that is exactly what Claude has done.
Claude, amazingly, has analyzed the code and understood the intent of the code.
Um, perhaps with a hint by the name of the function.
Although don't don't, uh, don't give it all away with the name of the function.
And there's a few things to try and cause it off track, but it has re-implemented this in a completely
different approach, using a theorem that I think it's called Shannon's, uh, algorithm.
Uh, I think that's right.
Yes, it is called Shannon's algorithm.
Uh, and, uh, it is an approach that allows you to solve this puzzle just with one loop.
One loop through.
Uh, sorry, I'm on the wrong loop here.
This is the loop.
One loop through, not a nested loop.
Uh, and as a result, uh, you can see there are there are, in fact, uh, two of them side by side.
But it's not a, it's not a, uh, a nested loop, a loop within a loop.
Um, and that allows you to get to the answer in a fraction of the time.
So what Claude has done, which is so ingenious, is it's understood the intent of the function, it's
not just translated something from Python to the equivalent C plus plus code, it has reimplemented
it just as it was prompted to get the same answer in a blazingly, uh, fast amount of time.
So I would say that is a terrific, terrific result by Claude.
Uh, and, uh, a round of applause there.
And it's certainly consistent with what we've seen from the Seal leaderboard.
Claude 3.5 sonnet, uh, rules the show.
Uh, Claude for the win.