Decision tables: Difference between revisions

Stronger second D entry
(Added AutoHotky)
(Stronger second D entry)
Line 366:
<lang d>import std.stdio, std.string;
 
struct DataPair(size_t N) { string message, truth; }
string message;
immutable char[N] truth;
}
 
immutable DataPair!8[] conditions = [
{"Printer does not print", "####...."},
{"A red light is flashing", "##..##.."},
{"Printer is unrecognised", "#.#.#.#."}];
 
immutable DataPair!8[] solutions = [
{"Check the power cable", "..#....."},
{"Check the printer-computer cable", "#.#....."},
Line 381 ⟶ 384:
 
void main() {
size_t code = 0;
 
foreach (immutable cond; conditions) {
write(cond.message, "? [y=yes/others=no] ");
string answer = "no";
Line 397 ⟶ 400:
else {
writeln("\nSolutions:");
foreach (immutable sol; solutions)
if (sol.truth[code] == '#')
writeln(" ", sol.message);