Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

43
votes
76answers
7k 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 ...
12
votes
1answer
571 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 ...
17
votes
15answers
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 a stack of letter ...
10
votes
9answers
616 views

Make an interpreter for yes!

Yes is a stack-based language that has a few space-separated instructions: ...
18
votes
10answers
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
2answers
257 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
3answers
1k 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 ...
27
votes
8answers
1k views

Golf a Brain-Flak Integer

Integers are tedious to represent in Brain-Flak. There are 8 operators: ...
29
votes
8answers
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 ...
17
votes
4answers
805 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
8answers
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 ...
14
votes
4answers
577 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 ...
25
votes
3answers
566 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 ...
19
votes
5answers
649 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 ...
13
votes
0answers
750 views

We can do better: FALSE [closed]

The interpreter executable for FALSE is 1020 bytes large. I think we can do better than THIS: ...
8
votes
0answers
517 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 puzzle is ...
20
votes
7answers
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 ...
28
votes
5answers
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 ...
0
votes
0answers
116 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 (+-*/)...
22
votes
5answers
588 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 ...
25
votes
19answers
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 ...
10
votes
4answers
928 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 ...
14
votes
6answers
940 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 ...
19
votes
1answer
832 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 ...
16
votes
6answers
4k 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) ...
16
votes
5answers
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 ...
35
votes
8answers
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, ...
10
votes
3answers
915 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 ...
3
votes
1answer
397 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 ...
13
votes
8answers
806 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 ...
21
votes
6answers
3k 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 ...
146
votes
116answers
47k 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. ...
17
votes
17answers
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 ...
5
votes
3answers
957 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 ...
28
votes
12answers
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 ...
17
votes
2answers
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 ...
8
votes
16answers
2k 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 ...
5
votes
3answers
867 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: ...
22
votes
7answers
3k 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: <...
11
votes
3answers
1k 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 ...