Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

saulnierpr

  • one year ago

PS4, Spring 2011: Looking at the sample code, I can't see why build_coder is necessary; it seems like it doesn't do anything build_encoder doesn't also do. (This appears to be confirmed by the solution set.) Am I missing something here?

  • This Question is Closed
  1. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I have not worked the MIT problem sets, but from looking at the psudocode in the PDF, it looks like the only difference is that build_coder allows for a positive or negative shift, and build_encoder only does a positive shift value. With this type of cypher, the build_coder would be more efficient. The decoding can be done with the same code by shifting the opposite direction. This reduces programming time.

  2. bwCA
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i couldn't tell what they wanted - i implemented build_coder() then build_encoder is just: return build_coder(shift)

  3. bwCA
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    and of couse, build decoder is just: return build_coder(-shift)

  4. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @bwCA yah, pretty typical code reuse. So have people write the code once, but call it with logical names. Then the interface to the user just asks for the shift value and if you want to encode or decode. They don't need to know you wrote something only once.

  5. saulnierpr
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ah! That makes perfect sense. I shoulda thought the whole problem through, not just the first bit; would've made it a bit more intuitive. Thanks.

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.