Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes #33

Open
peluche opened this issue Aug 26, 2024 · 11 comments
Open

small fixes #33

peluche opened this issue Aug 26, 2024 · 11 comments

Comments

@peluche
Copy link

peluche commented Aug 26, 2024

Thank you for the cool puzzles!

I don't know how to do a clean pull request on a .ipynb so I'm just dropping things here in case you want to fix:

(1) puzzle 18 - linspace is making a lot of warnings

<ipython-input-398-250908f931bc>:4: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
  out[k] = float(i + (j - i) * k / max(1, len(out) - 1))

this is fixed by adding: i, j = i[0], j[0] at the start of the function so that it becomes:

def linspace_spec(i, j, out):
    i, j = i[0], j[0]
    for k in range(len(out)):
        out[k] = float(i + (j - i) * k / max(1, len(out) - 1))

(2) puzzle 18 - linspace in the youtube walkthrough https://youtu.be/Hafo7hIl8MU?t=3955
the solution use a max() it feels like cheating (don't use sum, and other builtins) so maybe instead:

return arange(n) * (j - i) / ((1 > (n - 1)) * 1 + (1 <= (n - 1)) * (n - 1)) + i # emulate a max

(3) the colab format is broken for "puzzle 21 bucketize", and "speed run" they appear as a comment inside the previous python cell instead of a markdown cell.
image

(4) what you are measure in the bonus at the very end is "code golf" not "speed run" because the runtime aren't very good, it's just the code length :)

PS:
Doing the puzzle felt a bit like doing lambda calculus but for tensors, very very basic building blocks but "turing complete" set of problems we can solve. That was really fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@peluche and others