# Halloween Party Problem Solution in Lisp

The problem: Alex is attending a Halloween party with his girlfriend Silvia. At the party, Silvia spots a giant chocolate bar. If the chocolate can be served as only 1 x 1 sized pieces and Alex can cut the chocolate bar exactly K times, what is the maximum number of chocolate pieces Alex can cut […]

# 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. […]

# Solution to Service Lane Problem on HackerRank

The problem: Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any risks. Luckily, a service lane runs parallel to the highway. The length of the highway and the service lane is N […]

# 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 […]

# Solution to Problem 2 on ProjectEuler Using Scheme

The problem: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, … By considering the terms in the Fibonacci sequence whose values do not exceed four million, […]

# Solution to Problem 1 on ProjectEuler Using Scheme

The problem: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. The solution in Scheme: (define (remainder x y) (- x […]

# 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 […]

# 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 Root Algorithms in Scheme

I am playing around with Lisp (Scheme dialect in this case), so I decided to write some square root algorithms. Here’s the first naive version I wrote. As you can see it only works with perfect squares (the first argument should always be 1, as it starts looking with it; the second argument is the […]

# Basic Elements of Programming

I am reading the SICP (Structure and Interpretation of Computer Programs) book right now, and I am impressed with the elegance and clarity in which the authors explain most concepts.