[Code Challenge is] a contest that consists of some typical programming challenges, and other challenges that don’t include any hints and can be quite tricky.
It was formerly known as the Tuenti Challenge and more info about the past editions can be found here (requires login).
After a few minutes of staring at a .c file, I decided this challenge was a good opportunity to learn something new and that I'd do it using Python. I took a Python course a long time ago, but after 7 years I had to Google even the most basic things. Even then, I had a lot of fun re/learning the language and discovering how powerful and convenient it is!
I started the challenge a day late and was the ~300th person to submit the first problem correctly, so I didn't think I'd make it into the top 100. However after a lot of code, sweat and tears I climbed a few positions and ended the challenge at 66th. Then after wrong solutions were reviewed (and mine were all good, yay) I got to the 61st position!
A lot of the problems were really challenging and included concepts I knew nothing about, so being able to do half of them in limited time was great and I'm very happy with how they turned out!These are some of the key concepts that I needed, used or learned to solve each of the challenges. You can find more information about them on their respective pages.
- Reading from an input file using open() and .readlines()
- Writing output to an output file using .write()
- Basic usage of loops, conditionals, variables and data types
- Using range() and enumerate()
- Basic string manipulation (combine, replace characters, reverse, search)
- Basic list manipulation (append, pop)
- String searching
Challenge 3 - The night of the hunter
- Data parsing in three different formats (using partition and split)
- Comparing fractions without using floats
- Using map(), filter() and zip()
- Using dictionaries and the dict() function
- Using def to make functions
- Importing a module
Challenge 4 - Let’s build musical scales
- Careful data manipulation and list iteration (e.g. using [1:] or [::2])
- Filling up a list with elements from another with very specific conditions
- Basic CTF
- Scanning a file and detecting non-ascii characters
- Using a target string to decode the pattern looking for differences between its characters
- Looking up the days of the week in 20 languages with special characters (why)
- Making sure said days had the correct characters (this was painful and took a lot of trial and error and copying and pasting)
- Calculating dates correctly for normal and leap years
- Working with a subprocess, reading its input and outputting commands to it
- Using netcat to connect to a host
- Transversing a maze and listing all possible solutions (paths to an exit) to get the shortest one
Challenge 8 - Awesome Sales Inc.!
- Checking if a graph is connected or not
- Complexity (or why having six nested loops working with giant matrices andd being extremely redundant is not a good idea)
- Using DFS (depth first search) and recursive backtracking
- Detecting if two (large) sprites in an (even larger) map collide
- Calculating all collisions between sprites in a somewhat reasonable time
Challenge 10 - Packets delivery
- Using tcpdump to read the contents of a pcap file
- Sorting the contentes of a pcap file by sequence number
- Finding hexadecimal PNG data and writing the appropriate bytes to a PNG file
If you look at my code please note that for the most part, I had no idea what I was doing and a lot of it will be ugly and full of commented-out stuff. It may be hard to read, but time constraints and the fact that I was using a new language didn't let me get too fancy. In any case, thanks for reading!