[Tutor] Help!

Danny Yoo dyoo at hashcollision.org
Mon Jan 28 22:51:57 CET 2013


> Hi guys I wanted to make a program called Binary/decimal converter. But I want to do it the hard way e.g. not using built in python functions. Can you give me an idea about how I can do that?


Do you have an idea of what kind of things would be useful test cases
for this converter?  Thinking about this may help solidify what it is
you're trying to do.  By it, we want to help you express concretely
what you mean when you say "binary/decimal converter".

---

For example, if I wanted to write a program to convert "snow" to
"water", I might start like this:

I want to write a program to take words like "snow" and rewrite them
to "water".  But anything else should stay the same.  Let me give a
name to this.  Call it "melt".  Here are some examples I'd like to
make work (or not work).

    melt("The snow is cold!")  ==> "The water is cold!"
    melt("The snowflakes are falling") ==>  "The snowflakes are falling"
    melt("Snow and ice") ==>  "Water and ice"

That is, I want to make sure the translation is case sensitive, but
only applies when the whole word "snow" shows up.


... etc.  A potential approach might use regular expression
replacement, with a little bit of care about using a function for the
replacement argument so we can handle the weird uppercasing
requirement...

---


If you plan like this, and include concrete test cases, then you'll
have a better shot at solving the problem.


More information about the Tutor mailing list