You can do this by adding this to your CSS.. foo:nth-child(n+3) UPDATED: ul li:nth-child(6n+4), ul li:nth-child(6n+5), ul li:nth-child(6n+6) { border: 1px solid red; } ^ Altough I'm not a fan, it works. http://codepen.io/pacMakaveli/pen/JdWYoM...

If your input is on one line, then you don't need the tr command there. If it isn't, then the tr should precede the sed, as sed processes each line separately, and the solution wouldn't work if the pairs of numbers are on different lines. As for the solution itself,...

I would use v = sum(M(:,1:2:end-1).*M(:,2:2:end),2); Here M(:,1:2:end-1).*M(:,2:2:end) does multiplication: every element of an odd-numbered column of M is multiplied by its neighbor to the right. (This assumes even number of columns, otherwise the process you described is ill-defined.) Then every row is added up by the sum command. On...