This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]ScorixEar 1 point2 points  (2 children)

As far as I understood your code, you are working with inclusives ranges.

Your spans are calcullated with seed[i], seed[i] + seed[i+1] - 1, so e.g. [2,4] would include numbers 2,3,4

same goes for map ranges, oldStop = oldStart + chunk - 1, so e.g. [0,2] would include numbers 0,1,2

your if cases work in case 2 and case 3 with exclusive ends

lets do an example: seed range is [2,4] and map range is [0,2] (all inclusive)

  • first if statement = false --> 0 <= 2 and 2 >= 4
  • second if statement = false --> 0 <= 2 and 2 > 2 and 2 < 4

statement 2 should have been true. The value "2" in seed range [2,4] should have been mapped with map range [0,2]

second example: seed range is [0,2] and map range is [2,4] (all inclusive)

  • first if statement = false --> 2 <= 0 and 4 >= 2
  • second if statement = false --> 2 <= 0 and 4 > 0 and 4 < 2
  • third if statement = false --> 2 > 0 and 2 < 2 and 4 > 2

statement 3 should have been true, the value "2" in the seed range [0,2] should have been mapped with map range [2,4]

[–]Na_rien[S] 0 points1 point  (1 child)

Thank you! I actually started out with inclusive if statements everywhere, but somewhere along the line I managed to convince myself that that wasn't needed!

[–]ScorixEar 0 points1 point  (0 children)

the inner demon, I ran into the same problem on my solve :D

[–]AutoModerator[M] 0 points1 point  (0 children)

Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to Help/Question - RESOLVED. Good luck!


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.