Solution to Gem Stones Problem Using Lisp

The problem: John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lowercase latin letter from ‘a’ to ‘z’. An element can be present multiple times in a rock. An element is called a ‘gem-element’ if it occurs at least once in each of the rocks. […]

Utopian Tree Solution Using Lisp

The following problem comes from HackerRank: —– The Utopian tree goes through 2 cycles of growth every year. The first growth cycle of the tree occurs during the monsoon, when it doubles in height. The second growth cycle of the tree occurs during the summer, when its height increases by 1 meter. Now, a new […]

Should I Learn Common Lisp or Scheme?

First of you, if you are considering to learn functional programming, I highly recommend it. It’s one of the few programming paradigms that is really different from the usual imperative/procedural style. Depending on the language you choose it will definitely force you to think about programming in new ways. Lisp is a great choice for […]

C vs. Lisp Program Example

I was curious to see how a program to solve the same problem would look like in C and in Lisp. I went ahead and solved the problem below in both languages, using a very similar approach. Take your own conclusions! ——— James got hold of a love letter that his friend Harry has written […]

How to Run Scheme Programs from the Command Line

Since I started playing around with Lisp (Scheme dialect initially) I have been trying to find the simplest way possible to run my programs directly from the command line. MIT-Scheme allows you to load files with Scheme code, but you need to run it from inside the program, so not very practical. I also tried […]

Square Subsequences Problem

A reader asked if I could help him with the Square Subsequences problem on HackerRank. Basically you need to generate all subsequences of a given string (i.e., a powerset of the set of chars), count the number of subsequences that are square, and return this count. In the past I have already coded a powerset […]

Sockets Programming in C Using UDP Datagrams

Below you’ll find the code of a simple server-client program in C using UDP sockets for the transmission. Basically the client sends a message to the server, the server converts the message to uppercase and returns it to the client. If you want to see a simpler program first check this client-server program that only […]