instruction stringlengths 34 53.1k |
|---|
April 5th is National Deep DIsh Pizza Day, the theme of this challenge. Given a positive integer n (n is greater than 0), create an ASCII deep dish pizza. Actual deep dish pizza shown:
As you can see, there is a layer of crust on the bottom and surrounding the rest of the pizza.
How to make the pizza
The crust is mad... |
Your Challenge
You must write a program/function etc. that takes a domain name of a StackExchange site and outputs the domain for the meta version of the site passed to it. Examples:
stackoverflow.com => meta.stackoverflow.com
codegolf.stackexchange.com => codegolf.meta.stackexchange.com
mathoverflow.net => meta.mathov... |
It is common to start countdowns 100 days prior to an event, probably because of our base 10 system. Examples of this can be found everywhere:
100 days until your birthday
100 days until the wedding
100 days until the election
100 days until our graduation
100 days until her due date
100 days until football season
100... |
Purpose
The idea is to provide the code necessary to map a 32-bit integer to/from a pronouncable word of 9 characters maximum. That could be useful, for example, to make a serial number easier to remember, or type in a form.
Both the method for translating an integer to the corresponding word and for translating back a... |
For this challenge you need to implement two functions, f and g, on the integers, such that f ∘ g is a strictly decreasing function while g ∘ f is a strictly increasing function. In other words, if you take any two integers a < b, then f(g(a)) > f(g(b)) and g(f(a)) < g(f(b)). There are no restrictions on f and g indivi... |
There are clever ways of determining whether a number is a power of 2. That's no longer an interesting problem, so let's determine whether a given integer is an integer power of -2. For example:
-2 => yes: (-2)¹
-1 => no
0 => no
1 => yes: (-2)⁰
2 => no
3 => no
4 => yes: (-2)²
Rules
You may write a program or a func... |
A quine is a program that produces output that's identical to the program's source code. On this website, we generally only care about proper quines (at the time of writing, the current definition is "some part of the output is encoded by a different part of the program").
What advice do you have for writing proper qui... |
This is a version of the recent challenge Is this number an integer power of -2? with a different set of criteria designed to highlight the interesting nature of the problem and make the challenge more difficult. I put some consideration into it here.
The challenge as wonderfully stated by Toby in the linked question, ... |
Backstory
Not really real, sshh!
It all started one day when a coworker brought in a homemade loaf of bread for my boss's birthday.
My boss really liked this loaf of bread, and he wanted another. Unfortunately, my coworker has quit, so my boss needs me to give him another loaf.
The problem is, I have no idea how to mak... |
It's a funny accident that this world happens to have just 1 time dimension, but it doesn't have to be like that. It's easy to imagine worlds with 2 or more time dimensions, and in those worlds you could build computers and run software on them, just like in this one.
The System
Here is a system for running Brainf*ck p... |
(Inspired by ASCII's 95 Characters...95 Movie Quotes)
The Challenge
Given input n, output the nth Fibonacci number. You can use either 0 or 1 indexing, please state which in your submission. Simple, yeah? The catch is you must take the character set of the immediate previous answer, remove two characters from it, and a... |
Note: This challenge only allows answers in compiled languages
Task
Your task is pretty simple, make two different programs that when compiled result in the same output.
Scoring
Here is where the fun comes in. Your score will be the number of unique bytes present in exactly one program. For example if your two progra... |
This question is inspired by this one
Your task
Make a program or function that calculates the Tetration of 2 numbers. Tetration is what "comes next after addition, multiplication, and exponents".
For example, passing in 3 and 3, this is calculated:
3 ^ (3 ^ 3)
yielding this:
7625597484987
Simple, right?
WRONG.
Rule... |
The Problem:
This challenge comes from a real problem I was having. I have a dual monitor setup at work, and I wanted to use the following image as my wallpaper:
However, my monitors have quite significant bezels, and when I set my background, it looks something like this, where the pier appears (appiers?) to be broke... |
Literally! April 6th is National Teflon Day, which is celebrated with Teflon-coated pans (what we will be making). So, given a positive integer n, create a Teflon pan. The "pan" section of the pan is an octagon with each of its sides consisting of n characters, which will vary depending on which side it is except for t... |
I'm trying to strip down my python code to be as few lines as possible. The task: count how many square numbers are below 100. Here's my code so far:
m = 0
for x in range(0, 100):
m+=1-(-((-((x+1)**(0.5)-((x+1)**(0.5))//1))//1));
print(m)
That addition statement adds 1 to m (the counter) only when (x+1) is a perfe... |
Inspired by Golf me an ASCII Alphabet, of which this challenge is (almost) a direct inverse.
Task:
Take a string of ASCII-art text and output the content of the text as regular ASCII text.
Input:
String of ASCII-art text.
Input will only contain instances of ASCII character #, spaces and 4 or 5 newlines (a trailing n... |
In this challenge, your task is to decipher a string. Luckily, the algorithm is pretty simple: reading from left to right, each encountered digit N (0 to 9) must be replaced with the character which is N+1 positions before it.
Example
The input string "Prog2am0in6" would be decoded this way:
Hence, the expected output... |
Your task: given an integer n, generate an embedded hexagon pattern following the below rules, to the nth depth.
An embedded hexagon has the basic shape of this: (n=0)
__
/ \
\__/
Embedded Hexagons n=1 and n=2:
____
/ \ \
/\__/ \
\ /
\____/
________
/ \ \ \
/\__/ \ \
/\ ... |
This is the inverse of Let's do some "deciph4r4ng"
In this challenge, your task is to encipher a string. Luckily, the algorithm is pretty simple: reading from left to right, each typical writing character (ASCII range 32-126) must be replaced by a number N (0-9) to indicate that it is the same as the character N+1 pos... |
yOu wiLl bE giVen A sTriNg wHich cOnsiSts oF pRintAble asCii
cHarActErs.
yOu iTeraTe tHrougH thE sTrIng tHen chAnge rAndOM(uNifoRm, 50% cHanCe uPPercAse) lEtteRs to
uPPercAse aNd eVerytHing elSe tO lOwercAse.
tHat'S iT.
(sorry for the punctuation, it was for the concept of the question)
Readable version:
You wi... |
Note: This is inspired by this question by @Willbeing where task was to count the number of perfect plates of a certain length, but it's slightly different.
We call a perfect licence plate that plate whose text satisfies the following conditions:
It consists of characters, which can either be uppercase letters([A-Z])... |
When using Markup, like on the SE network, an indentation of four spaces before a line of text denotes it as part of a code block, as I hope you know. If you don't, here's an example (with . representing a space):
....Code
....More code
results in
Code
More code
The problem is, when you copy-paste code into an answer,... |
This challenge is a prize for ais523 for winning the "Rookie of the Year" category in "Best of PPCG 2016". Congratulations!
BackFlip is an esoteric programming language made by user ais523, who has created well over 30 other interesting esolangs.
BackFlip is a 2D language like Befunge or ><> where the instruction poin... |
Backstory
I've always found it quite annoying how some numbers in English don't have the same number of syllables even though they have the same number of digits. Example: seven has 2 syllables whereas all of the other digits have one (other than zero).
So, when I'm counting in time to something (like a drill cadence i... |
Introduction
Forte is a very peculiar esoteric language based on the concept of modifying the values of numbers. In Forte numbers are not constants but variables, you can use the LET instruction to assign new values to them.
For example, after executing LET 2=4-1 from now on 2 assumes the value of 3, which means that w... |
Who doesn't like to chill on a Sunday morning in summer with a chilled beer and TV or in winter playing badminton or ultimate with friends?
I always think knowing how many days you have to chill in a month keeps you well-informed and helps you plan what you want to do. Be it sitting in front of your pc and solving a co... |
Backstory [which is not true]
A piano is set up like this:
However, on my piano, all of the black keys are broken!
I still want to be able to play some chords on my broken piano though.
In music, a chord is a group of notes that are played together. To allow for input of chords, I will first define what a semitone is.... |
This challenge carries a bounty of 200 points for the first to answer and remain unbeaten for at least 3 days. Claimed by user3080953.
There's a lot of talk lately about end-to-end encryption, and pressure on companies to remove it from their products. I'm not interested in the rights-and-wrongs of that, but I wonder... |
Given a binary number, your task is to create a 'branch' of that number, with a depth of 2.
For example, given 0 as input, you should output exactly this:
/000
/00
/ \001
0
\ /010
\01
\011
This should be fairly self explanatory of how the branches should be created. Depth 2 means we calculate branc... |
Several years back, Hot Wheels made a simple flash game called "Formula Fuelers Racers"*. To play the game, you select three ingredients from a fridge to put into your car, which is then raced against the computer's randomly-generated car. It turns out the mechanics of this game are pretty simple. First off, the act... |
Introduction
For those not familiar with steam - or at least this particular aspect:
Often on peoples' profiles, people leave comments saying either "+rep _____" or "-rep _____". These are an unofficial means of showing whether you think someone in the community has a good or a bad reputation, for a number of reasons. ... |
From the Wikipedia article:
Location arithmetic (Latin arithmeticæ localis) is the additive (non-positional) binary numeral systems, which John Napier explored as a computation technique in his treatise Rabdology (1617), both symbolically and on a chessboard-like grid.
What?
Location numerals is a way of writing numb... |
Given an ascii-art road and the time it took me to cross it, tell me if I was speeding.
Units
Distance is in the arbitrary unit of d. Time is in the arbitrary unit of t.
The road
Here is a simple road:
10=====
The 10 means 10 d per t. That is the speed limit for the road. The road has 5 =s, so its d is 5. Therefore, i... |
Your task: given a number n, generate a '+' sign that is n characters away from its center. If this is confusing, check out the test cases.
Standard methods of input: output must be a string or printed. Standard loopholes apply.
Input: 1
Output: + ] 1 away from center `+`.
Input: 2
Output: + ] 2 a... |
Title misspelled on purpose. Read more to find out why.
Your task: given a delimited string or list including the characters A,B,C,D, output the indexes of all the adjacent equal characters. Output can be multiple strings/integers on multiple lines, a list/array, or a delimited string.
All output should be in a list or... |
In the old DOS operating system, a number of characters were provided to draw boxes. Here is a selection of these characters and their code points:
B3 B4 BF C0 C1 C2 C3 C4 C5 D9 DA
│ ┤ ┐ └ ┴ ┬ ├ ─ ┼ ┘ ┌
You can use these characters to draw boxes like this:
┌─────────┐
│ │
└─────────┘
Boxes can be at... |
Draw a simple ASCII art image containing a straight line.
It's similar to this and this but with different specifications.
Input
You can modify this input format to suit your code.
integer width
integer height
integer x0
integer y0
integer x1
integer y1
Output
A filled ASCII art image of the specified width and heigh... |
Hexagonal chess describes a family of chess variants played on a board where the cells are hexagons instead of the traditional squares. There are many such variants; in this challenge we'll be focusing on Gliński's variant, which is the most common.
The board is composed of three colors (so that the same color doesn't ... |
You must make a polyglot that outputs the square of the input in one language and the square root of the input in another. The shortest answer in bytes wins!
You must have a precision of at least 3 decimal places, and the input will always be a positive float.
|
Here's the phonetic alphabet:
Alfa
Bravo
Charlie
Delta
Echo
Foxtrot
Golf
Hotel
India
Juliett
Kilo
Lima
Mike
November
Oscar
Papa
Quebec
Romeo
Sierra
Tango
Uniform
Victor
Whiskey
X-ray
Yankee
Zulu
In the fewest bytes possible:
Input will be these words in a random order, with the first letters removed.
Your goal is to... |
Background
As most PPCG regulars will know, a quine is a program which outputs its own source code when run; and the Levenshtein distance between two strings is the minimum number of insertions, deletions, and edits needed to change one string into the other. In this challenge, we're combining the two concepts into a "... |
Convert a hexadecimal number (of any size) into a binary number.
Input
A POSITIVE hexadecimal number with a 0x in the beginning. A valid input will always match the following regex: 0x[0-9a-fA-F]+. If the input is not a valid hexadecimal number, that is, anything not matching this regex, the output should be 0.
Output
... |
Write a program or function with the following functionality:
The program/function first attempts to write the string Hello, world! to the standard output stream. (No other forms of output are acceptable for this challenge, as the focus is very much on the I/O rather than the trivial behaviour of the program itself.) ... |
Challenge
Given a list of SI base units, a list of equations and a target, you must derive the units of the target using only the base units.
Derived Units
From Wikipedia:
The International System of Units (SI) specifies a set of seven base units from which all other SI units of measurement are derived. Each of these ... |
Write a program that is a polyglot in three languages that plays rock–paper–scissors.
The input for any version of the program is always one of the strings rock or paper or scissors.
In the first language the program must output the rock–paper–scissors choice that beats the input:
Input Output
rock paper
paper... |
Recently I posted a question about Diffy games which has gone unanswered. Thats fine, the question is really hard, but I would like to make an easier question about Diffy games so that we can get the ball rolling.
How Diffy works
Copied from Find Diffy Games
The Diffy game works like as follows: You start with a lis... |
I am trying to use C# to find the index of the first 1 (right to left) in the binary representation of a number. For example, since 100 in binary is:
0b1100100
The first 1 is in the third position from the right, so it should yield 3.
234 should yield 2, 0 should yield 0, etc.
Here is my current solution:
k < 1 ? 0 :(... |
Print the dates of all the Sundays in 2017 in the following format : dd.mm.yyyy.
Expected Output:
01.01.2017
08.01.2017
15.01.2017
22.01.2017
29.01.2017
05.02.2017
12.02.2017
19.02.2017
26.02.2017
05.03.2017
12.03.2017
19.03.2017
26.03.2017
02.04.2017
09.04.2017
16.04.2017
23.04.2017
30.04.2017
07.05.2017
14.05.2017
21... |
Everyone loves The Big Bang Theory, right? And everyone loves polyglots, right? So let's combine them!
Task
Your task in each language is quite basic. You must output the name of the one of the 5 main characters of The Big Bang Theory: Sheldon Lee Cooper, Leonard Leakey Hofstadter, Howard Joel Wolowitz, Rajesh Ramayan ... |
The rundown
Create a program that generates an array of random length with random numbers, then apply a series of rules that alter the array. After the rules have been applied, print the sum of the array unless specified otherwise
Array setup
The array must be a random length between 5 and 10 inclusive, with random int... |
Task
Basically you have an array of random integers e.g.
I() = [1, 4, 3, 2, 5, 3, 2, 1]
and you have to create another array of the same length with the numbers 1 to the size of the array in place of the smallest to largest numbers respectively, e.g.
O() = [1, 7, 5, 3, 8, 6, 4, 2]
For duplicates, the first occurrence... |
Challenge
Given an input of an integer, \$n\$ (where \$0<n<50\$), output the graph of \$y=\mathrm{Re}((-n)^x)\$ from \$x = -3\$ to \$x = 3\$ inclusive.
Where \$\mathrm{Re}(p)\$ is the real part of the complex number \$p\$.
Note that \$\mathrm{Re}((-n)^x) = n^x \cos{(\pi x)}\$
Output
The output may be in any form you wi... |
In this challenge, you will be given a square matrix A, a vector v, and a scalar λ. You will be required to determine if (λ, v) is an eigenpair corresponding to A; that is, whether or not Av = λv.
Dot Product
The dot product of two vectors is the sum of element-wise multiplication. For example, the dot product of the f... |
The bus driver picks up the children from their homes every morning for school. All the homes are positioned around a circular street and the bus driver has to stop at every home exactly once.
One monday morning the bus driver decided to only pick up every second child he encountered along his way. However, he still ha... |
I heard somewhere that one thing that technology cannot do yet is fold towels1. So it is now your job to prove that statement false!
Given a string as input, made up of rectangles (towels), like the following, fold each towel in half twice. For example:
+------+ +------+ +--+
| | | | | |
... |
Your challenge is to write a program, function, etc. that calculates if the passed string is "in order". That means that the characters of the string have character codes that are in order from smallest to largest. The smallest char code must be the first. By that I mean lowest unicode codepoints to highest. It doesn'... |
No, not the ^^vv<><>BA kind of Easter eggs, real Easter eggs that we paint.
Here is an (awfully drawn) egg.
__
/ \
/ \
| |
\____/
In easter, we paint them with patterns. Like these:
__
/--\
/----\
|----|
\____/
__
/%%\
/%%%%\
|%%%%|
\____/
__
/~~\
/~~~~\
|~~~~|
\____/
The challenge
Given a chara... |
Given a string that is one of the directions on a 16-point compass rose
output the two directions that are immediately adjacent to the input direction, in clockwise order.
Specifically, you need to handle these (and only these) input/output pairs:
Input Output
N NNW NNE
NNE N NE
NE NNE ENE
ENE NE E
E ... |
Your program / function, etc. will take 2 inputs. The first will be a list of who came to my party and when. Example:
Kevin 13:02
Ruby 5
Sam 3
Lisa 6
Bob 12
What does that mean? It means that Kevin got to my party first (at 13:02, 24-hour time), then Ruby 5 minutes later, then Sam 3 minutes later, then Lisa ... |
This is a fewest-operations challenge where the objective is to sort a vector into ascending order using the fewest reversals. Your algorithm can only sort the vector using "sub-vector reversals"1, but it can use other operations for arithmetic operations, loops, checking if it's sorted etc. The number of sub-vector re... |
Your task is to write a program which, given a number and a string, splits the string into chunks of that size and reverses them.
Rules
Your program will receive a positive integer n, as well as a string s with length at least one consisting of only printable ASCII (not including whitespace). The string should then be ... |
Recently, I have found my reputation changing time to time. I would like to know my reputation changing real-time.
The job
Given an id of a user on PPCG (ex.64499), Print the user's reputation every 10 seconds. You may ignore the daily quota.
Examples
64499
3808
40695
Possible output format
12345
12,345
|
Given an audio file, determine whether it is encoded in a lossy format or a lossless format. For the purposes of this challenge, only the following formats need to be classified:
Lossy
AC3
AMR
AAC
MP2
MP3
Ogg Vorbis
WMA
Lossless
AIFF
FLAC
TTA
WAV
Rules
If input is taken in the form of a filename, no assumption... |
Challenge
Given three numbers \$a\$, \$b\$, and \$n\$, you must expand \$(a + bx)^n\$ in ascending powers of \$x\$ up to \$x^3\$.
Binomial Expansion
Note that this method is an approximation
The binomial expansion works like so:
(a + bx)^n = a^n(1 + bx/a)^n
= a^n(1 + n(bx/a) + n(n -1)(bx/a)^2/2! + n(n-1)(n-1... |
Many different types of train set exist, ranging from wooden tracks like Brio, to fully digital control perfect tiny metal replicas of real trains, but they all require a track to be designed, ideally using as many of your pieces as possible.
So, your task is to determine whether, given input of the available pieces, i... |
Your task: given an integer n, output an embedded triangle to the nth depth.
Standard methods of input and output, input in any convenient format, output should be as a string. Examples are 0-indexed, you can use 1-indexed if you want. Standard loopholes apply
The left and right sides of each figure is 2^n, when 0 inde... |
Gödel's β function takes three natural numbers as arguments.
It is defined as β(x,y,z) = rem(x, 1 + (z + 1) · y) = rem(x, (z · y + y + 1) )
where rem(a, b) denotes the remainder after integer division of a by b.
The β Lemma now states that:
For any sequence of natural numbers (k_0, k_1, … , k_n), there are natural nu... |
Problem adapted from the book Fortran 77 by Donald M. Monro
Introduction
Digital plotting machines are widely used to produce various forms of drawings, graphs and other pictorial results. Most such machines can move their pens only in certain directions, usually as single steps in the X and Y direction or both. A typi... |
Titin is a protein found in muscle tissue. It is a pretty big protein, and its full chemical name is giant as well. Comprising 189819 characters, the full name of titin would take about 3.5 hours to pronounce. Your task is to output this entire name!
Details
The full name can be found here: Gist (this file does not inc... |
Instructions
Your goal is to write code that makes a "string" from a string in the least amount of bytes possible, as per the rules of code-golf. Standard loophole rules apply.
To make a string, you have to assume the string contains only alphabetical characters and basic punctuation such as the period, comma, colons a... |
First, a few definitions:
Given n and k, consider the sorted list of multisets, where for each multiset we choose k numbers from {0, 1, ..., n-1} with repetitions.
For example, for n=5 and k=3, we have:
[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 1, 1), (0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 2, 2), (0,... |
I have an issue with my keyboard (more likely an issue with my browser). Some times when I click on a new text field and begin typing all my text comes out backwards. After a very short amount of time (for the purpose of the challenge we will say it is 10 milliseconds) it resumes typing forwards again. It seems that ... |
We'd like to factorize a semiprime \$N\$. The goal of this challenge is to find two small integers \$u\$ and \$v\$ such that \$uvN\$ can be trivially factorized with Fermat's method, thus allowing to easily deduct the factors of \$N\$.
The task
Given a semiprime \$N\$ and a positive integer \$k\$, we define \$x\$ and \... |
My boss just told me to write a cosine function. Being a good math geek, my mind immediately conjured the appropriate Taylor Series.
$$\cos(x) = \frac 1 {0!} - \frac {x^2} {2!} + \frac {x^4} {4!} - \frac {x^6} {6!} + \cdots + \frac{(-1)^k \times x^{2k}} {(2k)!} + \cdots$$
However, my boss is very picky. He would like t... |
Using our familiar mathematical symbols: +, x, parenthesis, and any rational number, it's easy to create expressions that evaluates to some desired number. For example: 1+(2x3)=7, (1+2)+(3x6.5)=22.5 and so on. Boring enough.
In this challenge, we'll use a new operator: ±. The use of ± in an expression means you need to... |
Some of you may say that I am wasting my time, but this task does not give me peace for more than 500 days. It is required to write a program in Python 3.x that takes two numbers as input and displays their sum. The numbers are given in the following format:
a b
Some example test cases:
100 500 -> 600
3 4 -> 7
Th... |
Make me a s'more! I tell you the width, the amount of graham cracker, the amount of chocolate, and the amount of marshmallow. An example:
Input:
Width: 10
Graham: 3
Chocolate: 2
Marshmallow: 1.
Output:
GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG
CCCCCCCCCC
CCCCCCCCCC
MMMMMMMMMM
GGGGGGGGGG
GGGGGGGGGG
GGGGGGGGGG
Is it that easy? U... |
Given two strings, find the translation table (substitution cipher) between the two, if the translation is not possible, output false. The answer must be minimized and created from left-to-right. The first character to be translated between words must be the first in the translation table. In addition to this, any lett... |
This task is rather simple, and makes use of three distinct "operator" characters. Your task is, given a simple sequence of letters, perform the following task to encode it using <,>,*. You may choose to use either upper or lowercase letters, you do not have to handle both.
Cipher Explanation
The cipher is simple, you... |
Your challenge is to make a program or function that outputs the GCD of its inputs in one language and the LCM of its inputs in another. Builtins for GCD or LCM (I'm looking at you, Mathematica) are allowed but not encouraged. There will be 2 inputs, which will always be positive integers, never greater than 1000.
Test... |
The Rundown
Given any input x and y, perform a complex operation, and print a corresponding result.
How your program should work
Given an input x and y in the form z = x+yi, find zi-z
If the absolute real value of zi-z is larger than the absolute imaginary part, print the real part; vice versa for the other way around... |
Your mission today is to create a vortex given a single parameter.
This parameter determines the length of each arm in characters.
Each "layer" of each arm contains one more character than the last.
Here's how the vortex will look, given the arm length:
0:
#
1:
#
###
#
2:
#
# #
###
# #
#
3:
## #
... |
Well, everyone loves Polyglots. You will be given two integers, in any standard form of input (no hardcoding). Your task is to write a polyglot which finds the minimum value in a language and the maximum value between the two numbers in the other language, and performs the following operations:
The code which finds th... |
Your submission must take a list of numbers (in whatever list format your language supports, or using multiple function / command-line parameters) or a string of numbers separated by any character that is not 0123456789. In one language, it must add all of them and output the sum. In another language, it must output th... |
Definition
A dollar word is a word where when each of its letters is given a cent value, from a = 1 to z = 26, and the letters are summed, the result is 100. Here is an example on CodeReview, and here is a list of dollar words I found online.
Input
Input will be alphabetical from a-z, in your one language's text dataty... |
Challenge
Given a user's name (not ID, we have that challenge already), output their current reputation and their ID.
Input
Input will be a single string which is the user's username. You may assume that this user exists.
Output
Output will be two integers to either STDOUT or STDERR which will be the user's reputation ... |
The challenge is simple
Write a script that, when given a string input, will hash the string using the MD2 hashing algorithm, and then return either a positive integer or negative integer output based on which character set below is more common in the resulting hash as a hexadecimal string:
01234567 - (positive)
89abcd... |
Sometimes a long absolute path, in e.g. a command-line parameter to a linux tool, can be shortened, using current working directory as reference:
$ pwd
/home/heh
$ cat /home/heh/mydir/myfile
my stuff
$ cat mydir/myfile
my stuff
In this challenge, you should make a function or a program that receives two parameters:
... |
The following puzzle was asked in puzzling SE. This puzzle is quite hard to solve by hand because every answer depends on another answer. So, for example, a solution with all answers being A does not work because then the question 7 would contradict question 8, for example.
One of the answers there at puzzling SE sugge... |
Write a function, f, that takes in a positive integer and returns a function.
The new function returned should be identical to f. However, when the "termination call" happens, f should instead return the sum of all integers passed.
For example, g=f(4) (if f is the first function) should set g to another function. h=g(... |
Challenge
Create a program that, when run, changes the contents of the source file. This means that you can delete/add/change characters in the source file, but you can't delete the (source) file itself (deletion is when the source file does not exist after the program is run).
In the case of pre-compiled languages suc... |
I was messing around on my 'ol TI-84 CE and made a program that produced this output (it was actually bigger but that is not the point):
*
* *
* * *
* *
*
* *
* * *
* *
*
...
I evolved it to take input text and make the triangle waves out of that. The final step was to also take a number to specify th... |
As you may very well know python has lists. As you might not know these lists can contain themselves.
a = []
a.append(a)
Python 2
Python 3
These are cool and there are lots of interesting things you can do with them, however you cannot compare them.
a = []
a.append(a)
b = []
b.append(b)
a == b
Python 2
Python 3
Task... |
Challenge
Given a number x, output the first x powers of two, starting with 2¹ (2).
Example
2 2 4
3 2 4 8
1 2
6 2 4 8 16 32 64
You may output numbers separated by non-numerical characters. You may not just output them mashed together like 248163264128.
Rules
In your code, you may only use the number 2. You m... |
Given a non-empty set of strings and a list of strings, find out how many times the set occurs in the list, i.e. how many times you could create the set with items from the list. Every element from the list can only be used once.
Hint: a set is an unordered list of unique items.
Default input/output rules apply.
No e... |
Introduction
One day, you were showing your kid how to draw on a computer. You type mspaint.exe in the run bar. To your horror, it says "No items match your search". You must create a simple version of paint so your kid can draw!
Challenge
You must create a simple drawing program. To do this, open a white display windo... |
Challenge:
To take two points on the plane and figure out the position of the point that's a) on the line that connects them, and b) equally distant from each of the original points.
Example:
(0,0), (3,3) -> (1.5,1.5)
(-1,-1), (1,1) -> (0,0)
(-7,3), (2,-2) -> (-2.5,0.5)
(3, 1), (-5,9) -> (-1,5)
Rules:
The input an... |
Introduction
Connect Four is a game where you attempt to get four in a row: horizontally, vertically, or diagonally. In this code golf, we will be trying to find who won, given a game board. There will always be one winner, and only one winner.
Task
Given a Connect Four board, figure out who the winner is: X or Y. ... |
Every palindrome with an even number of digits is divisible by 11, so 11 is the only [palindromic prime] with an even number of digits. - David Wasserman, OEIS
I learned this today the manual way, before I did my research, when my program skipped numbers with an even number of digits (except 11) when calculating pali... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.