On Wed, Aug 17, 2011 at 12:55 PM, Alex Giannakopoulos <[email protected]> wrote: > I am trying to write a verb that will tell me if the digits in a number are > distinct, > e.g. return 1 for 1234 but return 0 for 1231
Why bother writing any code? If you're using decimal, there are only like nine million nonnegative numbers with distinct digits. List them all in the code and use the e. verb. For example (I omit most of the array so that the email doesn't get too long), disv =: 0 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64 65 67 68 69 70 71 72 73 74 75 76 78 79 80 81 82 83 84 85 86 87 89 90 91 92 93 94 95 96 97 98 102 103 104 105 106 107 108 109 120 123 124 125 126 127 128 129 130 132 134 135 136 137 138 139 140 142 143 145 146 147 148 149 150 152 153 154 156 157 158 159 160 162 163 164 165 167 168 169 170 172 173 174 175 176 178 179 180 182 183 184 185 186 187 189 190 192 193 194 195 196 197 198 201 203 204 205 206 207 208 209 210 <snip> 9876523140 9876523401 9876523410 9876524013 9876524031 9876524103 9876524130 9876524301 9876524310 9876530124 9876530142 9876530214 9876530241 9876530412 9876530421 9876531024 9876531042 9876531204 9876531240 9876531402 9876531420 9876532014 9876532041 9876532104 9876532140 9876532401 9876532410 9876534012 9876534021 9876534102 9876534120 9876534201 9876534210 9876540123 9876540132 9876540213 9876540231 9876540312 9876540321 9876541023 9876541032 9876541203 9876541230 9876541302 9876541320 9876542013 9876542031 9876542103 9876542130 9876542301 9876542310 9876543012 9876543021 9876543102 9876543120 9876543201 9876543210 $ disv 8877691 dis =: disv e.~ | dis 1231 0 dis 1234 1 Ambrus PS. don't take this reply too seriously ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
