Solution for long repeat on checkio

I figured I’d share my solution for Long Repeat on Checkio. I got up this morning and had a few moments to solve. Did some research and found the groupby method from Itertools… there was an example online on how to use so I drew largely from that.

from itertools import groupby

def long_repeat(line):
        groups = groupby(line)
        result = [(k, sum(1 for _ in v)) for k, v in groups]
        occ = []
        for _ in result:
            k, v = _
        return max(occ)
        return 0

if __name__ == '__main__':
    # These "asserts" using only for self-checking and not necessary for auto-testing
    assert long_repeat('sdsffffse') == 4, "First"
    assert long_repeat('ddvvrwwwrggg') == 3, "Second"
    assert long_repeat("") == 0
    assert long_repeat("abababaab") == 2
    print('"Run" is good. How is "Check"?')

MongoDB, standard library, considering rolling my own blog again…

As you well know, I started out rolling my own blog and couldn’t finish due to being an extreme n00b. Now that I’ve made fairly significant progress with my FlaskCasts site I am slightly considering transferring all of this over to a strictly Python blog….but….IDK. We will see.

I got hung up on a couple of things tonight trying to get my flask casts site up off of the ground. First off I really got hung up on name vs id in my form fields. Apparently Flasks Request isn’t too fond of having both a name and an ID…and playing around with Bootstrap the ID tag was automatically placed so I was stuck for several minutes…about an hour..kind of sucked. Again…SOMETHING SMALL! But…I just wrote about it…so all the while I kept telling myself IT HAS TO BE SOMETHING SMALL AND STUPID….ALWAYS IS.

    def update(post_id, title, content):
        mongo.db.posts.update({'_id': post_id}, {'$set': {"title": title, "content": content}})

Then I ran into an issue trying to update by post…I forgot the $set (loss for a word here) and ran into some issues…luckily solved em all.

Next up…the create method. This one will be a little tricky because Ive designed the site to show posts by the slug for SEO reasons…so I won’t be able to have duplicate slugs in the database. The slugs are generated with the object/Post itself based on the title….however…I’m leaving myself the option of changing the title/content if need be. This is a simple site so…a lot of common functionality really isn’t required but its fun to think through the possibilities.


Lets do some Checkio…

30 minutes later


and it beat me…lol


working on it,…..


Preparing for the future…

Basically all I am doing is focusing on my future, by learning new skills in the present. It’s easy to get sidetracked and think of new and interesting ideas, but staying focused is the key. One of the things I have been doing is browsing Upwork projects to see what people are looking for in developers/projects. I figure if I can sift through the postings and do my best to learn as much as I can about the technologies people are paying for, my chances of being successful when I am ready to bid. When will that be? I plan on trying to roll out several of my own projects as portfolio pieces and build up a solid amount of content and once I can find a project that I am 100% confident I can fit into my schedule and accomplish I will bid. My goal is 1 year.

I’ve also had a few mobile app ideas float through my head, so learning about REST-ful API’s is on the agenda in the coming months.

As far as my FlaskCasts site…I made a few minor adjustments today. Found a couple of minor bugs I need to work out once I get a minute. Plan to work on it quite a bit tomorrow evening.

Thanks for reading!


I tinkered with the site a little here and there but nothing ground breaking today. I am just slowly piecing it together and hope to release: 9/6/17 with a couple of videos.

I love, it’s a cool  site that provides you with puzzles to solve in Python. Great learning tool. I embarked on The Angles of a Triangle today.

Never was all that great at trig but I love learning python so I tackled this one. Had help from this site:

And a library I found called Triangle Solver… 

Checkio doesn’t support external packages but I was able to dig through the code and pull out what I needed to solve this one.  Here is my solution:

from math import pi, acos

def sss(a,b,c):
    degree = pi / 180
    assert a + b > c and b + c > a and c + a > b
    A = acos((b**2 + c**2 - a**2) / (2 * b * c))
    B = acos((c**2 + a**2 - b**2) / (2 * c * a))
    C = 180 - (A/degree) - (B/degree)
    return A/degree, B/degree, C

def checkio(a, b, c):
        A, B, C = sss(a, b, c)
        result = [
        return sorted(result)
        return [0, 0, 0]

#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
    assert checkio(4, 4, 4) == [60, 60, 60], "All sides are equal"
    assert checkio(3, 4, 5) == [37, 53, 90], "Egyptian triangle"
    assert checkio(2, 2, 5) == [0, 0, 0], "It's can not be a triangle"
    assert checkio(5, 4, 3) == [37, 53, 90]

Flask application structure…

One of the beautiful things about Flask is the freedom to do whatever the hell you want. Unfortunately, for me as a novice, this can be a huge disadvantage at the same time. Not knowing all of the best practices can cause some unnecessary headache. Lucky for me there are a lot of blog entries out there to help get this off the ground.

Blueprints is a flask feature that allows you to organize your app in a modular way. Each “section” will act almost as if it is it’s own application. I took a screenshot of my current directory structure to show you what it looks like. So the project itself would be considered a repository,

and will end up on github at some point as I make more solid plans.

Right now I just wanted to get something running even if it is technically just a simple and basic “Hello World.”

Currently the file contains:

from flaskcasts import app['DEBUG'])

When ran, it then goes to the flaskcasts directory since it is a module and runs the code in

from flask import Flask

app = Flask(__name__)


from .views.home import home

This will go to the home blueprint and execute that code:

from flask import Blueprint

home = Blueprint('home', __name__)

def index():
    return "Welcome to the Index"

The only other file is and it basically holds the DEBUG=True boolean only.


Structurally, for a very basic application that is only going to feed videos from a YouTube or similar service, this should suffice.