master
1// length 809 chars/ comprimised 565 chars
2// Improvements:
3// - remove dtr import (15)
4// - remove return (25)
5// - interating over 2-99 for ez_prime (~89) (not recommended heavy runtime)
6// - for color_complement or triad iterating over colors (95)
7// doing all shrinks to 340 chars
8
9function(context, args) { // lock:#s.<user>.<script>
10 var lock = args.lock;
11 var d = #s.dtr.lib();
12 var commands = [ "unlock", "release", "open" ];
13 var primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ];
14 var color = [ "red", "lime", "blue", "orange", "green", "purple", "yellow", "cyan" ];
15 args = {};
16 var type = "", tmp, result = "", index;
17
18 do {
19 tmp = result.match(/!(\w+)!.*$/);
20 if (tmp) {
21 type = tmp[1];
22 index = 0;
23 }
24 if (type[0] == "E") { // EZ_xx
25 args[type] = commands[index++];
26 }
27 if (type[0] == "d") { // digit
28 args[type] = index++;
29 }
30 if (type[0] == "e") { // ez_prime
31 args[type] = primes[index++];
32 }
33 if (type[0] == "c") { // c00x
34 args[type] = color[index++];
35 if (type[3] == "1") { // c001
36 args.color_digit = args[type].length;
37 } else if (type[3] == "2") { // c002
38 args.c002_complement = color[(index + 3) % 8];
39 } else if (type[3] == "3") { // c003
40 args.c003_triad_1 = color[(index + 6) % 8];
41 args.c003_triad_2 = color[index];
42 }
43 }
44 result = lock.call(args);
45 } while (!result.match(/terminated/));
46
47 return {
48 ok: true,
49 msg: d.pp(args)
50 };
51}