Linked Questions

70
votes
7answers
5k views

Partitioning with varying partition size

How can I partition a list into partitions whose sizes vary? The length of the $k$'th partition is a function $f(k)$. For example: if $l = \{1, 2, 3, 4, 5, 6\}$ and $f(k) = k$. Then the partitioning ...
28
votes
9answers
4k views

Find subsequences of consecutive integers inside a list

I have a list which is something like this: {3,4,5,6,7,10,11,12,15,16,17,19,20,21,22,23,24,42,43,44,45,46} What I'd like to to is get the intervals which are in ...
11
votes
9answers
1k views

Number of sign flips in list?

Given a list of signs: list={1,1,-1,1,-1,-1,1,1,1,-1}; how to most conveniently and quickly determine the number of sign flips in the sequence? I have this ad-...
10
votes
4answers
835 views

Find positions of items in a list based on neighbours

How can I select items from a list where the selection criterion depends on the neighbouring items? For example select all indices where a change has occurred with respect to the previous element in ...
11
votes
4answers
974 views

Find list position and mapping list

Sorry, my English is not very good. I have two lists: ...
6
votes
5answers
313 views

How do I write a condition for Position that uses both the current and previous element?

For example, given {57, 3, 40, 94, 9, 84, 81, 93, 76, 5, 7, 76, 38, 9, 23, 95, 49, 0, 30, 3} I'd like to get all the indices at which the elements cross from ...
20
votes
1answer
635 views

Simulating Theatre puzzle

I have been trying to simulate the process of the theatre puzzle from the Joy of X (Strogatz). The puzzle, and some relevant material are here. My simplistic coding for this process follows: ...
7
votes
4answers
406 views

How to find position where a sequence drops off to zero

Suppose I have a sequence seq = {0,0,0,1,2,3,1,0,0,0,4,5,8,0} and I want to find the first position after which the sequence drops to zero (which in this case, is ...
8
votes
3answers
1k views

How do I find the intersection of a closed 3D curve given by numerical data with a specified plane?

I have a list of 3D data points which form a closed curve. My own data can't be easily generated analytically, but the qualitative behaviour is well represented by a parametric curve families such as <...
5
votes
2answers
897 views

From a list of dates, get a list of the last date available in each month

I wondered if anyone has another or even a more direct way of finding the last dates of each month available from a list of successive dates? I currently do the following (note: nothing special about ...
3
votes
6answers
278 views

What is the range of values $x$ for which $f(x)$ is higher than $k$ over a given domain?

What is the easiest way to answer the following question in Mathematica: Given a function $f(x)=y$, what is the range of values $x$ for which $y$ is higher than some number $k$ over the domain of $x$ ...
1
vote
2answers
1k views

How to find the position of non consecutive numbers?

Given a sorted table, how can I find the position of non consecutive numbers in the first column of the table? ...
1
vote
2answers
1k views

Finding max, min, and closest root of two dimensional data

I have some data that is two dimensional (traditional (x, y) format) as so: var = {{x1, y1}, {x2, y2}, {x3, y3}} I would like to search through that large list ...
3
votes
0answers
134 views

Incorrect roots from FindRoot [closed]

I am working on finding the permafrost active layer in a specific region and I have plotted depth vs temp. I need to find the root of the depth vs time for every time I have (over 9000 times) and <...