Count a 2D array within a range [closed] - arrays

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a map that I want to separately count the patterns of different numbers.
Without VB, I want to be able to create a dynamic counter that will be able to count the patterns of numbers.
For example:
I want to count how many times, even if it overlaps that this pattern occurs in the map
2 2
2 2
Counting I can see the pattern occurs six times but I'm struggling to create a simple array formula that will be able to do so
I've been told of success with and IF function with nested AND functions so I know it can be done without VB.

Use the formula
=COUNTIFS(A1:E15,2,B1:F15,2)
notice how the two areas are adjacent - one column offset from each other.
You can extend this to find two-by-two regions:
=COUNTIFS(A1:E14,2,B1:F14,2,A2:E15,2,B2:F15,2)
just be very careful about how the different ranges are offset.
An alternative way to write this which, I suspect, will be more efficient for large ranges is:
=SUMPRODUCT((A1:E14=2)*(B1:F14=2)*(A2:E15=2)*(B2:F15=2))

Related

Google Spreadsheet - Is there a way to overflow over blank cells [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 months ago.
Improve this question
I wonder if someone could help me fixing this issue
Planning to have nearly 100 columns to be viewable without scrolling horizontally, so each column shoud have 21 pixels's width, so it's for this reason I can't nor enlarge the columns neither merge themm...
I need that text in A2 overflow/overwrite over E2, F3, G3, H3 cells which are blank since the validation data in E3 is not selected
I want that A2 reacts exactly as I2 is doing by overwrites blank cells in front of it (M2...)
Could you help me fix this out? Any advice would be appreciated.
I share with you an example of my work
https://docs.google.com/spreadsheets/d/12bmwYSi3exkblW0C2VXqDTq5UGEd5GH8D1PsSkjaFNI/edit?usp=sharing
solution here is to unmerge A2:
update:
={"";IFNA(VLOOKUP($E$5,Sheet2!$A$2:$E$5,5,FALSE))}

Split an array in two parts such that the difference of their sums is minimum [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
Ok let's say that I have an array as 1 4 2 3 1 and I want to split it in 2 sub arrays such that the absolute difference of their sums is minimum.
That is to say as for the above example the 2 sub-arrays would be 4 2 and 3 1 1 which is |6 - 5| that is 1.
It seems to be a dynamic programming question but I'd like to solve it the conventional way.
I am not looking for exact answers but rather the ideology about how should I approach this problem.
Any hints would be appreciated. But just the hints as I'd like to solve it on my own thereafter.
We are not concerned about the order of the elements and their can be duplicate elements as well.
If you just want to find the minimum by any means then the brute force way would be to find all the ways to split the array in two and find the difference of sum of the numbers in each pair. Then store the minimum (and the two sub arrays) or a list of the minimums and replace this if the program finds a new minimum. Iterate over all the possible pairs and there you go your new subarray.
Depending on how you code this there are way to improve on this method. For example if you have the pair [1,2,3] and [4,5] you don't need to also do [4,5] and [1,2,3] as this would be the same pair of subarrays.
I don't want to write an actual way of doing this as you did specify you want to try it yourself

finding the biggest value [closed]

Closed. This question needs to be more focused. 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.
Closed 4 years ago.
Improve this question
PLEASE NOTE: I am not looking for code, but for a way how to solve this problem.
My input is world that looks like this:
The problem is, i have to find the biggest number, without using OWN variables I could declare myself, and I'm only allowed to use turnLeft(), turnRight(), move(), isLeft/Right/FrontClear(), getNumber() and putNumber() functions to move < around the world.
Could you please give me a 'verbal solution' or a hint how to do such thing?
While you cannot use any variable, note that you do have available memory (getNumber() and putNumber()). For instance, you could think about leaving a mark in positions you have already been to implement some kind of flood fill.
Further, you can fill the floor with the biggest number you have seen yet. Basically, encoding your own state in the floor.
Important questions:
Is the configuration of the maze always fixed?
Is the range of possible numbers in the floor fixed to a reasonable range (e.g. digits 1-9)?

Producing all subsets of a set gievn a restriction [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Assume we have a set of N items say, S = {t1, t2, t3}. I would like to produce all the possible subsets of S given the restriction that t1 must appear in every set. Therefore, all possible subsets of S are {t1}, {t1,t2}, {t1,t3}, and {t1,t2,t3}. How can I write a recursive function that takes two sets {t1} and {t2,t3} and returns the subsets listed above.
Also if I had 100s of subsets such as S, storage of all subsets becomes a problem. My program goes in iterations and at every iteration I only need to manipulate one subset from each set. Is there I way I can produce the subsets of a set in steps rather than all at once? i.e. every time I call next(S), I get a new subset.
Note I'm coding in C.
Your "restriction" amounts to the following
Remove all the elements from S that must appear in the final sets. Call the remaining set S` and the removed elements B.
Produce the powerset of S` taking the union with B for each item to add in the required elements.
The powerset is a standard recursive function and outside the scope of your question. Indeed, there are many examples of how to do so on Stack Overflow.

Which are admissible heuristics and why? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
There are n vehicles on an n x n grid. At the start they are ordered in the top row 1. The vehicles have to get to the bottom row such that the vehicle at (1,n) must get to (n, n − i + 1). On each time step, each of the vehicles can move one square up, down, left or right, or it can stay put. If the vehicle stays put, one adjacent vehicle (but not more than one) can hop over it. Two vehicles cannot occupy the same square.
Which of the following heuristics are admissible for the problem of moving all the vehicles to their destination?
i. sum from 1 to n (h1 ... hn)
ii. max(h1 ... hn)
iii. min(h1 ...hn)
I think that iii is the only correct one, but I'm not sure how to formulate my reasoning on why.
I am sure someone will come along with a very detailed answer, but as a favour to those who like me can be a bit overwhelmed by all things AI, an admissible heuristic is quite simply:
A heuristic that never overestimates the true cost of getting to the goal
Not to sound too uncharitable, but it sounds as if maybe the problems you've posted are from a homework problem or assignment. I wouldn't want to spoil your fun working out exactly which of those three heuristics are and aren't admissible - but hopefully that one sentence definition should help you along.
If you get confused, just remember: if once your vehicles have both reached their goals you find the actual cost was less than what the heuristic thought it would be then it's inadmissable.

Resources