Jump to content

Longest common prefix: Difference between revisions

→‎version 3: updated program and output to reflect latest task test cases additions
(→‎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:
say LCP('throne', "throne") /*two strings, exactly the same. */
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('') /*just a single null argument. */
say LCP() /*no arguments specified at all. */
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.*/
exit /*stick a fork in it, we're done.*/
Line 564 ⟶ 566:
────────────── string 1: throne
────────────── 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»
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
Line 581 ⟶ 589:
────────────── string 2: suffix
longest common prefix= «null»
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
────────────── number of strings specified: 2
────────────── string 1: foo
────────────── string 2: foobar
longest common prefix= foo
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
────────────── number of strings specified: 4
Cookies help us deliver our services. By using our services, you agree to our use of cookies.