Planet DesKel

DesKel's official page for CTF write-up, Electronic tutorial, review and etc.

15 August 2020

CTFLearn write-up: Programming (Easy)

1 minutes to read

Howdy there, welcome to another CTFLearn write-up. Today, we are going through an easy programming challenge. For the entire programming challenge, I’m going to use python programming. You also can use C, C++, Java or even Javascript to solve the challenge.

1) Simple Programming

Link: https://ctflearn.com/challenge/174

Copy the following script and run it with python 2 or 3. All the explanations are on the script.

# initiate the parameters
count = 0
file = 'data.dat'

with open(file) as f:    #Open the file
        l = f.readlines()   #read file by line
        for line in l:
                zero = line.count('0')  #count number of zero in the line
                one = line.count('1')   #count number of one in the line
                '''the condition where the number of '0' is divisible by 3
                OR the number of '1' is divisible by 2'''
                if (zero%3 == 0) or (one%2 == 0):
                        count = count + 1

print("Number of lines: " + str(count))
f.close()

simple programming ans

Conclusion

That’s all for the simple programming on CTFlearn. The post will be updated once I found another new task. See ya :)

tags: ctflearn - CTF - programming

Thanks for reading. Follow my twitter for latest update

If you like this post, consider a small donation. Much appreciated. :)


Vortex


© 2020 DesKel