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.

Filter by
Sorted by
Tagged with
19 votes
22 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 ...
RubenVerg's user avatar
  • 772
15 votes
4 answers
710 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 ...
Maya's user avatar
  • 5,663
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. ...
emanresu A's user avatar
  • 37.1k
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 ...
Command Master's user avatar
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 ...
ბიმო's user avatar
  • 16.8k
13 votes
1 answer
740 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 ...
Stewie Griffin's user avatar
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 ...
Adám's user avatar
  • 29.9k
10 votes
10 answers
852 views

Make an interpreter for yes!

Yes is a stack-based language that has a few space-separated instructions: ...
user avatar
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 ...
Mike Bufardeci's user avatar
15 votes
2 answers
332 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 ...
Esolanging Fruit's user avatar
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 ...
Sherlock9's user avatar
  • 12.2k
30 votes
9 answers
2k views

Golf a Brain-Flak Integer

Integers are tedious to represent in Brain-Flak. There are 8 operators: ...
Neil's user avatar
  • 169k
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 ...
KarlKastor's user avatar
  • 2,392
17 votes
4 answers
951 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 ...
user avatar
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 ...
DJMcMayhem's user avatar
14 votes
4 answers
679 views

Interpret StackyMath!

Time for you to implement my new stack based language! It's called StackyMath. This will be a stack based language with 8 operations on the stack and ways to add numbers to the stack. List of ...
J Atkin's user avatar
  • 5,080
25 votes
4 answers
716 views

Starry Metagolf

