[Question]
  [
In this challenge fake marquee text is text that is shown part by part, in a scrolling-like fashion.
Some examples:
```
testing 4
   t
  te
 tes
test
esti
stin
ting
ing
ng
g
hello 2
 h
he
el
ll
lo
o
foobarz 3
  f
 fo
foo
oob
oba
bar
arz
rz
z
Something a bit longer 10
         S
        So
       Som
      Some
     Somet
    Someth
   Somethi
  Somethin
 Something
Something 
omething a
mething a 
ething a b
thing a bi
hing a bit
ing a bit 
ng a bit l
g a bit lo
 a bit lon
a bit long
 bit longe
bit longer
it longer
t longer
 longer
longer
onger
nger
ger
er
r
small 15
              s
             sm
            sma
           smal
          small
         small
        small
       small
      small
     small
    small
   small
  small
 small
small
mall
all
ll
l
aaa 3
  a
 aa
aaa
aa
a
brace yourself 6
     b
    br
   bra
  brac
 brace
brace 
race y
ace yo
ce you
e your
 yours
yourse
oursel
urself
rself
self
elf
lf
f
```
You have to write a program or a function that takes in two input and prints the output as described above. You may or may not output trailing spaces in your output. This is code-golf so shortest code in bytes wins.
If your program is standalone (i.e. when run actually prints the lines) (Input can be hard-coded but easy to change) and sleeps a bit between each line of output you get a -10 bonus.
  
[Answer]
# CJam, ~~12~~ 11 bytes
*1 byte saved by Dennis.*
```
,Sf*\f+$zN*
```
I'm making use of "Input can be hard-coded but easy to change": this expects the input to be already on the stack, so you can prepend `"testing" 4` to the above, for instance.
[Test it here.](http://cjam.aditsu.net/#code=%22testing%224%0A%2CSf*%5Cf%2BW%25zN*&input=4%0Atesting)
## Explanation
Notice that the transpose of the desired output is much simpler:
```
   testing
  testing
 testing
testing
```
So we just need to create `n` lines, prepending `i` spaces for `i` from `n-1` down to `0`. That's what the code does:
```
,            e# Turn n into a range [0 1 .. n-1]
 Sf*         e# Turn each i into a string of i spaces.
    \f+      e# Swap this array with the input string and append it to each of the
             e# strings of spaces.
       $     e# Sort the array to have the string with n-1 spaces first.
        z    e# Transpose the grid.
         N*  e# Join the lines with newline characters.
```
## 19 - 10 = 9?
I find the "sleeps a bit between each line" bonus a bit vague and dodgy, but here is a 19 byte version that simply stalls after each line by computing all permutations of the array `[0 1 .. 7]`. In the online interpreter this simply leads to the final result being shown a bit later, but if you use the Java interpreter this will actually print each line after "sleeping a bit":
```
,Sf*\f+$z{oNo8e!;}/
```
[Answer]
# C, 69 bytes
printf magic!
```
f(s,n,i)char*s;{for(i=n;*s;i?i--:s++)printf("%*s%.*s\n",i,"",n-i,s);}
```
Expanded version with some explanation:
```
f(s,n,i)char*s;{       /* s is the string, n is the width of the grid. */
  for(i=n;             /* i is the number of preceding spaces. */
      *s;              /* Stop once we reach the end of the string. */
      i?i--:s++)       /* Decrease the number of spaces, and when there's 
                          none left start truncating the string itself. */
  printf("%*s          /* The first argument is the minimum width to print the 
                          string (left padded with spaces) and the second 
                          argument is the string to print. We use the empty 
                          string just to print the i spaces. */
    %.*s              /* The third argument is the maximum number of 
                         characters from the string (which is the fourth 
                         argument) to print. */
    \n",i,"",n-i,s);
}
```
And here's an example:
```
$ ./marquee stackoverflow 12
           s
          st
         sta
        stac
       stack
      stacko
     stackov
    stackove
   stackover
  stackoverf
 stackoverfl
stackoverflo
tackoverflow
ackoverflow
ckoverflow
koverflow
overflow
verflow
erflow
rflow
flow
low
ow
w
```
[Answer]
# Pyth, 13 bytes
```
jb.:++K*dQzKQ
```
Try it online: [Pyth Compiler/Executor](https://pyth.herokuapp.com/?code=jb.%3A%2B%2BK*dQzKQ&input=brace%20yourself%0A6&debug=0)
### Explanation
```
                 implicit: z = input string, Q = input number
      K*dQ       K = " " * Q
    ++K   zK     K + z + K
  .:        Q    all substrings of length Q
jb               join by newlines and print
```
[Answer]
## Python 65 63
```
s=lambda t,s:'\n'.join((' '*s+t)[i:s+i]for i in range(len(t)+s))
```
This was actually used to write the examples. Baseline solution.
```
>>> print(s("foobarz", 3))
  f
 fo
foo
oob
oba
bar
arz
rz
z
```
[Answer]
# Javascript (*ES7 Draft*), 61 bytes
```
f=(s,l)=>[x.substr(i,l)for(i in x=' '.repeat(l)+s)].join(`
`)
```
```
<input id="str" value="Some String" />
<input id="num" value="5" />
<button onclick="out.innerHTML=f(str.value, +num.value)">Run</button>
<br /><pre id="out"></pre>
```
# Javascript (*ES6*) Hardcoded Inputs, 47 bytes
Assuming hard-coded inputs in variables `s` (string) and `l` (length), it can be reduced to **47** bytes printing with an alert for each line:
```
for(i in x=' '.repeat(l)+s)alert(x.substr(i,l))
```
[Answer]
# K, 19 bytes
```
{x#'![1]\(x#" "),y}
```
Tack `x` spaces (`x#" "`) onto the beginning of the string `y`. Then use the "fixed-point scan" form of the operator `\` to create the set of rotated strings. A fixed-point in K stops iterating if the result of applying the function returns a repeated result or if the initial input is revisited. Since `![1]` will rotate a string one step at a time, `![1]\` is a nice idiom for cyclic permutations. Then we just trim the results with `x#'`.
A sample run:
```
  {x#'![1]\(x#" "),y}[4;"some text"]
("    "
 "   s"
 "  so"
 " som"
 "some"
 "ome "
 "me t"
 "e te"
 " tex"
 "text"
 "ext "
 "xt  "
 "t   ")
```
[Answer]
# J (22)
This ended up longer than I anticipated, but I guess it is not too bad.
```
[{."0 1[:]\.(' '#~[),]
```
Fun fact: non of the `[` and `]` are actually matched, or have anything to do with each other.
[Answer]
# Julia, 75 bytes
```
(s,n)->(n-=1;print(join([(" "^n*s*" "^n)[i:n+i]for i=1:length(s)+n],"\n")))
```
This creates an unnamed function that accepts a string and integer as input and prints the output. To call it, give it a name, e.g. `f=(s,n)->(...)`.
Ungolfed + explanation:
```
function f(s, n)
    # Decrement n by 1
    n -= 1
    # Construct the lines as an array using comprehension by repeatedly
    # extracting subsets of the input string padded with spaces
    lines = [(" "^n * s * " "^n)[i:n+i] for i = 1:length(s)+n]
    # Print the array elements separated by a newline
    print(join(lines, "\n"))
end
```
Examples:
```
julia> f("banana", 3)
  b
 ba
ban
ana
nan
ana
na 
a
julia> f("Julia", 6)
     J
    Ju
   Jul
  Juli
 Julia
Julia 
ulia  
lia   
ia    
a     
```
Note that this solution is 66 bytes if `s` and `n` are assumed to already exist in the program.
[Answer]
# QBasic, 56 - 10 = 46
This is golfed QBasic--the autoformatter will expand `?` into `PRINT` and add some spaces. Tested with [QB64](http://qb64.net), though there shouldn't be anything in here that won't work with DOS QBasic.
```
s=SPACE$(n)+s
FOR i=1TO LEN(s)
?MID$(s,i,n)
SLEEP 1
NEXT
```
QBasic generally isn't good with string operations, but there very conveniently *is* a function that returns a given number of spaces!
Taking some liberties with "input may be hard-coded," this code expects the variable `s` to be `DIM`'d `AS STRING`, in order to avoid the `$` type suffix, as well as the string being assigned to `s` and the number to `n`.
Example preamble:
```
DIM s AS STRING
s="string"
n=4
```
Output:
```
   s
  st
 str
stri
trin
ring
ing
ng
g
```
The top blank row may be eliminated by starting the `FOR` loop at 2 instead of 1.
**Bonus:** Adding `CLS` right before `NEXT` for a paltry four bytes turns this into... a *real marquee*!
![Marquee](https://i.stack.imgur.com/fAhdb.gif)
I `PRINT CHR$(3)` QBasic. :^D
[Answer]
# Ruby, 68, 55 bytes
```
a=" "*$*[1].to_i+$*[0]+" ";a.size.times{|b|puts a[b...b+$*[1].to_i]}
```
After an update from @blutorange:
```
a=" "*(z=$*[1].to_i)+$*[0];a.size.times{|b|puts a[b,z]}
```
Output:
```
         S
        So
       Som
      Some
     Somet
    Someth
   Somethi
  Somethin
 Something
Something 
omething a
mething a 
ething a b
thing a bi
hing a bit
ing a bit 
ng a bit l
g a bit lo
 a bit lon
a bit long
 bit longe
bit longer
it longer 
t longer 
 longer 
longer 
onger 
nger 
ger 
er 
r 
```
`ruby marquee.rb "Something a bit longer" 10`
First submission so asking for criticism.
[Answer]
# Haskell, ~~61~~ ~~59~~ 54 bytes
```
m n=unlines.scanr((take n.).(:))[].(replicate n ' '++)
```
Usage example:
```
*Main> putStr $ m 6 "stackoverflow"
     s
    st
   sta
  stac
 stack
stacko
tackov
ackove
ckover
koverf
overfl
verflo
erflow
rflow
flow
low
ow
w
*Main> 
```
Edit: an empty line at the beginning / end is allowed
[Answer]
# Bash, 109 - 10 = 99 bytes
I see that in the time it took me to write my solution, I have been soundly beaten. Nevertheless, I spent too long writing it to not post it...
Besides which, it has some unique features, like the time between lines printing being user-adjustable based on how much is in the current directory! (Also somewhat inconsistent, depending on how your disk feels)
```
l=${#1};s=$1;for j in `seq 1 $2`;do s=" $s";done;for i in `seq 0 $((l+$2))`;do echo "${s:i:$2}";find 1>2;done
```
Example:
```
cd <some directory in which you own everything recursively>
Marquee.sh "Test Case" 4
    
   T
  Te
 Tes
Test
est 
st C
t Ca
 Cas
Case
ase
se
e
 
```
Ungolfed and commented:
```
l=${#1} #Length of the incoming string
s=$1 #Can't reassign to the parameter variables, so give it another name
for j in `seq 1 $2`; do
    s=" $s" # Put on the padding spaces
done
for i in `seq 0 $((l+$2))`; do
    #Cut the string and print it. I wish I could lose "padding" that easily!
    echo "${s:i:$2}" #Format is ${string:index:length}, so always the same
    # length, with the index moving into the string as the loop advances
    find 1>2  #Wait "a bit". From ~/, about 6 minutes per line on my junky 
    # computer with a huge home directory. Probably in the <1 sec range for
    # most people.
    #This actually has the same character count as sleep(X), but is much
    # more fun!
done
```
I've never really tried this before. Suggestions and comments welcome!
[Answer]
# Pure Bash, 61 bytes
```
printf -vs %$2s"$1"
for((;++i<${#1}+$2;)){
echo "${s:i:$2}"
}
```
### Output:
```
$ ./marquee.sh testing 4
   t
  te
 tes
test
esti
stin
ting
ing
ng
g
$ 
```
[Answer]
# Perl, 50
```
$c=$" x$^I;$_="$c$_$c";sleep say$1while(/(?<=(.{$^I}))/g)
```
`57` characters `+3` for `-i`, `-n` and `-l`. `-10` characters for the sleep.
`-i` is used for the numeric input, which is stored in `$^I`. Basically, we add `i` spaces to the front and end of the input, and then search for every `i` characters and loop through them with `while`. `say` conveniently returns `1` which we can input to `sleep`.
```
echo "testing" | perl -i4 -nlE'$c=$" x$^I;$_="$c$_$c";sleep say$1while(/(?<=(.{$^I}))/g)'
```
[Answer]
# POSIX shell, 94
```
[ $3 ]||set "`printf "%${2}s"`$1" $2 t
[ "$1" ]&&printf "%-.${2}s" "$1" "
"&&$0 "${1#?}" $2 t
```
I know it looks closer to perl, but this really is shell!
The first line adds the necessary leading spaces, only on the first time through the loop. It sets $3 to indicate that it has done so.
The second line (N.B. embedded newline) recurses until input is exhausted, printing the first *n* characters of the string, then invoking itself with the first character removed from $1.
Tested with Debian `/bin/dash` - sample outputs follow:
./marquee "testing" 4
```
   t
  te
 tes
test
esti
stin
ting
ing
ng
g
```
./marquee "Something a bit longer" 10
```
         S
        So
       Som
      Some
     Somet
    Someth
   Somethi
  Somethin
 Something
Something 
omething a
mething a 
ething a b
thing a bi
hing a bit
ing a bit 
ng a bit l
g a bit lo
 a bit lon
a bit long
 bit longe
bit longer
it longer
t longer
 longer
longer
onger
nger
ger
er
r
```
./marquee "small" 15
```
              s
             sm
            sma
           smal
          small
         small
        small
       small
      small
     small
    small
   small
  small
 small
small
mall
all
ll
l
```
[Answer]
# Python 2, 51 bytes / 37 bytes
**Without hardcoded input (51 bytes):**
```
def f(s,n):
 s=" "*n+s
 while s:print s[:n];s=s[1:]
```
Call like `f("testing", 4)`.
**With hardcoded input (37 bytes):**
```
s="testing";n=4
s=" "*n+s
while s:print s[:n];s=s[1:]
```
Both versions output an initial line of spaces.
[Answer]
# Pyth, 12 bytes
```
jb.:X*dyQQzQ
```
[Demonstration.](https://pyth.herokuapp.com/?code=jb.%3AX*dyQQzQ&input=testing%0A4&debug=0)
---
# Pyth, 17 - 10 = 7 bytes
```
FN.:X*dyQQzQ&.p9N
```
This version employs a delay between line prints. This can be seen on the command line compiler, which you can get [here](https://github.com/isaacg1/pyth).
Run the following:
```
pyth -c 'FN.:X*dyQQzQ&.p9N' <<< 'testing
4'
```
This has a delay of about 0.3 seconds before each print. If you prefer a longer delay, you can use:
```
FN.:X*dyQQzQ&.pTN
```
This has about a 4 second delay.
[Answer]
# Java, 133 ~~119~~ 115
```
int i;void f(String s,int n){for(;++i<n;)s=" "+s+" ";for(;i<=s.length();)System.out.println(s.substring(i-n,i++));}
```
Long version:
```
int i;
void f(String s, int n) {
    for(; ++i < n;)
        s = " " + s + " ";
    for(; i<=s.length();)
        System.out.println(s.substring(i-n, i++));
}
```
Padding is applied to the string, and then substrings of the padded string are printed to the console.
*-4 bytes thanks to @KevinCruijssen.*
[Answer]
# Python 2, (52 bytes - 10 = 42) ~~64~~ ~~62~~ ~~60~~ ~~46~~ ~~44~~
(I assumed the line for hard-coded input doesn't add to byte count.)
I didn't see a program yet that actually sleeps between printing lines, so I made one that does, since it looks more like a marquee that way. This program is 2 more bytes in Python 3.
EDIT: The program now does a computation instead of sleeping. I used `i` in the calculation so that the program doesn't store it as a constant, but must compute it each time.
[**Try It Online!**](https://tio.run/##K6gsycjPM/pfbKuem1hUWJqaqm7NlWdrav0/09aAqzwjMydVoTg6UzfPKtaqoCgzr0RDXUFdK0@7WDM60ypPOzPWOlPb1tA6U0vLHIj@/wcA)
```
i=0
while s[i-n:]:print(' '*n+s)[i:n+i];i+=1;i**7**7
```
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 3 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
＊／⤢
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjBBJXVGRjBGJXUyOTIy,i=Zm9vYmFyeiUwQTM_,v=8)
Input is string and integer (in either order) separated by a newline.
---
Explanation:
```
＊     | Repeat a b times vertically (a=string input, b=int input) 
  ／   | Make antidiagonal (add one extra space to each line bottom up)
    ⤢　| Transpose (reflect along top-left to bottom-right diagonal)
```
[Answer]
# Matlab, 95
As always, it is a manipulation of matrices. The core here is the command `spdiags` which lets you create diagonal matrices very easily.
```
t=input('');
n=numel(t);
k=input('');
flipud(char(full(spdiags(repmat(t,n+k-1,1),1-n:0,n+k-1,k))))
```
With hardcoding 71 bytes (expected string stored in `t` and the number in `k`)
```
n=numel(t);flipud(char(full(spdiags(repmat(t,n+k-1,1),1-n:0,n+k-1,k))))
```
[Answer]
# APL, 50 - 10 = 40 chars
I'm sure it could be shorter. 50 is the length of the program without the two constants.
```
{⍵≡⍬:⍬⋄⎕←↑⍵⋄⎕DL 99⋄∇1↓⍵}⊂[0]⊖s⍴⍨n,¯1+⍴s←'brace yourself',' '⍴⍨n←6
```
Explanation:
```
                               ' '⍴⍨n←6   call the number 'n' and make n spaces
            s←'brace yourself',           append them to the string and call it 's'
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
                             s⍴⍨n,¯1+⍴s   make a len(s)-1 by n matrix by repeating s 
                        ⊂[0]⊖             reflect the matrix and extract the columns
{                      }                  pass the list of columns to this function
 ⍵≡⍬:⍬⋄                                   return if the list is empty
       ⎕←↑⍵⋄                              print the first column (as a row)
            ⎕DL 99⋄                       wait for 99ms
                   ∇1↓⍵                   recurse with the rest of the columns
```
Developed for [ngn APL](https://github.com/ngn/apl) on the terminal.
[Answer]
# [J](http://jsoftware.com/), ~~15~~ 14 bytes
```
,.~/@(' '&,~<)
```
[Try it online!](https://tio.run/##y/r/P03B1kpBR69O30FDXUFdTafORpOLKzU5I19BPSM1JydfXSFNwQgqUJJaXJKZlw4SMoEKFZckJmfnl6UWpeXkl4MkDI3@/wcA "J – Try It Online")
[Answer]
# Powershell - 85 83 bytes
It's late, it's not going to win :-) But I thought I'd throw in a Powershell one for completeness:
`function m($s,$n){1..$($n+$s.length)|%{-join(" "*$n+$s+" "*$n)[$_-1..$($n+$_-1)]}}`
[Answer]
# [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 38 bytes
```
L#,b]*ApR1€Ω_32C€*dbR@$BcB]€¦+bU@BcBJn
```
[Try it online!](https://tio.run/##S0xJKSj4/99HWScpVsuxIMjwUdOacyvjjY2cgQytlKQgBxWnZKdYIOfQMu2kUAcgxyvvv0pOYm5SSqKCoZ29nT2X////SiWpxSWZeelK/00A "Add++ – Try It Online")
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `N`, 8 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
L€ṣs+rðƬ
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPUwlRTIlODIlQUMlRTElQjklQTNzJTJCciVDMyVCMCVDNiVBQyZmb290ZXI9JmlucHV0PTQlMEElMjJ0ZXN0aW5nJTIyJmZsYWdzPU4=)
#### Explanation
```
L€ṣs+rðƬ  # Implicit input
L€ṣ       # Push [" " * 0, " " * 1, ..., " " * (n-1)]
   s+     # Prepend each to the input
     rðƬ  # Reverse and transpose with filler space
          # Implicit output, joined on newlines
```
[Answer]
# Cobra - 60
```
def f(n,s)
    s=' '.repeat(n)+s
    while''<s,print (s=s[1:])[:n]
```
[Answer]
# Groovy - 82
```
n=args[1]as int;t=" "*n+args[0]+" "*n;(0..t.size()-n).each{println t[it..it+n-1]}
```
[Answer]
# Lua, 79 bytes
```
r=io.read;t=r()w=r()s=" "t=s:rep(w)..t;for i=1,t:len()do print(t:sub(i,i+w))end
```
[Answer]
# C#, 112 bytes
```
s=>n=>{var r=new string(' ',n-1);s=r+s+r;r="";for(int i=0;i<s.Length-n+1;)r+=s.Substring(i++,n)+"\n";return r;};
```
Full program with ungolfed method and test cases:
```
using System;
namespace FakeMarqueeText
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string,Func<int,string>>f= s=>n=>
            {
                var r=new string(' ',n-1);
                s=r+s+r;
                r="";
                for(int i=0;i<s.Length-n+1;)
                    r+=s.Substring(i++,n)+"\n";
                return r;
            };
            // test cases:
            Console.WriteLine(f("testing")(4));
            Console.WriteLine(f("hello")(2));
            Console.WriteLine(f("foobarz")(3));
            Console.WriteLine(f("Something a bit longer")(10));
            Console.WriteLine(f("small")(15));
            Console.WriteLine(f("aaa")(3));
            Console.WriteLine(f("brace yourself")(6));
        }
    }
}
```
]