Category Archives: computer science

Solution for the Random Selection Challenge

A few days ago, I wrote up two small Python Challenges. Several people have presented solutions for the first challenge, and I also posted my solution in the comments there. However, the second challenge remained unsolved, and I will present … Continue reading

Posted in computer science, Math, Programming, Python, Statistics, Utility Functions | Tagged , , , , , , , , | Leave a comment

Manually fuzzing my own compiler

As I mentioned before, I had to write a compiler for simplified CPL. An obvious requirement was that the compiler generate correct code. A less obvious requirement, but important none-the-less, was that after a syntax error, the compiler will keep … Continue reading

Posted in Compilation, computer science, Programming, Projects, Python | Tagged , , , , | Leave a comment

Writing a Quad Interpreter

My compilation homework is writing a compiler from simplified CPL to Quad, a made up assembly language. The compiler was going well, and when it started to emit code, I naturally wanted to test it. The problem is, I work … Continue reading

Posted in Assembly, Compilation, computer science, Personal, Programming, Python | Tagged , , | Leave a comment

Small Python Challenge No. 2 – LRU Cache

Caching is easy. Consider the cache I used to optimize the recursive spring: class _NotInDict(object): pass _NotInDict = _NotInDict() def cached(func): cache = {} def wrapper_func(*args): prev_result = cache.get(args, _NotInDict) if prev_result is _NotInDict: result = func(*args) cache[args] = result … Continue reading

Posted in Algorithms, Challenges, computer science, Programming, Python, Utility Functions | Tagged , , | 2 Comments

A classic programming challenge, in Python

It has become a tradition for computer scientists to create various self referential ‘strange loops’. Traditions such as writing a compiler in the language it compiles are actually quite useful – and also very interesting. This tradition also branched to … Continue reading

Posted in Challenges, computer science, Programming Philosophy, Python | Tagged , , | 6 Comments

Small Python Utility Functions 2

So I finished some time ago the first assignment in Numerical Analysis. Ahh, such a joyous occasion. Why you ask? Well, because I wrote the programming assignments in Python, and not some annoying made-up pseudo-code language. I know, I know, … Continue reading

Posted in computer science, Programming, Python | Tagged | Leave a comment

Pagerank recommends movies

So how was your Yom Kippur? After Yom Kippur ended, I sat down to write something that was nagging me for quite some time. I wanted to see what pagerank had to say about movies. I’ve always liked to picture … Continue reading

Posted in Algorithms, computer science, Math, Programming, Python | Tagged , , , | 1 Comment

Browser visibility-security and invisibility-insecurity

Formal languages have a knack of giving some output, and then later doing something completely different. For example, take the “Halting Problem“, but this is probably too theoretical to be of any relevance… so read on for something a bit … Continue reading

Posted in computer science, Design, Programming, Programming Philosophy, Security | Tagged | Leave a comment

Origami crease-patterns are NP-complete

After talking about it with someone I met, I looked it up, and it does seem to be so. There is of-course a lot of research on the subject that I didn’t yet get the chance to read, but I … Continue reading

Posted in computer science, Math, Origami, Protocols | Tagged , , | 1 Comment