instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Related: Is this quadrilateral cyclic?
Background
A tangential quadrilateral is a quadrilateral which has an incircle:
Examples include any square, rhombus, or a kite-like shape. Rectangles or parallelograms in general are not tangential.
Task
Given the four vertices of a quadrilateral (as Cartesian coordinates), dete... | stackexchange_codegolf |
emanresu A posted a challenge to reconstruct an ordered list of integers from its unordered set of unordered prefixes. Many users (beginning with xnor's answer) noticed that summing each unordered prefix led to a very short solution. Well, let's cruelly take that possibility away by using data that isn't integers!
A fe... | stackexchange_codegolf |
Anyone remember these things?
Your challenge today is to make the shortest program that involves your pet growing into 1 of at least 7 different creatures.
Your creature will grow into different forms depending on a random percentage from an RNG and the name you give it (from STDIN or equivalent for your language) a... | stackexchange_codegolf |
Here's a programming puzzle for you:
Given a list of pairs of strings and corresponding numbers, for example, [[A,37],[B,27],[C,21],[D,11],[E,10],[F,9],[G,3],[H,2]], output another list which will have just the strings in the following manner:
The total count of any string should be exactly equal to its corresponding ... | stackexchange_codegolf |
Write two programs, each taking a string s and a number n ≥ 0, such that:
The first program prints s n times, separated by newlines.
The second program prints each character of s n times, with repeated characters separated by newlines.
Every character at column x, line y in one program equals the character at column y... | stackexchange_codegolf |
This challenge is from a game called Keep Talking And Nobody Explodes.
Memory is a fragile thing but so is everything else when a bomb goes off, so pay attention! – from the manual
The Objective
A number from 1–4 is given as the "display", along with scrambled numbers 1–4 as the "buttons."
The output must be the label ... | stackexchange_codegolf |
Let's say we have some arbitrary number:
For example 25. We also have some "tokens" (poker chips, money, something similar) with different values.
Values of tokens are
2; 3; 4; 5.
"Tokens" are limitless
You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so.
F... | stackexchange_codegolf |
Taking a positive integer n as input, print the sample space of n consecutive coin flips. The coin is fair, with two sides H and T, each with probability 0.5.
For example,
Input - 3
Output -
HHH
HHT
HTH
HTT
THH
THT
TTH
TTT
Rules
Standard loopholes apply
You may print the elements out of order, but all of them should ... | stackexchange_codegolf |
Inspired by this video by Matt Parker
The distances between the letter keys of a QWERTY keyboard are somewhat standardised. The keys are square and both the horizontal and vertical spacing are 19.05mm (so if there were no gaps between the keys, their side lengths would be 19.05mm), and the three rows of keys are offset... | stackexchange_codegolf |
Yes is a stack-based language that has a few space-separated instructions:
yes: Push 1 to the stack
no: Push 0 to the stack
what: Push the input to the stack (input is taken at the start of program execution and is the same for the whole execution)
sure: Increment the last item in the stack
nah: Decrement the last item... | stackexchange_codegolf |
The JavaScript compressor RegPack uses a very simple string compression algorithm. Given a piece of code, it will make a list of characters that aren't used in that code and use them to delimit repeated strings that are inserted back into the string.
To show how strings are compressed, it's necessary to show how the de... | stackexchange_codegolf |
(First challenge, please let me know if there are any problems with it.)
A heterogram is a word where no letter of the alphabet occurs more than once, and a palindrome is a phrase that is the same backwards and forwards.
The challenge here is to write a piece of code that takes in a word (just letters) as input, and o... | stackexchange_codegolf |
Introduction
My calculator is behaving weird. Sometimes when I type in an 8 it displays a 2. And sometimes when I type in a 6 it displays a +. Some buttons are mixed up!
Could anyone help me determine which?
Challenge:
Input: List of incorrect equations, with correct results.
Output: The two buttons that are swapped.
F... | stackexchange_codegolf |
Challenge
In this challenge, all numbers are in \$\mathbb{N}_0\$.
Create a function or program that, when given a number \$N\$ and a tuple of \$k\$ numbers \$(n_i)\$ (all ≤ \$N\$), returns the number of ways \$N\$ can be written as a sum of \$k\$ integers (\$x_1 + x_2 + ... + x_k\$) such that \$n_i \le x_i \le N\$.
The... | stackexchange_codegolf |
Given a constructible point \$(x, y) \in \mathbb R^2\$, output the steps required to construct \$(x, y)\$
Constructing a point
Consider the following "construction" of a point \$(\alpha, \beta)\$ in the Cartesian plane:
Begin with the points \$(0, 0)\$ and \$(1, 0)\$. Then, more points can be added by performing a fini... | stackexchange_codegolf |
Context:
A reclusive billionaire has created a game show to attract the world's best and brightest programmers. On Mondays at the stroke of midnight, he chooses one person from a pool of applicants to be the contestant of the week, and provides them with a game. You are this week's lucky contestant!
This week's game:... | stackexchange_codegolf |
The Venetian election system was... complicated.
The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St Mark's Square and chose the first boy he met who drew from the urn a ballot for each councillor and only those 30 who got the wo... | stackexchange_codegolf |
You left your computer for too long, and it went to sleep. Wake it up again by printing the following coffee maker.
________._________
| | \ - /
| || | \ - /
| || |___\___/
| || | X
| | ___
| | / - \
|______| / - \
| ____ | /_______\
||7:30||__________
||____| |
|______... | stackexchange_codegolf |
Given a string containing only letters (case-insensitive), split it into words of uniformly random lengths, using the distribution below, with the exception of the last word, which can be of any valid length (1-10). Your output is these words, as a space-separated string ("test te tests"), an array of strings (["test",... | stackexchange_codegolf |
I'm sure this is going to spark some controversy, but let's do a practical demonstration.
The objective of this is simple, using the new code of conduct and no input, print out my pronouns ( "he/him", "he him" is also acceptable).
Here's the challenge. This is a classical polyglot contest!
This means that the first... | stackexchange_codegolf |
Your task is to write a program or function
that determines whether a number is divisible by another.
The catch is that it should give an answer as soon as possible,
even if not all digits of the number have been given.
Your program should take an integer D ≥ 2
and then a series of digits as input.
These represent the ... | stackexchange_codegolf |
You will be given a two-dimensional array and a number and you are asked to find whether the given matrix is Toeplitz or not. A matrix is a Toeplitz matrix if every descending diagonal, going from left to right, has only one distinct element. That is, it should be in the form:
Input Format:
You will be given a functio... | stackexchange_codegolf |
Sociable numbers are a generalisation of both perfect and amicable numbers. They are numbers whose proper divisor sums form cycles beginning and ending at the same number. A number is \$n\$-sociable if the cycle it forms has \$n\$ unique elements. For example, perfect numbers are \$1\$-sociable (\$6\to6\to\cdots\$) and... | stackexchange_codegolf |
Currently, the Stack Exchange network has nearly 150 sites. These sites are as follows:
Computer Graphics
Portuguese Language
elementary OS
Open Source
Law
Русский язык
Mythology
Health
Stack Overflow на русском
CiviCRM
Woodworking
Music Fans
Vi and Vim
Coffee
Engineering
Lifehacks
Economics
History of Science and Math... | 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 |
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 |
Challenge description
A Langford string of order N is defined as follows:
The length of the string is equal to 2*N,
The string contains first N letters of the English alphabet, each letter appearing twice,
For each pair of the same letters, there are M letters between them, where M is that letter's position in the alp... | stackexchange_codegolf |
It turns out that my toaster is a tad broken. It lost WiFi (You know, it's one of those newfangled smart toasters), and its been going bonkers! Since it no longer works, I've been having to hack into my breakfast's source code and run Plate.bread.toastAs(3); every morning. Will you help?
My toaster takes one input: the... | stackexchange_codegolf |
The Task
Create a function/subroutine which returns 1. You can make it as elaborate as you like, as long as it returns 1.
The Rules
The entry with the most upvote wins - just like any popularity contest. Good luck!
| stackexchange_codegolf |
You are a taxicab driver in San Francisco. As is typical of taxicab drivers, you are navigating a grid where the only valid directions you can move are the left, right, up, and down. However, San Fransisco is very hilly so the distance between two adjacent intersections is not necessarily the same. More specifically, t... | stackexchange_codegolf |
Write a program or a function in your favorite programming language that will take as input a number n (integer or non-integer) between 0 and 100 inclusive, and output the corresponding grade as outlined below:
If 0 < n <= 40, then output E.
If 40 < n <= 55, then output D.
If 55 < n <= 65, then output C.
If 65 < n <= ... | stackexchange_codegolf |
Your task is simple: given a number as an input, you have to print the English name of the chemical element with that atomic number, up to and including ununoctium. For example, for an input of 77, your program has to print Iridium, and nothing else.
You can use any language, but no library (or other, in-built feature)... | stackexchange_codegolf |
Given guaranteed strictly positive integers \$w\$ and \$n\$, output
An equilateral triangle array with side length \$w\$, filled with two distinct, consistent values. I'll call these 0 and 1 but they do not have to be equal to 0 and 1.
The number of 1s inside this array must be equal to \$n\$.
The output triangle must... | stackexchange_codegolf |
A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python.
Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sortin... | 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 |
There are important differences between Python 2 and 3, so it's often useful to know which version of the interpreter is running your code. The straightforward method is something like this:
def get_python_version():
import sys
return sys.version_info.major
But you can exploit other differences to come up with... | stackexchange_codegolf |
What general tips do you have for golfing in Smalltalk? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Smalltalk (e.g. "remove comments" is not an answer).
Smalltalk is a purely object-oriented language created by Alan Kay. The two links are GNU Small... | stackexchange_codegolf |
After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages?
Your answer needs to accept boolean input b and output the text "true" or "false". The same code needs to output, when run in another language, "waar" or "onwaar" or any other trans... | stackexchange_codegolf |
I'm new to code golf challenges. My problem came up in Advent of Code 2020 Day 8
The input is an array of arrays. In part two of the problem one needs to run several trials to produce a result by changing an element in the input array. My current code is this (comments added to explain what's going on):
p input.each_wi... | stackexchange_codegolf |
Note that this challenge requires no handling or understanding of complex numbers.
Given a non-empty square matrix where every element is a two-element (Re,Im) integer list, determine (giving any truthy/falsy values or any two consistent values) whether this represents a Hermitian matrix.
Note that the input is a 3D ar... | stackexchange_codegolf |
Today's challenge:
Given an ordered list of at least 3 unique integer 2D points forming a polygon, determine if the resulting polygon is Rectilinear.
A polygon is rectilinear if every interior angle is a right angle. The edges do not necessarily have to be purely vertical or horizontal (parallel to the x or y axis), ... | stackexchange_codegolf |
A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. For those who are not aware of how knights in chess work, knights are capable of moving in an L shape (see fig. 1). (Or a ߆ shape, or even a \ shape depending on who you ask.) Essentially, in one move,... | stackexchange_codegolf |
ProSet is a classic card game that is played normally with 63 cards. One card has 6 colored dots on it, like below
The rest of the cards are missing some of these 6 dots, but each card has at least 1 dot. Every card in the deck is different. Below are some example valid cards.
A ProSet is a nonempty set of cards such... | stackexchange_codegolf |
The formatting order of dates is one of the most complex and divisive issues the world faces today. Some of us vehemently argue that Month/Day/Year is appropriate, considering that's how we say dates out loud. Others loudly proclaim that Day/Month/Year is best, because it puts the terms in ascending order of the durati... | stackexchange_codegolf |
In mathematics, a cyclic quadrilateral is one whose vertices all lie on the same circle. In other words, every vertex is on the circumcircle of the other three. For more information, see the MathWorld article.
Examples
These quadrilaterals are cyclic:
This trapezoid is not cyclic.
(Images from Wikipedia)
Objective
Gi... | stackexchange_codegolf |
Problem
You are given a binary string A of length N.
You can perform the following type of operation on the string A:
Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$)
Change \$A_i\$ and \$A_j\$ to \$Ai \oplus Aj\$. Here \$\oplus\$ represents the bitwise XOR operation.
Input
A binary string con... | stackexchange_codegolf |
Background: Too many illegal immigrants from Blandia are crossing the border to Astan. The emperor of Astan has tasked you with digging a trench to keep them out, and Blandia must pay for the expenses. Since all typists have been furloughed until the trench is arranged, your code must be as short as possible.*
Task: Gi... | stackexchange_codegolf |
Let's play some code golf!
Given a tic-tac-toe board state (Example:)
|x|x|o|
|x|o|x|
|o|o|x|
Determine whether a game is a win a lose or cat. Your code should output any of these options given a state. The above game should output lose
Just to be clear: a win is defined as any 3 xs in a row (diagonal, horizontal, ver... | stackexchange_codegolf |
See Also: Recognition
Introduction
You've now been taken off the speed camera development team (let's face it, your code is nowhere near production code standards) and are now working on a program to extract information about the car from the number plates. Of course, you've caught the code golf bug and want to write t... | stackexchange_codegolf |
Most computer keyboards feature a small integrated LED light,
indicating the current input mode, as controlled with the CAPS LOCK button.
Your task is to blink it:
Turn it on;
Wait for 0.5 (+/-0.1) seconds;
Turn it off again.
Video footage of the LED blinking is highly appreciated !
Rules
You can blink a different ... | stackexchange_codegolf |
This is a Cops and Robbers challenge. This is the cop's thread. The robber's thread is here.
As a cop, you must pick any sequence from the OEIS, and write a program p that prints the first integer from that sequence. You must also find some string s. If you insert s somewhere into p, this program must print the second ... | stackexchange_codegolf |
My doubles pickleball group often has five people. Four are playing and one is awaiting the next game. We can represent the state of the game with a string of five characters like abCde. This indicates that a and b are playing against c and d with c serving. We want to write a routine that gives the possible positions ... | stackexchange_codegolf |
Problem
Assume you have a single 7-segment display without a decimal point, so 7 "lines" that can be labelled A through G as seen here.
This display will only show the numbers from 0 to 9 as usual, like so:
Any time this display changes from one number to another, some of its lights will have to change their state fr... | stackexchange_codegolf |
I need to prepare digits made of cardboard to display some number (example). I don't know beforehand which number I should display - the only thing I know is that it's not greater than n.
How many cardboard digits should I prepare?
Example: n = 50
To display any number in the range 0...50, I need the following digits:
... | stackexchange_codegolf |
MS Paint was always a great time waster, but it was shunned by most graphic designers. Perhaps people lost interest because of the jarring color palette, or because of limited undo levels. Regardless, it's still possible to generate beautiful images with just the standard brush and default color palette.
Challenge
Usin... | stackexchange_codegolf |
When translating DNA into proteins, the ribosomes read the sequence of DNA nucleotides 3 by 3. Each set of 3 nucleotides is called a codon, and each codon encodes for an amino acid, with some redundancies. Here's the conversion table used by most organisms (table is read left, top, right):
Humans and most other organi... | stackexchange_codegolf |
Given a string s and a positive integer N, gradually duplicate each character more and more until N duplicates, and then staying at N duplicates until N characters away from the end, then step down again.
For example, given abalone and 3:
a we start with 1 copy
bb then 2 copies
aaa then 3 copies, which is our sec... | stackexchange_codegolf |
Background
SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely S, K, and I instead of lambda abstraction. Unlike lambda calculus, beta reduction is possible only when a combinator is given enough arguments to reduce.
T... | stackexchange_codegolf |
Let me explain one by one the above terms...
We will call \$\text{Z-Factorial}(n)\$ of a positive integer \$n\$, \$n!\$ (i.e. \$n\$ factorial) without any trailing zeros.
So, \$\text{Z-Factorial}(30)\$ is \$26525285981219105863630848\$ because \$30!=265252859812191058636308480000000\$
We will call Modified Z-Factorial ... | stackexchange_codegolf |
You are given two arbitrary integer lists, e.g. [-10, 99, -6, 43], [100, 32, 44]. You are to pick one integer from each list and sum them up, then sort the best pairs ordered by the absolute distance to 100 in ascending order. Paired up integers from each list shall not be repeated in the output.
For instance, we have
... | stackexchange_codegolf |
Key Links
Dwarf question
Chat room
Game
Controller Interface
Troll league table
<script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>Sc... | stackexchange_codegolf |
There is a helicopter flying 500 meters from the ground. It can fly up 100 meters, which takes 1.0 secs. Or if it doesn't fly up it will fall 200 meters, which also takes 1.0 secs - This means if the instruction is anything other than "Fly" the helicopter falls. Build a program that takes input of a list of instruction... | stackexchange_codegolf |
This challenge was posted as part of the April 2018 LotM challenge, as well as for Brain-flak's 2nd birthday
I was thinking about what the most efficient way to encode brain-flak programs would be. The obvious thing to do, since there are only 8 valid characters, is to map each character to a 3-bit sequence. This is c... | stackexchange_codegolf |
This is a Code Golf challenge.
Flood is a game in which the player is presented with a game board such as this:
On each turn, you choose a colour (on the link above, by clicking a square containing that colour), and the cell in the top-left corner is filled with that colour - this colour will absorb all adjacent cells... | stackexchange_codegolf |
The Challenge
Input: alphanumeric string. You can assume that the string will only contain the characters [0-9A-Z]. This can come from a parameter, command line, or STDIN. Digits are always before letters in terms of the base. Think like an extended version of HEX.
Output X,Y Such that Y is the minimum base required to... | stackexchange_codegolf |
Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.
An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered speci... | stackexchange_codegolf |
Note: This challenge has been changed to eliminate the strict whitespace manipulation requirements that made this challenge low-quality. Some rules regarding whitespace have been changed.
I'm rather good at mental math, particularly adding positive integers in my head. Here is my method for adding the numbers together... | stackexchange_codegolf |
There was a discussion going on in TNB once about the best temperature scale, and we agreed on something: Take the average of all four main temperature scales! That is, Celsius, Kelvin, Fahrenheit, and Rankine (Sorry Réaumur).
So, now the issue is, most people don't use this system. So, I need a program to convert back... | stackexchange_codegolf |
Your task is to output a spaceship of size n with shooters/guns and n bullets of character - (with spaces in between each bullet) for each gun
Rules
If n is odd, you must output the guns every even numbered row
If n is even, you must output the guns every odd numbered row
All rows with guns must have n+1 # character... | stackexchange_codegolf |
Background
From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, and all the denominators differ from each other. The value of an expression of this type is a positive rational number ... | stackexchange_codegolf |
Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two activities will be on the same day, and all activities are guaranteed to fit within the calendar box.
The calendar has the date... | stackexchange_codegolf |
The barfoos, a hypothetical alien species, go about charity in an interesting way.
Every morning, barfoo Specialists come up with an ordered list of causes to donate to, and for each cause they recommend what quantity of resources should be donated.
That wasn't the weird part. Here's the weird part:
A random civilian b... | stackexchange_codegolf |
The Challenge
Create a program or function that takes no input, and outputs (or returns):
I'm a programming paradox — no I'm not.
Without using a character twice in any string, or digit twice in any integer.
Rules
You may not use any character twice within a string. For example, the word "test" would violate this ru... | stackexchange_codegolf |
Introduction
Most of you are familiar with the merge sort algorithm for sorting a list of numbers.
As part of the algorithm, one writes a helper function called merge that combines two sorted lists into one sorted list.
In Python-like pseudocode, the function usually looks something like this:
function merge(A, B):
C... | stackexchange_codegolf |
Header:
this question has a very close duplicate, but the other question requires a difference between versions of the languages, instead of a difference between different implementation. this means that all answers from the almost-duplicate are invlid here. this is also my first question, so please don't be harsh.
the... | stackexchange_codegolf |
Generate the following list of lists consisting of the unique last digits of the powers from 1 to 9 for the numbers [0..9]
[[0], [1], [2, 4, 8, 6], [3, 9, 7, 1], [4, 6], [5], [6], [7, 9, 3, 1], [8, 4, 2, 6], [9, 1]]
e.g. For the number 2 we have:
\$2^1,2^2,2^3,2^4,2^5,... \to 2,4,8,16,32,64,128,... \to 2,4,8,6,4,8,..... | stackexchange_codegolf |
This rar file, when decompressed, gives a 65024-byte exe file. Requiring you to output the contents of that file would be absolutely no fun.
But you aren't required to do that. Actually, you're to do something opposite: Output a binary of the same length (65024 bytes), such that no byte equals the byte at same position... | stackexchange_codegolf |
Write a program to solve a series of linear equations as short as possible. It must solve arbitrary number of equations problems. They can inputted however you like, coefficients of augmented matrix is probably the easiest. The program doesn't have to handle non-integer coefficients or solutions. No degenerate or inval... | 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 |
In this challenge I will ask you to find a QR decomposition of a square matrix. The QR decomposition of matrix A is two Matrices Q and R such that A = QR. In particular we are looking for Q to be an orthogonal matrix (that is QTQ=QQT=I where I is the multiplicative identity and T is the transpose) and R to be a upper... | stackexchange_codegolf |
Take as input two strings \$A\$ and \$B\$. Output a string \$C\$ that is \$A\$ but with two characters swapped such that the Levenshtein distance \$d(C,B)\$ is as small as possible. You must swap two characters and you cannot swap a character with itself, although you may swap two identical characters in different po... | stackexchange_codegolf |
You have to write a program, implementing a function digitsum(int i). The program has to modify its own code (for languages, where this is not possible with f.e. reflection, please be creative) to get itself to solve the goal.
You start with
function digitsum(int i){
return i;
}
and implement an evolutionary algo... | stackexchange_codegolf |
B-splines are defined using a set of "knots", "control points", and degree. For the purposes of this challenge, the control points are not needed.
The knots are simply a list of strictly increasing real values (note that real B-splines may have repeated knots, for the purposes of this challenge assume knots are all uni... | stackexchange_codegolf |
Challenge :
Sort the vowels (only vowels) in the given string .
Note :
Vowels are the following characters: A, E, I, O, U
Vowel sorting is cyclic i.e. After rearrangement the first vowel of sorted string goes where the original first vowel was
Input :
A string line, the original line (consisting of alphabets and wh... | stackexchange_codegolf |
Background
This challenge is about Convolutional neural networks, and its two main building blocks, namely Convolutional layer and Pooling layer.
For simplicity, we ignore the "depth" of the images and intermediate tensors, and just look at the width and height.
Convolutional layer
A convolutional layer works like a ke... | stackexchange_codegolf |
Input:
A positive integer n consisting of digits in the range 0-9.
Challenge:
If d is the highest digit in the integer, assume the base of the number is d+1. E.g. if the integer is 1256 then you shall assume it's in base-7, if it's 10110 then you shall assume it's base-2 (binary), and if it's 159 then it's decimal.
Now... | stackexchange_codegolf |
I've been developing some programs involving me fetching a vector from a url using Alpha-2 country codes (such as GET /jp.svg for Japan). Except, oh no! All the country data on my computer uses Alpha-3! That just won't do...The task is simple: Take an Alpha-3 country code (e.g. UKR) and return its Alpha-2 equivalent (... | stackexchange_codegolf |
Just over seven years ago, everybody suddenly stopped talking about the Maya people. It is time to rectify that!
For clarification, I am talking about the Mesoamerican Long Count Calendar. Your program will have as input a date in the Gregorian Calendar, and as output the corresponding date from the aforementioned Meso... | stackexchange_codegolf |
Definition
In Mathematics, Harmonic Sequence refers to a sequence where
$$a_n = \frac 1 n$$
i.e. the \$n_{th}\$ term of the sequence equals the reciprocal of \$n\$.
Introduction
In this challenge, given a positive integer \$n\$ as input, output the Partial Sum of first \$n\$ terms of the Harmonic Sequence.
Input
Yo... | stackexchange_codegolf |
Write a program that takes an undirected graph and finds the minimum cut, i.e., the set of edges that, if removed, would disconnect the graph into two or more connected components. The program should have a time complexity of \$O(n^2m)\$, where n is the number of vertices and m is the number of edges in the graph.
One ... | stackexchange_codegolf |
The task
Most Casio calculators featured a variable M, which has 3 operators related to it: M, M+, and M-
M, as you can expect, returns the value stored in the variable.
M+ takes the number on the left and add it to M.
M- does the same thing as M+, but subtract instead.
To make the challenge just a bit more difficult, ... | stackexchange_codegolf |
When I was a kid, there was a "really cool" shortcut to count to 100:
1, 2, miss a few, 99, 100
Output the exact string above, in the fewest characters possible, without using these characters: 0, 1, 2, 9
| stackexchange_codegolf |
I am currently working on a golfing language. Do you have any suggestions for this language? What are some helpful features of a good golfing language? What features do you find useful? Do you suggest a language based on variables, stack(s), tapes, registers, etc?
As usual, please post separate tips in separate answers... | stackexchange_codegolf |
You have to print out your username, by only using the characters in your username.
Standard loopholes are forbidden
This is not code-golf, so shortest does not win
Don't modify your username please
And each language be used one time
| stackexchange_codegolf |
The cardinality of the set \$\mathbb Q\$ of rational numbers is known to be exactly the same as that of the set \$\mathbb Z\$ of integers. This means that it is possible to construct a bijection between these sets—a mapping such that each integer corresponds to exactly one rational number, and vice versa.
Provide such ... | stackexchange_codegolf |
The abs() function in most languages does one thing: give the positive version of the input. Most of the times this is done using something similar to
int
abs (int i)
{
return i < 0 ? -i : i;
}
I was wondering if there is any way to do this with less bytes.
Note that this doesn't have to be more efficient, just sm... | stackexchange_codegolf |
This challenge like some of my previous challenges will have you counting free polyforms, which are generalizations of Tetris pieces.
This code-golf challenge will have you count polyomino-like polyforms on hypercubes. In particular, this challenge is to write a program that takes in three parameters:
n, which represe... | stackexchange_codegolf |
This challenge is rather simple:
You are given an array of positive (not including 0) integers, and have to select a random element from this array.
But here's the twist:
The probability of selecting an element is dependent on the value of the integer, meaning as the integer grows larger, the probability of it to get s... | stackexchange_codegolf |
Given a 2D string as input, either as a string with newlines or a list of lines, output the coordinates (x, y) of all the hashes (#) in the list. The input will only contain hashes and spaces. (and newlines, if you choose to take input as a 2D string)
If there are no hashes, you can output anything.
Output should be... | stackexchange_codegolf |
Input: binary string
Output: binary string that represents the binary input + 1
Example: Given 10111 as an input, output 11000
Limitations: Can't use arithmetic operators or functions (like + - * /)
Criterion: code-golf, the shortest code wins the big imaginary award.
| stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.