Warning : session_start(): open(/var/lib/php/sessions/sess_fhtobcdlth8nd1k5fqochrqi28, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning : session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
2-Grams Predictor [Lua] [1004708]
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:
2034 / 361
Referenced in:
[show references]