Skip to main content

Questions tagged [subsequence]

Challenges pertaining to a sequence within a larger sequence

Filter by
Sorted by
Tagged with
23 votes
16 answers
2k views

Given a string of space delimited words, find the longest word such that, when that word is replaced with spaces, it is still a subsequence of the remaining string. Then, replace everything, except ...
thejonymyster's user avatar
12 votes
5 answers
490 views

In this challenge you will write code to take a list of positive integers and output all maximal linear sublists. A sublist is is a list which can be created by deleting values from the the input ...
Wheat Wizard's user avatar
  • 103k
9 votes
11 answers
910 views

Brief description of the game In the game Otteretto Classic (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. ...
Luis Mendo's user avatar
  • 107k
-3 votes
7 answers
1k views

Challenge You are supposed to output the series I recently designed which goes as follows which are pen stroke counts of ascending prime numbers: ...
aitzazisstuffed's user avatar
7 votes
6 answers
497 views

I have a follow-up question here from my previous question on Math SE. I am lazy enough to explain the content again, so I have used a paraphraser to explain it below: I was considering arbitrary ...
aitzazisstuffed's user avatar
8 votes
18 answers
848 views

Let's say you are given an integer array. Create a function to determine the largest sum of any array's adjacent subarrays. For instance, the contiguous subarray with the largest sum is ...
user avatar
16 votes
25 answers
2k views

Given as input a positive nonzero integer n >= 10 and a sequence of digits 0-9 (which may be taken as a string or a list), ...
Ginger's user avatar
  • 6,098
15 votes
12 answers
1k views

Write 2 programs in the same language which count the number of shared subsequences of consecutive elements from 2 given sequences. For example, given ...
Fatalize's user avatar
  • 39.6k
17 votes
9 answers
2k views

inspired by Longest Increasing Substring Task Given a list of non-negative integers, output the length of its longest alternating subsequence. An alternating sequence is a sequence of numbers which ...
Bubbler's user avatar
  • 79.3k
29 votes
34 answers
4k views

Background A backronym is an acronym that was formed from an existing word. For example, spam is actually named after the canned meat product as used in the Monty Python sketch, but can be ...
pxeger's user avatar
  • 25.3k
15 votes
11 answers
2k views

Related, but not dupe. Challenge A list of integers \$a_1, a_2, a_3, \dots, a_n\$ (\$ n ≥ 1 \$) is Fibonacci-like if \$a_i = a_{i-1} + a_{i-2}\$ for every \$i > 2\$. Note that every list that ...
badatgolf's user avatar
  • 1,517
11 votes
7 answers
759 views

Given two sets of strings, \$ D \$ and \$ R \$, find the shortest string which contains every string in \$ D \$, but contains none of the strings in \$ R \$. There are almost always multiple possible ...
pxeger's user avatar
  • 25.3k
19 votes
8 answers
2k views

Given a string, like potatocarrot, break it into the smallest number of substrings possible. These substrings can consist either be a single character, or one of a ...
rydwolf's user avatar
  • 19.3k
31 votes
35 answers
4k views

The Fibonacci Sequence is a sequence of positive integers where the first two elements are 1 and the rest are the sum of the previous two. It begins \$1, 1, 2, 3, 5, 8, 13\$ and continues forever. But ...
emanresu A's user avatar
  • 46.2k
13 votes
8 answers
940 views

Make a program that outputs a sequence of integers so that every finite sequence of positive integers is a substring (continuous subsequence) of the output. For example, the following sequence ...
AnttiP's user avatar
  • 8,048
23 votes
25 answers
1k views

Your input is an array of numbers: a permutation of \$\{1, 2 \dots n\}\$ for some integer \$n \geq 2\$. How many times must you repeat this list before you can "pick out" the numbers \$[1, 2 ...
lynn's user avatar
  • 69.7k
21 votes
13 answers
2k views

You will be given as input an infinite stream of positive integers. Your task is to write a program which outputs an infinite sequence of lists with two requirements: All lists in the output are ...
Wheat Wizard's user avatar
  • 103k
16 votes
17 answers
1k views

Thanks to rak1507 for the suggestion "Random" in this challenge always refers to "uniformly random" - of all possible choices, each has an equal chance of being chosen. Uniform ...
caird coinheringaahing's user avatar
24 votes
27 answers
2k views

Challenge Given an input string X, determine if X can be obtained from reshaping a strict prefix of itself (a prefix that is not ...
Fmbalbuena's user avatar
  • 5,085
24 votes
29 answers
3k views

Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 5, Part 2. Santa needs help figuring out which strings in his text file are naughty ...
Bubbler's user avatar
  • 79.3k
26 votes
34 answers
3k views

Given an array of integers, count the number of contiguous subarrays with an even sum. You may assume that the array is non-empty, and contains only non-negative integers. This is code-golf, so the ...
dingledooper's user avatar
  • 23.4k
11 votes
22 answers
2k views

Given a long multi-sentence string, the goal is the count the occurrences of the following words: park, lake, ...
Taako's user avatar
  • 589
23 votes
23 answers
3k views

Given an array of integers. Find out its longest sub-array (contiguous subsequence) whose sum is 0. The sub-array for output may be an empty array. Input Input an array of integers. Output Output the ...
tsh's user avatar
  • 36.2k
34 votes
26 answers
4k views

Inspired by Wzl Determine if a given square binary matrix has exactly one row or column consisting of entirely 1s, and the rest of the matrix is ...
caird coinheringaahing's user avatar
20 votes
19 answers
2k views

Inspired by this: http://nolandc.com/smalljs/mouse_reveal/ (source). A valid answer: Takes a number \$w\$ and (assumed non-negative) integer \$x\$. Starts with an integer list with a length of \$2^w\$...
Wezl's user avatar
  • 1,496
17 votes
19 answers
3k views

Given a permutation of the alphabet and an intended "word", determine if the word was guessed in a game of Hangman, where the permutation is the list of guesses. For example, given ...
caird coinheringaahing's user avatar
14 votes
2 answers
560 views

Try it online! currently has 680 listed languages, all of which are searchable. For most of those languages, when searching for it, you don't have to enter the entire string. For example, entering <...
caird coinheringaahing's user avatar
12 votes
15 answers
890 views

Given two strings \$ A \$ and \$ B \$ and a positive integer \$ n \$, determine whether \$ B \$ is composed entirely of (possibly overlapping) strict substrings of \$ A \$ of a length of at least \$ ...
pxeger's user avatar
  • 25.3k
18 votes
21 answers
3k views

Create a function (or closest equivalent, or full program) that takes an list of some datatype (your choice) that may be nested and a string (in either order), and generalizes the lisp c[ad]+r ...
Wezl's user avatar
  • 1,496
19 votes
13 answers
1k views

Given two strings a and b, count how many times b occurs as a substring in ...
pxeger's user avatar
  • 25.3k
44 votes
39 answers
8k views

From the subreddit r/SpeedOfLobsters: Edit the text of an image to create a new phrase This meme format/style is pretty self-explanatory. Simply have a browse through the subreddit if you need more ...
caird coinheringaahing's user avatar
20 votes
19 answers
2k views

A marquee is a low-tech board that allows customizable letters. For example, here is a marquee: SALE ON SNEAKERS However, someone might come along and vandalize it ...
Stephen's user avatar
  • 14.2k
18 votes
19 answers
2k views

What is the Fibonacci Rectangular Prism Sequence? The Fibonacci Rectangular Prism Sequence is a sequence derived from the Fibonacci sequence starting with one. The first 3 numbers of the Fibonacci ...
nthnchu's user avatar
  • 399
6 votes
12 answers
1k views

(Inspired by the Keg utility of this challenge) Given a non-empty input string, e.g. s c 1= e(a"E"), split the input into even-odd chunks. Example (Feel free to ...
user avatar
4 votes
2 answers
280 views

Let me know if this task has already been posed. I haven't found it when I looked. Input master sequence \$\ X = x_1\dots x_n\$: sequence of characters, eg. \$\rm international\$ subsequence \$\ Y = ...
kyrill's user avatar
  • 615
46 votes
23 answers
4k views

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 ...
Sara J's user avatar
  • 3,855
39 votes
27 answers
3k views

We all know the age-old debate - should strings be length-prefixed or should they be null-terminated? Well, you've run into a blob of binary data and apparently whoever made it decided that the best ...
Sara J's user avatar
  • 3,855
24 votes
10 answers
3k views

When making phone calls internationally, phone numbers are prefixed with a code indicating what country the number is located in. These codes are prefix codes, meaning that no code is a prefix of ...
Sara J's user avatar
  • 3,855
5 votes
2 answers
609 views

Challenge Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the ...
Mike Ponemariko's user avatar
16 votes
13 answers
1k views

Challenge Create a function takes in two 2-dimensional arrays of characters (or strings if the programming language does not have characters as a datatype) as inputs: a and b. If your language does ...
Hazard's user avatar
  • 161
32 votes
31 answers
5k views

Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no ...
Sara J's user avatar
  • 3,855
25 votes
29 answers
3k views

Background For this challenge, a 'metasequence' will be defined as a sequence of numbers where not only the numbers themselves will increase, but also the increment, and the increment will increase by ...
Geza Kerecsenyi's user avatar
5 votes
0 answers
234 views

Introduction This is a little challenge with the goal of identifying repeated pattern "blocks" in a string, and outputting them with their frequency of occurence from left to right. A friend ...
R. Gosman's user avatar
19 votes
21 answers
1k views

Given a non-empty matrix of non-negative integers, answer which unique rows contribute most to the sum total of elements in the matrix. Answer by any reasonable indication, for example a mask of the ...
Adám's user avatar
  • 31.8k
20 votes
23 answers
3k views

My two kids like to play with the following toy: The colored areas with the shapes inside can be touched and the turtle then lights the area and plays a sound or says the name of the color or the ...
Charlie's user avatar
  • 13k
19 votes
20 answers
4k views

Challenge: Given a positive integer, output the longest single-digit subsequence that occurs at least twice, AND has boundaries of another digit (or the start/end of the integer). An example: Input: <...
Kevin Cruijssen's user avatar
1 vote
11 answers
3k views

Okay, so I saw this in a meme and decided it'd be the perfect code golf challenge: I prefer to increase the side of my indents according to the Fibonacci sequence: ...
AJFaraday's user avatar
  • 11.8k
10 votes
8 answers
652 views

Introduction: After I posted two rainbow-related challenges: Codegolf Rainbow : Fun with Integer-Arrays 1 and Codegolf Rainbow : Draw in Black-and-White 2, the following comment was made by @ChrisM in ...
Kevin Cruijssen's user avatar
22 votes
2 answers
542 views

A set of n positive numbers has 2^n subsets. We'll call a set "nice" if none of those subsets have the same sum. ...
izzyg's user avatar
  • 42.3k
12 votes
8 answers
2k views

Introduction: Although I originally had a Dutch song in my head, where the lyrics are: "Doe 'n stapje naar voren, en 'n stapje terug" (which translated to "Take a little step forward, and a little ...
Kevin Cruijssen's user avatar