# Programs aren't always static.
# Sometimes a program has to behave differently based on the
# information it gets. We can control the flow of a program
# using conditionals.
fun = 3
hacking = 5
if fun < hacking:
print("Not enough fun!")
# Here we have an if statement.
# It says: if the value of fun is less than the value of hacking...
# then print "Not enough fun!"
# Did you notice that there is a tab before print in our example?
# This is called a code block.
# The ':' after hacking means the start of the code block.
# And the tab at the start of every line after that means that code
# belongs to that block.
if fun < hacking:
print("This code belongs to the if statement...")
print("That's because there is a tab at the beginning.")
print("This code does not belong to the if statement.")
print("It will run no matter if the statement is true or not.")
# Let's prove it...
hacking = 2
fun = 10
if fun < hacking:
print("Fun is not less than hacking, so this line will never print.")
print("But this line does not belong to the if statement.")
print("So it will print no matter what.")
# Here are the conditional operators you should know.
# You might recognise them from Maths class.
# < - Less than
# > - Greater than
# <= - Less than or equal to
# >= - Greater than or equal to
# == - Equals To
fun = 5
hacking = 5
if fun == hacking:
print("The value of fun is equal to the value of hacking...")
# That's not all! We can also chain if statements together.
if fun < hacking:
print("The value of fun is less than the value of hacking...")
elif fun > hacking:
print("The value of hacking is greater than the value of fun...")
else:
print("The value of hacking and the value of fun are equal...")
# In the above example we can see first we check if fun is less than
# hacking.
# If it is then it runs the code in the block that belongs to it.
# If it isn't, then we go on to the next if statement.
# The next statement checks if fun is greater than hacking.
# If it is then it runs the code in the block that belongs to it.
# If it isn't then it moves on to the last statement.
# The last statement is an 'else'. That just means if it didn't match
# any of the other
# if statements, then run the code in the block that belongs to it.
# In this case, if it isn't greater than or less than then it must be
# equal to, it's the only thing left.
# You can have multiple 'elif's also.
people = 5
capacity = 50
# CHALLENGE 1: Check if the number of people is lower than the capacity.
# If it is, print "success"
# If the number of people is higher than the capacity,
# print "too full"
# If the number of people is equal to the capacity,
# print "maximum people"
# CHALLENGE 2: Set the value of the people variable to 500.
# Then run the same check from CHALLENGE 1 again.
# CHALLENGE 3; Set the value of the people variable to 50.
# Then run the same check from CHALLENGE 1 again.
Showing posts with label Challenge. Show all posts
Showing posts with label Challenge. Show all posts
Saturday, August 5, 2017
Wednesday, July 26, 2017
Gratitude – Final Countdown – Challenge
Sometimes when we are not a specialist in a field, we rely on friends or close people who are willing to help and take their time just because we are connected in many ways, and we can help others with their legitimate doubts, creating some fraternity among those who are studying.
I was trying to resolve one specific challenge regarding programming and I was struggling to understand some connection between some object and variables, besides, of course, the lack of creativity that froze my mind. Moreover, I needed to create a solution using the regular commands in an inventive way, because the solution was not on Google explicitly. Everything to get the “infamous” flag…
Therefore, I tried to reach some friend spreading and widening the challenge to their mind, which, by the way, had the Elite status level – calling for attention and defiance.
When I found Bijan Natividad - http://bumblebij.deviantart.com/ - an admin from a group on Facebook related to JavaScript, I thought – “Today is very difficult to find someone with time and willingness to help newbies, but I will try”. Talking to him and with other friends from Brazil, Germany, and other countries, we were starting to solve, sometimes just trying to check what is not the logical path to find the flag, other times just trying to connect with the XMLHttpRequest using Javascript provided, which was connected with 5 different links providing on every 10 seconds 5 different codes.
Kembolle Amilcar gave to me some enlightenment about what could be the trigger and what couldn’t be, and as always, his pertinent comments helped me a lot.
https://www.linkedin.com/in/kembolle/?ppe=1
Haoni Hashimoto also helped me in another challenge where we had to decrypt two hexadecimal using XOR as a means of doing a parity check. A final bitstring which created parity with a meaningful message. If you XOR the bits together, you can tell if the message is connected with the main mission.
https://www.linkedin.com/in/haoni-hashimoto-6b634068/
Bijan Natividad just explained how was simple to him to solve – the Final Countdown Challenge - using Javascript – i.e, inserting the code into the console where the loop worked through the link waiting to get all five codes and at the end, changing from asynchronous to synchronous, get the 200 ok and parsing the 5 codes into the final link, solving the puzzle with ability. Here I have to point that patience is a great virtue which we can find in some friends.
https://www.linkedin.com/in/haoni-hashimoto-6b634068/
Bijan Natividad just explained how was simple to him to solve – the Final Countdown Challenge - using Javascript – i.e, inserting the code into the console where the loop worked through the link waiting to get all five codes and at the end, changing from asynchronous to synchronous, get the 200 ok and parsing the 5 codes into the final link, solving the puzzle with ability. Here I have to point that patience is a great virtue which we can find in some friends.
Thus, I am here to thank all my friends, represented by this two Friends, Kembolle from Brazil and Bijan from the Philippines, proving that there is a force, a collaborative force where we can rely on and evolve. My gratitude.
Afonso Henrique Rodrigues Alves
07/26/2017
ps.
Now, I am studying much more JavaScript because I am finding at some "Find the Flag" how important is this language as a connection to injection or leaked information.
Subscribe to:
Posts (Atom)
