Cody

# Problem 1199. ASCII art

Solution 574303

Submitted on 5 Feb 2015
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   Fail
%% chars=char([32:126,161:255]); bitmap=mean(double(imread('http://www.alfnie.com/software/monobitmap.bmp'))/255,3); bitmap=reshape(bitmap,size(bitmap,1),[],numel(chars)); img=imread('peppers.png'); img=sqrt(mean(double(img)/256,3)); img=img(1:floor(size(img,1)/size(bitmap,1))*size(bitmap,1),1:floor(size(img,2)/size(bitmap,2))*size(bitmap,2)); str=gray2char(img,chars,bitmap) assert(isequal(size(str),[14 36])); [i,loc]=ismember(str,chars); assert(all(all(i))); img=permute(reshape(img,size(bitmap,1),size(img,1)/size(bitmap,1),size(bitmap,2),size(img,2)/size(bitmap,2)),[1,3,2,4]); d=mean(mean(mean(abs(bitmap(:,:,loc)-img(:,:,:)).^2,3),2),1); assert(d<=0.11);

Error: Assertion failed.

2   Pass
%% chars=char([32:126,161:255]); bitmap=mean(double(imread('http://www.alfnie.com/software/monobitmap.bmp'))/255,3); bitmap=reshape(bitmap,size(bitmap,1),[],numel(chars)); img=load('clown.mat'); img=mean(ind2rgb(img.X,img.map),3); img=double(img(ceil(.25:.25:end),ceil(.25:.25:end))).^.25; img=img(1:floor(size(img,1)/size(bitmap,1))*size(bitmap,1),1:floor(size(img,2)/size(bitmap,2))*size(bitmap,2)); str=gray2char(img,chars,bitmap) assert(isequal(size(str),[30 91])); [i,loc]=ismember(str,chars); assert(all(all(i))); img=permute(reshape(img,size(bitmap,1),size(img,1)/size(bitmap,1),size(bitmap,2),size(img,2)/size(bitmap,2)),[1,3,2,4]); d=mean(mean(mean(abs(bitmap(:,:,loc)-img(:,:,:)).^2,3),2),1); assert(d<=0.172);

str = ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯\\ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯/\\ÃÂ\ÃÂÃÂÃÂ\/ÃÂÃÂ\\]\ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯\\\\ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯\ÃÂ¯ÃÂ¯\ÃÂ¯ÃÂ¯ÃÂ¯ÃÂ¯\ÃÂ¯\\ ``.`.ÃÂ·`.ÃÂ·``.`.,,;; `ÃÂ· \/` ``.``;>9ÃÂºÃÂ²` `ÃÂ´ÃÂ°7>/QÃÂ¾jj\/\\;/ÃÂ²;;;;;;;;;;/;;;;;;;; ,``;`ÃÂ·`.````ÃÂ·`;,,,ÃÂ· ; ;/` ```ÃÂ¸ÃÂ¿ÃÂ² ``ÃÂ°ÃÂÃÂÃÂQQ//ÃÂ¹;;;;;;;;/>;;;;;;;;;; ,,``..`,``,,ÃÂ·;;;;;; `; ./`. \; ÃÂ·ÃÂ·.ÃÂ·`ÃÂ·'/ÃÂ§Q\/\;;;;;;;;;;;;;;;;;;/ ;;``;`,,,``,`;;ÃÂ¿///,ÃÂ«,` </ ÃÂ·;/ _ÃÂ¿_`ÃÂ· .ÃÂ·`.,;`;/;\/\;;,;;;;;/\/;;;;;\/ ;,;;;;,,``;``;;;ÃÂ¹ÃÂ°ÃÂ°ÃÂ^^^J;ÃÂ¸ <>ÃÂ·ÃÂ·ÃÂ·`\ÃÂ° ;QQÃÂÃÂ¿ÃÂ¾,ÃÂ·.`ÃÂ·;ÃÂ·;;;;7ÃÂ§\\/;;;;ÃÂ¹/\\/;/;;\// \\;;;ÃÂ¸;,,```,,;;;ÃÂ·` _^`QÃÂ¿,^> ÃÂ·.3/ . ..;;>+``ÃÂ·ÃÂ¨ÃÂÃÂÃÂ¶ÃÂÃÂ% ÃÂ·`;;;;;;;;\</;;;;;;;;;;;;;;// ÃÂ><;;,,;``.',;`;;;` ÃÂ\ÃÂÃÂÃÂV\` `ÃÂ²ÃÂ¿^ ÃÂ·ÃÂ·;;/;/\ÃÂ¿;;;ÃÂ·`ÃÂ¸`jÃÂ¿QÃÂ< ,;\;;;;;;;\//\\\/><<;;;;;;;/ Q\\ÃÂ¿;;,;;,``;;,;;;;ÃÂ¸ ÃÂ³JJJÃÂ¹? ÃÂ\ ;jÃÂ¾ÃÂ¿ÃÂ¿j\\\\/;ÃÂ¿ÃÂ¿ÃÂ¯/\ÃÂ½ÃÂÃÂÃÂ.`..ÃÂ¸,;//;;/;//>;/\ÃÂ³\\/\\/;;/\;;;/ ÃÂ¿ÃÂ§ÃÂ\;;;;;;.`,,,;;;ÃÂ´`` .// ÃÂ¸ÃÂ¿ÃÂ¿ÃÂ§ÃÂ§ÃÂ§ÃÂ§/;``;>^^ÃÂ°ÃÂ°ÃÂ°ÃÂ°7ÃÂÃÂÃÂ§ÃÂ¿;;;;///\///\\/\\//\\//;\>;;//;;;/ Q\>ÃÂ²;```;;,,``ÃÂ¸;ÃÂ·ÃÂ²ÃÂ¸ jÃÂ§`,\ÃÂ¿ÃÂÃÂ§ÃÂ§ÃÂ¿\;`ÃÂ· ÃÂ¸ÃÂ¿ÃÂ¿>ÃÂµqÃÂ¿ÃÂ¿\ÃÂ¿ÃÂ¿ÃÂ7\\\/\ÃÂ¿Q\ÃÂÃÂ§ÃÂ§\\\/\//\ÃÂ¿\//<//;;;;/\ QÃÂ¿/;;ÃÂ²`,;;`;;;`ÃÂ´ `\ÃÂ¸ ;QÃÂ¿\\\\\/ÃÂ²ÃÂ²`ÃÂ´ ÃÂ»ÃÂ«J<ÃÂªÃÂ´ ÃÂ¿ÃÂÃÂÃÂ¿ÃÂ¾QÃÂ¿////ÃÂ¿ÃÂÃÂ§QQQÃÂ§QÃÂ¿QÃÂ¿///ÃÂ¿ÃÂ§ÃÂ\ÃÂ³//;</;;/ ÃÂÃÂ//;;;;;;;;;;` <> ;ÃÂ¿QÃÂQÃÂ§\/>;;`ÃÂ·` ÃÂ´`` gÃÂ¿ÃÂÃÂÃÂÃÂ¾ÃÂQÃÂQÃÂÃÂ§ÃÂ¿ÃÂ§ÃÂÃÂÃÂ§ÃÂ§ÃÂ§ÃÂ§ÃÂÃÂ¿/\\\Q/ÃÂ¿\<//\;;ÃÂ¹;< ÃÂQÃÂ¾ÃÂ¾/\//;>/ÃÂ¿;ÃÂ· ;ÃÂ² .;ÃÂ¿QÃÂ§ÃÂÃÂQ\\;;`ÃÂ¸ÃÂ´ 7ÃÂ§ÃÂÃÂÃÂÃÂQÃÂÃÂQÃÂÃÂ¾QQQÃÂÃÂ§ÃÂÃÂÃÂ\\\ÃÂ¿ÃÂ§ÃÂ¿QÃÂ¾QÃÂ¿\//\//\\/ ÃÂ¾gÃÂQÃÂQQ[QÃÂ¿ÃÂ¾ÃÂ\;/\/\/>;;;;ÃÂ¿\QÃÂ§ÃÂÃÂÃÂÃÂÃÂ¾ÃÂ¿;;;,ÃÂ¸` .....ÃÂ·ÃÂ²ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¿/ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ\\QQQQQÃÂÃÂÃÂÃÂ¿\/\/\\/\ ÃÂÃÂÃÂ¾ÃÂÃÂQÃÂÃÂ¾ÃÂ\\/\/<<//\\//\\\/ÃÂ§ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾Q/;'. ÃÂ· ,ÃÂ¸;ÃÂ¿;///\QÃÂ¾ÃÂ¾ÃÂ¿\//\/\///\ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂÃÂ§ÃÂ§///\\j\ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ/\\ÃÂ¹` `;/\\//\/\\\ÃÂ¿\ÃÂÃÂÃÂÃÂ§ÃÂÃÂÃÂÃÂQQÃÂ¿ÃÂ· .`ÃÂ³7ÃÂÃÂÃÂ§ÃÂÃÂ\\\ÃÂ¿\/J/\/\\/\/ÃÂÃÂÃÂÃÂÃÂÃÂQÃÂ/ÃÂ§/\\//\/ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂ//// ÃÂ·;<///\\\\\\ÃÂ§ÃÂ§ÃÂ§ÃÂ§ÃÂÃÂÃÂÃÂ§ÃÂÃÂÃÂÃÂÃÂÃÂQ. ÃÂ¸ÃÂ¿qgÃÂ¾QQQQQQgQQQQQQQj////\\//ÃÂÃÂÃÂÃÂÃÂQ\\/\\/\\// ÃÂÃÂÃÂÃÂÃÂÃÂ/\\/;ÃÂ¸ÃÂ¸,;//\\\/\\ÃÂ§ÃÂ§QQQÃÂ§ÃÂ§QQÃÂÃÂÃÂÃÂ¾ÃÂ§ÃÂ§\/;ÃÂ°ÃÂ§ÃÂ¿ÃÂ¸>\/7ÃÂ²ÃÂ²ÃÂ°ÃÂ°ÃÂ¯ÃÂ¯ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂgQQ/\\\ÃÂÃÂÃÂQ\ÃÂ§//\\/\//\ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¿\/\/\\//\\\\\\ÃÂ¿QQQQQQÃÂQÃÂÃÂÃÂÃÂÃÂÃÂ¾ÃÂ\//;`;ÃÂ³ÃÂ²` .`,;;;/\\///\\ÃÂÃÂÃÂÃÂÃÂÃÂ¾ÃÂ¾QÃÂÃÂÃÂ¾QÃÂ¾ÃÂ¾///\\//// ÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾\/////\\\ÃÂ¿ÃÂ§ÃÂ§ÃÂ§ÃÂ§QQQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂÃÂQQ//;;ÃÂ·ÃÂ·ÃÂ·ÃÂ·` ÃÂ·.ÃÂ·ÃÂ¸;;;;//\/\\\ÃÂ¿ÃÂ§QÃÂ§ÃÂ§QQÃÂÃÂÃÂÃÂÃÂQÃÂÃÂÃÂÃÂÃÂ§QÃÂ§ÃÂ¿jÃÂ§ÃÂ¿ÃÂ¿/\ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾ÃÂ¿ÃÂ¿\\ÃÂ¿ÃÂ¿ÃÂ§ÃÂ§ÃÂ§ÃÂ§QQQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQQÃÂ¿\;,ÃÂ·````;,;;;;;/////\\ÃÂ§ÃÂ§ÃÂ§ÃÂ§QQÃÂ§QÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¿QÃÂQÃÂ§\ÃÂ¿ÃÂ¿\// ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQQÃÂ§ÃÂ§ÃÂ§QQÃÂÃÂQQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂÃÂÃÂÃÂÃÂÃÂÃÂQQÃÂÃÂÃÂÃÂ¾ÃÂ¿;,,;,;;;;//\//\\\\ÃÂ§QÃÂ§ÃÂÃÂÃÂQQÃÂQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQQÃÂÃÂ\\ÃÂ¿\\/\ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQQQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾//;ÃÂ°ÃÂÃÂQÃÂ¿/;;/\///\ÃÂ¿ÃÂ¿ÃÂ¿ÃÂ§ÃÂ§ÃÂÃÂ§ÃÂ§QQQQQQQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂ§\/ÃÂ§ÃÂ§QQÃÂ§ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾` ÃÂ´``ÃÂ¹ÃÂ°ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂÃÂÃÂÃÂÃÂÃÂÃÂQ\\ÃÂ¿;'ÃÂ°ÃÂÃÂQQj\ÃÂ¿ÃÂ¿ÃÂ§QQQQQÃÂ§ÃÂQÃÂ§ÃÂÃÂÃÂ¾ÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂQÃÂ§ÃÂ§QQÃÂ¿Q ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾ ÃÂ·ÃÂ¸ ``ÃÂ³ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ§\/\\>ÃÂ¿;;ÃÂ°ÃÂÃÂQQÃÂ¿ÃÂ¾ÃÂ¾QQÃÂQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾QQÃÂÃÂ¾QÃÂÃÂQ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂpÃÂ·\/<ÃÂ¿ÃÂ¸ÃÂ¸.`;/\ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ§ÃÂ§QÃÂ¿ÃÂ¿\///\>;/ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ§QÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾ÃÂÃÂÃÂÃÂÃÂÃÂQÃÂ¿ÃÂ¶ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾ÃÂ´\\///ÃÂ¿ÃÂ§ÃÂ¾jQQQj\\ÃÂ¿ÃÂ¿QÃÂ§QQÃÂ§QQQQQQQQQ/////ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ§ÃÂ§ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¶QQQ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ ;\\/\//\\ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ¾ÃÂ§ÃÂ¿///ÃÂ§ÃÂÃÂÃÂÃÂÃÂÃÂÃÂ§\ÃÂ¿ÃÂ§ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ `<//\ÃÂ¿ÃÂ¿QQÃÂ§ÃÂ§ÃÂQÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ§ÃÂ¿;//ÃÂÃÂÃÂÃÂÃÂÃÂ\\\ÃÂ§QÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!