Cody

# Problem 46009. Pixel density

Solution 2966614

Submitted on 19 Sep 2020 by Alfonso Nieto-Castanon
• Size: 17
• 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
filetext = fileread('ppi.m'); assert(isempty(strfind(filetext, 'eval')), 'Eval forbidden.'); assert(isempty(strfind(filetext, 'regexp')), 'Regexp forbidden.'); assert(isempty(strfind(filetext, '!')), 'Shell commands are forbidden.'); assert(isempty(strfind(filetext, 'mlock')), 'mlock is forbidden.'); assert(isempty(strfind(filetext, 'munlock')), 'munlock is forbidden.');

2   Pass
% tv screen d = 40; % 720p resolution w = 1280; h = 720; y_correct = 36.71; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

3   Pass
% smartphone d = 5.5; % 720p resolution w = 1280; h = 720; y_correct = 267.02; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

4   Pass
% tablet d = 7.5; % 720p resolution w = 1280; h = 720; y_correct = 195.81; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

5   Pass
% monitor d = 17; % 1080p resolution w = 1920; h = 1080; y_correct = 129.58; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

6   Pass
d = 17; % 2K resolution w = 2048; h = 1080; y_correct = 136.19; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

7   Pass
d = 24; % UHD resolution w = 3840; h = 2160; y_correct = 183.57; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

8   Pass
d = 24; % 4K resolution w = 4096; h = 2160; y_correct = 192.94; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

9   Pass
d = 40; % 8K resolution w = 7680; h = 4320; y_correct = 220.29; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

10   Pass
d = 50; % 16K resolution w = 15360; h = 8640; y_correct = 352.46; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

### Community Treasure Hunt

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

Start Hunting!