Questions tagged [subsequence]

Challenges pertaining to a sequence within a larger sequence

Filter by
Sorted by
Tagged with
3
votes
11answers
790 views

Even-Odd chunks

(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 ...
2
votes
2answers
181 views

How many ways can given subsequence occur in given sequence?

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 = ...
40
votes
21answers
4k views

Is it a circumfix?

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 ...
35
votes
25answers
3k views

Length-terminated sequences

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 ...
19
votes
10answers
2k views

Where are they calling from?

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 ...
3
votes
1answer
150 views

Highest cardinality grouping of contiguous integers with minimum-sum threshold

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 ...
10
votes
10answers
681 views

Determine if a grid contains another grid

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 ...
30
votes
30answers
3k views

Greatest common substring

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 ...
25
votes
28answers
3k views

Make me a metasequence

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 ...
5
votes
0answers
162 views

Pattern Finder - Find Repeated Pattern in String [closed]

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 asked ...
17
votes
20answers
852 views

Most contributing rows

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 ...
20
votes
23answers
3k views

Playing with the musical turtle

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 ...
17
votes
18answers
4k views

Longest Repeating Subsequence of a Single Digit

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:...
1
vote
10answers
711 views

Indent your code according to Fibonacci

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: ...
9
votes
6answers
478 views

Codegolf Rainbow : Sorting Colors with Reflection

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 ...
22
votes
2answers
444 views

Subset Sum Orderings

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. ...
12
votes
8answers
2k views

Indexing Cha-Cha Slide

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 ...
23
votes
11answers
2k views

The Ever-Increasing Graph

Consider a one-dimensional sequence of numbers within a fixed range, i.e. [1, 2, 4, 6, 8, 0, 2, 7, 3] in range [0, 10⟩ The Ever-Increasing Graph* ** is a line ...
6
votes
5answers
388 views

Visit and exit an array

Challenge: Input: An integer n (> 0) An integer-array a of size ...
16
votes
24answers
1k views

ID generator with no matching contiguous pairs

Given 2 inputs (m=minimum starting id, n=number of ids), generate a sequential list of ids, starting at >=m, made up of the digits 0-9 where no 2 contiguous numbers are the same, e.g. 1232 is ok, 1233 ...
27
votes
9answers
1k views

Collapse the antistring

In this challenge you will be given an alphabetic string as input. We will define the "anti-string" of a given input to be the string with the case of all the letters inverted. For example ...
19
votes
25answers
1k views

Column-wise summation of overlapping slices

Task Given a list of integers L and another integer s, the goal is to compute the column-wise sums of all s-length (potentially overlapping) slices of L, while pertaining their positions relative to ...
13
votes
3answers
408 views

Remove entries from array to sort it and maximize sum of elements

This challenge is from an admission test to a closed number cyber security course. Anyway it doesn't have to do with cyber security, it's just to test the students logical and coding skills. Task ...
0
votes
4answers
152 views

Partition it into as few disjoint contiguous increasing subsequences as possible [closed]

Specification This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few substrings as possible, such that each substring ...
8
votes
8answers
819 views

Extension of the Game of Sevens

Introduction Output all the numbers in specific base that would appear in an adapted version of the game of seven. Challenge Your task is to output all the numbers in a given base in a given range, ...
10
votes
8answers
349 views

Collection from a sequence that constitute a perfect square

Given the sequence OEIS A033581, which is the infinite sequence, the n'th term (0-indexing) is given by the closed form formula 6 × n2 . Your task is to write code, which outputs all the subsets of ...
28
votes
15answers
2k views

Help pannenkoek count A presses

pannenkoek2012 aims to complete Super Mario 64 with as few presses as possible of the A button, which makes Mario jump. Each "A press" consists of three parts: Pressing the button Holding it for any ...
23
votes
19answers
1k views

Reconstruct an arithmetic sequence

Given a finite arithmetic sequence of positive integers with some terms removed from the middle, reconstruct the whole sequence. The task Consider an arithmetic sequence: a list of positive integers ...
19
votes
7answers
1k views

Number of distinct non-empty subsequences of binary expansion

A subsequence is any sequence that you can get from another by deleting any amount of characters. The distinct non-empty subsequences of 100 are ...
29
votes
21answers
1k views

Stackable sequences

You deal cards labeled 0 to 9 from a deck one a time, forming stacks that start at 0 and count up by 1. When you deal a 0, you place it on the table to start a new stack. When you deal any other ...
23
votes
25answers
1k views

Count edits accounting for grace period

When you edit a post on SE, any further edits within a 5-minute grace period are merged into it. Given a list of times you edit a post, count the edits not in a grace period. Say you edit at minutes <...
9
votes
7answers
780 views

Code-Golf Assembly Line

Note: This challenge has nothing to do with actual assembly language. As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman ...
7
votes
14answers
1k views

Reverse Fibonacci

Your task You must write a program, to print a reverse Fibonacci series, given a number. Input A non-negative integer N. Output You must output all the Fibonacci numbers from Fk to F0, where k is ...
16
votes
11answers
893 views

2D partitioned cumulative sum

Challenge Given a matrix M with r rows and c columns, and two Boolean lists V of length r and H of length c, calculate the partitioned cumulative vertical and horizontal sums. Rules r and c are ...
22
votes
13answers
1k views

Collapse consecutive integers

Related: Tell me how many math problems I have to do! Challenge Given a strictly positive strictly ascending integer list L and an integer 3 ≤ N ≤ length of L, replace the middle integers of L's ...
21
votes
35answers
1k views

All the k-mers/n-grams

Intro We have had histograms and counting, but not listing all of them. Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language ...
23
votes
20answers
2k views

Test if a string can be made with substrings!

Given a string s and an array/list l, determine whether or not s can be made with parts from ...
1
vote
0answers
147 views

Is one string contained within the other? [duplicate]

Given two inputs, you should print or return whether the characters in the first string are - in order - inside the second string. For example, we want to check whether the string ...
0
votes
1answer
117 views

CSV cleanup: remove all in col after ( [closed]

Problem Given a file with: ...
25
votes
12answers
1k views

Find the original string, without the repetition without the repetition in the middle

Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession. To make sure make sure other people are not ...
21
votes
10answers
1k views

How many Blackjack sequences in that list?

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 ...
43
votes
41answers
4k views

Bit run rundown

Given an integer n > 0, output the length of the longest contiguous sequence of 0 or 1 in ...
32
votes
8answers
2k views

Scroll Word's font size selector

Word's A▲ and ᴀ▼ buttons change the font size according to these rules: The starting font size is 11. If ᴀ▼ is pressed when the font size is 1, the size stays 1. The font size changes with 1 point in ...
25
votes
7answers
712 views

Uniquely removable subsequences

Introduction Consider a sequence of integers and one of its subsequences, say A = [4 2 2 4 4 6 5] and B = [2 4 5]. We want to remove the elements of B from A in order, and there are several ways of ...
3
votes
1answer
279 views

Add the Fibonnaci Sequence to the Lucas Sequence [duplicate]

Background of Lucas Numbers The French mathematician, Edouard Lucas (1842-1891), who gave the name to the Fibonacci Numbers, found a similar series occurs often when he was investigating Fibonacci ...
8
votes
7answers
349 views

Get a word's individuality!

I love /usr/share/dict/words; it's so handy! I use it for all my programs, whenever I can! You're going to take advantage of this ever so useful file to use, by ...
23
votes
8answers
625 views

Smallest number of contiguous monotonic subsequences

Challenge description A monotonic subsequence is a sequence of numbers [a1, a2, ..., an] such that ...
28
votes
20answers
2k views

Pairable strings

A string is pairable if it can be split into subtrings, each of which is a string repeated twice consecutively. For example, aabaaababbbaba is pairable as: ...
1
vote
1answer
427 views

Write a self-aware program [duplicate]

A standard (but disputed) test of self-awareness is the mirror test: An animal is considered self aware if it can recognize itself in the mirror. Your task is to write a program that is self-aware ...
20
votes
16answers
3k views

Find the odd one out in a sequence

The Challenge: Consider the function F(N) = 2^N + 1 where N is a positive integer less than ...