Guest User

Untitled

a guest
Jan 17th, 2023
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | Source Code | 0 0
  1. {% set testaus = namespace(list=[1,2,3,4,5,7,8,5,-5]) %}
  2. {% set handled = namespace(list=[]) %}
  3. {% set break = namespace(found=0) %}
  4. {% set rank = namespace(slot=0) %}
  5. {% set time = namespace(slot=0) %}
  6. {% set output = namespace(value=[]) %}
  7.  
  8. {#For-loop, hinnat aikajärjestyksessä (timeslot-järjestys)#}
  9. {% for price in testaus.list %}
  10. {#Tarkasteltava aikaslotti muistiin#}
  11. {% set time.slot = loop.index0 %}
  12.  
  13. {#For-loop, hinnat suuruusjärjestyksessä (rankslot-järjestys)#}
  14. {% for price2 in testaus.list|sort %}
  15. {% if price==price2 and break.found==0 %}
  16. {#Tarkasteltava rank-slotti muistiin, kun löytyy match#}
  17. {% set rank.slot = loop.index0 %}
  18. {#Tarkastetaan onko rank-slot jo käytetty (samansuuruiset hinnat)#}
  19. {% for x in handled.list %}
  20. {% if rank.slot==handled.list[loop.index0] %}
  21. {% set break.found=2 %}
  22. {% endif %}
  23. {% endfor %}
  24. {#0:lla täysin uusi ilmentymä, 2:lla jo listalla oleva ilmentymä ja mennään indexin ohi#}
  25. {% if break.found==0 %}
  26. {% set output.value = output.value + [loop.index] %}
  27. {% set handled.list = handled.list + [rank.slot] %}
  28. {% set break.found=1 %}
  29. {% elif break.found==2 %}
  30. {% set break.found=0 %}
  31. {% endif %}
  32. {% endif %}
  33. {% endfor %}
  34. {#Nollataan löytöapuri#}
  35. {% set break.found=0 %}
  36. {% endfor %}
  37. Alkup: {{testaus.list}}
  38. Ranks: {{output.value}}
Advertisement
Add Comment
Please, Sign In to add comment