To build a generic swap in C, pass the size explicitly, create a temporary byte buffer, then use memcpy three times to rotate the bit patterns.
VLA char buffer[size] is a GCC thing, for a more portable version malloc the temp and free it.
Stanford CS107, lecture 4
The youngest mathematician to win the Fields Medal in 40 years walked into UCLA and explained an unsolved problem that sits at the foundation of number theory. The companies that understand this mathematics hire at $400,000 a year and almost never post the jobs publicly.
His name is Manjul Bhargava. Fields Medal 2014. Princeton professor at 28. He reinvented the study of number fields and broke open problems that had been untouched for 200 years. His students go on to cryptography teams at Google, Jane Street, and the NSA before most mathematicians finish their PhDs.
This is UCLA, Distinguished Lecture Series, 2015. It covers square-free values of polynomials - a problem so deep that even the simplest version, x to the fourth plus 1, remains unsolved.
He starts with a question anyone can understand. If you pick a random integer, what is the probability it has no perfect square as a factor? The answer involves pi. It is 6 over pi squared - roughly 60 percent.
Then why. Each prime contributes independently. The probability of avoiding a squared factor at prime p is 1 minus 1 over p squared. Multiply over all primes and you get the Euler product for the Riemann zeta function. A question about integers connects directly to the deepest object in mathematics.
Then the hard part. For polynomials of degree four or higher in one variable not a single irreducible example is known where the conjecture is proven. Does x to the fourth plus 1 take infinitely many square-free values? Nobody knows.
Then the breakthrough. Bhargava shows how symmetry groups - algebraic structures acting on spaces of polynomials - can be used to transfer hard cases to easier ones. The technique works on a polynomial with degree 40 in 40 variables and resolves questions about quintic number fields that had been open for decades.
Watch the moment he describes a problem that the ABC conjecture would instantly solve - and notes that a proof of ABC has been sitting on the internet for years, unverified.
A cryptographer I know watched this series before joining a post-quantum security team. Said it was the first time algebraic number theory felt like engineering rather than pure abstraction.
Free on YouTube, UCLA Mathematics, full lecture series available.
This is a common C bug. You write a MAX macro, then call MAX(m++, n++). The preprocessor pastes the text, so it becomes (m++ > n++) ? m++ : n++. The smaller one increments once. The larger one increments twice.
Stanford CS107, lecture 12
My friends, mañana comienza el #adventofcode!
La razón por la que sigo recomendando está opción sobre otras alternativas es:
1. Te sirve para practicar inglés
2. La comunidad es inmensa
3. Sigue siendo súper retador y útil para practicar!
https://t.co/wUV558oNK8
The Fenwick Tree (Binary Indexed Tree)
> Criminally underrated !!
> Blazing fast !!
> Elegant as hell !!
> Prefix sums in O(log n) !!
> Point updates in O(log n) !!
> Super simple code !!
[[ Lower constant factors than a Segment Tree ]]
Great for competitive programming + analytics pipelines
And unlike Segment Trees…
You can fit the whole thing in your head
Some Use-case
👉 Running sums
👉 Frequency tables
👉 Order statistics
👉 Streaming analytics
👉 Sliding windows
👉 Cumulative frequencies in databases
Les dejo un video muy bueno sobre cómo diseñar APIs y cuándo elegir REST, WebSocket o gRPC.
También entra en arquitecturas y en cómo tomar mejores decisiones técnicas.
Si te gusta el backend, te va a sumar muchísimo.
👇
Functions are Vectors
This is a great blog post from Max Slater about how viewing functions as infinite dimensional vectors unlocks powerful tools from linear algebra.
I think this is an under-emphasized perspective in intro linear algebra classes.
List of Data Structures to know to pass LeetCode interviews:
1. HashMap
2. Array
3. Single Linked List
4. Doubly Linked List
5. Stack
6. Queue
7. Binary Search Tree
Want to understand B-trees better?
Try https://t.co/IBGLxVle6D and https://t.co/83QfJ8sNcd.
These are standalone sandboxes of the visuals I built for my "B-trees and database indexes" article. Helpful for learning B-tree insertion, search, and node splits.
Uno de mis recursos favoritos de toda la vida para aprender data structures y algoritmos es este podcast: BaseCS
Fue una sesión donde cada episodio habla de un tema en concreto: linked lists, DFS, BFS, trees y más
Lo escuchaba muchísimo cuando empecé a practicar para entrevistas
https://t.co/FQxbwHwoZl
Docker 101: Build and Publish a Container Image 🐳
One of the key Docker workflows is to build the project's image given its Dockerfile. Oftentimes, it's as simple as "docker build -t TAG" from the top folder, but not always.
Practice building images: https://t.co/BIzKbxAv0C
Last year I wrote my own database from scratch.
Here's some stuff I learned
1. DBs are one of the few programs that still have to worry about "running out of memory" even today with so much RAM
Example:
User runs
SELECT * from t
and t is 8GB in size but you only have 4GB RAM