> 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)
Tyler Hall
what
Austin Robinson
You could do this in 2 seconds in excel
Leo Foster
Fucking what?
Jonathan Bennett
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).
Parker Parker
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
Asher Turner
try perl for anything to do with text processing
Alexander Lewis
Ok so I think I have it: out = ['1'] while int(out[-1])
Anthony Baker
>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.
Joseph Brown
Sage for brainlet.
Landon Lopez
>American education churns out people who are unable to express themselves Sad!
David Gray
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?
Xavier Foster
Using len() is cheating.
Xavier Collins
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.
Sebastian Gonzalez
Now this gets me hard.
Tyler Roberts
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
Jason Stewart
As you probably expected, Python though someone could probably do in a Bash/awk one liner.
brainlets
Michael Hall
I did it myself as said in Bash and works for your provided output. j=0; k="1,"; while (( j
John Martinez
the output is static, the most elegant implementation of the algorithm in any language is a string literal.
Bentley Russell
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.
Elijah Hall
>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.
Josiah Cox
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.
Joseph Reed
nigger just make a function lmao no need for dem loops or shit power of mathemadicks
Kevin Butler
You could definitely do that.
So what's the function you came up with to calculate position n?
Joseph Murphy
too tired you do it
Jacob Brown
actually that's pretty good #include #include
int main() { int acc = 1; while (acc
Jayden Richardson
What language even is this.
Jonathan Campbell
Brainfuck is the most elegant programing language in the world prove me wrong
Cameron Edwards
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.
Jaxson Brown
Haskell.
Cooper Ross
yea a lovely O(1) solution with math blows anything else out of the water
Samuel Evans
Could you do it in erlang please?
Connor White
Sure, and I bet the professor who asked this wanted to see that solution.
Levi Foster
im not doing his homework for him
Camden Peterson
Use C and then have a loop with a counter and a print line that adds “X, “ over and over. Tard