Scroll Word's font size selector
Word VBA, 199 147 126 116 102 100 87 85 Bytes
Why emulate when you can do?!
Declared function in the ThisDocument
module that takes input n
in the form of Array(true,true,false,true)
and outputs to the Word font size selector :P
Golfed:
Sub a(n):Set f=Content.Font:For Each i In n
If i Then f.Grow Else f.Shrink
Next:End Sub
Ungolfed:
Sub a(n)
Set f=ThisDocument.Content.Font
For Each i In n
If i Then
f.Grow
Else
f.Shrink
End if
Next
'' Implicitly output font size to MS Word Font Size Selector
End Sub
.GIF of usage
Thanks
-21 thanks to @Adám (removed Selection.WholeStory:
call)
-10 thanks to @Adám (assume clean environment; remove f.size=11:
call)
-14 thanks to @Adám (cheeky output word font size selector)
-2 thanks to @Adám (bool ParamArray)
-13 for changing ParamArray n()
to n
and expecting input as Boolean Array
-2 for moving from a code module to the ThisDocument
module
Old Version 114 Bytes
Takes input n
as a ParamArray, in the form of true,true,false,true
and outputs word vbe immediates window
Sub a(ParamArray n()):Set f=Selection.Font:For Each i In n
If i Then f.Grow Else f.Shrink
Next:Debug.?f.Size:End Sub
Older version, 199 Bytes
Takes input in the form of 170,-4,6,-1
(accepts numbers larger than 1 in magnitude)
Sub a(ParamArray n()):Selection.WholeStory:Set f=Selection.Font:f.Size=12:For Each i In n
If i>1 Then
For j=i To 0 Step -1:f.Grow:Next
Else
For j=i To 0:f.Shrink:Next:End If:Next:Debug.?f.Size:End Sub
JavaScript (ES6), 103 101 bytes
Takes input as an array of -1
/ 1
.
a=>a.map(k=>[1,12,28,36,48,72,80,1630,1638].map((v,i)=>n+=n>v&&k*[1,1,6,4,12,-16,2,-2,-8][i]),n=11)|n
Test
let f =
a=>a.map(k=>[1,12,28,36,48,72,80,1630,1638].map((v,i)=>n+=n>v&&k*[1,1,6,4,12,-16,2,-2,-8][i]),n=11)|n
console.log(f([]));
console.log(f([1]));
console.log(f([-1]));
console.log(f([1,1,1,-1,1,1,1,1,1,1,1,1]));
console.log(f(Array(2000).fill(1)));
Saved 2 bytes thanks to ETHproductions
Python 2, 111 107 bytes
i=10;r=range
for d in input():i+=d*(0<i+d<179)
print(r(1,12)+r(12,29,2)+[36,48,72]+r(80,1631,10)+[1638])[i]
Requires input to be in the [-1, 1, 1, -1, ...]
format. It works with the examples for some bytes extra:
for d in input():i=min(max(0,i+d),179)