100 Days of Coding – Day 6

My 100 Days of Code Repository

Today once again continued with the redesign (or restructure if you will) of the Fantasy Grounds XML to PDF Project I’m working on. Yesterday, I populated the ‘Info’ section and made some basic upgrades.

Today was the redesign of abilities – which for the record was much cleaner and simpler than the old way I had doing it. The old way had about 7 or 8 lines of code for each ability score, where as now, there is a 12 line function that handles it all. Also moved into coins as well.

Tomorrow I’m not sure what will be up – I’m going to try to get my coding in, but I also have a band gig (hence the musical part of MusicalCoder) which will take me from after work until after midnight… So Day 7 may end up being Saturday!

Until tomorrow!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 5

My 100 Days of Code Repository

First – I bet these are boring!!! I understand, but these are mainly for my to use to personally track what I did (and since tweets are so limited, it seemed easier to write about what I did here, and then tweet the web url so others can read it, if they want!)

Today continued with the redesign (or restructure if you will) of the Fantasy Grounds XML to PDF Project I’m working on. Yesterday, I finished laying out and designing the character dictionary set with all the necessary fields.

Today, I populated the ‘Info’ section. First true upgrade went in. The first time I was designing this, I skipped the Multi-class option – just giving you a “Not currently supported” if a character was multi-classed… But no more… currently, it will print the shortcut names each class the character has levels in (using either 3 or 4 letters). So happy with that.

Tomorrow will be redesigning the ability processing!

Until tomorrow!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 4

My 100 Days of Code Repository

Today I spent some time refreshing myself on Python dictionaries, and laid out a design_blank_character function, that basically builds a blank character for all the needed info, into a dictionary of dictionaries.

By doing this, I’ll be able to keep the character in memory, and print out multiple pdf pages by choice (lets say I have a pdf for the players, and a pdf for me, the DM) if I choose to do a non FG session!

Today did take me a little bit to get into the flow, but once I did, I felt good, and didn’t actually stop until after midnight! All in all, a good coding session!

Until tomorrow!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 3

My 100 Days of Code Repository

Another short blog post – still working on the same program. Started making changes to help readability of code – as well as I realized there are a couple of PDFs I could create – so I’m going to be modifying the xml pull process to store in variables, instead of loading the PDF string automatically.

But another day of coding done!!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 2

My 100 Days of Code Repository

So day 2 finds me continuing to work on this Fantasy Grounds project (continuing from Day 1). This looks like it may take a few days to code it all out (depening on how many days I put more than an hour in!)

I’m happy with myself from the standpoint that I haven’t had to look to the web too often to refresh my python skill, since I hadn’t used it much recently. I realize I’m going to have to think about what I want to do with this once its completely working… right now it’ll only work for me as I’m ‘hard’ coding certain directories and such.

I think, when I’m done with it completely, I might turn it into a web app and host it so others could use it to make their d&d stuff… maybe even ask for a contribution!

Which of course, will force me to learn how to make python web apps!!!

Onwards and Upwards!

Until tomorrow!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 1

So – the first project I’ve added to my 100 days of coding is a pdf maker! Not that type of pdf maker…

I am a geek/nerd/moniker of choice, and as such, am an avid Dungeon Master for DnD! As such, I purchased a program called Fantasy Grounds that I’ve started using to manage my campaigns. However, I’m also currently playing face to face, and as such, wanted to be able to track my players characters and print out sheets for them!

While Fantasy Grounds is great at tracking – it’s pretty lousy at print the character sheet. But, they provide an export to xml for your characters, so I decided to make a python program that will read this xml file, and make an fdf file that I can then merge into the standard DnD 5E character sheet.

I did some research, found the additional programs I need to make this happen, and have gotten started. You can check out my github page for my progress My Fantasy Grounds PDF Maker GitHub

Until tomorrow…

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding — Day 0

So I’ve sort of let life and work take me by storm, and haven’t written anything on here in months… which is a shame, as I’ve bought a new computer, installed Ubuntu-Mate as well as a new python install, all of which I should be posting about…

But I recently read an article here about coding for 100 days in a row, and I really wanted to make an effort to do this – to not only improve myself, but also make a stronger effort to learn various programming algorithms and languages.

