12 lines
517 B
JavaScript
12 lines
517 B
JavaScript
|
var items = "abcdefghijklmnop".split("");
|
||
|
s = (i) => {items = items.splice(-i).concat(items);}
|
||
|
x = (a,b) => {[items[a], items[b]] = [items[b], items[a]]}
|
||
|
p = (a,b) => {x(items.indexOf(a), items.indexOf(b))}
|
||
|
|
||
|
var input = require("fs").readFileSync("input.txt").toString().replace("\n", "");
|
||
|
var input = "," + input + ",";
|
||
|
var expr = input.replace(/,/g, ");").replace(/;([sxp])/g, ";$1(").replace(/([a-z])\/([a-z])/g, "'$1'/'$2'").replace(/\//g, ",");
|
||
|
expr = expr.substring(2);
|
||
|
eval(expr);
|
||
|
console.log(items.join(""));
|