-
3 Comments
inb4 someone finally does a regex solution...
I agree, this likely can't be reduced further, not without embedding code in a string anyway where it won't count against the size (which admittedly we're already kinda doing here anyway).
A function declaration with one output and two inputs is 7 nodes, a direct function call is 3, and the subscript access is 4. I briefly thought you could perhaps replace the second line of code with another dcall to get a total size of 13, but you can't refer to any variables then, so that's not helpful.
There's other hacks of course, but nothing that I think could be pulled off with just two dcalls. So yeah, this is likely as small as it gets. Well done.
Side note,: Matlab has a dictionary datatype these days, and it will work here without increasing the size since you can use strings as the keys and still do lookups using char arrays. :)
Well, turns out I was wrong; see solution 11642858 (which I'm happy to say still does not use regex).
Suggested Problems
-
10363 Solvers
-
Who knows the last digit of pi?
672 Solvers
-
Create a square matrix of multiples
482 Solvers
-
5357 Solvers
-
1294 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!