lrobbo314
Well-known Member
- Joined
- Jul 14, 2008
- Messages
- 3,963
- Office Version
- 365
- Platform
- Windows
I am trying to write a function that generates passwords.
As you can see below, if I just have the LAMBDA in the workbook, it works as expected.
But, when I define a name with the LAMBDA, the result has odd characters added into it that weren't in the second argument. In this example, there is an errant backslash, but I've seen [, {, }, ], and ` inserted into the result.
Is there a bug or something?
As you can see below, if I just have the LAMBDA in the workbook, it works as expected.
But, when I define a name with the LAMBDA, the result has odd characters added into it that weren't in the second argument. In this example, there is an errant backslash, but I've seen [, {, }, ], and ` inserted into the result.
Is there a bug or something?
Book4 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Length | 16 | |||
2 | Special Characters | @#$%^& | |||
3 | |||||
4 | |||||
5 | |||||
6 | @9I\lYt^6j#&%<3$ | ||||
7 | &L^$06@GF9r1cm#% | ||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2 | B2 | ="@#$%^&" |
C6 | C6 | =PWD(B1,B2) |
C7 | C7 | =LAMBDA(total_length,special,LET(sat,LAMBDA(a,n,TAKE(SORTBY(a,RANDARRAY(ROWS(a))),n)),msc,total_length-LEN(special),num_len,ROUNDUP(msc/3,0),rem,msc-num_len,UoL,ROUNDUP(rem/2,0),last,rem-UoL,scl,MID(special,SEQUENCE(LEN(special)),1),uc,CHAR(ROW(65:90)),lc,CHAR(ROW(97:122)),nl,CHAR(ROW(48:57)),sn,sat(nl,num_len),io,RANDBETWEEN(0,1),su,IF(io,sat(uc,UoL),sat(uc,last)),sl,IF(io,sat(lc,last),sat(lc,UoL)),sc,sat(scl,ROWS(scl)),all,VSTACK(sc,sl,su,sn),TEXTJOIN("",,sat(all,ROWS(all)))))(B1,B2) |
Excel Formula:
=LAMBDA(total_length,special,
LET(
sat,LAMBDA(a,n,TAKE(SORTBY(a,RANDARRAY(ROWS(a))),n)),
msc,total_length-LEN(special),
num_len,ROUNDUP(msc/3,0),
rem,msc-num_len,
UoL,ROUNDUP(rem/2,0),
last,rem-UoL,
scl,MID(special,SEQUENCE(LEN(special)),1),
uc,CHAR(ROW(65:90)),
lc,CHAR(ROW(97:122)),
nl,CHAR(ROW(48:57)),
sn,sat(nl,num_len),
io,RANDBETWEEN(0,1),
su,IF(io,sat(uc,UoL),sat(uc,last)),
sl,IF(io,sat(lc,last),sat(lc,UoL)),
sc,sat(scl,ROWS(scl)),
all,VSTACK(sc,sl,su,sn),
TEXTJOIN("",,sat(all,ROWS(all)))
)
)