A dartboard has seven rings with respective scores of 11 points, 13 points, 31 points, 33 points, 42 points, 44 points, and 46 points.
More than one discharged dart may lodge in a given ring.
What is the minimum number of darts used to score 100? Show how its achievable.
clearvars, clc
global remain build rings
rings=[46 42 33 31 13 11];
remain=100; build=[];
addOn
function addOn
global remain build rings
if isempty(build)
st=1;
else
st=build(end)+1;
end
for i=st:length(rings)
for ct=1:floor(remain/rings(i))
remain=remain-ct*rings(i);
buildHold=build;
build=[build repmat(i,1,ct)];
if remain==0
vals=rings(build);
disp(vals)
else
addOn;
end
build=buildHold;
remain=remain+ct*rings(i);
end
end
end
finds only one way of scoring 100; it has 8 darts: six 13's and two 11's.
So not only is 8 the minimum number of darts, but it is the only number of darts that can score exactly 100.
Now that we're at it, how about other totals, besides 100?
The below program find all the shortest ways of finding all the possible totals up to 200.
clearvars, clc
global remain build rings shortest
rings=[46 42 33 31 13 11];
for score=11:200
shortest=[];
remain=score; build=[];
addOn
fprintf('%4d ',score)
fprintf('%6d',shortest)
fprintf('\n')
end
function addOn
global remain build rings shortest
if isempty(build)
st=1;
else
st=build(end)+1;
end
for i=st:length(rings)
for ct=1:floor(remain/rings(i))
remain=remain-ct*rings(i);
buildHold=build;
build=[build repmat(i,1,ct)];
if remain==0
vals=rings(build);
if isempty(shortest) || ...
length(vals)<length(shortest)
shortest=vals;
end
% disp(vals)
else
addOn;
end
build=buildHold;
remain=remain+ct*rings(i);
end
end
end
finds minimal ways of getting 11 through 200:
total minimum way
11 11
12
13 13
14
15
16
17
18
19
20
21
22 11 11
23
24 13 11
25
26 13 13
27
28
29
30
31 31
32
33 33
34
35 13 11 11
36
37 13 13 11
38
39 13 13 13
40
41
42 42
43
44 33 11
45
46 46
47
48 13 13 11 11
49
50 13 13 13 11
51
52 13 13 13 13
53 42 11
54
55 42 13
56
57 46 11
58
59 46 13
60
61 13 13 13 11 11
62 31 31
63 13 13 13 13 11
64 33 31
65 13 13 13 13 13
66 33 33
67
68 46 11 11
69
70 46 13 11
71
72 46 13 13
73 42 31
74 13 13 13 13 11 11
75 42 33
76 13 13 13 13 13 11
77 46 31
78 13 13 13 13 13 13
79 46 33
80
81 46 13 11 11
82
83 46 13 13 11
84 42 42
85 46 13 13 13
86 42 33 11
87 13 13 13 13 13 11 11
88 46 42
89 13 13 13 13 13 13 11
90 46 33 11
91 13 13 13 13 13 13 13
92 46 46
93 31 31 31
94 46 13 13 11 11
95 42 42 11
96 46 13 13 13 11
97 42 42 13
98 46 13 13 13 13
99 46 42 11
100 13 13 13 13 13 13 11 11
101 46 42 13
102 13 13 13 13 13 13 13 11
103 46 46 11
104 42 31 31
105 46 46 13
106 42 33 31
107 46 13 13 13 11 11
108 46 31 31
109 46 13 13 13 13 11
110 46 33 31
111 46 13 13 13 13 13
112 46 33 33
113 13 13 13 13 13 13 13 11 11
114 46 42 13 13
115 42 42 31
116 46 46 13 11
117 42 42 33
118 46 46 13 13
119 46 42 31
120 46 13 13 13 13 11 11
121 46 42 33
122 46 13 13 13 13 13 11
123 46 46 31
124 31 31 31 31
125 46 46 33
126 42 42 42
127 46 42 13 13 13
128 42 42 33 11
129 46 46 13 13 11
130 46 42 42
131 46 46 13 13 13
132 46 42 33 11
133 46 13 13 13 13 13 11 11
134 46 46 42
135 42 31 31 31
136 46 46 33 11
137 42 33 31 31
138 46 46 46
139 46 31 31 31
140 46 42 13 13 13 13
141 46 42 42 11
142 46 46 13 13 13 11
143 46 42 42 13
144 46 46 13 13 13 13
145 46 33 33 33
146 42 42 31 31
147 46 46 42 13
148 42 42 33 31
149 46 46 46 11
150 46 42 31 31
151 46 46 46 13
152 46 42 33 31
153 46 42 13 13 13 13 13
154 46 42 33 33
155 31 31 31 31 31
156 46 46 33 31
157 42 42 42 31
158 46 46 33 33
159 42 42 42 33
160 46 46 42 13 13
161 46 42 42 31
162 46 46 46 13 11
163 46 42 42 33
164 46 46 46 13 13
165 46 46 42 31
166 42 31 31 31 31
167 46 46 42 33
168 42 42 42 42
169 46 46 46 31
170 46 31 31 31 31
171 46 46 46 33
172 46 42 42 42
173 46 46 42 13 13 13
174 46 42 42 33 11
175 46 46 46 13 13 11
176 46 46 42 42
177 42 42 31 31 31
178 46 33 33 33 33
179 42 42 33 31 31
180 46 46 46 42
181 46 42 31 31 31
182 46 46 46 33 11
183 46 42 33 31 31
184 46 46 46 46
185 46 42 33 33 31
186 31 31 31 31 31 31
187 46 42 33 33 33
188 42 42 42 31 31
189 46 46 42 42 13
190 42 42 42 33 31
191 46 46 33 33 33
192 46 42 42 31 31
193 46 46 46 42 13
194 46 42 42 33 31
195 46 46 46 46 11
196 46 42 42 33 33
197 46 46 46 46 13
198 46 46 42 33 31
199 42 42 42 42 31
200 46 46 42 33 33
|
Posted by Charlie
on 2023-03-27 09:31:53 |