libera/#maemo/ Wednesday, 2019-07-10

sixwheeledbeastcan random be used in a loop on the shell without having the same number come up14:15
KotCzarny?14:17
KotCzarnytry: echo $RANDOM14:17
KotCzarnyworks in bash14:17
sixwheeledbeastto avoid xy I need to pull a random list of say 50 integers from a pool of 01-99 . I beleive RANDOM will repeat them if in a loop14:17
KotCzarnyit returns 0-32767 i think14:17
KotCzarnyup to you to scale it to range you need14:18
sixwheeledbeasti want no duplicates14:18
KotCzarnythats not random then14:18
KotCzarnywhat you need is to create an array with 99 elements, then shuffle it14:18
sixwheeledbeastwell I suppose so but that's what i am looking for14:18
sixwheeledbeasti see is array the best way you think?14:19
KotCzarnyotherwise you have to keep different array with 'used' numbers anyway14:19
KotCzarnyand having to scan through it on every new return14:19
sixwheeledbeastI suppose so. I didn't think of it like that. i was hoping for a shell function already there :)14:20
KotCzarnyi havent seen such functionality in bash14:21
KotCzarnyanyway, your problem is 'shuffle deck of cards then deal them'14:21
KotCzarnytaught in schools often14:21
KotCzarnyso there should be lots of examples for different languages14:22
sixwheeledbeastnp array it is then. school?14:22
KotCzarnyya, it10114:22
sixwheeledbeastschool is long behind me we where lucky to have working ones in my era14:23
KotCzarnybut as i've said, google: deal shuffled deck of cards in bash14:23
Maxdamantusor a more interesting way of looking at it: find an information densitity preserving encryption, and encrypt all possible inputs in a predictable sequence.14:26
KotCzarnyor basically: shuffle in bash14:27
Maxdamantusbasically, encrypt(0), encrypt(1), encrypt(2), .. encrypt(n)14:27
sixwheeledbeastyep i am waiting for something to render so can't open a browser at the moment, hence I thought I'd ask the question having used random before.14:27
KotCzarnyswb: but it's better to use any scripting lang, perl/php/python14:27
KotCzarnywhichever you are best in14:28
KotCzarnyat some point you will have to switch to it when adding functionality14:28
Maxdamantusanyway, if you want a sequence of numbers in a random order: seq 99 | sort -R | head -5014:28
KotCzarnywow14:29
sixwheeledbeastonly ever used bash for most things but i can have a look in python if necessary.14:29
KotCzarnyi forgot sort has shuffle14:29
Maxdamantus(`seq 99` is a bit weird; I suspect what you really want is either `seq 0 99` or `seq 100`, which both emit 100 numbers (`seq 99` emits 99 numbers))14:29
sixwheeledbeastoh useful ty :)14:30
KotCzarnyseq -f '%02.0f' 1 99|sort -R14:30
KotCzarnydone14:30
KotCzarnyif you want only 50 of them, add |head -5014:31
sixwheeledbeastoh i see you have used the format flag to have 2sf nice14:33
KotCzarnyMangy_Dog: pink screen on hdmi means hdmi pixel format failed17:20
KotCzarnyerm, wrong chan17:20

Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!