So – for day 0, I spent the time learning git – and made a couple of commits to a project I was using, and had made changes to on my local system – but hadn’t been using git for… so I changed that… forked the repo, cloned it to my PC, made the modifications in 2 separate branches, and then commited said changes and made pull requests…

All that was a bit of a process as I had to set up SSH key for GitHub and what not – but it worked out at the end of the day…

I have several projects in mind, as well as working on freeCodeCamp as well…

Here is hoping the next 100 days are eventful! (At least for programming!)
Never B Flat, Sometimes B Sharp, Always B Natural

Regular Expressions, Part III (Phone Number – basic)

As I promised, here is another discussion about regular expressions, and more specific, phone numbers. The first part of this, I’m going to discuss the HackerRank Python Regex problem on validating phone numbers with regular expressions, but as its a very simplistic case, I’m going to expand on it.

Because, it’s pretty simplistic, I’m simply going to show you the code for the Hackerrank problem.


Since it’s so simplistic, I figure I’ll just go over the whole thing. First, notice the ^ and $ anchors. Again, these refer to the fact that everything is occurring on the evaluation. I’ll explain this better last…

The next piece is [789]. This simply tells us that we are looking for a 7, 8, or 9 as the first digit.

Next is \d{9} which is 2 parts, the first \d meaning we are looking for any digit, and the second {9} meaning we are looking for exactly 9 of them.

All that combined, along with the anchors I mentioned before, means that we are searching the input we are using regex on for 10 numbers, starting with a 7, 8, or 9. Nothing else will generate a match.

Now, suppose we didn’t care about starting with a 7, 8, or 9. The first thing we would do is drop the [789] and change {9} to {10}. Simple enough!

However, lets make this a bit more realistic. This makes no allusion to formatting… it doesn’t quantify the real formatting for a North American phone number. So let’s sat that formatting (which I’m simply going to refer to North American Phone Numbers as phone numbers).

A little education for us here. Phone numbers are divided into 3 sections. The first 3 digits are referred to as the area code. The next 3 digits are referred to as the Central Office code, frequently called the exchange, and then the last 4 digits are the subscriber number. Now there are some rules for the area code and the exchange.

For both the area code and exchange, the first digit must be between 2 and 9 (thus no 0’s or 1’s). The next 2 digits can be anything, however, for the exchange, they can’t be 1 and 1 (as those are for special services such as 911 or 411, etc). For simplicity, I’m going to leave it at that, and not worry about the extra formatting or extensions and such… this is more for a basic understanding…

We know we will use our anchors still, so ^$ go in immediately. Also, the last 4 digits are simple as well. I’m going to use parenthesis in the regex to simply group everything, so we know which sections are for which. We know that \d{4} will work for our last for digits, so we’ll add those.

So we currently have ^(\d{4})$. Now, the area code is pretty simple. It’s 3 digits, but can’t be 0 or 1, so that means [2-9]\d{2}, so we’ll add that in the front, giving us ^([2-9]\d{2})(\d{4})$. Now comes the hard part.

The exchange is a bit more difficult, because it can’t be #11. It can be #1#, or ##1, so it has to be broken down into multiple pieces.
The first piece is if the 2nd digit is a 1. That would be [2-9]1[02-9]. Remember the first digit can’t be 0 or 1 (always, from the above rule). We already stated that in this piece, the second digit is 1, which means the third piece can’t be 1, thus the [02-9].
Now the next piece will be the 3rd digit being 1. The nice thing is all the other rules apply, so all we need to do is switch the 2nd and 3rd numbers, giving us [2-9][02-9]1.
Now the last piece is the one that makes logical sense. If we’ve covered the case where the 2nd digit is 1, and the case where the 3rd digit is 1, then all we need to do is cover the case where neither digit is 1. We already have that rule [02-9], so all we do is put that in both spots, giving us [2-9][02-9][02-9]. There are all 3 pieces. Now we just put them together.

If you remember back in the Roman Numerals post, we talked about alternation, or the pipe |. That is basically a way to say this or that, and would look like this|that. All we have to do is combine the 3 pieces, putting that alternation between each piece, giving us [2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9][02-9].

