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

# Solution 91617

Submitted on 23 May 2012 by James

Correct

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

### Test Suite

Test
Code Input and Output
1
Pass

```%%
n=3;
x=7;
q=2;
y_correct = 1;
assert(isequal(whatdigit(n,x,q),y_correct))
```
```a =
2     1     8     7
```
2
Pass

```%%
n=5;
x=5;
q=3;
y_correct = 2;
assert(isequal(whatdigit(n,x,q),y_correct))
```
```a =
3     1     2     5
```
3
Pass

```%%
n=7;
x=7;
q=3;
y_correct = 3;
assert(isequal(whatdigit(n,x,q),y_correct))
```
```a =
1     1     7     6     4     9
a =
8     2     3     5     4     3
```
4
Pass

```%%
n=21;
x=17;
q=18;
y_correct = 8;
assert(isequal(whatdigit(n,x,q),y_correct))
```
```a =
1     8    13    14     8     1
a =
1     6    18    19    19    18     8     5     4     1
a =
Columns 1 through 10
1     4    25    17     8    18     8     0     8    16
Columns 11 through 14
16    21    10     1
a =
Columns 1 through 10
1     4    13    13    15    21    12    16    17     7
Columns 11 through 18
3     7    19    20    18    14     6     1
a =
Columns 1 through 10
1     2    22    10     5     6     8     5    17    18
Columns 11 through 20
21    12    20    19     7    13    22    12     8     3
Columns 21 through 22
2     1
a =
Columns 1 through 10
3     0     0     4     1     9     4     2     4     9
Columns 11 through 20
5     0     8     1     6     9     1     8     9     4
Columns 21 through 23
7     4     1
```
5
Pass

