Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Test a
- var Test_0 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('a') === true;
- }
- // Test aa
- var Test_1 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('aa') === true;
- }
- // Test aq
- var Test_2 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('aq') === false;
- }
- // Test apple
- var Test_3 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('apple') === true;
- }
- // Test applepie
- var Test_4 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('applepie') === true;
- }
- // Test appleqpietemp
- var Test_5 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('appleqpietemp') === false;
- }
- // Test axaxaxax
- var Test_6 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('axaxaxax') === true;
- }
- // Test assassin
- var Test_7 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('assassin') === true;
- }
- // Test assassine
- var Test_8 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('assassine') === true;
- }
- // Test assassineq
- var Test_9 = function (isConcatenationOfWords) {
- return isConcatenationOfWords('assassineq') === false;
- }
- ------------------------------------------------------------------------------------
- /**
- * @param str input string to test
- * @returns {boolean} true if input string is a concatenation of dictionary words
- */
- function isConcatenationOfWords(str) {
- // TODO: implement me!
- return false;
- }
- var result = isConcatenationOfWords('applepie');
- // ------------------------------------------------------------------
- function isWord(str) {
- return Context.Dictionary.includes(str.toLowerCase());
- }
- Implement a method that, given a String and a Set containing valid words from the English language, returns true if the given String is made up of a concatenation of valid words. Here, "valid word" means that isWord() function returns true.
- Examples:
- Given "applepie", the method would return true because "apple" is a word and so is "pie".
- Given "appleqpie", the method would return false because there is no way to break this up such that all subsequences are words. It would try "a", which is a word, but nothing can be made from "ppleqpie". It would next try "ap", then "app", "appl", and "apple". "apple" is a valid word, but nothing can be made from "qpie". Next try "appleq", and so on.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement