What language can most elegantly do this?:

What language can most elegantly do this?:

> Make a comma-separated list of numbers, with the beginning number being how many characters long the entire string is, up until 2046.

So example output:
>1,3,5,7,9,11,14,17
etc. (Notice jump from 11 to 14)

what

You could do this in 2 seconds in excel

Fucking what?

Your algorithm is fucked, either it should start at 0 (how many characters long the string currently is) or 11 should be 12 (how many characters long the string will be with the next number added).

The request is weird but it's well defined, you're just a shitty programmer. I'm thinking about it OP, let you know as soon as I got it

try perl for anything to do with text processing

Ok so I think I have it:
out = ['1']
while int(out[-1])

>you're just a shitty programmer
You're an idiot. outputs
1,3,5,7,9,12,15,18...
which is EXACTLY what I was saying, that if the number is the length of the string including the current number, that OP's example didn't make sense.

Sage for brainlet.

>American education churns out people who are unable to express themselves
Sad!

I've read the request 10 times and I still do not get it. What the fuck are you asking? Step by step:
1. You want a comma-separated list of numbers
2. What string are you referring to?
3. What is the beginning number?

Using len() is cheating.

numbers = 1 : f 1 [2 .. 2046]
where f _ [] = []
f l (x:xs) | l' == x = x : f l' xs
| otherwise = f l xs
where l' = l + (length $ show x) + 1

main = print $ numbers

This prints the numbers surrounded with brackets. Removing those is left as an exercise for the reader.

Now this gets me hard.

It took a while to parse OP's retardese, but the challenge is supposed to be to output a string of comma separated numbers, where each number gives the length of the part of the string from the beginning to after the current number.

So the length of "1" should be 1, the length of "1,3" should be 3, the length of "1,3,5" should be 5, etc. The string should end at a length of at least 2046

As you probably expected, Python though someone could probably do in a Bash/awk one liner.

brainlets

I did it myself as said in Bash and works for your provided output.
j=0; k="1,"; while (( j

the output is static, the most elegant implementation of the algorithm in any language is a string literal.

fucking lol. just increment by a delta, and increment delta after each power of 10. delta is 2, then 3, 4, 5...It's in linear time. The len() solution is O(N^2), which is retarded.

>fucking lol
Sign of an idiot. Provide an implementation or shut up. The len() solution is O(n+1)->O(n). Go read your textbook kid.

Something like this?
val it = Iterator.iterate((0,1)){case (a,b) => (b,b+1+b.toString.length)}.map(_._2)
println(it.take(2046).mkString(","))


lazy val as: Stream[Int] = 0 #:: 1 #:: as.zip(as.drop(1)).map{case (a,b) => b.toString.length + b + 1}
println(as.drop(1).take(2046).mkString(","))


Arguably Scala isn't absolutely ideal for code golf... yet.

nigger just make a function lmao
no need for dem loops or shit
power of mathemadicks

You could definitely do that.

So what's the function you came up with to calculate position n?

too tired
you do it

actually that's pretty good
#include
#include

int main() {
int acc = 1;
while (acc

What language even is this.

Brainfuck is the most elegant programing language in the world prove me wrong

Sure as fuck can't be arsed. It was your idea and I already provided one of the solutions that deal with the length of the prior number explicitly.

There's obviously a pattern at which position the prior string gets 1 longer, though.

Haskell.

yea a lovely O(1) solution with math blows anything else out of the water

Could you do it in erlang please?

Sure, and I bet the professor who asked this wanted to see that solution.

im not doing his homework for him

Use C and then have a loop with a counter and a print line that adds “X, “ over and over. Tard