1 | static <A, B> L<Pair<A, B>> combineZigZag(L<A> l1, L<B> l2) { |
2 | int lA = l(l1), lB = l(l2), maxSum = max(lA, lB); |
3 | L<Pair<A, B>> out = new L; |
4 | |
5 | int ndiags = lA + lB - 1; |
6 | for diag to ndiags: { |
7 | int row_stop = max(0, diag - lA + 1); |
8 | int row_start = min(diag, lB - 1); |
9 | for (int row = row_start; row >= row_stop; row--) { |
10 | // on a given diagonal row + col = constant "diag" |
11 | // diag labels the diagonal number |
12 | int col = diag - row; |
13 | out.add(pair(l1.get(col), l2.get(row))); |
14 | } |
15 | } |
16 | |
17 | ret out; |
18 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017436 |
Snippet name: | combineZigZag - combine two priority-first lists into a new priority-first list |
Eternal ID of this version: | #1017436/8 |
Text MD5: | c59dcc56b90a333ca28eefaa48c78573 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-21 13:04:18 |
Source code size: | 548 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 385 / 435 |
Version history: | 7 change(s) |
Referenced in: | [show references] |