instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
The Cabbage, Wolf, Goat riddle with a twist!
Backstory:
There’s an intergalactic river than needs to be crossed! Being a space-ferryman you’ve offered some aliens on your small space ferry that can only carry two entities: you and a passenger. However, you know that because politics, some of these aliens will instantly... | stackexchange_codegolf |
In this challenge we learned a way to encode every positive integer using factor trees.
Here is how it works:
The empty string has value of 1.
(S) where S is any expression with a value of S evaluates to the Sth prime.
AB where A and B are arbirary expressions with values of A and B respectively has value A*B.
For ex... | stackexchange_codegolf |
Introduction
The \$RADD(n)\$ operation is defined as the sum of \$n + [\$ the number whose decimal representation are the decimal digits of \$n\$ in reverse order \$]\$, see A004086. After reversal, trailing zeros are lost. See Reverse-Then-Add Sequence and A056964.
Not all numbers can be represented as the result of a... | stackexchange_codegolf |
This code-golf challenge will give you two positive integers n and k as inputs and have you count the number of rectangles with integer coordinates that can be drawn with vertices touching all four sides of the \$n \times k\$ rectangle $$
\{(x,y) : 0 \leq x \leq n, 0 \leq y \leq k\}.
$$
That is, there should be:
at le... | stackexchange_codegolf |
You're a plumber working on a house, and there's some pipes that must be connected at weird angles. You have 8°, 11.25°, 22.5°, 45°, and 90° fittings at your disposal, and you want to use as few as possible to match the angle as closely as possible.
Goal
Match the desired angle as closely as possible, with as few fitt... | stackexchange_codegolf |
Whilst trying (and failing) have persuade my infant son to eat his dinner, I tried singing to him. Mid way through this song I realised the formulaic structure might lend itself well to code golfing!
The task is to write a program or function which accepts no input and produces the following text:
There's a hole in the... | stackexchange_codegolf |
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that the program is executed in, excluding lines that are empty, only contain whitespace, or are just single-line comments (a line which the first character tha... | stackexchange_codegolf |
Fast and Golfiest Robbers Thread
Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest algorithm) to become more popular on the site.
The rules are simple. The cops choose problems from LeetCode, a competitive co... | stackexchange_codegolf |
Introduction
All these snakes everywhere! I've had enough, and have decided that I much prefer camels. Therefore, I want you to convert my snakes to camels for me.
Challenge
Turn any snake_case string into a camelCase string.
Capitals should be returned to lowercase before the conversion occurs.
Test Cases
In: camel_c... | stackexchange_codegolf |
The infinity symbol is also called a lemniscate. Your program must draw a lemniscate with text via standard out (formatted with newline feeds) or graphically.
The infinity symbol (by my standards) must be continuous (that is, every non-whitespace character must be touching two other non-whitespace characters diagonally... | stackexchange_codegolf |
Your task is to write a computer program such that when it is cut up into lines (split on the newline character) every arrangement of the lines will output a different number between 1 and n! (where n is the total number of lines). No number should be output by two different arrangements and every arrangement should o... | stackexchange_codegolf |
Introduction:
Some times using a 24-hour clock are formatted in a nice pattern. For these patterns, we'll have four different categories:
All the same (pattern A:AA or AA:AA):
0:00
1:11
2:22
3:33
4:44
5:55
11:11
22:22
Increasing (pattern B:CD or AB:CD, where D==C+1==B+2==A+3):
0:12
1:23
2:34
3:45
4:56
12:34... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
As we all know, Santa comes down the chimney to deliver presents to good kids. But chimneys are normally full of smoke, and the Elves are worried about Santa's health. So they decide to blow the smoke out using an electronic air blower... | stackexchange_codegolf |
Introduction
This is a little challenge with the goal of identifying repeated pattern "blocks" in a string, and outputting them with their frequency of occurence from left to right.
A friend asked me this question and I realized it wasn't as simple as tossing what you've seen into a hash table and popping them off if p... | stackexchange_codegolf |
Introduction
So my boss is making me do some manual labor...urgh...I have to take a part out a box of parts, process it and put it back in the box. To make this more interesting I try to sort the parts as I do this, as each part has a unique alphanumeric serial number.
Unfortunately, I only have room to have four part... | stackexchange_codegolf |
Given an integer from 1 to 999 inclusive, output a truthy value if it appears horizontally, vertically, or diagonally, either forwards or backwards, anywhere in the 3x3 square of digits 1-9 on a standard number pad:
789
456
123
If the number does not appear, output a falsy value.
The exact 65 numbers you need to outpu... | stackexchange_codegolf |
OUTPUT: The number of seconds since midnight on January 1, 1 A.D., as an integer.
INPUT: None, you must pull the current timestamp yourself.
TASK: This is code-golf, shortest answer in bytes wins.
Standard loopholes apply.
| stackexchange_codegolf |
This challenge is a riff on Dion's challenge "Is this a rectangle?". The goal of this challenge is to write a program to decide whether or not some collection of tuples of integers represents a hypercube of some dimension.
Background
A hypercube is a generalization of a square.
A \$0\$-cube is a single point.
A \$1\$... | stackexchange_codegolf |
Task: Output the Swiss flag.
Happy Swiss National Day / Schweizer Bundesfeiertag / Fête nationale suisse / Festa nazionale svizzera / Fiasta naziunala svizra!
Details:
The flag consists of a white (#FFFFFF) cross on a red (#FF0000) background. The cross consists of a 6x6 square with arms of size 6x7 glued to each sid... | stackexchange_codegolf |
Introduction
The EKG sequence begins with 1 and 2, then the rule is that the next term is the smallest positive integer not already in the sequence and whose common factor with the last term is greater than 1 (they are not coprimes).
The first terms are:
1, 2, 4, 6, 3, 9, 12, 8, 10, 5, 15, ...
It's called EKG because... | stackexchange_codegolf |
Order and Chaos is a variant of Tic-Tac-Toe played on a 6x6 board. What makes the game unique, however, is that both players can place either an X or an O! Each turn (starting with Order), a player places an X or O in any unoccupied square.
Winning is simple. Order wins if there are 5 Xs or Os (vertically, horizontally... | stackexchange_codegolf |
As preparation for the nth Exodus, Noah decides to write a program that will decide If he will let animals on his ark. However, Noah wants to go back to grass roots. Thus he decides that the program should be as small and as simple as possible.
GOAL:
Recreate the Contrabulous Choosematron, in a way that follows evange... | stackexchange_codegolf |
Your challenge is simple. You need to write a program that prints to either STDOUT or a file the year the language it is written in was released. Because this is such a simple task, the twist is that it must be written in as many different languages as possible.
Your score is the total number of different years that ar... | stackexchange_codegolf |
My dog is called Rex. Every time I scold him, he seems not very impressed and the only times I see him react is when I pronounce his name. If I say
Rex, I told you not to do this! You're making me angry Rex!
all he hears is
Rex, * **** *** *** ** ** ****! ***'** ****** ** ***** Rex!
The challenge : given an input str... | stackexchange_codegolf |
Background
Though this is a bit late for Pi Day, I saw an article about Pilish and thought it would make a great challenge. Pilish is created by using a sequence of words where each word's length corresponds to a digit of pi.
Example from Wikipedia:
The following Pilish poem (written by Joseph Shipley) matches the fir... | stackexchange_codegolf |
Write code to generate a PDF file containing 6 bingo cards. Winner is the one that uses the shortest code and needs no actions except for installing a library and running the code. (No Save As PDF). Rules are as follows.
The generated PDF file should display accurately in Adobe's PDF reader, Google Chrome and Moxilla ... | stackexchange_codegolf |
Background
Hello is a language "written" by Anne Veling, which errors if the program does not contain only h, and will print Hello World for every h
Task
You are to write an interpreter/compiler for Hello.
Example in Python
import os
i = input("Program: ")
for a in i:
if a != 'h':
print("err")
quit(... | stackexchange_codegolf |
SVG is an XML vector graphics markup language embeddable in web content.
Your tips should be at least somewhat specific to SVG.
Please post one tip per answer.
| stackexchange_codegolf |
Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it.
Rules
Your input is an odd degree polynomial \$f\$ with integer coefficients in any reasonable format.
You must output a sequen... | stackexchange_codegolf |
Fast Trigonometry Calculations
Your task is to create a program which can calculate the sine, cosine and tangent of an angle in degrees.
Rules
No built-in trigonometry functions (not even secant, cosecant and cotangent if your language has them).
You may use lookup tables, but their total size must not exceed 3000 mem... | stackexchange_codegolf |
This is the cops' thread. See the robbers' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the robbers will try to come up with their algorithm. The catch is, the 'algorithm' must be a single closed-form mathematical e... | stackexchange_codegolf |
Related to AoC2017 Day 18, Part 2. (Anyone want to add Duet to esolangs?)
Duet is an assembly-like language that involves two processes running the same program simultaneously. Each process of Duet operates with 26 registers named a to z, all initialized to zero, except for the register p which contains the process ID... | stackexchange_codegolf |
A simple regex is either:
_ (which matches the empty string)
Any lowercase letter a to z (which matches that letter)
r*, where r is a regex (which matches r any number of times)
(r|s), where r and s are regexes (which matches either r or s)
(r+s), where r and s are regexes (which matches r followed by s)
Note that du... | stackexchange_codegolf |
You probably know the rhetorical question of whether a glass is half full or half empty. I'm getting a little tired of the phrase, so I decided that it's time to eliminate this confusion about glass fullness or emptiness programmatically.
Your task is to write a program that takes an ASCII art representation of an ugly... | stackexchange_codegolf |
Introduction
I have a room full of magic mirrors.
They are mysterious artifacts that can duplicate any item, except another magic mirror.
More explicitly, a duplicate version of the item will appear on the other side of the mirror, at the same distance.
However, if there is another magic mirror in the way on either sid... | stackexchange_codegolf |
You will be given two integers \$M\$ and \$N\$. Find the number of pairs \$(x,y)\$ such that \$1 \le x \le M\$, \$1 \le y \le N\$ and \$(x+y)\bmod5 = 0\$.
For example, if \$M = 6\$ and \$N = 12\$, pairs which satisfies such conditions are, \$(1,4), (4,1), (1,9), (2,3), (2,8), (3,2), (3,7), (3,12), (4,6), (6,4), (4,11),... | stackexchange_codegolf |
Who are they?
Primus-Orderus Primes (POP) are primes which contain their order in the sequence of primes.
So the nth prime, in order to be POP, must contain all the digits of n in a certain way which I'll explain.
Examples
Let's get things clearer:
All digits of n must appear among the digits of POP in the same order t... | stackexchange_codegolf |
Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a list of words passed as input. For example, if [carrot, potato] was the input, the optimal way to break the string up would be [potato][carrot]. If the list... | stackexchange_codegolf |
Task:
Make a program that draws the following figure line by line.
Your program should wait for one-second after drawing each line(it can be longer, just has to be a noticeable difference) .
Your program can only draw line by line (you cannot jump to another point or re-draw over a line)
Given a positive integer n, pr... | stackexchange_codegolf |
Alternating Arrays
An alternating array is a list of any length in which two (not necessarily different) values are alternating. That is to say, all even-indexed items are equal, and all odd-indexed items are equal.
Your task is to write a program or function which, when given a list of positive integers, outputs/retur... | stackexchange_codegolf |
In this challenge about prefix code, we learnt that prefix codes are uniquely concatenable.
That means, they can be joined together without separator, and without ambiguity.
For example, since [1,2,45] is a prefix code, I can join them together without separator as such: 1245245112145, and there will be no ambiguity.
H... | stackexchange_codegolf |
If you are given an array of numbers between 1 and 100 and an integer n, you must remove any instances of an item that appear greater than n times.
For example:
In : [92, 41, 81, 47, 28, 92, 84, 92, 81], n = 1
Out: [92, 41, 81, 47, 28, 84]
The most aesthetic/simple algorithm wins. And since this is a popularity-contes... | stackexchange_codegolf |
Your job, for this golf, is to write a program that will take moves of a game of reversi (othello) and display the result to the user.
Input
A string of numbers taken from the range [0-7]. Each pair of numbers represent first the X coordinate, then the Y coordinate. Any characters not in that range should be ignored.
O... | stackexchange_codegolf |
Do you have any code-golf tips for writing in SOGL, a golfing language created by dzaima?
Your tips should be at least somewhat specific to SOGL.
Please post one tip per answer.
| stackexchange_codegolf |
Intro
Something I've played around with in recreational mathematics has been construction of a divisor table to visually compare/contrast the prime divisors of a set of numbers. The set of input numbers are across the top as column labels, the prime divisors are on the left as row labels, and a mark indicates where the... | stackexchange_codegolf |
You want to send an ASCII letter to someone, but you need an envelope to put it in. Your task is to output an envelope given a size as input.
Rules:
Given positive integer input i, your envelope will be i characters tall (not counting the top row), and i*2 characters wide (not counting the side columns). In other word... | stackexchange_codegolf |
You are to golf a program that will take a filename as input and you must output what color the file is.
The file will have any one of these extensions but your program only needs to support one. Please say which one in your answer.
.jpg
.png
.svg
.gif
.bmp
And now to the classic layout.
Input
A filename with one of ... | stackexchange_codegolf |
\$\newcommand{T}[1]{\text{Ta}(#1)} \newcommand{Ta}[3]{\text{Ta}_{#2}^{#3}(#1)} \T n\$ is a function which returns the smallest positive integer which can be expressed as the sum of 2 positive integer cubes in \$n\$ different ways. For example, \$\T 1 = 2 = 1^3 + 1^3\$ and \$\T 2 = 1729 = 1^3 + 12^3 = 9^3 + 10^3\$ (the ... | stackexchange_codegolf |
Given a string, replace all left-double-quotes into two backticks and all right-double-quotes into two single-quotes.
Left-quotes means the quotes that starts a quote. Right-quotes means the quotes that ends a quote. Quotes cannot be nested. You may assume that there are an even number of double-quotes in the string.
E... | stackexchange_codegolf |
Given the ASCII art of two vectors, find the resultant vector's magnitude and degree.
Input
This can be received via STDIN, read from a local file, or provided through a function call. Here is an example of a two vector input:
^------>
|
|
|
x
This represents a change of 4 units north and 7 units east. Every input's ... | stackexchange_codegolf |
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... | stackexchange_codegolf |
Inspired by @AviFS.
Given a string containing brackets, e.g.
[xyz]]abc[[def]hij[
You can parse through it with a stack of brackets. When you find an open bracket, push a value to the stack, when you find a close bracket, pop from the stack. If you make these values indices, you know where you need to remove brackets.
... | stackexchange_codegolf |
First attempt at a question.
Calculating Transitive Closure
According to Wikipedia, "the transitive closure \$R^*\$ of a homogeneous binary relation \$R\$ on a set \$X\$ is the smallest relation on \$X\$ that contains \$R\$ and is transitive."
Also, "a relation \$R\$ on a set \$X\$ is transitive if, for all \$x, y, z... | stackexchange_codegolf |
Given three integers >= 2, create an ASCII cube in an orthogonal (cabinet) projection.
The three integers represent height, width and depth (measured in visible characters) including the corners. The corners should be 'o's or '+', free choice.
w: 10, h: 5, d: 4
Thus gives:
o--------o
/ /|
/ / |
o... | stackexchange_codegolf |
Backstory
You wake up dizzy in a chemistry laboratory, and you realize you have been kidnapped by a old mad chemist. Since he cannot see very well because of his age, he wants you to work for him and only then, you can escape the laboratory.
Task
It is your task to return the structural formulae of the molecules whose ... | stackexchange_codegolf |
We all know what a quine is. A quine is a program which prints its own source code. And we also know about the printable ASCII characters. Well... this challenge mixes both.
Your mission, should you accept it, is to create an index quine. An index quine is a non-empty program, composed only of the printable ASCII chara... | stackexchange_codegolf |
The abs() function in most languages does one thing: give the positive version of the input. Most of the times this is done using something similar to
int
abs (int i)
{
return i < 0 ? -i : i;
}
I was wondering if there is any way to do this with less bytes.
Note that this doesn't have to be more efficient, just sm... | stackexchange_codegolf |
Given an integer, output five perfect cubes whose sum is that integer. Note that cubes can be positive, negative, or zero. For example,
-10 == -64 - 64 + 64 + 27 + 27
so for input -10 you could output [-64, -64, 64, 27, 27], though other solutions are possible. Note that you should output the cubes, not the numbers be... | stackexchange_codegolf |
Martin Ender recently hit 100K, and has come up with some pretty awesome languages. We're going to have a bit of fun with one of them, Hexagony (and a bit of regex for Retina)
As a brief overview, you need to write a program that inputs a Hexagony grid and determines if there is a path on that grid that matches a stri... | stackexchange_codegolf |
An intriguing MathsSE question asked if there were large N-queens solutions where no three queens lie on a line. That question's body included the unique 4×4 solution up to symmetries
. Q . .
. . . Q
Q . . .
. . Q .
and noted that there are no solutions for 5×5 to 7×7 because of knight lines. However, joriki over ther... | stackexchange_codegolf |
Given a fraction in the format m/n (where m and n are coprime integers), output the corresponding Unicode fraction. Your program/function will not be expected to take in any input that does not correspond to a Unicode character. Arrays, e.g. [2, 3] as opposed to 2/3, are accepted. m / n as opposed to m/n is also fine. ... | stackexchange_codegolf |
[Question inspired by Can you calculate the average Levenshtein distance exactly? . Thank you Anush. ]
The longest common substring between two strings is the longest substring which is common to both. Please note this is not the same as the longest common subsequence whose fastest algorithm takes quadratic time.
The ... | stackexchange_codegolf |
Given a multidimensional array, find the recursive alternating sum. An alternating sum is simply the sum of an array, where every other item (starting with the second) is negated. For example, the alternating sum of [7, 1, 6, -4, -2] is the sum of [7, -1, 6, 4, -2], or 14. In this challenge, you'll take the alternating... | stackexchange_codegolf |
Tamagotchi and Giga Pets were small electronic devices which simulated a little virtual pet. This pet had several stats, like health, hunger, etc.
I recently wrote this example:
import msvcrt,os,sys;d=m=100;h=s=t=p=0;f=10
while 1:
os.system('cls'if os.name=='nt'else'clear');print("health:",d,"\nhunger:",h,"\nsleep:",... | stackexchange_codegolf |
The Riemann R function is as follows:
$$R (x)=\sum _{n=1}^{\infty } \frac{\mu (n) \text{li}\left(x^{1/n}\right)}{n}.$$
This uses the Möbius function as well as the logarithmic integral.
From Wikipedia, the Möbius function is defined so that for any positive integer \$n\$, \$μ(n)\$ is the sum of the primitive nth roots... | stackexchange_codegolf |
How do I remove all duplicates from list and order it based on count?
s = ["foo", "this", "lem", "foo", "lem"]
s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"]
#should return
>>> ["foo", "lem", "this"]
>>> ["ebh", "wosv", "foo", "4whcu"]
Rules:
Must be shorter than the below code in terms of byte size.
Order must b... | stackexchange_codegolf |
Your challenge is to take an array of strings and output the longest string in the array. So for
["tiny", "small", "bigger", "biggest"]
the output would be biggest.
If two elements of the array have the same length, you should choose the one that appears first in the array. That means if the array looks like this:
["o... | stackexchange_codegolf |
I was asked by OEIS contributor Andrew Howroyd to post a Code Golf Challenge to extend OEIS sequence A049021.
Would be super great to get a couple more terms for [...] A049021. Kind of thing [...] team golf would excel at.
As I found out the hard way with the help of user202729, the definition of A049021 is... slippe... | stackexchange_codegolf |
So, I wrote myself a one-liner which printed out a snake on the console. It's a bit of fun, and I wondered how I might condense my code...
Here's a (short) example output:
+
+
+
+
+
+
+
... | stackexchange_codegolf |
Specification
Write the shortest possible code in any language that does the following:
It takes two arguments, x and y, and generates x + y lines of text.
The first x lines should consist of y nested pairs of square brackets separated by a space surrounding a single digit, which cycles from 1 to 9, then 0 to 9, etc. f... | stackexchange_codegolf |
Alternesting, is the act of taking a string and nesting it in alternating brackets. Here is how you alternest a string.
For a string of length N, take the center N characters, and surround them in parenthesis. So if our string was Hello world! (12 characters), we'll end up with
(Hello world!)
Then, take the remaining... | stackexchange_codegolf |
It's really frustrating when I'm working and I have a ton of windows open that are completely or partially hidden behind other windows. To make things worse, I'm still using two 1024x768 monitors.
Your task is to take a list of coordinates that designate the area, in pixels, on a screen, that a list of windows occupy a... | stackexchange_codegolf |
I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a readline call (replaced in the snippet with a prompt).
In order to get the horizontal and vertical position differentials, I'm writing the following code:
[x1,y1,x2,y2]=prompt("Please enter th... | stackexchange_codegolf |
Introduction
Given an ASCII tower and the force of the wind, write a program or function to determine if the tower will balance or which way it will fall.
For example the first tower balances but the second falls over toward the left.
# # # #
### ###
### ###
# # # #
... | stackexchange_codegolf |
You are to write a program which generates random integers between \$0\$ and \$99\$ inclusive, outputting each integer in turn, until \$0\$ is generated. You may choose which single-order random distribution (uniform, binomial, Poisson etc.) you use so long as each integer has a non-zero chance of being generated and i... | stackexchange_codegolf |
You have a phone plan that lets you talk 180 minutes a day. Every day that you go over your daily limit you have to pay a fine of F = Men, where M is the number of minutes you went over and n is the number of days you have gone over (e.g if I went 20 minutes over the daily limit and it's my 2nd day going over, I have t... | stackexchange_codegolf |
task
Your task is to build a structure with \$n\$ cubes. The volume of cubes follow the following sequence (bottom -> top)
\$n^3, (n-1)^3, (n-2)^3,...,1^3\$
input
The total volume of the structure (\$V\$).
output
value of (\$n\$), i.e : The total number of cubes.
\$V = n^3 + (n-1)^3 + .... + 1^3\$
notes
Input will a... | stackexchange_codegolf |
Explanation
Befunge is a two-dimensional program that uses stacks.
That means, to do 5 + 6, you write 56+, meaning:
56+
5 push 5 into stack
6 push 6 into stack
+ pop the first two items in the stack and add them up, and push the result into stack
(to those of you who do not know stacks, "push" just means add ... | stackexchange_codegolf |
Here's a fun idea:
Write a simple game (tic-tac-toe, guess the number, etc) that has an easter egg in it, that can be triggered by a specific, special input from the user and does something cool, but the code for the game does not appear to contain any easter eggs (or any obviously obfuscated code) at first glance.
Thi... | stackexchange_codegolf |
In Applied Cryptography by Bruce Schneier (which I have been reading quite a lot recently), a protocol for splitting secrets is discussed. Here is a brief description:
Trent generates a random byte string, R, the same length as the message, M.
Trent XORS M with R to make S.
He gives R to Alice and S to Bob.
Your ... | stackexchange_codegolf |
Lets define a pointer sequence to be any sequence such that a(n) = a((n-1)-(a(n-1))) forall n greater than some finite number. For example if our sequence begun with
3 2 1
Our next term would be 2, because a(n-1) = 1, (n-1)-1 = 1, a(1) = 2 (this example is zero index however it does not matter what index you use the... | stackexchange_codegolf |
Intro
Two numbers are a reversed multiple pair if they satisfy the following property:
$$
a\cdot b = \operatorname{reversed}( (a-1)\cdot b )
$$
Here, \$\operatorname{reversed}()\$ means to reverse the digits of a number (e. g 123 becomes 321.)
Example
$$
a=6,\quad b=9,\quad
6\cdot 9=54,\quad
5\cdot 9=45
$$
As you can ... | stackexchange_codegolf |
I'm new to this site, so I don't know whether this challenge already appeared:
Write a piece of source code, so that after running the code, it prints out exactly (i.e. not longer, not shorter) the source code itself.
The code can be in any programming language, but preferably in commonly used ones, such as the C famil... | stackexchange_codegolf |
It is well known, in the field of Mathematics studying infinity, that the Cartesian product of any finite amount of countable sets is also countable.
Your task is to write two programs to implement this, one to map from list to integer, one to map from integer to list.
Your function must be bijective and deterministic,... | stackexchange_codegolf |
The idea is simple. You've to create a "visualised" letter-replacement, by providing 3 strings (input can be comma separated, separate inputs, or as an array). The first segment is the word you want to correct, and the second segment is the letters you want to replace, and the third segment is the replacement for the l... | stackexchange_codegolf |
Challenge: Create a program that prints out the size of its own source code file.
For example, a 35 bytes size of program must print out 35. Pre-calculation is not valid. What I mean by pre-calculation is:
// test.js -> its size is 15 byte
console.log(15)
It must dynamically calculate the size of own source code fi... | stackexchange_codegolf |
(This is OEIS A057531.)
Your task
Given a positive integer, \$n\$, find the \$n\$th number where the digit sum equals the number of factors
Explanation
For example, let's take 22:
Its factors are \$[1, 2, 11, 22]\$ (length: 4).
Its digit sum is 4.
This means that it is a number where the digit sum equals the number of ... | stackexchange_codegolf |
Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length.
If there are multiple of the same maximal length, any of them can be returned.
Definitions:
An arithmetic sequence is a sequence \$a(1),a(2),a(3),a(4),...\$ such that there is a constant \$c\$ such that \$a(m+1)-a(m) = c\... | stackexchange_codegolf |
Challenge
In this challenge, we will use a language that is very similar to Brainfuck but slightly different.
This variant of BF does not have any input and output commands; instead, it simply takes a tape as input and modifies it until it halts. The final state of the tape is considered the output of the program.
The... | stackexchange_codegolf |
This challenge has been divided into parts.
Your goal is to convert a sentence into a form of 'short-hand'
For Part 1 these are the rules
Take in 1 word
Remove all vowels(a,e,i,o,u), except the ones at the beginning and the end
If a letter is repeated more than once consecutively, reduce it to only one (e.g. Hello -> ... | stackexchange_codegolf |
A time in the format hhMMss is represented by six numbers in the range 0..9 (e.g.100203 for 3 seconds after 2 minutes after 10am (10:02.03), or 155603 for three seconds after 56 minutes after 3pm (15:56.03).
Treating these times as integers, these numbers are therefore in the range 000000 to 235959; but not all numbers... | stackexchange_codegolf |
You have 2 numbers, both stored separate as numeric data type.
First number is always 6 digits long.
Second number can vary between 1 and 4 digits. If it's less than 4 digits, it needs to be padded with numeric value 0.
End result always needs to be 10 digits number.
Order has to be respected. n1|n2
Example #1:
n1 = 11... | stackexchange_codegolf |
You are James and four of your friends (Bjarne, Eich, Rossum, Ada) are called for an interview. There are n interviewers, and they can each serve one person at a time, alphabetically. Each round of interview takes 20 min.
Let's take n = 2,
So, the first round started with Ada and Bjarne, takes 20 min (they're handle... | stackexchange_codegolf |
This challenge takes place on the snub square tiling.
Start by choosing any triangle, and color it \$c_1\$.
Next, find all tiles which touch this triangle at any vertex, and color them \$c_2\$. Next, find all tiles which share a vertex with any \$c_2\$-colored tile, and color these \$c_3\$.
Continue this process ad inf... | stackexchange_codegolf |
Suppose we have two different types of coin which are worth relatively prime positive integer amounts. In this case, it is possible to make change for all but finitely many quantities. Your job is to find the largest amount that cannot be made with these two types of coin.
Task
Input: A pair of relatively prime integer... | stackexchange_codegolf |
Given a textual representation (case-insensitive full name or 3 character abbreviation) of a month return the number of days in the month.
For example, december, DEC, and dec should all return 31.
February can have either 28 or 29 days.
Assume the input is a month in one of the correct forms.
| stackexchange_codegolf |
Challenge
Given a positive integer \$N \ge 3\$, generate an alternating series of \$N\$ random numbers within the range \$[1, N]\$, such that their sum equals \$N\$. Expressed mathematically as
$$N = \sum_{i=1}^{N} (-1)^{i-1} a_i$$ where \$a_i \in [1,N]\$ are random terms.
Input
\$N\$
Output
A string representing the ... | stackexchange_codegolf |
Introduction:
Aaron is a young game developer. He recently joined the development team of a game where the players select their character from a predefined set, aka "heroes". Unfortunately, the names of the existing heroes are not evenly distributed throughout the alphabet. For example, there are 6 heroes that have a n... | stackexchange_codegolf |
You've inherited a server that runs several apps which all output to the same log.
Your task is to de-interleave the lines of the log file by source. Fortunately, each line begins with a tag that indicates which app it is from.
Logs
Each line will look something like this:
[app_name] Something horrible happened!
App ... | stackexchange_codegolf |
You should write a program or function that given a list of positive integers multiplies each element with the smallest positive integer possible to create a strictly increasing list.
For example if the input is
5 4 12 1 3
the multiplications will be
5*1=5 4*2=8 12*1=12 1*13=13 3*5=15
and the output will be the incre... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.