Hello friends and welcome to my article in the SEC S20/W6 in this great dynamics. I would take part in the task immediately.
Colors involve orchestrating text to look for find in appearance. There are several colors used in our programming. They vary from red, blue, green, magenta, violet. Colors can be brought to life using Esc sequence to change colors in our texts. The escape are used to change appearance of text in program. We use \033 or \e in CPP which is synonymous to the ASCII for escape symbol.
Using escape sequence, syntax, we can be able to attribute special combination, such as bold, italics or underline. Possible by attributing [] After escape code then define parameters to vs implemented.
There are special categories which color theory can be applied. These are;
Standard Color Code; |
---|
This explains direct application of colors to our characters. Some of these color code and colors include.
Color Code | Representation |
---|---|
30m | Black 🖤 |
31m | Red ♥️ |
32m | Green 💚 |
33m | Yellow 💛 |
34m | Blue 💙 |
35m | Magenta [] |
36m | White 🤍 |
0m | reset all sequence |
The escape sequence 033 30m or \e [30m \033 [31m......]
for 🖤...just to mention a few.
Background Color Code; |
---|
Color Code | Background Color Representation |
---|---|
40m | Black background ⚫ |
41m | Red background 🔴 |
42m | Green background 🟢 |
43m | Yellow background 🟡 |
44m | Blue background 🔵 |
45m | Magenta background [] |
46m | Cyan background |
47m | White background ⚪ |
Representation can be \033 [40m...,\033 [41m...]
for 🔴 just to mention but a few
Special Attribute to Text: |
---|
We can either make out text background look high on contrast and brightness respectively
Color Code | High brightness text Representation |
---|---|
90m | Black ⬛ |
91m | Red 🟥 |
92m | Green 🟩 |
93m | Yellow 🟨 |
94m | Blue 🟦 |
95m | Magenta [] |
96m | Cyan |
97m | White ⬜ |
Color Code | high brightness background color representation |
---|---|
100m | Black background ⬛ |
101m | Red background 🟥 |
102m | Green background 🟩 |
103m | Yellow background 🟨 |
104m | Blue square 🟦 |
105m | Magenta background [] |
106m | Cyan background |
107m | White background ⬜ |
Text Styling: |
---|
Here we choose how we want to style, to look bold underlined and so on. It's possible with these codes
Color Code | Background color representation |
---|---|
1m | Bold |
4m | Underline |
5m | Black |
7m | inverted color |
9m | strike through text |
After all these codes and background, we can implement them in our program. \e [ 1; 31; 47m]
is interpreted as bold red text in background below.
Explanation; |
---|
It begins with what it turned out to be after encoding. Wake up message; wishes him goodluck, program ask user to input their names program proceeds by requesting level of difficulty the user wants to play. The crucial aspect of the game is giving players cluesto the right answers. Each option displays a clue whether number is high or low. Players can work with regards to hint given.
Easy mode involves selecting numbers from 0 to 20. Players having maximum of t attempts until users gives correct clues. The normal mode involves selecting players from 0 to 50 here players have about seven attempts. Once they are exhausted, program displays a response with correct answers applauding congratulations
Difficult mode players is requested to select random numbers from 0 to 100 In this case maximum of 10 attempts is given, if player guesses rightly it also displays congratulations if not sorry you ran out of attempts the answer would be shown immediately.
Estimated Guessing Time: |
---|
Problem Scenario:
We try to calculate average number of guesses required to find a number within a range using guessing strategy.
Assumption;
Number generation; we assume random numbers is generated uniformly within specified range
Optimal Guessing Strategy;
We'll use binary search algorithm, an efficient method for finding target values in arranged sequence. Once number aren't sorted, we can adapt binary search principle.
Analyzing:
Binary search is medium to get used, we divide space in half with each guess, the worst case scenario target numbers is median of range. Best case first guess is presumed correct.
Calculation:
Ranging from 0-100 numbers of division required is log2(1000)= 9.97
Worst case takes about 10 guesses
Ranging from 0-1000
Number of division required
log 2(10000)= 13.29
Worst case it would take around 14 guesses
Using proportion it takes 2 seconds to get an attempt from 0-100 and about 2×10= 20 sec.
Ranging from 0-10000
It is maximum of 14 attempts giving at least 2×14=28 sec
Game Routine |
---|
Start with numbers of ball remaining. Players take turns, a variable to store numbers of ball is present. It continues for a while in a loop while there are balls remaining. It requires current players to enter numbers of balls they need to take,validate to ensure it's allowed and there are enough balls left.
If input is valid it updates numbers of ball, switches to the next player turn and the sequence continues until there are no balls left. Game ends once the last ball is taken current player is emerged as winner.
From the above it could be spotted that player 2 wind seeing he has four balls left. We all know how it works. We check for an invalid input so that you wouldn't be disqualified.
Here we create shapes using simple approach, start printing the *
in simple forms, them transform to large complex shape by using nested loops to properly print row and column .
Cc;
@sergeyk
❌❌❌Why do you have screenshots of the code from one software environment and a screenshot of the result of the application from another online software environment?
Screenshots are not your creation!!!! You took them from @rafk
this is a copy paste, the code, by the way, is also copied from @rafk
What's the point of me rating your work?
Not counted at all❌❌❌
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Upvoted. Thank You for sending some of your rewards to @null. It will make Steem stronger.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit