Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 236575

Submitted on 26 Apr 2013 by Marco Castelli

Correct

84Size
Leading solution size is 39.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, log in.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
user_solution = fileread('hexagonal_dots_in_circle.m');
assert(isempty(strfind(user_solution,'regexp')));
assert(isempty(strfind(user_solution,'2str')));
assert(isempty(strfind(user_solution,'str2')));
assert(isempty(strfind(user_solution,'interp')));

                    
2
Pass
 
%%
r = 0;
n_correct = 1;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     1
ans =
     1
3
Pass
 
%%
r = 0.5;
n_correct = 1;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     2
ans =
     1
4
Pass
 
%%
r = 1.5;
n_correct = 7;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     4
ans =
     7
5
Pass
 
%%
r = 1;
n_correct = 7;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     3
ans =
     7
6
Pass
 
%%
r = 2;
n_correct = 19;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     5
ans =
    19
7
Pass
 
%%
r = 2.5;
n_correct = 19;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     6
ans =
    19
8
Pass
 
%%
r = 3;
n_correct = 37;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     7
ans =
    37
9
Pass
 
%%
r = 5;
n_correct = 91;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     8
ans =
    91
10
Pass
 
%%
r = 7.5;
n_correct = 199;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
     9
ans =
   199
11
Pass
 
%%
r = 10;
n_correct = 367;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
    10
ans =
   367
12
Pass
 
%%
r = 15;
n_correct = 823;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
    11
ans =
   823
13
Pass
 
%%
r = 20;
n_correct = 1459;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
    12
ans =
        1459
14
Pass
 
%%
r = 25;
n_correct = 2263;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
    13
ans =
        2263
15
Pass
 
%%
r = 50;
n_correct = 9061;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
    14
ans =
        9061
16
Pass
 
%%
r = 100;
n_correct = 36295;
assert(isequal(hexagonal_dots_in_circle(r),n_correct));
R =
         0
    0.5000
    1.0000
    1.5000
    2.0000
    2.5000
    3.0000
    5.0000
    7.5000
   10.0000
   15.0000
   20.0000
   25.0000
   50.0000
  100.0000
N =
           1
           1
           7
           7
          19
          19
          37
          91
         199
         367
         823
        1459
        2263
        9061
       36295
ans =
    15
ans =
       36295