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...
*** 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 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...
The goal of this assignment is to implement a simple client-server system. You have to use...
The goal of this assignment is to implement a simple client-server system. You have to use Python. The basic functionality of the system is a remote calculator. You first will be sending expressions through the client to the server. The server will then calculate the result of the expression and send it back to the client where it is displayed. The server should also send back to the client the string "Socket Programming" as many times as the absolute value...
Programming Exercise 2: implement the member function moveToNth(...) that removes the item marked by the cursor...
Programming Exercise 2: implement the member function moveToNth(...) that removes the item marked by the cursor and inserts it as the nth element of the list; test your implementation by turning the flag LAB3_TEST2 from 0 to 1 in config.h; - Programming Exercise 3: implement the ListArray member function find(...) that searches for the element given as a parameter; the search starts at the cursor and stops when it finds the element or at the end of the list; the...
For this assignment you need to write a parallel program in C++ using OpenMP for vector...
For this assignment you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is: #pragma...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT