instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given a string, character list, byte stream, sequence… which is both valid UTF-8 and valid Windows-1252 (most languages will probably want to take a normal UTF-8 string), convert it from (that is, pretend it is) Windows-1252 to UTF-8.
Walked-through example
The UTF-8 string
I ♥ U T F - 8
is represente... | stackexchange_codegolf |
A Latin square of order n is text which is arranged as a square of n lines by n columns, contains n different characters, and each character appears once in each line and column. For example, here is a Latin square of order 9:
Code gOlf
ode gOlfC
de gOlfCo
e gOlfCod
gOlfCode
gOlfCode
OlfCode g
lfCode gO
fCode gOl
M... | stackexchange_codegolf |
Challenge
Given a colour raster image* with the same width and height, output the image transformed under Arnold's cat map. (*details see below)
Definition
Given the size of the image N we assume that the coordinates of a pixel are given as numbers between 0 and N-1.
Arnold's cat map is then defined as follows:
A pixe... | stackexchange_codegolf |
Given a range and a list thereof, while keeping the existing intervals in the list unchanged, split the additional range into sub-intervals and add them to the list, such that all the ranges in the final list are disjoint and contain all numbers present in the input ranges.
The goal is to create an insertInterval(inte... | stackexchange_codegolf |
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag.
Input
Well, obviously this challenge has no input.
Output
Draw the flag of Iceland in any applicable visual format of at le... | 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 |
Any two separate nodes in a binary tree have a common ancestor, which is the root of a binary tree. The lowest common ancestor(LCA) is thus defined as the node that is furthest from the root and that is the ancestor of the two nodes.
The following are binary trees and the lowest common ancestors of the some of their n... | stackexchange_codegolf |
Super permutations
Input: A string
The program should loop through all lengths of the input (decrementing one each time), generate all combinations with replacement of the string, then make permutations out of the generated combinations, and display all of the strings.
They can be separated with anything (doesn't need... | stackexchange_codegolf |
The partial sums of a list of integers [a1, a2, a3, ..., an] are
s1 = a1
s2 = a1 + a2
s3 = a1 + a2 + a3
...
sn = a1 + a2 + ... + an
We can then take the list of partial sums [s1, s2, s3, ..., sn] and compute its partial sums again to produce a new list, and so on.
Related: Iterated forward differences
Input:
A non-em... | stackexchange_codegolf |
If you look at the Fibonacci Numbers, you will notice a pattern in their parity: 0, 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144. Every third number is even, and all the others are odd. This makes sense because an even plus an odd is odd, but an odd plus an odd is even and the sum for a term will always include... | stackexchange_codegolf |
Or, "Swap the first and last letters of each word"
Your challenge is to, given a string of alphabetical ASCII characters as well as one other character to use as a delimiter (to separate each word), swap the first and last letters of each word. If there is a one-character word, leave it alone.
The examples/testcases us... | stackexchange_codegolf |
You are given 100 arrays/sets of 5-8 numbers between 1-20. If you combine all the arrays you will always get at least one of each number (1-20), so don't worry about an "unsolvable" case. The goal is to find the combination of arrays that minimizes duplicate numbers while still getting one of each number from 1-20.
Her... | stackexchange_codegolf |
Task
A date can be compactly represented in a 6-character string in the format ddmmyy where the first two characters (dd) represent a day, the 3rd and 4th characters (mm) represent a month and the last two characters (yy) represent a 20XX year. Given a string with 6 characters in [0-9] determine if it represents a vali... | stackexchange_codegolf |
Marshall Lochbaum's online BQN REPL has an interesting(and aesthetically pleasing) method of displaying arrays. Your task is to implement a version with simpler rules.
[2,[3],4,[[[6,[5],7]]]]
becomes:
┌─
· 2 ┌· 4 ┌·
· 3 · ┌·
┘ ... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
It's time to prepare an advent calendar, but I've only got a large sheet of rectangular paper, randomly colored red and green like this:
GRRRGRRGRG
GGRGGGRRGR
GRRGRGRGRG
GGRRGRGRGG
GRGGRGRGGG
RRGRGRGRRG
RRRGRGRGGG
RGGRGGRRRG
RGGGRRRRRG... | stackexchange_codegolf |
Your task is to write a program, function or snippet (yes, snippets are allowed) that simply outputs an integer. However, you must be able to separate your submission into prefixes that also produce distinct integers. You cannot use any bytes that have appeared in previous prefixes. For example, we can have the prefixe... | 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 |
Laguerre polynomials are nontrivial solutions to Laguerre's equation, a second-order linear differential equation: \$xy''+(1-x)y'+ny=0\$. For a given value of \$n\$, the solution, \$y\$, is named \$L_n(x)\$. To avoid trivial solutions, the polynomials are non-constant except for \$n=0\$.
The polynomials can be found wi... | stackexchange_codegolf |
Challenge
Given the phase of the moon, draw it using ASCII art.
Your program must handle new moon, waxing crescent, first quarter, waxing gibbous, full moon, waning gibbous, last quarter, and waning crescent. Your input will be an integer.
0 -> new moon
1 -> waxing crescent
2 -> first quarter
3 -> waxing gibbous
4 -> f... | stackexchange_codegolf |
There are radiation hardened quines, palindromic quines, but has anyone tried both?!
I think not!
Rules
So the challenge here is to make a quine that if any symbol is deleted it prints its original source code, and the quine needs to be the same read forward and backwards(before radiation damage)! All code will be scor... | stackexchange_codegolf |
Task
Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, with an apothem of 1, using the formula A = n * tan(π / n).
The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides.
Output the area of this regular polygon as a floating point value sh... | stackexchange_codegolf |
Given a number \$n ≥ 2\$, a blackbox function \$f\$ that takes no arguments and returns a random integer in the range 0...n-1 inclusive, and a number \$m ≥ n\$, your challenge is to generate a random integer in the range 0...m-1 inclusive. You may not use any nondeterministic builtins or behaviour, your only source of ... | stackexchange_codegolf |
Write a program that creates a two-state checkbox that people can interact with using a mouse.
Specifically, your program should achieve all of the following:
Have a 8×8 pixel (or larger if desired) region of the screen that is the clickable area of the checkbox. Henceforth this region is simply called the checkbox.
... | stackexchange_codegolf |
You have been hired for your tech knowledge as a Secret Agent's sidekick to ensure that the good guy can get his job done and the world can be saved.
This is your last mission before retiring with a high paycheck and the gratitude of the whole world. But before you have to disarm the Evil Genius' Big Overly Massive BOM... | stackexchange_codegolf |
This challenge is from a game, Keep Talking And Nobody Explodes.
It's hard to say how this mechanism works. The engineering is pretty impressive, but there must have been an easier way to manage nine wires. — from the manual
Input
Exactly 9 "wires", each which is labeled 'A', 'B', or 'C', and is colored red, blue, or b... | stackexchange_codegolf |
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps.
More specifically: Let the following be an example:
##..
##..
..__
..__
Where # is filled, . is empty, and _ is recursive.
This describes a pattern wherein the top left quarter is filled, t... | stackexchange_codegolf |
Write a function in Python 2.7 that takes a list of integers as an argument. It should return True or False depending on whether there are any 2 integers in the argument list that sum to zero.
[4,-4,9,6,5]
True
[6,5,-3,2]
False
| stackexchange_codegolf |
Background
(Based on a true, heart-wrenching story)
In my time, I've played around with Lisp and similar languages often. I've written with them, ran them, interpreted them, designed them, and made machines write with them for me... And if there is one thing that bothers me, it's seeing Lisp that does not comply with m... | stackexchange_codegolf |
Challenge
The cops created code challenges which result in certain wildly incorrect answers despite correct math. Choose an uncracked, not safe formula from the cop thread.
Your task is to find an incorrect answer and describe its underlying cause. The challenge author has the responsibility to confirm whether the expl... | stackexchange_codegolf |
Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which indicates a identifier. There are no keywords.
In this language, the value of identifiers is not important except when they appear multiple times. Thus for... | stackexchange_codegolf |
Given a list of countries in alphabetical order, put them in the same order as they are given in the song "Yakko's World".
Specifically, you are given the following list of countries* exactly:
Abu Dhabi, Afghanistan, Albania, Algeria, Algiers, Angola, Argentina, Australia, Austria, Bahamas, Bahrain, Bangladesh, Barbado... | stackexchange_codegolf |
Original: https://james-iry.blogspot.co.at/2009/05/brief-incomplete-and-mostly-wrong.html
Alain Colmerauer designed the logic programming language Prolog. His goal was to create a programming language that is as intelligent as a two-year-old child. In order to prove that he had succeeded in his goal, he presented a P... | stackexchange_codegolf |
Given 3 bytes or RGB as input, calculate the nearest CMYK values, and output them.
create either a function with parameters and return value or a program that operates on stdin/stdout
use the color profile of your choice, but provide a reference
input may be either separate numeric values in range [0;255] or a 6 digit... | stackexchange_codegolf |
As a kind of part 2 to Hello, World! (Every other character), write a program such that all three of these programs print "Hello, World!": the entire program, the 1st, 3rd, 5th, etc. characters of your program, and the 2nd, 4th, 6th, etc.
If your program is:
abc
def
It should output "Hello, World!", but so should
acdf... | stackexchange_codegolf |
The goal of radiation hardening is to make a program still work after you remove a byte. However, what if a skilled competitor is purposefully trying to mess with you?
In this game, each bot will take turns removing one character from the next bot down the line. If the bot fails to produce valid output next turn you ga... | stackexchange_codegolf |
Your task is to find how many distinct Blackjack sequences can be found in an ordered list of 12 cards.
A Blackjack sequence is defined as a sequence of consecutive cards whose sum of points is exactly 21. Points are counted according to the following table:
Symbol | Name | Points Symbol | Name | Points
-------+-... | stackexchange_codegolf |
This challenge is simple. Given a number, output a ascii-art representation of the number, using the Mayan Base-20 numeral system.
What is the Mayan system?
The Mayans used base 20 to store numbers, so the first position was the 1s place, the next the 20s place, then the 400s, etc.
So Mayan number 1 is 1 in base 10, b... | stackexchange_codegolf |
Given no input, output this interesting alphabet pattern in either case (the case has to be consistent) via an accepted output method:
A
AB
ACBC
ADBDCD
AEBECEDE
AFBFCFDFEF
AGBGCGDGEGFG
AHBHCHDHEHFHGH
AIBICIDIEIFIGIHI
AJBJCJDJEJFJGJHJIJ
AKBKCKDKEKFKGKHKIKJK
ALBLCLDLELFLGLHLILJLKL
AMBMCMDMEMFMGMHMIMJMKMLM
ANBNCNDNENFNGN... | stackexchange_codegolf |
An illegal prime is a prime number which encodes information that is illegal to possess - specifically, in one case, a gzip file of the source code of DeCSS, a piece of software to decrypt copy-protected DVDs.
Your task has two phases:
Build a source file that implements DeCSS in as few bytes as possible. This can be ... | stackexchange_codegolf |
In LLAMA, you want to dump cards from your hand as quickly as you can, but you might not be able to play what you want.
Each player starts a round with six cards in hand; the deck consists of llama cards and cards numbered 1-6, with eight copies of each. On a turn, the active player can play a card or draw a card. To p... | stackexchange_codegolf |
Fennel is a lispy language which compiles to Lua.
From its page:
Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system.
I am looking for general tips for golfing in this language. Tips should be specific to Fennel, "Remove ... | stackexchange_codegolf |
Intro/Background
I was looking at "You Had One Job" pictures lately, and noticed an old favourite of mine:
And I said to myself: "I need a program that can generate text like that".
So I devised a set of rules for character swapping and wrote a CGCC challenge!
The Challenge
Given a single string as input, output a str... | stackexchange_codegolf |
Related
Introduction
As it happens, someone put forward the idea that, since PPCG has graduated, up votes on questions should be worth 10 rep. As a result, I started wondering how much rep I would have if it had always been 10 rep.
Challenge
Given a PPCG user's id as input, output how much total rep the user would have... | stackexchange_codegolf |
Given a positive integer n.
Generate a JSON array (can be a string, or your language's built-in JSON representation as long as we can get valid JSON, (your code does not need to include outputting the string, you can just use the built-in JSON representation)) containing two empty JSON arrays, then, add a set of 2 empt... | stackexchange_codegolf |
Challenge
Given a the ID for a PPCG user who has existed for at least a month, output the average amount of reputation they gain per month. You can do this by dividing their reputation by the time since their account was created (which you can find on the profile). This should be returned floored; that is, truncate all... | stackexchange_codegolf |
There are numerous reasons for trying to obfuscate input. These include preventing decompiling, and being a nuiscance.
With this in mind your challenge should your choose to accept it is to write a meta-obfuscator. Your code must in some Language X receive input as a String, and output a program in language X that out... | stackexchange_codegolf |
A polynomial is divisible by a factor (x-n) if f(n)=0 for a function f. Your job: to determine if a polynomial function f(x) is divisible by (x-n).
The input
The input is in the form of (x-n), (Polynomial). Remember, if n is negative, (x-n) will be in the input form of (x+n). For the polynomial, all exponents will... | stackexchange_codegolf |
Introduction:
(Source: Wikipedia)
When we look at a rainbow it will always have the colors from top to bottom:
Red; orange; yellow; green; blue; indigo; violet
If we look at these individual rings, the red ring is of course bigger than the violet ring.
In addition, it's also possible to have two or even three rainbow ... | stackexchange_codegolf |
Write a program that translates an arithmetic expression to a Brainfuck program which evaluates the expression and prints the result in decimal numbers. For example, this arithmetic expression,
2 * (3 + 4)
can be translated to Brainfuck as,
++ 2
>+++ 3
>++++ 4
[-<+>]< add
<[>[->+>+<<]>[-<+>]<<-]>[-]>>[-<<<+>>>]<<< mul... | stackexchange_codegolf |
It seems that many people would like to have this, so it's now a sequel to this challenge!
Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number.
Task: Given a prime power pn > 1, return the power n.
Testcases:
input output
9 2
16 4
343 ... | stackexchange_codegolf |
Typescript is a typed superset of Javascript. For this challenge, we'll consider the following classic basic types:
string
number
boolean
undefined
null
And two "meta" types:
any
never
The type any annotates that any type is valid:
const a: any = "foo";
const b: any = 42;
const c: any = true;
const d: any = undefin... | 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 task is to to compete for the shortest regex (in bytes) in your preferred programming language which can distinguish between English and Spanish with minimum 60% 90% accuracy.
Silvio Mayolo's submission (pinned as Best Answer) has secured his spot as the winner of original contest against any chance of being contes... | stackexchange_codegolf |
To celebrate the 2497th anniversary of the Greek victory at Salamis in 480 BC. Draw the lambda blazon.
The lambda blazon was the lambda painted on greek shields like so:
Puzzle: Given a positive odd integer n, produce an ascii art image of the above shield.
Specifications:
n=1:
( /\ )
n=3:
( /\ )
| / \ |
( /... | stackexchange_codegolf |
Introduction
We all know prefixes and suffixes. But there are other types of affixes that exist too. Such as circumfixes, a type of affix that has two parts, one of which is a prefix and another of which is a suffix. Figuring out whether some string is a prefix or a suffix of some other string is easy, but what about f... | stackexchange_codegolf |
What is the shortest sequence of moves that, from the solved state of the cube, creates a pattern that meets the following criteria:
6 colors on each face
at most 2 facelets of the same color
no adjacent facelets of the same color
EDIT: I made up the name of the pattern. I asked this question in 2018 on Mathematics S... | stackexchange_codegolf |
Not a dupe to this. That question asks specifically for counting up forever, while this question allows many other approaches.
Write a program or function which, given infinite time and memory, would print an infinite non-periodic output.
Clarifications
'Infinite' means the solution keeps outputting something without ... | stackexchange_codegolf |
Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign.
Task
Your task is to write a program that receives a sentence and applies the factorial joke to the sentence.
The "factorial joke" consists of looking for exclamation marks "!" and doi... | stackexchange_codegolf |
Introduction
Busy Beavers are programs (specifically Turing Machine programs) that aim to output the most ones as possible, while having the least states as possible and halting.
Challenge
Your challenge is to make a busy beaver, which outputs as many ones as possible, but also outputs a second busy beaver. That secon... | stackexchange_codegolf |
Background:
For this challenge, a polynomial looks like this:
$$P(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_2x^2+a_1x+a_0$$
The degree, \$n\$, is the highest power \$x\$ is raised to. An example of a degree 7 polynomial would be:
$$P(x)=4x^7+2x^6-7x^4+x^2-6x+17$$
All powers are integers \$n\ge0\$. This means \$x\$, \$-2\$, and ... | stackexchange_codegolf |
Background
Due to some unfortunate accident during coding you are now teleported and stranded on an alien planet. You really hope that the locals will be helpful and point to the general direction of how to get home, but before trying to talk to them you want to decipher their language. Fortunately it looks like the al... | stackexchange_codegolf |
There have already been challenges about computing the exponential of a matrix , as well as computing the natural logarithm
of a number. This challenge is about finding the (natural) logarithm of matrix.
You task is to write a program of function that takes an invertible \$n \times n\$ matrix \$A\$ as input and returns... | stackexchange_codegolf |
The following is an unfolded milk carton:
+-----+-\|/-+-----+-\|/-+-+
| | / \ | | / \ | |
+-----+/---\+-----+/---\+-+
| | | | | |
| | | | | |
| | | | | |
+-----+-----+-----+-----+-+
\ / \ / \ / \ /
\_/ \_/ \_/ \_/
This is a code-golf kolmo... | stackexchange_codegolf |
Consider an array A of integers of length n. The k-max subarray sum asks us to find up to \$k \leq 3\$ (contiguous) non overlapping subarrays of A with maximum sum. If A is all negative then this sum will be 0. If A = [-1, 2, -1, 2, -1, 2, 2] and k=2 for example, then the two subarrays could be [2, -1, 2] and [2, 2] ... | stackexchange_codegolf |
Background
Roman numeral is a simple number system with the following properties:
Each symbol in the system maps to a specific value. (e.g. I = 1, V = 5, X = 10, C = 100)
The value of a Roman numeral can be evaluated as follows:
First, find all occurrences of adjacent pairs of symbols where a strictly smaller-valued ... | stackexchange_codegolf |
Background
Malbolge is truly intriguing language. But programs written in it are also extraordinairly huge (and in some cases, unpostable on PPCG).
Your challenge (shall you accept it) is, to compress and decompress given normalized Malbolge program. Devise your own lossless algorithm. You may compress your data furthe... | stackexchange_codegolf |
Introduction
Sometimes I get bored and there are no new questions on PPCG, so I want you to dig a random question from PPCG's past.
Challenge
Given a user's PPCG ID as input (e.g. my ID is 30525), output the URL of a randomly chosen PPCG question. If the question does not meet the following criteria, you must choose an... | stackexchange_codegolf |
You've been given a bag of Skittles. Everybody knows that in order to appreciate the different flavors the most, you need to rotate between the flavors.
Basics:
You can only eat 1 skittle at a time
The order that you eat your skittles must be periodic.
Each period cannot contain a particular flavor more than once.
... | stackexchange_codegolf |
An Séimhiú agus an tUrú
In Irish Gaelic (Gaeilge) there are a number of ways that the start of a word can be changed. The most common of these are lenition (an séimhiú) and eclipsis (an t-urú)
Lenition involves adding the letter h as the second letter. For example, the word "bean" (woman) would be lenited to "bhean".
E... | stackexchange_codegolf |
Write a program which outputs the square root of a given number in the shortest time possible.
Rules
It may not use any builtins or powering with non-integers.
Input format
as a function argument
as a command line argument
as a direct input on stdin or a window
Your entry hasn't to be a complete program, it may be ... | stackexchange_codegolf |
Introduction
This is the evolution of this previous challenge which was about checking satisfieability of normal formulae in conjunctive normal form (CNF). However, this problem is NP-complete and watching algorithms finish is just boring, so we're gonna simplify the problem!
Specification
Input
You may tune the follow... | stackexchange_codegolf |
A program is bit primed if bits in prime positions must alternate between zero and one, starting with one.
For example, this is a template for a bit primed program with [0..47] bits.
..10.1.0 ...1.0.. .1.0...1 .....0.1 .....0.. .1.0...1
01234567 89012345 67890123 45678901 23456789 01234567
Create a bit primed program... | stackexchange_codegolf |
Write a regular expression which matches a given string consisting of three non-negative, space-separated integers if and only if the last integer is the sum of the previous two. Answers may be for integers of any numeral system with radix between 2 and 10.
Test cases
These should fail:
0 1 2
10 20 1000
These should m... | stackexchange_codegolf |
Given text, remove leading and trailing whitespace (spaces, tabs, and newlines).
Alternate title: Implement your own string trimming.
Input
ASCII text (printable + spaces, tabs (\t), and newlines (\n)), in whatever format you would like. Carriage returns (\r) are outside of the scope of the input.
Output
The same text ... | stackexchange_codegolf |
Found this picture on the web today. Being a lazy programmer, I don't want to actually open google and type a couple of characters. Way too much work! This is such an important task that it should be automated.
Challenge
Everyone knows that the first image in a google search result is always the best. Hence it should ... | 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 |
Employers love to see their employees working hard, while the employees would love to work less, especially those with a monthly rather than hourly payment.
The laziest of employees are thinking about the world where every month starts with the same weekday and it makes them wonder if they would work more or less.
T... | stackexchange_codegolf |
Now that we're graduating, it's time to tally up the number of times someone suggested that PPCG was graduating, even before the annoucement! (see here)
Your program will receive a list of chat messages. Each message has three pieces of data: the user (e.g. Geobits), the timestamp (e.g. Aug 19 '15 2:41 PM), and the mes... | stackexchange_codegolf |
Given string S representing a dollar amount, make change for that amount of money use the least number of coins to make the change and record the amount of each coin in a list. Here are the coins available to use and their value.
Coin : Value
Dollar Coins : $1.00
Quarters: $0.25
Dimes: $0.10
Nickels: $0.05
Pennies: $0.... | stackexchange_codegolf |
Introduction to Numerical Mathematics
This is the "Hello, World!" of PDEs (Partial Differential Equations). The Laplace or Diffusion Equation appears often in Physics, for example Heat Equation, Deforming, Fluid Dynamics, etc... As real life is 3D but we want to say "Hello, World!" and not sing "99 bottles of beer,..."... | stackexchange_codegolf |
Dennis puts in a huge amount of effort for this community, including as moderator, language designer, and provider of TIO.
Unfortunately, his four-year-old daughter has caught a cold, so let us all help him keep track of her recovery (may it be speedy) by providing him with a thermometer:
.-----------.
| |
| ... | stackexchange_codegolf |
Sandbox
Definition: A positive integer n is almost-prime, if it can be written in the form n=p^k where p is a prime and k is also a positive integers. In other words, the prime factorization of n contains only the same number.
Input: A positive integer 2<=n<=2^31-1
Output: a truthy value, if n is almost-prime, and a fa... | stackexchange_codegolf |
Inspired/mostly copied but I don't think it's a dupe. Also Inspired.
In this challenge, you will create polyglots that include all languages from previous answers, and another language which you won't share and others must guess.
The first language prints 1, the second prints 2, etcetera.
For example, if the first answ... | stackexchange_codegolf |
Intro/Background
I was looking at "You Had One Job" pictures lately, and noticed an old favourite of mine:
And I said to myself: "I need a program that can generate text like that".
So I devised a set of rules for character swapping and wrote a CGCC challenge!
The Challenge
Given a single string as input, output a str... | stackexchange_codegolf |
Your task is to write a non-empty program / function of byte count L, which, when repeated M times, checks whether a given positive integer N is equal to L × M.
You should, in theory, support an arbitrary number of repetitions (an arbitrary positive integer value of M), but it's fine if, due to language limitations, it... | stackexchange_codegolf |
Your task is to make a bidirectional compressor. It takes a list of bytes as input and returns a list of bytes as output. It has the property than whenever it is iterated twice it returns the original input.
In other words, if f is your program as a function, then f(f(x))=x for all x.
Now, since this is a "compressor",... | stackexchange_codegolf |
your shift key is broken. wheNever you type two lines, the cApitaL
LetteRs in them get swappeD. you must write a program to fiX THIS!
Description
The input is two strings, s1 and s2, equal in length. They will each contain only printable ASCII and be at least one character in length. You may input these as two strings,... | stackexchange_codegolf |
Introduction
I Ching is an ancient divination text and the oldest of the Chinese classics. It uses a type of divination called cleromancy, which produces apparently random numbers.
The basic unit of the Zhou yi is the hexagram (卦 guà), a figure composed of six stacked horizontal lines (爻 yáo). Each line is either broke... | stackexchange_codegolf |
To-Do: Come up with a Better Title
Specification:
This challenge is similar to kolmogorov-complexity, but with a twist. You goal is to output a finite string that resembles the following string of psuedo-random characters as closely as possible:
BABBBBAAABBAABBBBAABBBAABBBABBAABABABBBBABBBBBBAABABBAABABBBABBBABAAAAABA... | stackexchange_codegolf |
When using a tool such as git to merge two files, a conflict could be detected and added to the result of the merge.
A merge of these two files:
my file:
Common line of code 1
Common line of code 2
my lines
Common line of code 3
Common line of code 4
their file:
Common line of code 1
Common line of code 2
their lines
... | stackexchange_codegolf |
The totient function \$\phi(n)\$, also called Euler's totient function, is defined as the number of positive integers \$\le n\$ that are relatively prime to (i.e., do not contain any factor in common with) \$n\$, where \$1\$ is counted as being relatively prime to all numbers. (from WolframMathworld)
Challenge
Given an... | stackexchange_codegolf |
In Bgil Midol's question, the score of a sequence of slice is defined as
sumof|startslices|∗2+sumof|endslices|∗2+sumof|stepslices|∗3
Such scoring method makes multiple slices possibly take less score, e.g.
[::25] 75
[::5][::5] 30
Given the length of a string, an upper bound of number of slices1, and the one slice i... | stackexchange_codegolf |
As a big fan of the Lost TV series, I always got intrigued by the sequence of numbers that repetitively appears on the episodes. These numbers are:
\$ 4, 8, 15, 16, 23, 42\$ (A104101)
Using any programming language, write a code that outputs these numbers.
Scoring:
Shortest answer wins
The output must not contain any ... | stackexchange_codegolf |
The narcissist is a program which, given its own source as input, prints a truthy value and, given anything other than that, prints a falsey value. Today, we're reversing this.
Create a program that, given the name of whatever your language's truthy value is (True, true, 1), prints its own source. Given the name of wha... | stackexchange_codegolf |
Input:
An integer
Output:
Sum of the input itself + the length of the input + each individual digit of the input.
nr + nr-length + {sum of digits} = output
Examples:
Input: 99
Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119
Input: 123
Output: 123 + 3 + (1 + 2 + 3) → 132
Challenge rules:
The input can also co... | stackexchange_codegolf |
Steganographic Squares
Your job is to take in a string, and generate an NxN image that represents this string. You must also write the algorithm that takes in the image and turns it back into a string as well. The scoring will be will include the byte count of both algorithms:
"Encryption" Algorithm + "Decryption" Algo... | stackexchange_codegolf |
The Challenge
Create an terminating expression in SKI Combinator Calculus in less than 200 combinators (S, K, I) that reduces to the expression with the most combinators.
There will be no limit on how many parenthesis/applications can be used.
SKI
SKI expressions are created using S, K, I and parenthesis. They are redu... | stackexchange_codegolf |
You probably all know the 7-segment display which can display among other things all digits from \$0\dots 9\$:
Challenge
We only consider the segments \$\texttt{A}\dots\texttt{G}\$, your task is to decode a single digit given which segments are turned on.
This can be encoded as an 8-bit integer, here's a table of each... | stackexchange_codegolf |
This is the cops' post. The robbers' is here.
You make a program and a regex.
For most inputs, one of the following happens:
the regex doesn't match, and the program returns a falsey value
the regex doesn't match, and the program returns a truthy value
the regex matches, and the program returns a truthy value
But for... | stackexchange_codegolf |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.