text
stringlengths
180
608k
[Question] [ Inspired by [this](https://codegolf.stackexchange.com/questions/153978/generalized-matrix-trace). Agatha Stephendale, a sophomore who is really into raster graphics, has taken a course in linear algebra. Now she imagines matrices as rectangles, but in her artistic mind, she attaches diagonal lines to t...
[Question] [ **This question already has answers here**: [Tell me the moves](/questions/25018/tell-me-the-moves) (12 answers) Closed 6 years ago. Chess is a game with 6 different types of pieces that can move in different ways: * Pawns - They can only move up or capture diagonally (also forward). Capturing a...
[Question] [ # Introduction [Kipple](https://esolangs.org/wiki/Kipple) is a stack-based, esoteric programming language invented by Rune Berg in March 2003. Kipple has 27 stacks, 4 operators, and a control structure. ## Stacks The stacks are named `a`-`z` and contain 32-bit signed integers. There is also a special s...
[Question] [ A simple pedometer can be modeled by a pendulum with two switches on opposite sides—one at x=0 and one at x=***l***. When the pendulum contacts the far switch, the ambulator can be assumed to have taken half a step. When it contacts the near switch, the step is completed. Given a list of integers repre...
[Question] [ Given an input of a list of words and their abbreviations, output the pattern by which the abbreviations can be formed. Let us take the example input of ``` potato ptao puzzle pzze ``` as an example (that is, the abbreviation for `potato` is `ptao`, and the abbreviation for `puzzle` is `pzze`). Conside...
[Question] [ You are provided a set of arbitary, unique, 2d, integer Cartesian coordinates: e.g. [(0,0), (0,1), (1,0)] Find the longest path possible from this set of coordinates, with the restriction that a coordinate can be "visited" only once. (And you don't "come back" to the coordinate you started at). **Impor...
[Question] [ I really love sliding tile puzzles, but recently, I haven't had time for them. Hence, I need a program to give me my fix of sliding-tile puzzles, specifically Klotski puzzles. Your input will be in the following format: ``` ####### #001gg# ##.222# .###### ``` where `#` represents walls, `.` represents ...
[Question] [ # Introduction Most of you are familiar with the [merge sort](http://en.wikipedia.org/wiki/Merge_sort) algorithm for sorting a list of numbers. As part of the algorithm, one writes a helper function called `merge` that combines two sorted lists into one sorted list. In Python-like pseudocode, the funct...
[Question] [ Chris, a cryptic crosswords addict, has a set algorithm for the order in which he solves them. ![enter image description here](https://i.stack.imgur.com/YtkK7.jpg) We will use the above image as a guide. 1. Chris always starts off with the first across clue, in this case 1 Across. Chris is a capable cr...
[Question] [ Given a board, write the shortest program or function to display or return which characters are in sight of the player. A character is in sight if is possible to draw a line between it and the player, without crossing any characters that block vision. Input: * `@` represents the player's position. Ther...
[Question] [ I like my job, but sometimes it can get a bit tedious and boring. As motivation, I want to know how many hours of work are left before I finally get my two days of weekend and relaxation. * I work **every day** from Monday to Friday, totalling **38.5 hours**, starting at **9am** and ending at **6pm**. ...
[Question] [ Robber Thread [here](https://codegolf.stackexchange.com/q/217598/45613) ## The Challenge Choose any numeric\* formula, algorithm, or code challenge. Implement it in such a way that the math is correct, but at least one answer is *wildly*\*\* wrong due to some defect in how computers/programs operate, e...
[Question] [ ## About Hangul As I'm Korean, I'm really proud of Korean character, [Hangul](https://en.wikipedia.org/wiki/Hangul)(한글). Hangul is a syllabary invented by King Sejong the great, 4th king of Joseon dynasty, in 1443. Because today (October 9th) is Hangul day in Korea, I'll give you a challenge: Make some...
[Question] [ # Introduction In a general election, one would like to calculate a constant price per parliament seat. This means that for `N >= 0` seats to be distributed and a list `ns` of votes per party, we would like to find a number `d` such that ``` sum(floor(n/d) for n in ns) == N ``` To make things interest...
[Question] [ Someone gave my wife a decorative calendar consisting of four cubes. Here it is showing today's date (as of the posting of this challenge) on the front: [![enter image description here](https://i.stack.imgur.com/CfORU.jpg)](https://i.stack.imgur.com/CfORU.jpg) When I first saw it, I looked at it from t...
[Question] [ Given an ordered list of 2 or more 2D cartesian points, output a truthy value if either the path touches itself or self-intersects; otherwise output a falsy value if it does not touch itself or self-intersect. You may assume that consecutive points in the list are distinct. ### Examples: ``` (0,0), (1,...
[Question] [ Given an input list of non-empty strings, output an ASCII art representation of a tournament, based on the following drawing rules: * The number of strings is guaranteed to be of quantity `2,4,8,16,etc.` * The first two strings play each other, and the next two play each other, and so on. This is the f...
[Question] [ Given three integers >= 2, create an ASCII cube in an orthogonal (cabinet) projection. The three integers represent height, width and depth (measured in visible characters) including the corners. The corners should be 'o's or '+', free choice. w: 10, h: 5, d: 4 Thus gives: ``` o--------o / ...
[Question] [ The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two strings of equal length is the number of positions at which the corresponding symbols are different. Let `P` be a binary string of length `n` and `T` be a binary string of length `2n-1`. We can compute the `n` Hamming di...
[Question] [ You are an employee at the hip new grocery store Half Foods, and it's the day before ~~Thanksgiving~~ ~~Christmas~~ Easter. Since the store will be packed with customers rushing to get their foodstuffs, the store needs a traffic manager to send everyone to the appropriate lines. Being lazy, you'd like ...
[Question] [ **Question** You have a 50 by 50 character array. Each cell has an arrow pointing in any one of four directions. No cell is empty. On entering a cell, you must exit it in the direction specified by the arrow. The arrow may also point in the same direction you came from, resulting in a dead end. You may...
[Question] [ This challenge is the first of a series of [fewest-operations](/questions/tagged/fewest-operations "show questions tagged 'fewest-operations'") problems that should be written in the [GOLF CPU](https://codegolf.meta.stackexchange.com/questions/5134/the-golf-cpu-framework). You can find the next one [he...
[Question] [ # Scriptbot Warz! --- The results are in and *Assassin* is our champion, winning 2 of 3 matches! Thanks to everyone who submitted their Scriptbots! Special thanks to *horns* for *BestOpportunityBot* which displayed excellent pathing and made full use of all action options. **Map 1** Assassin took out B...
[Question] [ Your challenge is to create a clock that displays the time as a hex number, and the background color as the hex color code of the time. Requirements: No input. In the center of your output you should display the number sign and the current time in 24 hour format as "#hhmmss". The program should update...
[Question] [ This is a word game from a set of activity cards for children. Below the rules is code to find the best triplet using /usr/share/dict/words. I thought it was an interesting optimization problem, and am wondering if people can find improvements. ## Rules 1. Choose one letter from each of the sets below....
[Question] [ Imagine a simple SKI calculus expression - for example, `(((S α) β) γ)`. As you can see, each node of the rooted tree has exactly two children. Sometimes though, the parentheses are omitted and the tree is unrooted (just to make the notation clear, I believe). The challenge is to put the parentheses ba...
[Question] [ According to [Wikipedia](https://en.wikipedia.org/wiki/Darboux%27s_theorem_(analysis)#Darboux_function), a strongly Darboux function is > > one for which the image of every (non-empty) open interval is the whole real line > > > In other words, a function \$f\$ is strongly Darboux if given 3 arbitra...
[Question] [ Bob got kidnapped and is stuck in a maze. Your job is to help him find a way out. But since it is a very dark and scary maze, he can't see anything. He can only feel walls when he runs in to it, and knows when he has found the exit, but doesn't know anything more that. Since he has to run your program ...
[Question] [ The 5-card magic trick involves a magician whose assistant gives them 4 shown cards and a hidden one, in this order, and the magician must guess the hidden one. # WARNING: Solution below! Leave now or get spoiled with it. --- ### The solution The trick here is that the five cards are given *in a specif...
[Question] [ A convenient and useful way to represent topological surfaces is with a [fundamental polygon](https://en.wikipedia.org/wiki/Fundamental_polygon). Each side on a polygon matches to another side and can be either parallel or anti-parallel. For instance the here is the fundamental polygon of a [torus](htt...
[Question] [ Inspired by [this challenge](https://codegolf.stackexchange.com/questions/109897/animate-the-text-in-your-terminal) --- ## Goal: The goal is to draw waves crashing onto a beach. ## Input: You will be given 3 integers (in whatever format you want) as input. The first integer will be the length of the...
[Question] [ *This challenge is based on the game [Layerz.](http://layerzgame.com/)* Given, on stdin or as a function argument, a 2D rectangular array of cells where each cell contains either a blank (you may choose to use 0s instead of blanks at no penalty), a 1, a 2, a 3, or a 4; find a way to divide it into vali...
[Question] [ Let's build a simulation for an aspect in the card game, which I personally know by the Dutch name 'Oorlog' (translates to 'War'). ## How does 'Oorlog' work? Two decks of cards (each including two Jokers) are equally divided between the amount of players playing. Each player shuffles their own stock, p...
[Question] [ Because rickrolling is the greatest meme on Earth, you *[know the rules and so do I]* are to write the shortest code that can textually rickroll the unsuspecting reader. Let *[you down]* there be an input text which contains letters, punctuation, and spaces. Anytime a *[lie and hurt you]* phrase from t...
[Question] [ # Objective Design a [**mo**dulator/**dem**odulator pair](https://en.wikipedia.org/wiki/Modem) to accurately transmit data as quickly as possible over simulated [plain old telephone service (POTS)](https://en.wikipedia.org/wiki/Plain_old_telephone_service). # Steps 1. Generate some random (`/dev/random...
[Question] [ # Scores This section will be filled in as submissions are entered. **Normal** ``` 1. bopjesvla Perl 54 2. edc65 Javascript (ES6) 91 3. name language score 4. name language score 5. name language score ``` **Bonus Roun...
[Question] [ Given a list of strings, find the **smallest square** matrix that contains each of the initial strings. The strings may appear horizontally, vertically or diagonally and forwards or backwards like in this question [Word Search Puzzle](https://codegolf.stackexchange.com/questions/37940/word-search-puzzl...
[Question] [ We define a [Collatz](http://en.wikipedia.org/wiki/Collatz_conjecture)-like sequence `s` with 4 positive integers: * `n` starting value * `d > 1` divisor * `m > 1` multiplier * `i` increment (In the original Collatz sequence `d = 2` `m = 3` and `i = 1`.) Given these integers `s` will be created in the ...
[Question] [ In this contest you have to write a program, that accepts a black and white pixel image, and tries to alter it, such that the white shape forms **star domain**, with as few changes as possible. Allowed changes are turning white pixels into black ones and turning black pixels into white ones. The output...
[Question] [ Here's one for all you wordsmiths out there! Write a program or function which takes a list of words and produces a list of all possible concatenative decompositions for each word. For example: ***(Note: This is only a small sampling for illustrative purposes. Actual output is far more voluminous.)*** ...
[Question] [ This is a code golf puzzle with a real-world application. Some current browsers, if you enter a URL that looks like ``` data:text/html,<script>alert("hi")</script> ``` will execute the given JavaScript code. Now suppose you had a URL which looked like (pseudocode): ``` data:text/html,<script> myPub...
[Question] [ I present to you a test! Your test is to test. The test is to test the testee with tests a tester gives you, in the shor**test** amount of code. Specifically, you will give a multiple choice test that you have recieved as input. In this challenge, you must take an input like this: ``` 1. Our site is ca...
[Question] [ # BlackJack > > As I had a blast working on the > original KOTH challenge, I wanted to > come up with another one. For me, the fun > of these AI challenges is in refining > a comparatively simple bot which plays > a very simple game subtly. Due to the > probabilistic nature of card games, I > t...
[Question] [ Related: [Clearly parenthesize APL trains](https://codegolf.stackexchange.com/q/150380/78410) ## Background In the most basic form, APL has two kinds of tokens: **arrays** and **functions**. For this challenge, we will use a lowercase letter `a-z` for an array, and an uppercase letter `A-Z` for a funct...
[Question] [ In [association football](https://en.wikipedia.org/wiki/Association_football) (also known as soccer), a [penalty shoot-out](https://en.wikipedia.org/wiki/Penalty_shoot-out_(association_football)) is the second tie-breaker measure that may be used in a match which can't end in a tie, after extra time (i...
[Question] [ In the game 2048, you have a grid, and you can move the elements in four directions. They all move in that direction as far as they can. For this challenge, you will be given a padded, square 2D string (either with newlines, or a list of strings), like so: ``` ab cd e f ghij kl mno p q r s...
[Question] [ Imagine I have an infinite number of homework problems (!) each given an integer number. Math Problem Notation is a notation for describing subsets of the problem using problem specifiers. An MPN expression can consist of several things: * A single value. This represents a set containing the number: `9...
[Question] [ An easy way to understand the unit n-dimensional hypercube is to consider the region of space in n dimensions that you can get if every coordinate component lies in [0, 1]. So for one dimension it's the line segment from 0 to 1, for two dimensions it's the square with corners (0, 0) and (1, 1), etc. Wr...
[Question] [ **Warning: DO NOT take medical advice from this post. If you want medical advice, go to a qualified professional.** I have a headache. I need headache pills. I'll tell you the last few doses I've had, and you tell me when I can have my next dose, without overdosing. I'll give you this string: `P: 00:00...
[Question] [ ### Background Very skilled card handlers are capable of a technique whereby they cut a deck perfectly in half, then perfectly interleave the cards. If they start with a sorted deck and perform this technique flawlessly 52 times in a row, the deck will be restored to sorted order. Your challenge is to ...
[Question] [ **Background:** MtDNA is a part of the human DNA that is passed from a mother to a child and it rarely mutates. Since this is true for all humans it is possible to create a huge tree that visualize how all humans are related to each other through their maternal ancestry all the way back to the hypothet...
[Question] [ In Python, you can use the `dir` function on any object to get a list of the names of its instance functions: ``` >>> dir('abc') ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__g...
[Question] [ # Background In a galaxy (and possibly a universe) far, far away... there was a spaceship and a bunch of planets. A malfunction on board caused the spaceship to run out of fuel. It is now moving at a dangerously slow speed near a cluster of planets, from which it must escape! What will be the crew's fa...
[Question] [ The 8 Puzzle is the smaller variant of the 15Puzzle (or the [Sliding puzzle](http://en.wikipedia.org/wiki/Fifteen_puzzle)). You have a `3x3` grid which is filled with numbers from 0-8 (0 denotes the blank tile) arranged in a random order. Your task is to input a 3x3 grid and show the shortest solution...
[Question] [ Recamán's sequence ([A005132](http://oeis.org/A005132)) is a mathematical sequence, defined as such: $$A(n) = \begin{cases}0 & \textrm{if } n = 0 \\ A(n-1) - n & \textrm{if } A(n-1) - n \textrm{ is positive and not already in the sequence} \\ % Seems more readable than %A(n-1) - n & \textrm{if } A(n-1)...
[Question] [ Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Lets define 4 matrix moves as: * ↑\* (up): Moves a column up * ↓\* (down): Moves a column down * →\* (right): Moves a row to the right * ←\* (left): Moves a row to the ...
[Question] [ # Introduction You have a friend that keeps asking you for loans and you are getting tired of it. Today, he came for a loan again. Instead of turning down his offer, you get a great idea: troll your friend by giving him as many coins/bills as possible. # Challenge You will take as input: the amount of ...
[Question] [ ## Introduction Sharp edges are, frankly, just plain dangerous so, given a PNG as input, blur the image using the method described below and blunt those damned sharp edges. ## Method To get the RGB value of each pixel, use the following three equations: $$R = \sqrt{\frac{1.5\times\sum^n\_{a=1}R^2\_a}{n...
[Question] [ Given a black-and-white image in any [reasonable lossless format](http://meta.codegolf.stackexchange.com/q/9093/45941) as input, output ASCII art that is as close to the input image as possible. ## Rules * Only linefeeds and ASCII bytes 32-127 may be used. * The input image will be cropped so that ther...
[Question] [ Given the ASCII art of two vectors, find the resultant vector's magnitude and degree. --- ## Input This can be received via STDIN, read from a local file, or provided through a function call. Here is an example of a two vector input: ``` ^------> | | | x ``` This represents a change of 4 units north an...
[Question] [ # The lost pawn problem After the chess game ended, a surviving pawn was left behind enemy lines. let's help him find the shortest way back home. The original problem describes a nXn "chess" board, and a function `f: {1,..,n-1}X{1,..,n}X{-1,0,1} => R+` of weights. the goal is to find the best path from...
[Question] [ You should write a program or function which given a list of tetris blocks as input outputs or returns the biggest gap between two points in the same height level which the pieces can connect. The 7 types of tetris pieces are the following: [![Tetris bricks](https://i.stack.imgur.com/YcgOC.png)](http:/...
[Question] [ Suppose you are given a set of **non-intersecting** intervals of integers `[a1,b1],[a2,b2],[a3,b3],...,[aN,bN]`. (Where `[a,b]` is the set of integers greater than or equal to `a` and less than or equal to `b`.) The interval at index `X` covers `bX - aX + 1` values. We'll call this number `cX`. Given t...
[Question] [ Consider how a word could be arranged on an arbitrarily large [Boggle](http://en.wikipedia.org/wiki/Boggle) grid ***if the rule about not using the same letter cube more than once is ignored***. Also assume that you have an unlimited number of letter cubes (with all letters present), and `Qu` is just `...
[Question] [ "A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much *entropy*, rather than information, can a picture convey? Your task is to generate an image, exactly 4,000 bytes in size, with the highest ...
[Question] [ [Earlier](https://codegolf.stackexchange.com/questions/140560/how-hard-can-i-crush-my-array) I defined the process of crushing an array > > In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double the second one. > > ...
[Question] [ In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic prominence" of 300 or more feet. This means that to move from one 14er to another, you must first desce...
[Question] [ *Based on an idea suggested by [Zgarb](https://codegolf.stackexchange.com/users/32014/zgarb).* A spaceship is moving around a regular 3D grid. The cells of the grid are indexed with integers in a right-handed coordinate system, *xyz*. The spaceship starts at the origin, pointing along the positive *x* ...
[Question] [ Football is the sport where players kick the ball, not carry it. Some confused individuals might call this soccer. --- A football team has one goalkeeper, and 10 players out on the pitch. There are many [formations](https://en.wikipedia.org/wiki/Formation_(association_football)) used in football, that ...
[Question] [ You sit at home, rubbing your hands in a most evil fashion. *This time, I'll be able to set the community A-SPIN! I'll merely claim that I have proven this problem (which is of no doubt improvable) inside this book here…* You open to the first relevant page. You scrawl those words… You are, of course, ...
[Question] [ Write a program or function that takes in a list of positive integers. Each of these integers represents the side length of a square on a 2D plane. Each square can be moved to any integer coordinates in the plane, but it can't rotate and it can't overlap other squares. Using a different [printable ASCI...
[Question] [ ### Overview Given a list of fireworks `a-z` and times `3-78`, arrange them with fuses to make them all light up at the correct time. A line of input is given as space separated letters and numbers: ``` a 3 b 6 c 6 d 8 e 9 f 9 ``` That example shows that firework `a` need to light at time `3`, `b` and ...
[Question] [ ## Goal In this competition, you are given a random room with one candle inside. The goal is to write the shortest program (this is golf) that determines what parts of the room are illuminated by the candle, by replacing the dark spots with `@`'s. The program should take a room from STDIN, with the out...
[Question] [ It is easy to describe a finite state machine that recognizes multiples of 9: keep track of the digit sum (mod 9) and add whatever digit is accepted next. Such a FSM has only 9 states, very simple! By the equivalence between FSM-recognizability and regular languages, there is a regular expression for m...
[Question] [ # Pokerface ### Introduction Leo enjoys playing poker, but his job at Tech Inc. is too demanding for him to learn how to play well. Leo, being a computer scientist, is not discouraged. He decides to take more time than it would have taken to just learn poker, and use it to write a poker bot to help him...
[Question] [ A bunch of cars are lined up at a 4-way stop sign waiting to proceed. Everyone is confused about who gets to go next, who is going which way, etc. Clearly suboptimal. Your job is to schedule the traffic at the stop sign in an optimal fashion. You receive as input 4 strings of turn requests, one for eac...
[Question] [ **Edit: I will be posting a newer version of this question on `meta-golf` soon. Stay tooned!** **Edit #2: I will no longer be updating the challenge, but will leave it open. The `meta-golf` version is available here: <https://codegolf.stackexchange.com/questions/106509/obfuscated-number-golf>** # Backg...
[Question] [ You are a taxicab driver in San Francisco. As is typical of taxicab drivers, you are navigating a grid where the only valid directions you can move are the left, right, up, and down. However, San Fransisco is very hilly so the distance between two adjacent intersections is not necessarily the same. Mor...
[Question] [ ## Background The twelve-coin problem is a classic [balance puzzle](http://en.wikipedia.org/wiki/Balance_puzzle) commonly used in job interviews. The puzzle first appeared in 1945 and was posed to my father by my grandfather when he asked to marry my mother! **In the puzzle there are twelve coins, one ...
[Question] [ Does anybody have tips for golfing in Erlang? I'm looking for specific things that can be applied to Erlang, not any language. I know we already have tips for Elixir, but that is different. As usual, please post separate tips in separate answers. [Answer] ## Use the ending conditions Suppose you ...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/16185/edit). Closed 6 years ago. [Improve this question](/p...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/19705/edit). Closed 7 years ago. [Improve this question](/p...
[Question] [ *This [answer-chaining](/questions/tagged/answer-chaining "show questions tagged 'answer-chaining'") challenge is officially over, resulting in the win of **[Wheat Wizard](https://codegolf.stackexchange.com/users/56656/wheat-wizard)**, with a total of 7 answers. Any other answer is welcome, but it won'...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- This question does not appear to be about code golf or coding challenges within the scope defined in the [help center](https://codegolf.stackexchange.com/help/on-topic). Closed 7 years ago....
[Question] [ **This question already has answers here**: [Palindromic palindrome generator](/questions/47827/palindromic-palindrome-generator) (39 answers) Closed 7 years ago. Your task is to palindromize a string as follows: Take the string. ``` abcde ``` Reverse it. ``` edcba ``` Remove the first letter. `...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/20487/edit). Closed 7 years ago. [Improve this question](/p...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/16954/edit). Closed 8 years ago. [Improve this question](/p...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/20558/edit). Closed 8 years ago. [Improve this question](/p...
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/24747/edit). Closed 9 years ago. [Improve this question](/p...
[Question] [ This is the first in a series, the second is [Two roads diverged in a yellow wood (part 2)](https://codegolf.stackexchange.com/questions/114379/two-roads-diverged-in-a-yellow-wood-part-2) This challenge is inspired by Robert Frost's famous poem, "The Road Not Taken": > > Two roads diverged in a yellow...
[Question] [ Let's define the "unwrapped size" function `u` of a nested list `l` (containing only lists) by the following rules: * If `l` is empty, then `u(l)` is 1. * If `l` is non-empty, `u(l)` is equal to the sum of the unwrapped sizes of every element in `l`, plus one. Your task is to write a program (or functi...
[Question] [ There is a well known question [here](https://codegolf.stackexchange.com/questions/85/fibonacci-function-or-sequence) that asks for a short (least characters) fibonacci sequence generator. I would like to know if someone can generate the first N elements only, of the fibonacci sequence, in very short s...
[Question] [ # Introduction The Cartesian product of two lists is calculated by iterating over every element in the first and second list and outputting points. This is not a very good definition, so here are some examples: the Cartesian product of `[1, 2]` and `[3, 4]` is `[(1, 3), (1, 4), (2, 3), (2, 4)]`. The pr...
[Question] [ Let's say I have a non-empty list (array): ``` l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ``` I want to incrementally slice the list into incremented amount of elements per chunk. For this array, my desired output is: ``` [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10]] ``` What would be the best way to slice the arra...
[Question] [ ## Challenge: Given the input number `n`. It should give me nested sublists of `n` layers with the [power of two](https://en.wikipedia.org/wiki/Power_of_two) numbers for each level. Each power of two value will be in separate sublists. ## Notes: * `n` will always be greater than 0 * I am using the exam...
[Question] [ **Make me an icecream cone please** We have a ton of great ice cream places here in New England. Most of them are closed for the winter now, so... ``` .-@@-. (======) (--------) (==========) (__________) \/\/\/\/\/ \/\/\/\/ \/\/\/ \/\/ \/ ``` **GOAL** Output the above icecream con...
[Question] [ Given a sequence of three integers, determine if the sequence is arithmetic (of the form `[a, a+d, a+2*d]`) or geometric (of the form `[a, a*r, a*r^2]`) by outputting a fourth term that completes it (`a+3*d` for arithmetic, `a*r^3` for geometric). Examples: ``` [1, 2, 3] -> 4 (This is an arithmetic seq...
[Question] [ ## Background You have been given the task of calculating the number of landmines in a field. You must calculate the landmine score given a list/string of numbers and the landmine number. The landmine number tells you where landmines are. For each digit: 1. if the left digit plus the right digit is equ...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/115342/edit). Closed 6 years ago. [Improve this question](/posts/115342/edit)...
[Question] [ Consider a list of subject, grade pairs. E.g. ``` [("Latin", "A"), ("French", "A*"), ("Math", "B"), ("Latin", "A*")] ``` The task is to return the same list but with each subject given at most once. Where a subject occurred more than once originally, the returned list should have the highest grade fo...