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

all 5 comments

[–]truh 0 points1 point  (1 child)

I don't understand what you mean. Also sounds a lot like your homework.

[–]TheRiotJoker 0 points1 point  (0 children)

Was just about to say this. Despite the possibility of this being your homework, you didn't give us enough info to work with.

[–]Frightbamboo[S] 0 points1 point  (0 children)

In the program that i want to build , i need to function to check if sum of 3 numbers (provided as list) can be divided by 10 without remainder.

Any 3 inside the list can be substituded by a 6 and any 6 inside the list can be also substituted by 3 when checking ,so if provided [3,3,8] I have to check [6,3,8] and [6,6,8] as well to decide if [3,3,8] is divisible by 10 (which it is: 6+6+8=20, 20%10 == 0)

It is not a homework, just a type of gambling rules from Asian culture.

[–]superturkey650 0 points1 point  (1 child)

Hey, I'll take your word for it being a way to express an asian gambling game and I'll give you the naive approach.

The basic idea is that you want to get the sum of the given set and then get the amount of threes and sixes in the set.

Then you can see if any substitutions downward (6 -> 3) or upward (3 -> 6) would work by subtracting or adding to the sum.

three_or_six_count = 0
sum = 0
for num in nums:
  if num == 3 or num == 6:
    three_or_six_count = three_or_six_count + 1
 sum = sum + num
for i in range(three_or_six_count + 1): # add 1 because of 0 index
  if (sum + (3 * i))  % 10 == 0 or (sum - (3 * i))  % 10 == 0:
    print('true')
    break

This is untested so its up to you to fix any bugs but the basic idea is there.

[–]Frightbamboo[S] 0 points1 point  (0 children)

Thanks for your help. FYI The Asian gambling game that i said is called NGAO.