{"ScriptPreparationCode":"function nthIndexOfFor(text, search, n) {\r\n let i = 0;\r\n n--;\r\n for (i = text.indexOf(search); n \u003E 0; i = text.indexOf(search, i \u002B 1), n--) {\r\n if (i === -1) return -1;\r\n }\r\n return i;\r\n}\r\n\r\nfunction nthIndexOfWhile(text, search, n) {\r\n let i = text.indexOf(search);\r\n while (--n \u003E 0) {\r\n if (i === -1) return -1;\r\n i = text.indexOf(search, i \u002B 1);\r\n }\r\n return i;\r\n}\r\n\r\nfunction nthIndexOfRec(text, search, n) {\r\n const recur = (n, i) =\u003E {\r\n if (n \u003C= 0) return i;\r\n const j = text.indexOf(search, i \u002B 1);\r\n if (j === -1) return -1;\r\n return recur(n - 1, j);\r\n }\r\n return recur(n, -1);\r\n}\r\n\r\nfunction nthIndexOfCc(text, search, n) {\r\n let i = -1;\r\n const ret = (v) =\u003E i = v;\r\n const recur = (n, i) =\u003E {\r\n if (n \u003C= 0) return void ret(i);\r\n const j = text.indexOf(search, i \u002B 1);\r\n if (j === -1) return void ret(-1);\r\n recur(n - 1, j);\r\n }\r\n recur(n, -1);\r\n return i;\r\n}\r\n\r\nfunction nthIndexOfCatch(text, search, n) {\r\n const recur = (n, i) =\u003E {\r\n if (n \u003C= 0) throw i;\r\n const j = text.indexOf(search, i \u002B 1);\r\n if (j === -1) throw -1;\r\n recur(n - 1, j);\r\n }\r\n try {\r\n recur(n, -1);\r\n } catch (i) {\r\n return i;\r\n }\r\n}\r\n\r\nfunction nthIndexOfGen(text, search, n) {\r\n const recur = function*(n, i) {\r\n if (n \u003C= 0) yield i;\r\n const j = text.indexOf(search, i \u002B 1);\r\n if (j === -1) yield - 1;\r\n yield* recur(n - 1, j);\r\n };\r\n return recur(n, -1).next().value;\r\n}","TestCases":[{"Name":"for","Code":"let e = document.getElementById(\u0027for\u0027);\r\ne.innerHTML = nthIndexOfFor(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 7)\r\n \u002B \u0027 \u0027 \u002B nthIndexOfFor(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 17);","IsDeferred":false},{"Name":"while","Code":"let e = document.getElementById(\u0027while\u0027);\r\ne.innerHTML = nthIndexOfWhile(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 7)\r\n \u002B \u0027 \u0027 \u002B nthIndexOfWhile(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 17);","IsDeferred":false},{"Name":"recur","Code":"let e = document.getElementById(\u0027rec\u0027);\r\ne.innerHTML = nthIndexOfRec(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 7)\r\n \u002B \u0027 \u0027 \u002B nthIndexOfRec(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 17);","IsDeferred":false},{"Name":"continuation","Code":"let e = document.getElementById(\u0027cc\u0027);\r\ne.innerHTML = nthIndexOfCc(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 7)\r\n \u002B \u0027 \u0027 \u002B nthIndexOfCc(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 17);","IsDeferred":false},{"Name":"throw-catch","Code":"let e = document.getElementById(\u0027catch\u0027);\r\ne.innerHTML = nthIndexOfCatch(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 7)\r\n \u002B \u0027 \u0027 \u002B nthIndexOfCatch(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 17);","IsDeferred":false},{"Name":"generator","Code":"let e = document.getElementById(\u0027gen\u0027);\r\ne.innerHTML = nthIndexOfGen(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 7)\r\n \u002B \u0027 \u0027 \u002B nthIndexOfGen(\u0027/1/23/7/3/19/61/2/4/27/18/\u0027, \u0027/\u0027, 17);","IsDeferred":false}]}