Upward and onward to greater glory!
up vote
14
down vote
favorite
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:
Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s what I wish you whenever I finish tweeting! Excelsior!
Challenge
Given a series of non-negative integers, output a line with Excelsior!
every time an integer is greater than the previous one.
Rules
- Input will be an array of non-negative integers.
- Output will consist of lines with the word
Excelsior
(case does matter) followed by as many!
as the length of the current run of increasingly greater numbers. You can also return an array of strings. - Input and output formats are flexible according to the site rules, so feel free to adapt them to your language formats. You can also add spaces at the end of the lines, or even extra new lines after or before the text if you need.
Examples
Input Output
-----------------------------------
[3,2,1,0,5] Excelsior! // Excelsior because 5 > 0
[1,2,3,4,5] Excelsior! // Excelsior because 2 > 1
Excelsior!! // Excelsior because 3 > 2 (run length: 2)
Excelsior!!! // Excelsior because 4 > 3 (run length: 3)
Excelsior!!!! // Excelsior because 5 > 4 (run length: 4)
<Nothing>
[42] <Nothing>
[1,2,1,3,4,1,5] Excelsior! // Excelsior because 2 > 1
Excelsior! // Excelsior because 3 > 1
Excelsior!! // Excelsior because 4 > 3 (run length: 2)
Excelsior! // Excelsior because 5 > 1
[3,3,3,3,4,3] Excelsior! // Excelsior because 4 > 3
This is code-golf, so may the shortest code for each language win!
code-golf string number
|
show 2 more comments
up vote
14
down vote
favorite
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:
Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s what I wish you whenever I finish tweeting! Excelsior!
Challenge
Given a series of non-negative integers, output a line with Excelsior!
every time an integer is greater than the previous one.
Rules
- Input will be an array of non-negative integers.
- Output will consist of lines with the word
Excelsior
(case does matter) followed by as many!
as the length of the current run of increasingly greater numbers. You can also return an array of strings. - Input and output formats are flexible according to the site rules, so feel free to adapt them to your language formats. You can also add spaces at the end of the lines, or even extra new lines after or before the text if you need.
Examples
Input Output
-----------------------------------
[3,2,1,0,5] Excelsior! // Excelsior because 5 > 0
[1,2,3,4,5] Excelsior! // Excelsior because 2 > 1
Excelsior!! // Excelsior because 3 > 2 (run length: 2)
Excelsior!!! // Excelsior because 4 > 3 (run length: 3)
Excelsior!!!! // Excelsior because 5 > 4 (run length: 4)
<Nothing>
[42] <Nothing>
[1,2,1,3,4,1,5] Excelsior! // Excelsior because 2 > 1
Excelsior! // Excelsior because 3 > 1
Excelsior!! // Excelsior because 4 > 3 (run length: 2)
Excelsior! // Excelsior because 5 > 1
[3,3,3,3,4,3] Excelsior! // Excelsior because 4 > 3
This is code-golf, so may the shortest code for each language win!
code-golf string number
ouflak assumes integers are 1 digit long, is that ok
– ASCII-only
2 days ago
1
@ASCII-only not really. I don't know if LUA has a limitation with that, but if that's not the case ouflak should parse integers of any length.
– Charlie
2 days ago
@Charlie I don't know Lua, but although it's verbose, it is possible to take for example a space-delimited input and split like this.
– Kevin Cruijssen
2 days ago
I'm looking at it. The trick is to be able to handle both scenarios.
– ouflak
2 days ago
FWIW languages like C or Javascript will only handle integers within its precision (9/16 digits) anyway.
– user202729
2 days ago
|
show 2 more comments
up vote
14
down vote
favorite
up vote
14
down vote
favorite
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:
Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s what I wish you whenever I finish tweeting! Excelsior!
Challenge
Given a series of non-negative integers, output a line with Excelsior!
every time an integer is greater than the previous one.
Rules
- Input will be an array of non-negative integers.
- Output will consist of lines with the word
Excelsior
(case does matter) followed by as many!
as the length of the current run of increasingly greater numbers. You can also return an array of strings. - Input and output formats are flexible according to the site rules, so feel free to adapt them to your language formats. You can also add spaces at the end of the lines, or even extra new lines after or before the text if you need.
Examples
Input Output
-----------------------------------
[3,2,1,0,5] Excelsior! // Excelsior because 5 > 0
[1,2,3,4,5] Excelsior! // Excelsior because 2 > 1
Excelsior!! // Excelsior because 3 > 2 (run length: 2)
Excelsior!!! // Excelsior because 4 > 3 (run length: 3)
Excelsior!!!! // Excelsior because 5 > 4 (run length: 4)
<Nothing>
[42] <Nothing>
[1,2,1,3,4,1,5] Excelsior! // Excelsior because 2 > 1
Excelsior! // Excelsior because 3 > 1
Excelsior!! // Excelsior because 4 > 3 (run length: 2)
Excelsior! // Excelsior because 5 > 1
[3,3,3,3,4,3] Excelsior! // Excelsior because 4 > 3
This is code-golf, so may the shortest code for each language win!
code-golf string number
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:
Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s what I wish you whenever I finish tweeting! Excelsior!
Challenge
Given a series of non-negative integers, output a line with Excelsior!
every time an integer is greater than the previous one.
Rules
- Input will be an array of non-negative integers.
- Output will consist of lines with the word
Excelsior
(case does matter) followed by as many!
as the length of the current run of increasingly greater numbers. You can also return an array of strings. - Input and output formats are flexible according to the site rules, so feel free to adapt them to your language formats. You can also add spaces at the end of the lines, or even extra new lines after or before the text if you need.
Examples
Input Output
-----------------------------------
[3,2,1,0,5] Excelsior! // Excelsior because 5 > 0
[1,2,3,4,5] Excelsior! // Excelsior because 2 > 1
Excelsior!! // Excelsior because 3 > 2 (run length: 2)
Excelsior!!! // Excelsior because 4 > 3 (run length: 3)
Excelsior!!!! // Excelsior because 5 > 4 (run length: 4)
<Nothing>
[42] <Nothing>
[1,2,1,3,4,1,5] Excelsior! // Excelsior because 2 > 1
Excelsior! // Excelsior because 3 > 1
Excelsior!! // Excelsior because 4 > 3 (run length: 2)
Excelsior! // Excelsior because 5 > 1
[3,3,3,3,4,3] Excelsior! // Excelsior because 4 > 3
This is code-golf, so may the shortest code for each language win!
code-golf string number
code-golf string number
asked 2 days ago
Charlie
7,2812388
7,2812388
ouflak assumes integers are 1 digit long, is that ok
– ASCII-only
2 days ago
1
@ASCII-only not really. I don't know if LUA has a limitation with that, but if that's not the case ouflak should parse integers of any length.
– Charlie
2 days ago
@Charlie I don't know Lua, but although it's verbose, it is possible to take for example a space-delimited input and split like this.
– Kevin Cruijssen
2 days ago
I'm looking at it. The trick is to be able to handle both scenarios.
– ouflak
2 days ago
FWIW languages like C or Javascript will only handle integers within its precision (9/16 digits) anyway.
– user202729
2 days ago
|
show 2 more comments
ouflak assumes integers are 1 digit long, is that ok
– ASCII-only
2 days ago
1
@ASCII-only not really. I don't know if LUA has a limitation with that, but if that's not the case ouflak should parse integers of any length.
– Charlie
2 days ago
@Charlie I don't know Lua, but although it's verbose, it is possible to take for example a space-delimited input and split like this.
– Kevin Cruijssen
2 days ago
I'm looking at it. The trick is to be able to handle both scenarios.
– ouflak
2 days ago
FWIW languages like C or Javascript will only handle integers within its precision (9/16 digits) anyway.
– user202729
2 days ago
ouflak assumes integers are 1 digit long, is that ok
– ASCII-only
2 days ago
ouflak assumes integers are 1 digit long, is that ok
– ASCII-only
2 days ago
1
1
@ASCII-only not really. I don't know if LUA has a limitation with that, but if that's not the case ouflak should parse integers of any length.
– Charlie
2 days ago
@ASCII-only not really. I don't know if LUA has a limitation with that, but if that's not the case ouflak should parse integers of any length.
– Charlie
2 days ago
@Charlie I don't know Lua, but although it's verbose, it is possible to take for example a space-delimited input and split like this.
– Kevin Cruijssen
2 days ago
@Charlie I don't know Lua, but although it's verbose, it is possible to take for example a space-delimited input and split like this.
– Kevin Cruijssen
2 days ago
I'm looking at it. The trick is to be able to handle both scenarios.
– ouflak
2 days ago
I'm looking at it. The trick is to be able to handle both scenarios.
– ouflak
2 days ago
FWIW languages like C or Javascript will only handle integers within its precision (9/16 digits) anyway.
– user202729
2 days ago
FWIW languages like C or Javascript will only handle integers within its precision (9/16 digits) anyway.
– user202729
2 days ago
|
show 2 more comments
28 Answers
28
active
oldest
votes
up vote
9
down vote
JavaScript (ES6), 58 54 bytes
a=>a.map(c=>a<(a=c)?`Excelsior${s+='!'}
`:s='').join``
Try it online!
Commented
a => // a = input array, also used to store the previous value
a.map(c => // for each value c in a:
a < // compare the previous value
(a = c) // with the current one; update a to c
// this test is always falsy on the 1st iteration
? // if a is less than c:
`Excelsior${s += '!'}n` // add a '!' to s and yield 'Excelsior' + s + linefeed
: // else:
s = '' // reset s to an empty string and yield an empty string
).join`` // end of map(); join everything
Why re-using a[ ] to store the previous value is safe
There are three possible cases:
- If $a[text{ }]$ is empty, the callback function of
.map()
is not invoked at all and we just get an empty array, yielding an empty string. - If $a[text{ }]$ contains exactly one element $x$, it is coerced to that element during the first (and unique) test
a < (a = c)
. So, we're testing $x < x$, which is falsy. We get an array containing an empty string, yielding again an empty string. - If $a[text{ }]$ contains several elements, it is coerced to
NaN
during the first testa < (a = c)
. Therefore, the result is falsy and what's executed is the initialization of $s$ to an empty string -- which is what we want. The first meaningful comparison occurs at the 2nd iteration.
add a comment |
up vote
5
down vote
Python 2, 84 83 81 70 68 bytes
a=n=''
for b in input():
n+='!';n*=a<b;a=b
if n:print'Excelsior'+n
Try it online!
-2 bytes, thanks to ASCII-only
68?
– ASCII-only
2 days ago
@ASCII-only Thanks :)
– TFeld
2 days ago
functions are too long :(
– ASCII-only
2 days ago
well, recursive approaches at least
– ASCII-only
2 days ago
same with zip
– ASCII-only
2 days ago
add a comment |
up vote
5
down vote
05AB1E, 26 24 23 bytes
ü‹γvyOE.•1Š¥èò²•™N'!׫,
-2 bytes thanks to @Kroppeb.
Try it online or verify all test cases.
Explanation:
ü # Loop over the (implicit) input as pairs
‹ # And check for each pair [a,b] if a<b is truthy
# i.e. [1,2,1,3,4,1,5,7,20,25,3,17]
# → [1,0,1,1,0,1,1,1,1,0,1]
γ # Split it into chunks of equal elements
# i.e. [1,0,1,1,0,1,1,1,1,0,1]
# → [[1],[0],[1,1],[0],[1,1,1,1],[0],[1]]
vy # Foreach `y` over them
O # Take the sum of that inner list
# i.e. [1,1,1,1] → 4
# i.e. [0] → 0
E # Inner loop `N` in the range [1, length]:
.•1Š¥èò²• # Push string "excelsior"
™ # Titlecase it: "Excelsior"
N'!׫ '# Append `N` amount of "!"
# i.e. N=3 → "Excelsior!!!"
, # Output with a trailing newline
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•1Š¥èò²•
is "excelsior"
.
2
I don't really know 05AB1E but can't you exchange the0Kg
withO
?
– Kroppeb
2 days ago
@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)
– Kevin Cruijssen
2 days ago
add a comment |
up vote
5
down vote
Perl 6, 60 58 57 bytes
-1 byte thanks to nwellnhof
{"Excelsior"X~("!"Xx grep +*,[[&(-+^*×*)]] .skip Z>$_)}
Try it online!
Anonymous code block that returns a list of Excelsiors!
add a comment |
up vote
4
down vote
Java-8 118 113 Bytes
n->{String e="";for(int i=0;i<n.length-1;)System.out.print(""==(n[i+1]>n[i++]?e+="!":(e=""))?e:"Excelsior"+e+"n");}
Easy to read :
private static void lee(int num) {
String exclamation = "";
for (int i = 0; i < num.length - 1;) {
exclamation = num[i + 1] > num[i++] ? exclamation += "!" : "";
System.out.print("".equals(exclamation) ? "" : "Excelsior" + exclamation + "n");
}
}
2
Here some golfs to save 10 bytes:n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"n"))e=n[i++]<n[i]?e+="!":"";}
. Try it online (108 bytes). (Java 10+)
– Kevin Cruijssen
2 days ago
@KevinCruijssen Thanks!
– coder-croc
2 days ago
2
n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;}
(107 bytes)
– Olivier Grégoire
2 days ago
Fixing my issue:++e
instead ofe++
so that there is at least one!
to be printed.
– Olivier Grégoire
yesterday
add a comment |
up vote
4
down vote
R, 86 bytes
Half of this answer is @Giuseppe's. RIP Stan Lee.
function(a)for(i in diff(a))"if"(i>0,cat("Excelsior",rep("!",F<-F+1),"
",sep=""),F<-0)
Try it online!
add a comment |
up vote
4
down vote
05AB1E, 20 19 bytes
ü‹0¡€ƶ˜ε'!×”¸Îsiorÿ
Try it online!
Explanation
ü‹ # pair-wise comparison, less-than
0¡ # split at zeroes
€ƶ # lift each, multiplying by its 1-based index
˜ # flatten
ε # apply to each
'!× # repeat "!" that many times
ÿ # and interpolate it at the end of
”¸Îsior # the compressed word "Excel" followed by the string "sior"
add a comment |
up vote
4
down vote
C (gcc/clang), 106 99 97 bytes
f(a,n)int*a;{int r=0,s[n];for(memset(s,33,n);n-->1;)r*=*a<*++a&&printf("Excelsior%.*sn",++r,s);}
Thanks to gastropner for golfing 2 bytes.
Try it online here.
Ungolfed:
f(a, n) // function taking a pointer to the first integer and the length of the array
int *a; { // a is of type pointer to int, n is of type int
int r = 0, // length of the current run
i = 0, // loop variable
s[n]; // buffer for exclamation marks; we will never need more than n-1 of those (we are declaring an array of int, but really we will treat it as an array of char)
for(memset(s, 33, n); // fill the buffer with n exclamation marks (ASCII code 33)
n -- > 1; ) // loop over the array
r *= *a < *(++ a) // if the current element is less than the next:
&& printf("Excelsior%.*sn", // print (on their own line) "Excelsior", followed by ...
++ r, // ... r (incremented) of the ...
s) // ... n exclamation marks in the buffer s
; // else r is reset to 0
}
I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.
– gastropner
yesterday
@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.
– O.O.Balance
12 hours ago
add a comment |
up vote
4
down vote
Japt -R
, 25 22 bytes
ò¨ ËÅ£`ExlÐâ`ú'!Y+A
c
Try it
3 bytes saved thanks to Kamil
ò¨ :Partition at items that are greater than or equal to the previous item
Ë :Map
Å : Slice off the first element
£ : Map each element at 0-based index Y
`ExlÐâ` : Compressed string "Excelsior"
ú'! : Right pad with exclamation marks
Y+A : To length Y+10
c :Flatten
:Implicitly join with newlines & output
Another 25 bytes
– Luis felipe De jesus Munoz
2 days ago
The-R
flag isn't actually necessary, the challenge says you can output an array of strings.
– Kamil Drakari
2 days ago
Nice one, thanks, @KamilDrakari. I tried a solution usingslice
on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.
– Shaggy
10 hours ago
add a comment |
up vote
3
down vote
Common Lisp, 111 bytes
(setq i 0)(loop for(a b)on(read)do(incf i(if(and b(> b a))1(- i)))(format(> i 0)"Excelsior~v@{~a~:*~}~%"i #!))
Try it online!
add a comment |
up vote
3
down vote
Java 8, 106 bytes
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]<n[i]?"Excelsior"+(s+="!")+"n":(s="")+s;return z;}
Try it online!
(those reassignments of s
...yikes)
You can golf two more bytes by replacing(s="")+s
=>(s="")
– O.O.Balance
yesterday
1
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"n";return z;}
(103 bytes) Move thes=""
to spare bytes.
– Olivier Grégoire
yesterday
add a comment |
up vote
3
down vote
Stax, 17 bytes
Θx7├╖&σ '@7g┼┘Ñ«═
Run and debug it
add a comment |
up vote
3
down vote
R, 111 bytes
function(a,r=rle(sign(diff(a))),v=r$l[r$v>0])write(paste0(rep("Excelsior",sum(v)),strrep("!",sequence(v))),1,1)
Try it online!
A far better R tribute can be found here -- I was too fixated on sequence
and rle
.
This doesn't give some blank lines, but 86 bytes?
– J.Doe
2 days ago
2
@J.Doe dang, that's way better. I'd post that myself if I were you.
– Giuseppe
2 days ago
add a comment |
up vote
3
down vote
Jelly, 16 bytes
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ
A monadic Link yielding a list of lists of characters.
Try it online! (footer joins with newlines)
How?
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ - Link: list of integers e.g. [1,1,4,2,1,1,3,4]
Ɲ - for each pair of integers: [1,1] [1,4] [4,2] [2,1] [1,1] [1,3] [3,4]
< - less than? [ 0, 1, 0, 0, 0, 1, 1]
ṣ0 - split at zeros [, [1], , , [1, 1]]
Ä - cumulative sums [, [1], , , [1, 2]]
Ẏ - tighten [1,1,2]
”! - literal '!' character '!'
ẋ - repeat (vectorises) [['!'],['!'],['!','!']]
“Ø6ḥ» - dictionary lookup ['E','x','c','e','l','s','i','o','r']
Ɱ - map with:
; - concatenate [['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!','!']]
add a comment |
up vote
3
down vote
Perl 5 -n
, 41 bytes
$_>$l&&$l?say$c.='!':($c=Excelsior);$l=$_
Try it online!
Takes its input on separate lines.
add a comment |
up vote
3
down vote
Japt, 22 bytes
ò¨ ®£`ExlÐâ`+'!pYÃÅÃc
Try it online!
Explanation, with simplified example:
ò¨ :Split whenever the sequence does not increase
e.g. [2,1,1,3] -> [[2],[1],[1,3]]
® Ã :For each sub-array:
£ Ã : For each item in that sub-array:
`ExlÐâ` : Compressed "Excelsior"
+ : Concat with
'!pY : a number of "!" equal to the index
e.g. [1,3] -> ["Excelsior","Excelsior!"]
Å : Remove the first item of each sub-array
e.g. [[Excelsior],[Excelsior],[Excelsior,Excelsior!]]->[,,[Excelsior!]]
c :Flatten
e.g. [,,[Excelsior!]] -> [Excelsior!]
add a comment |
up vote
2
down vote
Retina, 55 bytes
d+
*
L$rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Excelsior$#1*!
Try it online! Link includes test cases. Explanation:
d+
*
Convert to unary.
rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Process overlapping matches from right to left (although the matches are then listed from left to right). This means that we can match every number in a run, and the match extends to the start of the run. Each match is further constrained that each additional matched number must be less than the previously matched additional number, or the first number if no additional numbers have been matched yet.
L$...
Excelsior$#1*!
For each match, output Excelsior
with the number of additional numbers in the run as desired.
add a comment |
up vote
2
down vote
Pyth, 32 bytes
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0
Try it online here, or verify all the test cases at once here.
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0 Implicit: Q=eval(input())
.+Q Get forward difference between consecutive elements of Q
.u 0 Reduce the above, returning all steps, with current value N starting at 0, next element as Y, using:
hN N+1
* Multiplied by
<0Y 1 if 0<Y, 0 otherwise
fT Filter to remove 0s
*L! Repeat "!" each element number of times
+L"Excelsior" Prepend "Excelsior" to each
j Join on newlines, implicit print
add a comment |
up vote
2
down vote
Jelly, 18 bytes
<Ɲ‘×¥ḟ0”!ẋ“Ø6ḥ»;Ɱ
Try it online!
Output prettified over TIO.
add a comment |
up vote
2
down vote
Lua, 88 87 83 82 96 95 113 bytes
Thanks @Kevin Cruijssen for update adhering to spirit of original question.
s=io.read()n=9 e="Excelsior!"f=e
for c in s.gmatch(s,"%S+")do if n<c+0then print(e)e=e..'!'else e=f end n=c+0 end
Try it online!
1
Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).
– Charlie
2 days ago
No problem. Think I've done as much as I can do here unless someone else sees something...
– ouflak
2 days ago
1
I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..
– Kevin Cruijssen
2 days ago
2
Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.
– Kevin Cruijssen
2 days ago
I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!
– ouflak
2 days ago
add a comment |
up vote
2
down vote
C++ 14 (g++), 123 118 bytes
(auto a){for(int n=0,i=0;++i<a.size();)a[i]>a[i-1]?puts(&("Excelsior"+std::string(++n,33))[0]):n=0;}
Fortunately std::string
has a constructor that repeats a char
. Try it online here.
Thanks to gastropner for saving 5 bytes.
Ungolfed:
(auto a) { // void lambda taking a std::array of integer
for(int n = 0, // length of the current run
i = 0; // loop variable
++ i < a.size(); ) // start with the second element and loop to the last
a[i] > a[i - 1] // if the current element is greater than the previous ...
? puts( // ... print a new line:
&("Excelsior" + // "Excelsior, followed by ...
std::string(++ n, 33)) // ... the appropriate number of exclamation marks (33 is ASCII code for '!'); increment the run length
[0]) // puts() takes a C string
: n = 0; // else reset run length
}
You can shave off another 5 bytes
– gastropner
2 days ago
add a comment |
up vote
2
down vote
C# (.NET Core), 115 107 105 bytes
a=>{var b="";for(int i=0;++i<a.Length;)if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));else b="";}
Try it online!
-8 bytes: changed b
to a string holding "!"s from an int counter
-2 bytes: set b+="!"
as an inline function (thanks to Zac Faragher)
Uses an Action delegate to pull in the input and not require a return.
Ungolfed:
a => {
var b = ""; // initialize the '!' string (b)
for(int i = 0; ++i < a.Length;) // from index 1 until the end of a
if(a[i] > a[i - 1]) // if the current index is greater than the previous index
Console.WriteLine("Excelsior" + // on a new line, print "Excelsior"
(b += "!")); // add a "!" to b, and print the string
else // if the current index is not greater than the previous index
b = ""; // reset b
}
1
you can save 2 bytes by making theb+="!"
inline with the Excelsiorif(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!
– Zac Faragher
23 hours ago
add a comment |
up vote
2
down vote
PHP, 117 109 bytes
<?php do{$i=next($argv);if($p!==null&&$p<$i){$e.='!';echo "
Excelsior$e";}else$e='';$p=$i;}while($i!==false);
Try it online!
add a comment |
up vote
1
down vote
Java, 113 bytes
String i="";for(int a=0;a<s.length-1;a++){if(s[a+1]>s[a]){i+="!";System.out.println("Excelsior"+i);}else{i="";}}
New contributor
add a comment |
up vote
1
down vote
VBA, 114 bytes
For i=0 To UBound(a)-LBound(a)-1 If a(i+1)>a(i)Then s=s&"!" Debug.Print("Excelsior"&s&"") Else s="" End If Next i
New contributor
add a comment |
up vote
1
down vote
Python 3, 87 bytes
c='!'
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
Or 97 with the following:
c='!';n=input()
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
This assumes inputs will be in the format:
32105
12345
<null input>
1
1213415
333343
New contributor
Your first program is invalid as it takes input through a predefined variable. The second is invalud as it can't distinguish between numbers with multiple digits. Why not use Python 2 or turn it into a function instead?
– Jo King
5 hours ago
add a comment |
up vote
0
down vote
Japt, 25 bytes
ä< ®?`ExlÐâ`+'!p°T:T=0
f
Try it online!
add a comment |
up vote
0
down vote
J, 50 bytes
'Excelsior',"1'!'#"0~[:;@(([:<+/);._1)0,2</ ::0]
Try it online!
ungolfed
'Excelsior' ,"1 '!' #"0~ [: ;@(([: < +/);._1) 0 , 2 </ ::0 ]
add a comment |
28 Answers
28
active
oldest
votes
28 Answers
28
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
JavaScript (ES6), 58 54 bytes
a=>a.map(c=>a<(a=c)?`Excelsior${s+='!'}
`:s='').join``
Try it online!
Commented
a => // a = input array, also used to store the previous value
a.map(c => // for each value c in a:
a < // compare the previous value
(a = c) // with the current one; update a to c
// this test is always falsy on the 1st iteration
? // if a is less than c:
`Excelsior${s += '!'}n` // add a '!' to s and yield 'Excelsior' + s + linefeed
: // else:
s = '' // reset s to an empty string and yield an empty string
).join`` // end of map(); join everything
Why re-using a[ ] to store the previous value is safe
There are three possible cases:
- If $a[text{ }]$ is empty, the callback function of
.map()
is not invoked at all and we just get an empty array, yielding an empty string. - If $a[text{ }]$ contains exactly one element $x$, it is coerced to that element during the first (and unique) test
a < (a = c)
. So, we're testing $x < x$, which is falsy. We get an array containing an empty string, yielding again an empty string. - If $a[text{ }]$ contains several elements, it is coerced to
NaN
during the first testa < (a = c)
. Therefore, the result is falsy and what's executed is the initialization of $s$ to an empty string -- which is what we want. The first meaningful comparison occurs at the 2nd iteration.
add a comment |
up vote
9
down vote
JavaScript (ES6), 58 54 bytes
a=>a.map(c=>a<(a=c)?`Excelsior${s+='!'}
`:s='').join``
Try it online!
Commented
a => // a = input array, also used to store the previous value
a.map(c => // for each value c in a:
a < // compare the previous value
(a = c) // with the current one; update a to c
// this test is always falsy on the 1st iteration
? // if a is less than c:
`Excelsior${s += '!'}n` // add a '!' to s and yield 'Excelsior' + s + linefeed
: // else:
s = '' // reset s to an empty string and yield an empty string
).join`` // end of map(); join everything
Why re-using a[ ] to store the previous value is safe
There are three possible cases:
- If $a[text{ }]$ is empty, the callback function of
.map()
is not invoked at all and we just get an empty array, yielding an empty string. - If $a[text{ }]$ contains exactly one element $x$, it is coerced to that element during the first (and unique) test
a < (a = c)
. So, we're testing $x < x$, which is falsy. We get an array containing an empty string, yielding again an empty string. - If $a[text{ }]$ contains several elements, it is coerced to
NaN
during the first testa < (a = c)
. Therefore, the result is falsy and what's executed is the initialization of $s$ to an empty string -- which is what we want. The first meaningful comparison occurs at the 2nd iteration.
add a comment |
up vote
9
down vote
up vote
9
down vote
JavaScript (ES6), 58 54 bytes
a=>a.map(c=>a<(a=c)?`Excelsior${s+='!'}
`:s='').join``
Try it online!
Commented
a => // a = input array, also used to store the previous value
a.map(c => // for each value c in a:
a < // compare the previous value
(a = c) // with the current one; update a to c
// this test is always falsy on the 1st iteration
? // if a is less than c:
`Excelsior${s += '!'}n` // add a '!' to s and yield 'Excelsior' + s + linefeed
: // else:
s = '' // reset s to an empty string and yield an empty string
).join`` // end of map(); join everything
Why re-using a[ ] to store the previous value is safe
There are three possible cases:
- If $a[text{ }]$ is empty, the callback function of
.map()
is not invoked at all and we just get an empty array, yielding an empty string. - If $a[text{ }]$ contains exactly one element $x$, it is coerced to that element during the first (and unique) test
a < (a = c)
. So, we're testing $x < x$, which is falsy. We get an array containing an empty string, yielding again an empty string. - If $a[text{ }]$ contains several elements, it is coerced to
NaN
during the first testa < (a = c)
. Therefore, the result is falsy and what's executed is the initialization of $s$ to an empty string -- which is what we want. The first meaningful comparison occurs at the 2nd iteration.
JavaScript (ES6), 58 54 bytes
a=>a.map(c=>a<(a=c)?`Excelsior${s+='!'}
`:s='').join``
Try it online!
Commented
a => // a = input array, also used to store the previous value
a.map(c => // for each value c in a:
a < // compare the previous value
(a = c) // with the current one; update a to c
// this test is always falsy on the 1st iteration
? // if a is less than c:
`Excelsior${s += '!'}n` // add a '!' to s and yield 'Excelsior' + s + linefeed
: // else:
s = '' // reset s to an empty string and yield an empty string
).join`` // end of map(); join everything
Why re-using a[ ] to store the previous value is safe
There are three possible cases:
- If $a[text{ }]$ is empty, the callback function of
.map()
is not invoked at all and we just get an empty array, yielding an empty string. - If $a[text{ }]$ contains exactly one element $x$, it is coerced to that element during the first (and unique) test
a < (a = c)
. So, we're testing $x < x$, which is falsy. We get an array containing an empty string, yielding again an empty string. - If $a[text{ }]$ contains several elements, it is coerced to
NaN
during the first testa < (a = c)
. Therefore, the result is falsy and what's executed is the initialization of $s$ to an empty string -- which is what we want. The first meaningful comparison occurs at the 2nd iteration.
edited 2 days ago
answered 2 days ago
Arnauld
68.6k584289
68.6k584289
add a comment |
add a comment |
up vote
5
down vote
Python 2, 84 83 81 70 68 bytes
a=n=''
for b in input():
n+='!';n*=a<b;a=b
if n:print'Excelsior'+n
Try it online!
-2 bytes, thanks to ASCII-only
68?
– ASCII-only
2 days ago
@ASCII-only Thanks :)
– TFeld
2 days ago
functions are too long :(
– ASCII-only
2 days ago
well, recursive approaches at least
– ASCII-only
2 days ago
same with zip
– ASCII-only
2 days ago
add a comment |
up vote
5
down vote
Python 2, 84 83 81 70 68 bytes
a=n=''
for b in input():
n+='!';n*=a<b;a=b
if n:print'Excelsior'+n
Try it online!
-2 bytes, thanks to ASCII-only
68?
– ASCII-only
2 days ago
@ASCII-only Thanks :)
– TFeld
2 days ago
functions are too long :(
– ASCII-only
2 days ago
well, recursive approaches at least
– ASCII-only
2 days ago
same with zip
– ASCII-only
2 days ago
add a comment |
up vote
5
down vote
up vote
5
down vote
Python 2, 84 83 81 70 68 bytes
a=n=''
for b in input():
n+='!';n*=a<b;a=b
if n:print'Excelsior'+n
Try it online!
-2 bytes, thanks to ASCII-only
Python 2, 84 83 81 70 68 bytes
a=n=''
for b in input():
n+='!';n*=a<b;a=b
if n:print'Excelsior'+n
Try it online!
-2 bytes, thanks to ASCII-only
edited 2 days ago
answered 2 days ago
TFeld
13.5k21139
13.5k21139
68?
– ASCII-only
2 days ago
@ASCII-only Thanks :)
– TFeld
2 days ago
functions are too long :(
– ASCII-only
2 days ago
well, recursive approaches at least
– ASCII-only
2 days ago
same with zip
– ASCII-only
2 days ago
add a comment |
68?
– ASCII-only
2 days ago
@ASCII-only Thanks :)
– TFeld
2 days ago
functions are too long :(
– ASCII-only
2 days ago
well, recursive approaches at least
– ASCII-only
2 days ago
same with zip
– ASCII-only
2 days ago
68?
– ASCII-only
2 days ago
68?
– ASCII-only
2 days ago
@ASCII-only Thanks :)
– TFeld
2 days ago
@ASCII-only Thanks :)
– TFeld
2 days ago
functions are too long :(
– ASCII-only
2 days ago
functions are too long :(
– ASCII-only
2 days ago
well, recursive approaches at least
– ASCII-only
2 days ago
well, recursive approaches at least
– ASCII-only
2 days ago
same with zip
– ASCII-only
2 days ago
same with zip
– ASCII-only
2 days ago
add a comment |
up vote
5
down vote
05AB1E, 26 24 23 bytes
ü‹γvyOE.•1Š¥èò²•™N'!׫,
-2 bytes thanks to @Kroppeb.
Try it online or verify all test cases.
Explanation:
ü # Loop over the (implicit) input as pairs
‹ # And check for each pair [a,b] if a<b is truthy
# i.e. [1,2,1,3,4,1,5,7,20,25,3,17]
# → [1,0,1,1,0,1,1,1,1,0,1]
γ # Split it into chunks of equal elements
# i.e. [1,0,1,1,0,1,1,1,1,0,1]
# → [[1],[0],[1,1],[0],[1,1,1,1],[0],[1]]
vy # Foreach `y` over them
O # Take the sum of that inner list
# i.e. [1,1,1,1] → 4
# i.e. [0] → 0
E # Inner loop `N` in the range [1, length]:
.•1Š¥èò²• # Push string "excelsior"
™ # Titlecase it: "Excelsior"
N'!׫ '# Append `N` amount of "!"
# i.e. N=3 → "Excelsior!!!"
, # Output with a trailing newline
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•1Š¥èò²•
is "excelsior"
.
2
I don't really know 05AB1E but can't you exchange the0Kg
withO
?
– Kroppeb
2 days ago
@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)
– Kevin Cruijssen
2 days ago
add a comment |
up vote
5
down vote
05AB1E, 26 24 23 bytes
ü‹γvyOE.•1Š¥èò²•™N'!׫,
-2 bytes thanks to @Kroppeb.
Try it online or verify all test cases.
Explanation:
ü # Loop over the (implicit) input as pairs
‹ # And check for each pair [a,b] if a<b is truthy
# i.e. [1,2,1,3,4,1,5,7,20,25,3,17]
# → [1,0,1,1,0,1,1,1,1,0,1]
γ # Split it into chunks of equal elements
# i.e. [1,0,1,1,0,1,1,1,1,0,1]
# → [[1],[0],[1,1],[0],[1,1,1,1],[0],[1]]
vy # Foreach `y` over them
O # Take the sum of that inner list
# i.e. [1,1,1,1] → 4
# i.e. [0] → 0
E # Inner loop `N` in the range [1, length]:
.•1Š¥èò²• # Push string "excelsior"
™ # Titlecase it: "Excelsior"
N'!׫ '# Append `N` amount of "!"
# i.e. N=3 → "Excelsior!!!"
, # Output with a trailing newline
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•1Š¥èò²•
is "excelsior"
.
2
I don't really know 05AB1E but can't you exchange the0Kg
withO
?
– Kroppeb
2 days ago
@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)
– Kevin Cruijssen
2 days ago
add a comment |
up vote
5
down vote
up vote
5
down vote
05AB1E, 26 24 23 bytes
ü‹γvyOE.•1Š¥èò²•™N'!׫,
-2 bytes thanks to @Kroppeb.
Try it online or verify all test cases.
Explanation:
ü # Loop over the (implicit) input as pairs
‹ # And check for each pair [a,b] if a<b is truthy
# i.e. [1,2,1,3,4,1,5,7,20,25,3,17]
# → [1,0,1,1,0,1,1,1,1,0,1]
γ # Split it into chunks of equal elements
# i.e. [1,0,1,1,0,1,1,1,1,0,1]
# → [[1],[0],[1,1],[0],[1,1,1,1],[0],[1]]
vy # Foreach `y` over them
O # Take the sum of that inner list
# i.e. [1,1,1,1] → 4
# i.e. [0] → 0
E # Inner loop `N` in the range [1, length]:
.•1Š¥èò²• # Push string "excelsior"
™ # Titlecase it: "Excelsior"
N'!׫ '# Append `N` amount of "!"
# i.e. N=3 → "Excelsior!!!"
, # Output with a trailing newline
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•1Š¥èò²•
is "excelsior"
.
05AB1E, 26 24 23 bytes
ü‹γvyOE.•1Š¥èò²•™N'!׫,
-2 bytes thanks to @Kroppeb.
Try it online or verify all test cases.
Explanation:
ü # Loop over the (implicit) input as pairs
‹ # And check for each pair [a,b] if a<b is truthy
# i.e. [1,2,1,3,4,1,5,7,20,25,3,17]
# → [1,0,1,1,0,1,1,1,1,0,1]
γ # Split it into chunks of equal elements
# i.e. [1,0,1,1,0,1,1,1,1,0,1]
# → [[1],[0],[1,1],[0],[1,1,1,1],[0],[1]]
vy # Foreach `y` over them
O # Take the sum of that inner list
# i.e. [1,1,1,1] → 4
# i.e. [0] → 0
E # Inner loop `N` in the range [1, length]:
.•1Š¥èò²• # Push string "excelsior"
™ # Titlecase it: "Excelsior"
N'!׫ '# Append `N` amount of "!"
# i.e. N=3 → "Excelsior!!!"
, # Output with a trailing newline
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•1Š¥èò²•
is "excelsior"
.
edited 2 days ago
answered 2 days ago
Kevin Cruijssen
34k554181
34k554181
2
I don't really know 05AB1E but can't you exchange the0Kg
withO
?
– Kroppeb
2 days ago
@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)
– Kevin Cruijssen
2 days ago
add a comment |
2
I don't really know 05AB1E but can't you exchange the0Kg
withO
?
– Kroppeb
2 days ago
@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)
– Kevin Cruijssen
2 days ago
2
2
I don't really know 05AB1E but can't you exchange the
0Kg
with O
?– Kroppeb
2 days ago
I don't really know 05AB1E but can't you exchange the
0Kg
with O
?– Kroppeb
2 days ago
@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)
– Kevin Cruijssen
2 days ago
@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)
– Kevin Cruijssen
2 days ago
add a comment |
up vote
5
down vote
Perl 6, 60 58 57 bytes
-1 byte thanks to nwellnhof
{"Excelsior"X~("!"Xx grep +*,[[&(-+^*×*)]] .skip Z>$_)}
Try it online!
Anonymous code block that returns a list of Excelsiors!
add a comment |
up vote
5
down vote
Perl 6, 60 58 57 bytes
-1 byte thanks to nwellnhof
{"Excelsior"X~("!"Xx grep +*,[[&(-+^*×*)]] .skip Z>$_)}
Try it online!
Anonymous code block that returns a list of Excelsiors!
add a comment |
up vote
5
down vote
up vote
5
down vote
Perl 6, 60 58 57 bytes
-1 byte thanks to nwellnhof
{"Excelsior"X~("!"Xx grep +*,[[&(-+^*×*)]] .skip Z>$_)}
Try it online!
Anonymous code block that returns a list of Excelsiors!
Perl 6, 60 58 57 bytes
-1 byte thanks to nwellnhof
{"Excelsior"X~("!"Xx grep +*,[[&(-+^*×*)]] .skip Z>$_)}
Try it online!
Anonymous code block that returns a list of Excelsiors!
edited 2 days ago
answered 2 days ago
Jo King
19.1k242102
19.1k242102
add a comment |
add a comment |
up vote
4
down vote
Java-8 118 113 Bytes
n->{String e="";for(int i=0;i<n.length-1;)System.out.print(""==(n[i+1]>n[i++]?e+="!":(e=""))?e:"Excelsior"+e+"n");}
Easy to read :
private static void lee(int num) {
String exclamation = "";
for (int i = 0; i < num.length - 1;) {
exclamation = num[i + 1] > num[i++] ? exclamation += "!" : "";
System.out.print("".equals(exclamation) ? "" : "Excelsior" + exclamation + "n");
}
}
2
Here some golfs to save 10 bytes:n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"n"))e=n[i++]<n[i]?e+="!":"";}
. Try it online (108 bytes). (Java 10+)
– Kevin Cruijssen
2 days ago
@KevinCruijssen Thanks!
– coder-croc
2 days ago
2
n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;}
(107 bytes)
– Olivier Grégoire
2 days ago
Fixing my issue:++e
instead ofe++
so that there is at least one!
to be printed.
– Olivier Grégoire
yesterday
add a comment |
up vote
4
down vote
Java-8 118 113 Bytes
n->{String e="";for(int i=0;i<n.length-1;)System.out.print(""==(n[i+1]>n[i++]?e+="!":(e=""))?e:"Excelsior"+e+"n");}
Easy to read :
private static void lee(int num) {
String exclamation = "";
for (int i = 0; i < num.length - 1;) {
exclamation = num[i + 1] > num[i++] ? exclamation += "!" : "";
System.out.print("".equals(exclamation) ? "" : "Excelsior" + exclamation + "n");
}
}
2
Here some golfs to save 10 bytes:n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"n"))e=n[i++]<n[i]?e+="!":"";}
. Try it online (108 bytes). (Java 10+)
– Kevin Cruijssen
2 days ago
@KevinCruijssen Thanks!
– coder-croc
2 days ago
2
n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;}
(107 bytes)
– Olivier Grégoire
2 days ago
Fixing my issue:++e
instead ofe++
so that there is at least one!
to be printed.
– Olivier Grégoire
yesterday
add a comment |
up vote
4
down vote
up vote
4
down vote
Java-8 118 113 Bytes
n->{String e="";for(int i=0;i<n.length-1;)System.out.print(""==(n[i+1]>n[i++]?e+="!":(e=""))?e:"Excelsior"+e+"n");}
Easy to read :
private static void lee(int num) {
String exclamation = "";
for (int i = 0; i < num.length - 1;) {
exclamation = num[i + 1] > num[i++] ? exclamation += "!" : "";
System.out.print("".equals(exclamation) ? "" : "Excelsior" + exclamation + "n");
}
}
Java-8 118 113 Bytes
n->{String e="";for(int i=0;i<n.length-1;)System.out.print(""==(n[i+1]>n[i++]?e+="!":(e=""))?e:"Excelsior"+e+"n");}
Easy to read :
private static void lee(int num) {
String exclamation = "";
for (int i = 0; i < num.length - 1;) {
exclamation = num[i + 1] > num[i++] ? exclamation += "!" : "";
System.out.print("".equals(exclamation) ? "" : "Excelsior" + exclamation + "n");
}
}
edited 2 days ago
answered 2 days ago
coder-croc
32738
32738
2
Here some golfs to save 10 bytes:n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"n"))e=n[i++]<n[i]?e+="!":"";}
. Try it online (108 bytes). (Java 10+)
– Kevin Cruijssen
2 days ago
@KevinCruijssen Thanks!
– coder-croc
2 days ago
2
n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;}
(107 bytes)
– Olivier Grégoire
2 days ago
Fixing my issue:++e
instead ofe++
so that there is at least one!
to be printed.
– Olivier Grégoire
yesterday
add a comment |
2
Here some golfs to save 10 bytes:n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"n"))e=n[i++]<n[i]?e+="!":"";}
. Try it online (108 bytes). (Java 10+)
– Kevin Cruijssen
2 days ago
@KevinCruijssen Thanks!
– coder-croc
2 days ago
2
n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;}
(107 bytes)
– Olivier Grégoire
2 days ago
Fixing my issue:++e
instead ofe++
so that there is at least one!
to be printed.
– Olivier Grégoire
yesterday
2
2
Here some golfs to save 10 bytes:
n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"n"))e=n[i++]<n[i]?e+="!":"";}
. Try it online (108 bytes). (Java 10+)– Kevin Cruijssen
2 days ago
Here some golfs to save 10 bytes:
n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"n"))e=n[i++]<n[i]?e+="!":"";}
. Try it online (108 bytes). (Java 10+)– Kevin Cruijssen
2 days ago
@KevinCruijssen Thanks!
– coder-croc
2 days ago
@KevinCruijssen Thanks!
– coder-croc
2 days ago
2
2
n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;}
(107 bytes)– Olivier Grégoire
2 days ago
n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;}
(107 bytes)– Olivier Grégoire
2 days ago
Fixing my issue:
++e
instead of e++
so that there is at least one !
to be printed.– Olivier Grégoire
yesterday
Fixing my issue:
++e
instead of e++
so that there is at least one !
to be printed.– Olivier Grégoire
yesterday
add a comment |
up vote
4
down vote
R, 86 bytes
Half of this answer is @Giuseppe's. RIP Stan Lee.
function(a)for(i in diff(a))"if"(i>0,cat("Excelsior",rep("!",F<-F+1),"
",sep=""),F<-0)
Try it online!
add a comment |
up vote
4
down vote
R, 86 bytes
Half of this answer is @Giuseppe's. RIP Stan Lee.
function(a)for(i in diff(a))"if"(i>0,cat("Excelsior",rep("!",F<-F+1),"
",sep=""),F<-0)
Try it online!
add a comment |
up vote
4
down vote
up vote
4
down vote
R, 86 bytes
Half of this answer is @Giuseppe's. RIP Stan Lee.
function(a)for(i in diff(a))"if"(i>0,cat("Excelsior",rep("!",F<-F+1),"
",sep=""),F<-0)
Try it online!
R, 86 bytes
Half of this answer is @Giuseppe's. RIP Stan Lee.
function(a)for(i in diff(a))"if"(i>0,cat("Excelsior",rep("!",F<-F+1),"
",sep=""),F<-0)
Try it online!
answered 2 days ago
J.Doe
1,951112
1,951112
add a comment |
add a comment |
up vote
4
down vote
05AB1E, 20 19 bytes
ü‹0¡€ƶ˜ε'!×”¸Îsiorÿ
Try it online!
Explanation
ü‹ # pair-wise comparison, less-than
0¡ # split at zeroes
€ƶ # lift each, multiplying by its 1-based index
˜ # flatten
ε # apply to each
'!× # repeat "!" that many times
ÿ # and interpolate it at the end of
”¸Îsior # the compressed word "Excel" followed by the string "sior"
add a comment |
up vote
4
down vote
05AB1E, 20 19 bytes
ü‹0¡€ƶ˜ε'!×”¸Îsiorÿ
Try it online!
Explanation
ü‹ # pair-wise comparison, less-than
0¡ # split at zeroes
€ƶ # lift each, multiplying by its 1-based index
˜ # flatten
ε # apply to each
'!× # repeat "!" that many times
ÿ # and interpolate it at the end of
”¸Îsior # the compressed word "Excel" followed by the string "sior"
add a comment |
up vote
4
down vote
up vote
4
down vote
05AB1E, 20 19 bytes
ü‹0¡€ƶ˜ε'!×”¸Îsiorÿ
Try it online!
Explanation
ü‹ # pair-wise comparison, less-than
0¡ # split at zeroes
€ƶ # lift each, multiplying by its 1-based index
˜ # flatten
ε # apply to each
'!× # repeat "!" that many times
ÿ # and interpolate it at the end of
”¸Îsior # the compressed word "Excel" followed by the string "sior"
05AB1E, 20 19 bytes
ü‹0¡€ƶ˜ε'!×”¸Îsiorÿ
Try it online!
Explanation
ü‹ # pair-wise comparison, less-than
0¡ # split at zeroes
€ƶ # lift each, multiplying by its 1-based index
˜ # flatten
ε # apply to each
'!× # repeat "!" that many times
ÿ # and interpolate it at the end of
”¸Îsior # the compressed word "Excel" followed by the string "sior"
edited yesterday
answered 2 days ago
Emigna
44.8k432136
44.8k432136
add a comment |
add a comment |
up vote
4
down vote
C (gcc/clang), 106 99 97 bytes
f(a,n)int*a;{int r=0,s[n];for(memset(s,33,n);n-->1;)r*=*a<*++a&&printf("Excelsior%.*sn",++r,s);}
Thanks to gastropner for golfing 2 bytes.
Try it online here.
Ungolfed:
f(a, n) // function taking a pointer to the first integer and the length of the array
int *a; { // a is of type pointer to int, n is of type int
int r = 0, // length of the current run
i = 0, // loop variable
s[n]; // buffer for exclamation marks; we will never need more than n-1 of those (we are declaring an array of int, but really we will treat it as an array of char)
for(memset(s, 33, n); // fill the buffer with n exclamation marks (ASCII code 33)
n -- > 1; ) // loop over the array
r *= *a < *(++ a) // if the current element is less than the next:
&& printf("Excelsior%.*sn", // print (on their own line) "Excelsior", followed by ...
++ r, // ... r (incremented) of the ...
s) // ... n exclamation marks in the buffer s
; // else r is reset to 0
}
I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.
– gastropner
yesterday
@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.
– O.O.Balance
12 hours ago
add a comment |
up vote
4
down vote
C (gcc/clang), 106 99 97 bytes
f(a,n)int*a;{int r=0,s[n];for(memset(s,33,n);n-->1;)r*=*a<*++a&&printf("Excelsior%.*sn",++r,s);}
Thanks to gastropner for golfing 2 bytes.
Try it online here.
Ungolfed:
f(a, n) // function taking a pointer to the first integer and the length of the array
int *a; { // a is of type pointer to int, n is of type int
int r = 0, // length of the current run
i = 0, // loop variable
s[n]; // buffer for exclamation marks; we will never need more than n-1 of those (we are declaring an array of int, but really we will treat it as an array of char)
for(memset(s, 33, n); // fill the buffer with n exclamation marks (ASCII code 33)
n -- > 1; ) // loop over the array
r *= *a < *(++ a) // if the current element is less than the next:
&& printf("Excelsior%.*sn", // print (on their own line) "Excelsior", followed by ...
++ r, // ... r (incremented) of the ...
s) // ... n exclamation marks in the buffer s
; // else r is reset to 0
}
I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.
– gastropner
yesterday
@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.
– O.O.Balance
12 hours ago
add a comment |
up vote
4
down vote
up vote
4
down vote
C (gcc/clang), 106 99 97 bytes
f(a,n)int*a;{int r=0,s[n];for(memset(s,33,n);n-->1;)r*=*a<*++a&&printf("Excelsior%.*sn",++r,s);}
Thanks to gastropner for golfing 2 bytes.
Try it online here.
Ungolfed:
f(a, n) // function taking a pointer to the first integer and the length of the array
int *a; { // a is of type pointer to int, n is of type int
int r = 0, // length of the current run
i = 0, // loop variable
s[n]; // buffer for exclamation marks; we will never need more than n-1 of those (we are declaring an array of int, but really we will treat it as an array of char)
for(memset(s, 33, n); // fill the buffer with n exclamation marks (ASCII code 33)
n -- > 1; ) // loop over the array
r *= *a < *(++ a) // if the current element is less than the next:
&& printf("Excelsior%.*sn", // print (on their own line) "Excelsior", followed by ...
++ r, // ... r (incremented) of the ...
s) // ... n exclamation marks in the buffer s
; // else r is reset to 0
}
C (gcc/clang), 106 99 97 bytes
f(a,n)int*a;{int r=0,s[n];for(memset(s,33,n);n-->1;)r*=*a<*++a&&printf("Excelsior%.*sn",++r,s);}
Thanks to gastropner for golfing 2 bytes.
Try it online here.
Ungolfed:
f(a, n) // function taking a pointer to the first integer and the length of the array
int *a; { // a is of type pointer to int, n is of type int
int r = 0, // length of the current run
i = 0, // loop variable
s[n]; // buffer for exclamation marks; we will never need more than n-1 of those (we are declaring an array of int, but really we will treat it as an array of char)
for(memset(s, 33, n); // fill the buffer with n exclamation marks (ASCII code 33)
n -- > 1; ) // loop over the array
r *= *a < *(++ a) // if the current element is less than the next:
&& printf("Excelsior%.*sn", // print (on their own line) "Excelsior", followed by ...
++ r, // ... r (incremented) of the ...
s) // ... n exclamation marks in the buffer s
; // else r is reset to 0
}
edited 11 hours ago
answered 2 days ago
O.O.Balance
1,2401318
1,2401318
I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.
– gastropner
yesterday
@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.
– O.O.Balance
12 hours ago
add a comment |
I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.
– gastropner
yesterday
@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.
– O.O.Balance
12 hours ago
I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.
– gastropner
yesterday
I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.
– gastropner
yesterday
@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.
– O.O.Balance
12 hours ago
@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.
– O.O.Balance
12 hours ago
add a comment |
up vote
4
down vote
Japt -R
, 25 22 bytes
ò¨ ËÅ£`ExlÐâ`ú'!Y+A
c
Try it
3 bytes saved thanks to Kamil
ò¨ :Partition at items that are greater than or equal to the previous item
Ë :Map
Å : Slice off the first element
£ : Map each element at 0-based index Y
`ExlÐâ` : Compressed string "Excelsior"
ú'! : Right pad with exclamation marks
Y+A : To length Y+10
c :Flatten
:Implicitly join with newlines & output
Another 25 bytes
– Luis felipe De jesus Munoz
2 days ago
The-R
flag isn't actually necessary, the challenge says you can output an array of strings.
– Kamil Drakari
2 days ago
Nice one, thanks, @KamilDrakari. I tried a solution usingslice
on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.
– Shaggy
10 hours ago
add a comment |
up vote
4
down vote
Japt -R
, 25 22 bytes
ò¨ ËÅ£`ExlÐâ`ú'!Y+A
c
Try it
3 bytes saved thanks to Kamil
ò¨ :Partition at items that are greater than or equal to the previous item
Ë :Map
Å : Slice off the first element
£ : Map each element at 0-based index Y
`ExlÐâ` : Compressed string "Excelsior"
ú'! : Right pad with exclamation marks
Y+A : To length Y+10
c :Flatten
:Implicitly join with newlines & output
Another 25 bytes
– Luis felipe De jesus Munoz
2 days ago
The-R
flag isn't actually necessary, the challenge says you can output an array of strings.
– Kamil Drakari
2 days ago
Nice one, thanks, @KamilDrakari. I tried a solution usingslice
on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.
– Shaggy
10 hours ago
add a comment |
up vote
4
down vote
up vote
4
down vote
Japt -R
, 25 22 bytes
ò¨ ËÅ£`ExlÐâ`ú'!Y+A
c
Try it
3 bytes saved thanks to Kamil
ò¨ :Partition at items that are greater than or equal to the previous item
Ë :Map
Å : Slice off the first element
£ : Map each element at 0-based index Y
`ExlÐâ` : Compressed string "Excelsior"
ú'! : Right pad with exclamation marks
Y+A : To length Y+10
c :Flatten
:Implicitly join with newlines & output
Japt -R
, 25 22 bytes
ò¨ ËÅ£`ExlÐâ`ú'!Y+A
c
Try it
3 bytes saved thanks to Kamil
ò¨ :Partition at items that are greater than or equal to the previous item
Ë :Map
Å : Slice off the first element
£ : Map each element at 0-based index Y
`ExlÐâ` : Compressed string "Excelsior"
ú'! : Right pad with exclamation marks
Y+A : To length Y+10
c :Flatten
:Implicitly join with newlines & output
edited 10 hours ago
answered 2 days ago
Shaggy
18.1k21663
18.1k21663
Another 25 bytes
– Luis felipe De jesus Munoz
2 days ago
The-R
flag isn't actually necessary, the challenge says you can output an array of strings.
– Kamil Drakari
2 days ago
Nice one, thanks, @KamilDrakari. I tried a solution usingslice
on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.
– Shaggy
10 hours ago
add a comment |
Another 25 bytes
– Luis felipe De jesus Munoz
2 days ago
The-R
flag isn't actually necessary, the challenge says you can output an array of strings.
– Kamil Drakari
2 days ago
Nice one, thanks, @KamilDrakari. I tried a solution usingslice
on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.
– Shaggy
10 hours ago
Another 25 bytes
– Luis felipe De jesus Munoz
2 days ago
Another 25 bytes
– Luis felipe De jesus Munoz
2 days ago
The
-R
flag isn't actually necessary, the challenge says you can output an array of strings.– Kamil Drakari
2 days ago
The
-R
flag isn't actually necessary, the challenge says you can output an array of strings.– Kamil Drakari
2 days ago
Nice one, thanks, @KamilDrakari. I tried a solution using
slice
on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.– Shaggy
10 hours ago
Nice one, thanks, @KamilDrakari. I tried a solution using
slice
on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.– Shaggy
10 hours ago
add a comment |
up vote
3
down vote
Common Lisp, 111 bytes
(setq i 0)(loop for(a b)on(read)do(incf i(if(and b(> b a))1(- i)))(format(> i 0)"Excelsior~v@{~a~:*~}~%"i #!))
Try it online!
add a comment |
up vote
3
down vote
Common Lisp, 111 bytes
(setq i 0)(loop for(a b)on(read)do(incf i(if(and b(> b a))1(- i)))(format(> i 0)"Excelsior~v@{~a~:*~}~%"i #!))
Try it online!
add a comment |
up vote
3
down vote
up vote
3
down vote
Common Lisp, 111 bytes
(setq i 0)(loop for(a b)on(read)do(incf i(if(and b(> b a))1(- i)))(format(> i 0)"Excelsior~v@{~a~:*~}~%"i #!))
Try it online!
Common Lisp, 111 bytes
(setq i 0)(loop for(a b)on(read)do(incf i(if(and b(> b a))1(- i)))(format(> i 0)"Excelsior~v@{~a~:*~}~%"i #!))
Try it online!
answered 2 days ago
Renzo
1,540516
1,540516
add a comment |
add a comment |
up vote
3
down vote
Java 8, 106 bytes
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]<n[i]?"Excelsior"+(s+="!")+"n":(s="")+s;return z;}
Try it online!
(those reassignments of s
...yikes)
You can golf two more bytes by replacing(s="")+s
=>(s="")
– O.O.Balance
yesterday
1
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"n";return z;}
(103 bytes) Move thes=""
to spare bytes.
– Olivier Grégoire
yesterday
add a comment |
up vote
3
down vote
Java 8, 106 bytes
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]<n[i]?"Excelsior"+(s+="!")+"n":(s="")+s;return z;}
Try it online!
(those reassignments of s
...yikes)
You can golf two more bytes by replacing(s="")+s
=>(s="")
– O.O.Balance
yesterday
1
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"n";return z;}
(103 bytes) Move thes=""
to spare bytes.
– Olivier Grégoire
yesterday
add a comment |
up vote
3
down vote
up vote
3
down vote
Java 8, 106 bytes
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]<n[i]?"Excelsior"+(s+="!")+"n":(s="")+s;return z;}
Try it online!
(those reassignments of s
...yikes)
Java 8, 106 bytes
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]<n[i]?"Excelsior"+(s+="!")+"n":(s="")+s;return z;}
Try it online!
(those reassignments of s
...yikes)
answered 2 days ago
NotBaal
1216
1216
You can golf two more bytes by replacing(s="")+s
=>(s="")
– O.O.Balance
yesterday
1
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"n";return z;}
(103 bytes) Move thes=""
to spare bytes.
– Olivier Grégoire
yesterday
add a comment |
You can golf two more bytes by replacing(s="")+s
=>(s="")
– O.O.Balance
yesterday
1
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"n";return z;}
(103 bytes) Move thes=""
to spare bytes.
– Olivier Grégoire
yesterday
You can golf two more bytes by replacing
(s="")+s
=> (s="")
– O.O.Balance
yesterday
You can golf two more bytes by replacing
(s="")+s
=> (s="")
– O.O.Balance
yesterday
1
1
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"n";return z;}
(103 bytes) Move the s=""
to spare bytes.– Olivier Grégoire
yesterday
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"n";return z;}
(103 bytes) Move the s=""
to spare bytes.– Olivier Grégoire
yesterday
add a comment |
up vote
3
down vote
Stax, 17 bytes
Θx7├╖&σ '@7g┼┘Ñ«═
Run and debug it
add a comment |
up vote
3
down vote
Stax, 17 bytes
Θx7├╖&σ '@7g┼┘Ñ«═
Run and debug it
add a comment |
up vote
3
down vote
up vote
3
down vote
Stax, 17 bytes
Θx7├╖&σ '@7g┼┘Ñ«═
Run and debug it
Stax, 17 bytes
Θx7├╖&σ '@7g┼┘Ñ«═
Run and debug it
answered 2 days ago
recursive
4,9541221
4,9541221
add a comment |
add a comment |
up vote
3
down vote
R, 111 bytes
function(a,r=rle(sign(diff(a))),v=r$l[r$v>0])write(paste0(rep("Excelsior",sum(v)),strrep("!",sequence(v))),1,1)
Try it online!
A far better R tribute can be found here -- I was too fixated on sequence
and rle
.
This doesn't give some blank lines, but 86 bytes?
– J.Doe
2 days ago
2
@J.Doe dang, that's way better. I'd post that myself if I were you.
– Giuseppe
2 days ago
add a comment |
up vote
3
down vote
R, 111 bytes
function(a,r=rle(sign(diff(a))),v=r$l[r$v>0])write(paste0(rep("Excelsior",sum(v)),strrep("!",sequence(v))),1,1)
Try it online!
A far better R tribute can be found here -- I was too fixated on sequence
and rle
.
This doesn't give some blank lines, but 86 bytes?
– J.Doe
2 days ago
2
@J.Doe dang, that's way better. I'd post that myself if I were you.
– Giuseppe
2 days ago
add a comment |
up vote
3
down vote
up vote
3
down vote
R, 111 bytes
function(a,r=rle(sign(diff(a))),v=r$l[r$v>0])write(paste0(rep("Excelsior",sum(v)),strrep("!",sequence(v))),1,1)
Try it online!
A far better R tribute can be found here -- I was too fixated on sequence
and rle
.
R, 111 bytes
function(a,r=rle(sign(diff(a))),v=r$l[r$v>0])write(paste0(rep("Excelsior",sum(v)),strrep("!",sequence(v))),1,1)
Try it online!
A far better R tribute can be found here -- I was too fixated on sequence
and rle
.
edited 2 days ago
answered 2 days ago
Giuseppe
15.9k31051
15.9k31051
This doesn't give some blank lines, but 86 bytes?
– J.Doe
2 days ago
2
@J.Doe dang, that's way better. I'd post that myself if I were you.
– Giuseppe
2 days ago
add a comment |
This doesn't give some blank lines, but 86 bytes?
– J.Doe
2 days ago
2
@J.Doe dang, that's way better. I'd post that myself if I were you.
– Giuseppe
2 days ago
This doesn't give some blank lines, but 86 bytes?
– J.Doe
2 days ago
This doesn't give some blank lines, but 86 bytes?
– J.Doe
2 days ago
2
2
@J.Doe dang, that's way better. I'd post that myself if I were you.
– Giuseppe
2 days ago
@J.Doe dang, that's way better. I'd post that myself if I were you.
– Giuseppe
2 days ago
add a comment |
up vote
3
down vote
Jelly, 16 bytes
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ
A monadic Link yielding a list of lists of characters.
Try it online! (footer joins with newlines)
How?
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ - Link: list of integers e.g. [1,1,4,2,1,1,3,4]
Ɲ - for each pair of integers: [1,1] [1,4] [4,2] [2,1] [1,1] [1,3] [3,4]
< - less than? [ 0, 1, 0, 0, 0, 1, 1]
ṣ0 - split at zeros [, [1], , , [1, 1]]
Ä - cumulative sums [, [1], , , [1, 2]]
Ẏ - tighten [1,1,2]
”! - literal '!' character '!'
ẋ - repeat (vectorises) [['!'],['!'],['!','!']]
“Ø6ḥ» - dictionary lookup ['E','x','c','e','l','s','i','o','r']
Ɱ - map with:
; - concatenate [['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!','!']]
add a comment |
up vote
3
down vote
Jelly, 16 bytes
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ
A monadic Link yielding a list of lists of characters.
Try it online! (footer joins with newlines)
How?
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ - Link: list of integers e.g. [1,1,4,2,1,1,3,4]
Ɲ - for each pair of integers: [1,1] [1,4] [4,2] [2,1] [1,1] [1,3] [3,4]
< - less than? [ 0, 1, 0, 0, 0, 1, 1]
ṣ0 - split at zeros [, [1], , , [1, 1]]
Ä - cumulative sums [, [1], , , [1, 2]]
Ẏ - tighten [1,1,2]
”! - literal '!' character '!'
ẋ - repeat (vectorises) [['!'],['!'],['!','!']]
“Ø6ḥ» - dictionary lookup ['E','x','c','e','l','s','i','o','r']
Ɱ - map with:
; - concatenate [['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!','!']]
add a comment |
up vote
3
down vote
up vote
3
down vote
Jelly, 16 bytes
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ
A monadic Link yielding a list of lists of characters.
Try it online! (footer joins with newlines)
How?
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ - Link: list of integers e.g. [1,1,4,2,1,1,3,4]
Ɲ - for each pair of integers: [1,1] [1,4] [4,2] [2,1] [1,1] [1,3] [3,4]
< - less than? [ 0, 1, 0, 0, 0, 1, 1]
ṣ0 - split at zeros [, [1], , , [1, 1]]
Ä - cumulative sums [, [1], , , [1, 2]]
Ẏ - tighten [1,1,2]
”! - literal '!' character '!'
ẋ - repeat (vectorises) [['!'],['!'],['!','!']]
“Ø6ḥ» - dictionary lookup ['E','x','c','e','l','s','i','o','r']
Ɱ - map with:
; - concatenate [['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!','!']]
Jelly, 16 bytes
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ
A monadic Link yielding a list of lists of characters.
Try it online! (footer joins with newlines)
How?
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ - Link: list of integers e.g. [1,1,4,2,1,1,3,4]
Ɲ - for each pair of integers: [1,1] [1,4] [4,2] [2,1] [1,1] [1,3] [3,4]
< - less than? [ 0, 1, 0, 0, 0, 1, 1]
ṣ0 - split at zeros [, [1], , , [1, 1]]
Ä - cumulative sums [, [1], , , [1, 2]]
Ẏ - tighten [1,1,2]
”! - literal '!' character '!'
ẋ - repeat (vectorises) [['!'],['!'],['!','!']]
“Ø6ḥ» - dictionary lookup ['E','x','c','e','l','s','i','o','r']
Ɱ - map with:
; - concatenate [['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!','!']]
answered 2 days ago
Jonathan Allan
49.9k534163
49.9k534163
add a comment |
add a comment |
up vote
3
down vote
Perl 5 -n
, 41 bytes
$_>$l&&$l?say$c.='!':($c=Excelsior);$l=$_
Try it online!
Takes its input on separate lines.
add a comment |
up vote
3
down vote
Perl 5 -n
, 41 bytes
$_>$l&&$l?say$c.='!':($c=Excelsior);$l=$_
Try it online!
Takes its input on separate lines.
add a comment |
up vote
3
down vote
up vote
3
down vote
Perl 5 -n
, 41 bytes
$_>$l&&$l?say$c.='!':($c=Excelsior);$l=$_
Try it online!
Takes its input on separate lines.
Perl 5 -n
, 41 bytes
$_>$l&&$l?say$c.='!':($c=Excelsior);$l=$_
Try it online!
Takes its input on separate lines.
answered 2 days ago
Xcali
4,980520
4,980520
add a comment |
add a comment |
up vote
3
down vote
Japt, 22 bytes
ò¨ ®£`ExlÐâ`+'!pYÃÅÃc
Try it online!
Explanation, with simplified example:
ò¨ :Split whenever the sequence does not increase
e.g. [2,1,1,3] -> [[2],[1],[1,3]]
® Ã :For each sub-array:
£ Ã : For each item in that sub-array:
`ExlÐâ` : Compressed "Excelsior"
+ : Concat with
'!pY : a number of "!" equal to the index
e.g. [1,3] -> ["Excelsior","Excelsior!"]
Å : Remove the first item of each sub-array
e.g. [[Excelsior],[Excelsior],[Excelsior,Excelsior!]]->[,,[Excelsior!]]
c :Flatten
e.g. [,,[Excelsior!]] -> [Excelsior!]
add a comment |
up vote
3
down vote
Japt, 22 bytes
ò¨ ®£`ExlÐâ`+'!pYÃÅÃc
Try it online!
Explanation, with simplified example:
ò¨ :Split whenever the sequence does not increase
e.g. [2,1,1,3] -> [[2],[1],[1,3]]
® Ã :For each sub-array:
£ Ã : For each item in that sub-array:
`ExlÐâ` : Compressed "Excelsior"
+ : Concat with
'!pY : a number of "!" equal to the index
e.g. [1,3] -> ["Excelsior","Excelsior!"]
Å : Remove the first item of each sub-array
e.g. [[Excelsior],[Excelsior],[Excelsior,Excelsior!]]->[,,[Excelsior!]]
c :Flatten
e.g. [,,[Excelsior!]] -> [Excelsior!]
add a comment |
up vote
3
down vote
up vote
3
down vote
Japt, 22 bytes
ò¨ ®£`ExlÐâ`+'!pYÃÅÃc
Try it online!
Explanation, with simplified example:
ò¨ :Split whenever the sequence does not increase
e.g. [2,1,1,3] -> [[2],[1],[1,3]]
® Ã :For each sub-array:
£ Ã : For each item in that sub-array:
`ExlÐâ` : Compressed "Excelsior"
+ : Concat with
'!pY : a number of "!" equal to the index
e.g. [1,3] -> ["Excelsior","Excelsior!"]
Å : Remove the first item of each sub-array
e.g. [[Excelsior],[Excelsior],[Excelsior,Excelsior!]]->[,,[Excelsior!]]
c :Flatten
e.g. [,,[Excelsior!]] -> [Excelsior!]
Japt, 22 bytes
ò¨ ®£`ExlÐâ`+'!pYÃÅÃc
Try it online!
Explanation, with simplified example:
ò¨ :Split whenever the sequence does not increase
e.g. [2,1,1,3] -> [[2],[1],[1,3]]
® Ã :For each sub-array:
£ Ã : For each item in that sub-array:
`ExlÐâ` : Compressed "Excelsior"
+ : Concat with
'!pY : a number of "!" equal to the index
e.g. [1,3] -> ["Excelsior","Excelsior!"]
Å : Remove the first item of each sub-array
e.g. [[Excelsior],[Excelsior],[Excelsior,Excelsior!]]->[,,[Excelsior!]]
c :Flatten
e.g. [,,[Excelsior!]] -> [Excelsior!]
answered yesterday
Kamil Drakari
2,541416
2,541416
add a comment |
add a comment |
up vote
2
down vote
Retina, 55 bytes
d+
*
L$rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Excelsior$#1*!
Try it online! Link includes test cases. Explanation:
d+
*
Convert to unary.
rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Process overlapping matches from right to left (although the matches are then listed from left to right). This means that we can match every number in a run, and the match extends to the start of the run. Each match is further constrained that each additional matched number must be less than the previously matched additional number, or the first number if no additional numbers have been matched yet.
L$...
Excelsior$#1*!
For each match, output Excelsior
with the number of additional numbers in the run as desired.
add a comment |
up vote
2
down vote
Retina, 55 bytes
d+
*
L$rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Excelsior$#1*!
Try it online! Link includes test cases. Explanation:
d+
*
Convert to unary.
rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Process overlapping matches from right to left (although the matches are then listed from left to right). This means that we can match every number in a run, and the match extends to the start of the run. Each match is further constrained that each additional matched number must be less than the previously matched additional number, or the first number if no additional numbers have been matched yet.
L$...
Excelsior$#1*!
For each match, output Excelsior
with the number of additional numbers in the run as desired.
add a comment |
up vote
2
down vote
up vote
2
down vote
Retina, 55 bytes
d+
*
L$rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Excelsior$#1*!
Try it online! Link includes test cases. Explanation:
d+
*
Convert to unary.
rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Process overlapping matches from right to left (although the matches are then listed from left to right). This means that we can match every number in a run, and the match extends to the start of the run. Each match is further constrained that each additional matched number must be less than the previously matched additional number, or the first number if no additional numbers have been matched yet.
L$...
Excelsior$#1*!
For each match, output Excelsior
with the number of additional numbers in the run as desired.
Retina, 55 bytes
d+
*
L$rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Excelsior$#1*!
Try it online! Link includes test cases. Explanation:
d+
*
Convert to unary.
rv`(_*,(?<!(?(1)1|2,)))+(_+)b
Process overlapping matches from right to left (although the matches are then listed from left to right). This means that we can match every number in a run, and the match extends to the start of the run. Each match is further constrained that each additional matched number must be less than the previously matched additional number, or the first number if no additional numbers have been matched yet.
L$...
Excelsior$#1*!
For each match, output Excelsior
with the number of additional numbers in the run as desired.
answered 2 days ago
Neil
77.9k744174
77.9k744174
add a comment |
add a comment |
up vote
2
down vote
Pyth, 32 bytes
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0
Try it online here, or verify all the test cases at once here.
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0 Implicit: Q=eval(input())
.+Q Get forward difference between consecutive elements of Q
.u 0 Reduce the above, returning all steps, with current value N starting at 0, next element as Y, using:
hN N+1
* Multiplied by
<0Y 1 if 0<Y, 0 otherwise
fT Filter to remove 0s
*L! Repeat "!" each element number of times
+L"Excelsior" Prepend "Excelsior" to each
j Join on newlines, implicit print
add a comment |
up vote
2
down vote
Pyth, 32 bytes
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0
Try it online here, or verify all the test cases at once here.
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0 Implicit: Q=eval(input())
.+Q Get forward difference between consecutive elements of Q
.u 0 Reduce the above, returning all steps, with current value N starting at 0, next element as Y, using:
hN N+1
* Multiplied by
<0Y 1 if 0<Y, 0 otherwise
fT Filter to remove 0s
*L! Repeat "!" each element number of times
+L"Excelsior" Prepend "Excelsior" to each
j Join on newlines, implicit print
add a comment |
up vote
2
down vote
up vote
2
down vote
Pyth, 32 bytes
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0
Try it online here, or verify all the test cases at once here.
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0 Implicit: Q=eval(input())
.+Q Get forward difference between consecutive elements of Q
.u 0 Reduce the above, returning all steps, with current value N starting at 0, next element as Y, using:
hN N+1
* Multiplied by
<0Y 1 if 0<Y, 0 otherwise
fT Filter to remove 0s
*L! Repeat "!" each element number of times
+L"Excelsior" Prepend "Excelsior" to each
j Join on newlines, implicit print
Pyth, 32 bytes
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0
Try it online here, or verify all the test cases at once here.
j+L"Excelsior"*L!fT.u*hN<0Y.+Q0 Implicit: Q=eval(input())
.+Q Get forward difference between consecutive elements of Q
.u 0 Reduce the above, returning all steps, with current value N starting at 0, next element as Y, using:
hN N+1
* Multiplied by
<0Y 1 if 0<Y, 0 otherwise
fT Filter to remove 0s
*L! Repeat "!" each element number of times
+L"Excelsior" Prepend "Excelsior" to each
j Join on newlines, implicit print
answered 2 days ago
Sok
3,349722
3,349722
add a comment |
add a comment |
up vote
2
down vote
Jelly, 18 bytes
<Ɲ‘×¥ḟ0”!ẋ“Ø6ḥ»;Ɱ
Try it online!
Output prettified over TIO.
add a comment |
up vote
2
down vote
Jelly, 18 bytes
<Ɲ‘×¥ḟ0”!ẋ“Ø6ḥ»;Ɱ
Try it online!
Output prettified over TIO.
add a comment |
up vote
2
down vote
up vote
2
down vote
Jelly, 18 bytes
<Ɲ‘×¥ḟ0”!ẋ“Ø6ḥ»;Ɱ
Try it online!
Output prettified over TIO.
Jelly, 18 bytes
<Ɲ‘×¥ḟ0”!ẋ“Ø6ḥ»;Ɱ
Try it online!
Output prettified over TIO.
edited 2 days ago
answered 2 days ago
Erik the Outgolfer
30.6k428102
30.6k428102
add a comment |
add a comment |
up vote
2
down vote
Lua, 88 87 83 82 96 95 113 bytes
Thanks @Kevin Cruijssen for update adhering to spirit of original question.
s=io.read()n=9 e="Excelsior!"f=e
for c in s.gmatch(s,"%S+")do if n<c+0then print(e)e=e..'!'else e=f end n=c+0 end
Try it online!
1
Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).
– Charlie
2 days ago
No problem. Think I've done as much as I can do here unless someone else sees something...
– ouflak
2 days ago
1
I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..
– Kevin Cruijssen
2 days ago
2
Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.
– Kevin Cruijssen
2 days ago
I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!
– ouflak
2 days ago
add a comment |
up vote
2
down vote
Lua, 88 87 83 82 96 95 113 bytes
Thanks @Kevin Cruijssen for update adhering to spirit of original question.
s=io.read()n=9 e="Excelsior!"f=e
for c in s.gmatch(s,"%S+")do if n<c+0then print(e)e=e..'!'else e=f end n=c+0 end
Try it online!
1
Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).
– Charlie
2 days ago
No problem. Think I've done as much as I can do here unless someone else sees something...
– ouflak
2 days ago
1
I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..
– Kevin Cruijssen
2 days ago
2
Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.
– Kevin Cruijssen
2 days ago
I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!
– ouflak
2 days ago
add a comment |
up vote
2
down vote
up vote
2
down vote
Lua, 88 87 83 82 96 95 113 bytes
Thanks @Kevin Cruijssen for update adhering to spirit of original question.
s=io.read()n=9 e="Excelsior!"f=e
for c in s.gmatch(s,"%S+")do if n<c+0then print(e)e=e..'!'else e=f end n=c+0 end
Try it online!
Lua, 88 87 83 82 96 95 113 bytes
Thanks @Kevin Cruijssen for update adhering to spirit of original question.
s=io.read()n=9 e="Excelsior!"f=e
for c in s.gmatch(s,"%S+")do if n<c+0then print(e)e=e..'!'else e=f end n=c+0 end
Try it online!
edited 2 days ago
Charlie
7,2812388
7,2812388
answered 2 days ago
ouflak
15129
15129
1
Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).
– Charlie
2 days ago
No problem. Think I've done as much as I can do here unless someone else sees something...
– ouflak
2 days ago
1
I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..
– Kevin Cruijssen
2 days ago
2
Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.
– Kevin Cruijssen
2 days ago
I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!
– ouflak
2 days ago
add a comment |
1
Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).
– Charlie
2 days ago
No problem. Think I've done as much as I can do here unless someone else sees something...
– ouflak
2 days ago
1
I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..
– Kevin Cruijssen
2 days ago
2
Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.
– Kevin Cruijssen
2 days ago
I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!
– ouflak
2 days ago
1
1
Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).
– Charlie
2 days ago
Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).
– Charlie
2 days ago
No problem. Think I've done as much as I can do here unless someone else sees something...
– ouflak
2 days ago
No problem. Think I've done as much as I can do here unless someone else sees something...
– ouflak
2 days ago
1
1
I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..
– Kevin Cruijssen
2 days ago
I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..
– Kevin Cruijssen
2 days ago
2
2
Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.
– Kevin Cruijssen
2 days ago
Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.
– Kevin Cruijssen
2 days ago
I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!
– ouflak
2 days ago
I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!
– ouflak
2 days ago
add a comment |
up vote
2
down vote
C++ 14 (g++), 123 118 bytes
(auto a){for(int n=0,i=0;++i<a.size();)a[i]>a[i-1]?puts(&("Excelsior"+std::string(++n,33))[0]):n=0;}
Fortunately std::string
has a constructor that repeats a char
. Try it online here.
Thanks to gastropner for saving 5 bytes.
Ungolfed:
(auto a) { // void lambda taking a std::array of integer
for(int n = 0, // length of the current run
i = 0; // loop variable
++ i < a.size(); ) // start with the second element and loop to the last
a[i] > a[i - 1] // if the current element is greater than the previous ...
? puts( // ... print a new line:
&("Excelsior" + // "Excelsior, followed by ...
std::string(++ n, 33)) // ... the appropriate number of exclamation marks (33 is ASCII code for '!'); increment the run length
[0]) // puts() takes a C string
: n = 0; // else reset run length
}
You can shave off another 5 bytes
– gastropner
2 days ago
add a comment |
up vote
2
down vote
C++ 14 (g++), 123 118 bytes
(auto a){for(int n=0,i=0;++i<a.size();)a[i]>a[i-1]?puts(&("Excelsior"+std::string(++n,33))[0]):n=0;}
Fortunately std::string
has a constructor that repeats a char
. Try it online here.
Thanks to gastropner for saving 5 bytes.
Ungolfed:
(auto a) { // void lambda taking a std::array of integer
for(int n = 0, // length of the current run
i = 0; // loop variable
++ i < a.size(); ) // start with the second element and loop to the last
a[i] > a[i - 1] // if the current element is greater than the previous ...
? puts( // ... print a new line:
&("Excelsior" + // "Excelsior, followed by ...
std::string(++ n, 33)) // ... the appropriate number of exclamation marks (33 is ASCII code for '!'); increment the run length
[0]) // puts() takes a C string
: n = 0; // else reset run length
}
You can shave off another 5 bytes
– gastropner
2 days ago
add a comment |
up vote
2
down vote
up vote
2
down vote
C++ 14 (g++), 123 118 bytes
(auto a){for(int n=0,i=0;++i<a.size();)a[i]>a[i-1]?puts(&("Excelsior"+std::string(++n,33))[0]):n=0;}
Fortunately std::string
has a constructor that repeats a char
. Try it online here.
Thanks to gastropner for saving 5 bytes.
Ungolfed:
(auto a) { // void lambda taking a std::array of integer
for(int n = 0, // length of the current run
i = 0; // loop variable
++ i < a.size(); ) // start with the second element and loop to the last
a[i] > a[i - 1] // if the current element is greater than the previous ...
? puts( // ... print a new line:
&("Excelsior" + // "Excelsior, followed by ...
std::string(++ n, 33)) // ... the appropriate number of exclamation marks (33 is ASCII code for '!'); increment the run length
[0]) // puts() takes a C string
: n = 0; // else reset run length
}
C++ 14 (g++), 123 118 bytes
(auto a){for(int n=0,i=0;++i<a.size();)a[i]>a[i-1]?puts(&("Excelsior"+std::string(++n,33))[0]):n=0;}
Fortunately std::string
has a constructor that repeats a char
. Try it online here.
Thanks to gastropner for saving 5 bytes.
Ungolfed:
(auto a) { // void lambda taking a std::array of integer
for(int n = 0, // length of the current run
i = 0; // loop variable
++ i < a.size(); ) // start with the second element and loop to the last
a[i] > a[i - 1] // if the current element is greater than the previous ...
? puts( // ... print a new line:
&("Excelsior" + // "Excelsior, followed by ...
std::string(++ n, 33)) // ... the appropriate number of exclamation marks (33 is ASCII code for '!'); increment the run length
[0]) // puts() takes a C string
: n = 0; // else reset run length
}
edited yesterday
answered 2 days ago
O.O.Balance
1,2401318
1,2401318
You can shave off another 5 bytes
– gastropner
2 days ago
add a comment |
You can shave off another 5 bytes
– gastropner
2 days ago
You can shave off another 5 bytes
– gastropner
2 days ago
You can shave off another 5 bytes
– gastropner
2 days ago
add a comment |
up vote
2
down vote
C# (.NET Core), 115 107 105 bytes
a=>{var b="";for(int i=0;++i<a.Length;)if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));else b="";}
Try it online!
-8 bytes: changed b
to a string holding "!"s from an int counter
-2 bytes: set b+="!"
as an inline function (thanks to Zac Faragher)
Uses an Action delegate to pull in the input and not require a return.
Ungolfed:
a => {
var b = ""; // initialize the '!' string (b)
for(int i = 0; ++i < a.Length;) // from index 1 until the end of a
if(a[i] > a[i - 1]) // if the current index is greater than the previous index
Console.WriteLine("Excelsior" + // on a new line, print "Excelsior"
(b += "!")); // add a "!" to b, and print the string
else // if the current index is not greater than the previous index
b = ""; // reset b
}
1
you can save 2 bytes by making theb+="!"
inline with the Excelsiorif(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!
– Zac Faragher
23 hours ago
add a comment |
up vote
2
down vote
C# (.NET Core), 115 107 105 bytes
a=>{var b="";for(int i=0;++i<a.Length;)if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));else b="";}
Try it online!
-8 bytes: changed b
to a string holding "!"s from an int counter
-2 bytes: set b+="!"
as an inline function (thanks to Zac Faragher)
Uses an Action delegate to pull in the input and not require a return.
Ungolfed:
a => {
var b = ""; // initialize the '!' string (b)
for(int i = 0; ++i < a.Length;) // from index 1 until the end of a
if(a[i] > a[i - 1]) // if the current index is greater than the previous index
Console.WriteLine("Excelsior" + // on a new line, print "Excelsior"
(b += "!")); // add a "!" to b, and print the string
else // if the current index is not greater than the previous index
b = ""; // reset b
}
1
you can save 2 bytes by making theb+="!"
inline with the Excelsiorif(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!
– Zac Faragher
23 hours ago
add a comment |
up vote
2
down vote
up vote
2
down vote
C# (.NET Core), 115 107 105 bytes
a=>{var b="";for(int i=0;++i<a.Length;)if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));else b="";}
Try it online!
-8 bytes: changed b
to a string holding "!"s from an int counter
-2 bytes: set b+="!"
as an inline function (thanks to Zac Faragher)
Uses an Action delegate to pull in the input and not require a return.
Ungolfed:
a => {
var b = ""; // initialize the '!' string (b)
for(int i = 0; ++i < a.Length;) // from index 1 until the end of a
if(a[i] > a[i - 1]) // if the current index is greater than the previous index
Console.WriteLine("Excelsior" + // on a new line, print "Excelsior"
(b += "!")); // add a "!" to b, and print the string
else // if the current index is not greater than the previous index
b = ""; // reset b
}
C# (.NET Core), 115 107 105 bytes
a=>{var b="";for(int i=0;++i<a.Length;)if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));else b="";}
Try it online!
-8 bytes: changed b
to a string holding "!"s from an int counter
-2 bytes: set b+="!"
as an inline function (thanks to Zac Faragher)
Uses an Action delegate to pull in the input and not require a return.
Ungolfed:
a => {
var b = ""; // initialize the '!' string (b)
for(int i = 0; ++i < a.Length;) // from index 1 until the end of a
if(a[i] > a[i - 1]) // if the current index is greater than the previous index
Console.WriteLine("Excelsior" + // on a new line, print "Excelsior"
(b += "!")); // add a "!" to b, and print the string
else // if the current index is not greater than the previous index
b = ""; // reset b
}
edited 13 hours ago
answered 2 days ago
Meerkat
2218
2218
1
you can save 2 bytes by making theb+="!"
inline with the Excelsiorif(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!
– Zac Faragher
23 hours ago
add a comment |
1
you can save 2 bytes by making theb+="!"
inline with the Excelsiorif(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!
– Zac Faragher
23 hours ago
1
1
you can save 2 bytes by making the
b+="!"
inline with the Excelsior if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!– Zac Faragher
23 hours ago
you can save 2 bytes by making the
b+="!"
inline with the Excelsior if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!– Zac Faragher
23 hours ago
add a comment |
up vote
2
down vote
PHP, 117 109 bytes
<?php do{$i=next($argv);if($p!==null&&$p<$i){$e.='!';echo "
Excelsior$e";}else$e='';$p=$i;}while($i!==false);
Try it online!
add a comment |
up vote
2
down vote
PHP, 117 109 bytes
<?php do{$i=next($argv);if($p!==null&&$p<$i){$e.='!';echo "
Excelsior$e";}else$e='';$p=$i;}while($i!==false);
Try it online!
add a comment |
up vote
2
down vote
up vote
2
down vote
PHP, 117 109 bytes
<?php do{$i=next($argv);if($p!==null&&$p<$i){$e.='!';echo "
Excelsior$e";}else$e='';$p=$i;}while($i!==false);
Try it online!
PHP, 117 109 bytes
<?php do{$i=next($argv);if($p!==null&&$p<$i){$e.='!';echo "
Excelsior$e";}else$e='';$p=$i;}while($i!==false);
Try it online!
edited 6 hours ago
answered 13 hours ago
Scoots
394311
394311
add a comment |
add a comment |
up vote
1
down vote
Java, 113 bytes
String i="";for(int a=0;a<s.length-1;a++){if(s[a+1]>s[a]){i+="!";System.out.println("Excelsior"+i);}else{i="";}}
New contributor
add a comment |
up vote
1
down vote
Java, 113 bytes
String i="";for(int a=0;a<s.length-1;a++){if(s[a+1]>s[a]){i+="!";System.out.println("Excelsior"+i);}else{i="";}}
New contributor
add a comment |
up vote
1
down vote
up vote
1
down vote
Java, 113 bytes
String i="";for(int a=0;a<s.length-1;a++){if(s[a+1]>s[a]){i+="!";System.out.println("Excelsior"+i);}else{i="";}}
New contributor
Java, 113 bytes
String i="";for(int a=0;a<s.length-1;a++){if(s[a+1]>s[a]){i+="!";System.out.println("Excelsior"+i);}else{i="";}}
New contributor
edited 2 days ago
New contributor
answered 2 days ago
isaace
1313
1313
New contributor
New contributor
add a comment |
add a comment |
up vote
1
down vote
VBA, 114 bytes
For i=0 To UBound(a)-LBound(a)-1 If a(i+1)>a(i)Then s=s&"!" Debug.Print("Excelsior"&s&"") Else s="" End If Next i
New contributor
add a comment |
up vote
1
down vote
VBA, 114 bytes
For i=0 To UBound(a)-LBound(a)-1 If a(i+1)>a(i)Then s=s&"!" Debug.Print("Excelsior"&s&"") Else s="" End If Next i
New contributor
add a comment |
up vote
1
down vote
up vote
1
down vote
VBA, 114 bytes
For i=0 To UBound(a)-LBound(a)-1 If a(i+1)>a(i)Then s=s&"!" Debug.Print("Excelsior"&s&"") Else s="" End If Next i
New contributor
VBA, 114 bytes
For i=0 To UBound(a)-LBound(a)-1 If a(i+1)>a(i)Then s=s&"!" Debug.Print("Excelsior"&s&"") Else s="" End If Next i
New contributor
New contributor
answered 2 days ago
isaace
1313
1313
New contributor
New contributor
add a comment |
add a comment |
up vote
1
down vote
Python 3, 87 bytes
c='!'
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
Or 97 with the following:
c='!';n=input()
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
This assumes inputs will be in the format:
32105
12345
<null input>
1
1213415
333343
New contributor
Your first program is invalid as it takes input through a predefined variable. The second is invalud as it can't distinguish between numbers with multiple digits. Why not use Python 2 or turn it into a function instead?
– Jo King
5 hours ago
add a comment |
up vote
1
down vote
Python 3, 87 bytes
c='!'
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
Or 97 with the following:
c='!';n=input()
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
This assumes inputs will be in the format:
32105
12345
<null input>
1
1213415
333343
New contributor
Your first program is invalid as it takes input through a predefined variable. The second is invalud as it can't distinguish between numbers with multiple digits. Why not use Python 2 or turn it into a function instead?
– Jo King
5 hours ago
add a comment |
up vote
1
down vote
up vote
1
down vote
Python 3, 87 bytes
c='!'
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
Or 97 with the following:
c='!';n=input()
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
This assumes inputs will be in the format:
32105
12345
<null input>
1
1213415
333343
New contributor
Python 3, 87 bytes
c='!'
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
Or 97 with the following:
c='!';n=input()
for i in range(1,len(n)):
if n[i]>n[i-1]:print('Excelsior'+c);c+='!'
else:c='!'
This assumes inputs will be in the format:
32105
12345
<null input>
1
1213415
333343
New contributor
edited 12 hours ago
New contributor
answered 12 hours ago
Henry T
114
114
New contributor
New contributor
Your first program is invalid as it takes input through a predefined variable. The second is invalud as it can't distinguish between numbers with multiple digits. Why not use Python 2 or turn it into a function instead?
– Jo King
5 hours ago
add a comment |
Your first program is invalid as it takes input through a predefined variable. The second is invalud as it can't distinguish between numbers with multiple digits. Why not use Python 2 or turn it into a function instead?
– Jo King
5 hours ago
Your first program is invalid as it takes input through a predefined variable. The second is invalud as it can't distinguish between numbers with multiple digits. Why not use Python 2 or turn it into a function instead?
– Jo King
5 hours ago
Your first program is invalid as it takes input through a predefined variable. The second is invalud as it can't distinguish between numbers with multiple digits. Why not use Python 2 or turn it into a function instead?
– Jo King
5 hours ago
add a comment |
up vote
0
down vote
Japt, 25 bytes
ä< ®?`ExlÐâ`+'!p°T:T=0
f
Try it online!
add a comment |
up vote
0
down vote
Japt, 25 bytes
ä< ®?`ExlÐâ`+'!p°T:T=0
f
Try it online!
add a comment |
up vote
0
down vote
up vote
0
down vote
Japt, 25 bytes
ä< ®?`ExlÐâ`+'!p°T:T=0
f
Try it online!
Japt, 25 bytes
ä< ®?`ExlÐâ`+'!p°T:T=0
f
Try it online!
answered 10 hours ago
Oliver
4,4801828
4,4801828
add a comment |
add a comment |
up vote
0
down vote
J, 50 bytes
'Excelsior',"1'!'#"0~[:;@(([:<+/);._1)0,2</ ::0]
Try it online!
ungolfed
'Excelsior' ,"1 '!' #"0~ [: ;@(([: < +/);._1) 0 , 2 </ ::0 ]
add a comment |
up vote
0
down vote
J, 50 bytes
'Excelsior',"1'!'#"0~[:;@(([:<+/);._1)0,2</ ::0]
Try it online!
ungolfed
'Excelsior' ,"1 '!' #"0~ [: ;@(([: < +/);._1) 0 , 2 </ ::0 ]
add a comment |
up vote
0
down vote
up vote
0
down vote
J, 50 bytes
'Excelsior',"1'!'#"0~[:;@(([:<+/);._1)0,2</ ::0]
Try it online!
ungolfed
'Excelsior' ,"1 '!' #"0~ [: ;@(([: < +/);._1) 0 , 2 </ ::0 ]
J, 50 bytes
'Excelsior',"1'!'#"0~[:;@(([:<+/);._1)0,2</ ::0]
Try it online!
ungolfed
'Excelsior' ,"1 '!' #"0~ [: ;@(([: < +/);._1) 0 , 2 </ ::0 ]
answered 29 mins ago
Jonah
1,861816
1,861816
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175918%2fupward-and-onward-to-greater-glory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
ouflak assumes integers are 1 digit long, is that ok
– ASCII-only
2 days ago
1
@ASCII-only not really. I don't know if LUA has a limitation with that, but if that's not the case ouflak should parse integers of any length.
– Charlie
2 days ago
@Charlie I don't know Lua, but although it's verbose, it is possible to take for example a space-delimited input and split like this.
– Kevin Cruijssen
2 days ago
I'm looking at it. The trick is to be able to handle both scenarios.
– ouflak
2 days ago
FWIW languages like C or Javascript will only handle integers within its precision (9/16 digits) anyway.
– user202729
2 days ago