1 | static IntRange varyIntRange(IntRange r, int variation, int minLength, int min, int max) { |
2 | // vary start within min/max |
3 | int start = random(max(min, r.start-variation), min(max, r.start+variation)+1); |
4 | // vary end within .../max |
5 | int end = random(r.end-variation, min(max, r.end+variation+1)); |
6 | // make longer if too short |
7 | end = max(end, start+minLength); |
8 | // move left if too long |
9 | if (end > max) { |
10 | int shift = end-max; |
11 | start -= shift; |
12 | end -= shift; |
13 | } |
14 | ret intRange(start, end); |
15 | } |
Began life as a copy of #1018801
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018802 |
Snippet name: | varyIntRange |
Eternal ID of this version: | #1018802/1 |
Text MD5: | a9ddc411d9b0a1d1a6224f023a8e7cf1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-13 19:56:25 |
Source code size: | 520 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 281 / 301 |
Referenced in: | [show references] |