15
LINES
Lua code
1 | -- a, b is our "buffer" for last 2 chars
|
2 | pairs = {}
|
3 | function p(m, s)
|
4 | if s ~= nil then
|
5 | -- fill buffer
|
6 | for i = 1, s:len() do
|
7 | a = b
|
8 | b = s:sub(i)
|
9 | if a ~= nil then
|
10 | pairs[a] = b
|
11 | end
|
12 | end
|
13 | end
|
14 | return pairs[b]
|
15 | end |
Author comment
m = max chars to return
s = fed "real" input
test run test run with input download show line numbers
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID |
Author/Program |
Comment |
Date |
1296 | stefan | Scores 24.5% on #1004698 | 2016-08-27 16:03:57 |
add comment
Snippet ID: |
#1004708 |
Snippet name: |
2-Grams Predictor [Lua] |
Eternal ID of this version: |
#1004708/1 |
Text MD5: |
976a4a3f7326762539f30de71b59d06f |
Author: |
stefan |
Category: |
javax / a.i. |
Type: |
Lua code |
Public (visible to everyone): |
Yes |
Archived (hidden from active list): |
No |
Created/modified: |
2016-08-27 15:52:01 |
Source code size: |
267 bytes / 15 lines |
Pitched / IR pitched: |
No / No |
Views / Downloads: |
949 / 198 |
Referenced in: |
[show references] |