instruction stringlengths 34 53.1k |
|---|
Say I have text like this (each word on one line, with no spaces)
Programming
Puzzles
&
Code
Golf
That makes no sense! It totally defies the laws of physics.
Your challenge is to remedy this impossible situation and collapse the text like so:
P
Prog
&uzz
Coderam
Golflesming
So that there is no empty space underneath ... |
Write a term on the pure untyped lambda calculus that, when applied to a church-encoded list of numbers, returns it with its numbers sorted in ascending or descending order. Church lists and numbers must be encoded as folds for their usual ADTs:
-- Usual ADTs for Lists and Nats (in Haskell, for example)
data List a = C... |
Introduction
On BBC Radio 2, on Saturdays there's a show hosted by Tony Blackburn called Pick of the Pops. Here, Tony selects a random week from a random year (in the range 1960-1989), and plays the songs which were in the top 20 charts at the time.
Challenge
Given a list of songs played on one Pick of the Pops episode... |
Write a program or function that given positive n and m calculates the number of valid distinct domino tilings you can fit in a n by m rectangle. This is sequence A099390 in the Online Encyclopedia of Integer Sequences. You may take input in as function argument(s), CLA or on stdin, in any reasonable format. You must r... |
Background
I have a bunch of square-shaped boxes of equal size, and since I'm a neat person, I want to arrange them all into a square formation.
However, their number is not necessarily a perfect square, so I may have to approximate the square shape.
I want you to find me the most aesthetically pleasing arrangement -- ... |
There are quite a large number of prime generating functions. Pretty much all of them are constructed and are based on the sieve of Eratosthenes, the Möbius function or the Wilson's theorem and are generally infeasible to compute in practice. But there are also generators, that have a very easy structure and were found... |
I define four box styles:
+-----+ ooooooo ^^^^^ *******
| 1 | o 2 o < 3 > * 4 *
| | o o < > * *
+-----+ ooooooo vvvvv *******
Write a program or function that given an integer and a string will find one of the above boxes inside the string and change its style into the b... |
Challenge
Write a function which takes one parameter: an integer t. Your function has to stop your program for t seconds before continuing, similar to time.sleep(t) in Python and WAIT t in BBC BASIC.
You must not use any built in waiting functions or any built in functions for executing code after a certain time, and y... |
Accordion is a solitaire card game I recently came across where nearly every layout is solvable, but incredibly hard. You can play it here.
Rules
52 face cards are placed face-up in a random order. Each turn, you replace a card with a later card, where the two cards:
Share a suit or number and
Are at a distance of 1... |
Who doesn't love action movies with fast noisy cars, especially those with a lot of crashes? Who doesn't love action shots in ascii art?
The scene is:
Two cars are starting at opposite sides of a straight road (with 60 spaces between). They start driving towards each other at constant speeds. The car to the left drives... |
Write a program or function that, given two ASCII strings A and B, will produce strings A' and B' where the common substrings are reversed in their place. The process for finding A' is as follows:
A' is initially empty.
If the first character of A is in B, find the longest prefix of A which is a substring of B. Remove... |
Golunar/Unary is a way to encode all valid Brainfuck programs, but it is not an enumeration, since most natural numbers do not correspond to a valid program.
For the purpose of this challenge, assume a doubly infinite tape and no comments, i.e., a Brainfuck program is valid if and only if it consists solely of the char... |
MarioLANG is a two-dimensional programming language where the source code resembles a Super Mario Bros. level. Furthermore, its instruction set is very similar to Brainfuck's. This means that MarioLANG is essentially a 2-D Brainfuck where the instruction pointer moves like Mario. So when I wrote my MarioLANG submission... |
Challenge
Given a string as input, golf down the Fourier program which outputs that string.
In Fourier there is no easy way to output a string: you have to go through each character code and output that as a character.
Fourier
The language is based upon an accumulator, a global variable which is initialised to 0 at the... |
Who will rule the realm?
You are given a family tree which contains: name, sex, date of birth, date of death and a list of heirs, for each family member. You may use any convenient (nested) list format to represent the tree. The following examples will use JSON. Determine who will rule the realm and in which order.
The... |
Consider a prime number p, written in base 10. The memory of p is defined as the number of distinct primes strictly less than p that are contained as substrings of p.
Challenge
Given a non-negative integer n as input, find the smallest prime p such that p has memory n. That is, find the smallest prime with exactly n di... |
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For ... |
Programming Puzzles & Code Golf is about to get a new moderator, Dennis! This challenge is a tribute to him and our other active (or recently active) moderators: Doorknob, Martin Büttner, and Chris Jester-Young. The challenge title is meant to be read to the tune of the Pepto Bismol song.
Basically, we're going to trea... |
Write a program (or function) that takes in a non-empty string of any printable ASCII characters.
Print (or return) a zigzagging chain of the characters in the string with every neighboring pair of characters linked by:
/ if the first character occurs before the second character in normal ASCII order. e.g.
B
/
A
\... |
Suppose you are given a pointer to the head of a singly linked list. Normally each node in the list has a pointer to the next element, and the last node's pointer is Null. Unfortunately the list might have been corrupted so that some node's pointer leads back to an earlier node in the list.
How can I design an algorith... |
Duplicate? I knew somebody must've done this before.
Programming a programming language in itself is something that has interested me since I knew what a programming language was. So I thought I'd create a Code Golf challenge for you.
Challenge
Create an interpreter for a given programming language, programmed entirel... |
Dead code sits there doing nothing, staring at us knowing it will never be executed... but today we can take revenge.
Specification
The input will be a multiline string.
Each line may either be an assignment or an expression .
Assignment
An assignment is of the form <name> = number where name is a sequence of letters, ... |
This question is inspired by, and is the inverse of this one.
Dennis (E), Doorknob (D), Martin (M) and Chris (C) have ordered a pizza. The rectangular pizza is divided into square pieces, each marked with their intended eater.
Write a program or function that given a rectangular pizza consisting of 0 or more of each le... |
Write code to figure out whether a run of Tetris pieces could be generated by the official Tetris algorithm. Fewest bytes wins.
Official Tetris games generate the sequence of falling pieces in a special way. The seven pieces IJLOSTZ are dropped in a random order, then another random permutation is dropped, and so on.
... |
Challenge
Given two integers A and B as input, you must write a program which outputs if A>B, A==B or A<B.
The integers will be in any reasonable range supported by your language which includes at least 256 values.
Your program can be either a full program or a function, taking input via STDIN or function arguments.
Ou... |
First, some definitions.
A Hadamard matrix is a square matrix whose entries are either +1 or −1 and whose rows are mutually orthogonal. The Hadamard conjecture proposes that a Hadamard matrix of order 4k exists for every positive integer k.
A circulant matrix is a special kind of matrix where each row vector is rotate... |
A common visual explanation of the Pythagorean theorem is as such:
The squares are meant to represent the side length's squared, and the areas of a + b = c, just like the Pythagorean theorem says.
This part is what you have to show.
Your task
You will get two integers as input, meant to represent sides a and b of a r... |
Your task is to take a list of arguments that are either integers or operators, and parse them like so:
There is a current operator, which starts as +.
Each time an operator is found, the current operator will change to it.
The possible operators are: "+", "-", "*", "/", and "%", which correspond to their meanings in ... |
The picture below shows a RLC circuit. A RLC circuit is an electrical circuit consisting of a resistor (R), an inductor (L), and a capacitor (C), connected in series or in parallel. (1)
In order to simplify computations, it's common to work in the frequency (Laplace) domain instead of the time domain.
Your task is:
Ta... |
This question was inspired this question and @orlp's comment and a lot of the explanation was copied from there.
Write a GOLF assembly program that given two arbitrary size decimal integers a, and b from stdin outputs two decimal integers to stdout, Q and R such that b * Q + R = a. In other words write divmod with arb... |
The Task
Given the positive value of unix timestamp output any of two valid ISO 8601 time formats:
YYYY-MM-DDTHH:mm:SS or, alternatively,
YYYY-MM-DD HH:mm:SS
You may ignore any leap seconds, if you wish, as well as the timezone part of the date.
Also, ignore the year 2038 problem.
Rules
You must not use any built-in... |
This competition is over. Thanks for the interesting non-esolang entries, and congrats to Jakuje for his winning JavaScript submission.
In the great tradition of ASCII Art Challenges on this site, here's another one. Given an input, draw a spiral.
&>----v
||>--v|
|||>v||
|||@|||
||^-<||
|^---<|
^-----<
Simple, yeah?... |
A tree is a connected, undirected graph with no cycles. Your task is to count how many distinct trees there are with a given number of vertices.
Two trees are considered distinct if they are not isomorphic. Two graphs are isomorphic if their respective vertices can be paired up in such a way that there is an edge betwe... |
In Pokémon there are 18 types:
Normal Fighting Flying Poison Ground Rock
Bug Ghost Steel Fire Water Grass
Electric Psychic Ice Dragon Dark Fairy
A Pokémon can have single or dual typing. For example, Pikachu is Electric, and Tyranitar is Rock/Dark. The order of the types does not ma... |
Preamble
In Stack Exchange markdown, we use ** to bold out text. For example, this markdown:
The **quick brown fox jumps over the lazy** dog.
Renders as:
The quick brown fox jumps over the lazy dog.
Of course, we use ** to close boldness as well. So less of the answer will be bold. For example:
The **quick** brown f... |
Make a plot (Poincare disk) of a tessellation on a hyperbolic plane, such as:
The program takes four inputs:
1) How many edges/polygon (three in this example).
2) How many intersect at each vertex (seven in this example).
3) How many steps away from the center vertex to render (5 in this example, if you look closely).... |
The spoak laugh
For those who don't know, in Brazil some people laugh on chats like this: aposkpaoskaposkaposkpaokspaoskpaoksa.
So here is the challenge: To make a program that generate this laugh in a natural way.
How to produce this laugh programatticaly?
When you laugh like this, you use one hand on the (a, s) part ... |
The basic idea of a kolmogorov-complexity challenge is to print a set output in the shortest code (though that meaning has changed now). We have had many of them, from Borromean Rings to The Gettysburg Address.
##Your Task
This question is similar, except that it requires printing of a special text - the text of this q... |
Challenge
Write a program that, given a string x which is 10 characters long and a character y, outputs the number of times character y occurs in string x.
The shortest program in bytes to do so wins.
Example
Input: tttggloyoi, t
Output: 3
Input: onomatopoe, o
Output: 4
|
I'm working on a golf for Java and I need an infinite loop. Obviously, I don't want to spend any more bytes than I have to, especially in such an expressive language.
Assuming I have some code I want to run, obviously the baseline is set at while(1>0)/*stmt*/ or 10 additional characters for a single line and while(1>0)... |
The Debian Linux distribution (and Debian-based distros, like Ubuntu, Kali and others) uses a package-manager called APT. To install program foo you would type into a terminal
sudo apt-get install foo
One little Easter Egg of APT is the following
apt-get moo
Which after typing will produce the following output
... |
Background
This is the first part of a 3-hole golf course on text processing.
The over-arching idea is that if you take an input text and pipe it through the solutions to all three challenges (with a small amount of glue code), it will spit out a beautifully formatted paragraph.
In this first challenge, your task is a ... |
Note: all array references in this post are zero-indexed.
When playing the piano, two notes on the same key must be pressed with two different fingers. You could use the same finger, but it doesn't sound as good. At least, according to my piano teacher. I can't hear any difference.
The challenge is to take a space-sepa... |
This is a challenge for the people using Swift 2.0 beta 6, it's not code golf, but it's a programming puzzle so I'm pretty sure this belongs here. The basic idea is: Make it compile. There are more details and a very nicely formatted playground at the Github project. Previous challenges are there as well, all set up to... |
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.
Challenge
You will have to write a program that when run in two different languages, will output the string:
This program wasn't written in <language program compiled/inte... |
Some people insist on using spaces for tabulation and indentation.
For tabulation, that's indisputably wrong. By definition, tabulators must be used for tabulation.
Even for indentation, tabulators are objectively superior:
There's clear consensus in the Stack Exchange community.
Using a single space for indentation i... |
Consider three number sequences, \$A\$, \$B\$ and \$C\$:
\$A\$: A sequence based on recurrence relations, \$f(n) = f(n-1)+f(n-2)\$, starting with \$f(1) = 3, f(2) = 4\$. So, the sequence begins like this: \$3, 4, 7, 11, 18, 29, 47, 76, ...\$
\$B\$: The composite numbers, that is all integers that aren't primes (or 1):... |
This challenge was inspired by programming an Arduino microcontroller. I have 6 LEDs and 6 buttons connected to various pins on the board. In the code, each button and LED is assigned an ID number (1-6). Pin numbers (ranging from 0-13) corresponding to the ID numbers are looked up using a switch statement. Purely for a... |
Background
When playing an RPG such as Dungeons & Dragons, Pathfinder, or Paranoia, players each need a set of dice. You are hosting one such game this weekend, and some of the friends you invited have never played an RPG before. They don't want to commit to buying their own set of dice until they know they'll use them... |
Similar figures
Two rectangles are similar if the ratios of their sides are the same.
Consider these two rectangles; a rectangle 5 lines tall and 11 chars wide:
===========
===========
===========
===========
===========
and a rectangle 10 lines tall and 22 chars wide:
======================
======================
===... |
Write a program (or function) that takes in a positive integer.
If the input is 1, print (or return) two diamonds neighboring side-by-side, each with a side length of 1 slash:
/\/\
\/\/
For every input N greater than 1, look at the output for N-1 and for each pair of neighboring diamonds, insert a new diamond in betwe... |
The task
Write a program or function that takes a traffic intersection structure and outputs the sequence, in which vehicles will pass.
The output should contain at most four lines with the following format #. x->y\n, where # is a sequence number number, followed by the dot ., x and y are characters ["N", "E", "S", "W"... |
Here's a simple one to stretch your compression muscles. Your code (a complete program) must output the spelled-out English representation of all the cardinal numbers from 1 to 100, and then all the ordinal numbers from 1 to 100. The numerals in each list should be delimited by commas and spaces and properly hyphenated... |
Given the 95 printable characters in ASCII plus newline, break it apart into two equal, 48 character groups (hereafter called group A and group B). Create a one-to-one mapping of your choice (you have total discretion) between the two groups. In other words, A might map to a, and vice versa, but A might also map to > a... |
This is my first challenge, so I'm keeping it fairly simple.
If you've ever typed telnet towel.blinkenlights.nl on your command line and pressed enter, you will have experienced the joy of asciimation. Asciimation is, quite simply, doing an animation with ascii art. Today we will be doing a very basic asciimation of a ... |
Every Unicode character has a name, like "LATIN CAPITAL LETTER A". A Unicode character name may contain only uppercase letters, white spaces, and the minus sign.
Write a program that reads a text and outputs the names of each character on a new line. For example, if the input were "Hello, World!", the output would be
L... |
Background
The official currency of the imaginary nation of Golfenistan is the foo, and there are only three kinds of coins in circulation: 3 foos, 7 foos and 8 foos.
One can see that it's not possible to pay certain amounts, like 4 foos, using these coins.
Nevertheless, all large enough amounts can be formed.
Your job... |
I read about circles somewhere, and just now learned about discs (it's actually a pretty common concept) and thought about codegolf.
Your task is to randomize a point/several points on a disc with the radius 1.
Rules:
All points must have an equal probability to be generated
Floating point coordinates must be used; t... |
The interpreter executable for FALSE is 1020 bytes large. I think we can do better than THIS:
��Û������������������ˆ��È���ˆB0�ˇ*,x�r�pH@NÆ˝T,�g�Œ$F(FIÏa®.GÏu0C˙íp%NÆ˝ÿJÄg�™,@"$<��ÌNÆˇ‚JÄg�í*�"�$&<��a®NÆˇ÷,�"NÆˇ‹F�k�r‹Ç*BA˙¸C˙Ra�ºª∆j��Úp�@�0j�^@�[f(¸A˙�8¸+(¸`�ˇ¯&Ã`‘@�]f8¸Nu c êàTÄ1@ˇ˛`º@�aj�T@�!kÆ@�{fª∆j��ö�}fÙ`ö@�"fB(¸... |
This is a code-golf challenge whereby you need to devise a program that acts like a quine or a quine that modifies itself to illustrate machine learning.
Background
There is a basic artificial intelligence program called 'the pangolin game' which is described here. The basic ideas is that the program when run the first... |
Input
A list of words separated by any number of spaces.
Output
A horizontal ASCII art graph, where the n-th line is composed by as many asterisks (*) as the n-th word is long.
Example usage
The > signals user input, you should not input it when testing the program.
> This is an example histogram of word length
****
**... |
In this challenge you are going to write an interpreter for a simple language I've made up. The language is based on a single accumulator A, which is exactly one byte in length. At the start of a program, A = 0. These are the languages instructions:
!: Inversion
This instruction simply inverts every bit of the accumula... |
Challenge
In this challenge, you are to code in any language a program or function that will take a string and replace certain characters within it with different characters.
Input
The input is the same for both functions and full programs:
[string] [char1] [char2]
string will be an indefinite line of characters surr... |
As you should (hopefully) know, a radiation hardened quine is a quine that you can remove any one character from and still print its original, pre-modified source. The thing is, with most of these you can only remove one character; otherwise everything breaks down. This is where this comes in; your goal is to build a r... |
Introduction
Some ASCII characters are just so expensive these days...
To save money you've decided to write a program that encodes expensive characters using inexpensive ones.
However, character prices change frequently and you don't want to modify your program every time you need to encode or decode a different chara... |
Inspired by this question
Given a positive integer \$n\$, your code must output the first \$n\$ composite numbers.
Input / Output
You may write a program or a function. Input is through STDIN or function argument and output is to STDOUT, or function return value.
Output can be a List, Array, or String.
Examples
0 ->
... |
Introduction
Last year was my birthday (really!) and sadly I had to organise my own party. Well, now you know, couldn't you at least make the cake?
Challenge
Given an integer n as input, write a full program to output a birthday cake with n candles on.
Output
A piece of cake with one candle on is:
$
|
---
~~~
---
An... |
In this challenge, we will together create a word-search containing many programs in different languages.
I have started us off with a grid of 60-by-25 blanks (·), some of which are replaced by the characters of a Ruby program.
To answer, choose a language that was not yet used. Using your chosen language, write a prog... |
Background
You are working as a programmer for a car sales company.
Your task for this week is to program an XML parser that takes in data about available models from different car manufacturers, and pretty-prints information about the newest models.
Luckily for you, the testing department has provided only one test ca... |
Around the year 1637, Pierre de Fermat wrote in the margins of his copy of the Arithmetica:
It is impossible to separate a cube into two cubes, or a fourth power
into two fourth powers, or in general, any power higher than the
second, into two like powers. I have discovered a truly marvelous
proof of this, which t... |
Introduction
Yesterday I saw a birthday puzzle. Congrats!!
Also this week I watched an episode of the TV show Bones where a dead body was found buried under a tree. To calculate the time of death, they counted the tree rings.
Tree rings form because trees grow slower during the winter and faster during the summer. Thus... |
This is what I thought this question was going to be, before I fully read it.
A group of code golfers walk into The Nineteenth Bite Pizzeria and order a pizza. It comes in an irregular shape, made of unit squares. Your task is to help them cut it into identical slices. That is, the slices must have the exact same sha... |
Space indentation users, unite! We must fight against all the lowly tab users!
Your mission (should you choose to accept it) is to write a program or function that takes in two arguments:
A string: This is the input.
A positive integer: This the number of spaces per tab.
You must go through every line of the string a... |
Challenge
Your goal is to write a program that prints another program.
That printed program should print another program, and the new program should print another program, until the end.
Rules
Each program must less than 256 bytes. (If this needs to be changed, leave a comment)
The last program must be an empty progra... |
In this challenge your goal will be to output the lyrics to Daft Punk's Harder, Better, Faster, Stronger. Specifically, output this text:
Work It
Make It
Do It
Makes Us
Harder
Better
Faster
Stronger
More Than
Hour
Our
Never
Ever
After
Work Is
Over
Work It
Make It
Do It
Makes Us
Harder
Better
Faster
Stronger
More Tha... |
I honestly cannot believe that this is not a question yet on Code Golf, but....
Print the local time (with a.m. or p.m.) as a string to the console, preceded by "It's ".
Example:
Run code....
Output:
It's 12:32p.m.
Shortest code wins.
Code away!
Leaderboard
var QUESTION_ID=57552,OVERRIDE_USER=42854;function answers... |
You work for a company that wants to make a user-friendly calculator, and thus you have been tasked with adding the ability for users to use "numerical shorthands," that is, letters that represent numerical values, such as k for 1000. Because your company wants to save money on storage in said calculators, you must min... |
The question uses C to formulate the problem, but solutions in any language can be accepted. At the end of the question you can find a pythonic version.
As part of a bigger software, we have a C function:
void wrapper(void* p);
Which is a wrapper function around the C function:
void handler(void* p);
wrapper() is tri... |
The Situation
Suppose I allow "Shady Sam" admin access on my workstation to perform an important administrative task on my Mac Pro for me by giving them a temporary root login password. (Assume they were trustworthy, perhaps a systems admin for my company.)
From a remote location (e.g. home), I use my MacBook Pro lapt... |
Find the digit which occurs the most in a range of prime numbers.
Input:
Two numbers, p and q, specifying the range; the range includes both p and q.
Output:
The digit that occurs most frequently in that range of prime numbers. If two or more digits are tied, all of them should be outputted.
Winning Criteria:
Fastest c... |
I hear somebody was very selfish on their birthday, demanding cake from everyone and there were no plans to share! 🎂
It's bound to be somebody's birthday today, so why not bake them a cake. Use your favourite programming language to make a delicious cake, with a nice "Happy Birthday" message as the output. (Might I s... |
Write a program or function that transforms an input string into Zalgo text.
For example, for an input string Zalgo, a possible output might look like:
Z̗̄̀ȧ̛̛̭̣̖̇̀̚l̡̯̮̠̗̩̩̥̭̋̒̄̉̏̂̍̄̌ģ̨̭̭̪̯̫̒̇̌̂o̢̟̬̪̬̙̝̫̍̈̓̅̉̇
Zalgoification specs
Each letter (upper or lower case) must be zalgoified, and nothing else (spaces, pun... |
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages.
Rosetta code features lists by language of idiomatic approaches to primality testing, one using the Mil... |
Your goal is to create a program that prints itself indefinitely, with a new line after each one. Thus, if your program is a one-liner, it would be repeated on every line of the output.
Example
Program:
A
Output:
A
A
A
...
Rules
It must be a complete program, not a snippet or function.
The program should loop fore... |
Last year, there was a very popular challenge to create an image containing every 24-bit RGB colour.
My challenge is to create a smooth animation (24 frames/s say), where the colour of every pixel of every frame is unique. I will also allow duplication of colours as long as every colour appears the same number of time... |
Background
Benford's Law is freaky!
Of all the numbers in the world, roughly 30% of them start with a 1! 17.6% start with a 2, 12.5% start with a 3, and so on, and so on.
For example, take a look at the following graph. Take the largest 120000 towns in the world, take their altitude, and voila - they obey Benford's law... |
This challenge is a tribute to PPCG user Dennis for winning the robbers' part of The Programming Language Quiz.
Looking at Dennis' PPCG profile page we can see some pretty impressive stuff:
He currently has over sixty-eight thousand reputation, making him second in rep overall, surpassing third place by almost thirty ... |
Challenge
Write the shortest program that receives two signed integers n and i and for each i between 1 and 2^n - 1 returns the next ordered permutation based on the binary representation of the number. There is no specific order of the combinations but the number of 1s in the binary representation must always stay th... |
I'm sure most of us have seen SQL results in a terminal, all neatly formatted into rows and columns. If you haven't, here's an example:
+----------+-----------+----------------+
| column 1 | column 2 | column 3 |
+----------+-----------+----------------+
| data | more data | even more data |
| etc | jus... |
Write a program that accepts as input an emoticon and ouputs if the emoticon is happy or sad.
The program accepts a string as input or parameter, and should display the string "happy" if the input is in the happy emoticon list, or "sad" if the input is in the sad emoticon list.
You can assume the input is always a vali... |
Suppose this grid of spaces and X's represents the cross section of some strangely shaped empty ice cube trays:
X X X
X X X XX X XX X
XXXXXX XXXXXXXXXXXXX
Columns without X's represent holes or gaps in the trays that can't hold water, draining into an infinite capacity sink. Water falling off the l... |
Task
Your mission is to create a program that reviews Python code. The solution can be written in any language!
It must take input that contains python code. The program must add # This is not pythonic! before each block of non-whitespace lines.
Input
The data can be entered via stdin.
The data will contain at least 3... |
Aligning Lines!
Given a character and a multiline string, your job is to pad each line of the string so they line up among the given delimiter.
Examples
Input:
,
Programming, Puzzles
And, Code golf
Output:
Programming, Puzzles
And, Code golf
Input
The input will be a multiline string and a character (which yo... |
Every 3 seconds, add a room to the house.
A house with one room looks like this:
|---|
|[=]|
|---|
Two rooms:
|---||---|
|[=]||[=]|
|---||---|
Three rooms:
|---|
|[=]|
|---|
|---||---|
|[=]||[=]|
|---||---|
Four rooms:
|---||---|
|[=]||[=]|
|---||---|
|---||---|
|[=]||[=]|
|---||---|
Five rooms:
|---||---|
|[=]||[... |
In xkcd 1047, Randall Munroe lists "slightly wrong" approximations of assorted quantities and numbers with varying precision and complexity, such as that the number of liters in a gallon is very close to 3 + π⁄4. In the middle of the comic, he gives an intermission: a way to estimate the world (and United States) popul... |
Exchange the Stacks!
Write a program that can exchange any character from two stacks. In this challenge, a stack is a tower of characters. An example stack is below:
1
a
4
d
*
c
3
There are two stacks involved in the challenge and both are inputted when the program runs. The program will also be given an argument of w... |
Suppose you are stringing a strand of Froot Loops for a necklace, bracelet, shoelace, or whatever. There are 6 loop colors: red, orange, yellow, green, blue, and purple. You want your strand to start with red at the very left and cycle in rainbow order going right, ending with purple. That is, you want to make it so yo... |
I've already made this in Python, but it seems that it could be shortened a lot:
txt = input("Type something.. ")
c = "#"
b = " "
print(c * (len(txt) + 4))
print(c, b * len(txt), c)
print(c, txt, c)
print(c, b * len(txt), c)
print(c * (len(txt) + 4))
So if the user types:
Hello World
The program prints:
#############... |
If you haven't played golf before, here's a list of golf-related terms I use in this question
Shot, also called a stroke: Every time the ball is hit, this is a shot.
Hole: A golf course is split into holes, in which the goal is to hit a ball from one designated location to another in as few shots as possible.
Tee: Whe... |
This is code golf. Fewest bytes wins, only standard libraries, etc.
Write code, in any language, to output all possible same-length permutations of all items of an array / list / object in the input format and any order, grouped in whatever way you like. The items can be of ANY type, as allowed by the programming langu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.