instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.
The input list will not be in any particular order and may contain repeated values.
Examples:
[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11... | stackexchange_codegolf |
(Inspired by this challenge.)
Let's say we have a string ABBCBA. We can say that there is a rise between A and B, for B follows A; we can say that there is a run between B and B, for nothing changes; and finally we can say there is a fall between C and B. We can draw a graph like this:
A B B C B ... | stackexchange_codegolf |
Write a code that runs or compiles in as many programming languages as possible and prints a newline separated list of names of previous and current programming languages.
Every used language must have 1 character longer name than previous; ex. C#, C++, Ruby, Jelly, Python...
Each language must output a list of langua... | stackexchange_codegolf |
What general tips do you have for golfing in Lexurgy? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Lexurgy (e.g. "remove comments" is not an answer).
Please post one tip per answer.
Lexurgy is a tool created by Graham Hill/def-gthill meant for conlang... | stackexchange_codegolf |
My previous challenge, Print invisible text was quite popular, likely due to how trivial it is.
However those more observant of you may have noticed that you're not really printing invisible text, because it's impossible to read what was inputted given only the output.
So I figured how about a real invisible text chall... | stackexchange_codegolf |
The problem is to create a string of the same character repeated 100 times.
One potential solution in JavaScript is:
var i = 100,
s = '';
while(i--) s += "Z";
Shortest code wins.
| stackexchange_codegolf |
I just want to do some benchmarking of different programming languages. So here is a tip: You can use as many characters as you want. In the end there is only the time your program needed.
So, here is the Task:
Task
After searching for a good task that would require a lot of computation, I came up with the problem Is a... | stackexchange_codegolf |
For a 2 dimensional array we will define the elements in either the first row or the last column to be the largest "J-Bracket" of the array. For example in the following array elements in the J-bracket are highlighted:
\$
\begin{bmatrix}
\color{red}{\underline 1} & \color{red}{\underline 2} & \color{red}{\underline 4}... | stackexchange_codegolf |
Given a matrix, sum its values up/down or left/right to form an X, fold it up, and return the list. I describe the algorithm here:
Algorithm
Your input will be a odd-sized square matrix of integers within your language's reasonable numerical capacity.
Let's take the following matrix as an example:
1 2 3 2 1
0 3 2 3 0
4... | stackexchange_codegolf |
Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one.
For example, computing this with inputs codegolf.stackexchange.com and e for the character yields:
codegolf.stackexchange.com
cdegolf... | stackexchange_codegolf |
The generalised harmonic number of order \$m\$ of \$n\$ is
$$H_{n,m} = \sum^n_{k=1} \frac 1 {k^m}$$
In this challenge, we'll be considering the generalised harmonic numbers of order \$2\$:
$$H_{n,2} = \sum^n_{k=1} \frac 1 {k^2}$$
This sequence begins \$1, \frac 5 4, \frac {49} {36}, \frac {205} {144}, \dots\$ and conve... | stackexchange_codegolf |
Write a program that, when run in different languages, outputs a different byte permutation of the code in each language. The exact source code is counted as one permutation.
Here "different language" can be different version(Py 2 and Py 3) or different standard flags. It's different output that forces different versio... | stackexchange_codegolf |
Problem
One day, you boss walks up to you and tells you he needs to know the time. He still insists after you pointing at the clock directly above your head, and confesses he has a severe case of dyscalculia, which causes him to not even be able to see numbers on a clock. While you're still left wondering how someone u... | stackexchange_codegolf |
Write code to generate a PDF file containing 6 bingo cards. Winner is the one that uses the shortest code and needs no actions except for installing a library and running the code. (No Save As PDF). Rules are as follows.
The generated PDF file should display accurately in Adobe's PDF reader, Google Chrome and Moxilla ... | stackexchange_codegolf |
This challenge is to write fast code that can perform a computationally difficult infinite sum.
Input
An n by n matrix P with integer entries that are smaller than 100 in absolute value. When testing I am happy to provide input to your code in any sensible format your code wants. The default will be one line per row of... | stackexchange_codegolf |
Pick a quote or phrase that is exactly 5 words long, such as Programming puzzles and code golf!.
Write a program that, when appended to itself n times, outputs the first n + 1 words of your phrase in order.
For example, if your program code was MYPROG and your phrase was Programming puzzles and code golf!, running...
... | stackexchange_codegolf |
Given an integer N from 1-9, you must print an NxN grid of NxN boxes that print alternating 1s and Ns, with each box having an alternating starting integer.
Examples
Input: 1
Output:
1
Input: 2
Output:
12 21
21 12
21 12
12 21
Input: 3
Output:
131 313 131
313 131 313
131 313 131
313 131 313
131 313... | stackexchange_codegolf |
In this thread we use 32-bit signed integers (assuming the usual two's complement). For simplicity I shall call this type Int32. The range is from -2147483648 through 2147483647. Any two values can be successfully multiplied (the result is an Int32 as well) since we use multiplication without overflow checking (we only... | stackexchange_codegolf |
Background
An ex-increasing set sequence of order \$N\$ is defined as a sequence of integer sets \$S_1,S_2,\cdots,S_n\$ which satisfies the following:
Each \$S_i\$ is a non-empty subset of \$\{1,2,\cdots,N\}\$.
For \$1\le i<n\$, \$S_i \cap S_{i+1} = \varnothing\$, i.e. any two consecutive sets have no elements in comm... | stackexchange_codegolf |
Write a script that outputs A to stdout infinitely.
There should be no newlines or separators between the characters.
Standard loopholes apply.
This is code-golf. The shortest solution in each language wins.
| stackexchange_codegolf |
Qat is a tool that lets you search for words matching a given pattern, often used by crossword and other word puzzle writers and solvers.
In this challenge, you will have to implement a specific part of Qat, namely a subset of the "equation solver".
Equations
The output of a Qat query depends on the dictionary you use ... | stackexchange_codegolf |
In a fictional document management system, input documents are structured with weighted headings. Lowest weighted headings are the most important.
This is a sample document:
H1 All About Birds
H2 Kinds of Birds
H3 The Finch
H3 The Swan
H2 Habitats
H3 Wetlands
From this document we would like to produce an outline usin... | stackexchange_codegolf |
Read this yng Nghymraeg
Challenge
Given a word in Welsh, output all of the possible mutated forms of the word.
Mutations
A mutation is a change of the first letter of a word when following certain words or in certain grammatical contexts.
In Welsh, the following are considered "consonants":
b c ch d dd f ff g ng h l ll... | stackexchange_codegolf |
Introduction
This challenge was originally the "Among Us" challenge in the "Misc" category of YASCON CTF 2020. (The link includes an answer to that challenge. Click at your own risk.)
You're given a lot of files, 1 of which is different from every other files. Your job is to find that 1 different file.
Challenge
Input... | stackexchange_codegolf |
Description
While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly i... | stackexchange_codegolf |
For more MtG-goodness: Magic: The Gathering Combat with Abilities
Premise:
In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands can produce one of the five colors which are:
White (W)
Blue (U)
Black (B)
Red (R)
Green (G)
The cost is made up of two... | stackexchange_codegolf |
Pangrams
The quick brown fox jumped over the lazy dog.
This is an example of a pangram - a sentence that contains every letter of the alphabet at least once.
A self-enumerating pangram is a sentence that fulfills the criteria to be a pangram by producing an analysis of its own letter count.
An example of achieving th... | stackexchange_codegolf |
Lighthouses on an island have blink codes that let ships know which lighthouse they are seeing. Input should be strings of S and L. Here is a (Python) example of codes for 4 lighthouses as a list of strings:
['SLS', 'SLL', 'SSS', 'LSL']
where:
S = short ON (1 sec)
L = long ON (3 sec)
Long and short ON's are both follo... | stackexchange_codegolf |
This challenge has ended. To see the final scores of the competitors, click here
In this challenge, each submission is one bot. Each bot should be a Javascript function. Bots will fight to obtain the highest total worth in gold. Gold can be farmed, or earned from killing other bots, and is used to upgrade healing, at... | stackexchange_codegolf |
The Golf (re)Sort
Everyone is sorting arrays these days, and so do we at our day jobs. But we like to go out golfing. When we do, we sure like to take our time. It is important to have a stress free experience.
Since we like golfing so much, we have decided to make a sorting algorithm that will let us stay away from t... | stackexchange_codegolf |
Introduction
Every string has an "alphabet", composed of the characters that make it up. For example, the alphabet of \$abcaabbcc\$ is \${a, b,c}\$. There are two operations you can do with alphabets: getting the alphabet of a string, and seeing if another string has a given alphabet.
Challenge
Given two strings, you m... | stackexchange_codegolf |
You are given an array A of length N and an array B of length N-1.
You need to output array where items alternates:
A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1]
Restrictions:
N>0
Type of items is not specified, but code should work at least for unsigned integers.
Sample input:
A = [1,2,3,4]
B = [7,8,9]
Sample output:... | stackexchange_codegolf |
Challenge
Given an integer n ≥ 4, output a permutation of the integers [0, n-1] with the property that no two consecutive integers (integers with absolute difference 1) are next to each other.
Examples
4 → [1, 3, 0, 2]
5 → [0, 2, 4, 1, 3]
6 → [0, 2, 4, 1, 3, 5]
7 → [0, 2, 4, 1, 5, 3, 6]
You may use 1-indexing instead... | stackexchange_codegolf |
The Australian Apparent Temperature (aka, wind chill) in °C AT is given by this algorithm from the Australian Bureau of Meterology (wp, source):
AT = Ta + (0.33 * e) - (.7 * ws) - 4.0
Where:
Ta = Dry bulb temperature (°C)
e = Water vapour pressure (hPa)
ws = Wind speed (m/s) (at an elevation of 10 meters)
The water ... | stackexchange_codegolf |
All Aboard the ASCII Train!
o O O ___ ___ ___ ___ ___ ___ ___ ___ ___
o | C | | O | | D | | E | | | | G | | O | | L | | F |
TS__[O] |___| |___| |___| |___| |___| |___| |___| |___| |___|
{======|_|"""""|_|"""""|_|"""""|_|"""""|_|"""... | stackexchange_codegolf |
Background
Tatamibari is a logic puzzle designed by Nikoli.
A Tatamibari puzzle is played on a rectangular grid with three different kinds of symbols in it: +, -. and |. The solver must partition the grid into rectangular or square regions according to the following rules:
Every partition must contain exactly one symb... | stackexchange_codegolf |
Given a string, if it is even, break the string into 2 even parts, then reverse the parts to get the "reversencoded" string.
Example:
onomatopoeia -> tamonoaieopo
If the string is not of even length, then do not change the position of the middle character, and reverse the letters before and after the middle character.
... | stackexchange_codegolf |
Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.
This may mean outputting the empty string.
If there are several valid outputs, ... | stackexchange_codegolf |
Background
Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diagonally) and the number of tents on each row... | stackexchange_codegolf |
The Chinese Remainder Theorem can be quite useful in modular arithmetic.
For example, consider the following set of congruence relations:
For sets of congruence relations like this, where all the bases (3, 5, 7 in this example) are co-prime with each other, there will be one and only one integer n between 1 and the pr... | stackexchange_codegolf |
For this challenge, a word is defined as a string of letters, separated by spaces.
Given a string of words, and an integer i representing an index into that string, output the whole word which contains the character at index i.
For example (using 0-based indexing), with the string code golf, and the index 6, the 7th ch... | stackexchange_codegolf |
We all know run-length decoding: A list of character-length pairs expands to a string of that many characters, so A1B4C2 expands to ABBBBCC. But what if we stretch this concept to 2 dimensions?
Instead of character-length pairs, in this challenge you will be given character-length-direction triples. For example, using ... | stackexchange_codegolf |
What is the shortest way to convert a string containing integers separated by spaces to a list of integers?
input : "-3 1 5 8 10"
output : [-3, 1, 5, 8, 10]
I regularly face this situation and I wanted to know if there is a better way than (24 bytes):
list(map(int,s.split()))
| stackexchange_codegolf |
Your task is to create a program/function to replicate this word generator.
Details
Your program/function take two input. One input is the categories. The other input is the syllable types.
Categories
categories will consist of classes of letters.
For example, V=aeiou means that the letters a, e, i, o, and u will be cl... | stackexchange_codegolf |
You will be given a nested array. Your program has to visualize the array.
But.. How?
For example, let's assume we have a nested array, like [["1","2"],[["1","2"],"3"],"4",[[[["5"]]]],"6"].
This nested array can be visualised as:
->1
->2
-->1
-->2
->3
>4
---->5
>6
Examples
Input 1:
["Atom",["Proton",["Up Quark", "Up... | stackexchange_codegolf |
As in this question, your task – should you choose to accept it – is to calculate the date of Easter Sunday according to the Gregorian Computus (as used in the Catholic Church and most others) when provided with only a year number as input, in as few characters as possible without relying on Easter-specific date functi... | stackexchange_codegolf |
Let us say that we have a particular set of functions on strings. These functions are kind of like fill in the blanks or madlibs, except that they only take one input and use that to fill in all of their blanks. For example we might have a function that looks like
I went to the ____ store and bought ____ today.
If w... | stackexchange_codegolf |
Given \$A = (a_1,\dots,a_k)\ k\ge2 \$ a sequence of positive integers, in which all elements are different.
Starting from \$i=2\$, while \$a_i\in A:\$ (until the last element)
If \$d=|a_i-a_{i-1}|\$ is not already in \$A\$, append \$d\$ to \$A\$
Increase \$i\$
Output the completed sequence.
This is code-golf
Example
... | 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 |
The challenge
Simply write a program that outputs its own source code.
Nothing more than a regular quine.
The problem
We don't have a computer so we have to run the program on a programmable logic device (such as an FPGA, a CPLD, a gate array ...).
The rules
Any device available on the market (such as a printer connec... | stackexchange_codegolf |
The Challenge
Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg.
Given: 1.25
x1: 1.25
x2: 2.5
x3: 3.75
x4: 5
Thus: Answer is 5
Clarifications
Inputs will be a rational number in the range of (0,100] of which the Decimal Representation has no more than 4 ... | stackexchange_codegolf |
Make a Windows style Loading bar by the following instructions.
(notice that this is different than Loading... Forever)
Your output should start by [.... ].
Every tick, you should wait 100 ms, then move each dots by one character right. if the dot is on the tenth character, move it to the first. Notice that you s... | stackexchange_codegolf |
Discussion in courtrooms often occurs at a high speed and needs to be accurately transcribed in case the text of the decision is needed in future cases. For this purpose, the stenographers who transcribe court discussions use specially designed keyboards with a small set of buttons, which are pressed in groups to spell... | stackexchange_codegolf |
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
Output how many letters would be used if all the numbers from 1 to 1000 (one thousand) inclusive were written out in words.
NOTE: Do not count spaces or hyphens. For example, 342 (th... | stackexchange_codegolf |
Given an initial \$n\$-tuple \$t_0=(t_{0,1},...,t_{0,n})\$, we can obtain its corresponding Ducci sequence \$\{t_0, t_1, ...\}\$ by the recurrence \$\displaystyle t_{i+1}=\left(\left|t_{i,1}-t_{i,2}\right|,\left|t_{i,2}-t_{i,3}\right|,...\left|t_{i,n}-t_{i,1}\right|\right)\$.
That is, to obtain the next term of the seq... | stackexchange_codegolf |
Challenge:
Find the number of ways to climb some stairs with n steps and with some limitations. You should be able to run the tests below on TIO https://tio.run/ without timing out. – 60 seconds. (Typically a fraction of a second is well within reach for most languages if a good optimizing strategy is applied).
The in... | stackexchange_codegolf |
Background
Here in the UK1, these are the income tax rules:
You get a personal allowance (untaxed) of up to £12,570:
If you earn less than £100,000, you get the full £12,570 as personal allowance
For every £2 over £100,000, your personal allowance goes down by £1
After the personal allowance, the next £37,700 is ta... | stackexchange_codegolf |
To "shift" over a number n places, do the following:
Remove the last n digits
Add n copies of the first digit to the beginning of the number
For example, to shift the number 31415 three places, take out the last three digits to get 31, and then add three more copies of the first digit, 3, to the end, giving 33331.
If... | stackexchange_codegolf |
This is the companion thread to the main Recover the mutated source code (link) challenge. If you have successfully cracked a cop's answer, post your solution as an answer to this question.
As a reminder, here are the robber rules from the main challenge again:
The robber will attempt to change the cop's program (whic... | stackexchange_codegolf |
Given a positive integer nesting level n and string s of printable ascii characters( to ~, output a program which, when run in the same language, outputs a program which outputs a program . . . which outputs the string s.
A total of n programs should be generated, all of which should be run in the same language as your... | stackexchange_codegolf |
Your task is, to count how many pluses I have.
What Pluses?
The no plus: 0 Points
-
The naïve Plus: 1 Point
+
The double Plus: 2 Points
+
+++
+
The mega double plus: 3 Points
+
+++
+
+ + +
+++++++++
+ + +
+
+++
+
Pluses of higher order than 3 must be ignored.
Rules
Input will ... | stackexchange_codegolf |
According to Wikipedia, a strongly Darboux function is
one for which the image of every (non-empty) open interval is the whole real line
In other words, a function \$f\$ is strongly Darboux if given 3 arbitrary real numbers \$a\$, \$b\$, and \$y\$, it is always possible to find an \$x\$ between (distinct) \$a\$ and \... | stackexchange_codegolf |
Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern:
*
***
x
instead of
* *
x
This means that each cell is the sum of the three cells on the row directly above it and one cell on the row 2 above it. Just like Pascal's triangle the zeroth row has a single 1 on it that generates... | stackexchange_codegolf |
Consider, for a given positive integer \$k\$, the sequence \$(a, a+1, a+2, ..., a+k)\$, where \$a\$ is some positive integer. Is there ever a pair \$a, k\$ such that for each element \$a+i\$ in the sequence, either \$\gcd(a, a+i)\$ or \$\gcd(a+i, a+k)\$ are greater than 1?
This was investigated by Alan R. Woods as part... | stackexchange_codegolf |
My stovetop has 10 different settings of heat (0 through 9) and a very odd way of cycling through them.
When I hit plus (+) it increments the number, unless the number is 9 in which case it becomes 0, or the number is 0 in which case it becomes 9.
When I hit minus (-) it decrements the number, unless the number is ze... | stackexchange_codegolf |
Introduction
You may remember sudoku, where there can only be one of each number in each row, column and block of nine.
The general idea is that if the array contains but one element, you can submit that as a deterministic solution. If there are already filtered arrays (by rows, columns and 3×3 blocks) the remainder ca... | stackexchange_codegolf |
Introduction
A known fact is that Jon Skeet can code Perl and make it look like Java. In this challenge you will try to do something similar.
Challenge
Write a piece of code of any length that can be executed without any errors/exceptions in two different languages. Your program can take inputs, give outputs, whatever ... | stackexchange_codegolf |
According to RollingStone, below are the 26 greatest singers of all time:
Aretha Franklin Al Green
Ray Charles Robert Plant
Elvis Presley Mick Jagger
Sam Cooke Tina Turner
John Lennon Freddie Mercury
Marvin Gaye Bob Marley
Bob Dylan Smoke... | stackexchange_codegolf |
Here's a relatively simple challenge for you:
Given a list of positive integers:
Line them up in a grid, and sum each column. For example, if the input was [123, 7, 49, 681], the grid would look like this:
1 2 3
7
4 9
6 8 1
And the sum of each column would be [18, 19, 4]:
1 2 3
7
4 9
6 8 1
--... | stackexchange_codegolf |
Inspired by and drawns from Is this number Loeschian?
A positive integer \$k\$ is a Loeschian number if
\$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers.
For example, the first positive Loeschian numbers are: \$1\$ (\$i=1, j=0\$); \$3\$ (\$i=j=1\$); \$4\$ (\$i=2, j=0\$); \$7\$ (\$i=2, j=... | stackexchange_codegolf |
Introduction
Fischer random chess, also known as Chess960 for the 960 valid starting boards, is a variant of chess where each player's pieces are randomly shuffled at the start. As a reminder, each player gets 8 pawns, two rooks, two knights, two bishops, one queen, and one king. For this challenge, you don't need to k... | stackexchange_codegolf |
A lawn is defined as a rectangular field with of one character surrounded by two layers of visible whitespace. This means two lines above and twos lines below, and a two space padding on the left (the right has visible whitespace, so you do not need to include it).
|||||
|||||
|||||
A mowed lawn is... | stackexchange_codegolf |
Based on Practical Golf - US States
Your task is to find the abbreviation (symbol) of an element given the element name, up to and including ununoctium (118). Use the periodic table on Wikipedia.
Thanks to squeamish ossifrage, you can find a full list of elements to abbreviations at http://pastebin.com/DNZMWmuf.
You ma... | stackexchange_codegolf |
Background
Manufactoria is a game about programming. The player must use a form of two-dimensional programming language to complete tasks. If you've never heard of it, the easiest way to learn is to try out the first few levels of the game.
Challenge
Your challenge is to create a program which tests the primality of a... | stackexchange_codegolf |
In a certain chatroom, we like making acronym jokes about the build tool we use called sbt. While it usually stands for "Scala Build Tool", we aim to come up with all sorts of meanings, such as:
Stupid Brick Teeth
Sussy Baka Training
Shady Blue Tourists
Seriously Big Toes
Silly Bear Topics
Salacious Bacon Tripod
Syrin... | stackexchange_codegolf |
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum.
Example:
5
would return
20
Example 2:
4
would return
6
EDIT:
To be clear:
a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle.
... | stackexchange_codegolf |
Information
Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$)
The diagonal line starts from the top left and goes to the bottom right.
You must use the ASCII character \ for the line.
The input number can be given from STDIN or if your program doesn’t support that, use a har... | stackexchange_codegolf |
Disclaimer: This is heavily inspired by "Polyglot the OEIS!" but fixes the problem that lead to closure (see the output section) and was re-posted as to not invalidate answers.
Introduction
We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version of the interesti... | stackexchange_codegolf |
Given an ordered list of numbers (possibly with leading zeros), arrange the numbers vertically, then let all zeros drop all the way to the bottom and all overhangs drop to the bottom-most open slot. Output the resulting integers, removing leading zeros.
Worked Example
Say we were given the following as input:
['0000312... | stackexchange_codegolf |
What general tips do you have for golfing in 2 dimensional programming languages? I'm looking for tips which can be applied to code-golf problems and are specific to 2D programming languages, but not specific to any one language (Responses like "remove comments" and "use the M operation" are not answers).
Please post ... | stackexchange_codegolf |
Background
Given a triangle \$ABC\$, extend its three sides by the opposite side length, as shown in the figure below. Then the six points surprisingly lie on a circle called the Conway circle, whose center coincides with the incenter (the center of incircle, the circle that is tangent to the three sides from the insid... | stackexchange_codegolf |
Challenge
Write a program or a function that returns or prints a square-random-symmetrical matrix.
Input
N: The size of the matrix i.e 6 x 6
Output
The matrix. You can either print it, return it as string (with the newlines) or as a list/array of lists/arrays.
Rules
You need to use at least N different characters, ... | stackexchange_codegolf |
Take a line of input (function arguments or stdin, etc.).
Remove comments in it, where a comment starts and ends with ".
Do not remove comments in string literals, which start and end with '. String literals do not contain escapes, because smalltalk has nice, easily lexable syntax ;).
Output this string.
The number of... | stackexchange_codegolf |
These are the classical puzzles:
You need to boil eggs for exactly 9 minutes, or else the visiting Duchess will complain, and you will lose your job as head chef.
But you have only 2 Hourglasses, one measures 7 minutes, and the other measures 4 minutes. How can you correctly measure 9 minutes?
(taken from here)
Let's... | stackexchange_codegolf |
Challenge
Giving a valid arithmetic sum with some missing numbers, output the full expression.
Example:
1#3 123
+ 45# => + 456
-------- --------
579 579
Input
Expression format can be an array ["1#3", "45#", "579"], a string "1#3+45#=579", or 3 inputs f... | stackexchange_codegolf |
Challenge: Create a program that prints out the size of its own source code file.
For example, a 35 bytes size of program must print out 35. Pre-calculation is not valid. What I mean by pre-calculation is:
// test.js -> its size is 15 byte
console.log(15)
It must dynamically calculate the size of own source code fi... | stackexchange_codegolf |
The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers.
The first few rows are:
1
1 1
2 2 1
2 4 5 5
16 16 14 10 5
16 32 46 56 61 61
Each row is generated as follows:
If the row number is even (1-indexed):
Bring... | stackexchange_codegolf |
Very interesting background
Comcoins are a currency like any other. The residents of Multibaseania (an economically robust system of city-states with very few residents in a galaxy far, far away) use Comcoins to conduct transactions between themselves. Comcoins are represented by unique codes on special not-paper slips... | stackexchange_codegolf |
The crazy mathematician owns a wide collection of numbers, and therefore the space he has left is quite limited. To save some, he must fold his integers, but unfortunately he is really lazy. Your task, if you wish to help him, is to create a function / program that folds a given positive integer for our number maniac.
... | stackexchange_codegolf |
I'm working from home and the heat of my laptop on my lap is the only thing keeping me warm. I have a Dell G3 Laptop with an NVidia GEForce GTX CPU.
I have tried writing a rust program with 5 threads that calculates and prints the Fibonacci sequence in an infinite unthrottled loop, but that only gave a bit of warmth, a... | stackexchange_codegolf |
Your Challenge:
For a golf Course Of Inputted 'n' length to hole where:
'n' is a whole number and a multiple of 5 between 150 and 500
and
1 integer in code = 1 metre
You must calculate the least amount of swings it can be completed in using a combination of clubs and ranges.
Here is a visual representation of what t... | stackexchange_codegolf |
For this challenge, you will be given an absolute path, and a "new" path (which can be absolute or relative), and you need to return the final path.
For example, if your current directory was /var/tmp/test:
my_dir or my_dir/ should return /var/tmp/test/my_dir
../../my_dir should return /var/my_dir
/my_dir/./ should re... | stackexchange_codegolf |
Definition of long text
Long text usually shows emphasis, for instance, loooooool or yaaaaaaaaaay. Usually the vowel is replicated many times. In this challenge we require:
At least 3 times, which means yaaay and yaaaay are allowed, but yay and yaay are not.
Consistent, which means that shoes can turn out be shoooeee... | stackexchange_codegolf |
I just had a lesson in school about alkanes and figured it would probably make for a great code golf challenge! Don't worry, it isn't as complicated as it may look!
A Quick Rehash
(Please Note: To keep this brief, not all information is 100% accurate.)
Alkanes are strings of carbon and hydrogen. Every carbon atom has 4... | stackexchange_codegolf |
A bronze plaque in the pedestal of the Statue of Liberty displays the poem "The New Colossus" by Emma Lazarus, part of which reads:
Give me your tired, your poor,
Your huddled masses yearning to breathe free,
The wretched refuse of your teeming shore.
Send these, the homeless, tempest-tost to me,
I lift my lam... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Christmas is coming up, and Santa hasn't kept to his diet very well this year. Due to his size, he is getting the elves to collect a list of all the chimneys he will be able to fit down. Unfortunately, chimneys these days are a bit of ... | stackexchange_codegolf |
For this problem you are given an \$n \times n\$ matrix of integers. The task is to find a pentagon in the matrix with maximum sum. The pentagon must include part (or all) of the x and y axes as two of its sides starting from the top left cell.
All the sides except one must be horizontal or vertical. The remaining si... | stackexchange_codegolf |
Sandbox
Given two positive integers a and b, return the smallest multiple of b that is greater than or equal to a.
Examples
Definitions: true = is a multiple of b, false = is not a multiple of b.
f(1,3) = 3 because 1 is false, 1+1 is false, but 1+1+1 is true. Therefore 3 is returned.
f(5,3) = 6 because 5 is false, but... | stackexchange_codegolf |
A lazy physicist has the job to perform the double slit experiment. However, they are lazy and can't be bothered to set up all the equipment themselves and so are going to simulate the effects. They can't program though so are going to need some help. As they are lazy your program should be as short as possible.
Given... | stackexchange_codegolf |
In this code-challenge you will write a hash function in 140 bytes1 or less of source code. The hash function must take an ASCII string as input, and return a 24-bit unsigned integer ([0, 224-1]) as output.
Your hash function will be evaluated for every word in this large British English dictionary2. Your score is the ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.