13 KiB
Python Track Comments
This page represents all my comments from my solutions currently hosted on Exercism.io. You can view my profile here. The reason for this is simply to have a place where I can collect my comments, as well as just have some fun with Python and webscraping. Exercise file and exercise submission links will be provided for each and every exercise. This file is for the Python track, contains 48 submissions, 18 of which have comments. This file was built on 24-07-2019 at 04:10:14 UTC.
Word Count
Link to File | Link to Submission
Not exactly proud of this one really. I had to use regex to do the splitting as I couldn't think of a way to split on both arbitrary length whitespace AND punctuation. Luckily, the string library has access to all the punctuation I needed, so I just rolled with it. This isn't exactly the most elegant solution I could come up with, but it's definitely short and that's what matters to me. It uses list/dictionary comprehension, which is huge to me, so it should probably be moderately fast in the long run.
Sieve
Link to File | Link to Submission
Hello World
Link to File | Link to Submission
Leap
Link to File | Link to Submission
Reverse String
Link to File | Link to Submission
Isogram
Link to File | Link to Submission
I'm kind of annoyed that there is no other way to do it that is 2 lines that doesn't have it calculate string without the spaces and hyphens twice, but whatever.
Pangram
Link to File | Link to Submission
RNA Transcription
Link to File | Link to Submission
ISBN Verifier
Link to File | Link to Submission
Hamming
Link to File | Link to Submission
Gigasecond
Link to File | Link to Submission
Bob
Link to File | Link to Submission
Yacht
Link to File | Link to Submission
Run Length Encoding
Link to File | Link to Submission
Meetup
Link to File | Link to Submission
I think I should have changed up the constants to be dynamic so the solution would be smaller, but honestly, in the end it's probably better to go with a pretty and longer solution.
I feel like my else method of handling the week parameter was pretty weak.
Armstrong Numbers
Link to File | Link to Submission
Rotational Cipher
Link to File | Link to Submission
Difference Of Squares
Link to File | Link to Submission
Anagram
Link to File | Link to Submission
I'm not sure if my .lower() optimization really made a difference, as it's duplicating the list. Originally, I was making .lower() on every single word, so I changed it, but now I'm wondering if it really made a difference as now I'm introducing enumerate and a second list of words. It got a bit longer (3 -> 4 lines), too...
Allergies
Link to File | Link to Submission
I took a bit more time with this one because I wanted to properly solve the problem you encounter when a score above 255 is entered, meaning a value not present is given. It took me a couple of minutes to remember how this all worked, but in the process, I learned a couple of long-forgotten math principles.
Series
Link to File | Link to Submission
I'm kind of bad at math and thinking in general, so I kind of just skimmed the thinking part via itertools. Oops.
Robot Simulator
Link to File | Link to Submission
Atbash Cipher
Link to File | Link to Submission
The extra grouping and sanitization was super confusing to figure out, I had honestly no idea what it wanted from me at that point.
Sum Of Multiples
Link to File | Link to Submission
Acronym
Link to File | Link to Submission
Not exactly excited to be using regex and string again for an exercise, but if I don't want to be spending forever on it, I suppose this is a far better solution. Regex just feels like cheating sometimes, haha.
Say
Link to File | Link to Submission
This exercise should be renamed 'Cardinal Numbers' or something along those lines. 'Say' is too broad and doesn't really mean anything. Anyways, my solution is honestly pretty hard to understand, some of the more complex code at the bottom handled was just working out the quirks that come with recursion (which was mostly a random solution I came up with, I did not plan on using recursion, I was expecting to have to make more than one function).
Kindergarten Garden
Link to File | Link to Submission
Added comments for clarification on what stuff does. For some reason Pytest fails, I believe it's got some kind of problem with it, as only 1 of the 5 tests fails, and I don't exactly see the reason why, so I have reason to believe the pytest itself is incorrect.
Grade School
Link to File | Link to Submission
Flatten Array
Link to File | Link to Submission
I decided that the empty nested tuple thing wasn't worth trying to fix, it's such a dumb test case.
Roman Numerals
Link to File | Link to Submission
Space Age
Link to File | Link to Submission
I don't like this solution since the measurements are off and they don't provide proper timings. I went and got my measurements (Oribital Sidereal Period (days) / ratio) from the Nasa factsheet here: https://nssdc.gsfc.nasa.gov/planetary/factsheet/neptunefact.html
Grains
Link to File | Link to Submission
Luhn
Link to File | Link to Submission
The pytester looks wrong to me. I tested mine online and double checked that it's doing it correctly, and the solutions on the Instructions page look right, yet mine do not solve test correctly through the pytester. I dunno, it feels weird for it to be wrong for such a simple problem.
Scrabble Score
Link to File | Link to Submission
Robot Name
Link to File | Link to Submission
Matrix
Link to File | Link to Submission
Twelve Days
Link to File | Link to Submission
I forgot that a couple things could be omitted, and decided to trim the nouns so that it's smaller. Script went from 10 or 11 lines to 7 lines for building the string.
Clock
Link to File | Link to Submission
Grep
Link to File | Link to Submission
I liked this exercise honestly. I learned about some new modules and methods, for example, while trying to create the invert flag, I was looking into how to negate the matching function, and the functools module allows one to create a wrapper that can negate any function you pass through it.
Tournament
Link to File | Link to Submission
This code is honestly pretty cryptic. I added comments for the portions that honestly make sense. I'm hoping it looks good enough for people to understand how the formatting works. It uses ljust and rjust built-in string methods so that the tally supports up to 99 matches before it breaks. Maybe I should add some code to make variable spacing?
Protein Translation
Link to File | Link to Submission
Two Fer
Link to File | Link to Submission
Collatz Conjecture
Link to File | Link to Submission
Truly cursed.
Markdown
Link to File | Link to Submission
Raindrops
Link to File | Link to Submission
Rest API
Link to File | Link to Submission
Comments are included in the code.
High Scores
Link to File | Link to Submission