Question

Implement an algorithm in Ruby that removes the elements that are in matrix A that are...

Implement an algorithm in Ruby that removes the elements that are in matrix A that are corresponding with other matrices
  
Input

MatrixA = 'whiteblueyellowgreenpurplewhiteyellow'

MatrixB = 'blue'

MatrixC = 'white'


Output

Result = 'yellowgreenpurpleyellow'

Homework Answers

Answer #1

Answer :

Algorithm :

MatrixA = 'whiteblueyellowgreenpurplewhiteyellow'

MatrixB = 'blue'

MatrixC = 'white'

puts MatrixA.gsub(MatrixB, '').gsub(MatrixC, '')

Below you can see the program and output :

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a ruby algorithm that prints only words that begin with a capital letter Input a...
Write a ruby algorithm that prints only words that begin with a capital letter Input a = ['aA', 'Aa', 'red', 'Book'] Output b = ['Aa', 'Book']
Part 1: Implement findknn Implement the function findknn, which should find the ?k nearest neighbors of...
Part 1: Implement findknn Implement the function findknn, which should find the ?k nearest neighbors of a set of vectors within a given training data set. The call of: [I,D]=findknn(xTr,xTe,k); should result in two matrices ?I and ?D, both of dimensions ?×?k×n, where ?n is the number of input vectors in xTe. The matrix ?(?,?)I(i,j) is the index of the ??ℎith nearest neighbor of the vector ???(?,:)xTe(j,:). So, for example, if we set i=I(1,3), then xTr(i,:) is the first nearest...
Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar...
Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar questions. Please post in a format that can be directly copied. Reasoning on answers would be most helpful but not required. Thank you in advance for your help. 2. Consider the following algorithm for finding the distance between the two closest elements in an array of numbers. ALGORITHM MinDistance(A[0..n − 1])//Input: Array A[0..n − 1] of numbers //Output: Minimum distance between two of its...
Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar...
Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar questions. Please post in a format that can be directly copied. Reasoning on answers would be most helpful but not required. Thank you in advance for your help. 1.Design an algorithm to find all the common elements in two sorted lists of numbers. For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, the output should be 2,...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except for 1s on the reverse diagonal from top right to bottom left. The reverse diagonal of an n-by-n matrix consists of the elements at the following indexes: (1, n), (2, n-1), (3, n-2), … (n, 1). The function takes one positive integer input argument named n, which is the size of the matrix, and returns the matrix itself as an output argument. Note that...
Implement function build_dictionary(words) that returns a dictionary. The words parameter is a list of strings. Each...
Implement function build_dictionary(words) that returns a dictionary. The words parameter is a list of strings. Each word in the words parameter will be counted and you will build your dictionary around the frequency count. Each key of your dictionary will be the word in your list of strings and the corresponding value is an integer indicating the word’s frequency. Assume input is always valid. ‘Blue’ and ‘blue’ should be counted as the same word. [You may use lower() ONLY and...
In this exercise you're going to implement a graph class using an adjacency matrix of size...
In this exercise you're going to implement a graph class using an adjacency matrix of size 26x26. This allows up to 26 vertices, which will be denoted by the uppercase letters A .. Z. Initially a graph is empty, and then vertices and edges are added. Edges are directed, and have weights. Example: (A, B, 100) denotes an edge from A to B with weight 100; there is no edge from B to A unless one is explicitly added. A...
Implement a singly linked list having all unique elements with the following operations.I 0 x –...
Implement a singly linked list having all unique elements with the following operations.I 0 x – Inserts element x at the end. I 1 y x – If the element y exists, then insert element x after the element y, else insert element y before the existing element x. Assuming either the element x or the element y exists. I 2 z y x – Inserts element x in the middle of the elements z and y. The element z...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(),...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(), and isEmpty(). For this assignment, enqueue() will be implemented in an unusual manner. That is, in the version of enqueue() we will use, if the element being processed is already in the queue then the element will not be enqueued and the equivalent element already in the queue will be placed at the end of the queue. Additionally, you must implement a circular queue....
Your assignment is to implement a computer program in C++ to implement the below application. According...
Your assignment is to implement a computer program in C++ to implement the below application. According to Dummies.com the following algorithm determines the amount of paint you need to paint the walls of a four-sided room: 1. Add together the length of each wall. (For example, if each of the four walls are 14, 20, 14, 20 feet respectively then the total length is 14 + 20 + 14 + 20 = 68 feet) 2. Multiply the sum by the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT