Las palabras y los botones cambian el tamaño de fuente de acuerdo con estas reglas:A▲ᴀ▼
- El tamaño de fuente inicial es 11.
- Si se presiona cuando el tamaño de fuente es 1, el tamaño permanece 1.ᴀ▼
- El tamaño de la fuente cambia con 1 punto en el rango de 1 a 12.
- El tamaño de fuente cambia con 2 puntos en el rango de 12 a 28.
- Las opciones son 28, 36, 48, 72 y 80 en el rango de 28 a 80.
- El tamaño de la fuente cambia con 10 puntos en el rango de 80 a 1630.
- El tamaño de fuente cambia con 8 puntos en el rango de 1630 a 1638.
- Si se presiona cuando el tamaño de fuente es 1638, el tamaño permanece 1638.A▲
Tarea
En el menor número de bytes posible, determine el tamaño de fuente resultante cuando se le da un conjunto de pulsaciones de botón en cualquier formato razonable.
Ejemplos
[3,-1,2]
, lo que significa : El resultado es 18.A▲A▲A▲ᴀ▼A▲A▲
Algunos formatos son posibles '^^^v^^'
, [1 1 1 -1 1 1]
, [True,True,True,False,True,True]
, ["+","+","+","-","+","+"]
, "‘‘‘’‘‘"
, "⛄️⛄️⛄️🌴⛄️⛄️"
, 111011
, "CaB"
, etc ...
[2]
: 14
[-1]
: 10
[13]
: 80
[-11,1]
: 2
[11,-1]
: 36
[170,-1]
: 1630
[2000,-2,100]
: 1638
"^vvv^v^^^v"
,[-1, 1, 1, -1, 1, -1]
,[0, 1, 0, 1, 1, 0, 1]
?Respuestas:
MATL,
494745 bytesInput format is
[1 1 -1 1 1 -1 -1 -1]
or[2 -1 2 -3]
, with optional commas.Try it online! Or verify all test cases.
Explanation
fuente
Word VBA,
1991471261161021008785 BytesWhy emulate when you can do?!
Declared function in the
ThisDocument
module that takes inputn
in the form ofArray(true,true,false,true)
and outputs to the Word font size selector :PGolfed:
Ungolfed:
.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()
ton
and expecting input as Boolean Array-2 for moving from a code module to the
ThisDocument
moduleOld Version 114 Bytes
Takes input
n
as a ParamArray, in the form oftrue,true,false,true
and outputs word vbe immediates windowOlder version, 199 Bytes
Takes input in the form of
170,-4,6,-1
(accepts numbers larger than 1 in magnitude)fuente
Set f=.Size = 12
?JavaScript (ES6),
103101 bytesTakes input as an array of
-1
/1
.Test
Show code snippet
Saved 2 bytes thanks to ETHproductions
fuente
a&&(b=c)
, you can save a byte witha?b=c:0
. Here though, I think you can even save two withn+=n>v&&k*[...][i]
Python 2,
111107 bytesRequires input to be in the
[-1, 1, 1, -1, ...]
format. It works with the examples for some bytes extra:fuente
i+=[0,d][0<i<179]
might workif
statement tho.0
or179
we're stuck there forever.Octave,
938987 bytesThe input array can have integers larger than 1 or smaller than -1 to represent multiplicity of action
Thanks to Adám, Changed language to Octave only to be able to use direct indexing into an array.
Saved 2 bytes thanks to rahnema1.
Test
On Ideone
fuente
[1:12,14:2:28,36,48,72,80:10:1630,1638](L)
.[1:11 [6:14 18 24 36 40:5:815 819]*2]
some bytes can be saved!Ruby, 106 bytes
I managed to shave a couple of bytes off the python solution (and it took a while of shaving).
It's an anonymous function that takes the input in the form of
[1, -1, 1, 1, ...]
. It seems to deal quite well with input in the form[170,-12]
as well, but I can't guarantee it will work 100% of the time, so I'll play it safe and say it works with[1, -1, 1, 1, ...]
.Tricks I used:
[0,179,a+b].sort[1]
: This clampsa+b
to be between 0 and 179, which are the valid indexes of the font-size array.Using the splat operator on ranges converts them into arrays, so the available font sizes is generated from
[*1..12,*(14..28).step(2),36,48,72,*(80..1630).step(10),1638]
. Which is a flat array containing the values from each of the flattened elements:1..12
is a range from 1 to 12 (inclusive). The splat operator turns it into the values1, 2, 3, ..., 11, 12
.(14..28).step(2)
is an enumerator for the given range, where each step goes up by 2. The splat operator turns it into the values14, 16, 18, ..., 26, 28
.36, 48, 72, 1638
) are all concatenated in their position into the great font-size array.I used the
inject
(/reduce
) method, which uses each element of the input array, while reducing them down into a 'memo' variable (as ruby puts it). I initialise this to 11, and the body of each inject iteration is to set this memo variable to the result of adding the current element of the input to the current memo value, and then clamping it between 0 and 180.All hail the splat operator!
fuente
PHP, 116 bytes
first generates the size index (from 1 to 180 inclusive),
then maps that to the point size and prints the result.
takes
+N
and-1
from command line arguments.(
-N
is also accepted; just take care that the size does not hop below zero!)Run with
-nr
.fuente
Perl 5, 123 bytes
122 bytes of code + 1 for
-a
Try it online!
Input format:
fuente