Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Test a
  2. var Test_0 = function (isConcatenationOfWords) {
  3.     return isConcatenationOfWords('a') === true;
  4. }
  5.  
  6. // Test aa
  7. var Test_1 = function (isConcatenationOfWords) {
  8.     return isConcatenationOfWords('aa') === true;
  9. }
  10.  
  11. // Test aq
  12. var Test_2 = function (isConcatenationOfWords) {
  13.     return isConcatenationOfWords('aq') === false;
  14. }
  15.  
  16. // Test apple
  17. var Test_3 = function (isConcatenationOfWords) {
  18.     return isConcatenationOfWords('apple') === true;
  19. }
  20.  
  21. // Test applepie
  22. var Test_4 = function (isConcatenationOfWords) {
  23.     return isConcatenationOfWords('applepie') === true;
  24. }
  25.  
  26. // Test appleqpietemp
  27. var Test_5 = function (isConcatenationOfWords) {
  28.     return isConcatenationOfWords('appleqpietemp') === false;
  29. }
  30.  
  31. // Test axaxaxax
  32. var Test_6 = function (isConcatenationOfWords) {
  33.     return isConcatenationOfWords('axaxaxax') === true;
  34. }
  35.  
  36. // Test assassin
  37. var Test_7 = function (isConcatenationOfWords) {
  38.     return isConcatenationOfWords('assassin') === true;
  39. }
  40.  
  41. // Test assassine
  42. var Test_8 = function (isConcatenationOfWords) {
  43.     return isConcatenationOfWords('assassine') === true;
  44. }
  45.  
  46. // Test assassineq
  47. var Test_9 = function (isConcatenationOfWords) {
  48.     return isConcatenationOfWords('assassineq') === false;
  49. }
  50. ------------------------------------------------------------------------------------
  51.  
  52. /**
  53.  * @param str input string to test
  54.  * @returns {boolean} true if input string is a concatenation of dictionary words
  55.  */
  56. function isConcatenationOfWords(str) {
  57.     // TODO: implement me!
  58. return false;
  59.  
  60. }
  61.  
  62. var result = isConcatenationOfWords('applepie');
  63.  
  64. // ------------------------------------------------------------------
  65.  
  66. function isWord(str) {
  67.     return Context.Dictionary.includes(str.toLowerCase());
  68. }
  69.  
  70. 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.
  71.  
  72. Examples:
  73.  
  74. Given "applepie", the method would return true because "apple" is a word and so is "pie".
  75. 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