Results 1 to 9 of 9
  1. Senior Member
    Student or Learner
    • Member Info
      • Native Language:
      • Persian
      • Home Country:
      • Iran
      • Current Location:
      • United States

    • Join Date: Jan 2018
    • Posts: 515
    #1

    within 2 of each other

    Add an instance method that determines if the dice values are within 2 of each other example: 1,2 are within 2 of each other; 2 5 are not within 2 of each other.
    Source: my professor

    What does "within two each other" mean? are double dices included? Like (4,4) or (6,6)?

  2. jutfrank's Avatar
    VIP Member
    English Teacher
    • Member Info
      • Native Language:
      • English
      • Home Country:
      • England
      • Current Location:
      • England

    • Join Date: Mar 2014
    • Posts: 9,096
    #2

    Re: within 2 of each other

    Think about it, Niaz. Is 4 within 2 of 4?

  3. Senior Member
    Student or Learner
    • Member Info
      • Native Language:
      • Persian
      • Home Country:
      • Iran
      • Current Location:
      • United States

    • Join Date: Jan 2018
    • Posts: 515
    #3

    Re: within 2 of each other

    Quote Originally Posted by jutfrank View Post
    Think about it, Niaz. Is 4 within 2 of 4?
    To be honest I don't understand this question "Is 4 within 2 of 4"?

    The formula to get this answer is " |dic1-dice2| <=2 " so I guess pairs like (5,3), (6,4), (3,2) makes sense too although they are not within 2

  4. Tarheel's Avatar
    VIP Member
    Interested in Language
    • Member Info
      • Native Language:
      • American English
      • Home Country:
      • United States
      • Current Location:
      • United States

    • Join Date: Jun 2014
    • Posts: 16,417
    #4

    Re: within 2 of each other

    Counting by twos:

    2
    4
    6
    8
    10
    12
    14
    16
    18
    20

    Each of the numbers in this series is within two of its immediate neighbors.
    Not a professional teacher

  5. VIP Member
    Interested in Language
    • Member Info
      • Native Language:
      • American English
      • Home Country:
      • United States
      • Current Location:
      • United States

    • Join Date: Apr 2009
    • Posts: 12,764
    #5

    Re: within 2 of each other

    Is the difference of the two dice >2?

  6. Senior Member
    Student or Learner
    • Member Info
      • Native Language:
      • Persian
      • Home Country:
      • Iran
      • Current Location:
      • United States

    • Join Date: Jan 2018
    • Posts: 515
    #6

    Re: within 2 of each other

    Quote Originally Posted by SoothingDave View Post
    Is the difference of the two dice >2?
    No the absolute value of two dices has to be less than or equal 2 ; otherwise, pairs like (6,1),(5,1),.. don't fall in the category of "within 2", which is wrong.

  7. VIP Member
    Interested in Language
    • Member Info
      • Native Language:
      • American English
      • Home Country:
      • United States
      • Current Location:
      • United States

    • Join Date: Apr 2009
    • Posts: 12,764
    #7

    Re: within 2 of each other

    6 and 1 are not within two of each other. Neither are 5 and 1.

    Yes, when I said "difference" I was assuming one would subtract the smaller number from the larger

  8. Senior Member
    Student or Learner
    • Member Info
      • Native Language:
      • Persian
      • Home Country:
      • Iran
      • Current Location:
      • United States

    • Join Date: Jan 2018
    • Posts: 515
    #8

    Re: within 2 of each other

    Quote Originally Posted by SoothingDave View Post
    6 and 1 are not within two of each other. Neither are 5 and 1.

    Yes, when I said "difference" I was assuming one would subtract the smaller number from the larger
    That's why I said we use absolute value with the notation | |.

  9. Tarheel's Avatar
    VIP Member
    Interested in Language
    • Member Info
      • Native Language:
      • American English
      • Home Country:
      • United States
      • Current Location:
      • United States

    • Join Date: Jun 2014
    • Posts: 16,417
    #9

    Re: within 2 of each other

    Three things, Niaz. One, you have not indicated that you understand the responses to your original post. Two, you have not clicked Thanks on anything in this thread.Three, it's dice which is plural, not singular. (Singular is die.)
    Not a professional teacher

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •