4 kyu

Bob's Signs

109 of 157Strikeskids

Description:

Overview

You need to help Bob be a good businessman and not charge people too much for his signs.

Description

Bob is running a business that creates signs for people. He can charge much less than his competitors because he charges by letter instead by the entire sign. He can take a sign and change a few letters to make a new sign much more cheaply than a competitor can make a sign from scratch.

The only problem is Bob is not very good at pricing these changes. He wants to be able to look at a sign and a customer's request and quickly be able to give the customer an estimate for the total cost.

Task

Write a class SignMaster that is able to help Bob estimate prices quickly. Bob will need to be able to changePrices(prices) so that he can adapt to the changing market. He also needs to estimatePrice(oldSign, newSign) so that he can give his price estimates to his customers.

The changePrices method takes an object that specifies the new prices. The values are the cost of doing an operation (add or remove) and the keys will be add or rem depending on the operation. Bob does not always want to change the price for both adding and removing letters, so this method should handle incomplete input. Before this method is called, the sign changes should be free.

estimatePrice takes two strings. The first string is the old sign of the customer and the second is their request. This method should return the cost of changing the sign from the old message to the new message. If there are multiple ways to change the sign, this method should return the cheapest way.

Strings
Dynamic Programming
Algorithms

Similar Kata:

More By Author:

Check out these other kata created by Strikeskids

Stats:

CreatedFeb 13, 2014
PublishedFeb 13, 2014
Warriors Trained822
Total Skips89
Total Code Submissions1820
Total Times Completed157
JavaScript Completions109
CoffeeScript Completions7
Haskell Completions29
Python Completions22
Total Stars45
% of votes with a positive feedback rating96% of 50
Total "Very Satisfied" Votes46
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes0
Total Rank Assessments6
Average Assessed Rank
4 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
5 kyu
Ad
Contributors
  • Strikeskids Avatar
  • JohanWiltink Avatar
  • user8436785 Avatar
  • fireguy187 Avatar
  • dfhwze Avatar
Ad