Cody

# Problem 2625. Shorten pathname

Solution 1712532

Submitted on 22 Jan 2019 by Valentin Noël-Youïnou
• Size: 7
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 'C:\foo\bar\baz\qux'; assert(isequal(shorten(x),'C:\..\qux'))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In shorten (line 2) In ScoringEngineTestPoint1 (line 2) In solutionTest (line 3)]

2   Pass
x = 'this\is\just\a\test'; assert(isequal(shorten(x),'this\..\test'))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In shorten (line 2) In ScoringEngineTestPoint2 (line 2) In solutionTest (line 5)]

3   Pass
x = 'testing\testing\123.mat'; assert(isequal(shorten(x),'testing\..\123.mat'))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In shorten (line 2) In ScoringEngineTestPoint3 (line 2) In solutionTest (line 7)]

4   Pass
x = 'testing\t1\t2\t3\t4\t5\t6\t7\t8\t9\t10\123.mat'; assert(isequal(shorten(x),'testing\..\123.mat'))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In shorten (line 2) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)]

5   Pass
x = 'corp.company_name.com\dir1\dir2\dir3\dir4\file'; assert(isequal(shorten(x),'corp.company_name.com\..\file'))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In shorten (line 2) In ScoringEngineTestPoint5 (line 2) In solutionTest (line 11)]

6   Pass
x = 'dir1\dir2\dir3\d.txt'; assert(isequal(shorten(x),'dir1\..\d.txt'))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In shorten (line 2) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)]

7   Pass
x = 'dir1\dir#2\dir_3\dir%4\dir(5)\dir+6\d.txt'; assert(isequal(shorten(x),'dir1\..\d.txt'))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In shorten (line 2) In ScoringEngineTestPoint7 (line 2) In solutionTest (line 15)]