text stringlengths 180 608k |
|---|
[Question]
[
I like to save time quite literally, by wearing three watches on my wrist... Problem is they each give a different time. One watch is x minutes behind the actual time. One watch is x minutes ahead of the actual time. The last watch shows the actual time.
Problem is, I can't tell which watch has the cor... |
[Question]
[
## Introduction
Some of you may have heard of [Hilbert's Grand Hotel](https://en.wikipedia.org/wiki/Hilbert's_paradox_of_the_Grand_Hotel). The manager there has lost his list of where the guests are staying but he still has the order in which they checked in. Each guest can not stay in a room with a ro... |
[Question]
[
Write a program that takes as its input a string consisting of printable characters (ASCII 20-7E) and an integer `n` in [2,16] and performs the following modification to the string.
* Each character in the string is converted to its ASCII code (the examples given are in hexadecimal, though base 10 is a... |
[Question]
[
The Animal-Alphabetical Sequence is an infinite string of letters built accordingly to the following procedure:
1. Start with the letter `A`;
2. Replace each letter with the name of the animal starting with such letter in the table below;
3. Go back to step 2.
For instance, the first four steps of the ... |
[Question]
[
Note: this problem was inspired by the [Unsolved Mathematical Problems for K-12](https://www.youtube.com/watch?v=JPhqhZvXlhQ) youtube video, which also features other interesting puzzles.
*From the [wikipedia article](https://en.wikipedia.org/wiki/No-three-in-line_problem):*
>
> The **no-three-in-line... |
[Question]
[
Having spend some time on this site I have come to enjoy things being as short as possible. That may be the reason why I'm recently kind of offended by strings containing the same characters more than once. Your job is to write a function or program which *condenses* a given string according to the fol... |
[Question]
[
## Background
I have a row of powerful magnets and a bunch of metal objects between them.
Where will the magnets pull them?
## Input
Your input is an array of non-negative integers, which will contain at least one `1`.
You can use any reasonable format.
The `0`s of the array represent empty space, and ... |
[Question]
[
Your task is to sum up and output one player's score in a game of 10-pin bowling after *up to* 21 **rolls**.
The rolls are represented as a sequence of integers in your [preferred method of input](https://codegolf.meta.stackexchange.com/q/2447/4372).
Each integer corresponds to the number of pins that ... |
[Question]
[
Your task is to create the shortest program (A) that outputs another program (B) with the most unique bytes, which in turn outputs the original program (A). Essentially, you are golfing one half of a pair of [ouroboros programs](https://en.wikipedia.org/wiki/Quine_(computing)#Ouroboros_programs) (a.k.a... |
[Question]
[
Your goal is to write a program that will solve any Mastermind puzzle in 6 or less moves.
### Background
Mastermind is a board game. The goal of the game is to exactly guess the combination (colours and order) of 4 coloured pegs hidden by the other player. When a guess is made, the other player respond... |
[Question]
[
# Introduction
This site is rapidly building up a huge dataset of code snippets, so let's do something with it!
[Here's a data file](https://drive.google.com/file/d/0B3uyVnkMpqbVMGVtMndpbEdlVEE). It contains 9,066 unique language+snippet pairs for 113 languages, all taken from this site. The format is ... |
[Question]
[
## The challenge
Write a function or a program that takes a string composed of one or more **subjective personal pronouns**, separated by **+** signs, as an argument. The output must be a single pronoun, that is the result of the relation defined in the next paragraph.
Of course, feel free to edit as y... |
[Question]
[
A Quat is a combination of a [quine](/questions/tagged/quine "show questions tagged 'quine'") and the popular esolang [cat](http://esolangs.org/wiki/Cat_program) program.
# Challenge
The challenge is to write a standard cat program. Whatever the user inputs, the program will echo the input to stdout. ... |
[Question]
[
**Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers.
---
Questions without an **objective primary winning criterion** are off-topic, as they make it impossible to indisputably decide which entry should win.
Closed 3 years ago.
[Improve this quest... |
[Question]
[
A **monotonic subsequence** is a sequence of numbers \$a\_1, a\_2, ..., a\_n\$ such that
$$a\_1 \le a\_2 \le ... \le a\_n \\
\text{or} \\
a\_1 \ge a\_2 \ge ... \ge a\_n$$
`[1, 3, 3, 7, 9, 13, 13, 100]` is a monotonic (non-decreasing) subsequence, as well as `[9, 4, 4, 3, 0, -10, -12]` (this one is non-... |
[Question]
[
My electric garage door works like this:
* There is just one push button to control the door
* If the door is fully closed and I hit the button, the door starts to open. It takes 10 seconds to open fully
* If the door is fully open and I hit the button, the door starts to close. It takes 10 seconds to ... |
[Question]
[
Given a non-flat list of integers, output a list of lists containing the integers in each nesting level, starting with the least-nested level, with the values in their original order in the input list when read left-to-right. If two or more lists are at the same nesting level in the input list, they sh... |
[Question]
[
You may have seen [Jacob's Ladder](https://en.wikipedia.org/wiki/Spark_gap#Visual_entertainment) in children's science museums. If you're not familiar with what they look like, there are several images and video examples on the [Wikimedia Commons](https://commons.wikimedia.org/wiki/Category:Jacob%27s_l... |
[Question]
[
# String Stairs
**Disclaimer:** This is the first challenge I propose. Any and all feedback is welcome. If this is a duplicate, please point it out.
[Here](https://codegolf.meta.stackexchange.com/a/13976/74163)'s a link to the sandbox post.
# Goal
The goal of this challenge is to, given a string and an... |
[Question]
[
## Background
I play D&D on a regular basis with some friends. While talking about the complexity of some systems/versions when it comes to rolling dice and applying bonuses and penalties, we jokingly came up with some additional complexity for dice rolling expressions. Some of them were too outrageous... |
[Question]
[
Stolen from @Downgoat with permission
The point of this challenge is to (not) settle the debate on the pronunciation of "gif".
[](https://i.stack.imgur.com/j8SIr.gif)"
---
The pronunciation of *gif* is debated and while it's supposed to be (and should ... |
[Question]
[
For those of you who are unfamiliar, [Kirkman's Schoolgirl Problem](http://mathworld.wolfram.com/KirkmansSchoolgirlProblem.html) goes as follows:
>
> Fifteen young ladies in a school walk out three abreast for seven days in succession: it is required to arrange them daily so that no two shall walk tw... |
[Question]
[
This is a potato:
```
@@
@@@@
@@@@@@
@@@@@@
@@@@
@@
```
More generally, a size N potato is defined as the following shape:
If N is even, it is 2 centered `@` symbols, followed by 4 centered `@` symbols, followed by 6 centered `@` symbols, all the way up to N centered `@` symbols; then, N centere... |
[Question]
[
**Can't see emoji? Click [here](https://geokavel.github.io/emojis/emoji.html).**
You will simulate a vending machine. The items are 56 different emojis, which can be represented as two surrogate UTF-8 characters, from: üçÖ(U+D83C U+DF45) to üçº
(U+D83C U+DF7C). In HTML these emojis can be represented... |
[Question]
[
One of my kid's favorite toys is [a set like this](http://rads.stackoverflow.com/amzn/click/B000CBSNRY). Actually its one of my favorite toys - I've been playing with it and its been giving me some PPCG challenge ideas. Here's one:
Write a program or function that takes an ASCII line drawing as input a... |
[Question]
[
From <http://en.wikipedia.org/wiki/Triangle>:

---
Write a program that takes three 2d coordinate tuples (Cartesian), and classifies what shape these three points describe.
In almost all cases these points will describe a triangle of v... |
[Question]
[
# Introduction
Write a solver for the [Hitori](https://en.wikipedia.org/wiki/Hitori) puzzles using least bytes.
# Challenge
Your task is write a solver for the Hitori (ひとり, the word for "alone" in Japanese; the meaning of the game name is "Leave me alone") logical puzzles. The rules are as follows:
* Y... |
[Question]
[
In this challenge, you'll calculate how great your land is.
---
Write a program or function that calculates the size of your land, given a wall you have built. You're given a non-empty input string containing a set of 4 distinct characters of your choice that represent the four directions "up", "down",... |
[Question]
[
As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction:
[](https://i.stack.imgur.com/KU5Iu.png)
Your task is to take the unrolled vector along with the matrix... |
[Question]
[
The goal of this challenge is to write [a program or function](https://codegolf.meta.stackexchange.com/a/2422/30072) that returns the least amount of strikes needed to complete a given course.
### Input
* The layout of the course can be passed in any suitable way and format you prefer.
(read from the ... |
[Question]
[
A simple graph is toroidal if it can be drawn on the surface of a torus without any edges intersecting. Your task is to take a simple undirected graph via any reasonable method (adjacency matrix, edge vertex sets, etc.) and decide whether or not it is a toroidal graph. You should output one of two dist... |
[Question]
[
## Introduction
There is a small village with nothing but a few houses and empty fields.
The local bureaucrats want to divide the village into lots so that each lot contains exactly one house, and the borders of the lots form a nice straight-line grid.
Your task is to determine whether this is possible... |
[Question]
[
## Introduction
[Kerning](https://en.wikipedia.org/wiki/Kerning) means adjusting the spacing between the letters of a text.
As an example, consider the word `Top` written with the following three glyphs:
```
##### ..... .....
..#.. ..... .....
..#.. ..##. .###.
..#.. .#..# .#..#
..#.. .#..# .#..#
..#..... |
[Question]
[
Programming Puzzles & Code Golf has opened a [taco truck](https://en.wikipedia.org/wiki/Food_truck)! The word is out and now users from all over the Stack Exchange network are coming to try our tasty, authentic ASCII [tacos](https://en.wikipedia.org/wiki/Taco). We need your help to ensure that everyone... |
[Question]
[
**Monday Mini-Golf:** A series of short [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") questions, posted (hopefully!) every Monday.
Sometimes folks get tired of life's rules: "don't do this", "you can't do that", "we won't let you do this". It can seem really restricting a... |
[Question]
[
[This question is a follow up to [Compute the runs of a string](https://codegolf.stackexchange.com/questions/84410/compute-the-runs-of-a-string) ]
>
> A period `p` of a string `w` is any positive integer `p` such that `w[i]=w[i+p]`
> whenever both sides of this equation are defined. Let `per(w)` deno... |
[Question]
[
In APL, you can write tacit functions, called *trains*. How they work is irrelevant for this challenge. Here are the different ways they can be grouped, using `⍴` as the function:
```
⍴ -> ⍴
⍴⍴ -> ⍴⍴
⍴⍴⍴ -> ⍴⍴⍴
⍴⍴⍴⍴ -> ⍴(⍴⍴⍴)
⍴⍴⍴⍴⍴ -> ⍴⍴(⍴⍴⍴)
⍴⍴⍴⍴⍴⍴ -> ⍴(⍴⍴(⍴⍴⍴))
...
```
The order remain... |
[Question]
[
This challenge is inspired by [this fantastic animated diagram](http://www.datapointed.net/visualizations/math/factorization/animated-diagrams/) (thanks to flawr for posting it in chat).
Given an input `n`, draw all of its prime factors as nested polygons of dots, as specified.
For example, given the n... |
[Question]
[
In this game two players compete to eat the most points worth of tokens, but there's a twist! Eating multiple tokens in a row of the same color gives an ever-growing bonus, but watch out, or your opponent will thwart your plans by eating the tokens you want before you can!
**Rules:**
* 1 versus 1
* n b... |
[Question]
[
# Problem
Say you have N [stacks](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)) named S1 through SN, where each Sk (k = 1 to N) contains N copies of the number k.
For example, when N = 3 the stacks looks like this:
```
1 2 3 <- top of stack
1 2 3
1 2 3 <- bottom of stack
=======
1 ... |
[Question]
[
Fed up with [experimenting on tiny domestic animals](https://en.wikipedia.org/wiki/Schr%C3%B6dinger%27s_cat), Nobel prize-winning Erwin Schrödinger has decided to find the nearest laser and shoot it at things instead. Because... science!
# Description
You will be given two points that the laser passes ... |
[Question]
[
Everyone knows that C is a lovely, safe, high level programming language. However you, as a coder are set the following task.
>
> Write a program to add two numbers.
>
>
>
* Input: Two space separated integers.
* Output: The sum of the two numbers in the input.
The twist is that your code must be 1... |
[Question]
[
# How long's left?
Recently, I was making pizza using a 5-minute timer on my phone. When someone walked in and asked me how long was left, I was confused for a moment at first as to how to answer the question. You see, if the timer at the current moment was at 3:47, by the time I had read out 'Three mi... |
[Question]
[
# The task
Write a program or function that takes a traffic intersection structure and outputs the sequence, in which vehicles will pass.
The output should contain at most four lines with the following format `#. x->y\n`, where `#` is a sequence number number, followed by the dot `.`, `x` and `y` are c... |
[Question]
[
I was just playing the board game *[Sorry!](https://en.wikipedia.org/wiki/Sorry!_(game))* with some people, and I realized that I could base a few interesting challenges off of it. This one is pretty simple.
You task is simply to output an [ascii-art](/questions/tagged/ascii-art "show questions tagged ... |
[Question]
[
There is a network of up to 26 nodes (named `A` to `Z` or `a` to `z` as per your wish). Every pair of nodes may be connected or disconnected. A node may be connected to at most 4 other nodes. Your task is to draw the network in a 2D diagram. Input will be given such that this task is possible (see more... |
[Question]
[
The `puppy` utility takes a filename as input, and does exactly what you would expect a puppy to do: it shreds it!
[](https://i.stack.imgur.com/Vkfvz.jpg)
## How to shred
1. ~~Rip out the pages with your teeth~~ Split the input file on newlines.
2. ~~Tear up... |
[Question]
[
The goal of this challenge is to find the direction and area enclosed by a loop.
# Input:
A rectangular grid consisting entirely of these characters: `^v<>`
(Optionally, you may also be given the dimensions of the grid before the grid itself in decimal with a prefix, suffix, and separator character of ... |
[Question]
[
Domain name trading is big business. One of the most useful tools for domain name trading is an automatic appraisal tool, so that you can easily estimate how much a given domain is worth. Unfortunately, many automatic appraisal services require a membership/subscription to use. In this challenge, you w... |
[Question]
[
Every programmer knows that rectangles `□` are really fun. To exacerbate this fun, these cute and fuzzy diagrams can be transformed into groups of interwoven brackets.
This challenge is the inverse [of my previous](https://codegolf.stackexchange.com/questions/68864/make-bracket-squares).
Let's say you ... |
[Question]
[
When a number is shown on a calculator, it's possible to consider what various transformations of that number would look like. For example, on a seven-segment display, 2 is shown like this:

And when flipped horizontally it looks like ... |
[Question]
[
# Challenge
Write a program or function that given a string, returns a valid Brainfuck program that when compiled and executed as Brainfuck, returns that string..
1. Assume all inputs are encoded as ASCII.
2. Assume the outputted BF program will execute in an environment with an infinite tape.
3. Assum... |
[Question]
[
This is a problem from [NCPC 2005](https://ncpc.idi.ntnu.no/ncpc2005/). Roy has
an apartment with only one single electrical outlet, but he has a bunch of power strips.
Compute the maximum number of outlets he can have using the power strips he
has. The number of outlets per power strip is given as inp... |
[Question]
[
## Context
So the Dutch "Ministerie van Binnenlandse Zaken en Koninkrijksrelaties" (NL) - "Ministry of the Interior and Kingdom Relations" (EN) recently released the source code of their digid-app.
They have some goofy code in there, which led to [mockery and memes on reddit](https://www.reddit.com/r/P... |
[Question]
[
All the [quine](/questions/tagged/quine "show questions tagged 'quine'") challenges on this site are focused on byte count, or the characters themselves. This one is different. Your challenge is to write a program that produces output which has a code point sum identical to the source's code point sum.... |
[Question]
[
Your task is simple, just remove the odd indices and double the even indices
## Example
the input is `Hello, World!` and we get indices
```
H e l l o , _ W o r l d !
1 2 3 4 5 6 7 8 9 10 11 12 13
```
and remove the odd indices
```
el,Wrd
```
Double!
```
eell,,WWrrdd
```
and you are done
1-Indexing
#... |
[Question]
[
Inspired by [this code review](https://codereview.stackexchange.com/questions/242563/check-if-array-has-the-same-number-of-even-and-odd-values-in-python) question, I am curious to see what happens if we turn that into a code-golf challenge!
The description is easy, the input is an array or any similar ... |
[Question]
[
Given two arrays of non-negative integers \$A = [A\_1,A\_2,\ldots,A\_n]\$ and \$R = [R\_1,R\_2,\ldots,R\_n]\$ which are equal in length, return an array which has the element \$A\_1\$ repeated \$R\_1\$ times, then element \$A\_2\$ repeated \$R\_2\$ times, all the way up to \$A\_n\$.
[Standard loopholes... |
[Question]
[
You are given an integer `n` as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking place `n` seconds from now.
## Rules
* You may **not** assume that the current year is 2021. In other words, imagine a user testing your sol... |
[Question]
[
Given a non-negative integer, print out an `X` that is that big. `X` is the output for input `0`, and you will add slashes equal to the input in each direction to extend the `X` for larger inputs.
# Test Cases
0
```
X
```
1
```
\ /
X
/ \
```
2
```
\ /
\ /
X
/ \
/ \
```
...
10
```
\ ... |
[Question]
[
# Introduction
In chess, Knights can move two squares in one direction, and then one square in an orthogonal direction. On an x/y plane, these can be thought of as being a relative change of coordinates, such as (+1, -2).
# Challenge
Your task is to output all 8 possible moves as pairs of relative x/y ... |
[Question]
[
You have a 3x3 grid. Each cell can be colored black or white. Display all 512 of these colorings. Fewest bytes wins.
You can display the grids in any formation as long as they are visually separated and the spacing looks regular. You may use ASCII art or images. Any two distinct visible symbols or colo... |
[Question]
[
Create a program, that converts input string to a palindrome starting with the input string. The program itself must be a palindrome.
For example input: `neverod`, print `neveroddoreven`. You should handle multi-word, multi-line inputs as well.
[Answer]
# Dyalog APL, 6 4
```
⌽,,⌽
```
[Try it here.... |
[Question]
[
A palindromic number, as a refresher, is any number which reads the same forward as backwards. However, what about palindromes in other bases?
## Input
Any integer `b` where `b > 1`.
## Output
All integer base 10 numbers from 0 to 1000 inclusive that are palindromes in base b. The output can either be ... |
[Question]
[
Given a positive integer number \$n\$ output its perfect radical.
# Definition
A perfect radical \$r\$ of a positive integer \$n\$ is the lowest integer root of \$n\$ of any index \$i\$:
$$r = \sqrt[i]{n}$$
where \$r\$ is an integer.
In other words \$i\$ is the maximum exponent such that \$r\$ raised t... |
[Question]
[
Your program should take as input a number `n` that is greater than 0 and output a bar composed of `n // 8` ▉ characters (U+2588), as well as a final character which should be one of ▉ ▊ ▋ ▌ ▍ ▎▏(U+2589 to U+258F) representing `n % 8`. If `n % 8` is 0, your program should not output any... |
[Question]
[
**This question already has answers here**:
[Diamond Puzzles!](/questions/67952/diamond-puzzles)
(21 answers)
Closed 2 years ago.
When learning to factorise quadratics in the form \$x^2 + ax + b\$, a common technique is to find two numbers, \$p, q\$ such that
$$pq = b \\
p + q = a$$
as, for such... |
[Question]
[
## Getting the average of a list (e.g `[2,6,7]`)
* Get the length of the list: `[2,6,7] -> 3`
* Sum the numbers in the list: `2 + 6 + 7 = 15`.
* Divide the sum by their count: `15 / 3 = 5`.
You should compare the averages of two lists of *positive* integers **N** and **M**, by returning a value if **N*... |
[Question]
[
A [*proper divisor*](http://mathworld.wolfram.com/ProperDivisor.html) is a [divisor](https://en.wikipedia.org/wiki/Divisor) of a number *n*, which is not *n* itself. For example, the proper divisors of 12 are 1, 2, 3, 4 and 6.
You will be given **an integer** *x*, *x* ≥ 2, *x ≤ 1000*. Your task is to s... |
[Question]
[
>
> This is the cops' thread to a [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge. Click the link to find the [robbers' thread](https://codegolf.stackexchange.com/questions/242076/output-two-numbers-robbers-thread).
>
>
>
The challenge her... |
[Question]
[
Recently, someone proposed more stringent limits for Python's default line length:
>
> Clearly, no program should ever use more than 80 characters per line, for a whole host of reasons. First and foremost, for readability and maintainability, it is important to have a solid standard, so we can adjust ... |
[Question]
[
The challenge is to list all ordered partitions (composition (combinatorics)) of a given positive integer `n`. These are the lists of numbers from `1` to `n` whose sum is `n`. For example, given input `n = 4`, the result should be:
>
> 4
>
> 1, 3
>
> 3, 1
>
> 2, 2
>
> 2, 1, 1
>
> 1... |
[Question]
[
### Your task
Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$
### Example
Let's say we are given the inputs \$x=4\$ and \$d=2\$.
First, we get the series \$n^4\$:
* \$0^4 = 0\$
* \$1^4 = 1\$
* \$2^4 = 16\$
* \$3^4 = ... |
[Question]
[
Sometimes, while golfing, one needs to represent large number(s) in their code. Writing them as is can significantly increase the byte-count.
What *general*1 tips do you have for representing long numbers concisely in code?
Please post one tip per answer.
---
1With *general*, I mean tips that can be ap... |
[Question]
[
Given a nonnegative integer \$n\$, determine whether \$n\$ can be expressed as the sum of two square numbers, that is \$\exists a,b\in\mathbb Z\$ such that \$n=a^2+b^2\$.
```
0 -> truthy
1 -> truthy
2 -> truthy
3 -> falsy
4 -> truthy
5 -> truthy
6 -> falsy
7 -> falsy
11 -> fal... |
[Question]
[
[Quote notation](https://en.wikipedia.org/wiki/Quote_notation) is a way of expressing rational numbers based on the concept of [\$p\$-adic numbers](https://en.wikipedia.org/wiki/P-adic_number), written in the form \$x'y\$.
The quote indicates that the number to it's left (\$x\$) is "repeated" infinitel... |
[Question]
[
### Background
The [systematic chemical symbol](https://en.wikipedia.org/wiki/Systematic_element_name) is defined as such for \$ 118 < n < 1000 \$:
* The first letter corresponds to the first digit, capitalized.
* The second letter corresponds to the second digit.
* The third letter corresponds to the ... |
[Question]
[
Whenever I search for the running length of a movie in IMDb, it is displayed in minutes. Immediately I would try to convert it into hour(s) and minute(s). It would be better if we could automate this.
Input:
```
150 min
```
Output:
```
2 hours 30 minutes
```
Input:
```
90 min
```
Output:
```
1 hour 30 ... |
[Question]
[
Given a string, capitalize it. By capitalization I mean `conTeNT-lENgth` changes to `Content-Length`. In the example I showed the string with 2 words with `-` as the word boundary. However I expect you to write the code for the string containing any number of words separated by a **single** character a... |
[Question]
[
My [boss](https://codegolf.stackexchange.com/questions/137209/efficient-robot-movement) now wants me to implement a mechanism that lets him search for an item in an array, and gives him the index/indices where that value occurs.
## Your Task:
Write a program or function that receives an array and a va... |
[Question]
[
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits.
For example, when the given number is 177, whose binary representation is \$10110001\_{(2)}\$:
* \$ 10110001\_{(2)}=177 \$
* \$ 01100011\_{(2)}=99 \$
* \$ 11000110\_{(2)}=198 \$
* \$ 100... |
[Question]
[
Write the shortest code to reverse the bit order of a 32-bit integer.
**Rules:**
1. Input is assumed to be a valid integer or string equivalent if your language doesn't support numerical values (e.g. Windows Batch).
2. Output must be a valid integer or string equivalent if your language doesn't support... |
[Question]
[
[A recent SO question](https://stackoverflow.com/q/61348795/5306507) 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 a... |
[Question]
[
Your challenge: Write a function that takes a string `s`, a character `c`, and finds the length of the longest run of `c` in `s`. The length of the run will be `l`.
**Rules**:
* If `s` is of length 0 or `c` is empty, `l` should be 0.
* If there are no instances of `c` in `s`, `l` should be 0.
* [Standa... |
[Question]
[
# "Fit Numbers"
Sam has a "brilliant" idea for compression! Can you help?
---
Here is a rundown of Sam's compression scheme. First take in a base 10 representation of any natural number strictly smaller than 2^16, and write it as a binary string without any leading zeros.
```
1 -> 1
9 -> 1001
15 ->1111... |
[Question]
[
Given an input `n`, write a program or function that outputs/returns the sum of the digital sums of `n` for all the bases 1 to `n`.
$$n + \sum\_{b=2}^n \sum\_{i=0}^\infty \left\lfloor \frac{n}{b^i} \right\rfloor \bmod b$$
### Example:
`n = 5`
---
Create the range `[1...n]`: `[1,2,3,4,5]`
---
For each e... |
[Question]
[
Given a positive integer \$n\$ output an ASCII hexagon with diagonal side length \$n\$, as pictured (note there are \$2n\$ `_` characters on the top edge)
### Examples:
\$n = 1\$
```
__
/ \
\__/
```
\$n = 2\$
```
____
/ \
/ \
\ /
\____/
```
\$n = 5\$
```
__________
/ ... |
[Question]
[
*Inspired by [this](https://codegolf.stackexchange.com/questions/265087/dp-approach-gives-tle) (off topic) post*
Given an array of numbers, find the largest sum over a subarray not containing two adjacent elements
```
[1,2,3,4] -> 6 // [_,2,_,4]
[1,2,3,4,5] -> 9 // [1,_,3,_,5]
[2,2,1,... |
[Question]
[
[Pascal's triangle](https://en.wikipedia.org/wiki/Pascal%27s_triangle) is a triangular diagram where the values of two numbers added together produce the one below them.
This is the start of it:
```
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
```
You can see that the outside is all 1s, and each number is t... |
[Question]
[
**Input:**
a positive number \$n\$, smaller than \$80\$, from stdin or as a command-line argument.
**Output:** A square chessboard pattern, the size of the input number. The dark fields are represented by the letter `X`, the white fields by a space. The top-left field should be `X`.
A complete program ... |
[Question]
[
# Context
Consider the following sequence of integers:
$$2, 10, 12, 16, 17, 18, 19, ...$$
Can you guess the next term? Well, it is \$200\$. What about the next? It is \$201\$... In case it hasn't become obvious to you, this is the sequence of positive integers whose name starts with a letter `D` in Por... |
[Question]
[
This is the robbers' thread of [this](https://codegolf.stackexchange.com/questions/99155/polyglot-anagrams-cops-thread) challenge
The cops will choose an [OEIS](https://oeis.org) sequence and write two *full programs* in two different languages that produces that nth item in the sequence when given an ... |
[Question]
[
The [cross product](https://en.wikipedia.org/wiki/Cross_product) of two three-dimensional vectors \$\vec a\$ and \$\vec b\$ is the unique vector \$\vec c\$ such that:
* \$\vec c\$ is orthogonal to both \$\vec a\$ and \$\vec b\$
* The magnitude of \$\vec c\$ is equal to the area of the parallelogram fo... |
[Question]
[
Given two lists of numbers, a *source* and a *pattern*, reorder the source to match the relative ordering of the pattern. Any two entries of the reordered source should compare the same way as the entries at those same positions of the pattern.
For example, the input
```
s = [-5, 9, 4, 13, 11, -6, 0]
p... |
[Question]
[
Your challenge is to sort a string, but rather than by the normal alphabetical order (abc..xyz), you will be sorting strings by a specified alphabet.
You must write a program or function that takes two inputs: An alphabet **A** and an string **S**. Both will only contain lowercase English letters, and ... |
[Question]
[
# Introduction
Classically, booleans are one bit; `true` or `false`, `1` or `0`. Leading zeros would just be redundant. For example, `001` means the same as `00001` or just `1`.
# The 32-bit boolean
Given a truthy/falsey value, output the equivalent 32-bit boolean as a string.
(Or as a number if for *... |
[Question]
[
Today your goal is to find integers *a* and *b* given non-negative integer *n* such that:

You should write a program or a function that takes parameter *n* and outputs *a* and *b* in a format of your choice.
Standard loopholes ap... |
[Question]
[
Take the string `abcdfghjk`. To overwrite it, starting from `f`, with the string `wxyz`, you would continue along the original, replacing each character with the one from the replacement string. The result would be `abcdwxyzk`.
Now, consider a string which would be too long to fit, like `lmnopqrs`. Sta... |
[Question]
[
# Let me introduce you to GAU numbers
```
GAU(1) = 1
GAU(2) = 1122
GAU(3) = 1122122333
GAU(4) = 11221223331223334444
GAU(6) = 11221223331223334444122333444455555122333444455555666666
...
GAU(10) = 1122122333122333444412233344445555512233344445555566666612233344445555566666677777771223334444... |
[Question]
[
The [Bernoulli numbers](https://en.wikipedia.org/wiki/Bernoulli_number) (specifically, the second Bernoulli numbers) are defined by the following recursive definition:
[](https://i.stack.imgur.com/tNGGY.png)
Where [![mCk](https://i.stack.i... |
Subsets and Splits
Python Q&A Count
Counts the number of questions and answers related to Python in the dataset, providing insight into the prevalence of Python content.