Which gives us our final result of ^([2-9]\d{2})([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9][02-9])(\d{4})$. All done.

For the record, I tested the above on regexr.com, adding the following phone numbers: 5123456789 and 5123114567. It only matched the first one! Yay!

Until next time!

Never B Flat, Sometimes B Sharp, Always B Natural

Regular Expressions, Part II (Roman Numerals)

So, lately with HackerRank, I’ve been going over their regex section in python. I thought I’d review some of what I’ve done, for my own sake to review later on down the road!

Here are some of the regex problems I’ve solved… For the record, I’ve modified the original post of this to what it is now – before, I just listed the regex expression, and what the whole expression did… Now, however, I’m explaining what each bit does for my own understanding! I’m also reducing how many I do per post so there will be more posts about it as I go into a deeper detail for them…

The one that I will be discussing today is a regular expression to validate roman numerals.

For roman numerals, the expression is:

We start of with ^ which is called an anchor and it is used to say we are starting from the beginning of the string we are comparing…

Next is M{0,3} which tells us we are expecting the letter M between 0 and 3 times. Which covers any thousands digit.

The next piece is (CM|CD|D?C{0,3}) and it involves our first grouping. The parenthesis defines our grouping which can be used to later to pull out this specific information. We next have letters between pipes (|), which is called alternation. It’s saying we are next looking for CM or CD or D?C, which the question mark here means that the D is optional – meaning we are looking for C alone, or DC together, and that is followed by {0,3} which, like before, means we are looking for 0-3 of… so that whole grouping says we are for CM (900), CD (400), or D (500) with up to 3 C’s… which covers hundreds portion of any number over 99.

The piece after this is (XC|XL|L?X{0,3}) and it is also a grouping (which again, we can pull from later). This section covers our 10’s digit, and just like the last grouping, is looking for XC (90) or XL (40) or L (50) and/or up to 3 X’s (10 each).

The last piece is (IX|IV|V?I{0,3})$ and covers our 1’s digit. It’s also grouped so we can pull out this information later. Just like the prior 2 groups, it’s looking for IX (9) or IV (4) or V (5) and/or up to 3 I’s (1 each). The last piece, the $, is referring to the end of the line.

So if we put this all together, we are saying in the line we pass in, if there is a character that isn’t an M, D, C, L, X or I, this will fail. Also, if proper characters aren’t in the proper order, this will fail, and if there is anything after the lowest number, it will fail.

All in all, a pretty neat expression!

Next time, I’ll go over phone numbers.

Never B Flat, Sometimes B Sharp, Always B Natural


Once again, it’s another installment of JACU (or Just Another Computing Update)!

HackerRank: I currently have 1577.91 points, and am ranked 793. That means I’ve earned 570 points, and risen 698 ranks! Not bad. I’m almost through regex in python (of which there will be a couple of posts for)

CodeWars: I’m currently at 5kyu with 154 honor points, and am ranked # 10923 [93%]. I’ve increased 1 kyu, and 63 honor, as well as risen 8374 ranks (and 10%). I’m going to work on these a bit more as well.

CheckIO: I’m currently level 9, with 543/750. I completed the last 2 puzzles in Home, as well as finished Elementary, and have started on O’Reilly. There are some puzzles that are locked, since I’m not a paying member… I’ll think about remedying that…

CodeEval: I’m currently at 70 points – but haven’t completed the challenge, as they don’t tell you what is wrong, so I’m not sure where the bug is in my submission (I get the correct answer on my system), so I’ve sort of stalled on this one… I’ll be coming back to it soon.

Project Euler: Using HackerRank’s Project Euler contest, I’m ranked 1307th/48187, so that’s a good increase of 1608 ranks, and about 5000 more contestants joined, so I’m going strong here. I’m currently working on Project #23 (which has been solved on the PE site, just having an issue solving 1 test case, and not getting any help on the details…

So that is where I’m at! I will be blogging about my daily programmer exercises, once they are closed!

The More I Drink – Blake Shelton
Never B Flat, Sometimes B Sharp, Always B Natural