instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given a random code written using Brainfuck commands. You program should translate that code into the following ascii art: each Brainfuck command represents as 5x9 array of A and B symbols. All commands are concatenated with 5x3 arrays of A symbols. Symbols A and B you choose yourself.
For example, when input is ><+,.[... | stackexchange_codegolf |
Introduction
File names can be wildly varying things, ranging from a simple blah.txt to 303549020150514101638190-MSP0.txt. The former is usually human generated, while the latter is often machine generated. Wouldn't it be nice to have a simple function to make educated guesses on whether or not a file might be consider... | stackexchange_codegolf |
Following this question: Tut-tut-tut-tut-tut
Write a program that writes "tut-tut-tut" without using the characters "t", "u" or "-" in the code itself.
This is code golf, shortest code in bytes wins.
| stackexchange_codegolf |
Given an integer n as input, write a function that dynamically allocates n bytes and returns their address.
Rules
The allocator must be able to dynamically allocate memory at runtime.
It doesn't matter where the memory is allocated to or in what form, as long as it's allocated in a valid location which can be read fro... | stackexchange_codegolf |
Your job is to write a program that takes a number N as input and outputs all 2-by-N mazes that are solvable.
Output format can be in the form of any two distinct values representing wall and empty - I use x and . here but you can use anything. You can have a matrix, array, string, ascii art, whatever is convenient, an... | stackexchange_codegolf |
The Challenge
Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it.
Related.
Permissions in UNIX system
In UNIX, every file has three classes of permissions (user, group and others... | stackexchange_codegolf |
The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels:
あかさ
たなは
まやら
小わ、
When a key is tapped, it produces its respective kana. However, when the key is flicked in one of the four cardinal directions (up, down, left, right) it prod... | stackexchange_codegolf |
Takuzu is a logic game in which you have to complete a grid with cells containing 0s and 1s. The grid must follow 3 rules:
No three horizontal or vertical consecutive cells can be the same.
There must be an equal number of 0s and 1s in each row and column.
No two rows can be the same, and no two columns can be the sam... | stackexchange_codegolf |
Background
Often, when storing a number in binary with some maximum, we simply round the maximum to the next power of two then allocate the number of bits nececairy to store the whole range. Lets call the result of this method \$S(x, m)\$ where x is the number and m is the maximum.
While not bad, the naive has a few bi... | stackexchange_codegolf |
The Task
Your task is to create a program or a function that, given a sentence, outputs it translated to the Farfallino language. 'Y' is treated as a consonant.
The usual rules for farfallino alphabet are based on the substitution of each vowel with a 3 letter sequence where the vowel itself is repeated with an interce... | stackexchange_codegolf |
Background:
For this challenge, a polynomial looks like this:
$$P(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_2x^2+a_1x+a_0$$
The degree, \$n\$, is the highest power \$x\$ is raised to. An example of a degree 7 polynomial would be:
$$P(x)=4x^7+2x^6-7x^4+x^2-6x+17$$
All powers are integers \$n\ge0\$. This means \$x\$, \$-2\$, and ... | stackexchange_codegolf |
Sandbox
Inspired by a Codingame challenge I tried (and failed at) about a month ago.
Given a binary tree of words, say:
HELLO
/ \
WORLD EATING
/ / \
ARCH IDAHO GUARD
/
DOOZY
/
... | stackexchange_codegolf |
Write a program which can encode text to avoid reusing characters, and convert back.
Both normal and encoded forms are restricted to a particular character set: the space character with code point 32, the tilde character ~ with code point 126, and all characters between. This is 95 total characters. It's a printable s... | stackexchange_codegolf |
Inspired by a chat conversation I lurked.
I am an adventurer on the far away land of Zendikar. I truly enjoy traveling the land. Bushwhacking, weathering the roil and encountering strange and exotic flora and fauna are the highlights of any good adventure. Unfortunately, my duties as an adventurer do not always allow m... | stackexchange_codegolf |
Generate the contents of an SVG file containing 6 bingo cards. Winner is the one that uses the shortest code. A qualifying answer has an output that can be directly pasted in a blank to get the required image. Rules are as follows.
The generated SVG code should comply with SVG version 1.1 described here.
The size of t... | stackexchange_codegolf |
In the tabletop RPG named Pathfinder, there is a feat that characters can take called Sacred Geometry, which allows a character who has it to buff their spells in exchange for doing some math: to use it, the character rolls a number of six-sided dice equal to their ranks in a particular skill, consults a table based on... | stackexchange_codegolf |
The Challenge
Given an input string (or array) consisting of < and >, output a sequence (array or string) of integers such that:
the operators are all correct when applied in order between consecutive numbers in the output
all integers are positive (1 or greater)
the sum of the integers is as small as is mathematicall... | stackexchange_codegolf |
According to Wikipedia,
In mathematics, a natural number \$n\$ is a Blum integer if \$n = p \times q\$ is a semiprime for which \$p\$ and \$q\$ are distinct prime numbers congruent to \$3 \bmod 4\$. That is, \$p\$ and \$q\$ must be of the form \$4t + 3\$, for some integer \$t\$. Integers of this form are referred to a... | stackexchange_codegolf |
When this question was posted, it was caird coinheringaahing's birthday! (source: 1, 2, 3, 4) (It was also World Emoji Day.)
As a bit of some CGCC lore, caird's name came from a Jelly answer by Dennis (source) - the compressed form of "Code Golf" in Jelly is “½ċṭ6Ỵ», and if you insert a space (“½ċṭ6 Ỵ»), it becomes "ca... | stackexchange_codegolf |
This is the robbers' challenge. The cops' one is here.
In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing ... | stackexchange_codegolf |
The Fabius function is an example of a function that is infinitely differentiable everywhere, yet nowhere analytic.
One way to define the function is in terms of an infinite number of random variables. Specifically, given a sequence of independent random variables \$\{U_n\}\$, where each \$U_n\$ is uniform on the inter... | stackexchange_codegolf |
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py...
from random import*;c=['heads','tails'];print('u win'if choice(c)==input(' / '.join(c)+': ')else'u lose')
The program asks the user for either "heads" or "tails", if the result ... | stackexchange_codegolf |
The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional.
The same word must be output in a modified version: For each character, double it the second time it appears in the original word, triple it the third time etc.
Example input:
bonobo
Example output:
bonoobbooo
Stan... | stackexchange_codegolf |
Select any word from https://websites.umich.edu/~jlawler/wordlist with length greater than 1. For each letter on that word, remove it and check if any rearrangement of the remaining letters is present in the wordlist. If it is, this rearrangement is a child anagram of the original word.
For example, theism:
removing t... | stackexchange_codegolf |
API Easter egg hunt!
There's an API at http://easter_egg_hunt.andrewfaraday.com which will provide a special Easter egg hunt, just for you...
You can see the API docs at the above address, or try it from here.
The API:
All calls to this API are GET requests, which will return a JSON string.
These examples are in a 5x5 ... | stackexchange_codegolf |
It's the election! The area which we are in implements the system of voting called instant runoff (sometimes called alternative vote or preferential voting). Each voter orders each candidate from most preferred to least preferred, marking a "1" for their most preferred candidate,
a "2" for their second candidate, and s... | stackexchange_codegolf |
Inspired by The Great API Easter Egg Hunt!
Summary
Your task is to search for a predetermined integer in the "Collatz space" (to be explained later) using the fewest step possible.
Introduction
This challenge is based on the famous Collatz conjecture that hopefully everyone here at least heard of. Here is a recap taken... | stackexchange_codegolf |
Given (on STDIN, as command line arguments, or as function arguments) two distinct non-empty strings, find and return the shortest substring of the first string which is not a substring of the second. If no such substring exists, you may return the empty string, return any string which isn't a substring of the original... | stackexchange_codegolf |
Input: n
Output: A list of length n, with each element being the nth happy prime.
Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number either equals 1, or it loops endlessly in a cycle which does not include 1. A happy number is a number... | stackexchange_codegolf |
Introduction:
Inspired by these two SO questions (no doubt from the same class): print the elements in the subarray of maximum sum without adjacent elements java and Maximum sum of non adjacent elements of an array, to be printed.
Challenge:
Given a list of integers, output a subsequence consisting of non-adjacent elem... | stackexchange_codegolf |
Your code has to provide the following functions:
read(x)
Reads a complex number from the standard input. It has to accept and evaluate something in the form of for example 1.42 + 3i.
print(x)
Prints the complex number in the form of, for example 1.23 - 4.32i
add(x,y)
sub(x,y)
mult(x,y)
div(x,y)
Adds, subtracts... | stackexchange_codegolf |
Today, @HyperNeutrino succeeded merging his two accounts, and finally got the reputation he lost back. Now, it's time to celebrate! Your task is to output this exact text:
/\
/ \
/ \
/ \
/ \
/ \
/ ... | stackexchange_codegolf |
For the given string s, generate generate a table like below.
Input:abcd
Output:
abcd
bbcd
cccd
dddd
Input:Hello, world!
Output:
Hello, world!
eello, world!
llllo, world!
llllo, world!
ooooo, world!
,,,,,, world!
world!
wwwwwwwworld!
ooooooooorld!
rrrrrrrrrrld!
llllllllllld!
dddddddddddd!
!!!!!!!!!!!!!
Trailin... | stackexchange_codegolf |
Robbers' Thread
Your challenge is to find an existing challenge, and implement it in a way such that certain inputs fail. At least one input must not produce the correct output (use the other submissions on the challenge as a reference for this, but be sure to double-check). This must fail consistently, and you must kn... | stackexchange_codegolf |
Pickleball doubles is a game where only the serving side can score. The server calls the score as a triple of numbers, the serving side's score, the receiving side's score, and \$1\$ or \$2\$ to indicate whether the server is the first or second of their side to serve. If the server's side wins a point, their score i... | stackexchange_codegolf |
This is a problem on Luogu OJ. I decided to post it here because on Luogu OJ, many people, including me and my friend, are interested about how to solve this problem within the fewest characters.
Your task is to output the following ASCII-art:
************
####....#.
#..###..... | stackexchange_codegolf |
You are the captain of a world-famous wrestling team. An Olympic-grade match is coming up, and you are determined not to let your team down. You also happen to be a competent programmer, so you are going to write a program to help your team win!
You have access to the strength ratings for each of your own team wrestler... | 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 |
Another sequence, another challenge.*
Definition
A prime p is in this sequence, let's call it A, iff for every digit d in p's decimal expansion, you replace d with d copies of d and the resulting integer is still prime; zeros are not permitted.
For example, 11 is trivially in this sequence (it's the first number, incid... | stackexchange_codegolf |
Introduction
A polyglot is a program that is valid in multiple languages at once. An iterative quine is a program that outputs another program that outputs another program that outputs the source of the original program. Note that the number of chained programs does not have to be 3; it could be 2, 4, or 97384.
Challen... | stackexchange_codegolf |
I have a combinatorics problem that I'd like to put on the OEIS—the problem is that I don't have enough terms. This code challenge is to help me compute more terms, and the winner will be the user with the submission containing the greatest number of terms.
The Problem
Suppose I give you a triangular array of light bu... | stackexchange_codegolf |
You are the electoral strategist for a sudden late entrant in the 2020 US presidental election.
Your task: print out the names of states* your candidate will win, totalling at least 270 electoral college votes.
Background
Each state (and Washington DC) in the US system has an arbitrary number of "electoral college vot... | stackexchange_codegolf |
Source: Wikipedia
For this challenge, you should write two programs which resemble the figure and ground of the above image, such that one of them prints figure and the other prints ground. Specifically:
Write a program which takes no input and prints the string figure. The only allowed whitespace characters in your ... | stackexchange_codegolf |
Task
Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, but not diagonally. Every symbol on the path must be a 1, and it must start somewhere in the first column and end somewhe... | stackexchange_codegolf |
Your function or program should take a year as input and return (or print) the date (in the Gregorian calendar) of that years Easter (not the Eastern Orthodox Easter). The date returned should be formatted according to ISO 8601, but with support for years greater than 9999 (such as 312013-04-05 or 20010130), and it onl... | stackexchange_codegolf |
In this challenge, you are given two overlapping rectangles, and you need to calculate the rectangles created by removing one from the other.
For example, if you remove the red rectangle from the black one:
You end up with one of the following two rectangle sets:
You'll also need to handle the following:
To be more... | stackexchange_codegolf |
If I want to type the string aaa, the least keystrokes I can type it in is 3: a a a. But if I want to type the string aaaaaa, I can do it in 5: a a a ctrl-c ctrl-v, where the ctrl-c refers to copying aaa and the ctrl-v refers to pasting it.
Specifically, starting with an empty "buffer" and an empty "clipboard":
The ke... | stackexchange_codegolf |
Given N (2 <= N), print N lines of the letter Fibonacci series like this (i.e. N = 5)
First, start with a and b:
a
b
Next, add the two lines.
a
b
ab
Keep adding the last two lines.
a
b
ab
bab
Keep going...
a
b
ab
bab
abbab
And we're done.
Remember, this is code-golf, so the code with the fewest bytes wins.
| stackexchange_codegolf |
Robber Thread here
The Challenge
Choose any numeric* formula, algorithm, or code challenge. Implement it in such a way that the math is correct, but at least one answer is wildly** wrong due to some defect in how computers/programs operate, e.g. floating point errors, uninitialized/corrupted memory, environment bugs, c... | stackexchange_codegolf |
We are given a list of integers p1, ..., pk (not necessarily distinct) where each has a value between 1 and 9, inclusive. Using each of the p1, ..., pk exactly once, we can form concatenations of digits, to achieve a new list of numbers; we then output the product of this new list. The goal is to maximize this product ... | stackexchange_codegolf |
Polystrips are a subset of polyominoes conforming to the following rules:
each piece consist of 1 or more cells
no cell can have more than two neighbours
the cells should not enclose a hole
Free polyominoes are distinct when none is a rigid transformation (translation, rotation, reflection or glide reflection) of ano... | stackexchange_codegolf |
I love math. But I can't find a single calculator that can multiply correctly. They seem to get everything right except 6*9 (It's the question to life, the universe, and everything! How could they get that wrong?!). So I want you all to write a function for me that can multiply 2 numbers correctly (and 6*9 equals 42 in... | stackexchange_codegolf |
Barbrack
Your task is to write a program or function that takes a non-negative integer (in decimal or any other convenient base for your language), and output a number in the numbering system Barbrack.
What's that?
Barbrack is a numbering system I made up that can represent non-negative integers. Zero is represented wi... | 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 |
In the musical rendition of Les Miserables, a song appears called "Red and Black." Here is part of that song:
Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!
Source.
Your task is to turn input into a resounding "Red and Black" anthem.
Inpu... | stackexchange_codegolf |
Pretty simple challenge here. Who can make the fastest algorithm (lowest time complexity) to determine whether or not the circle is "boxed in" given the following setup?
Input: Your program receives a pair of numbers (a,b) that denotes the position of a circle on a grid like this with arbitrary dimensions:
Where a-1 i... | stackexchange_codegolf |
I was seen multiple shortest "Hello World!" program, but this is the longest program.
The Rules
Each submission must be a full program.
This must be non-interpreted language (for example, JavaScript, Python, HTML, etc.)
Target OS must be Windows, Mac, Linux or MS-DOS.
The challenge
Writing a longest Hello World prog... | stackexchange_codegolf |
You have given an array from which we need to remove duplicates.
Rules:
First or immediate duplicates gets removed first.
Array contains natural numbers a[i]>0 for i>=0
no. of elements in the array is greater than 1 i.e. n>1
e.g.
{1,2,3,4,5,5,4,6,6,7,8}=> {1,2,3,7,8}
{1,2,3,3,4,5,6,7,7,8} => {1,2,4,5,6,8}
{1,1,3,3,... | stackexchange_codegolf |
Robbers' Challenge
Read the cops' challenge first.
In this cops-and-robbers challenge, you (the robbers) must find the correct string of characters, which, when added into the cop's code, will make it produce the correct (case-sensitive) output (except that there may also be an extra trailing newline at the end).
The n... | stackexchange_codegolf |
This is a variant on the self-replicating program, defined here as a program that outputs its source (or a quine). Below is an example of a self-replicating program in Python:
s = 's = %r\nprint(s%%s)'
print(s%s)
When run from a file, this script should output itself.
Instead of a self-replicating program, I want you ... | stackexchange_codegolf |
Your task is to write a program in x86 machine language (any version you like) that will run through as many instructions as possible and then halt, using a maximum of 32 bytes of code and starting with zeroed-out registers.
You can assume anything about the random-access memory you like, as long as it's in a usable fo... | stackexchange_codegolf |
Given a string consisting of only upper and lower case letters, output an if it begins with a vowel, and a if not. For the purposes of this challenge, we'll ignore normal grammar rules, and use a very basic rule instead: if the input begins with a vowel (any of AEIOUaeiou), then output an. Otherwise, output a.
Your pro... | stackexchange_codegolf |
With the US election going on right now, I noticed that there is one (completely meaningless, but still) thing which Trump can still achieve and which is out of reach for Biden: Having the won states being connected.
Task: Given a list of strings of two-letter abbreviations (see below) for US states, determine whether ... | stackexchange_codegolf |
Objective
Given the distance between two keys in an octave, identify its name.
But there's a caveat. In this challenge, there are 22 keys in an octave, not usual 12.
Here, a porcupine[7] scale will be assumed.
Mapping
White keys are marked bold.
Distance
Name
0
Unison
1
Augmented Unison or Diminished Second
... | stackexchange_codegolf |
Consider an array A of integers of length n. The k-max subarray sum asks us to find up to \$k \leq 3\$ (contiguous) non overlapping subarrays of A with maximum sum. If A is all negative then this sum will be 0. If A = [-1, 2, -1, 2, -1, 2, 2] and k=2 for example, then the two subarrays could be [2, -1, 2] and [2, 2] ... | stackexchange_codegolf |
Your program should take as input a number n that is greater than 0 and output a bar composed of n // 8 ▉ characters (U+2588), as well as a final character which should be one of ▉ ▊ ▋ ▌ ▍ ▎▏(U+2589 to U+258F) representing n % 8. If n % 8 is 0, your program should not output any additional characters. This is difficult... | stackexchange_codegolf |
Most Unicode characters have full names, for example ” is "RIGHT DOUBLE QUOTATION MARK". You can find a useful reference here, just type in the character you want to find the full name of and look in the DESCRIPTION column.
Your challenge is to write a program or function that outputs itself as a string of these. You c... | stackexchange_codegolf |
I'm sure everyone has seen before that cups can be stacked into pyramids (and other shapes):
A
A A A
A A A A A
A A A A A A A A
Yes, A is definitely an adequate character to represent a cup.
New cups could be added either on the ground, to the right of the structure, or on top of two ad... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
You successfully route the laser into the sensor, but nothing happens.
"What?" Frustrated, you flip the note from Santa. There's some more text:
Calculate the number of ways to complete the laser puzzle, and enter it into the number p... | stackexchange_codegolf |
The Narrative
You are a bad musician. You never bothered to learn how to count rhythms. To remedy this shortcoming, you decide to write a program that will tell you how to count in any given time signature. You are still a bad musician, but you can at least pretend that you can count rhythms.
The Objective
Given a time... | stackexchange_codegolf |
Given a number n, calculates BB(n) (the maximum number of 1s finally on the tape, among all halting 2-symbol n-state Turing machines with tape of zeros).
To solve the problem, you are given an extra (black-box) function H as input, which takes a function in your language (f) and returns a truthy/falsy value indicates w... | stackexchange_codegolf |
Write a full program or a function taking an unsigned integer number N and doing this cut out work:
Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/'
Translate the piece above by 3 lines.
Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ... | stackexchange_codegolf |
Challenge
Your goal is to find the furthest point on a graph (from a provided start node). Your code doesn't need to handle cycles in the graph properly, but it might pose a fun challenge. For this question, you can assume the graph is actually a tree.
Input data
Input can be provided in any suitable format for the lan... | stackexchange_codegolf |
Implement the binary search algorithm as used to identify the source code revision that breaks a computer software program. Your tool should take two arguments specifying the earliest and latest numbered revision to search (both positive integers), and you have two options for making comparisons:
Execute the shell com... | stackexchange_codegolf |
The hamburger joint maHburger has hired you to write a program for them.
It is simple: make an ASCII hamburger, using the key. Sounds simple right? Well these customers are super picky, but one thing is for sure, they do love onions.
Write a program that accepts the customer's orders, and prints a hamburger with as man... | stackexchange_codegolf |
In the burial place of King Silo of Asturias there is an inscription that reads SILO PRINCEPS FECIT (King Silo made this).
The first letter is found in the very middle, and from there one reads by going in any non-diagonal direction radiating outward. The final letter is found on all four corners. In this challenge,... | stackexchange_codegolf |
Challenge
You just entered a room. Here's how it looks (you are the X):
|\ /|
| \/ |
| X |
| |
|----|
You challenge yourself to see if you can reach where you started by following the walls. You go right until you find a wall. Then, you turn clockwise until you are facing parallel to the wall.
For example, if you... | stackexchange_codegolf |
Consider a sorted array of positive floating point numbers such as:
input = [0.22, 2.88, 6.35, 7.17, 9.15]
For each integer \$i\$ from 1 up to the last value in input rounded up, output the mean of all values less than \$i\$.
In this case the output should be:
[0.22 0.22 1.55 1.55 1.55 1.55 3.15 4.155 4.155 5.154 ]
I... | stackexchange_codegolf |
...or is there?
Your challenge is to parse my lunch bill, which contains the base price, tips, discounts, coupons, and extras and find out if my lunch was $0 or less. If this is the input:
12.34
15 tip
25 discount
1.5 extra
2 coupon
Then the output might be false. Here's how it works:
12.34 is the base price.
15 tip m... | stackexchange_codegolf |
Write a program that takes a single line string that you can assume will only contain the characters /\_‾. (That's forward and backward slash, underline and overline. You can use ~ in place of overline if you need since overline is not convenient ASCII.)
For example, one possible input is:
__/‾‾\/\_/‾
Your program nee... | stackexchange_codegolf |
This is my first question in Code golf I found it in stack-overflow (originally in JavaScript however all languages are acceptable):
Render on screen NxN (where N in range 1-16) grid where each cell have black boundary and red number inside - cells are numerated in hex starting from left-upper corner to bottom-right. E... | stackexchange_codegolf |
Print or return the following text:
Hello world! The quick brown fox jumps over a lazy dog.
However, your submission will not be scored in bytes. Instead, primarily it will be scored by the width in pixels of the program when written in Arial in a 12pt font. In particular, the score is:
$$ (\text{visual width in px}) ... | stackexchange_codegolf |
Background
Gödel numbers are a way of encoding any string with a unique positive integer, using prime factorisations:
First, each symbol in the alphabet is assigned a predetermined integer code.
Then, to encode a string \$ x_1 x_2 x_3 \ldots x_n \$, where each \$ x_i \$ represents an symbol's integer code, the resultan... | stackexchange_codegolf |
The round function in Python 3 will round values of the form \$k+\frac{1}{2}\$ (with \$k\$ being an integer) to the nearest even integer, which is apparently better than the rounding method taught in school
Your task is to recreate this functionality: write a program of function that given a (real) number as input, out... | stackexchange_codegolf |
Given a list of countries in alphabetical order, put them in the same order as they are given in the song "Yakko's World".
Specifically, you are given the following list of countries* exactly:
Abu Dhabi, Afghanistan, Albania, Algeria, Algiers, Angola, Argentina, Australia, Austria, Bahamas, Bahrain, Bangladesh, Barbado... | stackexchange_codegolf |
Your challenge is to create a shortest code in your language of choice which writes on a .txt file the longest code to multiply two numbers by taking two numbers as input and output the answer.
NO INPUT NEEDED TO YOUR CODE WHICH IS DOING THE WRITING JOB!
The generator code and generated code can be in any languages
Do ... | stackexchange_codegolf |
The round function in Python 3 will round values of the form \$k+\frac{1}{2}\$ (with \$k\$ being an integer) to the nearest even integer, which is apparently better than the rounding method taught in school
Your task is to recreate this functionality: write a program of function that given a (real) number as input, out... | stackexchange_codegolf |
Each element on the periodic table of the elements has an atomic weight. For example, boron (element 5) has an atomic weight of 10.81. Your challenge is to write a program which takes as input the atomic number of an element and outputs its atomic weight.
Your program only needs to support elements up to and including ... | stackexchange_codegolf |
You're with your best bud, Jim, at the amusement park and as your favorite ride comes into view, you and Jim exchange glances. Naturally you race to get in line. Unfortunately he wins because you're a golfer and he plays a real sport (sorry friends). In fact, you're so far behind that you and Jim are separated by x peo... | stackexchange_codegolf |
Given a ragged list of positive integers return a full cycle of recursive rotations starting with the unchanged input and ending with the state immediately before revisiting the initial state.
Examples:
[[2,3],4,5,5] -> [[2,3],4,5,5] , [4,5,5,[3,2]] , [5,5,[2,3],4] , [5,[3,2],4,5]
[1,10,[2,2,4],6,[[5,6],7],1] -> [1,10... | stackexchange_codegolf |
(heavily inspired by Element of string at specified index)
Given a string s and an integer n representing an index in s, output s with the character at the n-th position removed.
0-indexing and 1-indexing are allowed.
For 0-indexing, n will be non-negative and less than the length of s.
For 1-indexing, n will be posit... | stackexchange_codegolf |
Given a positive integer N, output this doubling pattern of slash squares/rectangles.
For N=1, the base is:
/\
\/
The next square is added in the bottom right direction for N=2:
/\
\/\
\/
After that, a 2x1 rectangle is added in the bottom left direction for N=3:
/\
/\/\
\ \/
\/
Then a 2x2 square is added in the t... | stackexchange_codegolf |
Question: Print out all the coordinates of a NxN grid. Preferably in C, however other languages also accepted
Input: N (integer)
Output: for N=3, a 3x3 grid:
0,0
1,0
2,0
0,1
1,1
2,1
0,2
1,2
2,2
| stackexchange_codegolf |
The Simplest N-Dimensional shape one can create for any dimension is a Simplex, and this is a set of N+1 points that are all equal distance away from eachother.
For 2 dimensions, this is an equilateral triangle, for 3 dimensions, this is an regular tetrahedron, at 4 dimensions is the 5-Cell and so on.
The Challenge
Giv... | stackexchange_codegolf |
Related, both rope, nail and falling, but reversed and some other differences
Consider a loop of rope hanging on n nails on a row. Given a table showing whether the rope would fall down when each possible set of nails were removed, please provide a possible roping way. You may assume such a solution exist.
Here, "fall ... | stackexchange_codegolf |
Challenge and origin
On Stack Overflow a popular question is: How to convert byte size into human readable format in java? The most up voted answer has a quite nice method for doing this, but this is codegolf and we can do better, can't we?
Your challenge is to write a method or program that coverts the given
number... | stackexchange_codegolf |
The incenter of a triangle is the intersection of the triangle's angle bisectors. This is somewhat complicated, but the coordinate formula for incenter is pretty simple (reference). The specifics of the formula do not matter much for this challenge.
The formula requires lengths of sides, so it can be very messy for mos... | stackexchange_codegolf |
The task
Given an ascii string, output a program in my esolang MAWP that outputs the inputted string when run.
Useful functions in MAWP
Numbers from 0-9: Pushes the number to stack
M Takes the top two numbers off stack and pushes the sum to stack
A Takes the top two numbers off stack and... | stackexchange_codegolf |
A prime gap is the difference between two consecutive primes. More specifically, if p and q are primes with p <q and p+1, p+2, ..., _q_−1 are not primes, the primes p and q define a gap of n = q_−_p. The gap is said to be started by p, and to have length n.
It is known that arbitrarily large prime gaps exist. That is, ... | stackexchange_codegolf |
Imagine you are working on a 3D adaptation of the classical video game Asteroids. Your task is to write an algorithm that can create a random 3D asteroid.
This is a popularity contest, not code golf. Write nice code and create interesting results. Add other cool features if you want.
Rules:
Your algorithm must actuall... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.