instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Write the shortest program that prints this ASCII art section of a hexagonal tiling or honeycomb:
__
__/ \__
__/ \__/ \__
/ \__/ \__/ \
\__/ \__/ \__/
/ \__/ \__/ \
\__/ \__/ \__/
/ \__/ \__/ \
\__/ \__/ \__/
\__/ \__/
\__/
No input should be taken.
Output to stdout or your lan... | stackexchange_codegolf |
A certain children's game, often called "Huckle Buckle Beanstalk", is played with two players. Here is a brief description of how the game is played:
One player is designated the "hider", and the other the "seeker".
The seeker goes out of the room while the hider hides a small, pre-selected object, the "treasure".
T... | stackexchange_codegolf |
WARNING: This challenge may need 128 bit floats.1
The task is to perform numerical integration. Consider the following three functions.
\$
f(x) = cx^{c - 1}e^{-x^c}
\$
\$
g_1(x) = 0.5e^{-x}
\$
\$
g_2(x) = 5 e^{-10 x}
\$
We will have that \$c \geq 0.2\$. Your code should be correct for any value between 0.2 and 1.0.
... | stackexchange_codegolf |
Background
Wuxings(五行) are the five "elements" in Chinese philosophy. They are Fire(火), Water(水), Wood(木), Metal(金), and Soil(土). You can find them on East Asian calendar, where some days (Tuesday through Saturday) are named by the Wuxings.
Some Korean names are given according to Wuxings, so that father's name will ha... | stackexchange_codegolf |
Given two positive reals \$a\$ and \$b\$, output some positive reals \$r_i\$, such that \$\sum r_i=a\$ and \$\prod\left(r_i+1\right)=b\$. You can assume that it's possible. You can also assume that your float type have infinite precision.
Test cases:
2,3 => 2
2,4 => 1,1 or 1/2,(sqrt(57)+9)/12,(9-sqrt(57))/12 or etc.
2,... | stackexchange_codegolf |
Gematria is an ancient Jewish method to determine a numeric value of a letter sequence, using a fixed value for each letter. Gematria is originally applied to Hebrew letters, but for the context of this challenge, we'll use Latin script instead. There are many ways to implement Gematria in Latin script, but let's defin... | stackexchange_codegolf |
Introduction
You have been tasked to write a program that splits a rectangular integer array evenly in half (for whatever reason).
This task is computationally intensive, but luckily you have a dual-core machine to perform the calculations.
To maximize the benefits of parallelism, you decide to split the program evenly... | 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 |
Input
4 integers w, x, y, z from the range -999 to 999 inclusive where none of the values is 0.
Output
4 integers a, b, c, d so that aw + bx + cy + dz == 0 where none of the values is 0.
Restrictions
Your output should be the solution with the smallest sum of absolute values possible. That is the smallest value of \$|... | stackexchange_codegolf |
Introduction
This is a follow-up of this challenge where you're taking the role of that person's evil twin. Being evil you don't want to maximize your share, but rather be as unfair as possible and you're not going to make it too obvious, that's why you came up with the following scheme:
You're going to tell the others... | stackexchange_codegolf |
Challenge
The challenge is to implement the bottom encoding (only encoding, not decoding). There is a wide variety of existing implementations in the bottom-software-foundation org.
Bottom is a text encoding where each character is separated into multiple emoji.
Unicode escape(s)
Character
Value
U+1FAC2
200
... | stackexchange_codegolf |
This challenge was posted as part of the April 2018 LotM challenge
Brain-Flak is a turing-tarpit language which has gained quite a lot of fame here on PPCG. The memory of the language is composed by two stacks, but a "hidden" third stack was discovered by Wheat Wizard, leading to some interesting new ways of thinking ... | stackexchange_codegolf |
Task:
With the minimum amount of bytes, determine today's Zodiac sign using the programming language of your choice.
Rules:
This is code golf, the answer with the fewest characters wins. The initialization of getting the current date into a variable (e.g. var now = new Date();) does not add to the count. Leap years mu... | stackexchange_codegolf |
You get a string which contains an integer between 1000 and 99999999 as input. The input string might contain leading zeroes but cannot be longer than 8 characters.
Your goal is to output all dates between 6th of December 1919 and 5th of December 2019 which fit the input in these formats:
day - month - year (dmy)
mont... | stackexchange_codegolf |
Background
A classical logic gate is an idealized electronic device implementing a Boolean function, i.e. one that takes a certain number of Boolean inputs and outputs a Boolean. We only consider two-input logic gates in this challenge.
There are \$2^{2 \times 2} = 16\$ distinct two-input logic gates (2×2 input combina... | stackexchange_codegolf |
Thanks to rak1507 for the suggestion
"Random" in this challenge always refers to "uniformly random" - of all possible choices, each has an equal chance of being chosen. Uniform shuffling means that every possible permutation of the array has an equal chance of being chosen.
Given an array consisting of positive digit... | stackexchange_codegolf |
Every integer can be expressed in powers of 2. You know this as the binary system
Assume you are given a set of k numbers (0 < k < 2^n).
You want to decide for this set whether every integer power of 2 up to 2^(n-1) occurs at least m times
One example:
n = 7 (2^n = 128, )
k = 5
set =
{100,
91,
88,
63,
44}
m = 3
Solut... | stackexchange_codegolf |
Consider this nested array
[[1,2,4],[1,2,3],[2,3]]
In each subarray in which 1 appears, a 2 appears. You might say that 1's presence is dependent on 2's presence.
The converse is not true, as 2 appears in a subarray without 1.
Additionally, 3 is dependent on 2, and 4 is dependent on 1 and 2.
Task
Given a list of lists ... | stackexchange_codegolf |
Codidact post, CGCC Sandbox, Codidact Sandbox
Given three positive integers as input, animate an ascii-art polygonal loading symbol on the screen.
Intro
You will be given three inputs, \$n\$, \$l\$, and \$d\$...
\$n\$ (one of \$3\$, \$4\$, \$6\$, or \$8\$), is the number of sides of a polygon:
... | stackexchange_codegolf |
The point of this challenge is to find the smallest positive integer that uses up at least all of the digits supplied in the input after it is squared and cubed.
So, when provided an input such as 0123456789 (i.e. a number that finds the result):
69² = 4761
69³ = 328509
It means that 69 is the result of such an input.... | stackexchange_codegolf |
The generalised harmonic number of order \$m\$ of \$n\$ is
$$H_{n,m} = \sum_{k=1}^n \frac 1 {k^m}$$
For example, the harmonic numbers are \$H_{n,1}\$, and \$H_{\infty,2} = \frac {\pi^2} 6\$. These are related to the Riemann zeta function as
$$\zeta(m) = \lim_{n \to \infty} H_{n,m}$$
Given two positive integers \$n > 0\... | stackexchange_codegolf |
I am trying to find the shortest code in python 3, to solve this problem:
You are driving a little too fast, and a police officer stops you.
Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthd... | stackexchange_codegolf |
I made this because, although we have a bunch of other questions involving smiley faces, there is nothing for just printing an ASCII smiley face with as little code as possible.
Anyway, print this exactly (Trailing spaces allowed):
**********
******************
**********************
******* ****** ***... | stackexchange_codegolf |
Your challenge: Write a function that takes a string s, a character c, and finds the length of the longest run of c in s. The length of the run will be l.
Rules:
If s is of length 0 or c is empty, l should be 0.
If there are no instances of c in s, l should be 0.
Standard loopholes and Standard I/O Rules apply.
No mat... | stackexchange_codegolf |
Sandbox
Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep.
A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$.
#|##|# | #
#| | #|#
are all valid sheep for \$n=2,k=1.\$
##|###|## | ##
##|###| ## | ## ... | stackexchange_codegolf |
(Inspired by this question)
Objective
Your task is to write a program or function to print an ASCII version of the Stack Overflow logo to STDOUT
\|/
(-)
(-)
(-)
(-)
Your program should take two inputs, referred to here as H and N.
The height of the stack "container" (the parentheses) is determined by H. The number of... | stackexchange_codegolf |
Your task is to create a program which, given an input string, will output the first Google autocomplete result for that search. The format of input/output is up to you.
Rules
Your program must take 1 input, a string, and output the top Google autocomplete/auto-fill suggestions result. The format of input/output is up... | stackexchange_codegolf |
Note: This challenge has been moved to Polyglot the (non constant) OEIS! to avoid closure.
Introduction
We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version? Well, that would be kinda too easy, wouldn't it and how would you select a sequence with our standa... | stackexchange_codegolf |
Each term in the squaring sequence, \$x_n\$, is created by taking \$x_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x_1 = 1111\$. Squaring this yields \$1234321\$, so \$x_2 = 1234\$
The first few terms are:
1111
1234
1522
2316
5363
...
The Challenge
Your task is t... | stackexchange_codegolf |
The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to this video. With the current Gregorian calendar, the rules for leap years are as follows:
if year is divisible by 400, LEAP YEAR
else if year is divisible by 100, COMMON YEAR
else if year is divisible by 4, LEAP YEAR
... | stackexchange_codegolf |
Consider a word/string of length \$n\$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their numeric position in the alphabet (a=1, B=2, c=3, etc.).
Input can be any combination of upper or lower case alphabetic cha... | stackexchange_codegolf |
Related: Counting polystrips
Background
Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules:
Connect two cells with number N with a line spanning N cells, so that the two cells are at the two ends of the line.
The number 1 is considered connected t... | stackexchange_codegolf |
Scrolling through social media, one might encounter something like this:
We can see that, following PEMDAS order of operations, the answer is clearly 11 9.
For the sake of this challenge, PEMDAS means that multiplication will occur before division, so a/b*c = a/(b*c), not (a/b)*c. The same goes for addition and subtr... | 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 |
Introduction
In the United States, national elections are normally held on the first Tuesday after the first Monday in November.
Challenge
Write a program that takes a Year as integer, and a pair of (day of week as character and ordinal as integer) and output the date as "yyyy-mm-dd"
Remember, the second pair is after... | stackexchange_codegolf |
Background
You are working for some board-game manufacturer and need to produce wooden tiles with the numbers from 0 to n engraved on them for some game. However, without further ado, some tiles would become indistinguishable, e.g., 6 and 9. To avoid this, you have to equip numbers that can be confused with others (and... | 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 |
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 |
Given a non-empty array of positive integers, determine if it is possible to take squares with side lengths specified by each integer, and arrange them in space such that they form a square.
The output can have anything as truthy / falsey values, and the input array may contain duplicates.
For the truthy testcase [3,2,... | stackexchange_codegolf |
Consider an array of unique integers, with an arbitrary length greater than 2. It is sometimes possible to express elements of the array as the sum of at least two other elements. For example, if our array is [2, 3, 1], we can express 3 as the sum 2+1. However, we can't express either 2 or 1 as the sum of other element... | stackexchange_codegolf |
I tested the waters on this sort of question with python, but now I get to the real question I want to ask.
restricted-source challenges are uniquely rewarding in Haskell because of Haskell's strict rule set. Type coercion which is the bread and butter for other languages in these sort of challenges is arguably non-ex... | stackexchange_codegolf |
A prime number is a positive integer that has exactly two divisors 1 and the number itself. For example number 7 is a prime since it is divisible by 1 and 7. Number 1 is not a prime since it has only one divisor. Write a program or function that produces all even prime numbers.
This is a code golf challenge, shortest a... | stackexchange_codegolf |
Background
There are self-extracting .ZIP files. Typically they have the extension .EXE (and by executing the file they will be extracted) but when renaming them to .ZIP, you can open the file with some ZIP extracting software.
(This is possible because .EXE files require a certain header but .ZIP files require a certa... | 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 |
Joe lives at the Bahamas. It is winter. His children are disappointed that there is no snow. Joe needs to make snow for his children. Fortunately, he has a 3-d printer. He plans to make snowflakes with it. Unfortunately he has no idea how a snowflake would look like. In fact, he has never seen a snowflake! Let us help ... | stackexchange_codegolf |
Background
In Scrabble, players take turns placing tiles on a grid so that each contiguous set of (more than one) tiles in every row and column makes a word. In one play, tiles can be placed anywhere in a single row or column as long as there is a contiguous set of tiles that includes all of the ones placed.1 A word is... | stackexchange_codegolf |
Consider 30 by 30 Toeplitz matrices all of whose entries are 0 or 1. This challenge is a simple optimization challenge to find the matrix with the largest determinant possible.
Input None
Output A 30 by 30 Toeplitz matrix all of whose entries are 0 or 1 along with its determinant.
Score The determinant of the matrix y... | stackexchange_codegolf |
Challenge
Create a program that outputs a square grid showing visible and non-visible points \$(x, y)\$ from the origin based on their greatest common divisor (GCD).
A point \$(x, y)\$ is considered visible from the origin \$(0, 0)\$ if the \$\gcd(x, y) = 1\$. Otherwise, it's non-visible.
Input
An integer \$n\$, repre... | stackexchange_codegolf |
Background
Flow Free is a series of puzzle games whose objective is to connect all the same-colored pairs of dots on the grid. In this challenge, we consider the original game on a rectangular grid (no variations like bridges, warps, or hexagonal grids).
A puzzle in Flow Free might look like this:
Puzzle Solution
...... | stackexchange_codegolf |
As George Orwell wrote in 1984:
War is peaceFreedom is slaveryIgnorance is strength
Write a program or function that takes in one of the six main words from the Orwell quote and outputs its counterpart.
Specifically:
[input] -> [output]
war -> peace
peace -> war
freedom -> slavery
slavery -> freedom
ignorance -> stre... | stackexchange_codegolf |
In this challenge, you will calculate what your reputation would be, if the reputation cap didn't exist on PPCG.
Everyone can access the rawdata for reputation changes on the adress: codegolf.stackexchange.com/reputation.
The raw data follows a setup like this (these are the first few lines of my version of the page.
t... | stackexchange_codegolf |
Challenge
Given a quark composition of a particle as input, output the corresponding hadron's name.
Quarks will be represented by a capital letter and antiquarks by a lowercase letter.
The quarks may be in any order, not necessarily the order given below.
Built-in functions the access data about particles and/or quarks... | stackexchange_codegolf |
If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:
#include <stdio.h>
#include <stdlib.h>
#define class struct
#define function
class Point {
#define public int
public $x;
public $y;
};
int
function main()
{
struct Point*
$p = ... | stackexchange_codegolf |
Challenge Statement
The goal of this challenge is to build the 5 state Infinite Time Turing Machine that takes the longest to halt. Since Infinite Time Turing Machines can run for infinite time your score will be a "transfinite ordinal".
That's the challenge statement, but if you don't what all this means or want to d... | stackexchange_codegolf |
Introduction:
Since it's almost Halloween, I was just thinking of some random Halloween-themed challenges. Eventually I was reading through Frankenstein's wikipedia page, and came across the following text:
The creature
Part of Frankenstein's rejection of his creation is the fact that he does not give it a name, which... | stackexchange_codegolf |
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... | stackexchange_codegolf |
There was a prior question about golfing an HQ9+ compiler that translates HQ9+ code into the language it is written in, but that was closed as a duplicate of the interpreter challenge because converting an interpreter to a compiler is seen as trivial. This question is based on the closed one, but has some changes.
Writ... | stackexchange_codegolf |
Reversible computation refers to computation in which little or no information is deleted. Reversible computation a major component of quantum computation, and reversible computation is potentially many times more energy efficient than conventional computation. I want to know how easy it is to compute the conjugacy of ... | stackexchange_codegolf |
Okay, I propose a shortest-key-logger challenge. As explained by the gentleman at "Are key-logger questions allowed?", strict rules have to be imposed in order to make this challenge valid for PPCG.
The key-logger has to run on Windows, Linux or Mac OSX (any programming language is welcome).
Upon execution, it has to ... | stackexchange_codegolf |
There is fairly strong support on meta for challenge-writing questions to be on topic on main, provided these questions are specific and answerable. However, we don't have any such questions yet, so I figured I'd test the waters. This question is probably entering good subjective, bad subjective territory, but I think... | stackexchange_codegolf |
Introduction
Some time ago, I need to write function which split string in some specific way. At the first look, task looks trivial, but it was not so easy - especially when I want to decrease code size.
Challenge
As example we have following input string (it can be arbitrary)
Lorem ipsum dolor sit amet consectetur ad... | stackexchange_codegolf |
(yes, that title was intentional)
Your task is to correct common grammatical mistakes.
You must:
Capitalise the first letter of each sentence, ie the first non-whitespace letter after any of .!? and, additionally, capitalise the first letter of the input
Remove repeating punctuation, such as !!! -> !. Ellipses (...) a... | stackexchange_codegolf |
Write some code...
Write a program that takes no input and outputs an integer n which is a multiple of 3. So n=3k, where k is a positive integer.
Double the last character of your code.
Your code should then output k.
Examples
Here is my program hui#2(21+4)//lm, which outputs 81.
Because of that, hui#2(21+4)//lmm shoul... | stackexchange_codegolf |
Given a range and a list thereof, while keeping the existing intervals in the list unchanged, split the additional range into sub-intervals and add them to the list, such that all the ranges in the final list are disjoint and contain all numbers present in the input ranges.
The goal is to create an insertInterval(inte... | stackexchange_codegolf |
Knowing a given date (11/28/1973), and supposing I will die when I'm 99, what are the years when my birthday will be a thursday so that I will be able to party all week-end?
| stackexchange_codegolf |
Write a program to calculate the first 500 digits of the mathematical constant e, meeting the rules below:
It cannot include "e", "math.e" or similar e constants, nor may it call a library function to calculate e.
It must execute in a reasonable time (under 1 minute) on a modern computer.
The digits are to include the... | stackexchange_codegolf |
A Sumac sequence starts with two integers: t1 and t2.
The next term, t3, = t1 - t2
More generally, tn = tn-2 - tn-1
The sequence ends when tn < 0.
Your challenge: Write a program or function that prints the length of a Sumac sequence, starting with t1 and t2.
t1 and t2 are integers within your language's range.
Standa... | stackexchange_codegolf |
I found it quite hard to achieve a range of numbers as rows in MySQL.
For example the range 1-5 is achieved by:
SELECT 1
UNION
SELECT 2
UNION
SELECT 3
UNION
SELECT 4
UNION
SELECT 5
will result in:
1
2
3
4
5
for 0-99 I can cross join two 0-9 tables:
CREATE TABLE nums as
SELECT 0 as num
UNION
SELECT 1
UNION
SELECT ... | stackexchange_codegolf |
History
There's a room on StackOverflow in Russian where you can see such an interesting discussion:
Just because there are not enough real discussing in that room, @Grundy "plays ping-pong" to keep it unfrozen.
Task
Implement a bot for StackExchange that posts "ping!" to the 115624 room if the previous message was ... | stackexchange_codegolf |
(related)
A Pythagorean Triple is a list (a, b, c) that satisfies the equation a2 + b2 = c2.
A Primitive Pythagorean Triple (PPT) is one where a, b, and c are all coprime (i.e., the only common divisor between the three elements is 1). For example, the (3, 4, 5) right triangle is a famous Primitive Pythagorean Triple.
... | stackexchange_codegolf |
Your goal is to write a program or function that takes in as input a string representing the path to a file, and outputs a truthy value if that file is not empty and contains no non-null bytes -- i.e., all bits are 0 -- and a falsey value otherwise.
I realize it is a very simple problem and I guess I could hack
somethi... | stackexchange_codegolf |
The goal is to write a program that returns number of 1 bits in a given number.
Examples
5 -> 2
1254 -> 6
56465 -> 8
Winner
The winning submission is the code which runs in the minimum time. You can assume that normal int value in your language can handle any number (no matter how large) and computes all th... | stackexchange_codegolf |
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf... | stackexchange_codegolf |
Related: Deck Names Friends or Foes Paying for Spells
The Magic: the Gathering card game has five colours of magical mana: white (W), blue (U), black (B), red (R), and green (G). Cards can be any of the \$2^5=32\$ subsets of these colours. Hereafter 'colours' refer just to the initials W, U, B, R, G.
The order that the... | stackexchange_codegolf |
Write a function (not a full program), so that if the function is called with a single global variable (or your language's closest equivalent) as its argument, it outputs (i.e. prints or returns) the name of that variable. If the argument is not a variable, output a falsey value instead. (You don't have to handle the c... | stackexchange_codegolf |
Challenge
We all know about normal Christmas trees - but how about an upside-down Christmas tree! This is a fairly easy, Christmas themed challenge. The objective of this challenge is to make me an ASCII upside-down Christmas tree. Here are the rules for this challenge:
Accept an odd, positive integer. You can assume ... | stackexchange_codegolf |
For this challenge, a slice of a string is defined as an upper and lower index that can "cut" a piece of a string. All characters from the string in the range [start, end) (or [start, end] if you don't speak practlang) are part of that slice. If the upper index exceeds the string's length, the overflow is ignored. For ... | stackexchange_codegolf |
Print the following text and nothing else:
<html>
<body>
<p>HTML is kinda annoying</p>
</body>
</html>
I'm happy I'm not a web developer.
The catch? Your code must fit the template: print(<?>), where ? can be any group of characters. You can paste your completed code (with the print(<>) part) into this Scast... | stackexchange_codegolf |
Challenge
Origami (folding paper) is a creative form of art. As far as I know, master of Origami prefers square paper. Let's start from beginning - convert a rectangular paper to a square one.
So the paper is divided into squares. We remove the biggest square which shares one shorter edge with the current shape, step b... | stackexchange_codegolf |
An old test for programmers, taken from here (Note: in italian).
Along a road (denoted by '_'), there is a Magical Piper (denoted by 'P') and several mice (represented by the two characters 'o' and '~', that denote respectively the head and the tail of the small rodents).
Write a program that prints how many mice are g... | stackexchange_codegolf |
Input
A calendar year from 927 to 2022.
Output
You can use any three distinguishable outputs. As an example,
“K” (short for King)
or
“Q” (short for Queen)
depending on which of the two England had in that year. If there was both a King and Queen in that year you can output either.
If there was no King or Queen for th... | stackexchange_codegolf |
The task here is to write a program that takes an natural number, \$n\$, and produces the \$n\$th term of an OEIS sequence. That sequence should have an identifier in the form of A followed by 6 digits. Now when you take your source code and reverse the order of it's bytes to produce a new program, that program shoul... | stackexchange_codegolf |
This is a good beginner challenge and a good time killer.
I only said a -natural- log because the title was too short, this has nothing to do with logarithms.
Given 2 variables:
The number of ants n.
The width of the log w.
Output a log of width w with n ants (Example shown w=3, n=6)
| |
| \O/ \O/ \O/ |
... | stackexchange_codegolf |
You know it: keyboard or mouse input is just too mainstream to create Random Numbers through human behavior.
Create the most unique (Pseudo)Random Number Generator that create its numbers through human behavior.
Web-API's are not restricted! Anyone should use the code provided, so any special hardware is restricted. (I... | stackexchange_codegolf |
Last week, we worked to create the shortest 1-D string using the top 10,000 words in the English language. Now, lets try the same challenge in 2D!
What you need to do is to take all of the above words, and put them in a rectangle as small as possible, allowing for overlaps. For example, if your words were ["ape","pen... | stackexchange_codegolf |
A half cardinal cyclic quine is a cyclic quine with two states, one perpendicular to the other.
Rules
You can decide which rotation you want to implement, clockwise or counter-clockwise.
Once rotated, any gaps in your code should be replaced with spaces to preserve the positioning.
Your program must satisfy the communi... | stackexchange_codegolf |
The challenge
Write a function that returns the nth element of an array even if its out of bound.
function safeGet(index, arr) {
const safeIndex = ???
return arr[safeIndex]
}
const arr = ["a", "b", "c"];
safeGet(0, arr) // "a"
safeGet(1, arr) // "b"
safeGet(2, arr) // "c"
safeGet(3, arr) // "a" go back to the be... | stackexchange_codegolf |
Display the emoji of the eastern zodiac of given time, according to given country.
The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a repeating 12-year cycle. It is also assigned to hours.
Rules:
The country must be given as ISO 3166-1 alpha-3 code. The li... | stackexchange_codegolf |
The TAK function is defined as follows for integers \$x\$, \$y\$, \$z\$:
$$
t(x, y, z) = \begin{cases}
y, & \text{if $x \le y$} \\
t(t(x-1,y,z), t(y-1,z,x), t(z-1,x,y)), & \text{otherwise}
\end{cases}
$$
It can be proved that it always terminates and evaluates to the simple function below:
$$
t(x, y, z) = \begin{cases}... | stackexchange_codegolf |
Consider a form of binary where digits can be any of \$1\$, \$0\$ and \$-1\$. We'll still call this "binary" because we convert the digits from base two. For example,
$$\begin{align}
[1, 0, -1, 1]_2 & = 1 \times 2^3 + 0 \times 2^2 + -1 \times 2^1 + 1 \times 2^0 \\
& = 8 - 2 + 1 \\
& = 7
\end{align}$$
We'll call a repre... | stackexchange_codegolf |
Introduction
In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other catalogue challenges, there is "Hello World!" and "Is this number a prime?".
Challenge
Write a program that prints the decimal ... | stackexchange_codegolf |
Your task is to write a program or function that takes as input a list of positive integers and determines if there are any two integers in the list, that both appear the same number of times.
For example the list
[1, 2, 3, 2]
Has one 1 and one 3 so it satisfies the condition.
But the list
[3, 2, 2, 1, 2, 3]
does not... | stackexchange_codegolf |
What is elementary cellular automata?
Since I'm not sure I'll be able to explain this so that somebody who has never heard of this is able to understand, I'm giving an explanation from https://mathworld.wolfram.com/ElementaryCellularAutomaton.html
Elementary cellular automata have two possible values for each cell (0 ... | stackexchange_codegolf |
Scala isn't a very commonly used language around here. Most of those who know it like it[citation needed], but some go :\ when they encounter its user-defined operators, saying they're too complicated.
However, they're governed by a very simple set of rules, outlined here. Their precedence depends on the first characte... | stackexchange_codegolf |
Your Task:
Write a program or function that, when given a number, outputs its persistence. The persistence of a number is the number of times you can add its digits before arriving at a one-digit number. All one digit numbers have a persistence of 0. Note that this is different from questions about finding the digit... | stackexchange_codegolf |
Input
A binary string \$s\$ of length \$n\$ and a positive integer \$k \leq n\$.
Output
The number of binary strings with Levenshtein distance exactly \$k\$ from the string \$s\$.
Example outputs
Each example gives the largest possible output for the given \$(n, k)\$ pair.
k=1, s=1010, output=14
k=2, s=1010, outupt=55... | stackexchange_codegolf |
The goal of this challenge is to determine if a move is a legal English Checkers move.
This challenge will use an 8x8 board. A moved piece should be treated as a man (not a king) that can only move diagonally forward. The board will have 0 or more black pieces and 1 or more white piece. One white piece will be current... | stackexchange_codegolf |
What is Crazyhouse Chess?
Crazyhouse Chess is a chess variant that is basically normal chess except you can place a piece you previously captured back on the board instead of a regular turn.
Bot interface
Only JavaScript bots are allowed.
A bot is a JavaScript function that takes 3 arguments (board, side, bank) and ret... | stackexchange_codegolf |
Graph theory is used to study the relations between objects. A graph is composed of vertices and edges in a diagram such as this:
A-----B
| / \
| / \
| / E
| / /
|/ /
C-----D
In the above diagram, A is linked to B and C; B is linked to A, C, and E; C is linked to A, B, and D; D is linked to C and... | stackexchange_codegolf |
Given an input string, output at random the unique combinations with repetition of the characters in the input string, from length 1 up to the length of the input string, with an equal chance of each one occurring.
Example: given the input abcd (or any combination thereof of the four characters a,b,c,d) , there is an e... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.