Math quiz [solved]
-
I do not think a solution exists. The closest my computer could get was 27. :((
using System.Collections.Generic;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{delegate double Op(double num1, double num2); public Form1() { InitializeComponent(); List<Op> ops = new List<Op> { new Op(M), new Op(D), new Op(A), new Op(S) }; List<int> opOrder = new List<int> { 0, 0, 0, 0 }; List<double> results = new List<double>(); for (int op1 = 0; op1 < 4; op1++) { for (int op2 = 0; op2 < 4; op2++) { for (int op3 = 0; op3 < 4; op3++) { for (int op4 = 0; op4 < 4; op4++) { for (int n1 = 1; n1 <= 5; n1++) { for (int n2 = 1; n2 <= 5; n2++) { for (int n3 = 1; n3 <= 5; n3++) { for (int n4 = 1; n4 <= 5; n4++) { for (int n5 = 1; n5 <= 5; n5++) { bool valid = true; List<int> opTest = new List<int> { op1, op2, op3, op4 }; List<int> numTest = new List<int> { n1, n2, n3, n4, n5 }; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i != j) { if (opTest\[i\] == opTest\[j\]) { valid = false; } }
static void Main(string[] args)
{
int[] nums = new int[] { 1,1,1,1,1};while (true) { Signs\[\] signs = new Signs\[4\]; while (true) { if (nums.Sum() == 15) { double x = nums\[0\]; for (int idx = 1; idx < 5; idx++) switch (signs\[idx - 1\]) { case Signs.Plus: x += nums\[idx\]; break; case Signs.Minus: x -= nums\[idx\]; break; case Signs.Div: x /= Convert.ToDouble(nums\[idx\]); break; case Signs.Times: x \*= nums\[idx\]; break; } if (x == 28 && nums.Distinct().Count() != 5 && signs.Distinct().Count() == 4) { // Breakpoint here... What? I'm lazy. } } signs\[3\]++; for (int idx = 3; idx > 0; idx--) if ((int)signs\[idx\] == 4) { signs\[idx\] = Signs.Plus; signs\[idx - 1\]++; } if ((int)signs\[0\] > 3) break; Console.Write('.'); } nums\[4\]++; for (int idx = 4; idx > 0; idx--) { if (nums\[idx\] > 5) { nums\[idx\] = 1; nums\[idx - 1\]++; } } if (nums\[0\] > 5) break; }
}
private enum Signs : int
{
Plus = 0,
Minus = 1,
Times = 2,
Div = 3
}But this isn't inclusive... It wouldn't try something like (5+1)*(4-3)/2, because you can't do that sequentially.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
static void Main(string[] args)
{
int[] nums = new int[] { 1,1,1,1,1};while (true) { Signs\[\] signs = new Signs\[4\]; while (true) { if (nums.Sum() == 15) { double x = nums\[0\]; for (int idx = 1; idx < 5; idx++) switch (signs\[idx - 1\]) { case Signs.Plus: x += nums\[idx\]; break; case Signs.Minus: x -= nums\[idx\]; break; case Signs.Div: x /= Convert.ToDouble(nums\[idx\]); break; case Signs.Times: x \*= nums\[idx\]; break; } if (x == 28 && nums.Distinct().Count() != 5 && signs.Distinct().Count() == 4) { // Breakpoint here... What? I'm lazy. } } signs\[3\]++; for (int idx = 3; idx > 0; idx--) if ((int)signs\[idx\] == 4) { signs\[idx\] = Signs.Plus; signs\[idx - 1\]++; } if ((int)signs\[0\] > 3) break; Console.Write('.'); } nums\[4\]++; for (int idx = 4; idx > 0; idx--) { if (nums\[idx\] > 5) { nums\[idx\] = 1; nums\[idx - 1\]++; } } if (nums\[0\] > 5) break; }
}
private enum Signs : int
{
Plus = 0,
Minus = 1,
Times = 2,
Div = 3
}But this isn't inclusive... It wouldn't try something like (5+1)*(4-3)/2, because you can't do that sequentially.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Dang, I think you're right. I didn't account for parens. Will attempt to modify...
-
I do not think a solution exists. The closest my computer could get was 27. :((
using System.Collections.Generic;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{delegate double Op(double num1, double num2); public Form1() { InitializeComponent(); List<Op> ops = new List<Op> { new Op(M), new Op(D), new Op(A), new Op(S) }; List<int> opOrder = new List<int> { 0, 0, 0, 0 }; List<double> results = new List<double>(); for (int op1 = 0; op1 < 4; op1++) { for (int op2 = 0; op2 < 4; op2++) { for (int op3 = 0; op3 < 4; op3++) { for (int op4 = 0; op4 < 4; op4++) { for (int n1 = 1; n1 <= 5; n1++) { for (int n2 = 1; n2 <= 5; n2++) { for (int n3 = 1; n3 <= 5; n3++) { for (int n4 = 1; n4 <= 5; n4++) { for (int n5 = 1; n5 <= 5; n5++) { bool valid = true; List<int> opTest = new List<int> { op1, op2, op3, op4 }; List<int> numTest = new List<int> { n1, n2, n3, n4, n5 }; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i != j) { if (opTest\[i\] == opTest\[j\]) { valid = false; } }
While we kill ourselves over this problem, Mustafa is out somewhere enjoying his weekend. This is all a set-up :suss:
I are n00b.
-
OK, let's see if you guys can work this one out :) The numbers: 1, 2, 3, 4, 5 and the operations +, -, *, / can be used in any order (parenthesis are free to control the order of evaluation) All the preceding mentioned numbers and operations can be used in any order once and only once to provide the result of 28. Remember, each of the operations can be used once only and each of the numbers can be used once only. You have to use them all to achieve your goal. You may begin :) [solution] Credited to aspdotnetdev (4 - (1/2)) * (5 + 3) = 28. Points awarded. Would you like me to make this a feature? Sorta like the CCC but for us more Mathematically as opposed to being "constantly high on peyote in order to be able to answer the CCC"?
If the post was helpful, please vote, eh! Current activities: Playing Star Craft II. Don't bother me, eh? Now and forever, defiant to the end. What is Multiple Sclerosis[^]?
modified on Friday, October 15, 2010 2:52 PM
Using integer math: 4*(5+2)-1/3 = 28
-
Using integer math: 4*(5+2)-1/3 = 28
But he said numbers, not integers, so you can't just round it :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
OK, let's see if you guys can work this one out :) The numbers: 1, 2, 3, 4, 5 and the operations +, -, *, / can be used in any order (parenthesis are free to control the order of evaluation) All the preceding mentioned numbers and operations can be used in any order once and only once to provide the result of 28. Remember, each of the operations can be used once only and each of the numbers can be used once only. You have to use them all to achieve your goal. You may begin :) [solution] Credited to aspdotnetdev (4 - (1/2)) * (5 + 3) = 28. Points awarded. Would you like me to make this a feature? Sorta like the CCC but for us more Mathematically as opposed to being "constantly high on peyote in order to be able to answer the CCC"?
If the post was helpful, please vote, eh! Current activities: Playing Star Craft II. Don't bother me, eh? Now and forever, defiant to the end. What is Multiple Sclerosis[^]?
modified on Friday, October 15, 2010 2:52 PM
or I downvote you! ;P This is not possible I think. I have run an exhaustive search over my brain, and now I am tired.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
or I downvote you! ;P This is not possible I think. I have run an exhaustive search over my brain, and now I am tired.
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth EditionIf there is a solution, I must find it. If there is not, I must prove that!
-
If there is a solution, I must find it. If there is not, I must prove that!
Practice on Fermat's Last Theorem then ;P
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
OK, let's see if you guys can work this one out :) The numbers: 1, 2, 3, 4, 5 and the operations +, -, *, / can be used in any order (parenthesis are free to control the order of evaluation) All the preceding mentioned numbers and operations can be used in any order once and only once to provide the result of 28. Remember, each of the operations can be used once only and each of the numbers can be used once only. You have to use them all to achieve your goal. You may begin :) [solution] Credited to aspdotnetdev (4 - (1/2)) * (5 + 3) = 28. Points awarded. Would you like me to make this a feature? Sorta like the CCC but for us more Mathematically as opposed to being "constantly high on peyote in order to be able to answer the CCC"?
If the post was helpful, please vote, eh! Current activities: Playing Star Craft II. Don't bother me, eh? Now and forever, defiant to the end. What is Multiple Sclerosis[^]?
modified on Friday, October 15, 2010 2:52 PM
(4 - 1 / 2) * (5 + 3)
-
OK, let's see if you guys can work this one out :) The numbers: 1, 2, 3, 4, 5 and the operations +, -, *, / can be used in any order (parenthesis are free to control the order of evaluation) All the preceding mentioned numbers and operations can be used in any order once and only once to provide the result of 28. Remember, each of the operations can be used once only and each of the numbers can be used once only. You have to use them all to achieve your goal. You may begin :) [solution] Credited to aspdotnetdev (4 - (1/2)) * (5 + 3) = 28. Points awarded. Would you like me to make this a feature? Sorta like the CCC but for us more Mathematically as opposed to being "constantly high on peyote in order to be able to answer the CCC"?
If the post was helpful, please vote, eh! Current activities: Playing Star Craft II. Don't bother me, eh? Now and forever, defiant to the end. What is Multiple Sclerosis[^]?
modified on Friday, October 15, 2010 2:52 PM
Mustafa Ismail Mustafa wrote:
parenthesis are free to control the order of evaluation
((2(3+5))*(2/1)) - 4 :rolleyes: UPDATE: [(2){3*5+1}]-4 :mad: on self... UPDATE 2: This looks good.... (5+3)*(4-(1/2)) derived from 28=56/2=8*7/2.....
modified on Friday, October 15, 2010 2:45 PM
-
Mustafa Ismail Mustafa wrote:
parenthesis are free to control the order of evaluation
((2(3+5))*(2/1)) - 4 :rolleyes: UPDATE: [(2){3*5+1}]-4 :mad: on self... UPDATE 2: This looks good.... (5+3)*(4-(1/2)) derived from 28=56/2=8*7/2.....
modified on Friday, October 15, 2010 2:45 PM
Didn't bother evaluating that... you use 2 twice.
-
(4 - 1 / 2) * (5 + 3)
nice!
-
Mustafa Ismail Mustafa wrote:
parenthesis are free to control the order of evaluation
((2(3+5))*(2/1)) - 4 :rolleyes: UPDATE: [(2){3*5+1}]-4 :mad: on self... UPDATE 2: This looks good.... (5+3)*(4-(1/2)) derived from 28=56/2=8*7/2.....
modified on Friday, October 15, 2010 2:45 PM
you used 2 twice
-
OK, let's see if you guys can work this one out :) The numbers: 1, 2, 3, 4, 5 and the operations +, -, *, / can be used in any order (parenthesis are free to control the order of evaluation) All the preceding mentioned numbers and operations can be used in any order once and only once to provide the result of 28. Remember, each of the operations can be used once only and each of the numbers can be used once only. You have to use them all to achieve your goal. You may begin :) [solution] Credited to aspdotnetdev (4 - (1/2)) * (5 + 3) = 28. Points awarded. Would you like me to make this a feature? Sorta like the CCC but for us more Mathematically as opposed to being "constantly high on peyote in order to be able to answer the CCC"?
If the post was helpful, please vote, eh! Current activities: Playing Star Craft II. Don't bother me, eh? Now and forever, defiant to the end. What is Multiple Sclerosis[^]?
modified on Friday, October 15, 2010 2:52 PM
That was fun... thanks! :thumbsup:
-
(4 - 1 / 2) * (5 + 3)
Ahhh, I was trying to avoid fractions... Didn't think of doing it that way... Well done.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Mustafa Ismail Mustafa wrote:
parenthesis are free to control the order of evaluation
((2(3+5))*(2/1)) - 4 :rolleyes: UPDATE: [(2){3*5+1}]-4 :mad: on self... UPDATE 2: This looks good.... (5+3)*(4-(1/2)) derived from 28=56/2=8*7/2.....
modified on Friday, October 15, 2010 2:45 PM
That is very cunning. We'll have to wait for the word from the East to see if it's within the rules. :) [Edit] Just noticed the double 2's, forget everything I said. Cheater. ;P [/Edit]
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
That was fun... thanks! :thumbsup:
Giving up so soon?
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
That is very cunning. We'll have to wait for the word from the East to see if it's within the rules. :) [Edit] Just noticed the double 2's, forget everything I said. Cheater. ;P [/Edit]
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
I corrected it.. I still stand for approval as... ;)
-
Mustafa Ismail Mustafa wrote:
parenthesis are free to control the order of evaluation
((2(3+5))*(2/1)) - 4 :rolleyes: UPDATE: [(2){3*5+1}]-4 :mad: on self... UPDATE 2: This looks good.... (5+3)*(4-(1/2)) derived from 28=56/2=8*7/2.....
modified on Friday, October 15, 2010 2:45 PM
Now you forgot the / and you have an extra *
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
(4 - 1 / 2) * (5 + 3)
There we go! :-D Congratulations man, you get the points for today.
If the post was helpful, please vote, eh! Current activities: Playing Star Craft II. Don't bother me, eh? Now and forever, defiant to the end. What is Multiple Sclerosis[^]?