Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {% set testaus = namespace(list=[1,2,3,4,5,7,8,5,-5]) %}
- {% set handled = namespace(list=[]) %}
- {% set break = namespace(found=0) %}
- {% set rank = namespace(slot=0) %}
- {% set time = namespace(slot=0) %}
- {% set output = namespace(value=[]) %}
- {#For-loop, hinnat aikajärjestyksessä (timeslot-järjestys)#}
- {% for price in testaus.list %}
- {#Tarkasteltava aikaslotti muistiin#}
- {% set time.slot = loop.index0 %}
- {#For-loop, hinnat suuruusjärjestyksessä (rankslot-järjestys)#}
- {% for price2 in testaus.list|sort %}
- {% if price==price2 and break.found==0 %}
- {#Tarkasteltava rank-slotti muistiin, kun löytyy match#}
- {% set rank.slot = loop.index0 %}
- {#Tarkastetaan onko rank-slot jo käytetty (samansuuruiset hinnat)#}
- {% for x in handled.list %}
- {% if rank.slot==handled.list[loop.index0] %}
- {% set break.found=2 %}
- {% endif %}
- {% endfor %}
- {#0:lla täysin uusi ilmentymä, 2:lla jo listalla oleva ilmentymä ja mennään indexin ohi#}
- {% if break.found==0 %}
- {% set output.value = output.value + [loop.index] %}
- {% set handled.list = handled.list + [rank.slot] %}
- {% set break.found=1 %}
- {% elif break.found==2 %}
- {% set break.found=0 %}
- {% endif %}
- {% endif %}
- {% endfor %}
- {#Nollataan löytöapuri#}
- {% set break.found=0 %}
- {% endfor %}
- Alkup: {{testaus.list}}
- Ranks: {{output.value}}
Advertisement
Add Comment
Please, Sign In to add comment