- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2: [Arrays] – Functions, Variable and Scope, Debugging, Arrays, and Command Line Arguments › Substitution project and Scrabble lab: Finding analogy
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]