# Search Results

• ### Getting the index of the returned max or min item using max()/min() on a list

##### - by KevinGriffin
I'm using Python's max and min functions on lists for a minimax algorithm, and I need the index of the value returned by max() or min(). In other words, I need to know which move produced the max (at a first player's turn) or min (second player) value. for i in range(9): newBoard = currentBoard.newBoardWithMove([i / 3, i % 3], player) if newBoard: temp = minMax(newBoard, depth + 1, not isMinLevel) values.append(temp) if isMinLevel: return min(values) else: return max(values) I need to be able to return the actual index of the min or max value, not just the value.

• ### Finding min and max values

##### - by user01
I am trying to write a simple program that reads integers from a data file and outputs the minimum and maximum value. The first integer of the input file will indicate how many more integers will be read, and then the integers will be listed. My program compiles without any problem, however, it returns values that are not part of the set in my test data file. Could anyone help with diagnose this issue? int main(){ FILE *fp = fopen("data.txt", "r"); int count; int num; int i; int min = 0; int max = 0; fscanf (fp, "%d", &count); for (i = 0; i < count; i++) fscanf( fp, "%d", &i); { if (num < min) min = num; if (num > max) max = num; } fclose (fp); printf("Of the %d integers, the minimum value is %d and the maximum value is %d \n", count, min, max);}

• ### min.js to clear source

##### - by dole
Hi there As far i know until now, the min version of a .js(javascript) file is obtaining by removing the unncessary blank spaces and comments, in order to reduce the file size. My questions are: How can I convert a min.js file into a clear, easy readable .js file Besides, size(&and speed) are there any other advtages of the min.js file. the js files can be encripted? can js be infected. I think the answer is yes, so the question is how to protect the .js files from infections? Only the first question is most important and I'm looking for help on it. TY

• ### C++ min heap with user-defined type.

##### - by bsg
Hi, I am trying to implement a min heap in c++ for a struct type that I created. I created a vector of the type, but it crashed when I used make_heap on it, which is understandable because it doesn't know how to compare the items in the heap. How do I create a min-heap (that is, the top element is always the smallest one in the heap) for a struct type? The struct is below: struct DOC{ int docid; double rank; }; I want to compare the DOC structures using the rank member. How would I do this? I tried using a priority queue with a comparator class, but that also crashed, and it also seems silly to use a data structure which uses a heap as its underlying basis when what I really need is a heap anyway. Thank you very much, bsg

• ### css + first load bug + min-height

##### - by Henry
We forked an editor for upcoming release of our CMS. See: http://tinyurl.com/ylbtns2 The editor uses the css of the current template and loads an additional fix.css (inside the iframe) to override some rules: * { background-image: none !important; min-height: 0px !important; } #breadcrumbs, #content .sidebar, #footer, #header, #search_form { display: none; } #content { margin: 0px; width: 100%; } The problem: on first load the "min-height: 0px !important;" seems not to work - on second load the height of the editor iframe is 100px like it should be. Other rules like no background (fix.css) are working on first load and get overridden.

• ### Hello World Problem in Eclipse with Android 2.3 used min 7 instead of min 9

##### - by Gnev
*/I am Having a Similar Problem.......... Any Suggestions/ package com.example.helloandroid6; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android Developers"); setContentView(tv); } }

• ### ScrollTo - toggle between min-height/fixed height

##### - by Skoder
Hi everyone, I'm trying to use the ScrollTo plugin, but I can't seem to get it working properly. I tried to view the source at the site I linked to but I'm trying to achieve something slightly different. I would like the window pane to change size according to the content (so the height would increase for longer text and would decrease for shorter text). However, when I supply a min-height (as opposed to a fixed height), the pane automatically changes to the maximum height when the page is loaded. So if I have something set to margin-top:1000px;, the pane will be 1000px in size regardless of what tab is currently displaying. The fix would be to use height instead, but that would mean that the window won't expand in height and the user would have to scroll. I got my code from viewing the source on the ScrollTo page, but I also tried this tutorial code. Thanks for any help

• ### Using recursion to to trim a binary tree based on a given min and max value

##### - by Justin
As the title says, I have to trim a binary tree based on a given min and max value. Each node stores a value, and a left/right node. I may define private helper methods to solve this problem, but otherwise I may not call any other methods of the class nor create any data structures such as arrays, lists, etc. An example would look like this: overallRoot _____[50]____________________ / \ __________[38] _______________[90] / \ / _[14] [42] [54]_____ / \ \ [8] [20] [72] \ / \ [26] [61] [83] trim(52, 65); should return: overallRoot [54] \ [61] My attempted solution has three methods: public void trim(int min, int max) { rootFinder(overallRoot, min, max); } First recursive method finds the new root perfectly. private void rootFinder(IntTreeNode node, int min, int max) { if (node == null) return; if (overallRoot.data < min) { node = overallRoot = node.right; rootFinder(node, min, max); } else if (overallRoot.data > max) { node = overallRoot = node.left; rootFinder(node, min, max); } else cutter(overallRoot, min, max); } This second method should eliminate any further nodes not within the min/max, but it doesn't work as I would hope. private void cutter(IntTreeNode node, int min, int max) { if (node == null) return; if (node.data <= min) { node.left = null; } if (node.data >= max) { node.right = null; } if (node.data < min) { node = node.right; } if (node.data > max) { node = node.left; } cutter(node.left, min, max); cutter(node.right, min, max); } This returns: overallRoot [54]_____ \ [72] / [61] Any help is appreciated. Feel free to ask for further explanation as needed.

• ### How can I make Excel's MIN function ignore zeroes in a set?

##### - by mfg
In Excel, I have the following formula =(MIN(H69,H52,H35,H18)*(1/H18))*10 that is supposed to return the MIN of a range, and divide it by the current cell (*(1/H18) ), then multiply by 10. I am having difficulty with adding a type of NULLIF statement. I want to be able to have (the possibility for) blank rows, and have the MIN function ignore zero/blank fields while selecting the next lowest value (all are between 1.0-0.1). Is there a modifier i can apply to the MIN function to make it not compare zeroes in the MIN set? Is there a better funtion than MIN to use? This is to prevent the following situation: users will need to eliminate fields that are zeros from the form, theres 2 formula edits per entry, averaging 4 entries per use, so 8 possible errors per form use...

• ### Avoid Multiple Queries When Querying for Max and Min Values

Instead of making one query to get the Max and Min values for a column, and then making another query to get additional information about those rows, you can do it all in one query.

• ### 2 min video about the SQL_Compare

##### - by CatherineRussell
It is nice to start blogging again! I am working on new project in a small company now. We do not have a full time database admin. I have to cover multiple roles: getting requirements, writing docs and creating diagrams, designing app, writing code, testing and DBA role. I am not a DBA. But, I have to do day to day database changes: adding new new columns and tables. Check out 2 min video about the SQL_Compare. This tool saves time by automatically comparing and synchronizing database schemas; eliminate mistakes migrating database changes from dev, to test, to production; speed up the deployment of new database schema updates; generate T-SQL scripts to update one database to match the schema of another; find and fix errors caused by differences between databases;  keeps an accurate history of all previous database records.  http://www.red-gate.com/products/SQL_Compare/index.htm

• ### Is there an easy way to make a min heap in C++?

##### - by Alex
I'm very new to C++, and I was wondering if there was a way to make a min heap in C++ from the standard library. Thanks,

• ### 12.04: google-chrome takes ~3 min to startup, just shows grey box before that

##### - by George
This is what I see when I first start google chrome: http://i.imgur.com/suQUv.png I've tried the beta version, the stable version, uninstalling and reinstall through ubuntu software center, logging in and logging out of my sync account, purging and reinstalling through apt-get etc. If I have no profile on then it seems to load with a normal speed, however, even after purging all my local account data and reisntalling and syncing it still takes forever.

• ### setting min date in jquery datepicker

##### - by user1184777
Hi i want to set min date in my jquery datepicker to (1999-10-25) so i tried the below code its not working. \$(function () { \$('#datepicker').datepicker({ dateFormat: 'yy-mm-dd', showButtonPanel: true, changeMonth: true, changeYear: true, showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: true, minDate: new Date(1999, 10 - 1, 25), maxDate: '+30Y', inline: true }); }); ** if i change the min year to above 2002 than it will work fine but if i specify min year less than 2002{like above eexample 1999} it will show only up to 2002.can someone help me. i am using jquery-1.7.1.min.js and jquery-ui-1.8.18.custom.min.js.

• ### What javascript min tool does jquery use?

##### - by JDS
I have a great deal of javascript that needs to be min'd before being served to the end user. Currently, I'm using JSMIN, but I'd like to switch to something a bit more powerful (such as something with local variable replacement). I'm currently looking at YUI min developed by yahoo, and it got me thinking about the min tool that jquery uses. Does anyone know what it is and if it's publicly available? Also, any recommendations on other min tools that might be better suited than YUI min? If possible, I'd like a java solution so I can just plug the library into what I've already created for the JSMIN solution. Thanks

• ### Cron - run task every 90 min.

##### - by Cory J
Trying to adjust a cron job to run every 90 min. It was previously running every 20 min, which was a simple cron job: */20 * * * * whatever To change it to every 90, it seems like I need to split it into 2 jobs, I've done this: 0 0,3,6,9 * * * whatever 30 1,4,7,10 * * * whatever Is this right? The job doesn't seem to kick off.

• ### Actionscript-3 random numbers between max and min...

##### - by Patrick
hi, I'm generating a random number between min and max with this code: return min + (max - min) * Math.random(); And it works. However, the random numbers are very little usually between "1 or 3" even if the max is 80. How can I better distribute the random numbers over all range ? thanks

• ### calculating min and max of 2-D array in c

##### - by m2010
This program to calculate sum,min and max of array elements Max value is the problem, it is always not true. void main(void) { int degree[3][2]; int min_max[][]; int Max=min_max[0][0]; int Min=min_max[0][0]; int i,j; int sum=0; clrscr(); for(i=0;i<3;i++) { for(j=0;j<2;j++) { printf("\n enter degree of student no. %d in subject %d:",i+1,j+1); scanf("%d",&degree[i][j]); } } for(i=0;i<3;i++) { for(j=0;j<2;j++) { printf("\n Student no. %d degree in subject no. %d is %d",i+1,j+1,degree[i][j]); } } for(i=0;i<3;i++) { sum=0; for(j=0;j<2;j++) { sum+=degree[i][j]; } printf("\n sum of degrees of student no. %d is %d",i+1,sum); min_max[i][j]=sum; if(min_max[i][j] <Min) { Min=min_max[i][j]; } else if(min_max[i][j]>Max) { Max=min_max[i][j]; } } printf("\nThe minimum sum of degrees of student no. %d is %d",i,Min); printf("\nThe maximum sum of degrees of student no. %d is %d",i,Max); getch(); }

• ### Min/Max across an array of objects

##### - by graham.reeds
It has been done to death pretty much, here on SO and around the 'Net. However I was wondering if there was a way to leverage the standard min/max functions of: Array.max = function(array) { return Math.max.apply(Math, array); }; Array.min = function(array) { return Math.min.apply(Math, array); }; So I can search across an array of objects of say: function Vector(x, y, z) { this.x = x; this.y = y; this.z = z; } var ArrayVector = [ /* lots of data */ ]; var min_x = ArrayVector.x.min(); // or var max_y = ArrayVector["y"].max(); Currently I have to loop through the array and compare the object values manually and craft each one to the particular need of the loop. A more general purpose way would be nice (if slightly slower).

• ### jQuery based min/max width fix for IE6

##### - by toomanyairmiles
Anyone know of a decent, reliable, jQuery based min/max width fix for IE6

• ### Obtaining the min and max of a two-dimensional array using LINQ

##### - by DanM
How would you obtain the min and max of a two-dimensional array using LINQ? And to be clear, I mean the min/max of the all items in the array (not the min/max of a particular dimension). Or am I just going to have to loop through the old fashioned way?

• ### SQL SERVER - Understanding how MIN(text) works.

##### - by tmercer
I'm doing a little digging and looking for a explanation on how SQL server evaluates MIN(Varchar). I found this remark in BOL: MIN finds the lowest value in the collating sequence defined in the underlying database So if I have a table that has one row with the following values: Data AA AB AC Doing a SELECT MIN(DATA) would return back AA. I just want to understand the why behind this and understand the BOL a little better. Thanks!