{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":55210,"title":"Determine whether one vector is a subset of another","description":"While bumbling through a pair of problems in the Number Theory group, I wrote code to determine whether a vector is a subset of another vector. I thought the function ismember might work, but it does not account for repeated elements in a way necessary to check for a subset. \r\nFor example, if a = [1 2 1 3 3] and b = [3 2 1 1 5 4], [lia, locb] = ismember(a,b) returns lia = [1 1 1 1 1] and locb = [3 2 3 1 1]. In other words, the first vector indicates whether each element in a appears in b at least once, and the second vector gives the index of the first occurrence of the element of a in b. The command all(lia) would return true, but a is not a subset of b. \r\nWrite a function to determine whether one vector is a subset of another. The function will return two arguments: a logical tf that indicates whether a is a subset of b and a vector locb that gives unique indices into b where the elements of a occur. For repeating elements, the indices should increase, and for elements of a not in b, return zero. For the example of a and b above, tf is false and locb = [3 2 4 1 0]. \r\nI could not find either a MATLAB function or Cody problem that addresses this task, but I would not be too surprised if there is an elegant or built-in solution that I missed.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 300px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 150px; transform-origin: 407px 150px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 152.492px 8px; transform-origin: 152.492px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhile bumbling through a pair of problems in the \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/groups/2001\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eNumber Theory group\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 151.292px 8px; transform-origin: 151.292px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, I wrote code to determine whether a vector is a subset of another vector. I thought the function \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 30.8px 8px; transform-origin: 30.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eismember\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 195.25px 8px; transform-origin: 195.25px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e might work, but it does not account for repeated elements in a way necessary to check for a subset. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 48.225px 8px; transform-origin: 48.225px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example, if \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 54.6417px 8px; transform-origin: 54.6417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e = [1 2 1 3 3] and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 48.8px 8px; transform-origin: 48.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e = [3 2 1 1 5 4], \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 103.95px 8px; transform-origin: 103.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003e[lia, locb] = ismember(a,b)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.6667px 8px; transform-origin: 25.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e returns \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 65.45px 8px; transform-origin: 65.45px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elia = [1 1 1 1 1]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 69.3px 8px; transform-origin: 69.3px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elocb = [3 2 3 1 1]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 205.75px 8px; transform-origin: 205.75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. In other words, the first vector indicates whether each element in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 36.5667px 8px; transform-origin: 36.5667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e appears in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 59.1167px 8px; transform-origin: 59.1167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e at least once, and the second vector gives the index of the \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 49.7833px 8px; transform-origin: 49.7833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003efirst occurrence \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 54.0583px 8px; transform-origin: 54.0583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eof the element of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.33333px 8px; transform-origin: 9.33333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 50.5583px 8px; transform-origin: 50.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. The command \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 30.8px 8px; transform-origin: 30.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eall(lia)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 42.4px 8px; transform-origin: 42.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e would return \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.4px 8px; transform-origin: 15.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003etrue\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.55px 8px; transform-origin: 15.55px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, but \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 56.775px 8px; transform-origin: 56.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is not a subset of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 372.883px 8px; transform-origin: 372.883px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to determine whether one vector is a subset of another. The function will return two arguments: a logical \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 7.7px 8px; transform-origin: 7.7px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003etf\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that indicates whether \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 45.1083px 8px; transform-origin: 45.1083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is a subset of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 42.3917px 8px; transform-origin: 42.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and a vector \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.4px 8px; transform-origin: 15.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elocb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 93.75px 8px; transform-origin: 93.75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that gives unique indices into \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 72.7333px 8px; transform-origin: 72.7333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e where the elements of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22.55px 8px; transform-origin: 22.55px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e occur. For repeating elements, the indices should increase, and for elements of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 21px 8px; transform-origin: 21px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e not in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 101.892px 8px; transform-origin: 101.892px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, return zero. For the example of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e above, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 7.7px 8px; transform-origin: 7.7px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003etf\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 8.94167px 8px; transform-origin: 8.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 19.25px 8px; transform-origin: 19.25px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003efalse\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 69.3px 8px; transform-origin: 69.3px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elocb = [3 2 4 1 0]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 382.592px 8px; transform-origin: 382.592px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eI could not find either a MATLAB function or Cody problem that addresses this task, but I would not be too surprised if there is an elegant or built-in solution that I missed.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [tf,locb] = isSubset(a,b)\r\n  [lia,locb] = ismember(a,b);\r\n  tf = all(lia);\r\nend","test_suite":"%%\r\na = [1 2 1 3 3];\r\nb = [3 2 1 1 5 4];\r\nlocb_correct = [3 2 4 1 0];\r\n[tf,locb] = isSubset(a,b);\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [];\r\nb = [3 2 1 1 5 4];\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isempty(locb))\r\n\r\n%%\r\na = 1:5;\r\nb = [3 2 1 1 5 4];\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [3 2 1 6 5];\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 1:5;\r\nb = [3 2 1 1 5 4];\r\n[tf,locb] = isSubset(b,b);\r\nlocb_correct = 1:6;\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [3 7 2 6];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [2 4 6 7];\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [2 1 0 6 0];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [6 1 3 7 8];\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [1 0 7 6 4];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [1 3 4 7 0];\r\n[tf,locb] = isSubset(a,b);\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [1 0 0 6 0 2 0];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [1 3 8 7 0 6 0];\r\n[tf,locb] = isSubset(a,b);\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'new test';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [38 3 15 5 6 8 4 30];\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'another one';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [26 38 2 6 7 3 17 5 11 0 8];\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'ChrisR wrote this problem';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [0 7 17 37 4 0 5 15 22 2 6 3 9 30 25 0 34 14 0 27 11 0 47 8 0];\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'Do not kowtow';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [1 2 5 38 11 6 9 18 16 15 30 21 45];\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\nn = randi(100);\r\na1 = ones(1,n-1); \r\na2 = ones(1,n+1);\r\nb  = ones(1,n);\r\n[tf1,locb1] = isSubset(a1,b);\r\n[tf2,locb2] = isSubset(a2,b);\r\nassert(tf1 \u0026\u0026 isequal(locb1,1:n-1))\r\nassert(~tf2 \u0026\u0026 isequal(locb2,[1:n 0]))\r\n\r\n%%\r\na = 1:randi(50);\r\nb = randperm(50);\r\n[~,ib] = sort(b);\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isequal(locb,ib(1:length(a))))\r\n\r\n%%\r\nfiletext = fileread('isSubset.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2022-07-18T03:14:24.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2022-07-18T03:14:24.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-18T03:11:39.000Z","updated_at":"2026-03-11T08:16:38.000Z","published_at":"2022-07-18T03:12:14.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhile bumbling through a pair of problems in the \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/groups/2001\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eNumber Theory group\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, I wrote code to determine whether a vector is a subset of another vector. I thought the function \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eismember\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e might work, but it does not account for repeated elements in a way necessary to check for a subset. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = [1 2 1 3 3] and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = [3 2 1 1 5 4], \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[lia, locb] = ismember(a,b)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elia = [1 1 1 1 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elocb = [3 2 3 1 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. In other words, the first vector indicates whether each element in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e appears in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e at least once, and the second vector gives the index of the \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efirst occurrence \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eof the element of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. The command \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eall(lia)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e would return \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etrue\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, but \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is not a subset of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to determine whether one vector is a subset of another. The function will return two arguments: a logical \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that indicates whether \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is a subset of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a vector \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elocb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that gives unique indices into \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e where the elements of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e occur. For repeating elements, the indices should increase, and for elements of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e not in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, return zero. For the example of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e above, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efalse\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elocb = [3 2 4 1 0]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eI could not find either a MATLAB function or Cody problem that addresses this task, but I would not be too surprised if there is an elegant or built-in solution that I missed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2248,"title":"Bell Number calculator","description":"Calculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the Wikipedia entry for Bell Number.\r\nExample\r\n Belln(8) = [1 1 2 5 15 52 203 877 4140]","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 102.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51.2167px; transform-origin: 407px 51.2167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia entry for Bell Number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 160px 8.5px; transform-origin: 160px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Belln(8) = [1 1 2 5 15 52 203 877 4140]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Belln(n)\r\n  y = [1:x];\r\nend","test_suite":"%%\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = [1 1 2 5 15 52];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 10;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975 678570 4213597 27644437];\r\nassert(isequal(Belln(n),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":23893,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":191,"test_suite_updated_at":"2021-06-16T09:39:43.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-03-14T09:59:39.000Z","updated_at":"2026-02-16T10:15:53.000Z","published_at":"2014-03-14T10:09:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia entry for Bell Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Belln(8) = [1 1 2 5 15 52 203 877 4140]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":23,"title":"Finding Perfect Squares","description":"Given a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.\r\nExample:\r\n Input  a = [2 3 4]\r\n Output b is true\r\nOutput is true since 2^2 is 4 and both 2 and 4 appear on the list.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 132.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 66.4333px; transform-origin: 407px 66.4333px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 76px 8.5px; tab-size: 4; transform-origin: 76px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 44px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 44px 8.5px; \"\u003ea = [2 3 4]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 68px 8.5px; tab-size: 4; transform-origin: 68px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003eb is true\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 202px 8px; transform-origin: 202px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOutput is true since 2^2 is 4 and both 2 and 4 appear on the list.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function b = isItSquared(a)\r\n\r\n  b = true;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('isItSquared.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp'); \r\nassert(~illegal)\r\n\r\n%%\r\na = [2 3 4];\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = [20:30];\r\nassert(isequal(isItSquared(a),false))\r\n\r\n%%\r\na = 1;\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = 0;\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = [6 10 12 14 36 101];\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = [6 10 12 14 101];\r\nassert(isequal(isItSquared(a),false))\r\n\r\n%%\r\na = primes(50);\r\nassert(isequal(isItSquared(a),false))\r\n","published":true,"deleted":false,"likes_count":187,"comments_count":51,"created_by":1,"edited_by":223089,"edited_at":"2023-08-21T13:31:52.000Z","deleted_by":null,"deleted_at":null,"solvers_count":21134,"test_suite_updated_at":"2023-08-21T13:31:52.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:20.000Z","updated_at":"2026-04-05T22:21:04.000Z","published_at":"2012-01-18T01:00:20.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  a = [2 3 4]\\n Output b is true]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput is true since 2^2 is 4 and both 2 and 4 appear on the list.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1881,"title":"GJam 2013 China Event: Happy Teams","description":"This Challenge is derived from \u003chttp://code.google.com/codejam/contest/2933486/dashboard#s=p0 GJam 2013 China Bad Horse\u003e. The problem is codified using a cell array of names.\r\n\r\nThe Challenge involves creating two teams with no pair of individuals on either team having a conflict.  The input is a list of pairs of individuals who can not be placed on the same team.  The Challenge is to determine if two teams can be created that do not have any players with conflicts. \r\n\r\n*Input:* conflicted name pairs  (cell array of pairs of names)\r\n\r\n*Output:* TF  (TF=1 if two Good teams are possible, 0 if Happy teams are non-producible)\r\n\r\n*Competition Summary:* Best Time of 9 minutes, 789 out of 1984 correct\r\n\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is derived from \u003ca href = \"http://code.google.com/codejam/contest/2933486/dashboard#s=p0\"\u003eGJam 2013 China Bad Horse\u003c/a\u003e. The problem is codified using a cell array of names.\u003c/p\u003e\u003cp\u003eThe Challenge involves creating two teams with no pair of individuals on either team having a conflict.  The input is a list of pairs of individuals who can not be placed on the same team.  The Challenge is to determine if two teams can be created that do not have any players with conflicts.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e conflicted name pairs  (cell array of pairs of names)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e TF  (TF=1 if two Good teams are possible, 0 if Happy teams are non-producible)\u003c/p\u003e\u003cp\u003e\u003cb\u003eCompetition Summary:\u003c/b\u003e Best Time of 9 minutes, 789 out of 1984 correct\u003c/p\u003e","function_template":"function TF=Make_Teams(names)\r\n% names is an array of cell arrays   \r\n% N columns of {1x2 cell}\r\n TF=0;\r\nend","test_suite":"%%\r\ntic\r\nnames={{'Dead_Bowie' 'Nyssa_Raatko'} {'Animora' 'Lafety_Le_Fei'} {'Animora' 'Mothergod'} {'Animora' 'Nyssa_Raatko'} {'Dead_Bowie' 'Genevieve_Savidge'} {'Dead_Bowie' 'Lafety_Le_Fei'} {'Animora' 'Genevieve_Savidge'} {'Dead_Bowie' 'Mothergod'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mephista' 'New_Wave'} {'Mephista' 'Ursa'} {'Zaladane' 'Mai_Shen'} {'Mephista' 'Mai_Shen'} {'White_Rabbit' 'Hypnota'} {'White_Rabbit' 'New_Wave'} {'Ursa' 'Scandal'} {'Zaladane' 'New_Wave'} {'Ursa' 'Hypnota'} {'Zaladane' 'Scandal'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Spider_Girl' 'Blue_Snowman'} {'Blue_Snowman' 'Roulette'} {'Roulette' 'Spider_Girl'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Magenta' 'Golden_Glider'} {'Tala' 'Mothergod'} {'The_Lightning' 'Shiv'} {'The_Lightning' 'Prank'} {'Magenta' 'Shiv'} {'Tala' 'Prank'} {'Trinity' 'Golden_Glider'} {'Magenta' 'Prank'} {'The_Lightning' 'Mothergod'} {'Trinity' 'Mothergod'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'The_Lightning' 'Star_Sapphire'} {'Unicron' 'Queen_Of_Fables'} {'Unicron' 'Dead_Bowie'} {'Lady_Quark' 'Fury_Leika'} {'Lady_Quark' 'Star_Sapphire'} {'The_Lightning' 'Dead_Bowie'} {'Asbestos_Lady' 'Queen_Of_Fables'} {'Unicron' 'Lady_Quark'} {'Asbestos_Lady' 'Star_Sapphire'} {'The_Lightning' 'Fury_Leika'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Scandal'} {'Lashina' 'King_Ghidorah'} {'Doctor_Cyber' 'Tala'} {'Lashina' 'Evinlea'} {'Dr_Evil' 'Tala'} {'Zaladane' 'King_Ghidorah'} {'Doctor_Cyber' 'Evinlea'} {'Doctor_Cyber' 'King_Ghidorah'} {'Dr_Evil' 'Scandal'} {'Lashina' 'Scandal'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Bombshell' 'Rampage'} {'Deuce' 'Ursa'} {'Bombshell' 'Ursa'} {'Lady_Octopus' 'Rampage'} {'Doctor_Cyber' 'Black_Mamba'} {'Deuce' 'Madame_Rouge'} {'Doctor_Cyber' 'Rampage'} {'Lady_Octopus' 'Madame_Rouge'} {'Doctor_Cyber' 'Madame_Rouge'} {'Lady_Octopus' 'Black_Mamba'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Cyborgirl' 'Fury_Leika'} {'Asbestos_Lady' 'Margaret_Love'} {'Amazing_Grace' 'Fury_Leika'} {'Cyborgirl' 'Hypnota'} {'Duela_Dent' 'Amazing_Grace'} {'Duela_Dent' 'Hypnota'} {'Amazing_Grace' 'Margaret_Love'} {'Duela_Dent' 'Mephista'} {'Duela_Dent' 'Fury_Leika'} {'Asbestos_Lady' 'Mephista'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jason_Kreis' 'Poundcakes'} {'Margaret_Love' 'Star_Sapphire'} {'Snapdragon' 'Ingra'} {'Snapdragon' 'Poundcakes'} {'Snapdragon' 'Star_Sapphire'} {'Dead_Bowie' 'Star_Sapphire'} {'Jason_Kreis' 'Ingra'} {'Dead_Bowie' 'Rampage'} {'Dead_Bowie' 'Poundcakes'} {'Margaret_Love' 'Rampage'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lazara' 'Southpaw'} {'Dansen_Macabre' 'Jewelee'} {'Lazara' 'Amazing_Grace'} {'Osira' 'Amazing_Grace'} {'Osira' 'Coachwhip'} {'Coachwhip' 'Princess_Python'} {'Dansen_Macabre' 'Princess_Python'} {'Coachwhip' 'Southpaw'} {'Osira' 'Princess_Python'} {'Osira' 'Jewelee'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lashina' 'Trinity'} {'Lashina' 'Mephista'} {'Lashina' 'Shiv'} {'Lashina' 'Dr_Evil'} {'Lashina' 'Fem_Paragon'} {'Lashina' 'King_Ghidorah'} {'Lashina' 'The_Lightning'} {'Lashina' 'Syndrome'} {'Lashina' 'Margaret_Love'} {'Lashina' 'Lady_Octopus'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lotso' 'Snapdragon'} {'Animora' 'Silver_Swan'} {'Devastation' 'Animora'} {'Snapdragon' 'Devastation'} {'Silver_Swan' 'Lotso'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Spider_Girl' 'Livewire'} {'Jason_Kreis' 'Trinity'} {'Spider_Girl' 'Syndrome'} {'Jason_Kreis' 'Livewire'} {'Harley_Quinn' 'Livewire'} {'Spider_Girl' 'Coachwhip'} {'Lady_Octopus' 'Coachwhip'} {'Lady_Octopus' 'Syndrome'} {'Harley_Quinn' 'Coachwhip'} {'Spider_Girl' 'Trinity'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Swan' 'Windfall'} {'Silver_Swan' 'Poison_Ivy'} {'Lafety_Le_Fei' 'Poison_Ivy'} {'Lafety_Le_Fei' 'Windfall'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Livewire' 'Titania'} {'Livewire' 'Abominatrix'} {'Shiv' 'Ursa'} {'Shiv' 'Abominatrix'} {'Princess_Python' 'Abominatrix'} {'Silk_Fever' 'Abominatrix'} {'Livewire' 'Ursa'} {'Princess_Python' 'Titania'} {'Princess_Python' 'Poundcakes'} {'Silk_Fever' 'Poundcakes'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Fem_Paragon' 'Amy_Madison'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Princess_Python' 'Dr_Evil'} {'Lady_Vic' 'Amy_Madison'} {'Lady_Octopus' 'Ursa'} {'Lafety_Le_Fei' 'Shiv'} {'Princess_Python' 'Amy_Madison'} {'Princess_Python' 'Shiv'} {'Lafety_Le_Fei' 'Ursa'} {'Lafety_Le_Fei' 'Amy_Madison'} {'Lady_Octopus' 'Dr_Evil'} {'Lady_Vic' 'Dr_Evil'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Queen_Of_Fables' 'Magenta'} {'Genevieve_Savidge' 'Magenta'} {'Spider_Girl' 'Black_Mamba'} {'Spider_Girl' 'Lady_Shiva'} {'Jinx' 'Lady_Shiva'} {'Spider_Girl' 'Mist'} {'Genevieve_Savidge' 'Lady_Shiva'} {'Jinx' 'Black_Mamba'} {'Genevieve_Savidge' 'Mist'} {'Queen_Of_Fables' 'Black_Mamba'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Titania' 'Saturn_Queen'} {'Lafety_Le_Fei' 'Saturn_Queen'} {'Lafety_Le_Fei' 'Tigress'} {'Titania' 'Tigress'} {'Golddigger' 'Tigress'} {'Titania' 'Tala'} {'Lafety_Le_Fei' 'Tala'} {'Golddigger' 'Tala'} {'Golddigger' 'Saturn_Queen'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Roulette' 'Livewire'} {'Roulette' 'Mai_Shen'} {'Shiv' 'Bombshell'} {'Ursa' 'Bombshell'} {'Ursa' 'Livewire'} {'Shiv' 'Doctor_Cyber'} {'Roulette' 'Bombshell'} {'Blue_Snowman' 'Mai_Shen'} {'Ursa' 'Doctor_Cyber'} {'Blue_Snowman' 'Livewire'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Duela_Dent'} {'Cyborgirl' 'Lafety_Le_Fei'} {'Cyborgirl' 'Duela_Dent'} {'Black_Mamba' 'Unicron'} {'Lady_Death' 'Duela_Dent'} {'Zaladane' 'Cyborgirl'} {'Cyborgirl' 'Devastation'} {'Lady_Death' 'Lafety_Le_Fei'} {'Black_Mamba' 'Devastation'} {'Zaladane' 'Unicron'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Rad' 'Jason_Kreis'} {'Emerald_Empress' 'Lady_Vic'} {'Rad' 'Magenta'} {'Lagomorph' 'Jason_Kreis'} {'Lagomorph' 'Lady_Vic'} {'Lagomorph' 'Magenta'} {'Lagomorph' 'Lady_Quark'} {'Emerald_Empress' 'Genevieve_Savidge'} {'Lady_Quark' 'Genevieve_Savidge'} {'Lady_Quark' 'Jason_Kreis'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Golden_Glider' 'Lady_Clay'} {'Golden_Glider' 'Titania'} {'Lady_Clay' 'Lashina'} {'Lady_Clay' 'Titania'} {'Black_Mamba' 'Lashina'} {'Lady_Clay' 'Lady_Octopus'} {'Maxima' 'Lady_Octopus'} {'Maxima' 'Titania'} {'Black_Mamba' 'Decay'} {'Golden_Glider' 'Decay'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Princess_Python' 'Fem_Paragon'} {'Abominatrix' 'Fem_Paragon'} {'Lady_Quark' 'Princess_Python'} {'The_Crimson_Ghost' 'Ingra'} {'Abominatrix' 'Jinx'} {'Lady_Quark' 'Rampage'} {'Abominatrix' 'Rampage'} {'Princess_Python' 'Jinx'} {'The_Crimson_Ghost' 'Jinx'} {'Lady_Quark' 'Ingra'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dr_Horrible' 'Ingra'} {'Dr_Horrible' 'Sun_Girl'} {'Prank' 'Duela_Dent'} {'Valentina' 'Duela_Dent'} {'Prank' 'Ingra'} {'Lazara' 'Tigress'} {'Lazara' 'Ingra'} {'Lazara' 'Sun_Girl'} {'Valentina' 'Tigress'} {'Valentina' 'Dr_Horrible'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dansen_Macabre' 'Jewelee'} {'Sun_Girl' 'Jewelee'} {'Lady_Shiva' 'Trinity'} {'Lady_Shiva' 'Ursa'} {'Poison_Ivy' 'Jewelee'} {'Dansen_Macabre' 'Ursa'} {'Poison_Ivy' 'Shimmer'} {'Poison_Ivy' 'Trinity'} {'Sun_Girl' 'Shimmer'} {'Lady_Shiva' 'Jewelee'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Eviless'} {'Superwoman' 'Typhoid_Mary'} {'Zaladane' 'Typhoid_Mary'} {'Zaladane' 'Genevieve_Savidge'} {'Superwoman' 'Eviless'} {'Zaladane' 'Bombshell'} {'Ingra' 'Bombshell'} {'Jinx' 'Genevieve_Savidge'} {'Ingra' 'Genevieve_Savidge'} {'Jinx' 'Eviless'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mai_Shen' 'Decay'} {'Ingra' 'Decay'} {'Mai_Shen' 'Deuce'} {'Ingra' 'Lady_Octopus'} {'Margaret_Love' 'Bombshell'} {'Ingra' 'Deuce'} {'Margaret_Love' 'Decay'} {'Dr_Evil' 'Lady_Octopus'} {'Dr_Evil' 'Bombshell'} {'Margaret_Love' 'Ingra'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dead_Bowie' 'Fake_Thomas_Jefferson'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silk_Fever' 'Snapdragon'} {'Professor_Padraic_Ratigan' 'Maxima'} {'Lady_Shiva' 'Decay'} {'Lady_Shiva' 'Lady_Octopus'} {'Nyssa_Raatko' 'Lady_Octopus'} {'Professor_Padraic_Ratigan' 'Decay'} {'Silk_Fever' 'Maxima'} {'Nyssa_Raatko' 'Decay'} {'Professor_Padraic_Ratigan' 'Lady_Octopus'} {'Lady_Shiva' 'Snapdragon'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Bombshell' 'Trinity'} {'Mothergod' 'Professor_Padraic_Ratigan'} {'Tigress' 'Dr_Horrible'} {'Tigress' 'Princess_Python'} {'Rad' 'Dr_Horrible'} {'Rad' 'Professor_Padraic_Ratigan'} {'Mothergod' 'Trinity'} {'Tigress' 'Trinity'} {'Bombshell' 'Professor_Padraic_Ratigan'} {'Mothergod' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mai_Shen' 'Windfall'} {'Syndrome' 'Queen_Bee'} {'Dr_Horrible' 'Mai_Shen'} {'Windfall' 'Animora'} {'New_Wave' 'Dr_Horrible'} {'Animora' 'Syndrome'} {'Queen_Bee' 'New_Wave'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Evinlea' 'Fake_Thomas_Jefferson'} {'Evinlea' 'Southpaw'} {'Magpie' 'Southpaw'} {'Magpie' 'Jason_Kreis'} {'Mist' 'Southpaw'} {'Tigress' 'Jason_Kreis'} {'Tigress' 'Fake_Thomas_Jefferson'} {'Mist' 'Jason_Kreis'} {'Evinlea' 'Gru'} {'Magpie' 'Gru'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Nyssa_Raatko' 'Shiv'} {'Nyssa_Raatko' 'Queen_Of_Fables'} {'Jewelee' 'The_Lightning'} {'Jinx' 'Shiv'} {'Nyssa_Raatko' 'Rad'} {'Jinx' 'The_Lightning'} {'Nyssa_Raatko' 'The_Lightning'} {'Jewelee' 'Rad'} {'Professor_Padraic_Ratigan' 'Shiv'} {'Professor_Padraic_Ratigan' 'Queen_Of_Fables'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Ingra' 'Sun_Girl'} {'Southpaw' 'Golden_Glider'} {'Superwoman' 'Mothergod'} {'Ingra' 'Tigress'} {'Superwoman' 'Sun_Girl'} {'Southpaw' 'Mothergod'} {'Silk_Fever' 'Tigress'} {'Superwoman' 'Ingra'} {'Ingra' 'Golden_Glider'} {'Silk_Fever' 'Sun_Girl'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mai_Shen' 'Tala'} {'Mai_Shen' 'Abominatrix'} {'Mai_Shen' 'Mothergod'} {'Mai_Shen' 'Ursa'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Princess_Python' 'Abominatrix'} {'Mai_Shen' 'Devastation'} {'Abominatrix' 'Mai_Shen'} {'Devastation' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Shiv' 'Titania'} {'Lady_Quark' 'Trinity'} {'Mothergod' 'Hypnota'} {'Shiv' 'Hypnota'} {'Lady_Quark' 'White_Rabbit'} {'Lady_Octopus' 'Trinity'} {'Shiv' 'Lady_Quark'} {'Mothergod' 'Trinity'} {'Mothergod' 'White_Rabbit'} {'Lady_Octopus' 'Titania'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lazara' 'Queen_Of_Fables'} {'Queen_Bee' 'Magpie'} {'Queen_Bee' 'Rad'} {'Lashina' 'Queen_Of_Fables'} {'Lashina' 'Superwoman'} {'Dead_Bowie' 'Queen_Of_Fables'} {'Lashina' 'Magpie'} {'Queen_Bee' 'Queen_Of_Fables'} {'Dead_Bowie' 'Rad'} {'Lazara' 'Superwoman'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'New_Wave' 'Ingra'} {'Syndrome' 'Princess_Python'} {'New_Wave' 'Sun_Girl'} {'Lashina' 'Ingra'} {'Silk_Fever' 'Ingra'} {'New_Wave' 'Princess_Python'} {'Syndrome' 'Shiv'} {'Lashina' 'Shiv'} {'Lashina' 'Sun_Girl'} {'Silk_Fever' 'Sun_Girl'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Hypnota' 'Sun_Girl'} {'Doctor_Cyber' 'Windfall'} {'Dr_Evil' 'Valentina'} {'Hypnota' 'Abominatrix'} {'Doctor_Cyber' 'Sun_Girl'} {'Mist' 'Windfall'} {'Doctor_Cyber' 'Valentina'} {'Mist' 'Abominatrix'} {'Mist' 'Sun_Girl'} {'Dr_Evil' 'Abominatrix'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Leather' 'King_Ghidorah'} {'Jinx' 'Bombshell'} {'Leather' 'Lady_Vic'} {'Leather' 'Osira'} {'Jewelee' 'Bombshell'} {'Leather' 'Bombshell'} {'Amy_Madison' 'King_Ghidorah'} {'Jinx' 'King_Ghidorah'} {'Jewelee' 'Osira'} {'Amy_Madison' 'Lady_Vic'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Madame_Rouge' 'Ingra'} {'Margaret_Love' 'Ingra'} {'Yellowjacket' 'Dansen_Macabre'} {'Margaret_Love' 'The_Crimson_Ghost'} {'Margaret_Love' 'Rad'} {'Madame_Rouge' 'The_Crimson_Ghost'} {'Yellowjacket' 'Rad'} {'Yellowjacket' 'Ingra'} {'New_Wave' 'Dansen_Macabre'} {'New_Wave' 'The_Crimson_Ghost'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Amy_Madison' 'Typhoid_Mary'} {'Typhoid_Mary' 'The_Crimson_Ghost'} {'Amy_Madison' 'Spider_Girl'} {'Queen_Bee' 'Spider_Girl'} {'Queen_Bee' 'Livewire'} {'Nyssa_Raatko' 'The_Crimson_Ghost'} {'Typhoid_Mary' 'Mothergod'} {'Amy_Madison' 'The_Crimson_Ghost'} {'Typhoid_Mary' 'Livewire'} {'Nyssa_Raatko' 'Mothergod'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Margaret_Love' 'Shimmer'} {'Snapdragon' 'Shimmer'} {'Snapdragon' 'Lady_Octopus'} {'Snapdragon' 'Jewelee'} {'Decay' 'Poundcakes'} {'Amy_Madison' 'Poundcakes'} {'Decay' 'Lady_Octopus'} {'Margaret_Love' 'Lady_Octopus'} {'Decay' 'Jewelee'} {'Amy_Madison' 'Jewelee'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Black_Mamba' 'Purgatori'} {'Talia_Al_Ghul' 'Windfall'} {'Lady_Death' 'Madame_Masque'} {'Spider_Girl' 'Madame_Masque'} {'Black_Mamba' 'Saturn_Queen'} {'Black_Mamba' 'Madame_Masque'} {'Spider_Girl' 'Saturn_Queen'} {'Talia_Al_Ghul' 'Purgatori'} {'Lady_Death' 'Windfall'} {'Spider_Girl' 'Purgatori'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Bombshell' 'Queen_Of_Fables'} {'Silk_Fever' 'Lady_Quark'} {'Windfall' 'Star_Sapphire'} {'Windfall' 'Queen_Of_Fables'} {'Silk_Fever' 'Star_Sapphire'} {'Silk_Fever' 'Bombshell'} {'Shiv' 'Dead_Bowie'} {'Shiv' 'Lady_Quark'} {'Windfall' 'Lady_Quark'} {'Bombshell' 'Dead_Bowie'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Swan' 'Gru'} {'Superwoman' 'Lagomorph'} {'Silver_Swan' 'Duela_Dent'} {'Silver_Swan' 'Superwoman'} {'Superwoman' 'Lady_Vic'} {'Saturn_Queen' 'Lady_Vic'} {'Saturn_Queen' 'Duela_Dent'} {'Poundcakes' 'Lagomorph'} {'Silver_Swan' 'Lady_Vic'} {'Poundcakes' 'Gru'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lady_Vic' 'Queen_Bee'} {'Deuce' 'Yellowjacket'} {'Prank' 'Amazing_Grace'} {'Bombshell' 'Yellowjacket'} {'Deuce' 'Amazing_Grace'} {'Lady_Vic' 'Lady_Death'} {'Deuce' 'Prank'} {'Bombshell' 'Amazing_Grace'} {'Prank' 'Queen_Bee'} {'Deuce' 'Lady_Death'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Maxima' 'Sun_Girl'} {'Spider_Girl' 'Genevieve_Savidge'} {'Spider_Girl' 'Madame_Masque'} {'Fem_Paragon' 'Margaret_Love'} {'Maxima' 'Genevieve_Savidge'} {'Maxima' 'Madame_Masque'} {'Spider_Girl' 'Sun_Girl'} {'Devastation' 'Sun_Girl'} {'Devastation' 'Margaret_Love'} {'Fem_Paragon' 'Madame_Masque'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Tala' 'Animora'} {'Tala' 'Scandal'} {'Tala' 'Amazing_Grace'} {'Tala' 'Lafety_Le_Fei'} {'Tala' 'Lady_Quark'} {'Tala' 'Silver_Banshee'} {'Tala' 'Dansen_Macabre'} {'Tala' 'Jason_Kreis'} {'Tala' 'Cyborgirl'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Fem_Paragon' 'Golddigger'} {'Southpaw' 'Deuce'} {'Southpaw' 'Golddigger'} {'Fem_Paragon' 'Sun_Girl'} {'Rad' 'Sun_Girl'} {'Southpaw' 'Sun_Girl'} {'Rad' 'Lady_Clay'} {'Fem_Paragon' 'Bombshell'} {'Deuce' 'Lady_Clay'} {'Deuce' 'Bombshell'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Poison_Ivy' 'Lady_Octopus'} {'Poison_Ivy' 'Lazara'} {'Lazara' 'Lagomorph'} {'Poison_Ivy' 'Tala'} {'Mephista' 'Lagomorph'} {'Mai_Shen' 'Lagomorph'} {'Mephista' 'Tala'} {'Mai_Shen' 'Lady_Octopus'} {'Mephista' 'Lady_Death'} {'Lazara' 'Lady_Death'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Professor_Padraic_Ratigan' 'Superwoman'} {'Professor_Padraic_Ratigan' 'Shiv'} {'Professor_Padraic_Ratigan' 'Amazing_Grace'} {'Amazing_Grace' 'Bombshell'} {'Saturn_Queen' 'Superwoman'} {'Professor_Padraic_Ratigan' 'Bombshell'} {'Tala' 'Shiv'} {'Tala' 'Trinity'} {'Saturn_Queen' 'Bombshell'} {'Amazing_Grace' 'Trinity'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Talia_Al_Ghul'} {'Cyborgirl' 'Snapdragon'} {'Talia_Al_Ghul' 'Cyborgirl'} {'Silver_Banshee' 'Deuce'} {'New_Wave' 'Mist'} {'Osira' 'Lady_Octopus'} {'Lady_Octopus' 'Silver_Banshee'} {'Snapdragon' 'Osira'} {'Mist' 'Zaladane'} {'Deuce' 'New_Wave'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Asbestos_Lady' 'Coachwhip'} {'Asbestos_Lady' 'Jewelee'} {'Asbestos_Lady' 'Shimmer'} {'Lady_Shiva' 'Jewelee'} {'Blue_Snowman' 'Coachwhip'} {'Ingra' 'Coachwhip'} {'Lady_Shiva' 'Ingra'} {'Lady_Shiva' 'Titania'} {'Ingra' 'Shimmer'} {'Blue_Snowman' 'Titania'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Abominatrix' 'Tigress'} {'Queen_Bee' 'Rampage'} {'Unicron' 'Rampage'} {'Lady_Octopus' 'Poundcakes'} {'Unicron' 'Queen_Of_Fables'} {'Abominatrix' 'Queen_Bee'} {'Abominatrix' 'Queen_Of_Fables'} {'Queen_Bee' 'Poundcakes'} {'Lady_Octopus' 'Tigress'} {'Abominatrix' 'Poundcakes'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Scandal' 'Jinx'} {'Scandal' 'Doctor_Cyber'} {'Scandal' 'Roulette'} {'Queen_Bee' 'Jinx'} {'Queen_Bee' 'Roulette'} {'Queen_Bee' 'Yellowjacket'} {'Margaret_Love' 'Yellowjacket'} {'Zaladane' 'Roulette'} {'Margaret_Love' 'Doctor_Cyber'} {'Zaladane' 'Yellowjacket'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lady_Quark' 'Madame_Masque'} {'Coachwhip' 'Lady_Quark'} {'Lady_Clay' 'Coachwhip'} {'Madame_Masque' 'Southpaw'} {'Talia_Al_Ghul' 'Lady_Clay'} {'Southpaw' 'Talia_Al_Ghul'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Evinlea' 'Silver_Banshee'} {'Magenta' 'Amy_Madison'} {'Magenta' 'Fake_Thomas_Jefferson'} {'Deuce' 'Fake_Thomas_Jefferson'} {'Magenta' 'Silver_Banshee'} {'Evinlea' 'Trinity'} {'Cyborgirl' 'Amy_Madison'} {'Cyborgirl' 'Trinity'} {'Evinlea' 'Fake_Thomas_Jefferson'} {'Deuce' 'Silver_Banshee'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jewelee' 'Madame_Rouge'} {'Jewelee' 'Fem_Paragon'} {'Jewelee' 'Professor_Padraic_Ratigan'} {'Jewelee' 'Evinlea'} {'Jewelee' 'Fury_Leika'} {'Jewelee' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Amy_Madison' 'The_Crimson_Ghost'} {'Syndrome' 'Lady_Vic'} {'Syndrome' 'Lady_Quark'} {'Lagomorph' 'Poison_Ivy'} {'Lagomorph' 'Lady_Vic'} {'Shimmer' 'Lady_Quark'} {'Lagomorph' 'The_Crimson_Ghost'} {'Amy_Madison' 'Syndrome'} {'Amy_Madison' 'Poison_Ivy'} {'Shimmer' 'Poison_Ivy'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Swan' 'Purgatori'} {'Nyssa_Raatko' 'Purgatori'} {'Nyssa_Raatko' 'Shimmer'} {'Abominatrix' 'Nyssa_Raatko'} {'Nyssa_Raatko' 'Bombshell'} {'Silver_Swan' 'Bombshell'} {'Abominatrix' 'Duela_Dent'} {'Abominatrix' 'Purgatori'} {'Windfall' 'Duela_Dent'} {'Windfall' 'Shimmer'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Fury_Leika' 'The_Lightning'} {'Amy_Madison' 'The_Lightning'} {'The_Crimson_Ghost' 'Lady_Death'} {'Shimmer' 'Lady_Death'} {'Amy_Madison' 'Queen_Of_Fables'} {'The_Crimson_Ghost' 'Queen_Of_Fables'} {'Fury_Leika' 'Queen_Of_Fables'} {'Amy_Madison' 'Dansen_Macabre'} {'Fury_Leika' 'Dansen_Macabre'} {'Shimmer' 'The_Lightning'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Abominatrix' 'Lady_Shiva'} {'Queen_Clea' 'Fake_Thomas_Jefferson'} {'Abominatrix' 'Hypnota'} {'Jewelee' 'Lady_Shiva'} {'Madame_Masque' 'Lady_Shiva'} {'Jewelee' 'Hypnota'} {'Queen_Clea' 'Hypnota'} {'Madame_Masque' 'Maxima'} {'Jewelee' 'Fake_Thomas_Jefferson'} {'Jewelee' 'Maxima'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Southpaw' 'Silver_Banshee'} {'Animora' 'Professor_Padraic_Ratigan'} {'Dansen_Macabre' 'Jason_Kreis'} {'Valentina' 'Professor_Padraic_Ratigan'} {'Animora' 'Jason_Kreis'} {'Animora' 'Silver_Banshee'} {'Southpaw' 'Professor_Padraic_Ratigan'} {'Dansen_Macabre' 'Titania'} {'Valentina' 'Jason_Kreis'} {'Valentina' 'Titania'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Saturn_Queen' 'Lazara'} {'Decay' 'Magpie'} {'Saturn_Queen' 'Decay'} {'Harley_Quinn' 'Magpie'} {'Bombshell' 'Silver_Banshee'} {'Decay' 'Lazara'} {'Decay' 'Madame_Masque'} {'Saturn_Queen' 'Silver_Banshee'} {'Bombshell' 'Madame_Masque'} {'Harley_Quinn' 'Lazara'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Banshee' 'Osira'} {'Jewelee' 'Dead_Bowie'} {'Scandal' 'Poison_Ivy'} {'Scandal' 'Osira'} {'Shiv' 'Dead_Bowie'} {'Shiv' 'Rad'} {'Silver_Banshee' 'Poison_Ivy'} {'Jewelee' 'Osira'} {'Scandal' 'Shiv'} {'Silver_Banshee' 'Rad'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Scandal' 'Roulette'} {'Poison_Ivy' 'Mephista'} {'Amazing_Grace' 'Spider_Girl'} {'Poison_Ivy' 'Roulette'} {'Scandal' 'Lafety_Le_Fei'} {'Mephista' 'Lafety_Le_Fei'} {'Mephista' 'Spider_Girl'} {'Poison_Ivy' 'Princess_Python'} {'Poison_Ivy' 'Spider_Girl'} {'Amazing_Grace' 'Princess_Python'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dr_Horrible' 'Genevieve_Savidge'} {'Decay' 'Windfall'} {'Dansen_Macabre' 'Princess_Python'} {'Purgatori' 'Windfall'} {'Purgatori' 'Princess_Python'} {'Purgatori' 'Mist'} {'Dr_Horrible' 'Mist'} {'Dansen_Macabre' 'Genevieve_Savidge'} {'Decay' 'Mist'} {'Dr_Horrible' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Typhoid_Mary' 'Margaret_Love'} {'Typhoid_Mary' 'Sun_Girl'} {'Typhoid_Mary' 'Osira'} {'Deuce' 'Fake_Thomas_Jefferson'} {'Fake_Thomas_Jefferson' 'Margaret_Love'} {'Deuce' 'Sun_Girl'} {'Fake_Thomas_Jefferson' 'Tala'} {'Lashina' 'Sun_Girl'} {'Lashina' 'Tala'} {'Deuce' 'Osira'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Golden_Glider' 'Rad'} {'Lashina' 'Mothergod'} {'White_Rabbit' 'Asbestos_Lady'} {'Star_Sapphire' 'White_Rabbit'} {'Lafety_Le_Fei' 'Star_Sapphire'} {'Mothergod' 'Lafety_Le_Fei'} {'Fury_Leika' 'Lashina'} {'Asbestos_Lady' 'Golden_Glider'} {'Rad' 'Fury_Leika'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Coachwhip' 'Abominatrix'} {'Lady_Death' 'Abominatrix'} {'Superwoman' 'Queen_Clea'} {'Coachwhip' 'Queen_Clea'} {'Superwoman' 'Tigress'} {'Coachwhip' 'Silk_Fever'} {'Rad' 'Lady_Death'} {'Rad' 'Tigress'} {'Rad' 'Silk_Fever'} {'Lady_Death' 'Queen_Clea'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Poison_Ivy' 'Leather'} {'Zaladane' 'Star_Sapphire'} {'Ursa' 'Star_Sapphire'} {'Poison_Ivy' 'Ursa'} {'Lady_Death' 'Harley_Quinn'} {'Poison_Ivy' 'Evinlea'} {'Zaladane' 'Evinlea'} {'Ursa' 'Leather'} {'Lady_Death' 'Leather'} {'Poison_Ivy' 'Harley_Quinn'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Margaret_Love' 'Duela_Dent'} {'Margaret_Love' 'Fake_Thomas_Jefferson'} {'Jewelee' 'Jason_Kreis'} {'Lagomorph' 'Jewelee'} {'Lagomorph' 'Fake_Thomas_Jefferson'} {'Lagomorph' 'Duela_Dent'} {'Madame_Masque' 'Jason_Kreis'} {'Jewelee' 'Decay'} {'Margaret_Love' 'Decay'} {'Madame_Masque' 'Fake_Thomas_Jefferson'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jason_Kreis' 'Jewelee'} {'Fury_Leika' 'Queen_Clea'} {'Jason_Kreis' 'Unicron'} {'Fury_Leika' 'Lagomorph'} {'Fury_Leika' 'Jewelee'} {'Abominatrix' 'Lagomorph'} {'Black_Mamba' 'Lagomorph'} {'Black_Mamba' 'Unicron'} {'Abominatrix' 'Queen_Clea'} {'Abominatrix' 'Unicron'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Osira' 'Golden_Glider'} {'Osira' 'Scandal'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Queen_Bee' 'Golden_Glider'} {'Sun_Girl' 'Lady_Vic'} {'Queen_Bee' 'Margaret_Love'} {'Sun_Girl' 'Golden_Glider'} {'Queen_Bee' 'Lady_Vic'} {'Sun_Girl' 'Madame_Masque'} {'Sun_Girl' 'Scandal'} {'Queen_Bee' 'Scandal'} {'Sun_Girl' 'Margaret_Love'} {'Queen_Bee' 'Madame_Masque'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lashina' 'Mothergod'} {'Lashina' 'Devastation'} {'Lashina' 'Decay'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Doctor_Cyber' 'Queen_Clea'} {'Ingra' 'Spider_Girl'} {'Ingra' 'Sun_Girl'} {'Doctor_Cyber' 'Spider_Girl'} {'New_Wave' 'Queen_Clea'} {'Dansen_Macabre' 'Tigress'} {'Dansen_Macabre' 'Spider_Girl'} {'New_Wave' 'Spider_Girl'} {'Doctor_Cyber' 'Sun_Girl'} {'New_Wave' 'Tigress'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Coachwhip' 'Southpaw'} {'Coachwhip' 'The_Crimson_Ghost'} {'Abominatrix' 'The_Crimson_Ghost'} {'Tala' 'Hypnota'} {'Madame_Masque' 'The_Crimson_Ghost'} {'Tala' 'New_Wave'} {'Tala' 'The_Crimson_Ghost'} {'Abominatrix' 'Hypnota'} {'Madame_Masque' 'Southpaw'} {'Coachwhip' 'New_Wave'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Black_Mamba' 'Emerald_Empress'} {'Golddigger' 'Prank'} {'Saturn_Queen' 'Prank'} {'Golddigger' 'Nyssa_Raatko'} {'Black_Mamba' 'Hypnota'} {'Saturn_Queen' 'Nyssa_Raatko'} {'Fury_Leika' 'Nyssa_Raatko'} {'Fury_Leika' 'Prank'} {'Fury_Leika' 'Hypnota'} {'Saturn_Queen' 'Emerald_Empress'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dead_Bowie' 'New_Wave'} {'Dead_Bowie' 'Typhoid_Mary'} {'Queen_Clea' 'Typhoid_Mary'} {'Lotso' 'Lagomorph'} {'Lotso' 'Southpaw'} {'Decay' 'New_Wave'} {'Lotso' 'New_Wave'} {'Dead_Bowie' 'Lotso'} {'Queen_Clea' 'Southpaw'} {'Decay' 'Lagomorph'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Eviless' 'Abominatrix'} {'Prank' 'Shimmer'} {'Rampage' 'Syndrome'} {'Queen_Bee' 'Syndrome'} {'Prank' 'Queen_Clea'} {'Prank' 'Syndrome'} {'Queen_Bee' 'Abominatrix'} {'Eviless' 'Shimmer'} {'Rampage' 'Eviless'} {'Rampage' 'Queen_Clea'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Tala' 'Professor_Padraic_Ratigan'} {'Decay' 'Silver_Swan'} {'Queen_Clea' 'Black_Mamba'} {'Poundcakes' 'King_Ghidorah'} {'Poundcakes' 'Silver_Swan'} {'Poundcakes' 'Tala'} {'Queen_Clea' 'Professor_Padraic_Ratigan'} {'Poundcakes' 'Black_Mamba'} {'Decay' 'King_Ghidorah'} {'Tala' 'Silver_Swan'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Tala' 'Bombshell'} {'Tala' 'Mai_Shen'} {'Tala' 'Madame_Rouge'} {'Tala' 'Spider_Girl'} {'Tala' 'Dr_Horrible'} {'Tala' 'Madame_Masque'} {'Tala' 'Lazara'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Livewire' 'Lady_Clay'} {'Livewire' 'Queen_Clea'} {'New_Wave' 'Queen_Clea'} {'New_Wave' 'Lady_Clay'} {'Livewire' 'Rad'} {'New_Wave' 'Rad'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Plastique' 'Cyborgirl'} {'Plastique' 'Tigress'} {'Plastique' 'Superwoman'} {'Plastique' 'Queen_Of_Fables'} {'Plastique' 'Star_Sapphire'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Professor_Padraic_Ratigan' 'Animora'} {'Princess_Python' 'Shiv'} {'Sun_Girl' 'Typhoid_Mary'} {'New_Wave' 'Animora'} {'Professor_Padraic_Ratigan' 'Lady_Clay'} {'New_Wave' 'Lady_Clay'} {'Sun_Girl' 'Shiv'} {'New_Wave' 'Typhoid_Mary'} {'Princess_Python' 'Lady_Clay'} {'Sun_Girl' 'Animora'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Sun_Girl' 'Golddigger'} {'Jewelee' 'Golddigger'} {'Zaladane' 'Deuce'} {'Sun_Girl' 'Deuce'} {'Mai_Shen' 'Golddigger'} {'Jewelee' 'Lazara'} {'Mai_Shen' 'Lazara'} {'Sun_Girl' 'Lazara'} {'Zaladane' 'Lashina'} {'Jewelee' 'Lashina'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jason_Kreis' 'Amazing_Grace'} {'Maxima' 'Ursa'} {'Queen_Bee' 'Gru'} {'Jason_Kreis' 'Gru'} {'Ursa' 'Lady_Death'} {'Maxima' 'Amazing_Grace'} {'Queen_Bee' 'Tala'} {'Ursa' 'Tala'} {'Jason_Kreis' 'Lady_Death'} {'Maxima' 'Gru'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lagomorph' 'Doctor_Cyber'} {'Mothergod' 'Roulette'} {'Doctor_Cyber' 'Dr_Evil'} {'Roulette' 'Lagomorph'} {'Jewelee' 'Magenta'} {'Fury_Leika' 'Mothergod'} {'Dr_Evil' 'Jewelee'} {'Magenta' 'Fury_Leika'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dead_Bowie' 'Fake_Thomas_Jefferson'} {'Fake_Thomas_Jefferson' 'Fury_Leika'} {'Fury_Leika' 'Dead_Bowie'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Scandal' 'Eviless'} {'Queen_Of_Fables' 'Queen_Bee'} {'Queen_Of_Fables' 'Duela_Dent'} {'Scandal' 'Duela_Dent'} {'Emerald_Empress' 'Eviless'} {'Syndrome' 'Yellowjacket'} {'Syndrome' 'Eviless'} {'Scandal' 'Yellowjacket'} {'Emerald_Empress' 'Queen_Bee'} {'Emerald_Empress' 'Scandal'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lazara' 'Blue_Snowman'} {'Lazara' 'Margaret_Love'} {'Lazara' 'Rad'} {'Lazara' 'Syndrome'} {'Lazara' 'Shiv'} {'Lazara' 'Spider_Girl'} {'Lazara' 'Silver_Swan'} {'Lazara' 'Coachwhip'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Valentina' 'Asbestos_Lady'} {'Valentina' 'Doctor_Cyber'} {'Ingra' 'Doctor_Cyber'} {'Scandal' 'Asbestos_Lady'} {'Ingra' 'Professor_Padraic_Ratigan'} {'Valentina' 'Yellowjacket'} {'Lotso' 'Professor_Padraic_Ratigan'} {'Lotso' 'Yellowjacket'} {'Lotso' 'Asbestos_Lady'} {'Scandal' 'Yellowjacket'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Devastation' 'Hypnota'} {'Purgatori' 'Livewire'} {'Evinlea' 'Hypnota'} {'Evinlea' 'Lazara'} {'Devastation' 'Lazara'} {'Nyssa_Raatko' 'Duela_Dent'} {'Evinlea' 'Livewire'} {'Nyssa_Raatko' 'Hypnota'} {'Purgatori' 'Hypnota'} {'Devastation' 'Duela_Dent'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Shimmer' 'Saturn_Queen'} {'Shimmer' 'Lafety_Le_Fei'} {'Golden_Glider' 'Saturn_Queen'} {'Shimmer' 'Cyborgirl'} {'Poison_Ivy' 'Lafety_Le_Fei'} {'Zaladane' 'Cyborgirl'} {'Golden_Glider' 'Cyborgirl'} {'Poison_Ivy' 'Snapdragon'} {'Golden_Glider' 'Snapdragon'} {'Zaladane' 'Saturn_Queen'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Queen_Of_Fables' 'Lazara'} {'Saturn_Queen' 'Golden_Glider'} {'Queen_Of_Fables' 'Golden_Glider'} {'Fury_Leika' 'Duela_Dent'} {'Dr_Horrible' 'Golden_Glider'} {'Fury_Leika' 'Ingra'} {'Queen_Of_Fables' 'Duela_Dent'} {'Fury_Leika' 'Dr_Horrible'} {'Saturn_Queen' 'Ingra'} {'Dr_Horrible' 'Lazara'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Hypnota' 'Abominatrix'} {'New_Wave' 'Mothergod'} {'Hypnota' 'Mothergod'} {'Harley_Quinn' 'Tigress'} {'Harley_Quinn' 'Hypnota'} {'Lady_Vic' 'Tigress'} {'New_Wave' 'Trinity'} {'New_Wave' 'Abominatrix'} {'Harley_Quinn' 'Trinity'} {'Lady_Vic' 'Abominatrix'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\ntoc\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-18T04:20:57.000Z","updated_at":"2013-09-18T04:34:45.000Z","published_at":"2013-09-18T04:34:45.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is derived from\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/contest/2933486/dashboard#s=p0\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGJam 2013 China Bad Horse\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. The problem is codified using a cell array of names.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Challenge involves creating two teams with no pair of individuals on either team having a conflict. The input is a list of pairs of individuals who can not be placed on the same team. The Challenge is to determine if two teams can be created that do not have any players with conflicts.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e conflicted name pairs (cell array of pairs of names)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e TF (TF=1 if two Good teams are possible, 0 if Happy teams are non-producible)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCompetition Summary:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Best Time of 9 minutes, 789 out of 1984 correct\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":53,"title":"Duplicates","description":"Write a function that accepts a cell array of strings and returns another cell array of strings *with only the duplicates* retained.\n\nExamples:\n\n Input  strs = {'a','b','a'}\n Output dups is 'a'\n\n Input  strs = {'a','b','c'}\n Output dups is Empty cell array: 0-by-1\n","description_html":"\u003cp\u003eWrite a function that accepts a cell array of strings and returns another cell array of strings \u003cb\u003ewith only the duplicates\u003c/b\u003e retained.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input  strs = {'a','b','a'}\n Output dups is 'a'\u003c/pre\u003e\u003cpre\u003e Input  strs = {'a','b','c'}\n Output dups is Empty cell array: 0-by-1\u003c/pre\u003e","function_template":"function dups = duplicates(strs)\n  dups = strs;\nend","test_suite":"%%\nstrs = {'aa','bb','aa','aa'};\ncorrect = {'aa'};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n%%\nstrs = {'10','11','12'};\ncorrect = {};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n%%\nstrs = {'zzz','zzz','zzz'};\ncorrect = {'zzz'};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n\n%%\nstrs = {'a','b','c','b','d','c'};\ncorrect = {'b','c'};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n%%\nstrs = {};\ncorrect = {};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))","published":true,"deleted":false,"likes_count":7,"comments_count":4,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2417,"test_suite_updated_at":"2012-01-18T01:00:24.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:24.000Z","updated_at":"2026-03-03T13:33:26.000Z","published_at":"2012-01-18T01:00:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that accepts a cell array of strings and returns another cell array of strings\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewith only the duplicates\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e retained.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  strs = {'a','b','a'}\\n Output dups is 'a'\\n\\n Input  strs = {'a','b','c'}\\n Output dups is Empty cell array: 0-by-1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":55210,"title":"Determine whether one vector is a subset of another","description":"While bumbling through a pair of problems in the Number Theory group, I wrote code to determine whether a vector is a subset of another vector. I thought the function ismember might work, but it does not account for repeated elements in a way necessary to check for a subset. \r\nFor example, if a = [1 2 1 3 3] and b = [3 2 1 1 5 4], [lia, locb] = ismember(a,b) returns lia = [1 1 1 1 1] and locb = [3 2 3 1 1]. In other words, the first vector indicates whether each element in a appears in b at least once, and the second vector gives the index of the first occurrence of the element of a in b. The command all(lia) would return true, but a is not a subset of b. \r\nWrite a function to determine whether one vector is a subset of another. The function will return two arguments: a logical tf that indicates whether a is a subset of b and a vector locb that gives unique indices into b where the elements of a occur. For repeating elements, the indices should increase, and for elements of a not in b, return zero. For the example of a and b above, tf is false and locb = [3 2 4 1 0]. \r\nI could not find either a MATLAB function or Cody problem that addresses this task, but I would not be too surprised if there is an elegant or built-in solution that I missed.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 300px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 150px; transform-origin: 407px 150px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 152.492px 8px; transform-origin: 152.492px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWhile bumbling through a pair of problems in the \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/groups/2001\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eNumber Theory group\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 151.292px 8px; transform-origin: 151.292px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, I wrote code to determine whether a vector is a subset of another vector. I thought the function \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 30.8px 8px; transform-origin: 30.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eismember\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 195.25px 8px; transform-origin: 195.25px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e might work, but it does not account for repeated elements in a way necessary to check for a subset. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 48.225px 8px; transform-origin: 48.225px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example, if \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 54.6417px 8px; transform-origin: 54.6417px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e = [1 2 1 3 3] and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 48.8px 8px; transform-origin: 48.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e = [3 2 1 1 5 4], \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 103.95px 8px; transform-origin: 103.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003e[lia, locb] = ismember(a,b)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.6667px 8px; transform-origin: 25.6667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e returns \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 65.45px 8px; transform-origin: 65.45px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elia = [1 1 1 1 1]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 69.3px 8px; transform-origin: 69.3px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elocb = [3 2 3 1 1]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 205.75px 8px; transform-origin: 205.75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. In other words, the first vector indicates whether each element in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 36.5667px 8px; transform-origin: 36.5667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e appears in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 59.1167px 8px; transform-origin: 59.1167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e at least once, and the second vector gives the index of the \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 49.7833px 8px; transform-origin: 49.7833px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003efirst occurrence \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 54.0583px 8px; transform-origin: 54.0583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eof the element of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 9.33333px 8px; transform-origin: 9.33333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 50.5583px 8px; transform-origin: 50.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. The command \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 30.8px 8px; transform-origin: 30.8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eall(lia)\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 42.4px 8px; transform-origin: 42.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e would return \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.4px 8px; transform-origin: 15.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003etrue\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.55px 8px; transform-origin: 15.55px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, but \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 56.775px 8px; transform-origin: 56.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is not a subset of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 372.883px 8px; transform-origin: 372.883px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to determine whether one vector is a subset of another. The function will return two arguments: a logical \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 7.7px 8px; transform-origin: 7.7px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003etf\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that indicates whether \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 45.1083px 8px; transform-origin: 45.1083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is a subset of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 42.3917px 8px; transform-origin: 42.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and a vector \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.4px 8px; transform-origin: 15.4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elocb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 93.75px 8px; transform-origin: 93.75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e that gives unique indices into \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 72.7333px 8px; transform-origin: 72.7333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e where the elements of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 22.55px 8px; transform-origin: 22.55px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e occur. For repeating elements, the indices should increase, and for elements of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 21px 8px; transform-origin: 21px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e not in \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 101.892px 8px; transform-origin: 101.892px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, return zero. For the example of \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003ea\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.85px 8px; transform-origin: 3.85px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003eb\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 8px; transform-origin: 1.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e above, \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 7.7px 8px; transform-origin: 7.7px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003etf\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 8.94167px 8px; transform-origin: 8.94167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 19.25px 8px; transform-origin: 19.25px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003efalse\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 69.3px 8px; transform-origin: 69.3px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; \"\u003elocb = [3 2 4 1 0]\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 382.592px 8px; transform-origin: 382.592px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eI could not find either a MATLAB function or Cody problem that addresses this task, but I would not be too surprised if there is an elegant or built-in solution that I missed.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [tf,locb] = isSubset(a,b)\r\n  [lia,locb] = ismember(a,b);\r\n  tf = all(lia);\r\nend","test_suite":"%%\r\na = [1 2 1 3 3];\r\nb = [3 2 1 1 5 4];\r\nlocb_correct = [3 2 4 1 0];\r\n[tf,locb] = isSubset(a,b);\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [];\r\nb = [3 2 1 1 5 4];\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isempty(locb))\r\n\r\n%%\r\na = 1:5;\r\nb = [3 2 1 1 5 4];\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [3 2 1 6 5];\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 1:5;\r\nb = [3 2 1 1 5 4];\r\n[tf,locb] = isSubset(b,b);\r\nlocb_correct = 1:6;\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [3 7 2 6];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [2 4 6 7];\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [2 1 0 6 0];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [6 1 3 7 8];\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [1 0 7 6 4];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [1 3 4 7 0];\r\n[tf,locb] = isSubset(a,b);\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = [1 0 0 6 0 2 0];\r\nb = [1 3 0 7 8 2 6 0];\r\nlocb_correct = [1 3 8 7 0 6 0];\r\n[tf,locb] = isSubset(a,b);\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'new test';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [38 3 15 5 6 8 4 30];\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'another one';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [26 38 2 6 7 3 17 5 11 0 8];\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'ChrisR wrote this problem';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [0 7 17 37 4 0 5 15 22 2 6 3 9 30 25 0 34 14 0 27 11 0 47 8 0];\r\nassert(~tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\na = 'Do not kowtow';\r\nb = 'Does the code work for character strings as well?';\r\n[tf,locb] = isSubset(a,b);\r\nlocb_correct = [1 2 5 38 11 6 9 18 16 15 30 21 45];\r\nassert(tf \u0026\u0026 isequal(locb,locb_correct))\r\n\r\n%%\r\nn = randi(100);\r\na1 = ones(1,n-1); \r\na2 = ones(1,n+1);\r\nb  = ones(1,n);\r\n[tf1,locb1] = isSubset(a1,b);\r\n[tf2,locb2] = isSubset(a2,b);\r\nassert(tf1 \u0026\u0026 isequal(locb1,1:n-1))\r\nassert(~tf2 \u0026\u0026 isequal(locb2,[1:n 0]))\r\n\r\n%%\r\na = 1:randi(50);\r\nb = randperm(50);\r\n[~,ib] = sort(b);\r\n[tf,locb] = isSubset(a,b);\r\nassert(tf \u0026\u0026 isequal(locb,ib(1:length(a))))\r\n\r\n%%\r\nfiletext = fileread('isSubset.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2022-07-18T03:14:24.000Z","deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2022-07-18T03:14:24.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-18T03:11:39.000Z","updated_at":"2026-03-11T08:16:38.000Z","published_at":"2022-07-18T03:12:14.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhile bumbling through a pair of problems in the \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/groups/2001\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eNumber Theory group\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, I wrote code to determine whether a vector is a subset of another vector. I thought the function \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eismember\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e might work, but it does not account for repeated elements in a way necessary to check for a subset. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = [1 2 1 3 3] and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = [3 2 1 1 5 4], \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e[lia, locb] = ismember(a,b)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e returns \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elia = [1 1 1 1 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elocb = [3 2 3 1 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. In other words, the first vector indicates whether each element in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e appears in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e at least once, and the second vector gives the index of the \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efirst occurrence \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eof the element of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. The command \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eall(lia)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e would return \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etrue\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, but \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is not a subset of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to determine whether one vector is a subset of another. The function will return two arguments: a logical \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that indicates whether \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is a subset of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a vector \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elocb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that gives unique indices into \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e where the elements of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e occur. For repeating elements, the indices should increase, and for elements of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e not in \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, return zero. For the example of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e above, \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efalse\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elocb = [3 2 4 1 0]\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eI could not find either a MATLAB function or Cody problem that addresses this task, but I would not be too surprised if there is an elegant or built-in solution that I missed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2248,"title":"Bell Number calculator","description":"Calculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the Wikipedia entry for Bell Number.\r\nExample\r\n Belln(8) = [1 1 2 5 15 52 203 877 4140]","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 102.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51.2167px; transform-origin: 407px 51.2167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia entry for Bell Number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 160px 8.5px; transform-origin: 160px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Belln(8) = [1 1 2 5 15 52 203 877 4140]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Belln(n)\r\n  y = [1:x];\r\nend","test_suite":"%%\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = [1 1 2 5 15 52];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 10;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975 678570 4213597 27644437];\r\nassert(isequal(Belln(n),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":23893,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":191,"test_suite_updated_at":"2021-06-16T09:39:43.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-03-14T09:59:39.000Z","updated_at":"2026-02-16T10:15:53.000Z","published_at":"2014-03-14T10:09:41.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia entry for Bell Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Belln(8) = [1 1 2 5 15 52 203 877 4140]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":23,"title":"Finding Perfect Squares","description":"Given a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.\r\nExample:\r\n Input  a = [2 3 4]\r\n Output b is true\r\nOutput is true since 2^2 is 4 and both 2 and 4 appear on the list.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 132.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 66.4333px; transform-origin: 407px 66.4333px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 76px 8.5px; tab-size: 4; transform-origin: 76px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 44px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 44px 8.5px; \"\u003ea = [2 3 4]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 68px 8.5px; tab-size: 4; transform-origin: 68px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 36px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003eb is true\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 202px 8px; transform-origin: 202px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOutput is true since 2^2 is 4 and both 2 and 4 appear on the list.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function b = isItSquared(a)\r\n\r\n  b = true;\r\n\r\nend","test_suite":"%%\r\nfiletext = fileread('isItSquared.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp'); \r\nassert(~illegal)\r\n\r\n%%\r\na = [2 3 4];\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = [20:30];\r\nassert(isequal(isItSquared(a),false))\r\n\r\n%%\r\na = 1;\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = 0;\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = [6 10 12 14 36 101];\r\nassert(isequal(isItSquared(a),true))\r\n\r\n%%\r\na = [6 10 12 14 101];\r\nassert(isequal(isItSquared(a),false))\r\n\r\n%%\r\na = primes(50);\r\nassert(isequal(isItSquared(a),false))\r\n","published":true,"deleted":false,"likes_count":187,"comments_count":51,"created_by":1,"edited_by":223089,"edited_at":"2023-08-21T13:31:52.000Z","deleted_by":null,"deleted_at":null,"solvers_count":21134,"test_suite_updated_at":"2023-08-21T13:31:52.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:20.000Z","updated_at":"2026-04-05T22:21:04.000Z","published_at":"2012-01-18T01:00:20.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  a = [2 3 4]\\n Output b is true]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput is true since 2^2 is 4 and both 2 and 4 appear on the list.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1881,"title":"GJam 2013 China Event: Happy Teams","description":"This Challenge is derived from \u003chttp://code.google.com/codejam/contest/2933486/dashboard#s=p0 GJam 2013 China Bad Horse\u003e. The problem is codified using a cell array of names.\r\n\r\nThe Challenge involves creating two teams with no pair of individuals on either team having a conflict.  The input is a list of pairs of individuals who can not be placed on the same team.  The Challenge is to determine if two teams can be created that do not have any players with conflicts. \r\n\r\n*Input:* conflicted name pairs  (cell array of pairs of names)\r\n\r\n*Output:* TF  (TF=1 if two Good teams are possible, 0 if Happy teams are non-producible)\r\n\r\n*Competition Summary:* Best Time of 9 minutes, 789 out of 1984 correct\r\n\r\n\r\n","description_html":"\u003cp\u003eThis Challenge is derived from \u003ca href = \"http://code.google.com/codejam/contest/2933486/dashboard#s=p0\"\u003eGJam 2013 China Bad Horse\u003c/a\u003e. The problem is codified using a cell array of names.\u003c/p\u003e\u003cp\u003eThe Challenge involves creating two teams with no pair of individuals on either team having a conflict.  The input is a list of pairs of individuals who can not be placed on the same team.  The Challenge is to determine if two teams can be created that do not have any players with conflicts.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e conflicted name pairs  (cell array of pairs of names)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e TF  (TF=1 if two Good teams are possible, 0 if Happy teams are non-producible)\u003c/p\u003e\u003cp\u003e\u003cb\u003eCompetition Summary:\u003c/b\u003e Best Time of 9 minutes, 789 out of 1984 correct\u003c/p\u003e","function_template":"function TF=Make_Teams(names)\r\n% names is an array of cell arrays   \r\n% N columns of {1x2 cell}\r\n TF=0;\r\nend","test_suite":"%%\r\ntic\r\nnames={{'Dead_Bowie' 'Nyssa_Raatko'} {'Animora' 'Lafety_Le_Fei'} {'Animora' 'Mothergod'} {'Animora' 'Nyssa_Raatko'} {'Dead_Bowie' 'Genevieve_Savidge'} {'Dead_Bowie' 'Lafety_Le_Fei'} {'Animora' 'Genevieve_Savidge'} {'Dead_Bowie' 'Mothergod'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mephista' 'New_Wave'} {'Mephista' 'Ursa'} {'Zaladane' 'Mai_Shen'} {'Mephista' 'Mai_Shen'} {'White_Rabbit' 'Hypnota'} {'White_Rabbit' 'New_Wave'} {'Ursa' 'Scandal'} {'Zaladane' 'New_Wave'} {'Ursa' 'Hypnota'} {'Zaladane' 'Scandal'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Spider_Girl' 'Blue_Snowman'} {'Blue_Snowman' 'Roulette'} {'Roulette' 'Spider_Girl'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Magenta' 'Golden_Glider'} {'Tala' 'Mothergod'} {'The_Lightning' 'Shiv'} {'The_Lightning' 'Prank'} {'Magenta' 'Shiv'} {'Tala' 'Prank'} {'Trinity' 'Golden_Glider'} {'Magenta' 'Prank'} {'The_Lightning' 'Mothergod'} {'Trinity' 'Mothergod'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'The_Lightning' 'Star_Sapphire'} {'Unicron' 'Queen_Of_Fables'} {'Unicron' 'Dead_Bowie'} {'Lady_Quark' 'Fury_Leika'} {'Lady_Quark' 'Star_Sapphire'} {'The_Lightning' 'Dead_Bowie'} {'Asbestos_Lady' 'Queen_Of_Fables'} {'Unicron' 'Lady_Quark'} {'Asbestos_Lady' 'Star_Sapphire'} {'The_Lightning' 'Fury_Leika'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Scandal'} {'Lashina' 'King_Ghidorah'} {'Doctor_Cyber' 'Tala'} {'Lashina' 'Evinlea'} {'Dr_Evil' 'Tala'} {'Zaladane' 'King_Ghidorah'} {'Doctor_Cyber' 'Evinlea'} {'Doctor_Cyber' 'King_Ghidorah'} {'Dr_Evil' 'Scandal'} {'Lashina' 'Scandal'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Bombshell' 'Rampage'} {'Deuce' 'Ursa'} {'Bombshell' 'Ursa'} {'Lady_Octopus' 'Rampage'} {'Doctor_Cyber' 'Black_Mamba'} {'Deuce' 'Madame_Rouge'} {'Doctor_Cyber' 'Rampage'} {'Lady_Octopus' 'Madame_Rouge'} {'Doctor_Cyber' 'Madame_Rouge'} {'Lady_Octopus' 'Black_Mamba'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Cyborgirl' 'Fury_Leika'} {'Asbestos_Lady' 'Margaret_Love'} {'Amazing_Grace' 'Fury_Leika'} {'Cyborgirl' 'Hypnota'} {'Duela_Dent' 'Amazing_Grace'} {'Duela_Dent' 'Hypnota'} {'Amazing_Grace' 'Margaret_Love'} {'Duela_Dent' 'Mephista'} {'Duela_Dent' 'Fury_Leika'} {'Asbestos_Lady' 'Mephista'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jason_Kreis' 'Poundcakes'} {'Margaret_Love' 'Star_Sapphire'} {'Snapdragon' 'Ingra'} {'Snapdragon' 'Poundcakes'} {'Snapdragon' 'Star_Sapphire'} {'Dead_Bowie' 'Star_Sapphire'} {'Jason_Kreis' 'Ingra'} {'Dead_Bowie' 'Rampage'} {'Dead_Bowie' 'Poundcakes'} {'Margaret_Love' 'Rampage'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lazara' 'Southpaw'} {'Dansen_Macabre' 'Jewelee'} {'Lazara' 'Amazing_Grace'} {'Osira' 'Amazing_Grace'} {'Osira' 'Coachwhip'} {'Coachwhip' 'Princess_Python'} {'Dansen_Macabre' 'Princess_Python'} {'Coachwhip' 'Southpaw'} {'Osira' 'Princess_Python'} {'Osira' 'Jewelee'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lashina' 'Trinity'} {'Lashina' 'Mephista'} {'Lashina' 'Shiv'} {'Lashina' 'Dr_Evil'} {'Lashina' 'Fem_Paragon'} {'Lashina' 'King_Ghidorah'} {'Lashina' 'The_Lightning'} {'Lashina' 'Syndrome'} {'Lashina' 'Margaret_Love'} {'Lashina' 'Lady_Octopus'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lotso' 'Snapdragon'} {'Animora' 'Silver_Swan'} {'Devastation' 'Animora'} {'Snapdragon' 'Devastation'} {'Silver_Swan' 'Lotso'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Spider_Girl' 'Livewire'} {'Jason_Kreis' 'Trinity'} {'Spider_Girl' 'Syndrome'} {'Jason_Kreis' 'Livewire'} {'Harley_Quinn' 'Livewire'} {'Spider_Girl' 'Coachwhip'} {'Lady_Octopus' 'Coachwhip'} {'Lady_Octopus' 'Syndrome'} {'Harley_Quinn' 'Coachwhip'} {'Spider_Girl' 'Trinity'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Swan' 'Windfall'} {'Silver_Swan' 'Poison_Ivy'} {'Lafety_Le_Fei' 'Poison_Ivy'} {'Lafety_Le_Fei' 'Windfall'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Livewire' 'Titania'} {'Livewire' 'Abominatrix'} {'Shiv' 'Ursa'} {'Shiv' 'Abominatrix'} {'Princess_Python' 'Abominatrix'} {'Silk_Fever' 'Abominatrix'} {'Livewire' 'Ursa'} {'Princess_Python' 'Titania'} {'Princess_Python' 'Poundcakes'} {'Silk_Fever' 'Poundcakes'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Fem_Paragon' 'Amy_Madison'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Princess_Python' 'Dr_Evil'} {'Lady_Vic' 'Amy_Madison'} {'Lady_Octopus' 'Ursa'} {'Lafety_Le_Fei' 'Shiv'} {'Princess_Python' 'Amy_Madison'} {'Princess_Python' 'Shiv'} {'Lafety_Le_Fei' 'Ursa'} {'Lafety_Le_Fei' 'Amy_Madison'} {'Lady_Octopus' 'Dr_Evil'} {'Lady_Vic' 'Dr_Evil'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Queen_Of_Fables' 'Magenta'} {'Genevieve_Savidge' 'Magenta'} {'Spider_Girl' 'Black_Mamba'} {'Spider_Girl' 'Lady_Shiva'} {'Jinx' 'Lady_Shiva'} {'Spider_Girl' 'Mist'} {'Genevieve_Savidge' 'Lady_Shiva'} {'Jinx' 'Black_Mamba'} {'Genevieve_Savidge' 'Mist'} {'Queen_Of_Fables' 'Black_Mamba'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Titania' 'Saturn_Queen'} {'Lafety_Le_Fei' 'Saturn_Queen'} {'Lafety_Le_Fei' 'Tigress'} {'Titania' 'Tigress'} {'Golddigger' 'Tigress'} {'Titania' 'Tala'} {'Lafety_Le_Fei' 'Tala'} {'Golddigger' 'Tala'} {'Golddigger' 'Saturn_Queen'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Roulette' 'Livewire'} {'Roulette' 'Mai_Shen'} {'Shiv' 'Bombshell'} {'Ursa' 'Bombshell'} {'Ursa' 'Livewire'} {'Shiv' 'Doctor_Cyber'} {'Roulette' 'Bombshell'} {'Blue_Snowman' 'Mai_Shen'} {'Ursa' 'Doctor_Cyber'} {'Blue_Snowman' 'Livewire'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Duela_Dent'} {'Cyborgirl' 'Lafety_Le_Fei'} {'Cyborgirl' 'Duela_Dent'} {'Black_Mamba' 'Unicron'} {'Lady_Death' 'Duela_Dent'} {'Zaladane' 'Cyborgirl'} {'Cyborgirl' 'Devastation'} {'Lady_Death' 'Lafety_Le_Fei'} {'Black_Mamba' 'Devastation'} {'Zaladane' 'Unicron'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Rad' 'Jason_Kreis'} {'Emerald_Empress' 'Lady_Vic'} {'Rad' 'Magenta'} {'Lagomorph' 'Jason_Kreis'} {'Lagomorph' 'Lady_Vic'} {'Lagomorph' 'Magenta'} {'Lagomorph' 'Lady_Quark'} {'Emerald_Empress' 'Genevieve_Savidge'} {'Lady_Quark' 'Genevieve_Savidge'} {'Lady_Quark' 'Jason_Kreis'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Golden_Glider' 'Lady_Clay'} {'Golden_Glider' 'Titania'} {'Lady_Clay' 'Lashina'} {'Lady_Clay' 'Titania'} {'Black_Mamba' 'Lashina'} {'Lady_Clay' 'Lady_Octopus'} {'Maxima' 'Lady_Octopus'} {'Maxima' 'Titania'} {'Black_Mamba' 'Decay'} {'Golden_Glider' 'Decay'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Princess_Python' 'Fem_Paragon'} {'Abominatrix' 'Fem_Paragon'} {'Lady_Quark' 'Princess_Python'} {'The_Crimson_Ghost' 'Ingra'} {'Abominatrix' 'Jinx'} {'Lady_Quark' 'Rampage'} {'Abominatrix' 'Rampage'} {'Princess_Python' 'Jinx'} {'The_Crimson_Ghost' 'Jinx'} {'Lady_Quark' 'Ingra'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dr_Horrible' 'Ingra'} {'Dr_Horrible' 'Sun_Girl'} {'Prank' 'Duela_Dent'} {'Valentina' 'Duela_Dent'} {'Prank' 'Ingra'} {'Lazara' 'Tigress'} {'Lazara' 'Ingra'} {'Lazara' 'Sun_Girl'} {'Valentina' 'Tigress'} {'Valentina' 'Dr_Horrible'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dansen_Macabre' 'Jewelee'} {'Sun_Girl' 'Jewelee'} {'Lady_Shiva' 'Trinity'} {'Lady_Shiva' 'Ursa'} {'Poison_Ivy' 'Jewelee'} {'Dansen_Macabre' 'Ursa'} {'Poison_Ivy' 'Shimmer'} {'Poison_Ivy' 'Trinity'} {'Sun_Girl' 'Shimmer'} {'Lady_Shiva' 'Jewelee'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Eviless'} {'Superwoman' 'Typhoid_Mary'} {'Zaladane' 'Typhoid_Mary'} {'Zaladane' 'Genevieve_Savidge'} {'Superwoman' 'Eviless'} {'Zaladane' 'Bombshell'} {'Ingra' 'Bombshell'} {'Jinx' 'Genevieve_Savidge'} {'Ingra' 'Genevieve_Savidge'} {'Jinx' 'Eviless'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mai_Shen' 'Decay'} {'Ingra' 'Decay'} {'Mai_Shen' 'Deuce'} {'Ingra' 'Lady_Octopus'} {'Margaret_Love' 'Bombshell'} {'Ingra' 'Deuce'} {'Margaret_Love' 'Decay'} {'Dr_Evil' 'Lady_Octopus'} {'Dr_Evil' 'Bombshell'} {'Margaret_Love' 'Ingra'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dead_Bowie' 'Fake_Thomas_Jefferson'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silk_Fever' 'Snapdragon'} {'Professor_Padraic_Ratigan' 'Maxima'} {'Lady_Shiva' 'Decay'} {'Lady_Shiva' 'Lady_Octopus'} {'Nyssa_Raatko' 'Lady_Octopus'} {'Professor_Padraic_Ratigan' 'Decay'} {'Silk_Fever' 'Maxima'} {'Nyssa_Raatko' 'Decay'} {'Professor_Padraic_Ratigan' 'Lady_Octopus'} {'Lady_Shiva' 'Snapdragon'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Bombshell' 'Trinity'} {'Mothergod' 'Professor_Padraic_Ratigan'} {'Tigress' 'Dr_Horrible'} {'Tigress' 'Princess_Python'} {'Rad' 'Dr_Horrible'} {'Rad' 'Professor_Padraic_Ratigan'} {'Mothergod' 'Trinity'} {'Tigress' 'Trinity'} {'Bombshell' 'Professor_Padraic_Ratigan'} {'Mothergod' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mai_Shen' 'Windfall'} {'Syndrome' 'Queen_Bee'} {'Dr_Horrible' 'Mai_Shen'} {'Windfall' 'Animora'} {'New_Wave' 'Dr_Horrible'} {'Animora' 'Syndrome'} {'Queen_Bee' 'New_Wave'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Evinlea' 'Fake_Thomas_Jefferson'} {'Evinlea' 'Southpaw'} {'Magpie' 'Southpaw'} {'Magpie' 'Jason_Kreis'} {'Mist' 'Southpaw'} {'Tigress' 'Jason_Kreis'} {'Tigress' 'Fake_Thomas_Jefferson'} {'Mist' 'Jason_Kreis'} {'Evinlea' 'Gru'} {'Magpie' 'Gru'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Nyssa_Raatko' 'Shiv'} {'Nyssa_Raatko' 'Queen_Of_Fables'} {'Jewelee' 'The_Lightning'} {'Jinx' 'Shiv'} {'Nyssa_Raatko' 'Rad'} {'Jinx' 'The_Lightning'} {'Nyssa_Raatko' 'The_Lightning'} {'Jewelee' 'Rad'} {'Professor_Padraic_Ratigan' 'Shiv'} {'Professor_Padraic_Ratigan' 'Queen_Of_Fables'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Ingra' 'Sun_Girl'} {'Southpaw' 'Golden_Glider'} {'Superwoman' 'Mothergod'} {'Ingra' 'Tigress'} {'Superwoman' 'Sun_Girl'} {'Southpaw' 'Mothergod'} {'Silk_Fever' 'Tigress'} {'Superwoman' 'Ingra'} {'Ingra' 'Golden_Glider'} {'Silk_Fever' 'Sun_Girl'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Mai_Shen' 'Tala'} {'Mai_Shen' 'Abominatrix'} {'Mai_Shen' 'Mothergod'} {'Mai_Shen' 'Ursa'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Princess_Python' 'Abominatrix'} {'Mai_Shen' 'Devastation'} {'Abominatrix' 'Mai_Shen'} {'Devastation' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Shiv' 'Titania'} {'Lady_Quark' 'Trinity'} {'Mothergod' 'Hypnota'} {'Shiv' 'Hypnota'} {'Lady_Quark' 'White_Rabbit'} {'Lady_Octopus' 'Trinity'} {'Shiv' 'Lady_Quark'} {'Mothergod' 'Trinity'} {'Mothergod' 'White_Rabbit'} {'Lady_Octopus' 'Titania'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lazara' 'Queen_Of_Fables'} {'Queen_Bee' 'Magpie'} {'Queen_Bee' 'Rad'} {'Lashina' 'Queen_Of_Fables'} {'Lashina' 'Superwoman'} {'Dead_Bowie' 'Queen_Of_Fables'} {'Lashina' 'Magpie'} {'Queen_Bee' 'Queen_Of_Fables'} {'Dead_Bowie' 'Rad'} {'Lazara' 'Superwoman'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'New_Wave' 'Ingra'} {'Syndrome' 'Princess_Python'} {'New_Wave' 'Sun_Girl'} {'Lashina' 'Ingra'} {'Silk_Fever' 'Ingra'} {'New_Wave' 'Princess_Python'} {'Syndrome' 'Shiv'} {'Lashina' 'Shiv'} {'Lashina' 'Sun_Girl'} {'Silk_Fever' 'Sun_Girl'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Hypnota' 'Sun_Girl'} {'Doctor_Cyber' 'Windfall'} {'Dr_Evil' 'Valentina'} {'Hypnota' 'Abominatrix'} {'Doctor_Cyber' 'Sun_Girl'} {'Mist' 'Windfall'} {'Doctor_Cyber' 'Valentina'} {'Mist' 'Abominatrix'} {'Mist' 'Sun_Girl'} {'Dr_Evil' 'Abominatrix'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Leather' 'King_Ghidorah'} {'Jinx' 'Bombshell'} {'Leather' 'Lady_Vic'} {'Leather' 'Osira'} {'Jewelee' 'Bombshell'} {'Leather' 'Bombshell'} {'Amy_Madison' 'King_Ghidorah'} {'Jinx' 'King_Ghidorah'} {'Jewelee' 'Osira'} {'Amy_Madison' 'Lady_Vic'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Madame_Rouge' 'Ingra'} {'Margaret_Love' 'Ingra'} {'Yellowjacket' 'Dansen_Macabre'} {'Margaret_Love' 'The_Crimson_Ghost'} {'Margaret_Love' 'Rad'} {'Madame_Rouge' 'The_Crimson_Ghost'} {'Yellowjacket' 'Rad'} {'Yellowjacket' 'Ingra'} {'New_Wave' 'Dansen_Macabre'} {'New_Wave' 'The_Crimson_Ghost'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Amy_Madison' 'Typhoid_Mary'} {'Typhoid_Mary' 'The_Crimson_Ghost'} {'Amy_Madison' 'Spider_Girl'} {'Queen_Bee' 'Spider_Girl'} {'Queen_Bee' 'Livewire'} {'Nyssa_Raatko' 'The_Crimson_Ghost'} {'Typhoid_Mary' 'Mothergod'} {'Amy_Madison' 'The_Crimson_Ghost'} {'Typhoid_Mary' 'Livewire'} {'Nyssa_Raatko' 'Mothergod'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Margaret_Love' 'Shimmer'} {'Snapdragon' 'Shimmer'} {'Snapdragon' 'Lady_Octopus'} {'Snapdragon' 'Jewelee'} {'Decay' 'Poundcakes'} {'Amy_Madison' 'Poundcakes'} {'Decay' 'Lady_Octopus'} {'Margaret_Love' 'Lady_Octopus'} {'Decay' 'Jewelee'} {'Amy_Madison' 'Jewelee'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Black_Mamba' 'Purgatori'} {'Talia_Al_Ghul' 'Windfall'} {'Lady_Death' 'Madame_Masque'} {'Spider_Girl' 'Madame_Masque'} {'Black_Mamba' 'Saturn_Queen'} {'Black_Mamba' 'Madame_Masque'} {'Spider_Girl' 'Saturn_Queen'} {'Talia_Al_Ghul' 'Purgatori'} {'Lady_Death' 'Windfall'} {'Spider_Girl' 'Purgatori'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Bombshell' 'Queen_Of_Fables'} {'Silk_Fever' 'Lady_Quark'} {'Windfall' 'Star_Sapphire'} {'Windfall' 'Queen_Of_Fables'} {'Silk_Fever' 'Star_Sapphire'} {'Silk_Fever' 'Bombshell'} {'Shiv' 'Dead_Bowie'} {'Shiv' 'Lady_Quark'} {'Windfall' 'Lady_Quark'} {'Bombshell' 'Dead_Bowie'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Swan' 'Gru'} {'Superwoman' 'Lagomorph'} {'Silver_Swan' 'Duela_Dent'} {'Silver_Swan' 'Superwoman'} {'Superwoman' 'Lady_Vic'} {'Saturn_Queen' 'Lady_Vic'} {'Saturn_Queen' 'Duela_Dent'} {'Poundcakes' 'Lagomorph'} {'Silver_Swan' 'Lady_Vic'} {'Poundcakes' 'Gru'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lady_Vic' 'Queen_Bee'} {'Deuce' 'Yellowjacket'} {'Prank' 'Amazing_Grace'} {'Bombshell' 'Yellowjacket'} {'Deuce' 'Amazing_Grace'} {'Lady_Vic' 'Lady_Death'} {'Deuce' 'Prank'} {'Bombshell' 'Amazing_Grace'} {'Prank' 'Queen_Bee'} {'Deuce' 'Lady_Death'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Maxima' 'Sun_Girl'} {'Spider_Girl' 'Genevieve_Savidge'} {'Spider_Girl' 'Madame_Masque'} {'Fem_Paragon' 'Margaret_Love'} {'Maxima' 'Genevieve_Savidge'} {'Maxima' 'Madame_Masque'} {'Spider_Girl' 'Sun_Girl'} {'Devastation' 'Sun_Girl'} {'Devastation' 'Margaret_Love'} {'Fem_Paragon' 'Madame_Masque'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Tala' 'Animora'} {'Tala' 'Scandal'} {'Tala' 'Amazing_Grace'} {'Tala' 'Lafety_Le_Fei'} {'Tala' 'Lady_Quark'} {'Tala' 'Silver_Banshee'} {'Tala' 'Dansen_Macabre'} {'Tala' 'Jason_Kreis'} {'Tala' 'Cyborgirl'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Fem_Paragon' 'Golddigger'} {'Southpaw' 'Deuce'} {'Southpaw' 'Golddigger'} {'Fem_Paragon' 'Sun_Girl'} {'Rad' 'Sun_Girl'} {'Southpaw' 'Sun_Girl'} {'Rad' 'Lady_Clay'} {'Fem_Paragon' 'Bombshell'} {'Deuce' 'Lady_Clay'} {'Deuce' 'Bombshell'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Poison_Ivy' 'Lady_Octopus'} {'Poison_Ivy' 'Lazara'} {'Lazara' 'Lagomorph'} {'Poison_Ivy' 'Tala'} {'Mephista' 'Lagomorph'} {'Mai_Shen' 'Lagomorph'} {'Mephista' 'Tala'} {'Mai_Shen' 'Lady_Octopus'} {'Mephista' 'Lady_Death'} {'Lazara' 'Lady_Death'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Professor_Padraic_Ratigan' 'Superwoman'} {'Professor_Padraic_Ratigan' 'Shiv'} {'Professor_Padraic_Ratigan' 'Amazing_Grace'} {'Amazing_Grace' 'Bombshell'} {'Saturn_Queen' 'Superwoman'} {'Professor_Padraic_Ratigan' 'Bombshell'} {'Tala' 'Shiv'} {'Tala' 'Trinity'} {'Saturn_Queen' 'Bombshell'} {'Amazing_Grace' 'Trinity'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Zaladane' 'Talia_Al_Ghul'} {'Cyborgirl' 'Snapdragon'} {'Talia_Al_Ghul' 'Cyborgirl'} {'Silver_Banshee' 'Deuce'} {'New_Wave' 'Mist'} {'Osira' 'Lady_Octopus'} {'Lady_Octopus' 'Silver_Banshee'} {'Snapdragon' 'Osira'} {'Mist' 'Zaladane'} {'Deuce' 'New_Wave'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Asbestos_Lady' 'Coachwhip'} {'Asbestos_Lady' 'Jewelee'} {'Asbestos_Lady' 'Shimmer'} {'Lady_Shiva' 'Jewelee'} {'Blue_Snowman' 'Coachwhip'} {'Ingra' 'Coachwhip'} {'Lady_Shiva' 'Ingra'} {'Lady_Shiva' 'Titania'} {'Ingra' 'Shimmer'} {'Blue_Snowman' 'Titania'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Abominatrix' 'Tigress'} {'Queen_Bee' 'Rampage'} {'Unicron' 'Rampage'} {'Lady_Octopus' 'Poundcakes'} {'Unicron' 'Queen_Of_Fables'} {'Abominatrix' 'Queen_Bee'} {'Abominatrix' 'Queen_Of_Fables'} {'Queen_Bee' 'Poundcakes'} {'Lady_Octopus' 'Tigress'} {'Abominatrix' 'Poundcakes'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Scandal' 'Jinx'} {'Scandal' 'Doctor_Cyber'} {'Scandal' 'Roulette'} {'Queen_Bee' 'Jinx'} {'Queen_Bee' 'Roulette'} {'Queen_Bee' 'Yellowjacket'} {'Margaret_Love' 'Yellowjacket'} {'Zaladane' 'Roulette'} {'Margaret_Love' 'Doctor_Cyber'} {'Zaladane' 'Yellowjacket'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lady_Quark' 'Madame_Masque'} {'Coachwhip' 'Lady_Quark'} {'Lady_Clay' 'Coachwhip'} {'Madame_Masque' 'Southpaw'} {'Talia_Al_Ghul' 'Lady_Clay'} {'Southpaw' 'Talia_Al_Ghul'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Evinlea' 'Silver_Banshee'} {'Magenta' 'Amy_Madison'} {'Magenta' 'Fake_Thomas_Jefferson'} {'Deuce' 'Fake_Thomas_Jefferson'} {'Magenta' 'Silver_Banshee'} {'Evinlea' 'Trinity'} {'Cyborgirl' 'Amy_Madison'} {'Cyborgirl' 'Trinity'} {'Evinlea' 'Fake_Thomas_Jefferson'} {'Deuce' 'Silver_Banshee'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jewelee' 'Madame_Rouge'} {'Jewelee' 'Fem_Paragon'} {'Jewelee' 'Professor_Padraic_Ratigan'} {'Jewelee' 'Evinlea'} {'Jewelee' 'Fury_Leika'} {'Jewelee' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Amy_Madison' 'The_Crimson_Ghost'} {'Syndrome' 'Lady_Vic'} {'Syndrome' 'Lady_Quark'} {'Lagomorph' 'Poison_Ivy'} {'Lagomorph' 'Lady_Vic'} {'Shimmer' 'Lady_Quark'} {'Lagomorph' 'The_Crimson_Ghost'} {'Amy_Madison' 'Syndrome'} {'Amy_Madison' 'Poison_Ivy'} {'Shimmer' 'Poison_Ivy'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Swan' 'Purgatori'} {'Nyssa_Raatko' 'Purgatori'} {'Nyssa_Raatko' 'Shimmer'} {'Abominatrix' 'Nyssa_Raatko'} {'Nyssa_Raatko' 'Bombshell'} {'Silver_Swan' 'Bombshell'} {'Abominatrix' 'Duela_Dent'} {'Abominatrix' 'Purgatori'} {'Windfall' 'Duela_Dent'} {'Windfall' 'Shimmer'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Fury_Leika' 'The_Lightning'} {'Amy_Madison' 'The_Lightning'} {'The_Crimson_Ghost' 'Lady_Death'} {'Shimmer' 'Lady_Death'} {'Amy_Madison' 'Queen_Of_Fables'} {'The_Crimson_Ghost' 'Queen_Of_Fables'} {'Fury_Leika' 'Queen_Of_Fables'} {'Amy_Madison' 'Dansen_Macabre'} {'Fury_Leika' 'Dansen_Macabre'} {'Shimmer' 'The_Lightning'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Abominatrix' 'Lady_Shiva'} {'Queen_Clea' 'Fake_Thomas_Jefferson'} {'Abominatrix' 'Hypnota'} {'Jewelee' 'Lady_Shiva'} {'Madame_Masque' 'Lady_Shiva'} {'Jewelee' 'Hypnota'} {'Queen_Clea' 'Hypnota'} {'Madame_Masque' 'Maxima'} {'Jewelee' 'Fake_Thomas_Jefferson'} {'Jewelee' 'Maxima'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Southpaw' 'Silver_Banshee'} {'Animora' 'Professor_Padraic_Ratigan'} {'Dansen_Macabre' 'Jason_Kreis'} {'Valentina' 'Professor_Padraic_Ratigan'} {'Animora' 'Jason_Kreis'} {'Animora' 'Silver_Banshee'} {'Southpaw' 'Professor_Padraic_Ratigan'} {'Dansen_Macabre' 'Titania'} {'Valentina' 'Jason_Kreis'} {'Valentina' 'Titania'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Saturn_Queen' 'Lazara'} {'Decay' 'Magpie'} {'Saturn_Queen' 'Decay'} {'Harley_Quinn' 'Magpie'} {'Bombshell' 'Silver_Banshee'} {'Decay' 'Lazara'} {'Decay' 'Madame_Masque'} {'Saturn_Queen' 'Silver_Banshee'} {'Bombshell' 'Madame_Masque'} {'Harley_Quinn' 'Lazara'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Silver_Banshee' 'Osira'} {'Jewelee' 'Dead_Bowie'} {'Scandal' 'Poison_Ivy'} {'Scandal' 'Osira'} {'Shiv' 'Dead_Bowie'} {'Shiv' 'Rad'} {'Silver_Banshee' 'Poison_Ivy'} {'Jewelee' 'Osira'} {'Scandal' 'Shiv'} {'Silver_Banshee' 'Rad'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Scandal' 'Roulette'} {'Poison_Ivy' 'Mephista'} {'Amazing_Grace' 'Spider_Girl'} {'Poison_Ivy' 'Roulette'} {'Scandal' 'Lafety_Le_Fei'} {'Mephista' 'Lafety_Le_Fei'} {'Mephista' 'Spider_Girl'} {'Poison_Ivy' 'Princess_Python'} {'Poison_Ivy' 'Spider_Girl'} {'Amazing_Grace' 'Princess_Python'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dr_Horrible' 'Genevieve_Savidge'} {'Decay' 'Windfall'} {'Dansen_Macabre' 'Princess_Python'} {'Purgatori' 'Windfall'} {'Purgatori' 'Princess_Python'} {'Purgatori' 'Mist'} {'Dr_Horrible' 'Mist'} {'Dansen_Macabre' 'Genevieve_Savidge'} {'Decay' 'Mist'} {'Dr_Horrible' 'Princess_Python'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Typhoid_Mary' 'Margaret_Love'} {'Typhoid_Mary' 'Sun_Girl'} {'Typhoid_Mary' 'Osira'} {'Deuce' 'Fake_Thomas_Jefferson'} {'Fake_Thomas_Jefferson' 'Margaret_Love'} {'Deuce' 'Sun_Girl'} {'Fake_Thomas_Jefferson' 'Tala'} {'Lashina' 'Sun_Girl'} {'Lashina' 'Tala'} {'Deuce' 'Osira'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Golden_Glider' 'Rad'} {'Lashina' 'Mothergod'} {'White_Rabbit' 'Asbestos_Lady'} {'Star_Sapphire' 'White_Rabbit'} {'Lafety_Le_Fei' 'Star_Sapphire'} {'Mothergod' 'Lafety_Le_Fei'} {'Fury_Leika' 'Lashina'} {'Asbestos_Lady' 'Golden_Glider'} {'Rad' 'Fury_Leika'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Coachwhip' 'Abominatrix'} {'Lady_Death' 'Abominatrix'} {'Superwoman' 'Queen_Clea'} {'Coachwhip' 'Queen_Clea'} {'Superwoman' 'Tigress'} {'Coachwhip' 'Silk_Fever'} {'Rad' 'Lady_Death'} {'Rad' 'Tigress'} {'Rad' 'Silk_Fever'} {'Lady_Death' 'Queen_Clea'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Poison_Ivy' 'Leather'} {'Zaladane' 'Star_Sapphire'} {'Ursa' 'Star_Sapphire'} {'Poison_Ivy' 'Ursa'} {'Lady_Death' 'Harley_Quinn'} {'Poison_Ivy' 'Evinlea'} {'Zaladane' 'Evinlea'} {'Ursa' 'Leather'} {'Lady_Death' 'Leather'} {'Poison_Ivy' 'Harley_Quinn'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Margaret_Love' 'Duela_Dent'} {'Margaret_Love' 'Fake_Thomas_Jefferson'} {'Jewelee' 'Jason_Kreis'} {'Lagomorph' 'Jewelee'} {'Lagomorph' 'Fake_Thomas_Jefferson'} {'Lagomorph' 'Duela_Dent'} {'Madame_Masque' 'Jason_Kreis'} {'Jewelee' 'Decay'} {'Margaret_Love' 'Decay'} {'Madame_Masque' 'Fake_Thomas_Jefferson'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jason_Kreis' 'Jewelee'} {'Fury_Leika' 'Queen_Clea'} {'Jason_Kreis' 'Unicron'} {'Fury_Leika' 'Lagomorph'} {'Fury_Leika' 'Jewelee'} {'Abominatrix' 'Lagomorph'} {'Black_Mamba' 'Lagomorph'} {'Black_Mamba' 'Unicron'} {'Abominatrix' 'Queen_Clea'} {'Abominatrix' 'Unicron'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Osira' 'Golden_Glider'} {'Osira' 'Scandal'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Queen_Bee' 'Golden_Glider'} {'Sun_Girl' 'Lady_Vic'} {'Queen_Bee' 'Margaret_Love'} {'Sun_Girl' 'Golden_Glider'} {'Queen_Bee' 'Lady_Vic'} {'Sun_Girl' 'Madame_Masque'} {'Sun_Girl' 'Scandal'} {'Queen_Bee' 'Scandal'} {'Sun_Girl' 'Margaret_Love'} {'Queen_Bee' 'Madame_Masque'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lashina' 'Mothergod'} {'Lashina' 'Devastation'} {'Lashina' 'Decay'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Doctor_Cyber' 'Queen_Clea'} {'Ingra' 'Spider_Girl'} {'Ingra' 'Sun_Girl'} {'Doctor_Cyber' 'Spider_Girl'} {'New_Wave' 'Queen_Clea'} {'Dansen_Macabre' 'Tigress'} {'Dansen_Macabre' 'Spider_Girl'} {'New_Wave' 'Spider_Girl'} {'Doctor_Cyber' 'Sun_Girl'} {'New_Wave' 'Tigress'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Coachwhip' 'Southpaw'} {'Coachwhip' 'The_Crimson_Ghost'} {'Abominatrix' 'The_Crimson_Ghost'} {'Tala' 'Hypnota'} {'Madame_Masque' 'The_Crimson_Ghost'} {'Tala' 'New_Wave'} {'Tala' 'The_Crimson_Ghost'} {'Abominatrix' 'Hypnota'} {'Madame_Masque' 'Southpaw'} {'Coachwhip' 'New_Wave'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Black_Mamba' 'Emerald_Empress'} {'Golddigger' 'Prank'} {'Saturn_Queen' 'Prank'} {'Golddigger' 'Nyssa_Raatko'} {'Black_Mamba' 'Hypnota'} {'Saturn_Queen' 'Nyssa_Raatko'} {'Fury_Leika' 'Nyssa_Raatko'} {'Fury_Leika' 'Prank'} {'Fury_Leika' 'Hypnota'} {'Saturn_Queen' 'Emerald_Empress'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dead_Bowie' 'New_Wave'} {'Dead_Bowie' 'Typhoid_Mary'} {'Queen_Clea' 'Typhoid_Mary'} {'Lotso' 'Lagomorph'} {'Lotso' 'Southpaw'} {'Decay' 'New_Wave'} {'Lotso' 'New_Wave'} {'Dead_Bowie' 'Lotso'} {'Queen_Clea' 'Southpaw'} {'Decay' 'Lagomorph'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Eviless' 'Abominatrix'} {'Prank' 'Shimmer'} {'Rampage' 'Syndrome'} {'Queen_Bee' 'Syndrome'} {'Prank' 'Queen_Clea'} {'Prank' 'Syndrome'} {'Queen_Bee' 'Abominatrix'} {'Eviless' 'Shimmer'} {'Rampage' 'Eviless'} {'Rampage' 'Queen_Clea'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Tala' 'Professor_Padraic_Ratigan'} {'Decay' 'Silver_Swan'} {'Queen_Clea' 'Black_Mamba'} {'Poundcakes' 'King_Ghidorah'} {'Poundcakes' 'Silver_Swan'} {'Poundcakes' 'Tala'} {'Queen_Clea' 'Professor_Padraic_Ratigan'} {'Poundcakes' 'Black_Mamba'} {'Decay' 'King_Ghidorah'} {'Tala' 'Silver_Swan'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Tala' 'Bombshell'} {'Tala' 'Mai_Shen'} {'Tala' 'Madame_Rouge'} {'Tala' 'Spider_Girl'} {'Tala' 'Dr_Horrible'} {'Tala' 'Madame_Masque'} {'Tala' 'Lazara'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Livewire' 'Lady_Clay'} {'Livewire' 'Queen_Clea'} {'New_Wave' 'Queen_Clea'} {'New_Wave' 'Lady_Clay'} {'Livewire' 'Rad'} {'New_Wave' 'Rad'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Plastique' 'Cyborgirl'} {'Plastique' 'Tigress'} {'Plastique' 'Superwoman'} {'Plastique' 'Queen_Of_Fables'} {'Plastique' 'Star_Sapphire'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Professor_Padraic_Ratigan' 'Animora'} {'Princess_Python' 'Shiv'} {'Sun_Girl' 'Typhoid_Mary'} {'New_Wave' 'Animora'} {'Professor_Padraic_Ratigan' 'Lady_Clay'} {'New_Wave' 'Lady_Clay'} {'Sun_Girl' 'Shiv'} {'New_Wave' 'Typhoid_Mary'} {'Princess_Python' 'Lady_Clay'} {'Sun_Girl' 'Animora'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Sun_Girl' 'Golddigger'} {'Jewelee' 'Golddigger'} {'Zaladane' 'Deuce'} {'Sun_Girl' 'Deuce'} {'Mai_Shen' 'Golddigger'} {'Jewelee' 'Lazara'} {'Mai_Shen' 'Lazara'} {'Sun_Girl' 'Lazara'} {'Zaladane' 'Lashina'} {'Jewelee' 'Lashina'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Jason_Kreis' 'Amazing_Grace'} {'Maxima' 'Ursa'} {'Queen_Bee' 'Gru'} {'Jason_Kreis' 'Gru'} {'Ursa' 'Lady_Death'} {'Maxima' 'Amazing_Grace'} {'Queen_Bee' 'Tala'} {'Ursa' 'Tala'} {'Jason_Kreis' 'Lady_Death'} {'Maxima' 'Gru'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lagomorph' 'Doctor_Cyber'} {'Mothergod' 'Roulette'} {'Doctor_Cyber' 'Dr_Evil'} {'Roulette' 'Lagomorph'} {'Jewelee' 'Magenta'} {'Fury_Leika' 'Mothergod'} {'Dr_Evil' 'Jewelee'} {'Magenta' 'Fury_Leika'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Dead_Bowie' 'Fake_Thomas_Jefferson'} {'Fake_Thomas_Jefferson' 'Fury_Leika'} {'Fury_Leika' 'Dead_Bowie'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Scandal' 'Eviless'} {'Queen_Of_Fables' 'Queen_Bee'} {'Queen_Of_Fables' 'Duela_Dent'} {'Scandal' 'Duela_Dent'} {'Emerald_Empress' 'Eviless'} {'Syndrome' 'Yellowjacket'} {'Syndrome' 'Eviless'} {'Scandal' 'Yellowjacket'} {'Emerald_Empress' 'Queen_Bee'} {'Emerald_Empress' 'Scandal'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Lazara' 'Blue_Snowman'} {'Lazara' 'Margaret_Love'} {'Lazara' 'Rad'} {'Lazara' 'Syndrome'} {'Lazara' 'Shiv'} {'Lazara' 'Spider_Girl'} {'Lazara' 'Silver_Swan'} {'Lazara' 'Coachwhip'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Valentina' 'Asbestos_Lady'} {'Valentina' 'Doctor_Cyber'} {'Ingra' 'Doctor_Cyber'} {'Scandal' 'Asbestos_Lady'} {'Ingra' 'Professor_Padraic_Ratigan'} {'Valentina' 'Yellowjacket'} {'Lotso' 'Professor_Padraic_Ratigan'} {'Lotso' 'Yellowjacket'} {'Lotso' 'Asbestos_Lady'} {'Scandal' 'Yellowjacket'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Devastation' 'Hypnota'} {'Purgatori' 'Livewire'} {'Evinlea' 'Hypnota'} {'Evinlea' 'Lazara'} {'Devastation' 'Lazara'} {'Nyssa_Raatko' 'Duela_Dent'} {'Evinlea' 'Livewire'} {'Nyssa_Raatko' 'Hypnota'} {'Purgatori' 'Hypnota'} {'Devastation' 'Duela_Dent'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Shimmer' 'Saturn_Queen'} {'Shimmer' 'Lafety_Le_Fei'} {'Golden_Glider' 'Saturn_Queen'} {'Shimmer' 'Cyborgirl'} {'Poison_Ivy' 'Lafety_Le_Fei'} {'Zaladane' 'Cyborgirl'} {'Golden_Glider' 'Cyborgirl'} {'Poison_Ivy' 'Snapdragon'} {'Golden_Glider' 'Snapdragon'} {'Zaladane' 'Saturn_Queen'} };\r\nexp=1;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Queen_Of_Fables' 'Lazara'} {'Saturn_Queen' 'Golden_Glider'} {'Queen_Of_Fables' 'Golden_Glider'} {'Fury_Leika' 'Duela_Dent'} {'Dr_Horrible' 'Golden_Glider'} {'Fury_Leika' 'Ingra'} {'Queen_Of_Fables' 'Duela_Dent'} {'Fury_Leika' 'Dr_Horrible'} {'Saturn_Queen' 'Ingra'} {'Dr_Horrible' 'Lazara'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\n%%\r\nnames={{'Hypnota' 'Abominatrix'} {'New_Wave' 'Mothergod'} {'Hypnota' 'Mothergod'} {'Harley_Quinn' 'Tigress'} {'Harley_Quinn' 'Hypnota'} {'Lady_Vic' 'Tigress'} {'New_Wave' 'Trinity'} {'New_Wave' 'Abominatrix'} {'Harley_Quinn' 'Trinity'} {'Lady_Vic' 'Abominatrix'} };\r\nexp=0;\r\nTF=Make_Teams(names);\r\nassert(TF==exp)\r\ntoc\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-18T04:20:57.000Z","updated_at":"2013-09-18T04:34:45.000Z","published_at":"2013-09-18T04:34:45.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is derived from\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://code.google.com/codejam/contest/2933486/dashboard#s=p0\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGJam 2013 China Bad Horse\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. The problem is codified using a cell array of names.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Challenge involves creating two teams with no pair of individuals on either team having a conflict. The input is a list of pairs of individuals who can not be placed on the same team. The Challenge is to determine if two teams can be created that do not have any players with conflicts.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e conflicted name pairs (cell array of pairs of names)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e TF (TF=1 if two Good teams are possible, 0 if Happy teams are non-producible)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCompetition Summary:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e Best Time of 9 minutes, 789 out of 1984 correct\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":53,"title":"Duplicates","description":"Write a function that accepts a cell array of strings and returns another cell array of strings *with only the duplicates* retained.\n\nExamples:\n\n Input  strs = {'a','b','a'}\n Output dups is 'a'\n\n Input  strs = {'a','b','c'}\n Output dups is Empty cell array: 0-by-1\n","description_html":"\u003cp\u003eWrite a function that accepts a cell array of strings and returns another cell array of strings \u003cb\u003ewith only the duplicates\u003c/b\u003e retained.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input  strs = {'a','b','a'}\n Output dups is 'a'\u003c/pre\u003e\u003cpre\u003e Input  strs = {'a','b','c'}\n Output dups is Empty cell array: 0-by-1\u003c/pre\u003e","function_template":"function dups = duplicates(strs)\n  dups = strs;\nend","test_suite":"%%\nstrs = {'aa','bb','aa','aa'};\ncorrect = {'aa'};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n%%\nstrs = {'10','11','12'};\ncorrect = {};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n%%\nstrs = {'zzz','zzz','zzz'};\ncorrect = {'zzz'};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n\n%%\nstrs = {'a','b','c','b','d','c'};\ncorrect = {'b','c'};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))\n\n%%\nstrs = {};\ncorrect = {};\nresult = duplicates(strs);\nassert(isempty(setdiff(result,correct)) \u0026 isempty(setdiff(correct,result)))","published":true,"deleted":false,"likes_count":7,"comments_count":4,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2417,"test_suite_updated_at":"2012-01-18T01:00:24.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:24.000Z","updated_at":"2026-03-03T13:33:26.000Z","published_at":"2012-01-18T01:00:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that accepts a cell array of strings and returns another cell array of strings\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ewith only the duplicates\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e retained.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  strs = {'a','b','a'}\\n Output dups is 'a'\\n\\n Input  strs = {'a','b','c'}\\n Output dups is Empty cell array: 0-by-1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"sets\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"sets\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"sets\"","","\"","sets","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f49e2e082a0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f49e2e08200\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f49e2e07940\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f49e2e08520\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f49e2e08480\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f49e2e083e0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f49e2e08340\u003e":"tag:\"sets\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f49e2e08340\u003e":"tag:\"sets\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"sets\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"sets\"","","\"","sets","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f49e2e082a0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f49e2e08200\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f49e2e07940\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f49e2e08520\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f49e2e08480\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f49e2e083e0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f49e2e08340\u003e":"tag:\"sets\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f49e2e08340\u003e":"tag:\"sets\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":55210,"difficulty_rating":"easy"},{"id":2248,"difficulty_rating":"easy-medium"},{"id":23,"difficulty_rating":"medium"},{"id":1881,"difficulty_rating":"medium"},{"id":53,"difficulty_rating":"medium"}]}}