Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- **6d.**(0.3 point) Define a function `sentence.scrambler()` that operates similarly to to `sentence.flipper()`, but which randomly scrambles the order of characters in each word, instead

- **6d.**(0.3 point) Define a function `sentence.scrambler()` that operates similarly to to `sentence.flipper()`, but which randomly scrambles the order of characters in each word, instead of deterministically reversing them. The function `sentence.scrambler()` should be vectorized, just like the current version of `sentence.flipper()`. Hint: you can use `browser()` at any point if you run into bugs in your development, or simply to see how your function is handling certain test inputs. Also, the implementation of `sentence.scrambler()` should be pretty similar to `sentence.flipper()`; really, you just need to replace `word.flipper()` by a suitable function. Once done, run `sentence.scrambler()` on the test string below to display the output.

```{r, error=TRUE}

# Define sentence.scrambler() here

sentence.scrambler = function(str) {

paste(lapply(strsplit(strsplit(str, ",")[[1]], ""),

function(x) paste(rev(x), collapse = "")), collapse = " ")

}

sentence.scrambler(c("I have no theorems, well",

"I do have theorems, but none of them are named Fienberg's Theorem",

"Even if there were a Fienberg's Theorem, it probably wouldn't be important",

"What's important is the attitude, for what statistics is",

"and how it's recognized by other people outside of our field"))

```

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

Mathematics Concepts With Applications

Authors: Charles P McKeague

1st Edition

1630983136, 9781630983130

More Books

Students also viewed these Mathematics questions

Question

1. Explain how business strategy affects HR strategy.

Answered: 1 week ago