Questions tagged [stack]
For challenges involving stack-like data structures (see tag wiki for details), including interpreters of stack-based programming languages and challenges specifically about call stacks.
44 questions
21
votes
24
answers
4k
views
Implement a simple stack language
In this challenge, you implement an interpreter for a simple stack-based programming language. Your language must provide the following instructions:
push a positive number
pop two numbers and push ...
15
votes
4
answers
729
views
Could you massage this stack for me?
Forth is one of the few non-esoteric stack-based languages. For this challenge, we will use a small subset of Forth, which simply executes a sequence of words in a linear fashion — without any ...
27
votes
18
answers
2k
views
r flag my Vyxal
Vyxal is a stack-based language, meaning that everything operates by popping and pushing values onto a stack. It has a bunch of useful flags, one of which is r.
...
11
votes
7
answers
2k
views
Modify The Stack
Let's say you have a stack, which at the start contains a b c in this order (a is on the top). You are given the required output ...
48
votes
85
answers
8k
views
Implementing a stack
I can't believe we don't have this already.. It's one of the most important data-structures in programming, yet still simple enough to implement it in a code-golf:
Challenge
Your task is to ...
13
votes
1
answer
760
views
Can you outgolf Bill Gates?
Pancake sorting is the colloquial term for the mathematical problem of
sorting a disordered stack of pancakes in order of size when a spatula
can be inserted at any point in the stack and used to flip ...
17
votes
15
answers
4k
views
Help my son find his letters
Background
Based on a game my four-year-old got from his rabbi.
The "goal" is to "find" the letters in a given order, e.g. aecdb. You are given ...
11
votes
10
answers
864
views
Make an interpreter for yes!
Yes is a stack-based language that has a few space-separated instructions:
...
19
votes
10
answers
3k
views
This is how we roll
Piet is an interesting programming language for a number of reasons. Today we will focus on one reason: the roll command. The roll command was originally from PostScript and is a powerful way to ...
15
votes
2
answers
343
views
Solve a Stack State Diagram
A stack state diagram shows how the values on one stack are changed into the other. For example, this is a stack state diagram:
3 0 2 1 0
This means that there ...
23
votes
3
answers
3k
views
The Burnt Pancake Problem
This challenge is related to Flipping Pancakes.
You may have heard of pancake sorting, where a stack of pancakes is sorted by size by inserting spatula into the stack and flipping all of the pancakes ...
31
votes
9
answers
2k
views
Golf a Brain-Flak Integer
Integers are tedious to represent in Brain-Flak. There are 8 operators:
...
29
votes
8
answers
4k
views
Verify a Tower of Hanoi solution
If you don't know what the Tower of Hanoi is, I'll explain it briefly: There are three rods and some discs each of which has a different size. In the beginning all discs are on the first tower, in ...
18
votes
4
answers
973
views
Actually Integer Metagolf
Background
Actually (the successor to Seriously) is a stack-based imperative golfing language I created in November of 2015. Like many other golfing languages, it has one-byte commands that perform ...
19
votes
9
answers
2k
views
Write a brain-flak classic interpreter!
Brain-Flak (a cross between Brainf**k and Flak-Overstow) is a stack-based esoteric language. Since this challenge was posted, the language has evolved and updated, but this first revision of the ...