What about logic? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 3

What about logic?

For example, the game "guess the number." Let's say I want to give the user some settings: numbers from 0 to 100, from 100 to 1000, nums with decimal ... Should I enumerate for the program all possible options for the settings? I.e: --if(1 || 2 || 3) { -----if (1 && 2) { -------if( 1 && 2 && 3) { code } } -----if(1 && 3) {code} etc. ??

29th Dec 2017, 9:40 AM
Bogdan Saliuk
Bogdan Saliuk - avatar
5 Antworten
+ 9
No, you could use a sorting algorithm like this one. https://code.sololearn.com/WH0xro6Iz123/?ref=app
29th Dec 2017, 8:49 AM
The Coding Sloth
The Coding Sloth - avatar
+ 3
If you are talking about setting for a game https://code.sololearn.com/W16L6RLpXVKI/?ref=app
29th Dec 2017, 9:49 AM
CalviŇ▓
CalviŇ▓ - avatar
+ 1
yes
29th Dec 2017, 8:35 AM
Prakhar Saxena
Prakhar Saxena - avatar
+ 1
I don;t understand, how it can work with my example :( How it must works with checkbox?
29th Dec 2017, 9:34 AM
Bogdan Saliuk
Bogdan Saliuk - avatar
0
At all, i still don't understand T_T Yes, we get array with 'checked', but what next? How does this frees me from enumerating all possible options for the settings?
29th Dec 2017, 3:12 PM
Bogdan Saliuk
Bogdan Saliuk - avatar