24-point calculator (console program including C # source)

Source: Internet
Author: User
Description:

There is no other way. You only need to calculate all kinds of possibilities, and then get an expression that can calculate 24, and eliminate repeated expressions as much as possible.

Assume that there are four numbers of a B c d, and the operator is replaced by OP, there are (a op B) OP (c op D) or (a op B) op C) OP d

ProgramDeveloped in C #2.0 and supports computing 8/(3-8/3) = 24

The biggest headache of this program is how to get rid of repeated results. I have rewritten the gethashcode () method to make repeated expressions calculate the same value as much as possible.

Syntax:

Calc24 [num1 [num2 [num3 [num4]

Example:

Calc24 3 3 8 8
Calc24 3 3 8
Calc24 3 3
Calc24 3
Calc24

If the parameter is omitted, the program automatically generates a random number of less than 24

Download:
Click here to download.

Appendix:

The following are some of the only answers. You can try:

1 1 3 4
1 3 4 6
1 3 9 10
1 3 13 16
1 4 7 9
1 5 5 5
1 5 7 9
1 5 8 13
1 5 9 9
1 5 11 16
1 6 7 9
1 7 7 9
1 7 7 12
1 7 7 17
1 9 11 11
1 9 11 13
2 2 5 8
2 2 11 11
2 3 10 10
2 4 7 7
2 4 10 10
2 5 5 10
2 5 6 9
2 5 7 9
2 16 18 19
3 3 3 3
3 3 7 7
3 3 8 8
3 3 8 201
3 3 8 208
3 3 23 207
3 5 6 77
4 4 7 7
4 4 10 10
4 5 6 9
4 16 18 19
5 5 18 77
5 10 10 13
5 10 10 17
6 6 8 8
7 8 9 10
7 8 9 12
7 8 10 10
7 8 10 11
9 9 9 12
9 11 12 13
11 13 17 19

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.