Longest common prefix: Difference between revisions
Content deleted Content added
→version 2: updated program and output to reflect latest task test cases additions. |
→version 3: updated program and output to reflect latest task test cases additions |
||
Line 527: | Line 527: | ||
say LCP('throne', "throne") /*two strings, exactly the same. */ |
say LCP('throne', "throne") /*two strings, exactly the same. */ |
||
say LCP('throne', "dungeon") /*2 completely different strings.*/ |
say LCP('throne', "dungeon") /*2 completely different strings.*/ |
||
say LCP('throne', '', "throne") /*3 strings, middle one is null. */ |
|||
say LCP('cheese') /*just a single cheesy argument. */ |
say LCP('cheese') /*just a single cheesy argument. */ |
||
say LCP('') /*just a single null argument. */ |
say LCP('') /*just a single null argument. */ |
||
say LCP() /*no arguments specified at all. */ |
say LCP() /*no arguments specified at all. */ |
||
say LCP('prefix', "suffix") /*two mostly different strings. */ |
say LCP('prefix', "suffix") /*two mostly different strings. */ |
||
say LCP('foo', "foobar") /*two mostly similar strings. */ |
|||
say LCP('a', "b", 'c', "aaa") /*four strings, mostly different.*/ |
say LCP('a', "b", 'c', "aaa") /*four strings, mostly different.*/ |
||
exit /*stick a fork in it, we're done.*/ |
exit /*stick a fork in it, we're done.*/ |
||
Line 564: | Line 566: | ||
────────────── string 1: throne |
────────────── string 1: throne |
||
────────────── string 2: dungeon |
────────────── string 2: dungeon |
||
longest common prefix= «null» |
|||
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ |
|||
────────────── number of strings specified: 3 |
|||
────────────── string 1: throne |
|||
────────────── string 2: «null» |
|||
────────────── string 3: throne |
|||
longest common prefix= «null» |
longest common prefix= «null» |
||
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ |
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ |
||
Line 581: | Line 589: | ||
────────────── string 2: suffix |
────────────── string 2: suffix |
||
longest common prefix= «null» |
longest common prefix= «null» |
||
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ |
|||
────────────── number of strings specified: 2 |
|||
────────────── string 1: foo |
|||
────────────── string 2: foobar |
|||
longest common prefix= foo |
|||
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ |
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ |
||
────────────── number of strings specified: 4 |
────────────── number of strings specified: 4 |