Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Command: tr -c '0-9' ' ' <input | dc -fdc-p2.dc
- [ q ] sQ
- [
- # Note that hash is offset from start of range, so that indices are < 2^31 (max)
- d dls-;h 1r-* # (1-hash(num-stat))*num num i
- lc+ sc # Score if not in hash
- dls- 1 r:h # Record num in hash
- ] sC
- ? # end start ...
- [
- se ss
- 0 Sh # Clear hash
- 1 # i=1 ...
- [
- dddZAr^ dsf *+ # factor = 10^len(i); num=i,i i ...
- d le <Q # quit search if two repeats is too large
- [
- d le <Q # quit if (end < num)
- d ls !>C # count if (num >= start)
- lf* r d3R+ # num = num,i
- lAx
- ] dsAx
- s. 1+ lLx # junk num; i++ loop
- ] dsLx +s.
- z0<M
- ] dsMx
- [Part 2: ]nlcp
Advertisement
Add Comment
Please, Sign In to add comment