No worries! I made a quick mock of my second idea as well. Here we just keep generating numbers until we reach the desired length. (This should follow a similar idea to your pseudo-code, but the method for accounting for multiple of the same number is slightly different)
{"data":{"behavior":{"v":"2","nodes":[{"inputCount":3,"outputCount":1,"name":"Random","behaviorType":"logic.logic.Random","x":450,"y":-192,"group":"","id":"4d9c4ae8ee666647","notes":"1 or 2","n_o":1,"min":1,"max":2},{"gateVal":0,"mode":"equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter2","x":630,"y":-192,"group":"","id":"4d9e68b2cdb80445","notes":"Check if this number is the same as the last","n_o":1},{"inputCount":7,"outputCount":5,"name":"Number List","behaviorType":"logic.data.NumberList","x":990,"y":-192,"group":"","id":"4d9e68b2c9eb8c4b","notes":"A list with repeats of 3 removed","n_o":1,"startVal":[]},{"inputCount":2,"outputCount":2,"name":"Limit Numbers","behaviorType":"logic.NodeGroup","x":810,"y":-192,"group":"","id":"4d9e68b29f5fa742","notes":"Counter","n_o":1,"isMenuItem":false},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":1260,"y":-688,"group":"4d9e68b29f5fa742","id":"4d9e68b30d9e7f45","startVal":1,"tag":"Add","roundMode":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":1440,"y":-768,"group":"4d9e68b29f5fa742","id":"4d9e68b3bb4f4249","startVal":0,"tag":"Total #","roundMode":1},{"gateVal":2,"mode":"greater than or equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter2","x":1620,"y":-768,"group":"4d9e68b29f5fa742","id":"4d9e68b3a5a42e45","notes":"While the current number of repeating items is equal to or over 2, prevent new ones from being added to the list.","n_o":1},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":1800,"y":-624,"group":"4d9e68b29f5fa742","id":"4d9e68b364e04846","notes":"Limiter","n_o":1,"_startVal":0,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":1260,"y":-784,"group":"4d9e68b29f5fa742","id":"4d9e68b353c82d4c","startVal":0,"tag":"Reset","roundMode":1},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":1080,"y":-432,"group":"4d9e68b29f5fa742","id":"4d9e68b36e920847","portId":"4d9e68b29f5fa742i0","tag":"Same","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":1080,"y":-592,"group":"4d9e68b29f5fa742","id":"4d9e68b3649e244d","portId":"4d9e68b29f5fa742i1","tag":"Diff","dataType":2},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":1980,"y":-624,"group":"4d9e68b29f5fa742","id":"4d9e68b32225e141","portId":"4d9e68b29f5fa742o0","tag":"Num","dataType":2},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":1800,"y":-464,"group":"4d9e68b29f5fa742","id":"4dc03169d88c3448","notes":"We still need the list even if the number is not added.","n_o":1,"_startVal":0,"dataType":2},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":1980,"y":-448,"group":"4d9e68b29f5fa742","id":"4dc0c139d02bc74a","portId":"4d9e68b29f5fa742o1","tag":"Fail","dataType":2},{"inputCount":1,"outputCount":1,"name":"Number List Count","behaviorType":"logic.data.ListCount","x":1170,"y":-192,"group":"","id":"4dacbb0d0ba72245"},{"gateVal":8,"mode":"greater than or equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter2","x":1350,"y":-208,"group":"","id":"4dacd2a486986148","notes":"Check if the list is the desired length (8)","n_o":1},{"inputCount":1,"outputCount":0,"name":"Message","behaviorType":"logic.components.Message","x":1530,"y":-192,"group":"","id":"4dad4e4c39442048","notes":null,"n_o":0,"msg":"Again","route":"SendToSelf"},{"inputCount":0,"outputCount":1,"name":"Once","behaviorType":"logic.triggers.Once","x":270,"y":-208,"group":"","id":"4dc126f24b022d4d","resetOnLevelStart":false},{"inputCount":0,"outputCount":1,"name":"Mailbox","behaviorType":"logic.components.Mailbox","x":270,"y":-144,"group":"","id":"4dc1c5e4e4987b43","msg":"Again"}],"links":[{"input_id":"4d9c4ae8ee666647i0","output_id":"4dc126f24b022d4do0"},{"input_id":"4d9c4ae8ee666647i0","output_id":"4dc1c5e4e4987b43o0"},{"input_id":"4d9e68b2cdb80445i1","output_id":"4d9c4ae8ee666647o0"},{"input_id":"4d9e68b2cdb80445i0","output_id":"4d9e68b2cdb80445o1"},{"input_id":"4d9e68b2cdb80445i1","output_id":"4d9c4ae8ee666647o0"},{"input_id":"4d9e68b29f5fa742i0","output_id":"4d9e68b2cdb80445o0"},{"input_id":"4d9e68b2cdb80445i0","output_id":"4d9e68b2cdb80445o1"},{"input_id":"4d9e68b29f5fa742i1","output_id":"4d9e68b2cdb80445o1"},{"input_id":"4d9e68b2c9eb8c4bi1","output_id":"4d9e68b29f5fa742o0"},{"input_id":"4d9e68b2c9eb8c4bi2","output_id":"4d9e68b29f5fa742o0"},{"input_id":"4d9e68b2c9eb8c4bi2","output_id":"4d9e68b29f5fa742o1"},{"input_id":"4dacbb0d0ba72245i0","output_id":"4d9e68b2c9eb8c4bo0"},{"input_id":"4d9e68b29f5fa742i0","output_id":"4d9e68b2cdb80445o0"},{"input_id":"4d9e68b29f5fa742i1","output_id":"4d9e68b2cdb80445o1"},{"input_id":"4d9e68b2c9eb8c4bi1","output_id":"4d9e68b29f5fa742o0"},{"input_id":"4d9e68b2c9eb8c4bi2","output_id":"4d9e68b29f5fa742o0"},{"input_id":"4d9e68b2c9eb8c4bi2","output_id":"4d9e68b29f5fa742o1"},{"input_id":"4dacbb0d0ba72245i0","output_id":"4d9e68b2c9eb8c4bo0"},{"input_id":"4dacd2a486986148i1","output_id":"4dacbb0d0ba72245o0"},{"input_id":"4dacd2a486986148i1","output_id":"4dacbb0d0ba72245o0"},{"input_id":"4dad4e4c39442048i0","output_id":"4dacd2a486986148o1"},{"input_id":"4dad4e4c39442048i0","output_id":"4dacd2a486986148o1"},{"input_id":"4d9c4ae8ee666647i0","output_id":"4dc126f24b022d4do0"},{"input_id":"4d9c4ae8ee666647i0","output_id":"4dc1c5e4e4987b43o0"},{"input_id":"4d9e68b3bb4f4249i2","output_id":"4d9e68b30d9e7f45o0"},{"input_id":"4d9e68b3a5a42e45i1","output_id":"4d9e68b3bb4f4249o0"},{"input_id":"4d9e68b364e04846i0","output_id":"4d9e68b3a5a42e45o0"},{"input_id":"4dc03169d88c3448i1","output_id":"4d9e68b3a5a42e45o0"},{"input_id":"4d9e68b364e04846i1","output_id":"4d9e68b3a5a42e45o1"},{"input_id":"4dc03169d88c3448i0","output_id":"4d9e68b3a5a42e45o1"},{"input_id":"4d9e68b32225e141i0","output_id":"4d9e68b364e04846o0"},{"input_id":"4d9e68b3bb4f4249i0","output_id":"4d9e68b353c82d4co0"},{"input_id":"4d9e68b3bb4f4249i1","output_id":"4d9e68b353c82d4co0"},{"input_id":"4d9e68b30d9e7f45i1","output_id":"4d9e68b36e920847o0"},{"input_id":"4d9e68b364e04846i2","output_id":"4d9e68b36e920847o0"},{"input_id":"4dc03169d88c3448i2","output_id":"4d9e68b36e920847o0"},{"input_id":"4d9e68b353c82d4ci1","output_id":"4d9e68b3649e244do0"},{"input_id":"4d9e68b364e04846i2","output_id":"4d9e68b3649e244do0"},{"input_id":"4dc0c139d02bc74ai0","output_id":"4dc03169d88c3448o0"}]}}}
As a side note, behaviors do have a sequence of frame order, going from top-left to bottom-right. This isn’t explained anywhere, but is a good thing to keep in mind no matter how you’re coding. It’s even more important if you’re trying to implement one-frame code as it can have major impacts there.