minimum

Getting the minimum value of a list

元气小坏坏 提交于 2019-12-11 11:18:12
问题 I am trying to find the minimum value of a list (as a learning experience, so without min ). My approach is the following: minimo([X], X). minimo([X,Y|Tail], N):- (X > Y, minimo([Y,Tail], Y)); (X <= Y, minimo([X,Tail], X)). This gives me the following error: Syntax error: Operator expected So my questions are: What is causing the syntax error? I will try it myself once that is fixed if it actually gives the correct value back, but would this actually be a correct approach? Thanks in advance.

Taking minimum value of each entry +- 10 rows either side in numpy array

ε祈祈猫儿з 提交于 2019-12-11 06:46:55
问题 I have a 3d numpy array and want to generate a secondary array consisting of the minimum of each value and the values in the 10 rows directly above and 10 rows directly below (i.e each entry is the minimum value from 21 values) for each 2d array. I've been trying to use 'numpy.clip' to deal with the edges of the array - here the range of values which the minimum is taken from should simply reduce to 10 at the values on the top/bottom of the array. I think something like 'scipy.signal

How to find minimum possible height of tree?

对着背影说爱祢 提交于 2019-12-11 06:24:50
问题 The fan-out of a node in a tree is defined to be the number of children the node has. The fan-out of a tree is defined to be the maximum fan-out of any node in the tree. Assume tree T has n nodes and a fan-out f > 1. What is the minimum possible height of T? I have no idea how to begin this problem. I solved the first part which is to find the maximum number of nodes that can be T in terms of height h and fan-out f > 1. I got (f^(h+1) -1)/(f-1). I'm thinking you can use this to solve for the

(C) Getting the 3 minimum elements of an row in a matrix, and choose one randomly

℡╲_俬逩灬. 提交于 2019-12-11 01:15:24
问题 I've a 8x8 matrix, and after choosing the row I desire, I want to get the three minimum elements of it, and choose one of this three randomly. The thing is that I'dont know how to handle those three elements. I just know how to get the minimum element, that is the following code. int piezas[8][8] = { 0, 2, 2, 5, 3, 2, 1, 1, 0, 4, 5, 2, 4, 3, 0, 0, 0, 4, 2, 2, 1, 2, 3, 2, 0, 3, 1, 5, 1, 2, 3, 4, 2, 5, 6, 5, 3, 1, 2, 7, 8, 2, 0, 0, 0, 2, 1, 1, 1, 2, 2, 1, 1, 6, 3, 4, }; int myrow = 3; // the

Numpy: How to get rid of the minima along axis=1, given the indices - in an efficient way?

我与影子孤独终老i 提交于 2019-12-11 01:08:07
问题 Given a matrix A with shape (1000000,6) I have figured out how to get the minimum rightmost value for each row and implemented it in this function: def calculate_row_minima_indices(h): # h is the given matrix. """Returns the indices of the rightmost minimum per row for matrix h.""" flipped = numpy.fliplr(h) # flip the matrix to get the rightmost minimum. flipped_indices = numpy.argmin(flipped, axis=1) indices = numpy.array([2]*dim) - flipped_indices return indices indices = calculate_row

Finding the minimum in an unsorted array in logarithmic time

南楼画角 提交于 2019-12-10 20:38:38
问题 Is there an algorithmic approach to find the minimum of an unsorted array in logarithmic time ( O(logn) )? Or is it only possible in linear time? I don't want to go parallel. Thanks Michael 回答1: If the list is unsorted, your search has to be at least linear. You must look at each item at least once, because anything you haven't looked at might be less than what you've already seen. 回答2: It is not possibly in linear time, because in lg n steps you can only inspect lg n elements, and because

Minimum version for Storyboards in xcode iphone

好久不见. 提交于 2019-12-10 14:55:14
问题 I am working on Storyboards.I need to know the minimum version of ios that i can set befor making the Build and submit on App store.Can i use ios 4.0 as a target.Will it run on version below ios 5...? Is there any solution to it.? Any help would be appreciated. Thanks Vikas 回答1: you may have seen the following error message: Storyboards are unavailable on iOS 4.3 and prior but however, Updating Xcode to the latest version (4.3.1) does not help either. Here is a trick to modify the project for

C Macro for minimum of two numbers

痴心易碎 提交于 2019-12-10 14:43:28
问题 I want to make a simple macro with #define for returning the smaller of two numbers. How can i do this in C ? Suggest some ideas, and see if you can make it more obfuscated too. 回答1: For slightly obfuscated, try this: #define MIN(a,b) ((((a)-(b))&0x80000000) >> 31)? (a) : (b) Basically, it subtracts them, and looks at the sign-bit as a 1-or-0. If the subtraction results in a negative number, the first parameter is smaller. 回答2: Typically: #define min(a, b) (((a) < (b)) ? (a) : (b)) Be warned

Swift 4 - Setting a minimum deployment target

微笑、不失礼 提交于 2019-12-10 02:06:32
问题 The current deployment target is 11.0 which is fine. However, I would like to know how I would set a minimum of 8.0? 回答1: You can set the deployment target in your project's target's general settings. You can read more about this in Apple documentation "Setting Deployment Target". 来源: https://stackoverflow.com/questions/46465408/swift-4-setting-a-minimum-deployment-target

Lowest value in range

a 夏天 提交于 2019-12-09 11:50:29
问题 I would like to find the lowest value in some range. Do I have to iterate array each time or is there any dynamic method? Lets say I have input array: index: 0 1 2 3 4 5 6 7 value: 1 4 6 1 6 7 2 3 and then I have to choose smallest in range < a,b > (inclusive). For example: min(0,7) = 1 min(0,2) = 1 min(4,6) = 2 min(1,2) = 4 Im interested in the fastest solution, it would be the best to get the results in constant time. Array won't be changed in meantime. 回答1: If you are going to perform