Category Archives: computer-science

A Python 3 implementation of the MD5 Hash

Today we’ll see how to implement the MD5 hashing algorithm in Python. MD5 is a hash function, which was designed by Ron Rivest. I wrote it for my own education and perhaps it can help you as well. Even though the MD5 algorithm has been compromised and is not longer secure, it is still in […]

On the Lean proof assistant, Part 1

A long time ago I became interested in proof assistants. I tried Isabelle and Coq for sure and I might have tried Mizar. Here, ‘try’ could mean tried to install and failed. Some of them worked, but I quickly gave up using them. In all of them the documentation was bad and I couldn’t figure […]

OpenMP Tutorial: Part 2

This is a continuation of the OpenMP tutorial. Last time we wrote the following program: #include #include #include int main(int argc, char** argv){ long int N = 770948605618065977; printf(“Number to be tested: %ld\n”, N); long int upper = (long int) sqrt(N); omp_set_num_threads(2); #pragma omp parallel { int ID = omp_get_thread_num(); int start,stop; if (ID == […]

Simple OpenMP Tutorial

Today, I’ll give you a simple and practical example of using OpenMP with gcc. What’s OpenMP? It’s a C/C++/Fortran library for writing multithreaded applications. What’s that? Most computers these days have multiple cores so that multiple tasks can be done in parallel. With multiple cores, you can edit pictures and listen to music at the […]

Python’s “map” method and permutations of lists

Let’s look at Python’s map function. What does this function do? Here is the syntax: map(function, iterable, …) It takes a function called function and applies it to each element of iterable, returning the result as an iterable. For example: myList = [1,2,3,4] myList = map(lambda x:x**2 ,myList) for i in myList: print(i) The output […]

Polynomial over finite field: permutation polynomial?

Let’s assume you have a polynomial over a finite field $\F_q$, defined in Sage. How can you tell whether it’s a permutation polynomial? That is, when is the corresponding function $\F_q\to\F_q$ bijective? This is how you might have a polynomial over $\F_q$ defined in Sage: R. = GF(q) S. = PolynomialRing(R) f = 1 + […]

Book Review: Hsu’s Behind Deep Blue

Author: Feng-Hsiung Hsu Title: Behind Deep Blue: Building the Computer that Defeated the World Chess Champion I love battles of skill and stories of seemingly impossible goals. That’s the stuff of Bruce Lee, the Riemann hypothesis, and getting a tenure-track position. And then there’s the computer chess problem: create a machine that can beat the […]