Program 1: Word Pattern - Write a program or script in the programming language
ID: 2267370 • Letter: P
Question
Program 1: Word Pattern - Write a program or script in the programming language of your choice to
Part 1: Word to Pattern
a. for any given string of characters, return the pattern.
For example, the word "apple" may be represented as the patterns abbcd or 01123 or 12234
b. The program should be able to take a string from console (typed word) or read words from a file
Part 2: Pattern to Word
a. for a given string of characters representing a word pattern, return possible candidate words (take advantage of words_aplha.txt and you may want to create a new file)
For example, the pattern "abbcd" will return a list of candidates as:
apple
essay
reefs
hooky
leets
wooly
:
Likewise if a word is entered "apple" then the candidate list is also returned
b. The program should be able to take a string from console (typed word) or read words from a file.
3. Crypto Problem: Use your program to help solve this puzzle?
KCXCHUHCRIB KCGO RIKA CI RDW XCITB. QDH CP YO DBO RDW CXUZCIUHCRIB, RDW JRBBCQCKCHCOB QOVRXO KCXCHKOBB. —FUXCO JURKCIOHHC
What did you find helpful or challenging about this problem?
What is the "Key" used to create the encoded message?
4. What about this cipher? Your program may not work as written. What can you do to adapt the program or the cipher to meet your needs (hint: adapting the cipher may be easier)?
7 12 26 20 14 4 22 4 15 14 4 7 12 3 2 22 4 15 12 26 16 3 2 15 6 3 24 25 5 5 4 14 3 23
24 26 20 12 3 24 20 12 26 2 26 8 9 12 26 18 3 20 25 5 ?
26 2 23 7 3 24 : 20 12 3 23 26 6 3 20 12 25 2 10 . 23 25 6 9 8 3 23 15 18 23 20 26 20 25 4 2 23
24 3 9 8 26 5 3 4 2 3 23 22 6 18 4 8 4 21 9 8 26 25 2 20 3 17 20 7 25 20 12 4 2 3
23 22 6 18 4 8 4 21 5 25 9 12 3 24 20 3 17 20 .
What is the "Key" used to create this encoded message?
5. Please submit your code, results, and observations.
Explanation / Answer
#include<stdio.h>
#include<conio.h>
void printDigit(int digit);
int main() {
int reverse = 0, digit, num, mod;
printf("Enter a positive Integer ");
scanf("%d", &num);
/* reverse the input number */
while (num > 0) {
reverse = (reverse * 10) + num % 10;
num /= 10;
}
num = reverse;
while (num > 0) {
digit = num % 10;
printDigit(digit);
num = num / 10;
}
getch();
return 0;
}
void printDigit(int digit){
switch (digit) {
case 0:
printf("Zero ");
break;
case 1:
printf("One ");
break;
case 2:
printf("Two ");
break;
case 3:
printf("Three ");
break;
case 4:
printf("Four ");
break;
case 5:
printf("Five ");
break;
case 6:
printf("Six ");
break;
case 7:
printf("Seven ");
break;
case 8:
printf("Eight ");
break;
case 9:
printf("Nine ");
break;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.