Skip to content

Commit

Permalink
Merge branch 'master' into patch-7
Browse files Browse the repository at this point in the history
  • Loading branch information
siriak authored Oct 25, 2024
2 parents 3dae652 + 64b7b70 commit 7566746
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions text_manipulation/rearrangeWays.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
rearrangeWays <- function(string, as_report = TRUE){

if(as_report){ # conditional statement

# split the string into letters
string_split <- c(unlist(strsplit(string,split = "")))

# get the factorial of the letters vector
possible_ways <- factorial(length(string_split))

# create the answer text
answer <- paste(string, "can be rearranged in", possible_ways, "possible ways")


return(noquote(answer))


}else{

# split the string into letters
string_split <- c(unlist(strsplit(string,split = "")))

# get the factorial of the letters vector
possible_ways <- factorial(length(string_split))

return(possible_ways)

}


}

rearrangeWays(string = "straight")

0 comments on commit 7566746

Please sign in to comment.