instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Per the fundamental theorem of arithmetic, for a given number \$n\$, it is possible to find it's prime factors, and they are unique. Let's imagine we talk only of \$n\$ that is non-prime (composite).
We can also find the factors of all the composite numbers smaller than \$n\$. For example if \$n\$ is 10, then it has f... | stackexchange_codegolf |
What general tips do you have for golfing in BQN? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to BQN (e.g. "remove comments" is not an answer).
Please post one tip per answer.
At the moment of writing, the official BQN site is the most comprehensive res... | stackexchange_codegolf |
Task
Write a program/function that when given 3 positive integers \$a, b\$ and \$m\$ as input outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or that no such \$x\$ exists.
A reference implementation can be found here.
Constraints
You can expect \$a\$ and \$b\$ to be less than \$m\$.
Scoring
... | stackexchange_codegolf |
Your Goal: Estimate pi to at least 10 decimal places. The format is your choice - it can output as a number, as a string, as an output to STDOUT, etc.
Seems easy, right? But wait, it's not as simple as it seems...
The Rules: You get exactly 10 function calls (this includes operators). These functions cannot be ones tha... | stackexchange_codegolf |
There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The input is given as a string. For example:
Using the character #, follow the following rules:
If there are 2 or 3 neighboring ... | stackexchange_codegolf |
This is code-golf.
In this challenge, we will be writing programs/functions that solve "Knights and Knaves" puzzles.
Background
You find yourself on an island ... etc. ... every person on the island except for you is either a knight or a knave.
Knights can only make true statements.
Knaves can only make false statemen... | stackexchange_codegolf |
Euler's totient function, \$\varphi(n)\$, counts the number of integers \$1 \le k \le n\$ such that \$\gcd(k, n) = 1\$. For example, \$\varphi(9) = 6\$ as \$1,2,4,5,7,8\$ are all coprime to \$9\$. However, \$\varphi(n)\$ is not injective, meaning that there are distinct integers \$m, n\$ such that \$\varphi(m) = \varph... | stackexchange_codegolf |
Code golf: Print an image of the source code.
Requirements
Must output the image of the source code itself, not a version stored elsewhere and retrieved at run time.
Code must be legible enough to copy out by hand and reproduce the results.
Any image format is applicable.
Bonuses
-10% of your score if you allow mor... | stackexchange_codegolf |
Consider a zero-sum game with 2 contestants. Each round, each contestant chooses, independently of each other, one of \$n \ge 2\$ different choices. Depending on the two chosen choices, one player is awarded an amount from the other player's pot. For example, the following table shows the gains (positive integers) and ... | stackexchange_codegolf |
Your task
Randomly pick and print "Joe Mama" or "Joe Biden" in as little bytes as possible.
Rules
No trailing lines, spaces, or anything else weird like that
No election fraud! Both "Joe Mama" and "Joe Biden" must have equal chaces of winning
Prize
The winner will get a spot in https://github.com/Sid220/joe-mama-or-j... | stackexchange_codegolf |
The Background
Imagine the English alphabet written out in a row in capital letters -- ABCDEFGHIJKLMNOPQRSTUVWXYZ. Suppose we have a special variable-width lens such that, when placed over the row, it shows a certain "window" of the alphabet, with letters outside the lens hidden from view. Additionally, this lens has a... | stackexchange_codegolf |
Description
You have a list of integers and start counting from the first term to the next and continue from that to the next and so on..
How many times have you counted?
For example given [ 2, 5, 3, 8 ]
you start at 2 and count to 5 -> 3 4 5 (3 times)
then from 5.. 4 3 (2 times)
and finally 4 5 6 7 8 (5 times)
You co... | stackexchange_codegolf |
This seems almost trivial, but since after some effort I was not able to beat the literal solution in J, I thought it might make a decent challenge (though, to be clear, this is not a J-specific challenge).
Title says it all. You simply need to write a program, or function (taking no arguments) that returns or prints:... | stackexchange_codegolf |
Task
Your task is to write a program that, taking no input, outputs a string that represents a formatted codegolf answer of itself. The pattern is the following:
[Language name][1], n bytes
=
```
source code
```
[1]: link-to-language
With the language name being the language that you wrote your program (as stated in... | stackexchange_codegolf |
Recently a friend of mine posed the following:
What subset of the integers satisfies the condition if distinct a and b are in the subset, their average is not in the subset? I know the set of non-0 squares satisfies the condition, but I wonder if there exists a more... dense set that satisfies the condition.
(It turn... | stackexchange_codegolf |
One of your acquaintances has a hobby of making make-shift electrical gadgets using various types of batteries. However, since they're thrifty, they want to use as few batteries as possible for their projects. This challenge uses several types of batteries; your job is to output the fewest number of batteries that will... | stackexchange_codegolf |
A Munchausen Number in base \$b\$, also known as a Perfect digit-to-digit invariant or PDDI is a peculiar type of positive integer where the sum of its base-\$b\$ digits raised to themselves is equal to the number itself. They are named for the fictional Baron Munchausen, who apparently hoisted himself up via his own p... | stackexchange_codegolf |
(Meaning: Convert English to Bleet)
We have praised goats as god for years now.
But if we can't translate English to 'Bleet', the Goat God's language, we cannot communicate with them.
So, to communicate with them, we have researched the activities of goats, and retrieved this pattern, which is the core of the language.... | stackexchange_codegolf |
Description
Here's a very superstitious hotel elevator in Shanghai:
It avoids the number 13, because thirteen is unlucky in the Western world, and it avoids the digit 4, because four is unlucky in parts of Asia. What if this hotel was taller?
Read a positive even integer n from STDIN, representing the n... | stackexchange_codegolf |
If you want to build a fence and have different length boards available, there are many different ways to set up your posts. So, given a minimum and maximum board length, a number of boards, and the total length, count how many ways you can arrange them.
Input
Input is four positive integers:
min: The smallest board u... | stackexchange_codegolf |
From here. Every new game is the first day of the month, 12:00 PM UTC.
The goal is to create the Stack Overflow logo using ASCII characters.
It looks like this.
The exact output should look like this:
\\
\\
\= \\
\= \\
\= \\
\== \\
¯¯¯ \==
¯¯¯... | stackexchange_codegolf |
In one of our projects at work, we recently discovered a particularly large method for generating a 6 character string from a 15 character alphabet. A few of us claimed "I bet we can get that in one line" which started a little internal game of code golf.
Your task is to beat us, which I have no doubt won't take long!
... | stackexchange_codegolf |
There are a lot of challenges on this site regarding pi, but none that challenge you to calculate as many digits of pi as possible.
As you all may know, pi in its decimal form goes on for infinity, so calculating it in its entirety is near to impossible. However, I challenge you to write a program in your language of c... | 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 |
It is common to need to make a page selection interface. It typically looks like this:
prev 1 ... 3 4 [5] 6 7 ... 173 next
Which means there are totally 173 pages, and you are on the 5th page currently.
This challenge requires you take the total number of pages and the current page number as input, and output a string... | stackexchange_codegolf |
Context
Consider square matrices with n columns and rows containing the first n^2 (i.e. n squared) positive integers, where n is odd. The elements of the matrices are arranged such that the integers 1 through n^2 are placed sequentially in a counterclockwise spiral starting at the center and initially moving to the lef... | stackexchange_codegolf |
Sometimes, when I'm idly trying to factor whatever number pops up in front of me¹, after a while I realize it's easier than I thought. Take 2156 for example: it eventually occurs to me that both 21 and 56 are multiples of 7, and so certainly 2156 = 21 x 100 + 56 is also a multiple of 7.
Your task is to write some code ... | stackexchange_codegolf |
Given an input of a list of slices of a string, output the original string.
Each slice will be given as a list of length 2, containing the start position
of the slice (an integer ≥0) and the slice itself. If your language does not
support arrays of arbitrary types, you may also take this as a struct or
similar, or simp... | stackexchange_codegolf |
Introduction
Our goal is to efficiently find the maximum of a large amount of (redundant) data.
We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product)
$$
A\otimes B := A\cdot B^T = \left(\begin{array}{rrr}
A(1)\cdo... | stackexchange_codegolf |
Your Challenge is to take a binary string as input and get all binary numbers between itself and the reverse of its string representation (the reverse may be less than or greater than the original input).
Output must be padded with zeroes to be the same length as the input.
The Order in which the values are displayed d... | stackexchange_codegolf |
Output the area \$A\$ of a triangle given its side lengths \$a, b, c\$ as inputs. This can be computed using Heron's formula:
$$ A=\sqrt{s(s-a)(s-b)(s-c)}\textrm{, where } s=\frac{a+b+c}{2}.$$
This can be written in various ways, such as
$$ A= \frac{1}{4}\sqrt{(a+b+c)(-a+b+c)(a-b+c)(a+b-c)}$$
$$ A= \frac{1}{4}\sqrt{(a^... | stackexchange_codegolf |
September 1993 is known on Usenet as the September that never ended. Thus, for example, the day this question is being posted is Saturday, September 8740, 1993.
Your program or function should take any Gregorian date (with positive year) as input and return the same date as output if it's prior to September 1993 or the... | stackexchange_codegolf |
Given a positive square number as input. Output the number of values between the input and next highest square.
Example
Input: 1
Output: 2
Reason: The numbers 2 and 3 are between 1 and 4, the next highest square
Input: 4
Output: 4
Reason: The numbers 5, 6, 7, 8 are between 4 and 9
| stackexchange_codegolf |
Yesterday while playing with my kid I noticed the number in his toy train:
So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$
So simple challenge: given a non-negative number as input, return consistent truthy and falsey values that represent whether or not the string representation of the n... | stackexchange_codegolf |
This question will be deleted soon, do not read/answer it
Introduction
Given one matrix A x A and a number of movements N.
You will need to walk like a spiral starting in (1; 1):
right while possible, then
down while possible, then
left while possible, then
up while possible, repeat until got N.
Challenge
You can on... | stackexchange_codegolf |
Given a non-empty list of decimal digits (0, 1, ..., 9), replace each zero by the most recent nonzero, if possible.
Example 1: given
1 4 3 0 0 7 5 5 0 3
the output should be
1 4 3 3 3 7 5 5 5 3
Note how the first two zeros are replaced by 3, which is the most recent (i.e. rightmost) nonzero. Similarly, the last zer... | stackexchange_codegolf |
This is the cops' post. The robbers' is here.
You make a program and a regex.
For most inputs, one of the following happens:
the regex doesn't match, and the program returns a falsey value
the regex doesn't match, and the program returns a truthy value
the regex matches, and the program returns a truthy value
But for... | stackexchange_codegolf |
This question is about moving stacks around in the card game FreeCell, but here it will be presented more abstractly.
Given three integers \$0\le n,m<10000,0<k<10000\$.
There are \$m+2\$ columns, \$m\$ of them empty and two of them contain cards (from bottom to top) \$[0,-2,k]\$ and \$[0,-3,k-1,k-2,\cdots,1,0]\$. Besid... | stackexchange_codegolf |
Background
Sudoku is a number puzzle where, given an \$ n \times n \$ grid divided into boxes of size \$ n \$, each number of \$ 1 \$ to \$ n \$ should appear exactly once in each row, column and box.
In the game of Chess, the King can move to any of (at most) 8 adjacent cells in a turn. "Adjacent" here means horizonta... | stackexchange_codegolf |
Given a word, treat every letter as its number in English alphabet (so a becomes 1, b becomes 2, z becomes 26 and so on), and check if all of them, including duplicates, are pairwise coprime.
The input is exactly one word of lowercase English letters. The output is the fact if the word is coprime: any truthy/falsey val... | stackexchange_codegolf |
Dialogue by a 3Der.
I was hired by Sr. 4Der to learn the 4D universe and I was willing to get to know more about it. But since I am a 3Der, I wouldn't see him, nor would I know how the real shapes look like. All I can do is illustrate.
Sr. 4Der is pretty much invisible to us. We can't see him, but we can hear his voi... | stackexchange_codegolf |
Related
You are a manager at a large number factory. You want to show everyone your business is doing well, by showing randomly chosen samples. Unfortunately, your business is not doing that well. But luckily, you have a bit of ingenuity...
Write a program or function that when given an array of unique, positive numbe... | stackexchange_codegolf |
!!!Batch is another derivative of the Windows Batch programming language, its wiki is here
Your challenge is to create an compiler/translator that reads a !!!Batch program and returns a Windows Batch program.
In !!!Batch each token braced in two question marks like ?!!!? is converted to another ASCII character, like '?... | stackexchange_codegolf |
Input
A bound m <= 4294967295.
Output
Consider values sampled uniformly at random from integers in the range 0 to m, inclusive.
Your output should be the expected (average) number of trailing zeros in the binary representation of the sampled value. Your answer should be exact, for example given as a fraction.
Example
... | stackexchange_codegolf |
I came across an interesting tiling of the plane using squashed hexagons in a popular math book. All the six edges of the squashed hexagon are the same length. Two opposite corners are right angles and the rest four corners are 135 degrees each. This shape allows four squashed hexagons be arranged so that they meet at ... | stackexchange_codegolf |
The first magic card trick I ever learned as a child was the following:
Have 1 deck of cards where the pattern on the back is not vertically symmetric.
Organize all cards to be facing one direction.
Ask an individual to, "pick a card, any card, memorize it and give it back to you".
Proceed to put it into the deck (in ... | stackexchange_codegolf |
For more information, watch this video, and go to A276523 for a related sequence.
The Mondrian Puzzle (for an integer n) is the following:
Fit non-congruent rectangles into a n*n square grid. What is the smallest difference possible between the largest and the smallest rectangle?
For 6, the optimal difference for M(6) ... | stackexchange_codegolf |
Challenge
In this challenge, you have to fill an \$M\$ x \$N\$ rectangle grid with the most \$A\$ x \$B\$ rectangle pieces possible.
Requirements:
The sizes of the \$M\$ x \$N\$ rectangle grid is always bigger than the sizes of the \$A\$ x \$B\$ rectangle pieces. In other words, \$min(M, N) ≥ max(A, B)\$
You can freel... | stackexchange_codegolf |
Background
We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=".
Criteria:
The type of chain must change following an equals sign.
You must link the chains, you can do so multiple times, and it does not matter what lengt... | stackexchange_codegolf |
Results (May 22 2017 21:40:37 UTC)
Master won 18 rounds, lost 2 rounds, and tied 0 rounds
Save One won 15 rounds, lost 3 rounds, and tied 2 rounds
Machine Gun won 14 rounds, lost 3 rounds, and tied 3 rounds
Monte Bot won 14 rounds, lost 3 rounds, and tied 3 rounds
Amb Bot won 12 rounds, lost 8 rounds, and tied 0 rounds... | stackexchange_codegolf |
Given a sequence of integers or to be more specific a permutation of 0..N
transform this sequence as following:
output[x] = reverse(input[input[x]])
repeat
For example: [2,1,0] becomes [0,1,2] and reversed is [2,1,0]. [0,2,1] becomes [0,1,2] and reversed [2,1,0].
Example 1
In: 0 1 2
S#1: 2 1 0
S#2: 2 1 0
Output:... | stackexchange_codegolf |
Task
The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (the code is appended/concatenated \$N-1\$ to itself), the program should have a \$\dfrac{1}{N}\$ probability of outputting... | stackexchange_codegolf |
You know—they look like this:
source
The goal is to draw a music beats illustration like the following:
= = =
= = = = =
== = == = == = ====
== ==== == === = = =======
======== == ==== = ========= =
=================================
The rules are:
The width of the illustration is 3... | stackexchange_codegolf |
Because we haven't had enough of these, let's do another weird language!
+ increments the accumulator
- decrements the accumulator
# outputs the character with the codepoint of the accumulator modulo 127, and then resets the accumulator
$ is like # but it doesn't reset the accumulator
% reads a single character of inp... | stackexchange_codegolf |
Given a digit x (between 0 to 9, inclusive) and a number n, calculate the sum of the first n terms of the following sequence:
\$x,10x+x,100x+10x+x,\dots\$
For example, if x is 6 and n is 2, then the result will be 6+66 meaning 72.
There can be trailing whitespace in the output but not leading whitespace.
| stackexchange_codegolf |
Challenge
A simple challenge: given two or more strings, output all of the substrings that are in each string.
Rules
Input is always a comma separated list of strings
Strings should be outputted from longest to shortest length without duplicates
Strings should preserve whitespace
Examples
Input: aaa,aa
Output:
aa
a
... | stackexchange_codegolf |
Given the input tilesX and tilesY create a method that would make a rectangular ring from the tiles.
The function must order the tiles in a ring like this:
tilesX and tilesY are always positive integer values, cannot be 0
tilesX and tilesY are not always equal, expect values like: 2x5, 6x3 etc.
Checking for invalid i... | stackexchange_codegolf |
Inspired by There, I fixed it (with rope), There, I fixed it (with Tape), There, I broke it (with scissors)
Given a string with characters from a-z or A-Z (whichever you prefer), turn missing letters into numbers and make them explode.
Example
Input: abcafabc
Output: a12344321c
Why?
1) Find the missing letters (only g... | stackexchange_codegolf |
Overview
As most of y'all who visit chat know, I am Russian by ethnicity[citation not needed]. Recently, I switched from a keyboard that maps the letters 1-to-1 (mnemonic) to Windows' default mnemonic keyboard. Here are the letter mappings:
"`" -> "ъ"
"q" -> "я"
"w" -> "ш"
"e" -> "е"
"r" -> "р"
"t" -> "т"
"u" -> "у"
"i... | stackexchange_codegolf |
Dungeon Master was one of the first ever real-time role-playing games, originally released in 1987 on the Atari ST. Among other exciting things for the time, it offered a rather sophisticated spell system based on runes.
Your task today is to write a program or function that evaluates the number of Mana points required... | stackexchange_codegolf |
Whenever I search for the running length of a movie in IMDb, it is displayed in minutes. Immediately I would try to convert it into hour(s) and minute(s). It would be better if we could automate this.
Input:
150 min
Output:
2 hours 30 minutes
Input:
90 min
Output:
1 hour 30 minutes
Input:
61 min
Output:
1 hour 1 m... | stackexchange_codegolf |
Write a program or function that takes in a string and outputs a count of each modern English alphabet letter in the string, case-insensitive.
Input: A string consisting of printable ASCII characters (code points 32-126).
Output: A list of pairs, where each pair consists of a letter and its count in the string. The lis... | stackexchange_codegolf |
Make a quine but with a twist.
Statement
The quine prints its code but puts its first character at the end.
(You can do it in reverse but include that note in your answer)
The output must then be a program which is also an solution.
Example: Assume your code was foobar, running it will return oobarf which will be anoth... | stackexchange_codegolf |
Task
Your task is to write as short as possible program preferably in Brainf**k which determines the last digit of given number after it's conversion from decimal to binary system.
Input
An integer in decimal system consisting of up to 200 digits. There is a newline character (ASCII 10) after the given number
Output
On... | stackexchange_codegolf |
Given an integer array of at least two elements, output the Matrix-Vector (defined below) of the array.
To compute the Matrix-Vector, first rotate through the size-n input array to create a matrix of size n x n, with the first element of the array following the main diagonal. This forms the matrix portion. For the vect... | stackexchange_codegolf |
Introduction
Just on Hacker news, John Resig contemplates
transforming a query “foo=1&foo=2&foo=3&blah=a&blah=b” into one that looks like this: “foo=1,2,3&blah=a,b", https://johnresig.com/blog/search-and-dont-replace/.
He claims "being 10 lines shorter than Mark’s solution".
Query strings consist of sequences of name-v... | stackexchange_codegolf |
While similar to the other water-carrying puzzle, the unique aspects of this challenge make it entirely different.
Beth is located at an oasis in the middle of a desert. There is plenty of water in the lake, but unfortunately there are only X buckets, each of which has a capacity of Y liters of water.
Beth can carry 2... | stackexchange_codegolf |
Degree of Unsaturation
This is not a particularly hard code puzzle - but I'm interested to see your multiple ways of solving it.
The Degree of Unsaturation is the number of double chemical bonds between atoms, and/or the number rings in a chemical compound.
You will be given the molecular formula of a chemical compoun... | stackexchange_codegolf |
Let's suppose there is a finite unknown number n (n can be very large, does not necessarily fit 64-bits; think of BigInteger in Java or long in Python) and a function cmp(x) that returns true if x <= n.
Write a program to determine n in minimum number of calls to cmp.
| stackexchange_codegolf |
Introduction
You have to simulate playing golf over an input string that represents the green. The 2-character substring () represents the hole, and is guaranteed to appear only once in the string.
This is a sample green:
ABCDEFGHIJKLM()NOPQRSTUVWXYZ
The simulation consists of outputting the characters that the ball f... | stackexchange_codegolf |
A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n:
n divisors d(n)
1 1 1
2 1, 2 2
3 1, 3 2
4 1, 2, 4 3
5 1, 5 2
6 1, 2, 3, 6 ... | stackexchange_codegolf |
Challenge
Write a program or function that takes in 4 non-negative integers, A, B, C, and D, that represent two fractions, A/B and C/D, where B and D are non-zero and A <= B and C <= D.
Output an ASCII art depiction of the fractions made of |x- characters on two lines as follows:
The lines will always be the same, min... | stackexchange_codegolf |
The Rockstar programming language has "poetic number literals", allowing you to assign nonnegative, finite (at least one Rockstar interpreter supports infinity) numbers to variables without typing a single digit: just type words with length equal to each digit, modulo 10. For example,
This is a challenge
sets the vari... | stackexchange_codegolf |
Room Number Locator
I have come across an interesting problem solving technique at my job when given the wrong room number from a colleague for a meeting. Every now and then, while on the way to a meeting, a member on my team will send me the wrong room number, typically because they are in a rush at their desk and fat... | stackexchange_codegolf |
I have this function to generate UUID's:
function uuid($v=4,$d=null,$s=false)//$v-> version|$data-> data for version 3 and 5|$s-> add salt and pepper
{
switch($v.($x=''))
{
case 3:
$x=md5($d.($s?md5(microtime(true).uniqid($d,true)):''));break;
case 4:default:
$v=4;for($i=... | stackexchange_codegolf |
When writing a programm 1 missing character can ruin everything,
wouldn't it be great if the programm told you what was missing ?
Task:
Create any (non Empty) programm, that takes no input and outputs nothing.
That when 1 Character is removed from the programm, outputs that Character.
Input: None
Output:
Output nothing... | stackexchange_codegolf |
You sit at home, rubbing your hands in a most evil fashion. This time, I'll be able to set the community A-SPIN! I'll merely claim that I have proven this problem (which is of no doubt improvable) inside this book here… You open to the first relevant page. You scrawl those words…
You are, of course, the evil Fermat! Ha... | stackexchange_codegolf |
It is trivially possible to create a bijective function from \$\mathbb{Z}\$ (the set of all integers) to \$\mathbb{Z}\$ (e.g. the identity function).
It is also possible to create a bijective function from \$\mathbb{Z}\$ to \$\mathbb{Z}^2\$ (the set of all pairs of 2 integers; the cartesian product of \$\mathbb{Z}\$ an... | stackexchange_codegolf |
Yesterday, as part of a IQ-style test, I got this interesting question:
The time on a 24-hour clock is 11:43. What is the least number of minutes I should wait before the same digits are on the screen again (in any valid 24-hour time order)?
The answer's 91 minutes, if you were wondering!
This stuck in my mind, and ... | stackexchange_codegolf |
What general tips do you have for golfing in Clean? Please post only ideas that can be applied to code golf problems in general, and are at least somewhat specific to Clean.
If you've never heard of Clean, you can find out more here.
Or, you can join the chat room.
| stackexchange_codegolf |
your challenge is to draw this ASCII art:
| | |- - - - | | - - -
| | | | | | |
|- - -| |- - - | | | |
| | | | | | |
| | |- - - - |- - - |- - - - - -
remember this is code golf meaning you have to answer in the leas... | stackexchange_codegolf |
In this challenge you will be simulating a frog jumping from lily-pad to lily-pad in a pond. A frog's jump distance is uniquely determined by the size of the lily pad it jumps from. So for example there are lily-pads that let a frog jump 1 unit, lily-pads that let a frog jump 2 units etc. A frog can never jump more ... | stackexchange_codegolf |
Create the shortest script that organizes all the logs by month and date.
Rules
Syntax
organize <folder to scan> <folder to place logs>
folder cannot be root
the two folder should be different and not contain one another
Behaviour
The script should scan all the *.log files in <folder to scan> and copy them to <fol... | stackexchange_codegolf |
Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input must be given as six plain real numbers or as a list of six real numbers, in the order given in the example. Your task is ... | stackexchange_codegolf |
Sometimes, I will think it is one day of the week (e.g Friday) when in reality, it's earlier in the week (e.g Tuesday).
Your challenge is to display the number of days my estimates are off by.
Challenge
Given a day of the week I think it is, and the day of the week it actually is, output/return the number of days betwe... | stackexchange_codegolf |
Choose a challenge from the Cops thread, determine the third hidden message, and describe how the system works.
Keep in mind limitations and possibilities available to Cops:
You are not expected to guess any cryptographic secrets or additional information required to extract the hidden messages, as they should have al... | stackexchange_codegolf |
In North America, most electrical outlets/receptacles follow standards set by NEMA. For this challenge, you'll be given a few properties of a device you need to plug in, and your program (or function) should return all of the outlets that would be compatible.
For this challenge, an outlet has three properties: voltage,... | stackexchange_codegolf |
An linear discrete convolution is an operation that turns two vectors of numbers into a third vector of numbers by multiplying elements inside-out. Formally, for two vectors a and b with elements 0 to n - 1, the discrete linear convolution of a and b can be computed with this loop:
for i = 0 to 2*n - 2
c[i] = 0;
... | stackexchange_codegolf |
You are given two regexes and your task is to determine if the strings matched by the first regex are a subset of the strings matched by the second regex.
For this we are going to use a limited mathematical definition of a regex. A regex is defined recursively as one of:
ε - This matches only the string ""
0 - This ma... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2017 Day 3, Part 2.
You come across an experimental new kind of memory stored on an infinite two-dimensional grid.
Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up wh... | stackexchange_codegolf |
A straight-chain alk*ne is defined as a sequence of carbon atoms connected by single (alkane), double (alkene), or triple bonds (alkyne), (implicit hydrogens are used.) Carbon atoms can only form 4 bonds, so no carbon atom may be forced to have more than four bonds. A straight-chain alk*ne can be represented as a list ... | stackexchange_codegolf |
Given the 2-dimensional positions and velocities of a pair of billiard balls right before impact, calculate their velocities after a perfectly elastic collision. The balls are assumed to be ideal spheres (or equivalently: circles) with the same radius, same mass, uniform density, and no friction.
Input consists of 8 nu... | stackexchange_codegolf |
Leaderboard
154 Calculator
144 Taxman
138 Statistician
137 Solver
137 RandoAggroLawyer
136 Gambler
134 Turncoat
119 Lawyer
119 BloodyMurder
113 Bandit
79 Challenger
74 Mask
64 Random
An archive of the latest match, including the log and all output files, is available.
Calculator, by Brilli... | stackexchange_codegolf |
PROBLEM
For a list of numbers, list: Find the lowest possible integer, x, which is optimally close to the whole number even-harmonics of the values in list.
list has a length of n, and all of the values in list are <= 2000
x has a precision of 1.0 (integers only), and must be a value in the range [20, 100]
An even-har... | stackexchange_codegolf |
Inspired by Sygmei's question, I'm interested in finding out what languages can "do this properly".
Your task is to write a "for loop" function / macro / instruction. The arguments should be:
an initializer
a test
an increment
a body
All of these are "pieces of code" and should be able to access variables in the con... | stackexchange_codegolf |
I want an n*n table that is filled with black or white and the following conditions are satisfied in it:
All cells of a 2*2 square in this table should not be the same color.
All black and white cells must be connected horizontally or vertically.
Acceptable examples:
Can anyone design a function that takes n as inpu... | stackexchange_codegolf |
Given a non-negative integer \$n ,\$ output the \$n^{\text{th}}\$ Euler number (OEIS A122045).
All odd-indexed Euler numbers are \$0 .\$ The even-indexed Euler numbers can be computed with the following formula (\$i \equiv \sqrt{-1}\$ refers to the imaginary unit):
$$
E_{2n}
= i
\sum_{k=1}^{2n+1}{
\sum_{j=0}^{k}{
... | stackexchange_codegolf |
Okay, I recently wrote a Javascript Rubik's Cube scrambler that outputs a 25-move scramble. It's 135 bytes. The Gist is here, but for reference, I have the formatted code:
function(){
for(a=s=y=r=[],m='RLUDFB',x=Math.random;++a<26;y=r,s.push(r+["'",2,''][0|x()*2]))
for(;r==y;r=m[0|x()*5]);
return s.join(' ')
}
A... | stackexchange_codegolf |
Alternate Title: Tally Your Prison Sentence on the Wall
Given a number n, output tallies grouped into the traditional 5-per-group and 50 per row.
Examples
1
|
|
|
|
4
||||
||||
||||
||||
5
|||/
||/|
|/||
/|||
6
|||/ |
||/| |
|/|| |
/||| |
50
|||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/
||/| ||/| ||/| ||/| ||/... | stackexchange_codegolf |
Input a datetime, format the datetime in YYYY-MM-DD HH:mm:ss format using 30-hour clock time.
The 30-hour clock time works as:
After 6 a.m., it is same as 24-hour clock time
Before 6 a.m., it use date for previous day, and plus Hours by 24.
For more examples, you may checkout the testcases.
Rules
To simplify the que... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.