UW Writing a Function Crossfit that Consumes Two Strings Project
Two words can fit together orthogonally so long as there is a common character shared between them. This is useful for word games like crossword puzzles or Scrabble. For example, "tomato"
and "camel"
can cross at either the m
or the a
. We wish to find out all these crossing points
Write a function crossfit
that consumes two strings, word1
and word2
, and produces a list of pairs of numbers, representing all the places where these two words can cross. Specifically, if the pair (list p q)
is in your produced list, it indicates that the character at position p
in word1
matches the character at position q
in word2
. You may assume that the strings are composed entirely of lowercase alphabetic characters. The list of pairs should be produced in increasing order by the first element of the pair, breaking ties by increasing order of the second element of the pair: see the second example
.> (crossfit “tomato” “camel”)
(list (list 2 2) (list 3 1))
> (crossfit “folly” “mulled”)
(list (list 2 2) (list 2 3) (list 3 2) (list 3 3))
> (crossfit “foil” “paper”)
empty
There are several different approaches to solve this question. One approach is to recurse on the rest of one list, and adjust the recursive result to account for the fact that the first letter of that list has been removed. Another approach is to transform each letter in a list to a two-element list involving the letter and its position in the list. A third approach is to keep track of the “current position” in the list in a parameter to a function, and update that parameter in a natural way as the list is being processed. You may find a different approach as well.
You must not use boolean=?
, substring
or string-ith
. Write the code in race beginner level with list abbreviations. DO NOT USE FUNCTIONS LIKE MAP, FILETER, APPLY AND LABDA IN THE CODE. USE SIMPLE RECURSIVE FUNCTIONS AND FOR EACH HELPER FUNCTIONS USED IN THE CODE GIVE A FEW CHEC-EXPECTS AND THE CONTRACT FOR THE CODE.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
