Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9134293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:38:04+00:00 2026-06-17T08:38:04+00:00

one totally useless question: I bought a numerical game, it’s made of two black

  • 0

one totally useless question: I bought a numerical game, it’s made of two black dice plus 5 coloured ones. the two black ones form a 2 digits number, ranging from 11 to 66, the other 5 are the numbers you can use, combining them in all possible numerical expressions with the task to obtain the target number.

for example, black 40 + 2: target 42

coloured 5 3 6 2 4, you can obtain the target by 5 3 + 6 * 4 2 + – (using RPN because it avoids brackets).

now I’d like to use my pocket computer to find the best answer while we people play the game.

I must say I didn’t really think too hard about the solution yet, I just looked for the part on finding the permutations of the arguments, but then how to generate the possible expressions from that? I would do that using RPN and enumerating all possible “shapes” of expressions and then fill in the blanks with +-*/.

I don’t recognize the problem of enumerating the shapes of the expressions.

the output would be this:
…..xxxx
….x.xxx
…x..xxx
..x…xxx
….xx.xx
…x.x.xx
..x..x.xx
…xx..xx
..x.x..xx
….xxx.x
…x.xx.x
..x..xx.x
…xx.x.x
..x.x.x.x

things like:
..xx…xx
…xxx..x
..x.xx..x
..x.xx..x
are invalid, as the second or third operator would find one operand.

I can use a hard coded list, but it looks really ugly!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:38:05+00:00Added an answer on June 17, 2026 at 8:38 am

    What I think you’re looking for is the enumeration of full binary trees of size 5. (The count of such objects is the fifth Catalan number, which is 14.). The enumeration is straight-forward, based on the standard recursion for Catalan numbers:
    http://upload.wikimedia.org/math/2/f/1/2f17435a71394ce667ab694b27341560.png

    For each (i, 5-i), produce all the trees with i leaves, and all the trees with 5-i leaves, and for each combination of one tree from each set, construct a new tree by making a root node whose left child comes from the first set and whose right child comes from the second set. If you don’t want to use trees, use RPN directly:

    # Produces all possible RPN layouts with n values and n-1 binary operators,
    # representing values as '#' and operators as '+'
    def RPN(n):
      if n == 1:
        yield '#'
      for i in range(1,n):
        for left in RPN(i):
          for right in RPN(n - i):
            yield left + right + '+' 
    

    Of course, there are unary operators as well. If you allow those, it gets more complicated.

    Note that you can directly adapt the above to insert the arguments directly; instead of dividing n into (i, n-i), you would find all the partitions of the set of n values into two non-empty subsets. (Otherwise, you can just find all the permutations of the set of numbers, and plug them into the resulting RPN expressions.)

    Then “all” you need to do is insert all possible operator sequences (if you only allow +,-,* and / then you have 44 = 256 possibilities).

    So if the five numbers were distinct, you would end up with 14 * 5! * 44 = 430080 expressions to test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've totally rewritten my question because the simplicity of the previous one people were
I am going to totally re-ask this question. So this is one big edit
One of my colleagues has totally messed up the contents of a directory in
Totally confused by this one... We have a WAMPServer installation set up, running a
I thought this would be fairly easy, but I'm totally baffled. I want one
Ok, i have one totaly noob question about php sessions: I have 3 (and
one question about PHP Development. I am building up some Form Fields for Calculations.
One of the neat characteristics of UTF-8 is that if you compare two strings
Totally lost with this one. Here's my code: theColor = [NSString stringWithFormat:@white]; NSLog(@%s, theColor);
I'm totally confused which one to use and when, first thing I do when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.