```%%
n=201;
x=123;
q=241;
y_correct = 7;
assert(isequal(whatdigit(n,x,q),y_correct))
```
```a =
2     0     1
a =
4     0     2    20     1
a =
8     0     4    80     4    20     1
a =
16     0    28    41     2   120     6    20     1
a =
1     6     0    28    41     2   120     6    20     1
a =
Columns 1 through 10
2     0   121    66    43    42    82     4   160     8
Columns 11 through 12
20     1
a =
Columns 1 through 10
6     0    43   162     8   160     8    80     4    20
Columns 11 through 14
1     0    20     1
a =
Columns 1 through 10
12     0   106   185    89    84    24   121     6   120
Columns 11 through 16
6    20    41     2    20     1
a =
Columns 1 through 10
1     2     0   106   185    89    84    24   121     6
Columns 11 through 17
120     6    20    41     2    20     1
a =
Columns 1 through 10
2     0    61    43   102    85   144   147   127    46
Columns 11 through 19
162     8   160    88    24    81     4    20     1
a =
Columns 1 through 10
4     0   122   126    86    44    22     1     0    60
Columns 11 through 20
43    82    84   184    29    41    22   121     6    20
Column 21
1
a =
Columns 1 through 10
10     0    65   103   105     5   120    46    22   121
Columns 11 through 20
106    45    42    42   142    67    83    84    24   161
Columns 21 through 23
8    20     1
a =
Columns 1 through 10
1     0     0    65   103   105     5   120    46    22
Columns 11 through 20
121   106    45    42    42   142    67    83    84    24
Columns 21 through 24
161     8    20     1
a =
Columns 1 through 10
2     0     1   140   127    66   123   146    87   184
Columns 11 through 20
109    45     2   180   149   127   186   129    26   161
Columns 21 through 26
8    40     2     0    20     1
a =
Columns 1 through 10
4     0    22   121    66    83   184   169   128   126
Columns 11 through 20
106    65   143    27   121    66   123   186    69    43
Columns 21 through 28
42    42     2    40    42     2    20     1
a =
Columns 1 through 10
8     0    64    83   164   128    66    43    62    23
Columns 11 through 20
141    67   183   129   186   189     9    40    62    63
Columns 21 through 30
143   127    46   122    86    44    82     4    20     1
a =
Columns 1 through 10
16     0   148    87     4   140   107     5   180   109
Columns 11 through 20
145   187   129   146   187   109     5    60   123   186
Columns 21 through 30
169   128    46   182    29    21    41    42   122     6
Columns 31 through 32
20     1
a =
Columns 1 through 10
1     6     0   148    87     4   140   107     5   180
Columns 11 through 20
109   145   187   129   146   187   109     5    60   123
Columns 21 through 30
186   169   128    46   182    29    21    41    42   122
Columns 31 through 33
6    20     1
a =
Columns 1 through 10
2     0   141   107   125   166   188     9   180    89
Columns 11 through 20
44   102   105    25   101   105   165     8    40    82
Columns 21 through 30
64    83    44    82    84   104    25   101   125    86
Columns 31 through 35
44   162     8    20     1
a =
Columns 1 through 10
6     0   103    65    23    61   103     5   140   187
Columns 11 through 20
89   104    45   162   128    66    23   121    46   162
Columns 21 through 30
188    49   162    68    23    81   144   127    86    84
Columns 31 through 37
44     2    60     3     0    20     1
a =
Columns 1 through 10
14     0     7   180   169     8    20   101     5   180
Columns 11 through 20
149     7     0    40   102    85   184   109   145    87
Columns 21 through 30
24    81   104   185    29    41   122   146   127    86
Columns 31 through 39
164    88   164     8    60    43     2    20     1
a =
Columns 1 through 10
1     4     0     7   180   169     8    20   101     5
Columns 11 through 20
180   149     7     0    40   102    85   184   109   145
Columns 21 through 30
87    24    81   104   185    29    41   122   146   127
Columns 31 through 40
86   164    88   164     8    60    43     2    20     1
a =
Columns 1 through 10
2     0    81    44   122   146     7    20     1    60
Columns 11 through 20
83    84   184   149   107    25    41    82   124    86
Columns 21 through 30
84     4    60    63    43   162    88    84   144   187
Columns 31 through 40
149    67    83    84   104    85    84    64    83     4
Columns 41 through 42
20     1
a =
Columns 1 through 10
4     0   162   128   146   127   126   186     9   140
Columns 11 through 20
187    69    83     4     0     0     0     0   100    65
Columns 21 through 30
83   104     5   120   186     9    20   161     8    80
Columns 31 through 40
44   122   126    46   102    65    83    24    41    62
Columns 41 through 44
123     6    20     1
a =
Columns 1 through 10
10     0   145   127    86     4    20    81   164    88
Columns 11 through 20
184    89   144    67    83     4     0    20     1   140
Columns 21 through 30
87    64   103   165   168   148    47   122    46   122
Columns 31 through 40
106   145   107    25   121   186    69   103   165   168
Columns 41 through 46
88    64   163     8    20     1
a =
Columns 1 through 10
1     0     0   145   127    86     4    20    81   164
Columns 11 through 20
88   184    89   144    67    83     4     0    20     1
Columns 21 through 30
140    87    64   103   165   168   148    47   122    46
Columns 31 through 40
122   106   145   107    25   121   186    69   103   165
Columns 41 through 47
168    88    64   163     8    20     1
a =
Columns 1 through 10
2     0    21   101   165   108   125   126   186   169
Columns 11 through 20
88   144    87    84    24   101    65    83    44    22
Columns 21 through 30
101   185    89   124    26    61    63    63   183   149
Columns 31 through 40
187    89    24   121     6   180     9    80    24    21
Columns 41 through 49
41   142   127     6    80     4     0    20     1
a =
Columns 1 through 10
4     0    62    43   162   148    27   181   129    66
Columns 11 through 20
183    69    63   103   145    87   164    68   143   147
Columns 21 through 30
87     4   100    25   141    47   162    28    41   182
Columns 31 through 40
169   128    46   122    66    83    24   141    47   122
Columns 41 through 50
126   126    86   164    88     4    80    44     2    20
Column 51
1
a =
Columns 1 through 10
8     0   124   166     8   140    47   122    86   144
Columns 11 through 20
107     5   120    86   164   108    85    44    62   163
Columns 21 through 30
108   165    88    64   183   149    67   103    85    24
Columns 31 through 40
1    40    62   163   188    89   124   166   148     7
Columns 41 through 50
100   185   129    66    43   182    49    82    84    84
Columns 51 through 53
4    20     1
a =
Columns 1 through 10
18     0    89     4   160    48   122     6    40    22
Columns 11 through 20
81   164   168     8    60   103   145     7    20   181
Columns 21 through 30
109   105    85   124    66   163   128   166    28   141
Columns 31 through 40
87   104   165     8    40   162    68    43     2   180
Columns 41 through 50
169   188   169   128    46    22   141   167    28    41
Columns 51 through 55
82   124     6    20     1
a =
Columns 1 through 10
1     8     0    89     4   160    48   122     6    40
Columns 11 through 20
22    81   164   168     8    60   103   145     7    20
Columns 21 through 30
181   109   105    85   124    66   163   128   166    28
Columns 31 through 40
141    87   104   165     8    40   162    68    43     2
Columns 41 through 50
180   169   188   169   128    46    22   141   167    28
Columns 51 through 56
41    82   124     6    20     1
a =
Columns 1 through 10
2     0   161   188    29     1   120     6    60     3
Columns 11 through 20
60    23   181     9   180   109    25   141   127     6
Columns 21 through 30
180    69     3    80   164    48    62   143   107     5
Columns 31 through 40
60     3   180     9   120    66   123   186    49   102
Columns 41 through 50
25   161   188   129    46    42   182   149   167     8
Columns 51 through 58
60     3    80    84   164     8    20     1
a =
Columns 1 through 10
6     0   163     8    20     1    60    23    41     2
Columns 11 through 20
180    89    24    61   163    28    61     3    60   183
Columns 21 through 30
89   144     7    40   122   186   109   145    67   163
Columns 31 through 40
28    41    22    41    22   161     8    40    22   181
Columns 41 through 50
129    66    23    21    81    44    22   161   108   165
Columns 51 through 60
88    24    41     2     0   100     5     0    20     1
a =
Columns 1 through 10
14     0   127    86     4     0   140    47   142    67
Columns 11 through 20
3   180    49    22   141   127    86    44     2   180
Columns 21 through 30
69    63   103    45    82    24   161    88    64    63
Columns 31 through 40
123    46    62   123    86   164    48    42    82    24
Columns 41 through 50
81   104   165   108   185   109   145   187    69   103
Columns 51 through 60
85     4   160    28    61     3     0   100    45     2
Columns 61 through 62
20     1
a =
Columns 1 through 10
1     4     0   127    86     4     0   140    47   142
Columns 11 through 20
67     3   180    49    22   141   127    86    44     2
Columns 21 through 30
180    69    63   103    45    82    24   161    88    64
Columns 31 through 40
63   12...```
6
Pass

```%%
n=1;
x=1;
q=1;
y_correct = 1;
assert(isequal(whatdigit(n,x,q),y_correct))
```
```a =
1
```