TOP 10

Z Wiki UnArt Slavičín
Skočit na navigaciSkočit na vyhledávání

Verze 1

:global x 0
:global myParent "wifi"
:global badParent "stahovaci"
:global userBytes 0/0
:global users 0,0
:global userDownload 0
:global userUpload 0
:global maxDownload 0,0
:global maxUpload 0,0
:global top 10
:global hArray1
:global hArray2
:global hArray3
:global a
:global b
:global c
:global d
:global e
:global f
:global hInt

/queue simple

:foreach i in=[find parent=$badParent] do={

  set $i parent=$myParent;

}

:foreach i in=[find] do={

  :if ([get $i parent]=$myParent) do={

    :set userBytes [get $i bytes];
    :local slashPosition [:find $userBytes /];
    :set userDownload [:pick $userBytes ($slashPosition+1) [:len $userBytes]];
    :set userUpload [:pick $userBytes 0 $slashPosition];
    :set users ($users + $x)
    :set maxDownload ($maxDownload + $userDownload)
    :set maxUpload ($maxUpload + $userUpload)
    :set hArray1 $maxDownload
    :set hArray2 $maxUpload
    :set hArray3 $users

    :for i from 0 to=([:len $maxDownload]-2) do={

      :for j from ($i+1) to=([:len $maxDownload]-1) do={

        :set hArray1 0;
        :set hArray2 0;
        :set hArray3 0;
        :set a [:pick $maxDownload $i ($i+1)];
        :set b [:pick $maxDownload $j ($j+1)];
        :set c [:pick $maxUpload $i ($i+1)];
        :set d [:pick $maxUpload $j ($j+1)];
        :set e [:pick $users $i ($i+1)];
        :set f [:pick $users $j ($j+1)];

        :if ($a<$b or $c<$d) do={

          :set hInt $a;
          :set a $b;
          :set b $hInt;
          :set hInt $c;
          :set c $d;
          :set d $hInt;
          :set hInt $e;
          :set e $f;
          :set f $hInt;

        }

        :set hArray1 ([:pick $maxDownload 0 $i] + $a);
        :set hArray2 ([:pick $maxUpload 0 $i] + $c);
        :set hArray3 ([:pick $users 0 $i] + $e);

        :if (($i+1)<$j) do={

          :set hArray1 ($hArray1 + [:pick $maxDownload ($i+1) $j]);
          :set hArray2 ($hArray2 + [:pick $maxUpload ($i+1) $j]);
          :set hArray3 ($hArray3 + [:pick $users ($i+1) $j]);

        }

        :set hArray1 ($hArray1 + $b);
        :set hArray2 ($hArray2 + $d);
        :set hArray3 ($hArray3 + $f);

        :if (($j+1)<[:len $maxDownload]) do={

          :set hArray1 ($hArray1 + [:pick $maxDownload ($j+1) ([:len $maxDownload])])
          :set hArray2 ($hArray2 + [:pick $maxUpload ($j+1) ([:len $maxUpload])])
          :set hArray3 ($hArray3 + [:pick $users ($j+1) ([:len $users])])

        }

        :set maxDownload $hArray1
        :set maxUpload $hArray2
        :set users $hArray3

      }

    }

    :set maxDownload [:pick $maxDownload 0 $top]
    :set maxUpload [:pick $maxUpload 0 $top]
    :set users [:pick $users 0 $top]

  }

  :set x ($x+1);

}

:for i from 0 to=([:len $users]-1) do={

  set [:pick $users $i ($i+1)] parent=$badParent;

}
:global x 0
:global myParent "wifi"
:global badParent "stahovaci"
:global userBytes 0/0
:global users 0,0
:global userDownload 0
:global userUpload 0
:global maxDownload 0,0
:global maxUpload 0,0
:global top 10
:global hArray1
:global hArray2
:global hArray3
:global a
:global b
:global c
:global d
:global e
:global f
:global hInt

/queue simple

:foreach i in=[find parent=$badParent] do={

  set $i parent=$myParent;

}

:foreach i in=[find] do={

  :if ([get $i parent]=$myParent) do={

    :set userBytes [get $i bytes];
    :local slashPosition [:find $userBytes /];
    :set userDownload [:pick $userBytes ($slashPosition+1) [:len $userBytes]];
    :set userUpload [:pick $userBytes 0 $slashPosition];
    :set users ($users + $x)
    :set maxDownload ($maxDownload + $userDownload)
    :set maxUpload ($maxUpload + $userUpload)
    :set hArray1 $maxDownload
    :set hArray2 $maxUpload
    :set hArray3 $users

    :for i from 0 to=([:len $maxDownload]-2) do={

      :for j from ($i+1) to=([:len $maxDownload]-1) do={

        :set hArray1 0;
        :set hArray2 0;
        :set hArray3 0;
        :set a [:pick $maxDownload $i ($i+1)];
        :set b [:pick $maxDownload $j ($j+1)];
        :set c [:pick $maxUpload $i ($i+1)];
        :set d [:pick $maxUpload $j ($j+1)];
        :set e [:pick $users $i ($i+1)];
        :set f [:pick $users $j ($j+1)];

        :if ($a<$b or $c<$d) do={

          :set hInt $a;
          :set a $b;
          :set b $hInt;
          :set hInt $c;
          :set c $d;
          :set d $hInt;
          :set hInt $e;
          :set e $f;
          :set f $hInt;

        }

        :set hArray1 ([:pick $maxDownload 0 $i] + $a);
        :set hArray2 ([:pick $maxUpload 0 $i] + $c);
        :set hArray3 ([:pick $users 0 $i] + $e);

        :if (($i+1)<$j) do={

          :set hArray1 ($hArray1 + [:pick $maxDownload ($i+1) $j]);
          :set hArray2 ($hArray2 + [:pick $maxUpload ($i+1) $j]);
          :set hArray3 ($hArray3 + [:pick $users ($i+1) $j]);

        }

        :set hArray1 ($hArray1 + $b);
        :set hArray2 ($hArray2 + $d);
        :set hArray3 ($hArray3 + $f);

        :if (($j+1)<[:len $maxDownload]) do={

          :set hArray1 ($hArray1 + [:pick $maxDownload ($j+1) ([:len $maxDownload])])
          :set hArray2 ($hArray2 + [:pick $maxUpload ($j+1) ([:len $maxUpload])])
          :set hArray3 ($hArray3 + [:pick $users ($j+1) ([:len $users])])

        }

        :set maxDownload $hArray1
        :set maxUpload $hArray2
        :set users $hArray3

      }

    }

    :set maxDownload [:pick $maxDownload 0 $top]
    :set maxUpload [:pick $maxUpload 0 $top]
    :set users [:pick $users 0 $top]

  }

  :set x ($x+1);

}

:for i from 0 to=([:len $users]-1) do={

  set [:pick $users $i ($i+1)] parent=$badParent;

}