A (7, 4) error correcting Hamming code is designed with a generator matrix, G = 1 0 0 0 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 0 0 0 0 1 1 1 1 . (1) a) (10 points) Determine the code word for the message, 0110. b) (10 points) Determine the code word for the message, 1100. c) (9 points) Determine the syndrome vector for the received word, 0111011. d) (1 point) Correct the received word, 0111011. e) (9 points) Determine the syndrome vector for the received word, 1100111. f) (1 point) Correct the received word, 1100111.
In: Computer Science
C Code
Edit this code to make it output all unique letters IN LOWERCASE of an input file.
For example, with this input:
Raspberry Grapefruit Straw berry raspBERRY
Blue$$berry apple Pine_apple raspberry
The output should be:
raspberry
grapefruit
straw
berry
blue
berry
apple
pine
NOTE: Words with different capitlization, like raspberry and raspBERRY count as 1 unique word, so raspberry should only be seen once in the output.
#include <stdio.h>
#include <stdlib.h>
int main()
{
//Pointer to access the file.
FILE *file_ptr;
//string to read each word.
char word[100];
// To open the file.
file_ptr = fopen("input_text.txt", "r");
if (file_ptr == NULL)
{
printf("No such file exist in
current folder \n");
exit(0);
}
//To read the file .
while ( fscanf(file_ptr, "%s", word) != EOF)
{
printf("Word (%ld):
",strlen(word));
printf ("%s\n", word);
}
//Close the file.
fclose(file_ptr);
return 0;
}
In: Computer Science
Read this entire document before beginning your lab.
For this lab you are required to fulfill all requirements exactly as described in this provided document, no less, no more.
Problem: Read in a word and display the requested characters from that word in the requested format. Write a Java program that
● prompts the user for a word and reads it,
● converts all characters of the input word to uppercase and display the word with a double quotation mark ( " ) at the start and end of the word,
● displays the word with all characters whose index is odd in lower case and for the rest of the characters displaying a * instead of the character,
● finally displays the original word as it was entered by the user.
Based on the previous specifications your program should behave and look exactly as shown in the cases below. Your program should work for any word entered by the user, not just the ones in the samples.
Below illustrates how your program should behave and appear.
Note that ◦ symbol indicates a space and ↵ is a new line character. All words except for user input (in blue) must be exactly as indicated in the sample. Any extra “spaces” and/or “new lines” will be graded a wrong answer.
|
Program Sample outputs |
|
|
ex:1 |
Enter◦a◦word:◦ELEPhant↵ ↵ ELEPhant |
|
ex:2 |
Enter◦a◦word:◦Nancy_12A↵ ↵ Nancy_12A |
Note 1: The use of libraries other than java.util.Scanner is
prohibited.
Note 2: You may find the use of the following methods useful –
charAt(), toLowerCase(), toUpperCase(), length().
in java
Note 3: Final thought, remember that your solution is case-sensitive and space-sensitive, fulfill the above instructions carefully and precisely.
In: Computer Science
Scrambled Word Game (Python)
Topics: List, tuple
In this lab, you will write a scrambled word game. The game starts by loading a file containing scrambled word-answer pair separated. Sample of the file content is shown below. Once the pairs are loaded, it randomly pick a scrambled word and have the player guess it. The number of guesses is unlimited. When the user guess the correct answer, it asks the user if he/she wants another scrambled word.
bta:bat
gstoh:ghost
entsrom:monster
Download scrambled.py and halloween.txt. The file scrambled.py already has the print_banner and the load_words functions. The function print_banner simply prints “scrambled” banner. The function load_words load the list of scrambled words-answer pairs from the file and return a tuple of two lists. The first list is the scrambled words and the second is the list of the answers. Your job is the complete the main function so that the game works as shown in the sample run.
Optional Challenge: The allowed number of guess is equal to the length of the word. Print hints such as based on the number of guess. If it’s the first guess, provides no hint. If it’s the second guess, provides the first letter of the answer. If it’s the third guess, provides the first and second letter of the correct answer. Also, make sure the same word is not select twice. Once all words have been used, the game should tell user that all words have been used and terminate.
Sample run:
Scrambled word is: wbe
What is the word? bee
Wrong answer. Try again!
Scrambled word is: wbe
What is the word? web
You got it!
Another game? (Y/N):Y
Scrambled word is: meizob
What is the word? Zombie
You got it!
Another game? (Y/N):N
Bye!
Provided code:
def display_banner():
print("""
__
_
_
_
/ _\ ___ _ __ __ _ _ __ ___ | |__ | | ___ __| |
\ \ / __|| '__|/ _` || '_ ` _ \ | '_ \ | | / _ \ / _` |
_\ \| (__ | | | (_| || | | | | || |_) || || __/| (_| |
\__/ \___||_| \__,_||_| |_| |_||_.__/ |_| \___|
\__,_|
""")
def load_words(filename):
#load file containing scrambled word-answer
pairs.
#scrambled word and answer are sparated by :
scrambled_list = []
answer_list = []
with open(filename, 'r') as f:
for line in f:
(s,a) = line.strip().split(":")
scrambled_list += [s]
answer_list += [a]
return (scrambled_list, answer_list)
def main():
display_banner()
(scrambled_list, answer_list) =
load_words('halloween.txt')
#your code to make the game
work.
main()
Halloween.txt file.
bta:bat
gstoh:ghost
entsrom:monster
ihtcw:witch
meizob:zombie
enetskol:skeleton
rpamevi:vampire
wbe:web
isdepr:spider
umymm:mummy
rboom:broom
nhlwaeeol:Halloween
pkiumnp:pumpkin
kaoa jlern tcn:jack o lantern
tha:hat
claabck t:black cat
omno:moon
aurdclno:caluldron
In: Computer Science
PYTHON
Find anagrams of a word using recursion.
This a possible run of your program: Enter a word or empty string to finish: poster
The word poster has the following 6 anagrams:
presto
repost
respot
stoper
topers
tropes
In: Computer Science
12) Refer the previous question: The following table gives the common disorders, problems and complaints associated with each body system and its components relevant to the nursing care you might provide for your clients in the Australian health care system. Complete the following table with regard to its definition, pathophysiology, signs and impact of specific health procedures(in 10-20 words each). DISEASES AFFECTING THE CARDIOVASCULAR SYSTEM Raynaud's phenomenon Raynaud's phenomenon
12.1) Definition Minimum word required : 10 Word count : 78
12.2) Briefly outline the pathophysiology Minimum word required : 10 Word count : 78
12.3) List four signs Minimum word required : 10 Word count : 78
12.4) Impact of calcium channel blockers in patients with Raynaud's phenomenon
In: Nursing
In: Civil Engineering
Caches are important to providing a high performance memory hierarchy to processors. Below is a list of 32-bit memory address references, given as word addresses. 6, 214, 175, 149, 214, 6 Given a direct-mapped cache with four-word blocks and a total size of 16 blocks. Please fill in the following table. You may assume that the cache is initially empty. Because the given address is word address, we may compute tags and indices based on word address. Four-word blocks indicate the right most 2 bits are offset in a block. 16 blocks indicates there are 4 bits for indices, and the rest 26 bits will be the tag.
Word address Binary Tag (hex) Index (Hex) Hit/Miss
6
214
175
149
214
6
In: Computer Science
Please, write code in c++. Using iostream and cstring library
Write a function that will find and return most recent word in
the given text.
The prototype of the function have to be the following void
mostRecent(char *text,char *word)
In char *word your function have to return the most recent word
that occurce in the text.
Your program have to be not case-sensitive(ignore case -
"Can" and "CAN" are the same
words)
Also note than WORD is sequence of letters sepereated by
whitespace.
Note. The program have to use pointer.
Input:
First line contains one line that is not longer than 1000 symbols
with whitespaces.
Output: The most recent word in UPPER case.
example:
Input:
Can you can the can with can?
output:
CAN
In: Computer Science
JAVA Wordladder Project
stone
Atone
aLone
Clone
clonS
cOons
coNns
conEs
coneY
Money
Word ladders were invented by Lewis Carroll in 1878, the author of Alice in Wonderland. A ladder is a sequence of words that starts at the starting word, ends at the ending word, In a word ladder puzzle you have to change one word into another by altering a single letter at each step. Each word in the ladder must be a valid English word and must have the same length. For example, to turn stone into money, one possible ladder is given on the left.
Many ladder puzzles have more than one possible solution. Your program must determine the shortest word ladder. Another path from stone to money is
stone store shore chore choke choky cooky cooey coney money
Objectives
Practice implementing and using a Queue data structure.
Gain an understanding of the algorithms used for efficient implementation.
Practice working in small teams to solve problems, design algorithms and write code
Instructions
Your program will accept starting and ending words from the input file called "infile.txt". Then, you read the dictionary file called “dictionary.txt '' store all words in a LinkedList. Finally, you build a word ladder between starting and ending words
There are several ways to solve this problem. One simple method involves using stacks and queues. The algorithm (that you must implement) works as it follows
Get the starting word and search through the dictionary to find all words that are one letter different. Create stacks for each of these words, containing the starting word (pushed first) and the word that is one letter different. Enqueue each of these stacks into a queue. This will create a queue of stacks! Then dequeue the first item (which is a stack) from the queue, look at its top word and compare it with the ending word. If they equal, you are done - this stack contains the ladder. Otherwise, you find all the words one letter different from it. For each of these new words create a deep copy of the stack and push each word onto the stack. Then enqueue those stacks to the queue. And so on. You terminate the process when you reach the ending word or the queue is empty.
You have to keep track of used words! Otherwise, an infinite loop occurs.
Example
The starting word is smart. Find all the words one letter different from smart, push them into different stacks and store stacks in the queue. This table represents a queue of stacks.
----------------------------------------------------
| scart | start | swart | smalt | smarm |
| smart | smart | smart | smart | smart |
----------------------------------------------------
Now dequeue the front and find all words one letter different from the top word scart. This will spawn seven stacks:
---------------------------------------------------------------------
| scant | scatt | scare | scarf | scarp | scars | scary |
| scart | scart | scart | scart | scart | scart | scart |
| smart | smart | smart | smart | smart | smart | smart
|
----------------------------------------------------------------------
which we enqueue to the queue. The queue size now is 11. Again dequeue the front and find all words one letter different from the top word start. This will spawn four stacks:
----------------------------------------
| sturt | stare | stark | stars |
| start | start | start | start |
| smart | smart | smart | smart |
----------------------------------------
Add them to the queue. The queue size now is 14. Repeat the procedure until either you find the ending word or such a word ladder does not exist. Make sure you do not run into an infinite loop!
Queue
You are to implement a Queue data structure based on Java’s Queue class using LinkedList.
Stack
You are to use Java's Stack class.
Dictionary
You read the dictionary file which has the contents at the bottom of this page "dictionary.txt"
The dictionary file contains exactly one word per line. The number of lines in the dictionary is not specified.
Output
Your program must output to the console one word ladder from the start word to the end word. Every word in the ladder must be a word that appears in the dictionary. This includes the given start and end words--if they are not in the dictionary, you should print "There is no word ladder between ..." Remember that there may be more than one ladder between the start word and the end word. Your program may output any one of these ladders. The first output word must be the start word and the last output word must be the end word. If there is no way to make a ladder from the start word to the end word, your program must output "There is no word ladder between ..."
For testing purposes, I provide you with the input file and the expected output.
SAMPLE OUTPUT
[line, fine]
[dear, fear]
There is no word ladder between stone and money
[fake, lake, lase, last, cast, cost, coat]
[like, line, fine, fire, fore, core, cord, cold, hold, held, help]
There is no word ladder between blue and pink
[face, fake, lake, like]
[help, held, hold, cold, cord, core, fore, fire, fine, find, mind]
[lice, line, fine, fire, fore, core, cord, cold, hold, held, help]
There is no word ladder between door and lice
Starter Code:
WordLadder.java
import java.util.*;
import java.io.*;
public class WordLadder {
private static LinkedList dict;
private static LinkedList visited;
private static String start, end;
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
File dictfile = new File("dictionary.txt");
File infile = new File("infile.txt");
dict = new LinkedList<>();
// load the dictionary
try(
Scanner in = new Scanner(dictfile);){
while(in.hasNext()) {
dict.add(in.next());
}
}
try(Scanner in = new Scanner(infile);)
{
while(in.hasNext()) {
start = in.next();
end = in.next();
if(start.length()!=end.length() || !dict.contains(start) || !dict.contains(end) ){
System.out.println("There is no word ladder between "+start+ " and "+end);
continue;
}
findLadder(start,end);
}
}
}
public static void findLadder(String start,String end) {
Queue> queue = new LinkedList<>();
visited = new LinkedList<>();
Stack copiedStack = new Stack<>();
// Left as exercise
}
public static boolean isAnEdge(String w1, String w2) {
// Left as exercise
}
}
lice deck cord bent band cast bike cash card boat cold coat dear slow core dash cost dame fish dorm dine deer dear dime fast blue deme dive dish dinn door dome fake slow pink face find fast fire fear fine finn help held hash fore folk fold hard hear here host hold hire lase land knot lake kunn kuns last mind main line lime like lost live linn love lunn mike maze mash make mice meta mien milk vice silk neck mink mine must most more nash sick nice rain pour pine nick pain nine nuns pond pony poor sake rick rash rime rust sane sand sine sure sony tiny warm vide ward worm
line fine dear fear stone money fake coat like help blue pink face like help mind lice help door lice
In: Computer Science