8
\$\begingroup\$

Resistors and other electronic components are typically manufactured with values that conform to one of the E-series of preferred numbers. IEC 60063 defines the following E-series:

E6:

10 15 22 33 47 68

E12:

10 12 15 18 22 27 33 39 47 56 68 82

E24:

10 11 12 13 15 16 18 20 22 24 27 30 33 36 39 43 47 51 56 62 68 75 82 91

E48:

100 105 110 115 121 127 133 140 147 154 162 169 178 187 196 205 215 226 237 249 261 274 287 301 316 332 348 365 383 402 422 442 464 487 511 536 562 590 619 649 681 715 750 787 825 866 909 953

E96:

100 102 105 107 110 113 115 118 121 124 127 130 133 137 140 143 147 150 154 158 162 165 169 174 178 182 187 191 196 200 205 210 215 221 226 232 237 243 249 255 261 267 274 280 287 294 301 309 316 324 332 340 348 357 365 374 383 392 402 412 422 432 442 453 464 475 487 499 511 523 536 549 562 576 590 604 619 634 649 665 681 698 715 732 750 768 787 806 825 845 866 887 909 931 953 976

E192:

100 101 102 104 105 106 107 109 110 111 113 114 115 117 118 120 121 123 124 126 127 129 130 132 133 135 137 138 140 142 143 145 147 149 150 152 154 156 158 160 162 164 165 167 169 172 174 176 178 180 182 184 187 189 191 193 196 198 200 203 205 208 210 213 215 218 221 223 226 229 232 234 237 240 243 246 249 252 255 258 261 264 267 271 274 277 280 284 287 291 294 298 301 305 309 312 316 320 324 328 332 336 340 344 348 352 357 361 365 370 374 379 383 388 392 397 402 407 412 417 422 427 432 437 442 448 453 459 464 470 475 481 487 493 499 505 511 517 523 530 536 542 549 556 562 569 576 583 590 597 604 612 619 626 634 642 649 657 665 673 681 690 698 706 715 723 732 741 750 759 768 777 787 796 806 816 825 835 845 856 866 876 887 898 909 920 931 942 953 965 976 988

Given a single input integer from the set {6, 12, 24, 48, 96, 192}, output the corresponding E-series, in order, containing exactly the numbers as shown above for the given series.

  • Output may be in whatever format of list, array, etc is appropriate for your language.
  • Base 10 integers only.
  • builtins that specifically implement these series are disallowed.
\$\endgroup\$
4
\$\begingroup\$

Python 3, 97 bytes

lambda n:[round(10**(i/n+2-(n<25)))+((.4<i/n<.67)-(.9<i/n<.92))*(n<25)+(i==185)for i in range(n)]

The output values scaled from 1 to 10 are well-approximated by an exponential interpolation:

10**(i/n)

Multiplying by 10 for 6, 12, 24 and 100 for 48, 96, 192 then rounding to the nearest integer

round(10**(i/n+2-(n<25)))

gives the right answers for all but 16 values, which gives errors of ±1.

n   i   est val  diff 
6   3   32  33  -1
6   4   46  47  -1
12  5   26  27  -1
12  6   32  33  -1
12  7   38  39  -1
12  8   46  47  -1
12  11  83  82  1
24  10  26  27  -1
24  11  29  30  -1
24  12  32  33  -1
24  13  35  36  -1
24  14  38  39  -1
24  15  42  43  -1
24  16  46  47  -1
24  22  83  82  1
192 185 919 920 -1

For n<=24, most of these errors are for inputs values in the interval 10/24<=i/n<=6/24. There's one other error for n==24 that trickles down to n==12, and one error for n==192. We fudge these errors by adding or subtracting 1 to the estimate.

\$\endgroup\$
1
\$\begingroup\$

Mathematica, 904 879 bytes

If[#>4!,{100,101,102,104,105,106,107,109,110,111,113,114,115,117,118,120,121,123,124,126,127,129,130,132,133,135,137,138,140,142,143,145,147,149,150,152,154,156,158,160,162,164,165,167,169,172,174,176,178,180,182,184,187,189,191,193,196,198,200,203,205,208,210,213,215,218,221,223,226,229,232,234,237,240,243,246,249,252,255,258,261,264,267,271,274,277,280,284,287,291,294,298,301,305,309,312,316,320,324,328,332,336,340,344,348,352,357,361,365,370,374,379,383,388,392,397,402,407,412,417,422,427,432,437,442,448,453,459,464,470,475,481,487,493,499,505,511,517,523,530,536,542,549,556,562,569,576,583,590,597,604,612,619,626,634,642,649,657,665,673,681,690,698,706,715,723,732,741,750,759,768,777,787,796,806,816,825,835,845,856,866,876,887,898,909,920,931,942,953,965,976,988}[[;;;;192/#]],{10,11,12,13,15,16,18,20,22,24,27,30,33,36,39,43,47,51,56,62,68,75,82,91},[[;;;;24/#]]]&

Ungolfed Massive-list-free Logic-only version:

If[#>4!,{E192}[[;;;;192/#]],{E24}[[;;;;24/#]]]&

Almost version, 60 bytes

Floor[Table[If[#>4!,100,10]Surd[10,#]^x,{x,0,#}]+.5][[;;-2]]

Accurate to within ±1

\$\endgroup\$
  • \$\begingroup\$ Pretty sure you can do much better than that by mathematically generating the list. Hint: 192nd root of 10. \$\endgroup\$ – Digital Trauma Mar 10 '16 at 2:05
  • \$\begingroup\$ Not quite. :( That gives 920 when it's 919 for input 192. \$\endgroup\$ – CalculatorFeline Mar 10 '16 at 2:36
  • \$\begingroup\$ So there's some sort of "One True Formatting" that must be used everywhere?(Sorry, but why the edit?) \$\endgroup\$ – CalculatorFeline Mar 10 '16 at 5:05
  • \$\begingroup\$ @CatsAreFluffy h2 is generally preferred to h1, though not everyone follows that rule—justification is that h1 should be the biggest thing on a page. By the way, I think Mathemeatica wouldn't be a bad name for a new golfing language... \$\endgroup\$ – lirtosiast Mar 10 '16 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.