!752 static L themap = litlist( "mine", "yours", "my", "your", "you are", "i am", "are you", "am i", "for me", "for you", "against me", "against you", "with me", "with you", "without me", "without you", "i", "you", "me", "you" ); p { makeBot("Switcheroo"); } answer { if (matchStart("switcheroo", s, m)) { S rest = m.rest(); ret switcheroo(rest); } } static S switcheroo(S s) { L tok = javaTok(s); for (int i = 1; i < l(tok); i += 2) { for (int j = 0; j < l(themap); j += 2) { S x = themap.get(j), y = themap.get(j+1); L tokx = javaTok(x), toky = javaTok(y); matchReplace(tok, i, tokx, toky); matchReplace(tok, i, toky, tokx); } } ret join(tok); } static void matchReplace(L tok, int i, L tokx, L toky) { //printFormat("Matching * * *", i, get(tok, i), tokx); if (tokRegionMatch(tok, i, tokx)) { printFormat("Replacing * *", tokx, toky); for (int j = 0; j*2+1 < l(tokx); j++) tok.set(i+j*2, "*" + toky.get(1+j*2)); } } static boolean tokRegionMatch(L tok, int i, L tokx) { for (int j = 0; j*2+1 < l(tokx); j++) if (!eqic(get(tok, i+j*2), get(tokx, 1+j*2))) ret false; ret true; }