instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Problem statement
The task is to write the shortest R statement to count the cells (rows * cols) in an instance of the R type numeric data.frame. For example, the data.frame which would be displayed as
a b c
1 1 2000 NA
2 2 2000 NA
3 3 2000 1
4 4 2000 Inf
has 12 cells.
Input
The data.frame is supplied in variabl... | stackexchange_codegolf |
Draw a simple ASCII art image containing a straight line.
It's similar to this and this but with different specifications.
Input
You can modify this input format to suit your code.
integer width
integer height
integer x0
integer y0
integer x1
integer y1
Output
A filled ASCII art image of the specified width and heigh... | stackexchange_codegolf |
You have played \$N\$ matches in some game where each match can only result in one of the two outcomes: win or loss. Currently, you have \$W\$ wins. You want to have a win percentage of \$P\$ or more, playing as few matches as possible. Output the minimum win streak that you need. Assume the current win streak is at \$... | stackexchange_codegolf |
Task - The title pretty much sums it up: raise an integer x to power x, where 0<x.
Restrictions:
Use of exponentiation, exp(), ln(), and any other powers-related language built-ins, like pow(), x^x, x**x is forbidden.
You can assume that the given integer fits the limits of the programming language of your choice.
Te... | stackexchange_codegolf |
The French spell out numbers in a peculiar way.
1-16 are "normal"
17-19 are spelled out 10+7. 10+8, 10+9.
20-69 are "normal" (OK, OK! Not really, but they are in this challenge)
70-79 are 60+10, 60+11 ... 60+10+7, 60+10+8, 60+10+9.
80-99 are 4*20, 4*20+1, 4*20+2 ... 4*20+16, 4*20+10+7, 4*20+10+8, 4*20+10+9
Challen... | stackexchange_codegolf |
the question is "complete this subtraction by replacing the asterisks with digits so the numbers 1-9 only appear once each"
9**
-*4*
____
**1
my code tries random numbers until it works, and displays the answer. here is the entire html app. I want one to fit in a tweet at 140 characters (not counting tags)
<scri... | stackexchange_codegolf |
(This is my first Q here, and I don't know much about code golfing.)
Your aim is to predict the winner of an ongoing Snakes and Ladders game.
INPUT
A single number (2-1000) indicating the number of spaces on the board, say x.
Another number (2-4) indicating number of players, say n.
n numbers, each giving the position... | stackexchange_codegolf |
Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both.
Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible at this point...
Details:
Must be in a single source file.
Any version of Fortran and any Lisp are allowed (specify whic... | stackexchange_codegolf |
A prime number is a positive integer that has exactly two divisors 1 and the number itself. For example number 7 is a prime since it is divisible by 1 and 7. Number 1 is not a prime since it has only one divisor. Write a program or function that produces all even prime numbers.
This is a code golf challenge, shortest a... | stackexchange_codegolf |
The autokey cipher is closely related to the Vigenère cipher (both were invented by Blaise de Vigenère). Decryption involves the encrypted message and the key. For simplicity, let us assume all characters in the message and key are lowercase letters (no spaces, numbers or symbols etc.).
How to decrypt the cipher
Conve... | stackexchange_codegolf |
Your challenge today is to write a program or function which takes a list l and gives the positions in l at which each successive element of l sorted appears.
In other words, output the index of the smallest value, followed by the index of the second smallest value, etc.
You can assume that the input array will contain... | stackexchange_codegolf |
Challenge
¡We're going to give exclamation and question marks inverted buddies!
Given a body of text containing sentences ending in ., ?, or !, prepend inverted question marks, ¿, to interrogative sentences (sentences ending in ?) and inverted exclamation marks, ¡, to exclamatory (sentences ending in !). Sentences endi... | stackexchange_codegolf |
In this challenge you will receive a list of positive integers \$W\$ called a word, and a square symmetric matrix \$M\$. Your task is to determine if the word can be turned into the empty list by applying a series of valid moves.
The valid moves are:
If two consecutive values in the list are equal you may remove them ... | stackexchange_codegolf |
Caves and Cliffs edition
Part 1, Very related
You're given a piece of ASCII art representing a piece of land, like so:
/‾\ _ __
__/ _/ \‾
_/ __/‾\ |
/ / ‾\ |
\_/‾ \_/
But unlike in the previous challenge, the terrain is mountainous, with caves and cliffs, and can turn b... | stackexchange_codegolf |
Basing on this SO question.
Challenge is rather simple: given a date period in the format YYYYMM output it in the format MMMYY.
Rules:
The input will be a number or a string exactly 6 characters long, consisting only of digits.
Last two digits will be between 01 and 12.
Output must be in the form MMMYY, where MMM repr... | stackexchange_codegolf |
I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application.
new Int32Array([...new Float32Array(b)].map(f=>f<0?f*32768:f*32767)
The examples in the wild I've seen convert each float individually to avoid static, gaps, glitches when the audio recording i... | stackexchange_codegolf |
We are used to the term "squaring" n to mean calculating n2. We are also used to the term "cubing" n to mean n3. That being said, why couldn't we also triangle a number?
How to triangle a number?
First off, let's pick a number, 53716.
Position it in a parallelogram, whose side length equals the number of digits of the... | stackexchange_codegolf |
The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language.
Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language.
All Corpus words are the same as their English... | stackexchange_codegolf |
Write the shortest program that prints, in order, a complete list of iPhone iterations, according to this site:
iPhone
iPhone 3G
iPhone 3GS
iPhone 4
iPhone 4S
iPhone 5
iPhone 5c
iPhone 5s
iPhone 6
iPhone 6 Plus
iPhone 6s
iPhone 6s Plus
iPhone SE
iPhone 7
iPhone 7 Plus
iPhone 8
iPhone 8 Plus
iPhone X
iPhone XR
iPhone XS... | stackexchange_codegolf |
Note: Bot Factory KoTH (2.0) is now posted; you're probably looking for that one instead!
In this challenge, bots (consisting of JS functions) move around an infinite factory (playing field), collecting characters (UTF-16). These characters can be used to build worker bots, or droppedfor other bots to pick up.
Results
... | stackexchange_codegolf |
Input
A matrix M represented as two space separated lines of integers. Each line will have the same number of integers and each integer will be either -1 or 1. The number of integers per line will be at most 20. M will therefore be 2 by n where n is the number of integers on each of the two lines.
Your code should be... | stackexchange_codegolf |
This is code golf. The winner is the valid code with the smallest number of bytes.
Challenge
Given inputs M and N, the width and height of a rectangular grid of squares, output a polygon that satisfies the following:
The polygon edges are made up only of square edges: there are no diagonal edges - all are vertical or... | stackexchange_codegolf |
Who doesn't like to chill on a Sunday morning in summer with a chilled beer and TV or in winter playing badminton or ultimate with friends?
I always think knowing how many days you have to chill in a month keeps you well-informed and helps you plan what you want to do. Be it sitting in front of your pc and solving a co... | stackexchange_codegolf |
Intro
Imagine a list of elements and their outcomes when some non-commutative function is applied to them. For example, we will use the elements Rock, Paper, and Scissors, the outcomes Win, Lose, and Tie, and an operator * such that X*Y = what would happen if you played X against Y
As a list, you might write it this wa... | stackexchange_codegolf |
Background
This challenge is inspired by this website, which published the following diagram:
This diagram shows us that the longest Roman Numeral expression under 250 is that of 188, which requires 9 numerals to express.
Challenge
The standard symbols used to express most Roman Numerals are the following: {I, V, X, L... | stackexchange_codegolf |
Your goal is to write a full program or function that takes 5 positive integers and a string with an image filename as input [X1,Y1], [X2,Y2], N, image.jpg in any reasonable format, where:
First couple [X1,Y1] are the top left X,Y coordinates (<=20) of the blue rectangle area in the example picture (16,11).
Second c... | stackexchange_codegolf |
This task builds on: Find all reflexicons using roman numerals
An autogram is a sentence that lists the count of its own letters. Below is one of the first documented autograms found by Lee Sallows in 1983:
This pangram lists four a’s, one b, one c, two d’s, twenty-nine e’s, eight f’s, three g’s, five h’s, eleven i’s,... | stackexchange_codegolf |
I'm making a page selector for my super cool terminal-based blog program. In order for it to fit correctly into the design, it has to have some constraints.
The page selector can only display a certain number of numbers at a time due to the constraints of the UI system. If there are more characters then can fit, they m... | stackexchange_codegolf |
I have some JavaScript code in a <script> HTML tag I'd like to golf, while still remaining in the tag. How can I golf that code, if at all? Here's the code:
<script>document.write`<font color=#40e0d0 face=arial>YOU ARE IN THE BEDROOM.<br>YOU SEE CRAB NICHOLSON.<br>HE HAS NO MITTENS.<br>HIS CLAWS ARE... | stackexchange_codegolf |
A Ken Thompson virus is a virus that infects your compiler and other programs. Since it infects all your tools, you can not detect it without using tools from before the virus was introduced.
Your will create a prototype for inserting the Ken Thompson virus into code. The goal of this virus will be to allow you to (fak... | stackexchange_codegolf |
Develop a program to check if a given word is part of a language defined by the following rules:
The language has a set of rules.
The empty string is considered a valid word in the language.
Two words from the language can be concatenated to create a new word in the language.
If X is a word in the language, then "A" +... | stackexchange_codegolf |
Introduction
One day, you were showing your kid how to draw on a computer. You type mspaint.exe in the run bar. To your horror, it says "No items match your search". You must create a simple version of paint so your kid can draw!
Challenge
You must create a simple drawing program. To do this, open a white display windo... | stackexchange_codegolf |
This is a little codegolf challenge from codingame.com. I was wondering how much Python3 code is necessary (but of course answers are not limited to Python3).
Input
The first line contains one positive integer n. The second line contains n positive integers. Each consecutive integers on the second line are separated by... | stackexchange_codegolf |
Given a square matrix, output the matrix's eigenvalues. Each eigenvalue should be repeated a number of times equal to its algebraic multiplicity.
The eigenvalues of a matrix A are scalar values λ such that, for some column vector v, A*v = λ*v. They are also the solutions to the characteristic polynomial of A: det(A - λ... | stackexchange_codegolf |
There are 18 primes with distinct prime digits (A124674). Namely, they are:
\$2, 3, 5, 7, 23, 37, 53, 73, 257, 523, 2357, 2753, 3257, 3527, 5237, 5273, 7253, 7523\$
Your task is to output this sequence.
Rules
sequence rules apply. This means valid solutions may use any of the following formats:
Given some index \$n\$... | stackexchange_codegolf |
The task
A string S is constructed with the following process:
Start with S being the empty string.
Insert at some position of S a string of the form ds, where d is a nonzero digit and s is a string of d lowercase ASCII letters. We say ds is a constituent of S.
Go to step 2 or stop.
Your task is to take such a string... | stackexchange_codegolf |
Challenge
Your task is to generate a string using this sequence:
1,1,2,1,1,2,3,2,1,1,3,2,4,2,3,1,....
Which is more understandable in this format:
1
1 2 1
1 2 3 2 1
1 3 2 4 2 3 1
1 4 3 2 5 2 3 4 1
The pattern increases the number of Digits in the string by two for each increment in the Value of N
For each integer val... | stackexchange_codegolf |
What is a home prime?
For an example, take HP(4). First, find the prime factors. The prime factors of 4 (in numerical order from least to greatest, always) are 2, 2. Take those factors as a literal number. 2, 2 becomes 22. This process of factoring continues until you reach a prime number.
number prime factors
4 ... | 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 |
Thanks to HyperNeutrino for making more test cases
Often in chat, someone will ask a question, and multiple people will answer it at the same time. Usually, the person who was beaten to the gun will say "ninja'd", creating even more unnecessary chat.
Given a chat log similar to the following:
Community: Hi
Test: Hi
Ran... | stackexchange_codegolf |
Given a rectangular board of cells with some number of holes in it, determine whether it is possible to complete a "holey knight's tour" (That is, a path that visits every non-hole cell exactly once using only chess knight moves, not returning to the starting cell) that starts on the top-left cell.
For the sake of comp... | stackexchange_codegolf |
Cleaning the dishes
In this task, you will be given a bar of soap with a width of 1 or more units. You will also be given a plate, which you will have to clean, using the soap as few times as you can. The plate will be at least 1 character. You will have to output a plate with the 'clean' character representing the pla... | stackexchange_codegolf |
Your task is to print this exact text:
| | | | | |
&***********&
| Code Golf |
| e---------f |
| d___________l |
| o-------------o |
| C_______________G |
###Dennis$Dennis###
#####################
Rules
Trailing or leading newline is allowed
code-golf, so shortest code wins!
| stackexchange_codegolf |
As most of you probably know, (byte-addressable) hardware memories can be divided into two categories - little-endian and big-endian. In little-endian memories the bytes are numbered starting with 0 at the little (least significant) end and in big-endian ones the other way round.
Fun fact: These terms are based on Jon... | stackexchange_codegolf |
Suppose A and B are two good friends. A has borrowed \$n\$ dollar from B. Now B wants the money back from A and A is also ready to give it. But the problem is A has only \$x\$ dollar notes and B has \$y\$ dollar notes. They both want to keep the number of notes in exchange as low as possible.
As an example if \$n=37\$,... | stackexchange_codegolf |
Let's continue the fibonacci based challenges stream, here's the next one:
Task
Draw a Fibonacci spiral ascii-art of n segments where starting from the first term:
each nth segment has a length of nth Fibonacci term.
each segment is joined to the end of the previous, rotated by 90 degrees taking the end of previous s... | stackexchange_codegolf |
Sokobunny 1
You love buns!
You love them so much, that you chased one down a bunburrow. The burrows are like mazes, and YOU WANT TO CATCH THE FLUFFBALLS!!!! However, the buns are smart! You can't catch the bun by by chasing after it, as you wait out of politeness for the buns.
Taken from the game Paquerette Down the Bu... | stackexchange_codegolf |
Challenge
Make the shortest program to determine if the figures in the input will fit into the space in the input.
Requirements
The input will be in the format of this example:
Input:
+----+ -- +--+
| +----+ | |
| | +--+
| |
+---------+
Output:
+----+
|+--++----+
|| |-- |
|+--+ |
... | stackexchange_codegolf |
This is a Cops and Robbers challenge. For the Robbers' thread, go here.
The Cops have three tasks.
1) Pick a sequence from the OEIS.
2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rule... | stackexchange_codegolf |
I got this challenge from Codingame and am curious about better solutions than mine:
Given a width via standard input draw a hollow square of '#' in given width and length.
Example:
5 results in
#####
# #
# #
# #
#####
I used python to solve this so i am particulary interested in other python code. But please fe... | stackexchange_codegolf |
Challenge
Create a function that takes an string as a parameter. (Easy as far)
This string will contain
Single digit numbers
Letters from the alphabet
Question marks (Of course)
Your function will check if there are exactly 3 question marks between every pair of two numbers that add up to 10 or more. If so, then your... | stackexchange_codegolf |
Sometimes I see a claim like "80% of respondents agreed" and I think "what was your sample size? 5?" because, of course, with a sample size of 5 it's possible to get 80% to agree on something. If the claim is "47% of respondents agreed" then I know it must be a larger sample size.[1]
challenge
Given a positive integer ... | stackexchange_codegolf |
In: Enough memory and a positive integer N
Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by...
Examples:
1: [1] which is a 1D array (a list) of length 1, containing a single 1
2: [[2,2],[2,2]] which is a 2D array (a table) with 2 rows and 2 columns, filled with 2s
3: [[[3,3,3],[3,3,... | stackexchange_codegolf |
The user will hide, and the computer will try to find them.
First, the program will take an input, for the size of the grid. Like 5x5, 10x10, 15x15, etc. The grid won't always be a perfect square.
The grid is sort of like a chessboard:
_______________________________
| | | | | |
| A1 | | | ... | stackexchange_codegolf |
This is not a duplicate of Sum of combinations with repetition. This question considers 1+2 to be the same as 2+1. The other question doesn't.
OEIS link - A000008
Background
If you have 4 types of coins (1, 2, 5 and 10 cents), in how many ways can you make an amount?
There are 4 ways of making 5 cents:
1 + 1 + 1 + 1... | stackexchange_codegolf |
This ascii-art challenge is about walking around a string like a snake.
s-n-a-k
.---. e
d <-' a
n-u-o-r
You will be given a string \$ S \$ of length \$ l \$ and a positive integer \$ n \$ where \$ n ^ 2 \ge l + 1 \$.
The string rotates 90° after writing \$ n \$ characters of \$ S \$, or when it hits itself. When \$ S ... | stackexchange_codegolf |
A great Python golfing tip is to omit needless spaces. But if you are like me, you don't always have the time to search for which spaces to remove. If only there was a way to speed up the process...
Task
Given a single line of Python, as input, return/output a new line which omits all needless spaces. The table below s... | stackexchange_codegolf |
Given a compressed string \$s\$ made of printable ASCII characters (32 to 126), your task is to print or return the original text by applying this simple decompression algorithm:
Start with \$k=0\$
Look for the first occurrence of the digit \$k\$ in \$s\$ and the sub-string \$s'\$ consisting of the \$2\$ characters pr... | stackexchange_codegolf |
Based on this, but I was asked[1],[2] to do a graphical edition.
Task
Generate a circular display of the text EASIER COMMUNICATION MEANS FASTER CODING MEANS FEWER CODERS MEANS . Any uppercase font goes. The letter tops must face out of the circle. Either the space before FEWER must be at the bottom (6 o'clock) or ... | stackexchange_codegolf |
We'll define the N-exponential potential of a positive integer M as the count of prefixes of MN that are perfect N-powers.
The prefixes of an integer are all the contiguous subsequences of digits that start with the first one, interpreted as numbers in base 10. For example, the prefixes of 2744 are 2, 27, 274 and 2744.... | stackexchange_codegolf |
Validate a codice fiscale
Every Italian resident/citizen is given a 16-character alphanumeric codice fiscale
Challenge
The final letter is a check code, which is calculated as follows :
Characters of the code are split up into even and odd character according to their positions (check letter excluded)
Both sets are re... | stackexchange_codegolf |
Contest Finished! Read comments on blobs to view their score.
This KoTH is loosely inspired by Primer's Natural Selection Simulation. Your bot is a blob. In order to survive, you must eat pellets to regain energy, which is used to move. With extra energy, blobs can split into two.
Energy and Movement
Your blob starts o... | stackexchange_codegolf |
Given a matrix of positive integers, output whether it's possible to generate it by starting with an empty1 matrix of the same dimensions and repeatedly filling a whole row or a whole column with the same value, overwriting any values already written.
Example
The following matrix:
$$\begin{pmatrix}1&1&1\\2&3&4\\2&3&4\e... | stackexchange_codegolf |
The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels:
あかさ
たなは
まやら
小わ、
When a key is tapped, it produces its respective kana. However, when the key is flicked in one of the four cardinal directions (up, down, left, right) it prod... | stackexchange_codegolf |
FizzBuzz is so simple, bet you can do it backwards. In this challenge, you will be given the length of the FizzBuzz string and must give the positive integer that produced that string.
Description
To break this down, a FizzBuzz string for n is generated by the following algorithm.
Start with an empty string and, for e... | stackexchange_codegolf |
Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers.
2 = A, B, C
3 = D, E, F
4 = G, H, I
5 = J, K, L
6 = M, N, O
7 = P, Q, R, S
8 = T, U, V
9 = W, X, Y, Z
No letters are associated with the number 0 or 1.
Your challenge: Given any phone number in seven-digit... | stackexchange_codegolf |
Introduction
A while ago a lost SO user posted a question here and its now been deleted but I think it would make a good challenge so here it goes...
Challenge
Write a full program or function that takes two strings and checks whether any permutation of the first string is a sub-string of the second string.
Input
Two s... | stackexchange_codegolf |
Description
A Caesar Shift is a very simple monoalphabetic cipher where each letter gets replaced by the one after it in the alphabet. Example:
Hello world! -> IFMMP XPSME!
(IBSLR, EGUFV! is the output for the actual challenge, this was an example of shifting by 1.)
As you can see, spacing and punctuation remain unatt... | 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 |
Requirements:
Take a single word as input with only lowercase alphabetical characters (a-z)
Output a string where every other character is repeated, with the first repeated character being the second character in the string
Example:
Input: abcde
Output: abbcdde
Winning Criteria:
Standard code golf. Shortest number of... | stackexchange_codegolf |
I have trouble remembering everything I have to do when leveling up a D&D character. For whatever reason, one of the things that gives me trouble is figuring out what their new maximum HP value should be. For this challenge, you will write a program or function to calculate the correct value automatically.
Terminology
... | stackexchange_codegolf |
Challenge
A repdigit is a non-negative integer whose digits are all equal.
Create a function or complete program that takes a single integer as input and outputs a truthy value if the input number is a repdigit in base 10 and falsy value otherwise.
The input is guaranteed to be a positive integer.
You may take and use ... | stackexchange_codegolf |
I noticed that it seems nobody has posted a non-ASCII (related) USA flag challenge yet, so what better time than the 4th of July?
The Challenge
Draw the current (as of 2022) flag of the United States of America.
Here is the flag:
Specifications
Hoist (height) of the flag: A = 1.0
Fly (width) of the flag: B = 1.9
Hoi... | stackexchange_codegolf |
Given two integers, s and e, print the title of Black Mirror series #s episode #e.
Expected output is as below, case sensitive. Output for blank cells and invalid inputs is unspecified.
e↓s→ 1 2 3 4 5 ... | stackexchange_codegolf |
Challenge
The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the integral values of x for which the equation holds true. The coefficients will be provided as input in the order of decreasing or increasing power. You can assume all the coefficients to... | stackexchange_codegolf |
For any ragged list its dimensions will be a list of non-negative integers defined as follows:
Elements that are not a list will have dimensions \$\textbf{[}\,\,\textbf{]}\$.
An empty list has dimensions \$[0]\$.
An \$n\$ dimensional list \$L\$ of length \$x\$ has dimensions \$x : k\$ where \$k\$ is the element wise m... | stackexchange_codegolf |
For this challenge you are going to make a function (your function may be a complete program) that takes a list as input and returns a permutation of that list. Your function must obey the following requirements.
It must be deterministic.
Composing your function with itself a variable number of times should be capabl... | stackexchange_codegolf |
It's the end of the year, you and your friends have just received your grades and ranks for the GOLF101 class. On a chat group, everyone sends their grade and rank to see who's got the best one.
Problem: someone is lying.
Here is an excerpt from the chat:
<A> I'm ranked 1 with a grade of 85.
<B> Ranked 3, got 50.
<C> R... | stackexchange_codegolf |
Introduction:
Inspired by the Puzzling-stackexchange post with the same name, which I've answered four years ago:
Can you create a perfectly valid English sentence, which makes perfect sense, but which contains the word "and" in it, five times consecutively in a row ?
"Something-or-other and and and and and something-... | stackexchange_codegolf |
Your input is a ragged list of possibly empty lists of non-negative integers. For example, [[2,0],[[]],[[[],[1],[]],[]]] is a valid input. This input is a "compressed" ragged list. What this means is that when we have a list of numbers, we interpret those as a list of indices, indexing the output.
For example, if I=[[2... | stackexchange_codegolf |
Sorry folks, but what I've got for you today is a golf but just limited by JS (or, to be strict, for a day of posting - an ES6 - the most modern set of it - if its ES7 - feel free to EDIT! use MOST MODERN features).
So if you afford that restriction - let's proceed!
Assume we have JSON root data structure r and some gl... | stackexchange_codegolf |
The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.
Imagine this set of numbers
[1 6 9 4 6 9 7 6 4 4 9 8 7]
Each of them creates a ... | stackexchange_codegolf |
Credit to Geobits in TNB for the idea
A post without sufficient detail recently posited an interesting game:
2 children sit in front of an array of candy. Each piece of candy is numbered 1 to x, with x being the total amount of candy present. There is exactly 1 occurrence of each number.
The goal of the game is for the... | stackexchange_codegolf |
This is how I checkout to see if a number is in a range (in between two other numbers):
var a = 10,
b = 30,
x = 15,
y = 35;
x < Math.max(a,b) && x > Math.min(a,b) // -> true
y < Math.max(a,b) && y > Math.min(a,b) // -> false
I have to do this math in my code a lot and I'm looking for shorter equivalent co... | stackexchange_codegolf |
in my country we have a children's song which goes like this:
Priletela muha na zid, muha na zid, muha na zid.
Priletela muha na zid,
muha na zid.
Pralatala maha na zad, maha na zad, maha na zad.
Pralatala maha na zad,
maha na zad.
Preletele mehe ne zed, mehe ne zed, mehe ne zed.
Preletele mehe ne zed,
mehe ne zed.
... | stackexchange_codegolf |
Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!.
How strings are twisted
The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It kinda loo... | stackexchange_codegolf |
Challenge:
Given a list of multi-line strings, overlap them (in the top-left) and output the result.
Example:
Input: ["aaaa\naaaa\naaaa\naaaa","bb\nbb\nbb","c"]
Output:
cbaa
bbaa
bbaa
aaaa
Challenge rules:
Input-format is flexible. You are allowed to get the input as a 2D list of lines (i.e. [["aaaa","aaaa","aaaa","a... | stackexchange_codegolf |
This challenge is pretty simple: you need to alert / print / show to the user the text "beep boop bop" (or "beep\nboop\nbop", with newlines), but it needs to be obfuscated. (where you couldn't see anything saying "beep", "boop", or "bop"). Points are calculated where your point value is in characters (not bytes)
| stackexchange_codegolf |
Challenge
Given a rectangular area arrange a group of rectangles such that they cover the rectangular area entirely.
Input
An integer denoting the height.
An integer denoting the width.
The dimensions of the rectangles consisting
of the following form: axb,cxd,... where a,b,c, and d are integers - any reasonable for... | stackexchange_codegolf |
This is an alternate version of this earlier challenge with a twist that adds a significant bit of difficulty.
Like last time, you are going to be given a string containing some alphabetic characters along with [ and ]. Your task is to split into sections that are enclosed in a "group" created by [...] and those that ... | stackexchange_codegolf |
You don't want to pay money for the expensive architectural program, so you decide to roll your own. You decide to use ASCII to design your buildings. Your program will take in a single string formatted in a specific way, and the program will output the building.
Input
Input consists of a single line of characters. It ... | stackexchange_codegolf |
Input
Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d).
Output
All real solutions of the input equation, with an accuracy of at least the thousandths place, sorted from smallest to largest.
Rules
Built-in equation solver are not allowed
Native math ... | stackexchange_codegolf |
If we have a list of integers we can "squish" one of them by:
decrementing it
replacing adjacent values with its new value
For example in this list:
[1,2,8,3,6]
If we squish the 8 we get:
[1,7,7,7,6]
The question is:
Given a starting array, what is the largest we can make its sum by repeatedly squishing values?
For... | stackexchange_codegolf |
Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height.
Or, if your language supports it, the two integers can be given as separate inputs.
Assume the width and height will never be less than 3, and they will always be given.
Example Outputs:
[3, 3]
|-|
| |
|-|
... | stackexchange_codegolf |
Your task is simple: Write a program (or function) that takes no input and outputs something like this:
## *name*, *length* bytes
*code*
Where *name* is the name of the language you are using, *length* is the number of bytes in your code, and *code* is your program's source code. If *code* contains multiple lines,... | stackexchange_codegolf |
Let's define a sequence of integer square roots. First, a(1) = 1. Then, a(n) is the smallest positive integer not seen before such that
sqrt(a(n) + sqrt(a(n-1) + sqrt(... + sqrt(a(1)))))
is an integer. Some examples:
a(2) is 3 because it's the smallest integer such that sqrt(a(2) + sqrt(a(1))) = sqrt(a(2) + 1) is int... | stackexchange_codegolf |
TL;DR
Record (left-right)/length for each pair of consecutive elements. If they're 0 or negative, don't record it.
Once this is done, take these actions. Don't update quotients:
Increment right and decrement left for (0, .3)
Remove from the array at >=.3
Print both elements for >.5
Print the remaining array. Have s... | stackexchange_codegolf |
You want to see how quickly the ratio of two consecutive Fibonacci numbers converges on φ.
Phi, known by the nickname "the golden ratio" and written as \$φ\$, is an irrational number, almost as popular as π and e. The exact value of \$φ\$ is \$\frac {1 + \sqrt 5} 2 = 1.618...\$
The Fibonacci sequence is a recursive ser... | stackexchange_codegolf |
The minimal power iteration of a number \$n\$ is defined as follows:
$$\text{MPI}(n):=n^{\text{min}(\text{digits}(n))}$$
That is, \$n\$ raised to the lowest digit in \$n\$. For example, \$\text{MPI}(32)=32^2=1024\$ and \$\text{MPI}(1234)=1234^1=1234\$.
The minimal power root of a number \$n\$ is defined as the number o... | stackexchange_codegolf |
A port of my other question: Double Prime Words
Consider a word/string of n alphanumeric characters with sum of the characters, s, using their numeric position in the alphabet (a=1, B=2, c=3, etc.) or numeric value (0,1, 2, 3 - 9). Numeric characters should be taken at individual value. (66 is two 6 characters for a su... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.