• Skip to main content
  • Skip to footer

SoftwareProg.com

Software programming learning aide

  • Blog
    • Discussion
  • News
  • CS50’s Introduction to Computer Science by Harvard University on Edx
    • Week 1
    • Week 2
    • Week 3
    • Week 4
    • Week 5

Substitution project and Scrabble lab: Finding analogy

CS50 threads to aide as a supplementary resource › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2 › Substitution project and Scrabble lab: Finding analogy

Tagged: arrays, pseudocode of substitution project, substitution project

  • This topic is empty.
Log In Register Lost Password
Viewing 1 post (of 1 total)
  • Author
    Posts
  • February 9, 2022 at 12:11 pm #201
    admin
    Keymaster

      ust started with the Substitution project.

      It appears there is a close analogy between Substitution project and Scrabble lab.

      In Scrabble lab, POINTS is an array that contains allotted value to the 26 alphabets. A = 1, B = 3…

      In Substitution project: A will be alloted the first character entered by the user as plantext, B second character….

      Am I correct?

      Here is my rough pseudocode:

      Make two arrays as reference point:

      Array 1       Array 2
      A                a
      B                b
      C               c
      … Z            … z

      Make two arrays based on key value for each character entered by the user in argv[1]. Say ntf…e

      Key 1            Key 2
      N                  n
      T                   t
      F                   f
      …E                … e

      Suppose the user enters in plain text: Rajeev

      R as first character will be checked in Array 1 and Array 2. Once R detected, corresponding value in Key 1 will be replaced.


      Reply


      There’s not really much point in having array1 or array2. After all, you know what order the alphabet is in. G will never be anywhere other than index 6, so you can just skip those first two arrays entirely and go straight to looking at index 6 of your key.

      Other than that you definitely seem to be on the right track


       [learn_press_profile]

    • Author
      Posts
    Log In Register Lost Password
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Log In

    Log in / Register

    Initiative by Digital Splendid OPC Pvt. Ltd.