Questions tagged [min]

Minimum value. Smallest, tiniest, least.

Min() is a math library function available in many programming environments which returns the entity of smallest value from two or more candidate values.

Do not use for:

  • Question about minimal value of type (Long.MIN_VALUE, Integer.MIN_VALUE etc.)

Examples:

SQL

SQL MIN() function is one of aggregate functions. It returns the smallest value of column.
Example:

SELECT MIN(column_name) FROM table_name;

Python

In Python, the native min function identifies the smallest element of a set (e.g., a list):

>> min([1, 2, 3])
1

Java

In Java we can use java.lang.Math class to compute minimum value of two arguments. Example:

int minElement = Math.min(x, y);

To compute minimum element in collection we can use ,min() method from java.util.Collections class:

int minElement = Collections.min(list);

Ruby

In Ruby to compute minimum element of collection we simply use min function:

[4,7].min

Clojure

In Clojure we use min function in following way:

(min 1 2 3 4)

In above code `min' is function name and numbers 1..4 are arguments passed to it.
Or if we have list defined:

def myList [1 2 3 4]

then we can compute min this way:

(apply min myList)

R

In R we have function min.

x <- c(1, 2, 3)
y <- c(4, 5)
z <- c(0, NA)
min(x)
min(y)
min(z)
min(z, na.rm = TRUE)
min(x, y, z, na.rm = TRUE)  ## as same as min(c(x, y, z), na.rm = TRUE)
3013 questions
0
votes
1 answer

Why do I have a RunTime error for my Python code?

I am doing the Hackerrank basic Python programming challenges. This one is called Mini-Max Sum* and the link for the problem is:…
John
  • 13
  • 3
0
votes
1 answer

Finding minimum and maximum in a list of tuples i.e (min,max),(max,min)?

I have a list of tuples, (x1,y1),(x2,y2) etc and what I'd like to find is the tuple where x is a maximum and y is a minimum and various other combinations. I have been able to find where x is a maximum and y is a maximum, and when x is a minimum and…
Tasha
  • 55
  • 5
0
votes
1 answer

How do I pull the maximum and minimum values from a signal after using FindPeaks in python

Using the example below, how can I pull the max and min values marked as 'Top' and 'Bottom' into a separate array? # Load library import numpy as np from findpeaks import findpeaks # Data i = 10000 xs = np.linspace(0,3.7*np.pi,i) X =…
0
votes
1 answer

How to make my code read more than one digit at a time? One digit input works but two-digit or more inputs does not work

I am a beginner in Python. My code works for one-digit numbers but not two-digit. I know the for-loop is reading user input one digit at a time but I have no idea how to make it read my input like it would in an array. Ex. 5,7,9 is read as 5,7,9 but…
Caleb Ade
  • 3
  • 1
0
votes
1 answer

Find maximum row value for each record and apply it to new column

I'm trying to get rid of the NULL values and create a new column that would capture the Y (yes). Each record ID has a separate column for favorite color. There will never be a N (no) or more than 1 Y for a single record ID. I attempted to do a…
Mystical Me
  • 137
  • 6
0
votes
0 answers

What is the numpy equivalent of [M, I] = min(____)

I have this matlab code that I am trying to convert to python: M = 100 K = 40 for m=1:M for k=1:K [dist(m,k),index] = min([norm(AP(m,:,1)-Ter(k,:,1)), norm(AP(m,:,2) Ter(k,:,1)),norm(AP(m,:,3)-Ter(k,:,1))]); if dist(m,k)
P3ac3
  • 3
  • 2
0
votes
1 answer

How would I add an artificial termination date to the termination date column based on two different dates for the same patient id

I need to figure out a query that will compare two EFFECTIVE dates for a given patient number with different HMOs and determine which is the later date of the two and then populate a TERMINATION date field for only the older of the two effective…
0
votes
1 answer

MIN and MAX of dates producing wrong output

I have Payment Data and I want to show MIN and MAX dates based on different Payment Types and COUNT number of payments and adjustments. CREATE TABLE Payment (BillingId int, PaymentId int, PaymentDate date, PaymentType varchar(50), PaymentBy…
Yara1994
  • 317
  • 2
  • 11
0
votes
2 answers

Qlikview - show first and last selected value in list

I need to display first and last selected value in list. I have listbox and when I pick date I got this result in list I want to get in one box min value selected but when I use minString(Data) I got 22/2022 instead 303/202. And for max I need to…
pape
  • 239
  • 4
  • 17
0
votes
1 answer

Maximum and Minimum using loops

I had to rearrange code so that when I run the program the output is: My attempt allowed the output to do everything except print the maximum or the minimum. Have tried moving count = count + 1 outside the loop to no avail. Still a beginner, any…
mi1ntcsci
  • 3
  • 2
0
votes
1 answer

Qlikview - show min and max date from date listbox

I have ListBox with value day(Date) and shows results: 1 2 3 4 5 6 7 I want when select number from 2 to 5 in table get result Date from Date To 02-02-2022 05-02-2022 Can anyone help me please, how to show first and last selected value…
pape
  • 239
  • 4
  • 17
0
votes
0 answers

Print 'error' if min function has no argument

I´m wrting a code to determine the next higher number that can be built with the same digits the original given number obtains. I found some code: def findnext(ii): return min(v for v in (int("".join(x)) for x in…
0
votes
3 answers

MInimum element in array ( C )

I'm a newbie both here in stackoverflow and both in the world of programming. Today i was solving some exercise about recursion, and one of these asked to write a recursive function for finding minimum element of an array. After many tries, I have…
Cyro
  • 1
  • 2
0
votes
0 answers

SQL Server get Min() from only one column

I want to pick the records with the minimum quantity per package_id I have these data on TableA package_id group_id quantity 1013 2 8 1013 3 6 1091 4 4 1091 2 8 1014 4 …
PanosPlat
  • 940
  • 1
  • 11
  • 29
0
votes
1 answer

Finding the longest and shortest string in an inputted array

This is my first time using S.O but Im having trouble with my simple program. Im learning C and Im trying to sort an array of 10 strings (that the user inputs) to find the largest and smallest string and print that on screen at the end, as well as…
Maisie Brooke
  • 123
  • 1
  • 10
1 2 3
99
100