Starry is a funny esoteric programming language in which code consists only of +*.,`' where the actual command represented by each of those characters is determined ...
Martin Ender's user avatar
19 votes
5 answers
776 views

A Bit of a Pickle

Python's pickle module is used for serialisation, allowing one to dump an object in a way such that it can be later reconstructed. For this, pickle uses a simple stack-based language. To keep things ...
Sp3000's user avatar
  • 61.8k
13 votes
0 answers
784 views

We can do better: FALSE [closed]

The interpreter executable for FALSE is 1020 bytes large. I think we can do better than THIS: ...
RK.'s user avatar
  • 497
9 votes
1 answer
733 views

Take It or Leave It III: A Game Show for Computers

This is the third in a series of puzzles that I will be posting every Monday at Midnight PST, and the final variant of "Take It or Leave It". The first puzzle is located Here The second ...
LivingInformation's user avatar
20 votes
7 answers
3k views

Take It or Leave It II: A Game Show for Computers

This is the second in a series of puzzles that I will be posting every Monday at Midnight PST. The first puzzle is located Here. Context: A reclusive billionaire has created a game show to attract ...
LivingInformation's user avatar
29 votes
5 answers
2k views

Take It or Leave It: A Game Show for Computers

Context: A reclusive billionaire has created a game show to attract the world's best and brightest programmers. On Mondays at the stroke of midnight, he chooses one person from a pool of applicants ...
LivingInformation's user avatar
1 vote
0 answers
136 views

Create a working Stack [duplicate]

Your mission, if you choose to accept it, is to create a stack that can do basic math operations. Explanation: Your stack must be able to do basic arithmetic (+-*/)...
jado's user avatar
  • 2,682
24 votes
5 answers
674 views

StickStack Numbers

StickStack is a very simple stack-based programming language with only two instructions: | pushes the length of the stack onto the stack ...
randomra's user avatar
  • 20.8k
30 votes
24 answers
2k views

Evaluating Dotty Strings

Write a program that takes in an odd length string containing only the characters . and :. With the aid of an initially empty ...
Calvin's Hobbies's user avatar
11 votes
4 answers
1k views

Write a Shift Interpreter

EDIT: As some of you suspected, there was a bug in the official interpreter: the order of composition in . was reversed. I had two versions of the interpreter, and ...
Zgarb's user avatar
  • 42.5k
14 votes
6 answers
1k views

Generate a Rectangle from a Specification

Introduction This challenge is inspired by Grime, my 2D pattern matching language. Basically, you are given a "grammar" that describes two-dimensional grids of characters, and your job is to generate ...
Zgarb's user avatar
  • 42.5k
19 votes
1 answer
1k views

Translate Prelude to Befunge

This is Weekly Challenge #2. Theme: Translation Write a program or function that takes in source code for a program in Prelude and outputs code for an equivalent program in Befunge-93. For the ...
feersum's user avatar
  • 31.3k
19 votes
6 answers
6k views

Smallest Bytecode Interpreter/VM

Leaderboard - JIT Compiled (Lower is better) es1024 - 81.2 points (including a working compiler!) Kieth Randall - 116 points Ell - 121 points Leaderboard - Interpreted (Lower is better) ...
Colorfully Monochrome's user avatar
16 votes
5 answers
1k views

Mondrian painting description language

This challenge consists in coding an interpreter for a Mondrian painting description language (MPDL). Language definition The language operates on a stack of rectangles. A rectangle is defined by ...
Arnaud's user avatar
  • 8,513
35 votes
8 answers
2k views

Coating Every Pancake

You have a stack of pancakes on a plate with a glob of syrup on top so thick it can't run down the sides. You won't be happy to eat until both faces of each pancake have at least touched the syrup, ...
Calvin's Hobbies's user avatar
14 votes
4 answers
1k views

Write a Clem interpreter

Clem is a minimal stack-based programming language featuring first-class functions. Your objective is to write an interpreter for the Clem language. It should properly execute all examples included in ...
Orby's user avatar
  • 874
3 votes
1 answer
433 views

Make a Number Expression

Few years ago, an esoteric programming language named 아희(Aheui) was created. Well, actually you don't need to know about this language or Korean characters. Aheui uses stacks and a queue, but this ...
Snack's user avatar
  • 2,182
15 votes
8 answers
917 views

Shortest representation of an Underload number

Flavour text The stack-based esolang Underload has some interesting ties to functional programming. One of them is its treatment of the numerical datatype—like the lambda calculus, you ...
algorithmshark's user avatar
21 votes
6 answers
5k views

Tower of Hanoi Sort

Write a function/subroutine to sort a list of integers, Tower of Hanoi style. You will be given a stack of integers. This is the main stack. You are also given two more helper stacks. These helper ...
Justin's user avatar
  • 21.2k
145 votes
116 answers
52k views

Weirdest way to produce a stack overflow [closed]

As a programmer you certainly know the error of a stack overflow due to an obvious recursion. But there are certainly many weird and unusual ways to get your favourite language to spit that error out. ...
masterX244's user avatar
  • 4,032
19 votes
17 answers
2k views

Build interpreter for non-existent language

Build an interpreter for a fake, stack-based language that gets an input, interprets it, and outputs the result as an array of numbers. It should iterate through each byte and perform a different ...
Taconut's user avatar
  • 903
5 votes
4 answers
1k views

Shortest implementation of a linked list, stack and queue

Challenge Write the shortest program that implements the minimum requirements for a linked list, stack and queue. Minimum requirements Functions that allow the user to add and remove elements from ...
Rob's user avatar
  • 1,477
26 votes
11 answers
4k views

Flipping pancakes

In pancake sorting the only allowed operation is to reverse the elements of some prefix of the sequence. Or, think of a stack of pancakes: We insert a spatula somewhere in the stack and flip all the ...
daniero's user avatar
  • 18.6k
19 votes
2 answers
2k views

Compact a Befunge program

Befunge is a 2-dimensional esoteric programming language. The basic idea is that (one-character) commands are placed on a 2-dimensional grid. Control flow walks across the grid, executing commands it ...
Mechanical snail's user avatar
11 votes
17 answers
3k views

Tower of hanoi solver

For reference as to what the tower of Hanoi is, either Google it or look on the Wikipedia page. Your code should be able to do 2 things, and they are the following: Accept user input that specifies ...
Carter Pape's user avatar
5 votes
3 answers
1k views

Generate number in reverse polish notation

Your task is to write a function which accepts a number N and creates a string of Reverse Polish Notation which will generate that number. Valid operations are: ...
captncraig's user avatar
  • 4,633
26 votes
9 answers
5k views

Interpret ><> (Fish)

While ><> is not a popular language, it can be good for golfing and has been used on this website. It was inspired by Befunge and has some similarities in its instructions. Required Commands:...
Kevin Brown-Silva's user avatar
16 votes
5 answers
2k views

Interpret Befunge-93

The program will be provided as the first argument, stdin should be used for all read requests by the program and stdout for all write requests. It can be assumed that the program is less than 80 ...
Nemo157's user avatar
  • 2,071