[Question]
  [
## Animate the text in your terminal
**The goal**
The goal is to "animate" the string "Hello world" in your output so that each character gets capitalised after each other. 
Your program can exit after each letter has been capitalised.
For example;
```
# Iteration 1
Hello world
# Iteration 2
hEllo world
# Iteration 3
heLlo world
# Iteration 4
helLo world
# Iteration 5
hellO world
# Iteration 6 (note: it should capitilize the space char (ie: a break between iteration 5 and iteration 7)
hello world
# Iteration 7
hello World
# Iteration 8
hello wOrld
# Iteration 9
hello woRld
# Iteration 10
hello worLd
# Iteration 11
hello worlD
```
It should only animate the string once and between each state there should be a 1 second delay.
**Input**
No input is required, but "Hello world" must be the string that is "animated".
**Output**
The string "Hello world" must be animated. The output must be as 1 line to create a sort of wave animation. An empty trailing new line is allowed. Example gif;
![https://i.gyazo.com/be12b693063b463540c5bf1f03d2454a.gif](https://i.gyazo.com/be12b693063b463540c5bf1f03d2454a.gif) 
I saw this on a metasploit youtube video and thought the effect was pretty cool, which is where I recorded the gif from, so it's a little laggy, but I hope it illustrates the output fine
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), lowest byte-count will be deemed the winner.
[Sandbox Link](http://meta.codegolf.stackexchange.com/a/11486/38505)
  
[Answer]
# Vim 26 bytes
```
ihello world<ESC>qq~gsul@qq0@q
```
Explanation (no .gif yet):
First, we must enter the 'hello world' text. This is pretty straightforward. It's just:
```
ihello world<ESC>
```
At this point, the cursor is on the 'd' in 'world'. Next:
```
qq              " Start recording into register 'q'
  ~             " Swap the case of the character underneath the cursor, and move the cursor to the right
   gs           " Sleep for one second
     u          " Undo the last change (of swapping case).
      l         " Move one character to the right (Get it? 'l' == 'Right' because vim is intuitive!)
                " This will cause the error to break on the last character of the input.
       @q       " Call register 'q'
         q      " Stop recording
          0     " Move to the first character
           @q   " Call the recursive macro
```
There are also two other 26 byte versions I found:
```
ihello world<ESC>qq~gsulq011@q
ihello world<ESC>011@='~gsul'<cr>
```
[Answer]
# Python 2, ~~98~~ ~~94~~ 90 bytes
```
for x in range(11):s='hello world';print'\r'+s[:x]+s[x:].capitalize(),;[1for y in' '*8**8]
```
~~-9~~ -4 bytes thanks to @ElPedro
-4 bytes thanks to @JonathanAllan and @Rod
[Answer]
# Commodore 64, 168 162 137 133 BASIC (and tokenized) bytes used
```
 0s=1024:?"{control+n}{clear home}hello world":fOi=.to1:fOj=.to11:x=pE(s+j):pokes+j,x+64
 1x=pE(1023+j):pO1023+j,abs(x-64):pO1029,32:pO1035,32:fOz=.to99:i=.:nEz,j,i
```
You will need to use BASIC keyword abbreviations to enter this into a real C64 or emulator (or enter the program into a Commodore 128 and load it back in C64 mode, although this should work on the 128 as well). The `{control+n}` will only work/display after the opening quote. It is shorthand for `chr$(14)` and therefore saves some bytes and switches the character set to *business mode* or upper/lower case characters.
I have added in some abbreviations for you so you. The `{clear home}` character is made by pressing `Shift` and the `CLR/HOME` key after the opening quotation mark.
For illustrative purposes the unobfustcated listing may be entered as follows:
```
 0 let s=1024
 1 print chr$(14); chr$(147); "hello world"
 2 for i=0 to 1
 3  for j=0 to 11
 4   let x=peek(s + j)
 5   poke s + j, x + 64
 6   let x=peek(1023 + j)
 7   poke 1023 + j, abs(x - 64)
 8   poke 1029, 32
 9   poke 1035, 32
10   for z=0 to 99
11    let i=0
12   next z
13  next j
14 next i
```
It works by switching the PETSCII charset into business mode (upper/lower case), and writing the hello world string to the top line of the screen which is located at memory location $0400, it will then take the value at each location for the next 11 bytes from there and increase each value by 64 (the upper case equivalent). If the j counter is > 0, it calls a routine at line 2 to decrease the previous memory location by 64 again.
Line 3 is a pause, it also writes a space to to location $0405 and $040b, which is a bug fix (which could probably be removed to save some bytes).
[![Commodore C64 animated hello world](https://i.stack.imgur.com/5M5L6.png)](https://i.stack.imgur.com/5M5L6.png)
[Answer]
# Powershell, ~~126~~ ~~119~~ ~~107~~ 104 Bytes
```
'Hello world';$s='hello world';1..10|%{sleep 1;cls;-join($s[0..($_-1)]+[char]($s[$_]-32)+$s[++$_..11])}
```
[![enter image description here](https://i.stack.imgur.com/mRtoH.gif)](https://i.stack.imgur.com/mRtoH.gif)
Revisions (there will likely be many):
Change `$s.Length` to const ~~`10`~~ 11
Restructured string builder, removed 1 join statement and used `++$s` instead of `($s+1)`, to save some bytes thanks to [@AdmBorkBork](https://codegolf.stackexchange.com/users/42963/admborkbork)
AdmBorkBork points out just using the string twice is actually shorter than encapsulating and then `.ToLower()`'ing it - which says a lot about how verbose powershell is, -3!
---
basically loop through the length of the string, form an array of three parts, the pre-capitcal, capital, and post-capital, take 32 away from the middle letter, then convert back to a char to get upper case, luckily this doesn't turn space into a visible character either, I hope this is acceptable?
[Answer]
# C#, ~~230~~ ~~215~~ ~~193~~ ~~161~~ ~~135~~ ~~134~~ 130 bytes
It's C# so it's long right! :-( But after some help and searching, I (and others, really) managed to remove exactly 100 bytes already.
## Golfed
```
()=>{for(int i=1;;){var b="\rhello world".ToCharArray();b[i++]-=' ';System.Console.Write(b);System.Threading.Thread.Sleep(1000);}}
```
## Ungolfed
```
class P
{
    static void Main()
    {
        for (int i = 1;;)
        {
            var b = "\rhello world".ToCharArray();
            b[i++] -= ' ';
            System.Console.Write(b);
            System.Threading.Thread.Sleep(1000);
        }
    }
}
```
### Screenshot
[![Animation with 1 second delay](https://i.stack.imgur.com/8lMJ0.gif)](https://i.stack.imgur.com/8lMJ0.gif)
Although it looks alot better when looping and faster..
### Updates
* Lost 15 bytes by using carriage return instead of `Clear()` which also allowed me to replace a using with `System.Console`somewhere inline.
* Replaced program with lambda saving 23 bytes thanks to **@devRicher**
* It became kind of a collaboration with **@devRicher** at this point, thanks to some of his suggestions I managed to lose another 32 bytes!
* Thanks to 2 really smart and interesting suggestions by **@Kratz** I managed to replace `new string(b)` with `b` and `b[i]=char.ToUpper(b[i])` with `b[i]-=' '`, saving me another 26 bytes!
* 1 byte less by moving `i++` thanks to **@Snowfire**
* 4 bytes less by moving carriage return to the beginning of the string and removing `i<11` from my `for` loop
[Answer]
## [CP-1610](https://en.wikipedia.org/wiki/General_Instrument_CP1600) assembly, 50 DECLEs = 63 bytes
This code is intended to be run on an [Intellivision](https://en.wikipedia.org/wiki/Intellivision).
A CP-1610 opcode is encoded with a 10-bit value, known as a 'DECLE'. This program is 50 DECLEs long, starting at $4800 and ending at $4831.
```
                                  ROMW  10          ; use 10-bit ROM
                                  ORG   $4800       ; start program at address $4800
                          main    PROC
4800 0002                         EIS               ; enable interrupts (to enable display)
4801 0001                         SDBD              ; load pointer to string in R4
4802 02BC 0026 0048               MVII  #@@str, R4
4805 02A2                         MVI@  R4,     R2  ; R2 = length of string
4806 0091                         MOVR  R2,     R1  ; R1 = uppercase counter
4807 02BD 0214            @@loop  MVII  #$214,  R5  ; R5 = video memory pointer
4809 0093                         MOVR  R2,     R3  ; R3 = character counter
480A 02A0                 @@next  MVI@  R4,     R0  ; R0 = next character
480B 0338 0020                    SUBI  #32,    R0  ; minus 32 -> character #
480D 004C                         SLL   R0,     2   ; multiply by 8 to get the
480E 0048                         SLL   R0          ; correct GROM card
480F 03F8 0007                    XORI  #7,     R0  ; add 7 (for white)
4811 014B                         CMPR  R1,     R3  ; uppercase? ...
4812 020C 0002                    BNEQ  @@draw
4814 0338 0100                    SUBI  #256,   R0  ; ... yes: sub 32*8
4816 0268                 @@draw  MVO@  R0,     R5  ; draw character
4817 0013                         DECR  R3          ; decrement character counter
4818 022C 000F                    BNEQ  @@next      ; process next character or stop
481A 0001                         SDBD              ; R0 = spin counter to wait ~1 second
481B 02B8 0038 00D3               MVII  #$D338, R0  ;    = 54072 = 13518 * 60 / 15
                                                    ; (assuming 13518 cycles per frame)
481E 0010                 @@spin  DECR  R0          ; 6 cycles
481F 022C 0002                    BNEQ  @@spin      ; 9 cycles
                                                    ; -> 15 cycles per iteration
4821 0114                         SUBR  R2,     R4  ; reset pointer to beginning of string
4822 0011                         DECR  R1          ; decrement uppercase counter
4823 022C 001D                    BNEQ  @@loop      ; process next iteration or stop
4825 0017                         DECR  PC          ; infinite loop
4826 000B 0068 0065 006C  @@str   STRING 11, "hello world"
482A 006C 006F 0020 0077
482E 006F 0072 006C 0064
                                  ENDP
```
### Output
[![enter image description here](https://i.stack.imgur.com/sawzc.gif)](https://i.stack.imgur.com/sawzc.gif)
[Answer]
# [MATL](https://github.com/lmendo/MATL), 30 bytes
```
11:"10&Xx'hello world't@)Xk@(D
```
Try it at [MATL Online!](https://matl.io/?code=11%3A%2210%26Xx%27hello+world%27t%40%29Xk%40%28D&inputs=&version=19.7.4)
```
11:              % Push [1 2 ... 11]
  "              % For each k in [1 2 ... 11]
  10&Xx          %   Pause for 10 tenths of a second and clear screen
  'hello world'  %   Push this string
  t              %   Duplicate
  @)             %   Get the k-th character from the duplicated string
  Xk             %   Convert to uppercase
  @(             %   Write into the k-th position of the string
  D              %   Display
                 % Implicit end
```
[Answer]
# PHP, ~~76~~ ~~74~~ 71 bytes
Thank you @hd for the delay being a full second and no fraction thereof!  
Thanks @user63956 for 2 bytes and @aross for 3 bytes.
```
for(;$c=($s="hello world")[$i];sleep(print"$s\r"))$s[$i++]=ucfirst($c);
```
Run with `-nr`.
[Answer]
# C, ~~97~~ ~~withdrawn~~ 106 bytes
with escaped characters counted as 1 byte
```
char*a="HELLO\0WORLD\xED";b,c;m(){for(b=0;b<156;putchar(a[c]+32*(b/12^c||c==5)))(c=b++%12)||fflush(sleep(1));}
```
Note: I have ~~commented out the time delay on~~ unlinked TIO because it waits for completion before displaying the output, it also doesn't seem to recognize carriage returns and puts new lines. Also, if you're on Windows, sleep is in milliseconds instead of seconds, so `sleep(1)` should become `sleep(1000)`.
~~Note 2: I've withdrawn this entry for the moment until the output bugs have been ironed out.~~
[Answer]
# JavaScript (ES6), ~~141 139~~ 131 bytes
*Saved 8B thanks to Apsillers*
```
_=>a=setInterval("b=[...`hello world`],c.clear(b[d]=b[d].toUpperCase(++d>10&&clearInterval(a))),c.log(b.join``)",1e3,c=console,d=0)
```
# Explanation
This creates a function with no arguments, which splits the string `hello world` into an array of characters and capitalises the `d+1`th character. `d` is a counter that starts as `0` and is increased every time.
# Usage
```
f=_=>a=setInterval("b=[...`hello world`],c.clear(b[d]=b[d].toUpperCase(++d>10&&clearInterval(a))),c.log(b.join``)",1e3,c=console,d=0)
f()
```
[Answer]
# [Noodel](https://tkellehe.github.io/noodel/), 22 [bytes](https://tkellehe.github.io/noodel/docs/code_page.html)
```
”<8@\|DḶ|\6þıHḶƥɲSḍsɲS
```
[Try it:)](https://tkellehe.github.io/noodel/editor.html?code=%E2%80%9D%3C8%40%5C%7CD%E1%B8%B6%7C%5C6%C3%BE%C4%B1H%E1%B8%B6%C6%A5%C9%B2S%E1%B8%8Ds%C9%B2S&input=&run=true)
---
# How it works
```
”<8@\|DḶ|\6þ           # Displays the string "hello¤world".
”<8@\|DḶ|\6            # Decompresses to the array ["h", "e", "l", "l", "o", "¤", "w", "o", "r", "l", "d"] and pushes it on top of the stack.
           þ           # Pushes a copy of the array to the screen which since is an array is done by reference.
            ı          # Makes the array on the top of the stack the new stack.
             HḶƥɲSḍsɲS # Loops eleven times creating the animation.
             H         # Pushes the string "H" on to the top of the stack.
              Ḷ        # Consumes the "H" that gets evaluated as a base 98 number which comes out to eleven.
               ƥ       # Move the stack pointer up one.
                ɲS     # Switch the case of the top of the stack which will show up on the screen because the array is done by reference.
                  ḍs   # Delay for one second.
                    ɲS # Switch the case back.
                       # Implicit end of the loop.
```
---
The snippet uses a **25 byte** version that loops continuously.
```
<div id="noodel" cols="10" rows="2" code="”<8@\|DḶ|\6þıḷʠ*HḶƥɲSḍsɲS" input=""/>
<script src="https://tkellehe.github.io/noodel/release/noodel-2.5.js"></script>
<script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script>
```
[Answer]
# Bash + coreutils, ~~99~~ 98 bytes
```
x=hello\ world
for((;n<11;)){
echo -en "\r${x:0:n}"`tr a-z A-Z<<<"${x:n:1}"`"${x:n+++1}"
sleep 1
}
```
[Answer]
# [Perl 6](http://perl6.org/), ~~65~~ 61 bytes
```
for 3..12 ->\i{sleep say "\echello world".&{S:nth(i)/./{$/.uc}/}}
```
```
(sleep say S:nth(3+$++)/./{$/.uc}/with "\echello world")xx 11
```
GIF: [![enter image description here](https://i.stack.imgur.com/qBOrp.gif)](https://i.stack.imgur.com/qBOrp.gif)
### How it works
The ANSI escape sequence `\ec` clears the screen.  
Each iteration, the `i`'th character of the hard-coded string is substituted by its upper-case version.  
The `say` function always returns `True`, which is passed on to the sleep function which interprets it as `1` second.
[Answer]
## Ruby, ~~82~~ 81 bytes
```
12.times{|a|$><<?^H*11;'Hello world'.chars{|y|$><<((0!=a-=1)?y:y.upcase)};sleep 1}
```
^H is ascii 8 (backspace), and is only 1 byte.
[Answer]
# C, 87 bytes
```
m(){char*f,a[]="\rhello world";for(f=a;*++f;*f&=95,printf(a),*f|=32,fflush(sleep(1)));}
```
Compiles and runs on Linux.
[Answer]
# Mathematica, ~~130~~ ~~128~~ ~~123~~ ~~110~~ 108 bytes
```
Dynamic@o
s="hello world";i=1;t=StringTake;Do[o=t[s,{1,i-1}]<>Capitalize@t[s,{i}]<>t[s,{++i,11}];Pause@1,11]
```
Explanation: From `i=1` to 11, print from the 1st to the (i-1)th character of "hello world", capitalise `"hello world"[i]`, then print the rest of the string, incrementing `i` at the same time.
[Answer]
# Java ~~215~~ ~~212~~ ~~204~~ 203 bytes
```
interface A{static void main(String z[])throws Exception{for(int i=0;i<10;i++){char[]b="helloworld".toCharArray();b[i]=Character.toUpperCase(b[i]);System.out.println(new String(b));Thread.sleep(1000);}}}
```
Ungolfed:
```
 interface A {
 static void main(String z[]) throws Exception {
    for (int i = 0; i < 10; i++) {
        char[] b = "helloworld".toCharArray();
        b[i] = Character.toUpperCase(b[i]);
        System.out.println(new String(b));
        Thread.sleep(1000);
    }
  }
}
```
[Answer]
# [R](https://www.r-project.org/), ~~106~~ 103 bytes
```
x=el(strsplit("hello world",""))
for(i in 1:11){y=x;y[i]=toupper(y[i]);cat('\f',y,sep='');Sys.sleep(1)}
```
Just a simple loop, clearing the console with `cat('\f')` seems somewhat system-dependent but I am not aware of a better way.
[Answer]
# C, 122 bytes
```
i;f(){char s[]="Hello world\r";for(i=0;i<11;i++){s[i]=toupper(s[i]);s[i-1]=tolower(s[i-1]);printf(s);fflush(0);sleep(1);}}
```
Shorter than C# :D
[Answer]
# Perl, 75 bytes
```
sleep print"\33c".("hello world"=~s/(.{$_})(.)(.*)/$1\U$2\E$3\n/r)for 0..10
```
Uses the ANSI code `ESC``c` to clear the console and move the cursor to the top left at every iteration, but still needs `\n` at the end of the replace string to avoid having the whole animation lost in the line buffer.
A successful call to `print` returns a value of 1, which can be passed directly to `sleep`.
[Answer]
# SmileBASIC, ~~90~~ 71 bytes
```
FOR I=0TO 10CLS?"hello world
LOCATE I,0?CHR$(CHKCHR(I,0)-32)WAIT 60NEXT
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~24~~ 21 bytes
```
”Æ⁹Œu⁸¦ȮœS
“½,⁻⁸3»Jç€
```
This is a niladic link/function that prints to STDOUT. It does not work as a full program.
The code can't be tested on TIO; it uses control characters and TIO has no terminal emulator (yet).
### How it works
```
“½,⁻⁸3»Jç€  Niladic link. No arguments.
“½,⁻⁸3»     Index into Jelly's dictionary to yield "hello world".
       J    Indices; yield [1, ..., 11].
        ç€  Apply the helper link to each index, with right arg. "hello world".
”Æ⁹Œu⁸¦ȮœS  Dyadic helper link. Left argument: i. Right argument: "hello world"
”Æ          Set the return value to '\r'.
  ⁹         Set the return value to "hello world". Implicitly prints '\r'.
   Œu⁸¦     Uppercase the i-th letter.
       Ȯ    Print.
        œS  Sleep "hello world" seconds. (Strings are cast to Boolean.)
```
[Answer]
# C, 122 bytes
As an exercise, I wrote this to provide a more optimal output format than some of the other answers. Also it means the cursor sits after the most recently capitalized letter during the pauses.
```
main(){
    char*p=".Hello world\rH";
    write(1,p+1,13);
    do{
        sleep(1);
        *p=8;
        p[1]|=32;
        p[2]^=(p[2]>32)*32;
        write(1,p++,3);
    }while(p[4]);
}
```
(Newlines and indentations cosmetic and not part of byte count)
Now, some readers may note that this requires some massaging to get to run on modern machines (the magic incantation is `-static -Wl,-N`), but this is how real implementations of C used to behave, so I think it is valid. It also assumes the character set is ASCII, and it does not print a trailing newline.
Bonus: For an EBCDIC version, you can replace `8` with `22` and `64` with `32`, and switch the logic for `p[1]` and `p[2]`. To test on a non-EBCDIC system, you can compile with `-funsigned-char -fexec-charset=cp037`.
Output is 43 bytes: `Hello world«H‹hE‹eL‹lL‹lO‹o ‹ W‹wO‹oR‹rL‹lD`
[Answer]
# Scala, 92 bytes
```
val h="hello world"
0 to 10 map{i=>print("\b"*99+h.updated(i,h(i)toUpper))
Thread sleep 999}
```
## Ungolfed
```
val h="hello world"    //declare a variable h with the string "hello world"
0 to 10                //create a range from 0 to 10
map { i=>              //loop with index i
  print(                 //print
    "\b" * 99              //99 backspace chars
    + h.updated(           //and h with
      i,                     //the i-th char
      h(i).toUpper           //replaced with the i-th char in uppercase
    )     
  )
  Thread sleep 999       //sleep 999 ms
}
```
[Answer]
# Clojure, 116 bytes
```
(doseq[i(range 11)](Thread/sleep 1000)(print"\r"(apply str(update(vec"hello world")i #(char(-(int %) 32)))))(flush))
```
Basically a for-loop that goes over the indices of each character, updating each character in turn.
```
(defn -main []
  (doseq [i (range 11)] ; For the index of each character...
    (Thread/sleep 1000)
    (print "\r" ; Clear old line
           (apply str ; Turn the vector back into a string
             (update ; Update the char at index i
               (vec "hello world") ; Turn the string into a vector so it's updatable
               i ; Index to update
               #(char (- (int %) 32))))) ; Subtract 32 from the character to make uppercase
    (flush)))
```
[Answer]
## Batch, 184 bytes
```
@echo off
for %%h in (Hello hEllo heLlo helLo hellO hello)do call:c %%h world
for %%w in (World wOrld woRld worLd worlD)do call:c hello %%w
exit/b
:c
timeout/t>nul 1
cls
echo %*
```
Curiously the command line for `timeout/t>nul 1` gets corrupted if there is no trailing newline, so I can't put it at the end of the file.
[Answer]
# Ruby, 108 bytes
First time, first year student. It's no eagle but I'm at least a little proud.
```
12.times{|i|sleep(0.1); puts "\e[H\e[2J", "hello world".sub(/(?<=.{#{Regexp.quote(i.to_s)}})./, &:upcase);}
```
[Answer]
# Pascal, ~~187~~ 152 bytes
Not exactly the most efficient or the shortest, but works quite well!
```
uses crt,sysutils;label R;const X:Word=1;P='hello world';begin
R:clrscr;write(P);gotoxy(X,1);write(upcase(P[X]));sleep(999);X:=X*Ord(X<11)+1;goto R
end.
```
Tested and works on Free Pascal Compiler 2.6+.
Thanks to [@manatwork](https://codegolf.stackexchange.com/users/4198/manatwork) for saving **35** bytes!
---
I've used <http://www.onlinecompiler.net/pascal> to compile the file and run it on Windows.  
Haven't seen any problem with it, so far.
[Answer]
## C ~~120~~ ~~110~~ ~~104~~ 96 bytes
```
f(){char *j,s[]="\rhello world";for(j=s;*++j;*j-=32,printf(s),*j+=32,fflush(0),sleep(‌​1));}
```
Ungolfed version
```
void f()
{
  char *j;
  char s[]="hello world";
  j=s; 
   for (;*j;j++)
   {
      *j-=32;  
       printf(s); // print the string and right after change the same char to lower case
       *j+=32;
      fflush(0);
      sleep(1);
   }
}
```
@Pakk Thanks for saving some bytes, great idea. :)
@Pakk @KarlNapf Thanks guys for your inputs.
can still be shortened!? :)
[Answer]
## Python 2, ~~220~~ ~~189~~ 179 bytes
Solution without using strings and `capitalize()`, byte count as is:
```
import time,sys
from numpy import *
F=fromstring("\rhello world",int8)
for i in range(1,12):
    time.sleep(1)
    F[i]-=32
    savetxt(sys.stdout,F,fmt="%c",newline="")
    F[i]+=32
```
And a bit longer variant (191 chars) without case resetting:
```
import time,sys
from numpy import *
a=arange(11)
F=tile(fromstring("\rhello world",int8),(11,1))
F[a,a+1]-=32
for i in a:
    time.sleep(1)
    savetxt(sys.stdout,F[i],fmt="%c",newline="")
```
]