Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Many thanks to xnorxnor for the short closed form x -> x + round(sqrt(x)) mapping sequence offsets to the value to sqrt. The savings over my previous calculation (generating the list of non-squares and selecting by index) provided enough to have an all-zero fallback for most out-of-range indices.

Many thanks to xnor for the short closed form x -> x + round(sqrt(x)) mapping sequence offsets to the value to sqrt. The savings over my previous calculation (generating the list of non-squares and selecting by index) provided enough to have an all-zero fallback for most out-of-range indices.

Many thanks to xnor for the short closed form x -> x + round(sqrt(x)) mapping sequence offsets to the value to sqrt. The savings over my previous calculation (generating the list of non-squares and selecting by index) provided enough to have an all-zero fallback for most out-of-range indices.

added 1523 characters in body
Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

CJam (27802182 2780 3034 sequences)

{:ZA3#:Cb(40-_z_!!:B-\+CbB)/C),{mq_i>},=_mqmo:NmQM+:M;KNK{)[N0{N1$_*-@/M@+1$md@M@-}K*]<W%B{X0@{2$*+\}%}*ZB&=}%%\C)<f*} 
  • [A040002, A040003]

  • [A040005, A040008]

  • [A040011, A040013]

  • A040015

  • [A040019, A040022]

  • A040024

  • [A040029, A040033]

  • A040035

  • A040037

  • [A040041, A040043]

  • A040048

  • A040052

  • [A040055, A040057]

  • A040059

  • A040063

  • [A040071, A040074]

  • A040077

  • A040080

  • [A040090, A040091]

  • [A040093, A040094]

  • A040099

  • [A040109, A040111]

  • A040118

  • A040120

  • [A040131, A040135]

  • A040137

  • A040139

  • [A040142, A040143]

  • A040151

  • [A040155, A040157]

  • A040166

  • A040168

  • [A040181, A040183]

  • [A040185, A040968]

    [A040000, A040003], [A040005, A040008], [A040011, A040013], A040015, [A040019, A040022], A040024, [A040029, A040033], A040035, A040037, [A040041, A040043], A040048, A040052, [A040055, A040057], A040059, A040063, [A040071, A040074], A040077, A040080, [A040090, A040091], [A040093, A040094], A040097, A040099, [A040109, A040111], A040118, A040120, [A040131, A040135], A040137, A040139, [A040142, A040143], A040151, [A040155, A040157], A040166, A040168, [A040181, A040183], [A040185, A040968]
  • [A041006, A041011]

    [A041006, A041011], [A041014, A042937]
  • [A041014, A042937]

    A006983, [A011734, A011745], [A023975, A023976], [A025438, A025439], [A025443, A025444], A025466, A025469, [A034422, A034423], A034427, A034429, A034432, A034435, [A034437, A034439], A034441, A034443, A034445, A034447, [A034449, A034459], [A034461, A034462], [A034464, A034469], A034471, A034473, [A034475, A034477], [A034479, A034487], [A034489, A034490], [A034492, A034493], A034495, [A034497, A034512], [A034514, A034516], [A034518, A034523], [A034525, A034582], A036861, A047752, A052375, A055967, A061858, A065687, A066035, A067159, A067168, A070097, A070202, A070204, [A070205, A070206], A072325, A072769, A076142, A082998, A083344, A085974, A085982, A086007, A086015, A089458, A093392, A094382, A105517, A108322, A111855, A111859, [A111898, A111899], A112802, A122180, A129947, A137579, A159708, [A161277, A161280], A165766, A167263, A178780, A178798, A180472, A180601, A181340, A181735, A184946, A185037, A185203, [A185237, A185238], [A185245, A185246], A185255, A185264, A185284, A191928, A192541, A197629, A198255, A200214, A206499, A210632, A212619, [A217148, A217149], A217151, [A217155, A217156], A228953, A230533, A230686, A235044, A235358, A236265, A236417, A236460, A238403, [A243831, A243836], A248805, A250002, A256974, A260502, A264668, A276183, A277165, A280492, A280815

The A040??? sequences correspond to the continued fractions of non-rational square roots from sqrt(52) to sqrt(1000) (with the gaps corresponding to ones which appear earlier in OEIS, but conveniently filled with random sequences); the. The A041??? sequences correspond to the numerators and denominators of the continued fraction convergents for non-rational square roots from sqrt(6) to sqrt(1000) (with the gap corresponding to sqrt(10), at A005667 and A005668). The other assorted sequences have zeroes for their first twenty values.

It was trickyMany thanks to mapxnor for the short closed form x -> x + round(sqrt(x)) mapping sequence numberoffsets to the value to sqrt. In the end I couldn't find anything better than generatingThe savings over my previous calculation (generating the list of non-squares and selecting by index. The trick I used in an earlier version) provided enough to have an all-zero fallback for most out-of-range indices no longer fits: it took me a couple of hours just to get both continued fractions and convergents into the 100 byte limit.

CJam (2780 sequences)

{:ZA3#:Cb(40-_!!:B-\+CbB)/C),{mq_i>},=:NmQ:M;K{)[N0{N1$_*-@/M@+1$md@M@-}K*]<W%B{X0@{2$*+\}%}*ZB&=}%} 
  • [A040002, A040003]

  • [A040005, A040008]

  • [A040011, A040013]

  • A040015

  • [A040019, A040022]

  • A040024

  • [A040029, A040033]

  • A040035

  • A040037

  • [A040041, A040043]

  • A040048

  • A040052

  • [A040055, A040057]

  • A040059

  • A040063

  • [A040071, A040074]

  • A040077

  • A040080

  • [A040090, A040091]

  • [A040093, A040094]

  • A040099

  • [A040109, A040111]

  • A040118

  • A040120

  • [A040131, A040135]

  • A040137

  • A040139

  • [A040142, A040143]

  • A040151

  • [A040155, A040157]

  • A040166

  • A040168

  • [A040181, A040183]

  • [A040185, A040968]

  • [A041006, A041011]

  • [A041014, A042937]

The A040??? sequences correspond to the continued fractions of non-rational square roots from sqrt(5) to sqrt(1000) (with the gaps corresponding to ones which appear earlier in OEIS, but conveniently filled with random sequences); the A041??? sequences correspond to the numerators and denominators of the continued fraction convergents for non-rational square roots from sqrt(6) to sqrt(1000) (with the gap corresponding to sqrt(10), at A005667 and A005668).

It was tricky to map the sequence number to the value to sqrt. In the end I couldn't find anything better than generating the list of non-squares and selecting by index. The trick I used in an earlier version to have an all-zero fallback for out-of-range indices no longer fits: it took me a couple of hours just to get both continued fractions and convergents into the 100 byte limit.

CJam (2182 2780 3034 sequences)

{:ZA3#:Cb(40-z_!!:B-\+CbB)/)_mqmo:M+:NK{)[N0{N1$_*-@/M@+1$md@M@-}K*]<W%B{X0@{2$*+\}%}*ZB&=}%\C)<f*} 
  • [A040000, A040003], [A040005, A040008], [A040011, A040013], A040015, [A040019, A040022], A040024, [A040029, A040033], A040035, A040037, [A040041, A040043], A040048, A040052, [A040055, A040057], A040059, A040063, [A040071, A040074], A040077, A040080, [A040090, A040091], [A040093, A040094], A040097, A040099, [A040109, A040111], A040118, A040120, [A040131, A040135], A040137, A040139, [A040142, A040143], A040151, [A040155, A040157], A040166, A040168, [A040181, A040183], [A040185, A040968]
  • [A041006, A041011], [A041014, A042937]
  • A006983, [A011734, A011745], [A023975, A023976], [A025438, A025439], [A025443, A025444], A025466, A025469, [A034422, A034423], A034427, A034429, A034432, A034435, [A034437, A034439], A034441, A034443, A034445, A034447, [A034449, A034459], [A034461, A034462], [A034464, A034469], A034471, A034473, [A034475, A034477], [A034479, A034487], [A034489, A034490], [A034492, A034493], A034495, [A034497, A034512], [A034514, A034516], [A034518, A034523], [A034525, A034582], A036861, A047752, A052375, A055967, A061858, A065687, A066035, A067159, A067168, A070097, A070202, A070204, [A070205, A070206], A072325, A072769, A076142, A082998, A083344, A085974, A085982, A086007, A086015, A089458, A093392, A094382, A105517, A108322, A111855, A111859, [A111898, A111899], A112802, A122180, A129947, A137579, A159708, [A161277, A161280], A165766, A167263, A178780, A178798, A180472, A180601, A181340, A181735, A184946, A185037, A185203, [A185237, A185238], [A185245, A185246], A185255, A185264, A185284, A191928, A192541, A197629, A198255, A200214, A206499, A210632, A212619, [A217148, A217149], A217151, [A217155, A217156], A228953, A230533, A230686, A235044, A235358, A236265, A236417, A236460, A238403, [A243831, A243836], A248805, A250002, A256974, A260502, A264668, A276183, A277165, A280492, A280815

The A040??? sequences correspond to the continued fractions of non-rational square roots from sqrt(2) to sqrt(1000) (with the gaps corresponding to ones which appear earlier in OEIS, but conveniently filled with random sequences). The A041??? sequences correspond to the numerators and denominators of the continued fraction convergents for non-rational square roots from sqrt(6) to sqrt(1000) (with the gap corresponding to sqrt(10), at A005667 and A005668). The other assorted sequences have zeroes for their first twenty values.

Many thanks to xnor for the short closed form x -> x + round(sqrt(x)) mapping sequence offsets to the value to sqrt. The savings over my previous calculation (generating the list of non-squares and selecting by index) provided enough to have an all-zero fallback for most out-of-range indices.

Included the continued fractions as well as the convergents for a significant score improvement
Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

CJam (21822780 sequences)

{:Z2/20500ZA3#:Cb(40-A3#_!!:B-\+CbB)/C),{mq_i>},{;2}j:Q[=:NmQ:M1MM;K{)[N0{N1$_*-@/M@+1$md@M@-}J*]K,:)\f<K*]<W%B{W%X0@X0@{2$*+\}/%}%2/zZ=Q2>f**ZB&=}%} 

This gives correct answers for the inclusive ranges

  • [A040002, A040003]

  • [A040005, A040008]

  • [A040011, A040013]

  • A040015

  • [A040019, A040022]

  • A040024

  • [A040029, A040033]

  • A040035

  • A040037

  • [A040041, A040043]

  • A040048

  • A040052

  • [A040055, A040057]

  • A040059

  • A040063

  • [A040071, A040074]

  • A040077

  • A040080

  • [A040090, A040091]

  • [A040093, A040094]

  • A040099

  • [A040109, A040111]

  • A040118

  • A040120

  • [A040131, A040135]

  • A040137

  • A040139

  • [A040142, A040143]

  • A040151

  • [A040155, A040157]

  • A040166

  • A040168

  • [A040181, A040183]

  • [A040185, A040968]

  • [A041006, A041011]

  • [A041014, A042937]

The [A041006, A041011]A040???, sequences correspond to the continued fractions of non-rational square roots from [A041014, A042937]sqrt(5), and to sqrt(1000) (with the 252gaps corresponding to ones which startappear earlier in OEIS, but conveniently filled with 20 zeroes. The two ranges of interestrandom sequences); the A041??? sequences correspond to the numerators and denominators of the continued fraction convergents ofconvergents for non-rational square roots from sqrt(6) to sqrt(1000) except(with the gap corresponding to sqrt(10), which is elsewhereat (A005667, A005668) but for which they conveniently left a gap to be filled with random sequences (A041012,and A041013A005668).

The trickiest partIt was mappingtricky to map the sequence number to the value to sqrt. In the end I couldn't find anything better than generating the list of non-squares and selecting by index. However, this does allow a littleThe trick: instead of using = for the get-array-item operator, I'm using {;2}j, abusing the memoisation operator I used in an earlier version to provide ahave an all-zero fallback value of 2 for any index out of the range-of-range indices no longer fits: it took me a couple of interest. At the end I detect this fallback valuehours just to replace theget both continued fractions and convergents with all-zeroesinto the 100 byte limit.

CJam (2182 sequences)

{:Z2/20500-A3#),{mq_i>},{;2}j:Q[:NmQ:M1M{N1$_*-@/M@+1$md@M@-}J*]K,:)\f<{W%X0@{2$*+\}/}%2/zZ=Q2>f*} 

This gives correct answers for the inclusive ranges [A041006, A041011], [A041014, A042937], and the 252 which start with 20 zeroes. The two ranges of interest correspond to the numerators and denominators of continued fraction convergents of non-rational square roots from sqrt(6) to sqrt(1000) except sqrt(10), which is elsewhere (A005667, A005668) but for which they conveniently left a gap to be filled with random sequences (A041012, A041013).

The trickiest part was mapping the sequence number to the value to sqrt. In the end I couldn't find anything better than generating the list of non-squares and selecting by index. However, this does allow a little trick: instead of using = for the get-array-item operator, I'm using {;2}j, abusing the memoisation operator to provide a fallback value of 2 for any index out of the range of interest. At the end I detect this fallback value to replace the convergents with all-zeroes.

CJam (2780 sequences)

{:ZA3#:Cb(40-_!!:B-\+CbB)/C),{mq_i>},=:NmQ:M;K{)[N0{N1$_*-@/M@+1$md@M@-}K*]<W%B{X0@{2$*+\}%}*ZB&=}%} 

This gives correct answers for the inclusive ranges

  • [A040002, A040003]

  • [A040005, A040008]

  • [A040011, A040013]

  • A040015

  • [A040019, A040022]

  • A040024

  • [A040029, A040033]

  • A040035

  • A040037

  • [A040041, A040043]

  • A040048

  • A040052

  • [A040055, A040057]

  • A040059

  • A040063

  • [A040071, A040074]

  • A040077

  • A040080

  • [A040090, A040091]

  • [A040093, A040094]

  • A040099

  • [A040109, A040111]

  • A040118

  • A040120

  • [A040131, A040135]

  • A040137

  • A040139

  • [A040142, A040143]

  • A040151

  • [A040155, A040157]

  • A040166

  • A040168

  • [A040181, A040183]

  • [A040185, A040968]

  • [A041006, A041011]

  • [A041014, A042937]

The A040??? sequences correspond to the continued fractions of non-rational square roots from sqrt(5) to sqrt(1000) (with the gaps corresponding to ones which appear earlier in OEIS, but conveniently filled with random sequences); the A041??? sequences correspond to the numerators and denominators of the continued fraction convergents for non-rational square roots from sqrt(6) to sqrt(1000) (with the gap corresponding to sqrt(10), at A005667 and A005668).

It was tricky to map the sequence number to the value to sqrt. In the end I couldn't find anything better than generating the list of non-squares and selecting by index. The trick I used in an earlier version to have an all-zero fallback for out-of-range indices no longer fits: it took me a couple of hours just to get both continued fractions and convergents into the 100 byte limit.

Save two chars
Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179
Loading
Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179
Loading