+ 1

Dice problem

Hello, i have trouble with a problem with dices, i tooked 4 dices with random numbers... they are all stacked on eachother and i have to find the sum of the invisible numbers ... i keep getting stuck, i will post here what i typed dice_1 = '1, 4, 3, 5, 2' dice_2 = '4, 5, 1, 3' dice_3 = '6, 1, 5, 2' dice_4 = '2, 6, 3, 4' dice_faces = '1, 2, 3, 4, 5, 6' i need to make a list with numbers that are invisibile, a list with numbers that are visible and the final, the sum of invisible faces. some help please

5th Nov 2021, 9:28 AM
AliN MaD
AliN MaD - avatar
10 Réponses
+ 1
Well you just answered it yourself then. You know that a die contains 1-6. You already have each die and the numbers it shows. Put all numbers not shown in an array and sum them. Then sum all the other dice values
5th Nov 2021, 9:52 AM
Slick
Slick - avatar
+ 1
Have you even attempted it? Let's see the code.
5th Nov 2021, 9:55 AM
Slick
Slick - avatar
+ 1
Correct, first off, "dice_1" should be a list. When you use a for loop to loop through a string, it will just loop over each character, not each number. "num_dice" also should be a list. append() is a list method so it can only be preformed on lists. AliN MaD thats right! ** and when you post about errors, it's better to include the full text. It'll usually tell you exactly what's wrong and where **
5th Nov 2021, 10:01 AM
Slick
Slick - avatar
0
You have to explain what "invisible numbers" are. I can see all of them
5th Nov 2021, 9:47 AM
Slick
Slick - avatar
0
invisible number meaning, if the dices are stacked one on top of another, those number u dont see ... dice has 6 faces, stacked, 1st dice u see 5 numbers, 2nd only 4 ...
5th Nov 2021, 9:48 AM
AliN MaD
AliN MaD - avatar
0
You can find the missing numbers and add them up. Or with math. Since the sum of invisible numbers and visible numbers are 1+2+3+4+5+6, which is 21, you can 21 - the sum of visible numbers. You won't need to know what numbers are invisible.
5th Nov 2021, 9:51 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
well the part writting the code is hard since i started to learn python,
5th Nov 2021, 9:53 AM
AliN MaD
AliN MaD - avatar
0
dice_1 = '1, 4, 3, 5, 2' dice_2 = '4, 5, 1, 3' dice_3 = '6, 1, 5, 2' dice_4 = '2, 6, 3, 4' dice_faces = '1, 2, 3, 4, 5, 6' for dice_faces in dice_1: num_dice = '' num_dice.append(d_f) num_dice i keep getting a error "no attribute 'append' "
5th Nov 2021, 9:58 AM
AliN MaD
AliN MaD - avatar
0
so i have to write them like [ 1, 2, 3, 4, 5, 6] ?
5th Nov 2021, 10:01 AM
AliN MaD
AliN MaD - avatar
0
Understood.
5th Nov 2021, 10:04 AM
AliN MaD
AliN MaD - avatar