{#
I love craft because the templating language is so expressive, but it does lead to a big ball of WTF...
#}
{#
Here were getting the highest year set for any award, also the lowest year. The base year needs to be set as well for scope reasons.
#}
{% set topYear = craft.entries({ section: "awards", order: "awardYear desc", limit: "1", }).first().awardYear %}
{% set bottomYear = craft.entries({ section: "awards", order: "awardYear asc", limit: "1", }).first().awardYear %}
{% set baseYear = 1 %}
{#
We are using this loop to figure out what our base year is. Essentially what is the closest year, ending in ***0 or ***5, that is directly below our topYear
#}
{% for i in 1..5 %}
{% if (topYear - i) % 5 == 0 %}
{% set baseYear = topYear - i %}
{% endif %}
{% endfor %}
{#
Now we're figuring out how many times we need to loop to hit all our award years
#}
{% set remainder = (topYear - bottomYear) % 5 %}
{% set loopCount = ceil(((topYear - bottomYear) / 5)) %}
{% if remainder == 0 %}
{% set loopCount = loopCount + 1 %}
{% endif %}