Files
exercism/python/COMMENTS.md
2020-11-16 09:27:25 -06:00

18 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 57 submissions, 24 of which have comments. This file was built on 31-07-2019 at 15:36:13 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.

Here's my pytest output, which looks correct yet it errors anyways: https://gist.github.com/Xevion/87995553d7b078208b5dd1f72371db69

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.

ETL

Link to File | Link to Submission

To this day, the way dictionary and list comprehension works, as in, the order you have to put it, with the nested unpacking (for value in values), it messes with me still to this day. I'm just glad it works, because it's simply amazing.

Prime Factors

Link to File | Link to Submission

Pig Latin

Link to File | Link to Submission

This one was a rather annoying challenge. Just like Pam Beesly, I despise Pig Latin now.

Simple Cipher

Link to File | Link to Submission

I personally had a lot of trouble understanding this exercise at first, I wish the exercise description was more clear on how it worked. The Wikipedia page linked doesn't talk about this strange key-value rotation cipher from hell. Unfortunately, I had to look at someone else's solution before I could figure it out, and I now fully understand how it works and can probably rewrite this off the top of my head (just clarifying, because I don't feel I've accomplished the intent of the exercise if I just copy).

There was one thing that bothered me though: despite us only having a usable set of 26 characters to work with, the instructions asked me to make a key of at least 100 characters. This is kind of crazy if you ask me, as it's completely useless to have a key of more than 26 characters for lowercase only, and even with uppercase (which is specifically NOT supported in this) the maximum useful key value is 52 unique characters.

Additionally, I've changed it so it has translation table like stuff already built. This will incur a time cost if the key is larger than the texts you intend to encode (for example, a 26 character key, and you encode a 5 character text. You will not be using 80% of the key tables generated in the cipher object. The time cost incurred should be negligible and if we're being honest, it doesn't matter that much, if you're using it for anything, your text should be at least 30 or so characters.

If I could make any changes, it would to support upper and lowercase, and then to extend that, punctuation and whitespace, though if you ask me, this would make the cipher easier to break in most cases. I would also change all the variables and methods (except encode/decode) to be privatized.

Scrabble Score

Link to File | Link to Submission

Sublist

Link to File | Link to Submission

50th exercise in the Python Track. Not exactly my favorite exercise, finding sublists in lists. How fun. How exciting. How empowering.

Robot Name

Link to File | Link to Submission

Matrix

Link to File | Link to Submission

Saddle Points

Link to File | Link to Submission

Ugh, the problem with exercises like this is you HAVE to specify if you're passing rows or columns first, in y, x or x, y format, and most of all, please just let us pass back tuples instead of these dumb dictionaries.

Oh, and I totally could have made a decision to do list/dictionary comprehension here, I just kinda got wrapped up in the y, x or x, y stuff. It really trips me out.

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.

Additionally, I learned that filter(None, container) can filter out any and all False (in a boolean context, e.g. None/[]/'') items. I actually used that one.

Otherwise, this exercise was pretty thorough in making one think, and I really had to put my skills to the test to create a scene which I genuinely liked. However, the implementation of overwriting the open() function for the pytests seems kind of rigid and would make debugging difficult for anyone running into weird problems (of which I thankfully did not).

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

Food Chain

Link to File | Link to Submission

Spiral Matrix

Link to File | Link to Submission

There is probably a better, mathematical way of doing this, maybe using recursion, but I'm really bad with numbers, so I just went with an easier but probably slower way to do it.

Ledger

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

Darts

Link to File | Link to Submission