How do I get colours and more control over spacing in the algorithmic package like this:

I tried this which looks good, but has numbers:
\begin{enumerate}
\item Create the cumulative sum of probabilities for each care type, thus defining the interval width
\item \textcolor{blue}{for} jj=1:m \textcolor{gray}{\% where m is the number of nurses}
\item Choose care type
\item \hspace{3cm}Randomly select care length ($n$) based on care type
\item \item \textcolor{blue}{for} ii=1:n \textcolor{gray}{\% where n is the sequence length}
\item\hspace{3cm} Generate a random number $w$
\item \hspace{3cm}Check into which cumulative probability interval $w$ falls and choose the corresponding surface category
\item update ii=ii+1
\item update jj=i+1
\item \textcolor{blue}{end}
\item \textcolor{blue}{end}
\end{enumerate}
But using algorithm
\documentclass{article}
\usepackage{color}
\usepackage{algorithmic}
\begin{document}
\begin{algorithmic}
\STATE\COMMENT{Create the cumulative sum of probabilities for each care type, thus defining the interval width}
\WHILE{jj=1:m} \% where m is the number of nurses
\STATE\COMMENT{Choose care type}
\STATE\COMMENT{Randomly select care length ($n$) based on care type}
\WHILE{ii=1:n} \% where n is the sequence length
\STATE\COMMENT{Generate a random number $w$}
\STATE\COMMENT{Check into which cumulative probability interval $w$ falls and choose the corresponding surface category}
\ENDWHILE
\ENDWHILE
\end{algorithmic}
\end{document}
Looks nasty, like this:


mcodenumbers lines of listings only if you addnumberedas an option to the package. You can turn off numbering for a single listing by addingnumbers=noneas an optional argument to that listing, or you can have it off by default (removenumberedfrom the package options) and number only those listings you want to, by addingnumbers=left,numberstyle=\tinyto the optional arguments of the listing. You can also use\lstsetin the document to change the behaviour of all the subsequent listings. – Torbjørn T. May 05 '13 at 10:53numbers=left, numberstyle={\tiny \color{black}}, numbersep=9pt,from the code presented as the first answer. – May 05 '13 at 10:55matlab-prettifierpackage; see this answer of mine. – jub0bs Feb 10 '14 at 13:21