Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

saulnierpr

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?

  • 10 months ago
  • 10 months ago

  • This Question is Closed
  1. e.mccormick
    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.

    • 10 months ago
  2. bwCA
    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)

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

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

    • 10 months ago
  4. e.mccormick
    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.

    • 10 months ago
  5. saulnierpr
    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.

    • 10 months ago
    • Attachments:

See more questions >>>

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.