Im wanting to have a series of letters a to j and then give each one of them a random number eg, a7, b3, c6, d5, e2, etc......
then I want to write and if or else statement, if (a + b + c= 15) then print true, else print false and re_randomize, hope this is clear, im a retired engineer trying out a new hobby, so total beginner, Im looking for code as I am very limited with my knowledge , I need the letters to say in order but with a random unique number , with each loop,
Many Thanks
how do you plan on choosing the 3 variables in the if (condition)? do you want to do that randomly as well or are there pre-determines conditions (e.g. d+h+i, a+f+h, ...)?
using an array, there can be symbols (e.g. a, b, c, ...) that are the indicies (e.g. 0, 1, 2, ..) to an array (e.g. if (var [a]+var[d]+var[g])
I want the numbers to be unique and different each time, then I want to be able to say if.
A + b + c = 15 then print true, but it may be A + B + C = 19, Then serial print false and re-randomize,
the code to decode the text could be much more complicated than the code to populate the variable array with random values and test if the sum of one or more variables equals some value
That is so kind of you to send me that code, but its not quite what im after,
I want it to work out if A+B+C=15 or 18.. print true, or does D+E+F=15 or whatever then print true so serial print will say A+B+C does not equal 15, so randomise the whole thing again, if A+B+C does equal 15 then move on to D+E+F does. That equal 15 no , then randomise the whole thing again,
I should have been more specific, back in the 80’s when we were buying Sinclair spectrums I went to night classes to learn basic programming, a homework assignment was to draw a 4x 4 grid put in the numbers 1 to 16, in such an order that they add up to I think it was 34 in any direction, he wanted us to randamize the 16 numbers and place them in the grid, if the first row added up to 34 we randomised the remainder numbers, it was just pure luck if you came up with the solution, I managed to write the code and after running it for a few days I got nowhere, I wanted to see how I’d go on now using an ESP32, I’m not looking for a solution for the whole thing, I want to be challenged, I just want the code to add a+b+c+d etc on all four lines then again down all 4 columns, once I get all 4 rows I check each each column just randomising each row, hope I’ve made sense
I should have been more specific, back in the 80’s when we were buying Sinclair spectrums I went to night classes to learn basic programming, a homework assignment was to draw a 4x 4 grid put in the numbers 1 to 16, in such an order that they add up to I think it was 34 in any direction, he wanted us to randamize the 16 numbers and place them in the grid, if the first row added up to 34 we randomised the remainder numbers, it was just pure luck if you came up with the solution, I managed to write the code and after running it for a few days I got nowhere, I wanted to see how I’d go on now using an ESP32, I’m not looking for a solution for the whole thing, I want to be challenged, I just want the code to add a+b+c+d etc on all four lines then again down all 4 columns, once I get all 4 rows I check each each column just randomising each row, hope I’ve made sense
If you are just starting out in Arduino and have to learn the programming language, summing arbitrary rows and columns of a 2 dimensional grid (array) is not a particularly simple problem.
If you don't want a prepackaged solution, start with simpler tasks and work your way up. There are plenty of tutorials on line for beginners, such as this one for arrays.