instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -x2 can be expressed as ∫x∫111dtxdu.
E := 1 | var | ∫EEEdvar
Any reasonable input/output method is allowed.
Examples:
Your score will be the your code length... | stackexchange_codegolf |
Given a date between 2010-01-01 and 2099-12-31 as three integers (please state your order if not [year,month,day]), answer with Tesco's corresponding five-digit Burger Relish Best Before End date number.
The format is simply the last two digits of the year, followed immediately by three digits representing the day of ... | stackexchange_codegolf |
Challenge
Given some input string, return a truthy value if it represents a correct roman numeral between 1 (=I) and 3999 (=MMMCMXCIX), and a falsey value otherwise.
Details
The input is a non-empty string that only comprises the characters IVXLCDM.
The roman numerals (that we use here in this challenge) are defined a... | stackexchange_codegolf |
Given a strictly positive integer n (therefore 0 isn't a valid test case), produce an approximate triangle of height n.
A non-programmatic process of drawing the picture
Initially we start with the base of the triangle.
|
So, we want to draw a triangle of a height of 5. First we know that all the |'s align on a straig... | stackexchange_codegolf |
I just got a job as a postman and I need your help to keep it.
I have to order a lot of mails before I go out to deliver them.
Streets are numbered strictly sequentially, starting with 1 at the start of the street, and continuing in order skipping no numbers until the end, with odd numbers on the left side and evens on... | stackexchange_codegolf |
Given an input value \$n\$, construct an array of \$n\$ random 128 bit (unsigned) integers. The integers should be uniformly random.
Your code can use any in built random number generation function it has or you can implement your own. Clearly this challenge is harder (and more fun) in lower level languages.
| stackexchange_codegolf |
Description
Output the rhyme scheme for a very long Terza Rima.
Input
None.
Output
ABA
BCB
CDC
DED
EFE
FGF
GHG
HIH
IJI
JKJ
KLK
LML
MNM
NON
OPO
PQP
QRQ
RSR
STS
TUT
UVU
VWV
WXW
XYX
YZY
Rules
You can pick between separating stanzas with whitespace or newlines, so either:
ABA BCB...
OR
ABA
BCB
...
A single trailing whit... | stackexchange_codegolf |
As input you will be given a ragged list of positive integers containing at least one integer at some level. For example:
[[],[[1,2,[3]]],[]]
You should output the depth of the least deep integer. For example if the input is just a list of integers, then the every integer is 1 level deep so the answer is 1. There m... | stackexchange_codegolf |
Disclaimer: This challenge inspired by me spending the morning debugging recursive functions, which have been frying my brain a little.
Here's an example of recursion, from a letter, we keep going to the previous letter of the alphabet, printing out each one as we go, until we hit the letter a, then we print that and s... | stackexchange_codegolf |
In this challenge posed by xnor, we were asked to implement XOR multiplication. In this challenge the goal is to find the first n XOR primes. XOR primes are very similar to regular primes as you can see by the following definitions:
Definition of Prime Number: A positive number greater than 1 which cannot be formed thr... | stackexchange_codegolf |
I'd like to propose a different kind of golfing challenge to this community:
(Artificial) Neural Networks are very popular machine learning models that can be designed and trained to approximate any given (usually unknown) function. They're often used to solve highly complex problems that we don't know how to solve alg... | 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 |
We all know what a quine is. A quine is a program which prints its own source code. And we also know about the printable ASCII characters. Well... this challenge mixes both.
Your mission, should you accept it, is to create an index quine. An index quine is a non-empty program, composed only of the printable ASCII chara... | stackexchange_codegolf |
Given an expression like 4 / 2 + 3, determine whether the expression has the same value in Python 2 and Python 3. Recall that in Python 2 division rounds down (so that 5 / 2 -> 2), whereas in Python 3 division returns a float (so that 5 / 2 -> 2.5).
For simplicity's sake, we will only consider expressions of the form:
... | stackexchange_codegolf |
A biquadratic number is a number that is the fourth power of another integer, for example: 3^4 = 3*3*3*3 = 81
Given an integer as input, output the closest biquadratic number.
Here are the first 15 double-squares:
1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000, 14641, 20736, 28561, 38416, 50625
This is code-golf s... | stackexchange_codegolf |
using Prefixed Length Code
We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of that character in the text. The characters that occur more frequently will be replaced by shorter codes. The resulting ... | stackexchange_codegolf |
Zig-zag strings
Given a string and a positive integer, output the string in a zig-zag wave pattern with a peak amplitude and character spacing equal to the integer.
This is similar to this question but also includes character spacing.
Input
Input can be read from STDIN or taken as function arguments. Input is a string... | stackexchange_codegolf |
Recently, I have found my reputation changing time to time. I would like to know my reputation changing real-time.
The job
Given an id of a user on PPCG (ex.64499), Print the user's reputation every 10 seconds. You may ignore the daily quota.
Examples
64499
3808
40695
Possible output format
12345
12,345
| stackexchange_codegolf |
Unlike most languages, Python evaluates a<b<c as it would be done in mathematics, actually comparing the three numbers, as opposed to comparing the boolean a<b to c. The correct way to write this in C (and many others) would be a<b && b<c.
In this challenge, your task is to expand such comparison chains of arbitrary le... | stackexchange_codegolf |
Stock Time Machine
You've gained access to a dataset, tomorrowStocks, which contains the stock prices from your favorite business on the NASDAQ. This dataset is a container indexed by minutes past opening. Each index contains the price of the stock at that time.
// Assume the stock market opens at 9:30AM EDT
// tomorro... | stackexchange_codegolf |
Introduction
It is somewhat like DVORAK Keyboard layout , but MUCH harder.
Let's talk about the Korean keyboard first. As you can see in Wikipedia, there is a Kor/Eng key to change between Korean and English key sets.
Koreans sometime type wrong : they attempt to write in Korean on a qwerty keyboard or in English on a ... | stackexchange_codegolf |
Introduction
The Nineteenth Byte is CGCC's official chatroom (go check it out!). Its name is a play on the nineteenth hole, and it also refers to golf, which is appropriate for CGCC's chatroom's name. The name is also precisely \$19\$ bytes long, as its name states.
Challenge
Your task is to write a program that output... | stackexchange_codegolf |
Programs often list outcome statistics, such as this:
54% of participants received an award
69% of participants got a promotion
85% of participants increased their salary
These percentages are the result of dividing a/x, where both a and x are whole numbers, and the result is rounded to the nearest hundredth.
Your ta... | stackexchange_codegolf |
I have a follow-up question here from my previous question on Math SE. I am lazy enough to explain the content again, so I have used a paraphraser to explain it below:
I was considering arbitrary series, springing up as a top priority, when I considered one potential series in my mind. It is as per the following:
The ... | stackexchange_codegolf |
Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given?
Task
Your program will get n (you can have n as part of input or use EOF instead) points (x,y).
The points might at same place => (x1,y1) = (x2,y2) can happen
x and y will be integer of range -10000~10000, wh... | stackexchange_codegolf |
Overview
Adding slightly to the complexity of working with Roman numerals...
The ancient Romans devised a number system using Latin letters, which served them well, and which is still used by modern civilization, though to a much smaller degree. In the time of its use, Romans would have had to learn to use and manipula... | 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 |
Your task is to print a number. Simple, right? It is simple, but not as simple as this. The first answer is to print the number 1, the second answer is to print the number 2, etc.
Rules
The first answer must print 1, and the nth answer must print n.
The first answer may be of any length.
Whitespace, comments, etc. are... | stackexchange_codegolf |
It's time for another Mesoamerican calendar! The Xiuhnelpilli was used by the Aztecs (more properly, the Mexica) to name their years. Each year has a number and a sign. Here's part of the cycle:
Input; Output
1089; 13 Calli
1090; 1 Tochtli
1091; 2 Acatl
1092; 3 Tecpatl
1093; 4 Calli
1094; 5 Tochtli
1095; 6 Acatl
... | stackexchange_codegolf |
Input
An integer n and a pair of distinct integer valued (x, y) coordinates on the boundary of the grid. The coordinates are indexed from 1. For example, n=10 and (1,2), (10, 7).
The points will always be on different sides of the grid and neither of them will be \$(1, 1)\$.
Output
The number of integer points in an n... | 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 |
Here's an advanced version of the Count the Liberties challenge.
The definitions of the terms liberty and group are the same as the previous challenge, so have a look at the previous one for details, but briefly put,
A group is a group of stones that are connected horizontally or vertically.
Liberty is the number of e... | stackexchange_codegolf |
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one.
The challenge is to compute the average Levenshtein distance between two independent and uniformly random chosen binary strings of length n each. Your... | stackexchange_codegolf |
Make a quine. Simple enough, except it has to be a palindrome and accept input.
Now, any side of a palindromic quine is one half of it. For example, one side of the hypothetical quine AAAA is AA. One side of AAAAA is AA (the center symbol is ignored).
Your job is to make a quine like this that accepts input. If the inp... | stackexchange_codegolf |
Introduction
The International System of Units is a system of measuring all around the world, except for a few countries including the US. The SI system (or metric system) is based on powers of ten, listed below (note that this is an incomplete table):
femto(f) pico(p) nano(n) micro(μ) milli(m) centi(c) (base unit) hec... | stackexchange_codegolf |
Inverse function of this challenge
To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick the characters back together. If the integer is negative, we use its absolute value in the first step, and then reverse t... | stackexchange_codegolf |
What am I?
As a plant cell, your program/function/etc. must undergo photosynthesis:
When the input is 6CO2+6H2O+light in any order, output C6H12O6+6O2 in any order. It does not have to be the same for each arrangement of the input.
When the input is just r, replicate (i.e. output your own code). quine rules apply.
Whe... | stackexchange_codegolf |
Write an object-oriented program that, when ran, outputs one complete example from each reserved-word-vise unique signature combination available to that language. Reserved words for primitive types are excluded. Each example should start from a new line.
This implies that for all signatures any changes in parameters, ... | stackexchange_codegolf |
There are a lot™ of pokemon. One of the defining characteristics of pokemon is their type, of which every1 pokemon has up to two types, a primary type and an optional secondary type. There are mechanical implications to each type, and so it is very useful to know what type a given pokemon is during battle. But there's ... | stackexchange_codegolf |
The challenge
Given a list of words ["Programming", "Puzzles", "Code", "Golf"] output the words crossword-style:
P r o g r a m m i n g
u
z
z
G l
C o d e
l s
f
The Algorithm
You have to process the list in the given order.
The words are printed in alternating orientations, starting h... | stackexchange_codegolf |
The minmod function is a variant of the familiar min, which appears in slope-limiting high-resolution schemes for partial differential equations. Given a number of slopes, it picks out the flattest slope, while taking care of relative signs between the slopes.
The function takes an arbitrary number of parameters. Then ... | stackexchange_codegolf |
In this challenge, your task is to take an anion and a cation, and output the chemical formula of the compound.
Input rules
Take in 2 strings (in any order) representing the anion and cation, e.g. F, NH_4, or Al.
To take in the charge of each ion, you can either have it as part of the string separated by a caret (e.g... | stackexchange_codegolf |
Challenge :
Check :
if there are exactly n exclamation marks ! between every pair
and whether the sum of each pair equals to 10.
Input :
A string of arbitary length.
The number of exclamation marks to check for
Output :
if there are exactly n exclamation marks between each pair, return truthy value, otherwise fal... | stackexchange_codegolf |
Your task is to find the length of the coastline of a map of islands provided in
an ASCII map. The input map will consist of 1 or more # characters that
indicate land, and spaces which indicate water. The coastline is considered to
be any edge between land and water, including inland lakes and islands.
Your solution sh... | stackexchange_codegolf |
Van der Waerden's theorem says that
For any given positive integers r and k, there is some number N such
that if the integers {1, 2, ..., N} are colored, each with one of r
different colors, then there are at least k integers in arithmetic
progression all of the same color. The least such N is the Van der
Waer... | stackexchange_codegolf |
Challenge
You are given two distinct bit strings of the same length. (For example, 000 and 111.) Your goal is to find a path from one to the other such that:
At each step, you change only one bit (you can go from 000 to any of 001, 010, 100).
You cannot visit the same bit string twice.
The path is as long as possible,... | stackexchange_codegolf |
Fermat's last theorem says that there there are no positive, integral solutions to the equation a^n + b^n = c^n for any n>2. This was proven to be true by Andrew Wiles in 1994.
However, there are many "near misses" that almost satisfy the diophantine equation but miss it by one. Precisely, they are all the greater than... | stackexchange_codegolf |
When we publish some software, we assign a version number to it. And users may want to update to the latest version of some software. So, it is the time to find out which version should be newer.
Input
Input two version numbers as strings.
In the context of this challenge, we only support version numbers which are some... | stackexchange_codegolf |
In chess, a knight can only move to the positions marked with X relative to its current position, marked with ♞:
A Knight's Graph is a graph that represents all legal moves of the knight chess piece on a chessboard. Each vertex of this graph represents a square of the chessboard, and each edge connects two squares th... | stackexchange_codegolf |
Challenge
Take a number and output it with 4 digits or less using letters and numbers. For example; 270,030 would turn into 270K.
Key
Billion -> B
Million -> M
Thousand -> K
Rules
You may choose to accept input numbers that include commas delimiting every three decimal places (such as 123,456,789).
Round to nearest, h... | stackexchange_codegolf |
Given an array of integers A, the task is to output another array B of the same length so that B[i] is the maximum over A for every index that is not i. That is \$B[i] = \max_{i' \ne i} A[i']\$.
Examples:
A = [1, 5, -3, 4, 2]. B = [5, 4, 5, 5, 5]
A = [1, 2, 3]. B = [3, 3, 2]
A = [-1, -2, -3, -1]. B = [-1, -1, -1, -1]
... | stackexchange_codegolf |
The wizard has a cunning cousin who is a witch. She looks down on the wizard, regarding him and his puzzles as mathematically naive. On reading his latest puzzle, she scorned him for always asking discrete problems with what she (unfairly) characterises as simple solutions, where the real, proper question should be co... | stackexchange_codegolf |
Given a string l, find all palindromic substrings p of l (including duplicates and single character strings). Next, rearrange all sub-strings in p into a valid palindrome (there may be multiple correct answers). If it is not possible to rearrange p into a single palindrome, your program may have undefined behavior (err... | stackexchange_codegolf |
Find the difference between the square of the sums and sum of the squares.
This is the mathematical representation:
\$\left(\sum n\right)^2-\sum n^2\$
Your program/method should take two inputs, these are your lower and upper limits of the range, and are inclusive.
Limits will be whole integers above 0.
Your program/m... | stackexchange_codegolf |
The ubiquitous Catalan numbers \$C_n\$ count the number of Dyck paths, sequences of up-steps and down-steps of length \$2n\$ that start and end on a horizontal line and never go below said line. Many other interesting sequences can be defined as the number of Dyck paths satisfying given conditions, of which the Fine se... | stackexchange_codegolf |
This is the cops' thread. For the robbers' thread, click here.
Cops' Task
First, write a quine in a language of your choosing.
Next, scramble the quine. Make sure to do this well as the robbers will be trying to unscramble it and find the original source code! Note that the scrambled code does not need to work.
Post a... | stackexchange_codegolf |
Explanation of the challenge
Given an input, return what shapes it could be. There are only a couple options.
Square
Triangle
Square
A square is in the following format:
XXXX
XXXX
XXXX
XXXX
So, in this example, the input would be:
16
And the output would be:
1 or "Square"
Triangle
We are only checking for equila... | stackexchange_codegolf |
We will say a string \$x\$ is cyclic maximal if there is no way to cycle its elements to get a lexicographically larger string. In other words there is no \$a\$ and \$b\$ such that \$a \oplus b = x\$ and \$b \oplus a > x\$, where \$\oplus\$ is concatenation.
For example [3,2,3,3] is not cyclic maximal because you can c... | stackexchange_codegolf |
Goal
As the title suggests, write a radix sort function (either MSB or LSB is fine) that accepts two parameters:
an array of values of any type (you can assume that they are all of the same type / class, etc.)
a function (or function pointer, depending on your language) that takes a single parameter of the same type a... | stackexchange_codegolf |
When I was a child I used to play a variation of Snap to stake soccer trading cards.
"Game" is an overstatement because the only role of the players is to secretly prepare their starting piles. As the game starts there are no choices other than just perform the game algorithm.
Rules
There is no maximum number of player... | stackexchange_codegolf |
This challenge is quite simple to conceptualise, but likely a lot harder to execute.
In this challenge, the program will have to detect the number N of its characters that have been randomly changed (at least half of the program will always remain). Then, it will have to output the Nth prime number.
A 'change' can only... | stackexchange_codegolf |
This is a somewhat proof-golf-like cops-and-robbers challenge. This is the robbers' thread; the cops' thread is here.
Robbers
The cops will post abstract rewriting systems. Your task is to crack their submissions by proving that the target string either can or can not be reached from the source string by applying their... | stackexchange_codegolf |
Your task: make a hexagonal triangle with side length n, where n is a positive whole number or 0.
First, let me define a hexagon:
/ \
| |
\ /
(Amazing ASCII art, right?)
Hexagons can be linked together by sharing sides:
/ \ / \
| | |
\ / \ /
/ \
| |
/ \ /
| |
\ /
A hexagonal triangle is the fo... | stackexchange_codegolf |
It is fairly simple to, given a number n, create a range from 0 to n-1. In fact, many languages provide this operation as a builtin.
The following CJam program reads an integer, and then prints out such a range (Try it online!):
ri,
Notice that it prints out numbers without a separator.
The Challenge
Your task is to r... | stackexchange_codegolf |
Your task
Given a simple regular expression, you have to count how many strings of length n have a match of length n with the given simple regex. This will just be a subset of regexs. Like, no lookaheads or named groups or recursion or whatever weird things regexs have.
Simple regular expression
For the purposes of thi... | 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 |
Let us assume that we have number X.
Let us assume that we have positive integer "components" (C) of this X number.
We can add these components together like C1+C2+...+Cn = X.
We have N as limit of number of components.
We have B as limit of biggest component
Distribution: if we have [8;8;5] then avg of components is ... | stackexchange_codegolf |
Given three non-negative integers y, m, and d (of which at least one must be positive) and a valid date with a positive year (in any reasonable format that includes the year, month, and day, and no additional information), output the date that is y years, m months, and d days after the original date.
The Gregorian cale... | stackexchange_codegolf |
Problem
A fact you may have noticed about factorials is that as \$n\$ gets larger \$n!\$ will have an increasing number of \$0\$s at the end of it's base \$10\$ representation. In fact this is true for any base.
In this challenge you will be given a base \$b > 1\$ and an integer \$n > 0\$ and you will determine the sm... | stackexchange_codegolf |
Background
MQTT (Message Queuing Telemetry Transport) is an ISO standard publish-subscribe-based messaging protocol (Wikipedia).
Each message has a topic, such as the following examples:
myhome/groundfloor/livingroom/temperature
USA/California/San Francisco/Silicon Valley
5ff4a2ce-e485-40f4-826c-b1a5d81be9b6/status
Ge... | stackexchange_codegolf |
Inspired by How do you write dates in Latin?
Challenge
Given a month-and-day date, output that date in abbreviated Latin, as explained below.
Input
Input is flexible, following conventions from other date and sequence challenges. You may choose to:
Take a date in mm/dd or dd/mm format or two separate month,day argumen... | stackexchange_codegolf |
Here is a challenge:
What is the shortest possible compiled program? Writing one line programs are fun, but they often lean on language libraries that get pulled into the final bits. How lean can you get the 'scaffolding' that supports and hooks into the compiled instructions? This seems like an interesting question be... | stackexchange_codegolf |
So task is simple, given array of numbers and result, you need to find what operations you need to use on numbers from array , to obtain requested result.
Let's make it simple for start, and allow only basic operations such as: addition, subtraction, multiplication and division.
Example:
Input : [5,5,5,5,5] 100
Outpu... | stackexchange_codegolf |
This thinking exercise is inspired from Super Chafouin's question "Just Repeat Yourself" in which the phrase "Do not repeat yourself!" had to be outputted using code that was basically a series of doubled characters, inclusive of newlines, so code like:
((zz==0011))&&((mm++&&mm++&&mm++&&mm++&&mm++&&nn--&&nn--&&nn--&&n... | stackexchange_codegolf |
Definition
A number is positive if it is greater than zero.
A number (A) is the divisor of another number (B) if A can divide B with no remainder.
For example, 2 is a divisor of 6 because 2 can divide 6 with no remainder.
Goal
Your task is to write a program/function that takes a positive number and then find all of it... | stackexchange_codegolf |
I thought it'd be interesting to turn AoC day 3 puzzle into a Golfing Challenge, so here it is.
Task
Find the number of # you'd encounter in an 11x11 grid (consisting of # and .) that repeats itself (to the right side), starting at the top left corner, which is always a .. You will need to check the position that is \$... | stackexchange_codegolf |
Today is November 11th, which for many regions is Remembrance Day.
If you don't know anything about the history or context of Remembrance Day, you can read about it in the wiki page, but it's not relevant for this challenge.
In Flanders Fields is a poem that is pretty well-known relating to this day. It opens like so:
... | stackexchange_codegolf |
Y'know, we've had a lot of "alphabet" challenges recently. (one two three four five.) While I love a good challenge, and those challenges were very fun, I think it's time for a change of pace. We need to exclude such challenges in the future. It's time for automation!
You're going to find some alphabets for me, and for... | stackexchange_codegolf |
In Elixir, (linked) lists are in the format [head | tail] where head can be anything and tail is a list of the rest of the list, and [] - the empty list - is the only exception to this.
Lists can also be written like [1, 2, 3] which is equivalent to [1 | [2 | [3 | []]]]
Your task is to convert a list as described. The ... | stackexchange_codegolf |
Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer greater than zero.
Rules
This is code-golf, so shortest answer wins.
Since unary behaves weirdly, the behavior with inpu... | stackexchange_codegolf |
Note: This is the radiation-hardening version of my previous challenge Pristine Bit Checking. This should be much more difficult than that one.
Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different.
Fo... | stackexchange_codegolf |
Gray Code is a number system where only 1 bit of the number changes from one number to the next number. Print the 8 bit Gray Code values of 0 to 255.
Shortest Code wins!
Start of output:
0 00000000
1 00000001
2 00000011
3 00000010
4 00000110
5 00000111
6 00000101
7 00000100
...
You only have to print the Gra... | stackexchange_codegolf |
Write a function (or macro) that returns true if and only if at least one of its arguments contains a call to the function itself and false otherwise.
For example:
int a=function(); //a==false
int b=function(0); //b==false
int c=function(function(0)); //c==true
int d=function(3*function(1)+2); //d==true (weakly-typed l... | stackexchange_codegolf |
Background
In JIS X 0208 a 94 by 94 map (kuten (区点)) is defined to encode Chinese characters (kanji), phonetic moras (kana) and other symbols. Along with this standard there are 3 different encodings that maintain 1-1 correspondences with the map, namely JIS, Shift_JIS and EUC. These encodings take 2 bytes for each cha... | stackexchange_codegolf |
Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District.
Introduction
In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", who is a member of a "group", and has certain "permissions" represented by a ten-character string such as "drwxrwxrwx".... | stackexchange_codegolf |
Output or display the following three lines of text, exactly as they are shown below. A trailing newline is accepted.
bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ
That block of text is the same as the one below, but where the n'th column is rotated n times downward:
!"#$%&'()*+,-./... | stackexchange_codegolf |
Briefing
The difficulty of a Code Golf question can be calculated as such:
$$\text{clamp} \left( \left\lceil \left( \frac v a \div 700 \right) \times 10 \right\rceil, 0, 10 \right)$$
Where \$v\$ is the number of views a question has
and \$a\$ is the number of answers a question has
and \$⌈x⌉\$ is the ceiling operator.
... | stackexchange_codegolf |
I noticed that there's no such question, so here it is:
Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please specify that in your answer.
Please only one tip per answer (see here).
| stackexchange_codegolf |
Write a program or a function that outputs the integer number of answers this question has. Your solution should still work as more answers are added.
Languages that run in a browser may be run from the js console while on this page. Otherwise, you'd probably have to download this page. Multi-language solutions, e.g. w... | stackexchange_codegolf |
Given an integer \$N\$, print or return integers \$a\$, \$b\$, and \$c\$ that satisfy all of the following conditions, if such integers exist:
\$a \times b + c = N\$
\$a\$, \$b\$, and \$c\$ are all prime
\$a > b > c\$
If no valid combination of integers exist, you should return nothing, 0, None, an empty list, or rai... | stackexchange_codegolf |
This is a cops-and-robbers challenge. The Cops' thread to this challenge is here
An interesting question to think about is the following:
If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about?
For example if I want to talk about the positive integers... | stackexchange_codegolf |
I just discovered this site and this is my first question, I hope I'm doing it correctly.
The challenge is the following, you must write a code that prints all the prime numbers of \$n\$ digits. Since this problem is computationally complicated, I think that one way to simplify it is to give a number \$m\$ that will be... | stackexchange_codegolf |
What could be more polar opposites than chess and demolition derby. You would think that no one who enjoys one would enjoy the other... until today.
Rules
The starting position is a standard chess board:
RNBQKBNR
PPPPPPPP
PPPPPPPP
RNBQKBNR
Looks normal enough, until you find out it's an EVERY PIECE FOR ITSELF, ... | stackexchange_codegolf |
Background
A triangular grid is a grid formed by tiling the plane regularly with equilateral triangles of side length 1. The picture below is an example of a triangular grid.
A triangular lattice point is a vertex of a triangle forming the triangular grid.
The origin is a fixed point on the plane, which is one of the ... | stackexchange_codegolf |
Your task is to write a program that runs in two different languages, and does the following:
In one language, it palindromizes a given string.
Take the string. abcde
Reverse the string. edcba
Remove the first character. dcba
Glue it onto the original string. abcdedcba
In another language, it depalindromizes a give... | stackexchange_codegolf |
Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination.
Given only one input integer \$n\$, calculate \$f(n,n)\$ where
$$ f(x,y)=
\begin{cases}
x & \text{if } y=0 \\
f(\left(\sum_{k=1}^xk\right),\text{ }y-1) & \text{otherwise}
\end{cases}
$$
If ... | stackexchange_codegolf |
bool doYouFeelLuckyPunk, actuallyIsLucky;
doYouFeelLuckyPunk = Harry.catchyPhrase();
actuallyIsLucky = Bandit.rollDice();
if(doYouFeelLuckyPunk) {
Bandit.grabGun();
if(!actuallyIsLucky)
Harry.useMagnum()
else {
Harry.tisButAScratch()
}
else
Bandit.surrender();
We all know how this p... | stackexchange_codegolf |
Introduction: Deep Thought calculated The answer to life the universe and everything in a period of 7.5 million years, the solution was 42.
Write a program in any programming language that takes approx 75 seconds to calculate, starting from whatever you want, and output the number 42.
N.B. The number 42 must be calcula... | stackexchange_codegolf |
This is perhaps one of the classical coding challenges that got some resonance in 1986, when columnist Jon Bentley asked Donald Knuth to write a program that would find k most frequent words in a file. Knuth implemented a fast solution using hash tries in an 8-pages-long program to illustrate his literate programming t... | stackexchange_codegolf |
Given a ragged list, e.g.
[[4, 7], [5, 3, [], [6, [2]]]]
Your challenge is to sort only the numbers in it. For example, with the above, the result would be
[[2, 3], [4, 5, [], [6, [7]]]]
The shape of the output should remain the same, only the numeric contents should change.
This is code-golf, shortest code wins!
All... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.