Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Math quiz [solved]

Math quiz [solved]

Scheduled Pinned Locked Moved The Lounge
question
60 Posts 18 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L leppie

    Very sneaky! Finding the loophole. The OP should have used must instead of can :)

    xacc.ide
    IronScheme - 1.0 RC 1 - out now!
    ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition

    H Offline
    H Offline
    Henry Minute
    wrote on last edited by
    #16

    Mustafa did say "You have to use them all". Last sentence.

    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.”

    A 1 Reply Last reply
    0
    • H Henry Minute

      Mustafa did say "You have to use them all". Last sentence.

      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.”

      A Offline
      A Offline
      AspDotNetDev
      wrote on last edited by
      #17

      Perhaps the OP was mistaken. ;P

      [Forum Guidelines]

      M 1 Reply Last reply
      0
      • A AspDotNetDev

        Perhaps the OP was mistaken. ;P

        [Forum Guidelines]

        M Offline
        M Offline
        Mustafa Ismail Mustafa
        wrote on last edited by
        #18

        Nope, not mistaken :)

        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[^]?

        1 Reply Last reply
        0
        • M Mustafa Ismail Mustafa

          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

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #19

          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;
                                                                  }
                                                              }
          
          I S 2 Replies Last reply
          0
          • A AspDotNetDev

            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;
                                                                    }
                                                                }
            
            I Offline
            I Offline
            Ian Shlasko
            wrote on last edited by
            #20

            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)

            A 1 Reply Last reply
            0
            • I Ian Shlasko

              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)

              A Offline
              A Offline
              AspDotNetDev
              wrote on last edited by
              #21

              Dang, I think you're right. I didn't account for parens. Will attempt to modify...

              [Forum Guidelines]

              1 Reply Last reply
              0
              • A AspDotNetDev

                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;
                                                                        }
                                                                    }
                
                S Offline
                S Offline
                SinghUlarity
                wrote on last edited by
                #22

                While we kill ourselves over this problem, Mustafa is out somewhere enjoying his weekend. This is all a set-up :suss:

                I are n00b.

                M 1 Reply Last reply
                0
                • M Mustafa Ismail Mustafa

                  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

                  G Offline
                  G Offline
                  GrumbleDuke
                  wrote on last edited by
                  #23

                  Using integer math: 4*(5+2)-1/3 = 28

                  I 1 Reply Last reply
                  0
                  • G GrumbleDuke

                    Using integer math: 4*(5+2)-1/3 = 28

                    I Offline
                    I Offline
                    Ian Shlasko
                    wrote on last edited by
                    #24

                    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)

                    1 Reply Last reply
                    0
                    • M Mustafa Ismail Mustafa

                      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

                      L Offline
                      L Offline
                      leppie
                      wrote on last edited by
                      #25

                      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

                      A 1 Reply Last reply
                      0
                      • L leppie

                        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

                        A Offline
                        A Offline
                        AspDotNetDev
                        wrote on last edited by
                        #26

                        If there is a solution, I must find it. If there is not, I must prove that!

                        [Forum Guidelines]

                        L 1 Reply Last reply
                        0
                        • A AspDotNetDev

                          If there is a solution, I must find it. If there is not, I must prove that!

                          [Forum Guidelines]

                          L Offline
                          L Offline
                          leppie
                          wrote on last edited by
                          #27

                          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

                          A 1 Reply Last reply
                          0
                          • M Mustafa Ismail Mustafa

                            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

                            A Offline
                            A Offline
                            AspDotNetDev
                            wrote on last edited by
                            #28

                            (4 - 1 / 2) * (5 + 3)

                            [Forum Guidelines]

                            W I M L 4 Replies Last reply
                            0
                            • M Mustafa Ismail Mustafa

                              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

                              S Offline
                              S Offline
                              Sandeep Mewara
                              wrote on last edited by
                              #29

                              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

                              A W H L 4 Replies Last reply
                              0
                              • S Sandeep Mewara

                                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

                                A Offline
                                A Offline
                                AspDotNetDev
                                wrote on last edited by
                                #30

                                Didn't bother evaluating that... you use 2 twice.

                                [Forum Guidelines]

                                1 Reply Last reply
                                0
                                • A AspDotNetDev

                                  (4 - 1 / 2) * (5 + 3)

                                  [Forum Guidelines]

                                  W Offline
                                  W Offline
                                  William Winner
                                  wrote on last edited by
                                  #31

                                  nice!

                                  1 Reply Last reply
                                  0
                                  • S Sandeep Mewara

                                    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

                                    W Offline
                                    W Offline
                                    William Winner
                                    wrote on last edited by
                                    #32

                                    you used 2 twice

                                    1 Reply Last reply
                                    0
                                    • M Mustafa Ismail Mustafa

                                      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

                                      A Offline
                                      A Offline
                                      AspDotNetDev
                                      wrote on last edited by
                                      #33

                                      That was fun... thanks! :thumbsup:

                                      [Forum Guidelines]

                                      L 1 Reply Last reply
                                      0
                                      • A AspDotNetDev

                                        (4 - 1 / 2) * (5 + 3)

                                        [Forum Guidelines]

                                        I Offline
                                        I Offline
                                        Ian Shlasko
                                        wrote on last edited by
                                        #34

                                        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)

                                        A 1 Reply Last reply
                                        0
                                        • S Sandeep Mewara

                                          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

                                          H Offline
                                          H Offline
                                          Henry Minute
                                          wrote on last edited by
                                          #35

                                          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.”

                                          S 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups