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 7926371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:44:57+00:00 2026-06-03T18:44:57+00:00

I require some input on the below logic. It is kind of billing system

  • 0

I require some input on the below logic.

It is kind of billing system takes the input and has a value associated with it.

A = 2 , 3A = 5
B = 3
C = 1 , 4C = 3

My code , should be such that take ABCCBAACCA , output should be value which is 16.

My solution as of now, I m thinking to count every element in the string, and them mod(modulus) by 3 for A , 4 for C (as in the above case, no need in case of B) every element in order to get the result.

I’m confused what data structure I should be using in order to implement such system.

  • 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-03T18:44:58+00:00Added an answer on June 3, 2026 at 6:44 pm

    In pseudocode I believe it would be:

    Count all A’s, B’s and C’s

    1. Divide A’s by 3 and multiply by 5

    2. Modulo A’s by 3 and multiply by 2

    3. Multiply B’s by 3

    4. Divide C’s by 4 and multiply by 3

    5. Modulo C’s by 4

    Sum the 5 results.

    In Ruby it could like something like this:

    input = "ABCCBAACCA"
    letters = ["A", "B", "C"]
    total = 0
    
    def score(letter,count)
      if letter == "A"
        ((count/3)*5)+((count%3)*2)
      elsif letter == "B"  
        count*3
      else letter == "C"  
        ((count/4)*3)+(count%4)
      end  
    end 
    
    letters.each do |letter|   
      puts "#{letter}: #{score(letter, input.count(letter))}"
      total += score(letter, input.count(letter))
    end
    
    puts "Total: #{total}"
    

    Which produces:

    A: 7
    B: 6
    C: 3
    Total: 16
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some lisp initialisation code: (eval-when (:compile-toplevel :load-toplevel :execute) (require 'asdf)) (eval-when (:compile-toplevel
My Perl program takes some text from a disk file as input, wraps it
Below is the link to the code that has the two RAdEditors I am
I have code like below to perform some conditional validation on fields in my
I'm working on a Google App Engine program that will require some basic spell
I'm looking to design an application that will require some deep control over IP
What will work faster - using PEAR package or require Some_Library.php files in code?
i have a validation class which needs improving. If I require some custom validation
I have a singleton object that use another object (not singleton), to require some
Quick yes/no - I'm building an AJAX application and some scripts require authentication. Can

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.