Eulerean tour 1

This is a simple solution that takes a list of nodes and
outputs a graph as a list of tuples representing edges between
nodes that have an Eulerean tour.

def edge(x, y):
    return (x, y) if x < y else (y, x)

def create_tour(nodes):
    # a very simple solution could just connect
    # the first node with the second node
    # second with third... and the last with the
    # first
    tour = []
    l = len(nodes)
    for i in range(l):
        t = edge(nodes[i], nodes[(i+1) % l])
    return tour

From Udacity-cs215 Intro to algorithms by Michael Litman.


Hello jupyter notebook -> html

What am I doing here?

I have decided to use jupyter notebooks to present some things that I find useful. For the moment, I will stick to the wordpress blog platform, but I am in the progress of creating a website using flask and put everything there.

Convert jupyter notebook to html

In the terminal, go to the relevant folder and type:

jupyter nbconvert --to html --template basic jupyter_to_html.ipynb

The --template basic is used to avoid including lots of CSS lines that would interfere with the wordpress’s CSS. The page remains unresponsive for some time if I do not use this command.

Paste the generated html in wordpress

Using the HTML interface, paste the generated jupyter_to_html.html code.

Adding CSS

The disadvantage for not including CSS makes the use of jupyter notebooks pointless.
In prooffreaderplus, it describes how to use a CSS stylesheet to make the jupyter notebook look pretty:

<style type="text/css">
.highlight{background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .1em;padding:0em .5em;border-radius: 4px;}
.k{color: #338822; font-weight: bold;}
.kn{color: #338822; font-weight: bold;}
.mi{color: #000000;}
.o{color: #000000;}
.ow{color: #BA22FF;  font-weight: bold;}
.nb{color: #338822;}
.n{color: #000000;}
.s{color: #cc2222;}
.se{color: #cc2222; font-weight: bold;}
.si{color: #C06688; font-weight: bold;}
.nn{color: #4D00FF; font-weight: bold;}

I do not use this right now.


This first blog post only includes Markdown, and using jupyter notebooks to write in Markdown and then convert to html is really useful.

Have a look here at github and predictablynoisy and prooffreaderplus