Black and White Thoughts

Month

June 2007

29 posts

Play
Jun 28, 2007
Jun 28, 2007
Jun 28, 20071 note
“If you want to succeed, double your failure rate” —Thomas J. Watson
Jun 25, 2007
Jun 22, 2007
Play
Jun 21, 2007
Topcoder

From time to time when i get bored i play a bit with Topcoder is a fun way to get better in solving problems. I decide to make approaches in different progarmming languages, above i post the problem statement and the solution i made in Ruby/Java, enjoy.

Problem Statement, SRM 355 div 2, 250 points:

In Russia, the Value Added Tax is 18% for almost all goods, with the exception of certain food items, which have a Value Added Tax of only 10%.

You are given a String product, the name of a product, and an int price, the price of the product before tax. You are also given a String[] food, each element of which is the name of a food product. If the given product is an element in food, it is a food item (and thus subject to 10% tax), and otherwise, it is a non-food item (and thus subject to 18% tax). Return the price of the product after tax has been added.

Java aprroach

public class ValueAddedTax {
    public double calculateFinalPrice(String product, int price, String[] food) {
        double res = 0.0;
        for ( int i = 0; i            if ( food[i].equals(product) ) {
                res = (double)(price*0.10)+price;
                break;
            }
            else
                res = (double)(price*0.18)+price;
        }                
        return res;
    }
}

Ruby approach 

class ValueAddedTax
    def calculateFinalPrice(product, price, food)
      food.each do |f|
        if f == product then
          res = (price*0.10)+price
          return res
       end
      end
      res = (price*0.18)+price
      return res
    end
end

Jun 21, 2007
Now in Tech/Geek mode

I think is time for making a change for this tumblelog, in a deeper tech way. I just want to get better in whatever thing i do concerning my carrier. That’s why i will begin  with writting things about programming PHP/Java/Ruby are in my thoughts this days so i will begin with that. I was thinking in posting cool things about Tumblr too, when i find them of course.

 So stay tune :-)

Jun 21, 2007
“Anyone who has never made a mistake has never tried anything new.” —Albert Einstein
Jun 20, 2007
Jun 19, 2007
Play
Jun 18, 2007
Play
Jun 15, 2007
Play
Jun 15, 2007
Jun 15, 2007
Jun 15, 2007
Jun 15, 2007
Jun 15, 2007
Jun 15, 2007
Jun 12, 2007
Jun 12, 2007
Next page →
2012 2013
  • January 45
  • February 34
  • March 33
  • April 37
  • May 33
  • June 7
  • July
  • August
  • September
  • October
  • November
  • December
2011 2012 2013
  • January 17
  • February 2
  • March 2
  • April 31
  • May 64
  • June 20
  • July 9
  • August 8
  • September
  • October 12
  • November 1
  • December 21
2010 2011 2012
  • January 1
  • February
  • March
  • April
  • May 2
  • June 5
  • July 5
  • August 9
  • September 5
  • October 16
  • November 10
  • December 8
2009 2010 2011
  • January 17
  • February 9
  • March 14
  • April 3
  • May 4
  • June 1
  • July
  • August
  • September
  • October
  • November
  • December 9
2008 2009 2010
  • January 9
  • February 2
  • March 4
  • April 5
  • May 15
  • June 4
  • July 31
  • August 2
  • September 8
  • October 5
  • November 7
  • December 58
2007 2008 2009
  • January 16
  • February 67
  • March 8
  • April 19
  • May 17
  • June 16
  • July 8
  • August 2
  • September 2
  • October 4
  • November
  • December 8
2007 2008
  • January
  • February
  • March 34
  • April 10
  • May 14
  • June 29
  • July 16
  • August 27
  • September 21
  • October 17
  • November 5
  • December 10