PHP (60)
Assuming the input is provided in the commandline:
for(;$i<702;)$s.=chr(96.5+sqrt($i+=2));echo$s!=$argv[1]?:42;
Explanation: you can view the string as a triangle structure.
j i val
0 0 a
1 1-2 bb
2 3-5 ccc
3 6-9 dddd
4 10-14 eeeee
5 15-20 ffffff
...
Line j
starts at index i = j*(j+1)/2
(that's the triangular number formula). Solving the quadratic equation results in index i
being on line j = int((sqrt(8*i+1)-1)/2)
and therefore containing character 97 + int((sqrt(8*i+1)-1)/2)
. The 0-350
index range allows us to simplify that to 96.5 + sqrt(2*(i+1))
, but that no longer holds true for larger values.
Edit: Switched to commandline input as suggested in the comments.
Edit: Uses ternaryconditional operator to save a character