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.
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:
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 '.':
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 '.':
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 '.':
- 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.
Have fun golfing!