DEV Community

algorhymer
algorhymer

Posted on • Edited on

Tales of the Algorhymer: Red-Nosed Reports

A Computer Science flipbook with a soundtrack!

For YOU! 🥰 🥰 🥰

flipbook

keywords: prefix sum, suffix sum, scan lemma, time-space complexity optimization, array indexing safety, proof sketching

See the full story on Github Pages!

Disclaimer:

  • Dev.to does NOT allow JS. I need JS for page flipping.
  • It is NOT optimized for Mobile Devices.
  • It is NOT optimized for Figma Design Courses.
  • I'm now trying a more friendlier tone. But, just in case Dev.to Gods decide to delete my work again without prior notice or post-mortem explanation, I'm using Github Pages.

Top comments (4)

Collapse
 
algorhymer profile image
algorhymer

Thank you!

It was inspired by the noob code of Uncle Bob.
That Clojure I linked is slow, bloat code, but it is even doing an antipattern related to vector usage.
TL;DR You can beat Uncle Bob in time and space.

This flipbook is a declarative-imperative pincer.
Declarative -> Time O(N)
We use program derivation techniques (nod to Richard S. Bird's scan lemma) to un-junior Uncle Bob's code to reach O(N) time.
Imperative -> Space O(1)
After that we use a graphical proof sketch in Knuth's style to ensure O(1) additional space.
This is really important since allocations take precious time (aka the O(N) would be still slow, because it has to allocate stuff).

The low-hanging reuable lesson keywords here are:
prefix sum, suffix sum, monoids, representing constraints (inequalities) as geometrically

The big lesson imo is:
Instead of thinking destructively (how can I remove an element from a list),
we think constructively (what would be the coziest spareparts I can build a safe list out of)

All credits go to original coder: Senior Ex-Google Ex-Netflix Movie Director Christopher Nolan

Unless I made a mistake (I have 0 credible peer reviews), it is language agnostic.
Aka it works in your fav lang Python.

TL;DR Do we have to become imperative Jedis or a declarative Siths? Neither, break free

Collapse
 
algorhymer profile image
algorhymer

@klement_gunndu
Please understand that: You can ask me to delete this comment.
I will do it, you do not even have to explain why you want it, I will just do it.
I'm trying to not get banned from Dev.to yet again.
I want to adhere to the code of conduct, but I also want to be truthful and not masquarade my thoughts.

Here's my unfiltered message:
(Once again, feel free to ask me to delete it. I'll do it.)

I'm sorry, but I do not understand AI.
I'm not sure whether you are a human being or an autonomous AI agent, which is half content-generator / half site-crawler-spider.

spider

Collapse
 
klement_gunndu profile image
klement Gunndu

@algorhymer hey thanks i ll take it as a good compliment. I m a automation expert and it suits me to test my agents regularly and make them better every day.