{"id":5742,"date":"2014-12-12T10:20:16","date_gmt":"2014-12-12T15:20:16","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=5742"},"modified":"2014-12-12T10:20:16","modified_gmt":"2014-12-12T15:20:16","slug":"obfuscated-matlab-code","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2014\/12\/12\/obfuscated-matlab-code\/","title":{"rendered":"Obfuscated MATLAB Code"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\/contributors\/3208495\">Sean<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48644-growth-yet-another-obfuscated-matlab-code\">Growth - Yet Another Obfuscated MATLAB Code<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/459278\">Hikaru<\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n   <p>This is awesome.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">dbtype <span style=\"color: #A020F0\">growth<\/span><\/pre><pre style=\"font-style:oblique\">\r\n1                                             figure(1)\r\n2     clf,hold on,grid on,view(58,38),feval(@(mm,x)mm(@(O)mm(@(Y,U,V,W,v,nN,NN,Mm,mM,md,Nn)...\r\n3     mm(@(G)mm(Y(G),x,0,0,v(mM(x))),mm(@(L)(@(M)(@(n,p,q,r)mm(mm(@(l,n)l{n},{@()1,@(){mm(Y...\r\n4     (L),                                                                             [25*...\r\n5     v(1.                                                                             \/r*(...\r\n6     n-1)                                              )-   25\/                       2*(r...\r\n7     -1);                                           md((n-1),r)*5                     ^2-(...\r\n8     r-1*                                          1)*5^  2\/  2;0]                    ,[0;...\r\n9     0;1]                           ,[   1;0        ;0    ],   6)                     ,M(n...\r\n10    -1,0                        ,0,v(mM(x)))}            },                          ~(n&gt;...\r\n11    .0)+                       2*~(n  &lt;=  0)))           ))                          ,(@(...\r\n12    d)((        @(   u,n        ,t    ,N   )(            ((    mm   (mm              ((@(...\r\n13    l,n)     l{n}),{(@()mm            (@                    ()(mm(@()Nn(u            (1),...\r\n14    u(2)    ,u(3)  ,(  '*g'           ),                   U,5))  ))  ),(@           ()mm...\r\n15    ((@(     w,    b,   p,            m,    mN   ){(        mm    (@   (A            )Nn(...\r\n16    A(1,           :)                    ,A(2,:),A(3,:            ),                 '-',...\r\n17    W,N^           2*                   0.3,V  ,(  mN(N           \/6                 ))),...\r\n18    [u,(           u+    n*   w)]        ))    ,(   mm            (@   (f   ,T,      S){(...\r\n19    d(u+              n*w,S,T,N-1))            ,(                    d(u+n*w,f(S,n   ,p),...\r\n20    f(T,             n,p),  N   -1))           ,(                   d(u+n  *w  ,f(S  ,n,p...\r\n21    *2),              (f    (T    ,n           ,(   p)*   2)),       N-1   ))    },  (@(r...\r\n22    ,n,p                    )r                    *(Mm(p))-nN(r            ,n        )*NN...\r\n23    (p)+                    (1                   -Mm(p  ))  *n*(           n'        *r))...\r\n24    ,NN(                    m)   *n   -t*         Mm    (m   ),            n*        Mm(m...\r\n25    )+NN                       (m)*t))}),9.8            \/(                           7.14...\r\n26    -N),                      0.1,2  +1  \/10.6          ,-                           .102...\r\n27    +1,(                       @(    r)   [1            *1                           *.32...\r\n28    ,.22                             ,1                                              *.08...\r\n29    ]*r+                             [0                                              ,1,(...\r\n30    .5)]                             *(                                              1-r)...\r\n31    )))}                                                                             ,1+(...\r\n32    N&gt;0))))))))))),@(f)mm(@(g)@(m,n,o,p)mm(f(g(g)),m,n,o,p),@(g)@(m,n,o,p)mm(f(g(g)),m,n,...\r\n33    o,p)),O(0),O(1),O(2),O(3),O(4),O(5),O(6),O(7),O(8),O(9)),(@(I)mm(@(l,m)mm(l{1+(I&gt;2)},...\r\n34    char(m((m(58+I)-46):(m(59+I)-47))+18)),{@(J)J,@str2func},['[O`YS`aWhS1]Z]`ZW\\SEWRbV',...\r\n35    'TZ]]`Q`]aaaW\\Q]aa_`b[]R^Z]b!TSdOZ\/9&gt;GLQTW[^c']))),@feval,9); %% (c) woodrush (2014) ...\r\n<\/pre><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">growth<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/maingrowth\/maingrowth_01.png\"> <p>They look the same!<\/p>\r\n   <p>Hikaru, also provides the technical details about the programming features used.  However, the detail I care about most was\r\n      left out: <i>How long did this take to make?<\/i><\/p>\r\n   <p>It is also a great example of pushing the MATLAB interepreter to its limits.<\/p>\r\n   <p>Maybe some day we can have an obfuscated MATLAB Code Contest, similar to the <a href=\"http:\/\/www.ioccc.org\/\">C one<\/a>.\r\n   <\/p>\r\n   <p>Have a great New Year everyone!<\/p>\r\n   <h3>Comments<a name=\"4\"><\/a><\/h3>\r\n   <p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=5742#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48644-growth-yet-another-obfuscated-matlab-code#comments\">comment<\/a> for Hikaru.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_1ea4cf997e994806a88e8426458f17f0() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='1ea4cf997e994806a88e8426458f17f0 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 1ea4cf997e994806a88e8426458f17f0';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Sean de Wolski';\r\n        copyright = 'Copyright 2014 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_1ea4cf997e994806a88e8426458f17f0()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2015a<br><\/p>\r\n<\/div>\r\n<!--\r\n1ea4cf997e994806a88e8426458f17f0 ##### SOURCE BEGIN #####\r\n%% Obfuscated MATLAB Code\r\n%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/answers\/contributors\/3208495 Sean>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48644-growth-yet-another-obfuscated-matlab-code Growth - Yet Another Obfuscated MATLAB Code> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/459278 Hikaru>.\r\n% \r\n\r\n%% \r\n% This is awesome.  \r\n%\r\n\r\ndbtype growth\r\n\r\n%%\r\n\r\ngrowth\r\n\r\n%%\r\n% They look the same!  \r\n%\r\n% Hikaru, also provides the technical details about the programming\r\n% features used.  However, the detail I care about most was left out: _How\r\n% long did this take to make?_\r\n%\r\n% It is also a great example of pushing the MATLAB interepreter to its\r\n% limits.\r\n%\r\n% Maybe some day we can have an obfuscated MATLAB Code Contest, similar to\r\n% the <http:\/\/www.ioccc.org\/ C one>.\r\n%\r\n% Have a great New Year everyone!\r\n\r\n\r\n%% Comments\r\n% \r\n% Give it a try and let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=5742#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48644-growth-yet-another-obfuscated-matlab-code#comments\r\n% comment> for Hikaru.\r\n%\r\n \r\n\r\n##### SOURCE END ##### 1ea4cf997e994806a88e8426458f17f0\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/maingrowth\/maingrowth_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   \r\n      Sean's pick this week is Growth - Yet Another Obfuscated MATLAB Code by Hikaru.\r\n      \r\n   \r\n   This is awesome.dbtype growth\r\n1           ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2014\/12\/12\/obfuscated-matlab-code\/\">read more >><\/a><\/p>","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5742"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=5742"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5742\/revisions"}],"predecessor-version":[{"id":5744,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5742\/revisions\/5744"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=5742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=5742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=5742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}