Meaning of a formula to develop a function [closed]
$begingroup$
So I have to develop a python function maxand(S,n) that given an integer n > 0 and a set S of non-negative integers, with n < |S|, returns:
$max_{ {t_1,...,t_n} subseteq S} $ $(t_1&...&t_n)$
where x & y is the bit-to-bit AND operator between integers. Examples:
maxand({2,5,13},1) = 13
maxand({2,5,13},2) = 5
maxand({2,5,13},3) = 0
My problem is that I can't understand what the formula is asking me to do.
For example, with n = 1, which elements of S do I have to consider to do the bitwise operation?
if the set is {2,5,13} and n = 1, then $t_1$ is supposed to be 2. Then what? And for n = 2, would it be $max_{ {2,5} subseteq S} $(2&5) with $t_1$ = 2 and $t_2$ = 5?
discrete-mathematics
$endgroup$
closed as off-topic by Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh Dec 28 '18 at 0:03
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
So I have to develop a python function maxand(S,n) that given an integer n > 0 and a set S of non-negative integers, with n < |S|, returns:
$max_{ {t_1,...,t_n} subseteq S} $ $(t_1&...&t_n)$
where x & y is the bit-to-bit AND operator between integers. Examples:
maxand({2,5,13},1) = 13
maxand({2,5,13},2) = 5
maxand({2,5,13},3) = 0
My problem is that I can't understand what the formula is asking me to do.
For example, with n = 1, which elements of S do I have to consider to do the bitwise operation?
if the set is {2,5,13} and n = 1, then $t_1$ is supposed to be 2. Then what? And for n = 2, would it be $max_{ {2,5} subseteq S} $(2&5) with $t_1$ = 2 and $t_2$ = 5?
discrete-mathematics
$endgroup$
closed as off-topic by Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh Dec 28 '18 at 0:03
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
So I have to develop a python function maxand(S,n) that given an integer n > 0 and a set S of non-negative integers, with n < |S|, returns:
$max_{ {t_1,...,t_n} subseteq S} $ $(t_1&...&t_n)$
where x & y is the bit-to-bit AND operator between integers. Examples:
maxand({2,5,13},1) = 13
maxand({2,5,13},2) = 5
maxand({2,5,13},3) = 0
My problem is that I can't understand what the formula is asking me to do.
For example, with n = 1, which elements of S do I have to consider to do the bitwise operation?
if the set is {2,5,13} and n = 1, then $t_1$ is supposed to be 2. Then what? And for n = 2, would it be $max_{ {2,5} subseteq S} $(2&5) with $t_1$ = 2 and $t_2$ = 5?
discrete-mathematics
$endgroup$
So I have to develop a python function maxand(S,n) that given an integer n > 0 and a set S of non-negative integers, with n < |S|, returns:
$max_{ {t_1,...,t_n} subseteq S} $ $(t_1&...&t_n)$
where x & y is the bit-to-bit AND operator between integers. Examples:
maxand({2,5,13},1) = 13
maxand({2,5,13},2) = 5
maxand({2,5,13},3) = 0
My problem is that I can't understand what the formula is asking me to do.
For example, with n = 1, which elements of S do I have to consider to do the bitwise operation?
if the set is {2,5,13} and n = 1, then $t_1$ is supposed to be 2. Then what? And for n = 2, would it be $max_{ {2,5} subseteq S} $(2&5) with $t_1$ = 2 and $t_2$ = 5?
discrete-mathematics
discrete-mathematics
edited Dec 27 '18 at 15:44
Andrés E. Caicedo
65.5k8158249
65.5k8158249
asked Dec 27 '18 at 15:41
emaphemaph
133
133
closed as off-topic by Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh Dec 28 '18 at 0:03
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh Dec 28 '18 at 0:03
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – Andrés E. Caicedo, Cesareo, amWhy, José Carlos Santos, Shailesh
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
I assume you know what the $&$ operator does and that your problem is with the notation
$$
max_{ {t_1,...,t_n} subseteq S} cdots .
$$
That tells you to look at all the $n$ element subsets of $S$ and find the largest value of the indicated expression. So in your example, when $n=2$ there are three $2$ element subsets -you want to find the maximum of
$$
2&5, 2&13, 5&13 .
$$
When $n=3$ the only $n$ element subset is the whole set and the maximum is the value for that subset:
$$
2&5&13 .
$$
(I assume that works out to be $0$; I haven't checked.)
$endgroup$
$begingroup$
Then take a look at the itertools module...
$endgroup$
– N74
Dec 27 '18 at 16:04
$begingroup$
@N74 Indeed, My answer addresses just what the mathematics means, not how to code it in python.
$endgroup$
– Ethan Bolker
Dec 27 '18 at 16:08
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I assume you know what the $&$ operator does and that your problem is with the notation
$$
max_{ {t_1,...,t_n} subseteq S} cdots .
$$
That tells you to look at all the $n$ element subsets of $S$ and find the largest value of the indicated expression. So in your example, when $n=2$ there are three $2$ element subsets -you want to find the maximum of
$$
2&5, 2&13, 5&13 .
$$
When $n=3$ the only $n$ element subset is the whole set and the maximum is the value for that subset:
$$
2&5&13 .
$$
(I assume that works out to be $0$; I haven't checked.)
$endgroup$
$begingroup$
Then take a look at the itertools module...
$endgroup$
– N74
Dec 27 '18 at 16:04
$begingroup$
@N74 Indeed, My answer addresses just what the mathematics means, not how to code it in python.
$endgroup$
– Ethan Bolker
Dec 27 '18 at 16:08
add a comment |
$begingroup$
I assume you know what the $&$ operator does and that your problem is with the notation
$$
max_{ {t_1,...,t_n} subseteq S} cdots .
$$
That tells you to look at all the $n$ element subsets of $S$ and find the largest value of the indicated expression. So in your example, when $n=2$ there are three $2$ element subsets -you want to find the maximum of
$$
2&5, 2&13, 5&13 .
$$
When $n=3$ the only $n$ element subset is the whole set and the maximum is the value for that subset:
$$
2&5&13 .
$$
(I assume that works out to be $0$; I haven't checked.)
$endgroup$
$begingroup$
Then take a look at the itertools module...
$endgroup$
– N74
Dec 27 '18 at 16:04
$begingroup$
@N74 Indeed, My answer addresses just what the mathematics means, not how to code it in python.
$endgroup$
– Ethan Bolker
Dec 27 '18 at 16:08
add a comment |
$begingroup$
I assume you know what the $&$ operator does and that your problem is with the notation
$$
max_{ {t_1,...,t_n} subseteq S} cdots .
$$
That tells you to look at all the $n$ element subsets of $S$ and find the largest value of the indicated expression. So in your example, when $n=2$ there are three $2$ element subsets -you want to find the maximum of
$$
2&5, 2&13, 5&13 .
$$
When $n=3$ the only $n$ element subset is the whole set and the maximum is the value for that subset:
$$
2&5&13 .
$$
(I assume that works out to be $0$; I haven't checked.)
$endgroup$
I assume you know what the $&$ operator does and that your problem is with the notation
$$
max_{ {t_1,...,t_n} subseteq S} cdots .
$$
That tells you to look at all the $n$ element subsets of $S$ and find the largest value of the indicated expression. So in your example, when $n=2$ there are three $2$ element subsets -you want to find the maximum of
$$
2&5, 2&13, 5&13 .
$$
When $n=3$ the only $n$ element subset is the whole set and the maximum is the value for that subset:
$$
2&5&13 .
$$
(I assume that works out to be $0$; I haven't checked.)
answered Dec 27 '18 at 15:57
Ethan BolkerEthan Bolker
43.4k551116
43.4k551116
$begingroup$
Then take a look at the itertools module...
$endgroup$
– N74
Dec 27 '18 at 16:04
$begingroup$
@N74 Indeed, My answer addresses just what the mathematics means, not how to code it in python.
$endgroup$
– Ethan Bolker
Dec 27 '18 at 16:08
add a comment |
$begingroup$
Then take a look at the itertools module...
$endgroup$
– N74
Dec 27 '18 at 16:04
$begingroup$
@N74 Indeed, My answer addresses just what the mathematics means, not how to code it in python.
$endgroup$
– Ethan Bolker
Dec 27 '18 at 16:08
$begingroup$
Then take a look at the itertools module...
$endgroup$
– N74
Dec 27 '18 at 16:04
$begingroup$
Then take a look at the itertools module...
$endgroup$
– N74
Dec 27 '18 at 16:04
$begingroup$
@N74 Indeed, My answer addresses just what the mathematics means, not how to code it in python.
$endgroup$
– Ethan Bolker
Dec 27 '18 at 16:08
$begingroup$
@N74 Indeed, My answer addresses just what the mathematics means, not how to code it in python.
$endgroup$
– Ethan Bolker
Dec 27 '18 at 16:08
add a comment |