Challenge
Ever seen those movie trailer titles (namely Martian, Interstellar, etc) where they have huge gaps in between letters slowly spreading out?
The challenge is to recreate this effect given a string, gap multiplier and direction, by inserting appropriate amount of spaces in between the letters.
Example
Input: 'INTERSTELLAR', Gap multiplier: 1.0, Direction: Increasing Inward
Output: I N T E R S T E L L A R
The spacing is: [1, 2, 3, ... , 3, 2, 1]; replacing the spaces with '.' to better demonstrate the spacing:
I.N..T...E....R.....S......T.....E....L...L..A.R
Input: 'INTERSTELLAR', Gap multiplier: 0.5, Direction: Increasing Inward
Output: IN T E R S T E L L AR
The spacing is multiplied by 0.5, therefore we get [0, 1, 1, 2, ... 2, 1, 1, 0] from integer division; using '.':
IN.T.E..R..S...T..E..L.L.AR
Input: 'CODEGOLF', Gap multiplier: 2.0, Direction: Increasing Outward
Output: C O D E G O L F
The spacing is multiplied by 2, increasing outward, therefore we get [8,6,4,2,4,6,8]; replacing with '.':
C........O......D....E..G....O......L........F
Input: 'CODEGOLF', Gap multiplier: 0.4, Direction: Increasing Outward
Output: C O DEGO L F
The spacing is multiplied by 0.4, increasing outward, therefore we get [1,1,0,0,0,1,1]; replacing with '.':
C.O.DEGO.L.F
Rules
- Takes 3 input: string, gap multiplier and direction
- If input string is odd in length (even in # of gaps) e.g. 'HELLO', the spacing of the inner most 2 gaps should be the same
H E L L O
- The direction and gap multiplier can be parsed however you want, e.g. you could use -2 as 'increasing inward with a multiplier of 2', 1 as 'increasing outward with a multiplier of 1', etc.
- It is only required to use spaces, however it is a bonus if the character filling is customizable.
Reference Animation
Have fun golfing!
Increasing
to1 => Inward, 0 => Outward
or vice versa. \$\endgroup\$C..O....D......E........G......O....L..F
\$\endgroup\$