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

  • Home
  • SEARCH
  • 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 8566383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:38:34+00:00 2026-06-11T17:38:34+00:00

I have a problem with a operator (+, -, /, * ) with a

  • 0

I have a problem with a operator
(+, -, /, * )
with a total sum using those operators and number of operands.

so for example i need to get total of 6 using 3 operands (1, 2, 3) and + operator, what can be the total number of permutations for that particular result.

i could not even think of the approach yet. Can anyone help me regarding that. I am using Java.

Thanks

  • 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-11T17:38:35+00:00Added an answer on June 11, 2026 at 5:38 pm

    There is a number of different methods, but to even briefly describe all of them I first need to re-read the books that I used to read in my ‘childhood’. Try this solution: create a stack that may be used to:

    • push a value
    • pop two topmost values and make one of supported arithmetic
      operations and then push the result back
    • pop a value

    This way you have a simple stack machine that allows you to perform the necessary calculations. Next you need to generate all possible permutations of concatenation of your operands and operators. When you pick up the operand from this concatenation you push it onto the stack. When you pick up the operator – you perform it. While performing operator you check that your stack has at least two elements in it – otherwise you need to skip this operator and seek for next possible operand. When you have no more operands in the concatenated sequence and you have only one element on stack – that means you completed your current calculation. so compare the result with the given result and log the sequence if needed. Then switch to the next permutation

    This is definitely not optimal solution – there is a lot of possibilities to optimize. And this is most interesting part 🙂 Good luck

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

Sidebar

Related Questions

I have a problem with operators. Generally I know basics of using operators. But
i have a problem about conversion of type using overload of operator, here i
I have a problem when using operator.setitem in python 3. When I use the
I have a problem with the is operator comparing generic types. public interface ISomeInterface<T>
I have a problem when I call operator<< on a pointer. I have searched
I'm facing a problem in Xcode with the operator keyword. I have this in
I have problem with my query on C, I’m using the oci8 driver. This
I have a problem in which I need to be prepared to explore a
I have a problem putting data into an unordered_map using a struct as key:
I'm trying to get will_paginate working with Sinatra and I have a stange problem

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.