Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Inputs: (char) 1x4N character vector of 'Yea' and 'Nay' (double) 1xN vector of volunteer IDs (double) The number of volunteers needed Outputs: 1. (double) 1xM

Inputs:

  1. (char) 1x4N character vector of 'Yea' and 'Nay'

  2. (double) 1xN vector of volunteer IDs

  3. (double) The number of volunteers needed

Outputs:

1. (double) 1xM vector of IDs who were selected

Background:

You are running the volunteer pool for the Olympic Marathon Tryouts. Unfortunately, your bosses have declined to give you any resources to organize the multitudes of volunteers required for this event. Fortunately, you don't need any resources other than MATLAB!

Function Description:

You are given a character vector consisting of the words 'Yea' and 'Nay' separated by spaces where the first word represents the first volunteer's answer, the second represents the second volunteers answer, and so on. First find all those who answered 'Yea'. Then select the number of volunteers given by the third input from the front of those who answered 'Yea'.

Example:

answers = 'Yea Nay Yea Yea Nay '; volunteers = [21, 5, 31, 10, 2]; needed = 2; selected = yeaOrNay(answers, volunteers, needed); selected [21 31]

Notes:

  • There will always be enough 'Yea' answers to fill all selected spots.

  • The string will always follow this capitalization pattern.

  • There will only be one space separating words and one trailing space after the last word.

    Hints:

  • Think of how you can reduce the number of characters in the first input without reducing the amount of information contained.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

Carry out an interview and review its success.

Answered: 1 week ago