Libraryless. Click here for Pure Java version (1457L/10K/33K).
!7 sS input_train = [[ Suppose we have a list. The list has 5 elements. How many elements does the list have? 5 ]]; sS input_test = [[ Suppose we have a list. The list has 3 elements. How many elements does the list have? ]]; p { L<S> tok_train = parse(input_train); L<S> tok_test = parse(input_test); printStruct(simpleComplete(tok_train, tok_test)); } static L<S> simpleComplete(L<S> tok_train, L<S> tok_test) { assertTrue("Bad length", l(tok_train) >= l(tok_test)); new SS map; for (int i = 1; i < l(tok_test); i += 2) map.put(tok_train.get(i), tok_test.get(i)); new L<S> out; for (int i = l(tok_test); i < l(tok_train); i += 2) { S t = tok_train.get(i); out.add(getOrKeep(map, t)); } ret out; } static L<S> parse(S s) { ret simpleSpaces(javaTok(s)); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008465 |
Snippet name: | List Logic [OK] |
Eternal ID of this version: | #1008465/5 |
Text MD5: | 817396408364d772009314095617fac5 |
Transpilation MD5: | 69d0e86c220f4e895effa2c48f1360de |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-16 14:46:32 |
Source code size: | 827 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 429 / 549 |
Version history: | 4 change(s) |
Referenced in: | -