Play Zip, Zap, Zop
$begingroup$
There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.
Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.
To elaborate, your input will be one or more Z
s, then one or more I
s, A
s, or O
s (all the same letter), then one or more P
s, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Z
s and P
s, as well as the suffix exactly as received, but then change the I
s to A
s, A
s to O
s, or O
s to I
s, preserving case at each step.
Example Test Cases
zip ==> zap
zAp ==> zOp
ZOP ==> ZIP
ZiiP ==> ZaaP
ZZaapp ==> ZZoopp
zzzzOoOPppP ==> zzzzIiIPppP
Zipperoni ==> Zapperoni
ZAPsky ==> ZOPsky
ZoPtOn ==> ZiPtOn
zipzip ==> zapzip
zapzopzip ==> zopzopzip
zoopzaap ==> ziipzaap
Rules and Notes
- You may use any convenient character encoding for input and output, provided that it supports all ASCII letters and that it was created prior to this challenge.
- You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.
- Valid inputs will full-match the regex
Z+(I+|A+|O+)P+.*
(in mixed case)
- Valid inputs will full-match the regex
Happy Golfing!
code-golf string
$endgroup$
add a comment |
$begingroup$
There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.
Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.
To elaborate, your input will be one or more Z
s, then one or more I
s, A
s, or O
s (all the same letter), then one or more P
s, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Z
s and P
s, as well as the suffix exactly as received, but then change the I
s to A
s, A
s to O
s, or O
s to I
s, preserving case at each step.
Example Test Cases
zip ==> zap
zAp ==> zOp
ZOP ==> ZIP
ZiiP ==> ZaaP
ZZaapp ==> ZZoopp
zzzzOoOPppP ==> zzzzIiIPppP
Zipperoni ==> Zapperoni
ZAPsky ==> ZOPsky
ZoPtOn ==> ZiPtOn
zipzip ==> zapzip
zapzopzip ==> zopzopzip
zoopzaap ==> ziipzaap
Rules and Notes
- You may use any convenient character encoding for input and output, provided that it supports all ASCII letters and that it was created prior to this challenge.
- You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.
- Valid inputs will full-match the regex
Z+(I+|A+|O+)P+.*
(in mixed case)
- Valid inputs will full-match the regex
Happy Golfing!
code-golf string
$endgroup$
2
$begingroup$
ziop -> what does this do?
$endgroup$
– Joshua
Feb 27 at 16:09
2
$begingroup$
@Joshua This is invalid according to the description (see "all the same letter").
$endgroup$
– Arnauld
Feb 27 at 16:23
1
$begingroup$
@Arnauld: And the test case for zoopzaap disagrees with the description.
$endgroup$
– Joshua
Feb 27 at 16:25
4
$begingroup$
@Joshua Why? This only applies to the vowels between the leadingz
's and the firstp
. The suffix may contain anything.
$endgroup$
– Arnauld
Feb 27 at 16:27
add a comment |
$begingroup$
There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.
Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.
To elaborate, your input will be one or more Z
s, then one or more I
s, A
s, or O
s (all the same letter), then one or more P
s, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Z
s and P
s, as well as the suffix exactly as received, but then change the I
s to A
s, A
s to O
s, or O
s to I
s, preserving case at each step.
Example Test Cases
zip ==> zap
zAp ==> zOp
ZOP ==> ZIP
ZiiP ==> ZaaP
ZZaapp ==> ZZoopp
zzzzOoOPppP ==> zzzzIiIPppP
Zipperoni ==> Zapperoni
ZAPsky ==> ZOPsky
ZoPtOn ==> ZiPtOn
zipzip ==> zapzip
zapzopzip ==> zopzopzip
zoopzaap ==> ziipzaap
Rules and Notes
- You may use any convenient character encoding for input and output, provided that it supports all ASCII letters and that it was created prior to this challenge.
- You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.
- Valid inputs will full-match the regex
Z+(I+|A+|O+)P+.*
(in mixed case)
- Valid inputs will full-match the regex
Happy Golfing!
code-golf string
$endgroup$
There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever.
Your task is to create a program that gives the next word in sequence given an input word. (Zip --> Zap --> Zop --> Zip) Since there's a lot of different ways to say these three words and flairs that can be added to them, your program should imitate case and letter duplication and carry suffixes.
To elaborate, your input will be one or more Z
s, then one or more I
s, A
s, or O
s (all the same letter), then one or more P
s, (all letters up to this point may be in mixed case) followed by some arbitrary suffix (which may be empty). You should leave the runs of Z
s and P
s, as well as the suffix exactly as received, but then change the I
s to A
s, A
s to O
s, or O
s to I
s, preserving case at each step.
Example Test Cases
zip ==> zap
zAp ==> zOp
ZOP ==> ZIP
ZiiP ==> ZaaP
ZZaapp ==> ZZoopp
zzzzOoOPppP ==> zzzzIiIPppP
Zipperoni ==> Zapperoni
ZAPsky ==> ZOPsky
ZoPtOn ==> ZiPtOn
zipzip ==> zapzip
zapzopzip ==> zopzopzip
zoopzaap ==> ziipzaap
Rules and Notes
- You may use any convenient character encoding for input and output, provided that it supports all ASCII letters and that it was created prior to this challenge.
- You may assume the input word is some variant of Zip, Zap, or Zop. All other inputs result in undefined behavior.
- Valid inputs will full-match the regex
Z+(I+|A+|O+)P+.*
(in mixed case)
- Valid inputs will full-match the regex
Happy Golfing!
code-golf string
code-golf string
edited Feb 27 at 0:12
Beefster
asked Feb 26 at 22:13
BeefsterBeefster
2,217936
2,217936
2
$begingroup$
ziop -> what does this do?
$endgroup$
– Joshua
Feb 27 at 16:09
2
$begingroup$
@Joshua This is invalid according to the description (see "all the same letter").
$endgroup$
– Arnauld
Feb 27 at 16:23
1
$begingroup$
@Arnauld: And the test case for zoopzaap disagrees with the description.
$endgroup$
– Joshua
Feb 27 at 16:25
4
$begingroup$
@Joshua Why? This only applies to the vowels between the leadingz
's and the firstp
. The suffix may contain anything.
$endgroup$
– Arnauld
Feb 27 at 16:27
add a comment |
2
$begingroup$
ziop -> what does this do?
$endgroup$
– Joshua
Feb 27 at 16:09
2
$begingroup$
@Joshua This is invalid according to the description (see "all the same letter").
$endgroup$
– Arnauld
Feb 27 at 16:23
1
$begingroup$
@Arnauld: And the test case for zoopzaap disagrees with the description.
$endgroup$
– Joshua
Feb 27 at 16:25
4
$begingroup$
@Joshua Why? This only applies to the vowels between the leadingz
's and the firstp
. The suffix may contain anything.
$endgroup$
– Arnauld
Feb 27 at 16:27
2
2
$begingroup$
ziop -> what does this do?
$endgroup$
– Joshua
Feb 27 at 16:09
$begingroup$
ziop -> what does this do?
$endgroup$
– Joshua
Feb 27 at 16:09
2
2
$begingroup$
@Joshua This is invalid according to the description (see "all the same letter").
$endgroup$
– Arnauld
Feb 27 at 16:23
$begingroup$
@Joshua This is invalid according to the description (see "all the same letter").
$endgroup$
– Arnauld
Feb 27 at 16:23
1
1
$begingroup$
@Arnauld: And the test case for zoopzaap disagrees with the description.
$endgroup$
– Joshua
Feb 27 at 16:25
$begingroup$
@Arnauld: And the test case for zoopzaap disagrees with the description.
$endgroup$
– Joshua
Feb 27 at 16:25
4
4
$begingroup$
@Joshua Why? This only applies to the vowels between the leading
z
's and the first p
. The suffix may contain anything.$endgroup$
– Arnauld
Feb 27 at 16:27
$begingroup$
@Joshua Why? This only applies to the vowels between the leading
z
's and the first p
. The suffix may contain anything.$endgroup$
– Arnauld
Feb 27 at 16:27
add a comment |
18 Answers
18
active
oldest
votes
$begingroup$
JavaScript (Node.js), 69 63 57 54 bytes
s=>Buffer(s).map(c=>s|c%4<1?s=c:c+c*90%320%34%24-8)+''
Try it online!
How?
We process the input string $s$ character by character.
We reuse $s$ as a flag: as soon as a numeric value is stored in it, we know that we must not update anything else.
To identify "p"
(112) and "P"
(80), we use the fact that their ASCII codes are multiples of $4$ and the ASCII codes of the other letters at the beginning of the string ("z"
, "Z"
and vowels) are not.
To turn a vowel with ASCII code $c$ into its counterpart $n$ while leaving z
and Z
unchanged, we use the following function:
$$n=c+((((90times c) bmod 320)bmod 34)bmod 24)-8$$
letter | ASCII code | * 90 | % 320 | % 34 | % 24 | - 8 | new letter
--------+------------+-------+-------+------+------+-----+-----------------------
'i' | 105 | 9450 | 170 | 0 | 0 | -8 | 105 - 8 = 97 -> 'a'
'a' | 97 | 8730 | 90 | 22 | 22 | 14 | 97 + 14 = 111 -> 'o'
'o' | 111 | 9990 | 70 | 2 | 2 | -6 | 111 - 6 = 105 -> 'i'
'z' | 122 | 10980 | 100 | 32 | 8 | 0 | 122 + 0 = 122 -> 'z'
'I' | 73 | 6570 | 170 | 0 | 0 | -8 | 73 - 8 = 65 -> 'A'
'A' | 65 | 5850 | 90 | 22 | 22 | 14 | 65 + 14 = 79 -> 'O'
'O' | 79 | 7110 | 70 | 2 | 2 | -6 | 79 - 6 = 73 -> 'I'
'Z' | 90 | 8100 | 100 | 32 | 8 | 0 | 90 + 0 = 90 -> 'Z'
Commented
s => // s = input string
Buffer(s) // convert it to a Buffer of ASCII codes
.map(c => // for each ASCII code c in s:
s | // if s is numeric
c % 4 < 1 ? // or c is either 'p' or 'P':
s = c // turn s into a numeric value and yield c
: // else:
c + // update c
c * 90 % 320 // by applying the transformation function
% 34 % 24 // (see above)
- 8 //
) + '' // end of map(); coerce the Buffer back to a string
$endgroup$
$begingroup$
How did you come up with that function?
$endgroup$
– Thomas Hirsch
Feb 27 at 22:50
2
$begingroup$
@ThomasHirsch It was found with a brute-force search function. The first step (multiplication + 1st modulo) makes sure that the parameters give identical result for both lowercase and uppercase. The 2nd step (the next 2 modulos and the subtraction) checks whether the correct delta values can be obtained from there.
$endgroup$
– Arnauld
Feb 27 at 23:19
add a comment |
$begingroup$
C (gcc), 81 ... 61 48 46 bytes
Saved 2 bytes thanks to @Grimy
Port of my JS answer. Outputs by modifying the input string.
f(char*s){for(;*++s%4;*s+=*s*90%320%34%24-8);}
Try it online!
Commented
f(char * s) { // f = function taking the input string s
for(; // for each character *s in s:
*++s % 4; // advance the pointer; exit if *s is either 'p' or 'P' (it's safe
// to skip the 1st character, as it's guaranteed to be 'z' or 'Z')
*s += // update the current character:
*s * 90 % 320 // apply a transformation formula that turns
% 34 % 24 // a vowel into the next vowel in the sequence
- 8 // while leaving 'z' and 'Z' unchanged
); // end of for()
} // end of function
$endgroup$
$begingroup$
-2 bytes
$endgroup$
– Grimy
Feb 28 at 12:50
$begingroup$
@Grimy Nice catch, thanks! (I did try*++s%4
at some point but overlooked the resulting optimization...)
$endgroup$
– Arnauld
Feb 28 at 13:02
1
$begingroup$
Further -3 bytes. This one should also be applicable to your JS answer.
$endgroup$
– Grimy
Feb 28 at 14:37
$begingroup$
@Grimy It's different enough from mine, so you may want to post this as a separate answer.
$endgroup$
– Arnauld
Feb 28 at 14:48
add a comment |
$begingroup$
Stax, 19 bytes
Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ
Run and debug it
$endgroup$
add a comment |
$begingroup$
Retina 0.8.2, 21 bytes
iT`Io`AOIiaoi`^.+?p
Try it online! Transliterates letters up to and including the first p
, although the z
and p
aren't in the transliteration section so aren't affected. The first O
is quoted because it normally expands to 13567
and the second o
is quoted because it too is magic; in the first part of the transliteration it expands to the other string. The resulting transliteration is therefore from IAOIiaoi
to AOIiaoi
then removing the duplicate source letters results in IAOiao
to AOIaoi
.
$endgroup$
add a comment |
$begingroup$
C, 43 bytes
f(char*s){for(;*++s%4;*s^=*s%16*36%98%22);}
Try it online!
Based on Arnauld's answer. I did a brute-force search to find the shortest formula that turns a => o, o => i, i => a, z => z.
$endgroup$
add a comment |
$begingroup$
Japt, 22 20 bytes
-2 bytes thanks to Oliver
r"%v+"_d`i¬iao¯`pu}"
Try it online!
$endgroup$
add a comment |
$begingroup$
R, 110 76 bytes
-36 bytes thanks to Krill
This function takes an input of one string.
function(a)sub(s<-sub('z+(.+?)p.*','\1',a,T),chartr('aioAIO','oaiOAI',s),a)
Try it online!
$endgroup$
1
$begingroup$
Collecting the string from pieces in R tends to be very long... But you save a lot of bytes by first extracting a substrings
that we'll be translating, and then replacing it with a translated copy: 76 bytes
$endgroup$
– Kirill L.
Feb 27 at 8:46
$begingroup$
@KirillL., Ah that's the clever trick I was trying to find.
$endgroup$
– CT Hall
Feb 27 at 15:18
add a comment |
$begingroup$
Perl 6, 41 33 bytes
{S:i{.+?p}=$/~~tr/iaoIAO/aoiAOI/}
Try it online!
Simple case-insensitive substitution to shift the vowel section.
$endgroup$
add a comment |
$begingroup$
Python 3.8 (pre-release), 81 78 bytes
lambda s,p='iaoIAO':''.join(('aoiAOI'+c)[(p:=p*(ord(c)%4)).find(c)]for c in s)
Try it online!
Python 2, 98 bytes
lambda s:''.join(('aoiAOI'+c)[(-~-('p'in s[:i].lower())*'iaoIAO').find(c)]for i,c in enumerate(s))
Try it online!
$endgroup$
add a comment |
$begingroup$
Java (JDK), 52 bytes
s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
Try it online!
- Port of Grimy's C answer. Make sure to upvote his answer!
$endgroup$
$begingroup$
-3 bytes by using a port of Grimy's C answer instead:s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
52 bytes.
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:44
add a comment |
$begingroup$
Perl 5, 31 bytes
s/.+?p/$&=~y,iaoIAO,aoiAOI,r/ei
TIO
$endgroup$
add a comment |
$begingroup$
SNOBOL4 (CSNOBOL4), 183 bytes
INPUT (BREAK('Pp') SPAN('Pp')) . P REM . S
A P 'a' ='o' :S(A)
Z P 'A' ='O' :S(Z)F(P)
I P 'i' ='a' :S(I)
K P 'I' ='A' :S(K)F(P)
O P 'o' ='i' :S(O)
L P 'O' ='I' :S(L)
P OUTPUT =P S
END
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 84 bytes
f=lambda s,r='':s[0]in'pP'and r+s or f(s[1:],r+('aoiAOI'+s[0])['iaoIAO'.find(s[0])])
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 60 bytes
n=>{for(int i=0;n[i]%4>0;)n[i]^=(char)(n[i++]%16*36%98%22);}
Based off of Grimy's C answer.
Try it online!
$endgroup$
1
$begingroup$
This unfortunately doesn't work as it replaces the vowels in the suffix as well.
$endgroup$
– Emigna
Feb 27 at 7:04
$begingroup$
As @Emigna states above, this replaces allaoi
-vowels, instead of just the ones before the firstp
/P
. One thing to golf however:("iao".IndexOf((char)(c|32))+1)%4
can be-~"iao".IndexOf((char)(c|32))%4
$endgroup$
– Kevin Cruijssen
Feb 27 at 12:04
add a comment |
$begingroup$
Ruby, 40 bytes
$_[$&]=$&.tr"IAOiao","AOIaoi"if/z+.+?p/i
Try it online!
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy), 22 bytes
l'pkIg‚£ć…iaoDÀ‚Du+`‡ì
Try it online or verify all test cases.
Can definitely be golfed a bit more..
Uses the legacy version of 05AB1E instead of the Elixir rewrite, because +
merges fields in same-length lists, whereas the new version would need a pair-zip-join ‚øJ
instead.
Explanation:
l # Lowercase the (implicit) input-string
# i.e. "ZipPeroni" → "zipperoni"
'pk '# Get the index of the first "p"
# i.e. "zipperoni" → 2
Ig‚ # Pair it with the length of the entire input-string
# i.e. 2 and "zipperoni" → [2,9]
£ # Split the (implicit) input-string into parts of that size
# i.e. "ZipPeroni" and [2,9] → ["Zi","pPeroni"]
ć # Extract head: push the head and remainder separately to the stack
# i.e. ["Zi","pPeroni"] → ["pPeroni"] and "Zi"
…iao # Push string "iao"
DÀ # Duplicate, and rotate it once towards the left: "aoi"
‚ # Pair them up: ["iao","aoi"]
Du # Duplicate and transform it to uppercase: ["IAO","AOI"]
+ # Python-style merge them together: ["iaoIAO","aoiAOI"]
` # Push both strings to the stack
‡ # Transliterate; replacing all characters at the same indices
# i.e. "Zi", "iaoIAO" and "aoiAOI" → "Za"
ì # Prepend it to the remainder (and output implicitly)
# i.e. ["pPeroni"] and "Za" → ["ZapPeroni"]
$endgroup$
add a comment |
$begingroup$
PHP, 30 bytes
too simple for a TiO:
<?=strtr($argn,oiaOIA,iaoIAO);
Run as pipe with -nF
. For PHP 7.2, put the string literals in quotes.
$endgroup$
$begingroup$
This transliterates alloia
vowels instead of only the ones before the firstp
/P
, doesn't it?
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:39
add a comment |
$begingroup$
C/C++ (VC++ compiler) 192bytes
this is a rather naive try but anyway
void f(char*I){int c={-8,14,6},B=1,v={105,97,111},j=0;for(*I;*I>0&B;I++){if(*I==80|*I==112){B=0;break;}if(*I==90|*I==122){}else{for(j;j<3;j++){if(*I==v[j]|*I==v[j]-32){*I+=c[j];break;}}}}}
some slightly more readable Version is this
#include "stdafx.h"
void f(char * theString)
{
signed int change = {'a'-'i','o'-'a','o'-'i'}; // add this to the vowel to get the next one
char theVowels = {'i','a','o'};
int breaker = 1;
printf("Input %sn",theString);
for (int i = 0;(theString[i] != '') && breaker; i++)
{
switch (theString[i])
{
case 'Z': /*fall through*/
case 'z': break;
case 'P': /*fall through*/
case 'p': breaker = 0;
break;
default:
{
for (int j = 0; j < 3; j++)
{
if ((theString[i] == theVowels[j]) || (theString[i]==(theVowels[j]-'a'+'A')))
{
theString[i] += change[j];
break;
}
}
}
break;
}
}
printf("Output %sn",theString);
}
int main()
{
char theString= "zzzzIIIIp0815-4711"; // a test string
f(theString);
return 0;
}
$endgroup$
$begingroup$
tio: tio.run/…
$endgroup$
– der bender
Mar 25 at 16:13
$begingroup$
tio golfed : tio.run/…
$endgroup$
– der bender
Mar 25 at 16:16
add a comment |
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f180463%2fplay-zip-zap-zop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
18 Answers
18
active
oldest
votes
18 Answers
18
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
JavaScript (Node.js), 69 63 57 54 bytes
s=>Buffer(s).map(c=>s|c%4<1?s=c:c+c*90%320%34%24-8)+''
Try it online!
How?
We process the input string $s$ character by character.
We reuse $s$ as a flag: as soon as a numeric value is stored in it, we know that we must not update anything else.
To identify "p"
(112) and "P"
(80), we use the fact that their ASCII codes are multiples of $4$ and the ASCII codes of the other letters at the beginning of the string ("z"
, "Z"
and vowels) are not.
To turn a vowel with ASCII code $c$ into its counterpart $n$ while leaving z
and Z
unchanged, we use the following function:
$$n=c+((((90times c) bmod 320)bmod 34)bmod 24)-8$$
letter | ASCII code | * 90 | % 320 | % 34 | % 24 | - 8 | new letter
--------+------------+-------+-------+------+------+-----+-----------------------
'i' | 105 | 9450 | 170 | 0 | 0 | -8 | 105 - 8 = 97 -> 'a'
'a' | 97 | 8730 | 90 | 22 | 22 | 14 | 97 + 14 = 111 -> 'o'
'o' | 111 | 9990 | 70 | 2 | 2 | -6 | 111 - 6 = 105 -> 'i'
'z' | 122 | 10980 | 100 | 32 | 8 | 0 | 122 + 0 = 122 -> 'z'
'I' | 73 | 6570 | 170 | 0 | 0 | -8 | 73 - 8 = 65 -> 'A'
'A' | 65 | 5850 | 90 | 22 | 22 | 14 | 65 + 14 = 79 -> 'O'
'O' | 79 | 7110 | 70 | 2 | 2 | -6 | 79 - 6 = 73 -> 'I'
'Z' | 90 | 8100 | 100 | 32 | 8 | 0 | 90 + 0 = 90 -> 'Z'
Commented
s => // s = input string
Buffer(s) // convert it to a Buffer of ASCII codes
.map(c => // for each ASCII code c in s:
s | // if s is numeric
c % 4 < 1 ? // or c is either 'p' or 'P':
s = c // turn s into a numeric value and yield c
: // else:
c + // update c
c * 90 % 320 // by applying the transformation function
% 34 % 24 // (see above)
- 8 //
) + '' // end of map(); coerce the Buffer back to a string
$endgroup$
$begingroup$
How did you come up with that function?
$endgroup$
– Thomas Hirsch
Feb 27 at 22:50
2
$begingroup$
@ThomasHirsch It was found with a brute-force search function. The first step (multiplication + 1st modulo) makes sure that the parameters give identical result for both lowercase and uppercase. The 2nd step (the next 2 modulos and the subtraction) checks whether the correct delta values can be obtained from there.
$endgroup$
– Arnauld
Feb 27 at 23:19
add a comment |
$begingroup$
JavaScript (Node.js), 69 63 57 54 bytes
s=>Buffer(s).map(c=>s|c%4<1?s=c:c+c*90%320%34%24-8)+''
Try it online!
How?
We process the input string $s$ character by character.
We reuse $s$ as a flag: as soon as a numeric value is stored in it, we know that we must not update anything else.
To identify "p"
(112) and "P"
(80), we use the fact that their ASCII codes are multiples of $4$ and the ASCII codes of the other letters at the beginning of the string ("z"
, "Z"
and vowels) are not.
To turn a vowel with ASCII code $c$ into its counterpart $n$ while leaving z
and Z
unchanged, we use the following function:
$$n=c+((((90times c) bmod 320)bmod 34)bmod 24)-8$$
letter | ASCII code | * 90 | % 320 | % 34 | % 24 | - 8 | new letter
--------+------------+-------+-------+------+------+-----+-----------------------
'i' | 105 | 9450 | 170 | 0 | 0 | -8 | 105 - 8 = 97 -> 'a'
'a' | 97 | 8730 | 90 | 22 | 22 | 14 | 97 + 14 = 111 -> 'o'
'o' | 111 | 9990 | 70 | 2 | 2 | -6 | 111 - 6 = 105 -> 'i'
'z' | 122 | 10980 | 100 | 32 | 8 | 0 | 122 + 0 = 122 -> 'z'
'I' | 73 | 6570 | 170 | 0 | 0 | -8 | 73 - 8 = 65 -> 'A'
'A' | 65 | 5850 | 90 | 22 | 22 | 14 | 65 + 14 = 79 -> 'O'
'O' | 79 | 7110 | 70 | 2 | 2 | -6 | 79 - 6 = 73 -> 'I'
'Z' | 90 | 8100 | 100 | 32 | 8 | 0 | 90 + 0 = 90 -> 'Z'
Commented
s => // s = input string
Buffer(s) // convert it to a Buffer of ASCII codes
.map(c => // for each ASCII code c in s:
s | // if s is numeric
c % 4 < 1 ? // or c is either 'p' or 'P':
s = c // turn s into a numeric value and yield c
: // else:
c + // update c
c * 90 % 320 // by applying the transformation function
% 34 % 24 // (see above)
- 8 //
) + '' // end of map(); coerce the Buffer back to a string
$endgroup$
$begingroup$
How did you come up with that function?
$endgroup$
– Thomas Hirsch
Feb 27 at 22:50
2
$begingroup$
@ThomasHirsch It was found with a brute-force search function. The first step (multiplication + 1st modulo) makes sure that the parameters give identical result for both lowercase and uppercase. The 2nd step (the next 2 modulos and the subtraction) checks whether the correct delta values can be obtained from there.
$endgroup$
– Arnauld
Feb 27 at 23:19
add a comment |
$begingroup$
JavaScript (Node.js), 69 63 57 54 bytes
s=>Buffer(s).map(c=>s|c%4<1?s=c:c+c*90%320%34%24-8)+''
Try it online!
How?
We process the input string $s$ character by character.
We reuse $s$ as a flag: as soon as a numeric value is stored in it, we know that we must not update anything else.
To identify "p"
(112) and "P"
(80), we use the fact that their ASCII codes are multiples of $4$ and the ASCII codes of the other letters at the beginning of the string ("z"
, "Z"
and vowels) are not.
To turn a vowel with ASCII code $c$ into its counterpart $n$ while leaving z
and Z
unchanged, we use the following function:
$$n=c+((((90times c) bmod 320)bmod 34)bmod 24)-8$$
letter | ASCII code | * 90 | % 320 | % 34 | % 24 | - 8 | new letter
--------+------------+-------+-------+------+------+-----+-----------------------
'i' | 105 | 9450 | 170 | 0 | 0 | -8 | 105 - 8 = 97 -> 'a'
'a' | 97 | 8730 | 90 | 22 | 22 | 14 | 97 + 14 = 111 -> 'o'
'o' | 111 | 9990 | 70 | 2 | 2 | -6 | 111 - 6 = 105 -> 'i'
'z' | 122 | 10980 | 100 | 32 | 8 | 0 | 122 + 0 = 122 -> 'z'
'I' | 73 | 6570 | 170 | 0 | 0 | -8 | 73 - 8 = 65 -> 'A'
'A' | 65 | 5850 | 90 | 22 | 22 | 14 | 65 + 14 = 79 -> 'O'
'O' | 79 | 7110 | 70 | 2 | 2 | -6 | 79 - 6 = 73 -> 'I'
'Z' | 90 | 8100 | 100 | 32 | 8 | 0 | 90 + 0 = 90 -> 'Z'
Commented
s => // s = input string
Buffer(s) // convert it to a Buffer of ASCII codes
.map(c => // for each ASCII code c in s:
s | // if s is numeric
c % 4 < 1 ? // or c is either 'p' or 'P':
s = c // turn s into a numeric value and yield c
: // else:
c + // update c
c * 90 % 320 // by applying the transformation function
% 34 % 24 // (see above)
- 8 //
) + '' // end of map(); coerce the Buffer back to a string
$endgroup$
JavaScript (Node.js), 69 63 57 54 bytes
s=>Buffer(s).map(c=>s|c%4<1?s=c:c+c*90%320%34%24-8)+''
Try it online!
How?
We process the input string $s$ character by character.
We reuse $s$ as a flag: as soon as a numeric value is stored in it, we know that we must not update anything else.
To identify "p"
(112) and "P"
(80), we use the fact that their ASCII codes are multiples of $4$ and the ASCII codes of the other letters at the beginning of the string ("z"
, "Z"
and vowels) are not.
To turn a vowel with ASCII code $c$ into its counterpart $n$ while leaving z
and Z
unchanged, we use the following function:
$$n=c+((((90times c) bmod 320)bmod 34)bmod 24)-8$$
letter | ASCII code | * 90 | % 320 | % 34 | % 24 | - 8 | new letter
--------+------------+-------+-------+------+------+-----+-----------------------
'i' | 105 | 9450 | 170 | 0 | 0 | -8 | 105 - 8 = 97 -> 'a'
'a' | 97 | 8730 | 90 | 22 | 22 | 14 | 97 + 14 = 111 -> 'o'
'o' | 111 | 9990 | 70 | 2 | 2 | -6 | 111 - 6 = 105 -> 'i'
'z' | 122 | 10980 | 100 | 32 | 8 | 0 | 122 + 0 = 122 -> 'z'
'I' | 73 | 6570 | 170 | 0 | 0 | -8 | 73 - 8 = 65 -> 'A'
'A' | 65 | 5850 | 90 | 22 | 22 | 14 | 65 + 14 = 79 -> 'O'
'O' | 79 | 7110 | 70 | 2 | 2 | -6 | 79 - 6 = 73 -> 'I'
'Z' | 90 | 8100 | 100 | 32 | 8 | 0 | 90 + 0 = 90 -> 'Z'
Commented
s => // s = input string
Buffer(s) // convert it to a Buffer of ASCII codes
.map(c => // for each ASCII code c in s:
s | // if s is numeric
c % 4 < 1 ? // or c is either 'p' or 'P':
s = c // turn s into a numeric value and yield c
: // else:
c + // update c
c * 90 % 320 // by applying the transformation function
% 34 % 24 // (see above)
- 8 //
) + '' // end of map(); coerce the Buffer back to a string
edited Feb 27 at 15:18
answered Feb 26 at 23:24
ArnauldArnauld
80k797331
80k797331
$begingroup$
How did you come up with that function?
$endgroup$
– Thomas Hirsch
Feb 27 at 22:50
2
$begingroup$
@ThomasHirsch It was found with a brute-force search function. The first step (multiplication + 1st modulo) makes sure that the parameters give identical result for both lowercase and uppercase. The 2nd step (the next 2 modulos and the subtraction) checks whether the correct delta values can be obtained from there.
$endgroup$
– Arnauld
Feb 27 at 23:19
add a comment |
$begingroup$
How did you come up with that function?
$endgroup$
– Thomas Hirsch
Feb 27 at 22:50
2
$begingroup$
@ThomasHirsch It was found with a brute-force search function. The first step (multiplication + 1st modulo) makes sure that the parameters give identical result for both lowercase and uppercase. The 2nd step (the next 2 modulos and the subtraction) checks whether the correct delta values can be obtained from there.
$endgroup$
– Arnauld
Feb 27 at 23:19
$begingroup$
How did you come up with that function?
$endgroup$
– Thomas Hirsch
Feb 27 at 22:50
$begingroup$
How did you come up with that function?
$endgroup$
– Thomas Hirsch
Feb 27 at 22:50
2
2
$begingroup$
@ThomasHirsch It was found with a brute-force search function. The first step (multiplication + 1st modulo) makes sure that the parameters give identical result for both lowercase and uppercase. The 2nd step (the next 2 modulos and the subtraction) checks whether the correct delta values can be obtained from there.
$endgroup$
– Arnauld
Feb 27 at 23:19
$begingroup$
@ThomasHirsch It was found with a brute-force search function. The first step (multiplication + 1st modulo) makes sure that the parameters give identical result for both lowercase and uppercase. The 2nd step (the next 2 modulos and the subtraction) checks whether the correct delta values can be obtained from there.
$endgroup$
– Arnauld
Feb 27 at 23:19
add a comment |
$begingroup$
C (gcc), 81 ... 61 48 46 bytes
Saved 2 bytes thanks to @Grimy
Port of my JS answer. Outputs by modifying the input string.
f(char*s){for(;*++s%4;*s+=*s*90%320%34%24-8);}
Try it online!
Commented
f(char * s) { // f = function taking the input string s
for(; // for each character *s in s:
*++s % 4; // advance the pointer; exit if *s is either 'p' or 'P' (it's safe
// to skip the 1st character, as it's guaranteed to be 'z' or 'Z')
*s += // update the current character:
*s * 90 % 320 // apply a transformation formula that turns
% 34 % 24 // a vowel into the next vowel in the sequence
- 8 // while leaving 'z' and 'Z' unchanged
); // end of for()
} // end of function
$endgroup$
$begingroup$
-2 bytes
$endgroup$
– Grimy
Feb 28 at 12:50
$begingroup$
@Grimy Nice catch, thanks! (I did try*++s%4
at some point but overlooked the resulting optimization...)
$endgroup$
– Arnauld
Feb 28 at 13:02
1
$begingroup$
Further -3 bytes. This one should also be applicable to your JS answer.
$endgroup$
– Grimy
Feb 28 at 14:37
$begingroup$
@Grimy It's different enough from mine, so you may want to post this as a separate answer.
$endgroup$
– Arnauld
Feb 28 at 14:48
add a comment |
$begingroup$
C (gcc), 81 ... 61 48 46 bytes
Saved 2 bytes thanks to @Grimy
Port of my JS answer. Outputs by modifying the input string.
f(char*s){for(;*++s%4;*s+=*s*90%320%34%24-8);}
Try it online!
Commented
f(char * s) { // f = function taking the input string s
for(; // for each character *s in s:
*++s % 4; // advance the pointer; exit if *s is either 'p' or 'P' (it's safe
// to skip the 1st character, as it's guaranteed to be 'z' or 'Z')
*s += // update the current character:
*s * 90 % 320 // apply a transformation formula that turns
% 34 % 24 // a vowel into the next vowel in the sequence
- 8 // while leaving 'z' and 'Z' unchanged
); // end of for()
} // end of function
$endgroup$
$begingroup$
-2 bytes
$endgroup$
– Grimy
Feb 28 at 12:50
$begingroup$
@Grimy Nice catch, thanks! (I did try*++s%4
at some point but overlooked the resulting optimization...)
$endgroup$
– Arnauld
Feb 28 at 13:02
1
$begingroup$
Further -3 bytes. This one should also be applicable to your JS answer.
$endgroup$
– Grimy
Feb 28 at 14:37
$begingroup$
@Grimy It's different enough from mine, so you may want to post this as a separate answer.
$endgroup$
– Arnauld
Feb 28 at 14:48
add a comment |
$begingroup$
C (gcc), 81 ... 61 48 46 bytes
Saved 2 bytes thanks to @Grimy
Port of my JS answer. Outputs by modifying the input string.
f(char*s){for(;*++s%4;*s+=*s*90%320%34%24-8);}
Try it online!
Commented
f(char * s) { // f = function taking the input string s
for(; // for each character *s in s:
*++s % 4; // advance the pointer; exit if *s is either 'p' or 'P' (it's safe
// to skip the 1st character, as it's guaranteed to be 'z' or 'Z')
*s += // update the current character:
*s * 90 % 320 // apply a transformation formula that turns
% 34 % 24 // a vowel into the next vowel in the sequence
- 8 // while leaving 'z' and 'Z' unchanged
); // end of for()
} // end of function
$endgroup$
C (gcc), 81 ... 61 48 46 bytes
Saved 2 bytes thanks to @Grimy
Port of my JS answer. Outputs by modifying the input string.
f(char*s){for(;*++s%4;*s+=*s*90%320%34%24-8);}
Try it online!
Commented
f(char * s) { // f = function taking the input string s
for(; // for each character *s in s:
*++s % 4; // advance the pointer; exit if *s is either 'p' or 'P' (it's safe
// to skip the 1st character, as it's guaranteed to be 'z' or 'Z')
*s += // update the current character:
*s * 90 % 320 // apply a transformation formula that turns
% 34 % 24 // a vowel into the next vowel in the sequence
- 8 // while leaving 'z' and 'Z' unchanged
); // end of for()
} // end of function
edited Feb 28 at 12:56
answered Feb 27 at 0:38
ArnauldArnauld
80k797331
80k797331
$begingroup$
-2 bytes
$endgroup$
– Grimy
Feb 28 at 12:50
$begingroup$
@Grimy Nice catch, thanks! (I did try*++s%4
at some point but overlooked the resulting optimization...)
$endgroup$
– Arnauld
Feb 28 at 13:02
1
$begingroup$
Further -3 bytes. This one should also be applicable to your JS answer.
$endgroup$
– Grimy
Feb 28 at 14:37
$begingroup$
@Grimy It's different enough from mine, so you may want to post this as a separate answer.
$endgroup$
– Arnauld
Feb 28 at 14:48
add a comment |
$begingroup$
-2 bytes
$endgroup$
– Grimy
Feb 28 at 12:50
$begingroup$
@Grimy Nice catch, thanks! (I did try*++s%4
at some point but overlooked the resulting optimization...)
$endgroup$
– Arnauld
Feb 28 at 13:02
1
$begingroup$
Further -3 bytes. This one should also be applicable to your JS answer.
$endgroup$
– Grimy
Feb 28 at 14:37
$begingroup$
@Grimy It's different enough from mine, so you may want to post this as a separate answer.
$endgroup$
– Arnauld
Feb 28 at 14:48
$begingroup$
-2 bytes
$endgroup$
– Grimy
Feb 28 at 12:50
$begingroup$
-2 bytes
$endgroup$
– Grimy
Feb 28 at 12:50
$begingroup$
@Grimy Nice catch, thanks! (I did try
*++s%4
at some point but overlooked the resulting optimization...)$endgroup$
– Arnauld
Feb 28 at 13:02
$begingroup$
@Grimy Nice catch, thanks! (I did try
*++s%4
at some point but overlooked the resulting optimization...)$endgroup$
– Arnauld
Feb 28 at 13:02
1
1
$begingroup$
Further -3 bytes. This one should also be applicable to your JS answer.
$endgroup$
– Grimy
Feb 28 at 14:37
$begingroup$
Further -3 bytes. This one should also be applicable to your JS answer.
$endgroup$
– Grimy
Feb 28 at 14:37
$begingroup$
@Grimy It's different enough from mine, so you may want to post this as a separate answer.
$endgroup$
– Arnauld
Feb 28 at 14:48
$begingroup$
@Grimy It's different enough from mine, so you may want to post this as a separate answer.
$endgroup$
– Arnauld
Feb 28 at 14:48
add a comment |
$begingroup$
Stax, 19 bytes
Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ
Run and debug it
$endgroup$
add a comment |
$begingroup$
Stax, 19 bytes
Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ
Run and debug it
$endgroup$
add a comment |
$begingroup$
Stax, 19 bytes
Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ
Run and debug it
$endgroup$
Stax, 19 bytes
Ç╛√êΣ%,╖FP╚`=Lh←⌡·ƒ
Run and debug it
answered Feb 26 at 22:23
recursiverecursive
5,6741322
5,6741322
add a comment |
add a comment |
$begingroup$
Retina 0.8.2, 21 bytes
iT`Io`AOIiaoi`^.+?p
Try it online! Transliterates letters up to and including the first p
, although the z
and p
aren't in the transliteration section so aren't affected. The first O
is quoted because it normally expands to 13567
and the second o
is quoted because it too is magic; in the first part of the transliteration it expands to the other string. The resulting transliteration is therefore from IAOIiaoi
to AOIiaoi
then removing the duplicate source letters results in IAOiao
to AOIaoi
.
$endgroup$
add a comment |
$begingroup$
Retina 0.8.2, 21 bytes
iT`Io`AOIiaoi`^.+?p
Try it online! Transliterates letters up to and including the first p
, although the z
and p
aren't in the transliteration section so aren't affected. The first O
is quoted because it normally expands to 13567
and the second o
is quoted because it too is magic; in the first part of the transliteration it expands to the other string. The resulting transliteration is therefore from IAOIiaoi
to AOIiaoi
then removing the duplicate source letters results in IAOiao
to AOIaoi
.
$endgroup$
add a comment |
$begingroup$
Retina 0.8.2, 21 bytes
iT`Io`AOIiaoi`^.+?p
Try it online! Transliterates letters up to and including the first p
, although the z
and p
aren't in the transliteration section so aren't affected. The first O
is quoted because it normally expands to 13567
and the second o
is quoted because it too is magic; in the first part of the transliteration it expands to the other string. The resulting transliteration is therefore from IAOIiaoi
to AOIiaoi
then removing the duplicate source letters results in IAOiao
to AOIaoi
.
$endgroup$
Retina 0.8.2, 21 bytes
iT`Io`AOIiaoi`^.+?p
Try it online! Transliterates letters up to and including the first p
, although the z
and p
aren't in the transliteration section so aren't affected. The first O
is quoted because it normally expands to 13567
and the second o
is quoted because it too is magic; in the first part of the transliteration it expands to the other string. The resulting transliteration is therefore from IAOIiaoi
to AOIiaoi
then removing the duplicate source letters results in IAOiao
to AOIaoi
.
answered Feb 27 at 1:17
NeilNeil
82.2k745178
82.2k745178
add a comment |
add a comment |
$begingroup$
C, 43 bytes
f(char*s){for(;*++s%4;*s^=*s%16*36%98%22);}
Try it online!
Based on Arnauld's answer. I did a brute-force search to find the shortest formula that turns a => o, o => i, i => a, z => z.
$endgroup$
add a comment |
$begingroup$
C, 43 bytes
f(char*s){for(;*++s%4;*s^=*s%16*36%98%22);}
Try it online!
Based on Arnauld's answer. I did a brute-force search to find the shortest formula that turns a => o, o => i, i => a, z => z.
$endgroup$
add a comment |
$begingroup$
C, 43 bytes
f(char*s){for(;*++s%4;*s^=*s%16*36%98%22);}
Try it online!
Based on Arnauld's answer. I did a brute-force search to find the shortest formula that turns a => o, o => i, i => a, z => z.
$endgroup$
C, 43 bytes
f(char*s){for(;*++s%4;*s^=*s%16*36%98%22);}
Try it online!
Based on Arnauld's answer. I did a brute-force search to find the shortest formula that turns a => o, o => i, i => a, z => z.
edited Feb 28 at 15:11
answered Feb 28 at 14:53
GrimyGrimy
2,6411019
2,6411019
add a comment |
add a comment |
$begingroup$
Japt, 22 20 bytes
-2 bytes thanks to Oliver
r"%v+"_d`i¬iao¯`pu}"
Try it online!
$endgroup$
add a comment |
$begingroup$
Japt, 22 20 bytes
-2 bytes thanks to Oliver
r"%v+"_d`i¬iao¯`pu}"
Try it online!
$endgroup$
add a comment |
$begingroup$
Japt, 22 20 bytes
-2 bytes thanks to Oliver
r"%v+"_d`i¬iao¯`pu}"
Try it online!
$endgroup$
Japt, 22 20 bytes
-2 bytes thanks to Oliver
r"%v+"_d`i¬iao¯`pu}"
Try it online!
edited Feb 26 at 23:52
answered Feb 26 at 23:05
ASCII-onlyASCII-only
4,4401338
4,4401338
add a comment |
add a comment |
$begingroup$
R, 110 76 bytes
-36 bytes thanks to Krill
This function takes an input of one string.
function(a)sub(s<-sub('z+(.+?)p.*','\1',a,T),chartr('aioAIO','oaiOAI',s),a)
Try it online!
$endgroup$
1
$begingroup$
Collecting the string from pieces in R tends to be very long... But you save a lot of bytes by first extracting a substrings
that we'll be translating, and then replacing it with a translated copy: 76 bytes
$endgroup$
– Kirill L.
Feb 27 at 8:46
$begingroup$
@KirillL., Ah that's the clever trick I was trying to find.
$endgroup$
– CT Hall
Feb 27 at 15:18
add a comment |
$begingroup$
R, 110 76 bytes
-36 bytes thanks to Krill
This function takes an input of one string.
function(a)sub(s<-sub('z+(.+?)p.*','\1',a,T),chartr('aioAIO','oaiOAI',s),a)
Try it online!
$endgroup$
1
$begingroup$
Collecting the string from pieces in R tends to be very long... But you save a lot of bytes by first extracting a substrings
that we'll be translating, and then replacing it with a translated copy: 76 bytes
$endgroup$
– Kirill L.
Feb 27 at 8:46
$begingroup$
@KirillL., Ah that's the clever trick I was trying to find.
$endgroup$
– CT Hall
Feb 27 at 15:18
add a comment |
$begingroup$
R, 110 76 bytes
-36 bytes thanks to Krill
This function takes an input of one string.
function(a)sub(s<-sub('z+(.+?)p.*','\1',a,T),chartr('aioAIO','oaiOAI',s),a)
Try it online!
$endgroup$
R, 110 76 bytes
-36 bytes thanks to Krill
This function takes an input of one string.
function(a)sub(s<-sub('z+(.+?)p.*','\1',a,T),chartr('aioAIO','oaiOAI',s),a)
Try it online!
edited Feb 27 at 15:21
answered Feb 27 at 2:25
CT HallCT Hall
46110
46110
1
$begingroup$
Collecting the string from pieces in R tends to be very long... But you save a lot of bytes by first extracting a substrings
that we'll be translating, and then replacing it with a translated copy: 76 bytes
$endgroup$
– Kirill L.
Feb 27 at 8:46
$begingroup$
@KirillL., Ah that's the clever trick I was trying to find.
$endgroup$
– CT Hall
Feb 27 at 15:18
add a comment |
1
$begingroup$
Collecting the string from pieces in R tends to be very long... But you save a lot of bytes by first extracting a substrings
that we'll be translating, and then replacing it with a translated copy: 76 bytes
$endgroup$
– Kirill L.
Feb 27 at 8:46
$begingroup$
@KirillL., Ah that's the clever trick I was trying to find.
$endgroup$
– CT Hall
Feb 27 at 15:18
1
1
$begingroup$
Collecting the string from pieces in R tends to be very long... But you save a lot of bytes by first extracting a substring
s
that we'll be translating, and then replacing it with a translated copy: 76 bytes$endgroup$
– Kirill L.
Feb 27 at 8:46
$begingroup$
Collecting the string from pieces in R tends to be very long... But you save a lot of bytes by first extracting a substring
s
that we'll be translating, and then replacing it with a translated copy: 76 bytes$endgroup$
– Kirill L.
Feb 27 at 8:46
$begingroup$
@KirillL., Ah that's the clever trick I was trying to find.
$endgroup$
– CT Hall
Feb 27 at 15:18
$begingroup$
@KirillL., Ah that's the clever trick I was trying to find.
$endgroup$
– CT Hall
Feb 27 at 15:18
add a comment |
$begingroup$
Perl 6, 41 33 bytes
{S:i{.+?p}=$/~~tr/iaoIAO/aoiAOI/}
Try it online!
Simple case-insensitive substitution to shift the vowel section.
$endgroup$
add a comment |
$begingroup$
Perl 6, 41 33 bytes
{S:i{.+?p}=$/~~tr/iaoIAO/aoiAOI/}
Try it online!
Simple case-insensitive substitution to shift the vowel section.
$endgroup$
add a comment |
$begingroup$
Perl 6, 41 33 bytes
{S:i{.+?p}=$/~~tr/iaoIAO/aoiAOI/}
Try it online!
Simple case-insensitive substitution to shift the vowel section.
$endgroup$
Perl 6, 41 33 bytes
{S:i{.+?p}=$/~~tr/iaoIAO/aoiAOI/}
Try it online!
Simple case-insensitive substitution to shift the vowel section.
edited Feb 27 at 11:16
answered Feb 26 at 22:59
Jo KingJo King
26k363129
26k363129
add a comment |
add a comment |
$begingroup$
Python 3.8 (pre-release), 81 78 bytes
lambda s,p='iaoIAO':''.join(('aoiAOI'+c)[(p:=p*(ord(c)%4)).find(c)]for c in s)
Try it online!
Python 2, 98 bytes
lambda s:''.join(('aoiAOI'+c)[(-~-('p'in s[:i].lower())*'iaoIAO').find(c)]for i,c in enumerate(s))
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 3.8 (pre-release), 81 78 bytes
lambda s,p='iaoIAO':''.join(('aoiAOI'+c)[(p:=p*(ord(c)%4)).find(c)]for c in s)
Try it online!
Python 2, 98 bytes
lambda s:''.join(('aoiAOI'+c)[(-~-('p'in s[:i].lower())*'iaoIAO').find(c)]for i,c in enumerate(s))
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 3.8 (pre-release), 81 78 bytes
lambda s,p='iaoIAO':''.join(('aoiAOI'+c)[(p:=p*(ord(c)%4)).find(c)]for c in s)
Try it online!
Python 2, 98 bytes
lambda s:''.join(('aoiAOI'+c)[(-~-('p'in s[:i].lower())*'iaoIAO').find(c)]for i,c in enumerate(s))
Try it online!
$endgroup$
Python 3.8 (pre-release), 81 78 bytes
lambda s,p='iaoIAO':''.join(('aoiAOI'+c)[(p:=p*(ord(c)%4)).find(c)]for c in s)
Try it online!
Python 2, 98 bytes
lambda s:''.join(('aoiAOI'+c)[(-~-('p'in s[:i].lower())*'iaoIAO').find(c)]for i,c in enumerate(s))
Try it online!
edited Feb 28 at 6:23
answered Feb 27 at 13:47
TFeldTFeld
16.3k21451
16.3k21451
add a comment |
add a comment |
$begingroup$
Java (JDK), 52 bytes
s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
Try it online!
- Port of Grimy's C answer. Make sure to upvote his answer!
$endgroup$
$begingroup$
-3 bytes by using a port of Grimy's C answer instead:s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
52 bytes.
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:44
add a comment |
$begingroup$
Java (JDK), 52 bytes
s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
Try it online!
- Port of Grimy's C answer. Make sure to upvote his answer!
$endgroup$
$begingroup$
-3 bytes by using a port of Grimy's C answer instead:s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
52 bytes.
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:44
add a comment |
$begingroup$
Java (JDK), 52 bytes
s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
Try it online!
- Port of Grimy's C answer. Make sure to upvote his answer!
$endgroup$
Java (JDK), 52 bytes
s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
Try it online!
- Port of Grimy's C answer. Make sure to upvote his answer!
edited Mar 2 at 16:39
answered Feb 27 at 14:56
Olivier GrégoireOlivier Grégoire
9,33511944
9,33511944
$begingroup$
-3 bytes by using a port of Grimy's C answer instead:s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
52 bytes.
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:44
add a comment |
$begingroup$
-3 bytes by using a port of Grimy's C answer instead:s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
52 bytes.
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:44
$begingroup$
-3 bytes by using a port of Grimy's C answer instead:
s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
52 bytes.$endgroup$
– Kevin Cruijssen
Mar 1 at 15:44
$begingroup$
-3 bytes by using a port of Grimy's C answer instead:
s->{for(int i=0;s[++i]%4>0;)s[i]^=s[i]%16*36%98%22;}
52 bytes.$endgroup$
– Kevin Cruijssen
Mar 1 at 15:44
add a comment |
$begingroup$
Perl 5, 31 bytes
s/.+?p/$&=~y,iaoIAO,aoiAOI,r/ei
TIO
$endgroup$
add a comment |
$begingroup$
Perl 5, 31 bytes
s/.+?p/$&=~y,iaoIAO,aoiAOI,r/ei
TIO
$endgroup$
add a comment |
$begingroup$
Perl 5, 31 bytes
s/.+?p/$&=~y,iaoIAO,aoiAOI,r/ei
TIO
$endgroup$
Perl 5, 31 bytes
s/.+?p/$&=~y,iaoIAO,aoiAOI,r/ei
TIO
edited Feb 27 at 10:56
answered Feb 27 at 10:49
Nahuel FouilleulNahuel Fouilleul
2,965211
2,965211
add a comment |
add a comment |
$begingroup$
SNOBOL4 (CSNOBOL4), 183 bytes
INPUT (BREAK('Pp') SPAN('Pp')) . P REM . S
A P 'a' ='o' :S(A)
Z P 'A' ='O' :S(Z)F(P)
I P 'i' ='a' :S(I)
K P 'I' ='A' :S(K)F(P)
O P 'o' ='i' :S(O)
L P 'O' ='I' :S(L)
P OUTPUT =P S
END
Try it online!
$endgroup$
add a comment |
$begingroup$
SNOBOL4 (CSNOBOL4), 183 bytes
INPUT (BREAK('Pp') SPAN('Pp')) . P REM . S
A P 'a' ='o' :S(A)
Z P 'A' ='O' :S(Z)F(P)
I P 'i' ='a' :S(I)
K P 'I' ='A' :S(K)F(P)
O P 'o' ='i' :S(O)
L P 'O' ='I' :S(L)
P OUTPUT =P S
END
Try it online!
$endgroup$
add a comment |
$begingroup$
SNOBOL4 (CSNOBOL4), 183 bytes
INPUT (BREAK('Pp') SPAN('Pp')) . P REM . S
A P 'a' ='o' :S(A)
Z P 'A' ='O' :S(Z)F(P)
I P 'i' ='a' :S(I)
K P 'I' ='A' :S(K)F(P)
O P 'o' ='i' :S(O)
L P 'O' ='I' :S(L)
P OUTPUT =P S
END
Try it online!
$endgroup$
SNOBOL4 (CSNOBOL4), 183 bytes
INPUT (BREAK('Pp') SPAN('Pp')) . P REM . S
A P 'a' ='o' :S(A)
Z P 'A' ='O' :S(Z)F(P)
I P 'i' ='a' :S(I)
K P 'I' ='A' :S(K)F(P)
O P 'o' ='i' :S(O)
L P 'O' ='I' :S(L)
P OUTPUT =P S
END
Try it online!
answered Feb 27 at 15:38
GiuseppeGiuseppe
17.3k31152
17.3k31152
add a comment |
add a comment |
$begingroup$
Python 2, 84 bytes
f=lambda s,r='':s[0]in'pP'and r+s or f(s[1:],r+('aoiAOI'+s[0])['iaoIAO'.find(s[0])])
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 84 bytes
f=lambda s,r='':s[0]in'pP'and r+s or f(s[1:],r+('aoiAOI'+s[0])['iaoIAO'.find(s[0])])
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 84 bytes
f=lambda s,r='':s[0]in'pP'and r+s or f(s[1:],r+('aoiAOI'+s[0])['iaoIAO'.find(s[0])])
Try it online!
$endgroup$
Python 2, 84 bytes
f=lambda s,r='':s[0]in'pP'and r+s or f(s[1:],r+('aoiAOI'+s[0])['iaoIAO'.find(s[0])])
Try it online!
edited Feb 28 at 6:01
answered Feb 28 at 5:55
Chas BrownChas Brown
5,0641523
5,0641523
add a comment |
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 60 bytes
n=>{for(int i=0;n[i]%4>0;)n[i]^=(char)(n[i++]%16*36%98%22);}
Based off of Grimy's C answer.
Try it online!
$endgroup$
1
$begingroup$
This unfortunately doesn't work as it replaces the vowels in the suffix as well.
$endgroup$
– Emigna
Feb 27 at 7:04
$begingroup$
As @Emigna states above, this replaces allaoi
-vowels, instead of just the ones before the firstp
/P
. One thing to golf however:("iao".IndexOf((char)(c|32))+1)%4
can be-~"iao".IndexOf((char)(c|32))%4
$endgroup$
– Kevin Cruijssen
Feb 27 at 12:04
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 60 bytes
n=>{for(int i=0;n[i]%4>0;)n[i]^=(char)(n[i++]%16*36%98%22);}
Based off of Grimy's C answer.
Try it online!
$endgroup$
1
$begingroup$
This unfortunately doesn't work as it replaces the vowels in the suffix as well.
$endgroup$
– Emigna
Feb 27 at 7:04
$begingroup$
As @Emigna states above, this replaces allaoi
-vowels, instead of just the ones before the firstp
/P
. One thing to golf however:("iao".IndexOf((char)(c|32))+1)%4
can be-~"iao".IndexOf((char)(c|32))%4
$endgroup$
– Kevin Cruijssen
Feb 27 at 12:04
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 60 bytes
n=>{for(int i=0;n[i]%4>0;)n[i]^=(char)(n[i++]%16*36%98%22);}
Based off of Grimy's C answer.
Try it online!
$endgroup$
C# (Visual C# Interactive Compiler), 60 bytes
n=>{for(int i=0;n[i]%4>0;)n[i]^=(char)(n[i++]%16*36%98%22);}
Based off of Grimy's C answer.
Try it online!
edited Mar 2 at 17:03
answered Feb 27 at 3:03
Embodiment of IgnoranceEmbodiment of Ignorance
2,248126
2,248126
1
$begingroup$
This unfortunately doesn't work as it replaces the vowels in the suffix as well.
$endgroup$
– Emigna
Feb 27 at 7:04
$begingroup$
As @Emigna states above, this replaces allaoi
-vowels, instead of just the ones before the firstp
/P
. One thing to golf however:("iao".IndexOf((char)(c|32))+1)%4
can be-~"iao".IndexOf((char)(c|32))%4
$endgroup$
– Kevin Cruijssen
Feb 27 at 12:04
add a comment |
1
$begingroup$
This unfortunately doesn't work as it replaces the vowels in the suffix as well.
$endgroup$
– Emigna
Feb 27 at 7:04
$begingroup$
As @Emigna states above, this replaces allaoi
-vowels, instead of just the ones before the firstp
/P
. One thing to golf however:("iao".IndexOf((char)(c|32))+1)%4
can be-~"iao".IndexOf((char)(c|32))%4
$endgroup$
– Kevin Cruijssen
Feb 27 at 12:04
1
1
$begingroup$
This unfortunately doesn't work as it replaces the vowels in the suffix as well.
$endgroup$
– Emigna
Feb 27 at 7:04
$begingroup$
This unfortunately doesn't work as it replaces the vowels in the suffix as well.
$endgroup$
– Emigna
Feb 27 at 7:04
$begingroup$
As @Emigna states above, this replaces all
aoi
-vowels, instead of just the ones before the first p
/P
. One thing to golf however: ("iao".IndexOf((char)(c|32))+1)%4
can be -~"iao".IndexOf((char)(c|32))%4
$endgroup$
– Kevin Cruijssen
Feb 27 at 12:04
$begingroup$
As @Emigna states above, this replaces all
aoi
-vowels, instead of just the ones before the first p
/P
. One thing to golf however: ("iao".IndexOf((char)(c|32))+1)%4
can be -~"iao".IndexOf((char)(c|32))%4
$endgroup$
– Kevin Cruijssen
Feb 27 at 12:04
add a comment |
$begingroup$
Ruby, 40 bytes
$_[$&]=$&.tr"IAOiao","AOIaoi"if/z+.+?p/i
Try it online!
$endgroup$
add a comment |
$begingroup$
Ruby, 40 bytes
$_[$&]=$&.tr"IAOiao","AOIaoi"if/z+.+?p/i
Try it online!
$endgroup$
add a comment |
$begingroup$
Ruby, 40 bytes
$_[$&]=$&.tr"IAOiao","AOIaoi"if/z+.+?p/i
Try it online!
$endgroup$
Ruby, 40 bytes
$_[$&]=$&.tr"IAOiao","AOIaoi"if/z+.+?p/i
Try it online!
answered Feb 27 at 7:36
Kirill L.Kirill L.
5,9631527
5,9631527
add a comment |
add a comment |
$begingroup$
05AB1E (legacy), 22 bytes
l'pkIg‚£ć…iaoDÀ‚Du+`‡ì
Try it online or verify all test cases.
Can definitely be golfed a bit more..
Uses the legacy version of 05AB1E instead of the Elixir rewrite, because +
merges fields in same-length lists, whereas the new version would need a pair-zip-join ‚øJ
instead.
Explanation:
l # Lowercase the (implicit) input-string
# i.e. "ZipPeroni" → "zipperoni"
'pk '# Get the index of the first "p"
# i.e. "zipperoni" → 2
Ig‚ # Pair it with the length of the entire input-string
# i.e. 2 and "zipperoni" → [2,9]
£ # Split the (implicit) input-string into parts of that size
# i.e. "ZipPeroni" and [2,9] → ["Zi","pPeroni"]
ć # Extract head: push the head and remainder separately to the stack
# i.e. ["Zi","pPeroni"] → ["pPeroni"] and "Zi"
…iao # Push string "iao"
DÀ # Duplicate, and rotate it once towards the left: "aoi"
‚ # Pair them up: ["iao","aoi"]
Du # Duplicate and transform it to uppercase: ["IAO","AOI"]
+ # Python-style merge them together: ["iaoIAO","aoiAOI"]
` # Push both strings to the stack
‡ # Transliterate; replacing all characters at the same indices
# i.e. "Zi", "iaoIAO" and "aoiAOI" → "Za"
ì # Prepend it to the remainder (and output implicitly)
# i.e. ["pPeroni"] and "Za" → ["ZapPeroni"]
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy), 22 bytes
l'pkIg‚£ć…iaoDÀ‚Du+`‡ì
Try it online or verify all test cases.
Can definitely be golfed a bit more..
Uses the legacy version of 05AB1E instead of the Elixir rewrite, because +
merges fields in same-length lists, whereas the new version would need a pair-zip-join ‚øJ
instead.
Explanation:
l # Lowercase the (implicit) input-string
# i.e. "ZipPeroni" → "zipperoni"
'pk '# Get the index of the first "p"
# i.e. "zipperoni" → 2
Ig‚ # Pair it with the length of the entire input-string
# i.e. 2 and "zipperoni" → [2,9]
£ # Split the (implicit) input-string into parts of that size
# i.e. "ZipPeroni" and [2,9] → ["Zi","pPeroni"]
ć # Extract head: push the head and remainder separately to the stack
# i.e. ["Zi","pPeroni"] → ["pPeroni"] and "Zi"
…iao # Push string "iao"
DÀ # Duplicate, and rotate it once towards the left: "aoi"
‚ # Pair them up: ["iao","aoi"]
Du # Duplicate and transform it to uppercase: ["IAO","AOI"]
+ # Python-style merge them together: ["iaoIAO","aoiAOI"]
` # Push both strings to the stack
‡ # Transliterate; replacing all characters at the same indices
# i.e. "Zi", "iaoIAO" and "aoiAOI" → "Za"
ì # Prepend it to the remainder (and output implicitly)
# i.e. ["pPeroni"] and "Za" → ["ZapPeroni"]
$endgroup$
add a comment |
$begingroup$
05AB1E (legacy), 22 bytes
l'pkIg‚£ć…iaoDÀ‚Du+`‡ì
Try it online or verify all test cases.
Can definitely be golfed a bit more..
Uses the legacy version of 05AB1E instead of the Elixir rewrite, because +
merges fields in same-length lists, whereas the new version would need a pair-zip-join ‚øJ
instead.
Explanation:
l # Lowercase the (implicit) input-string
# i.e. "ZipPeroni" → "zipperoni"
'pk '# Get the index of the first "p"
# i.e. "zipperoni" → 2
Ig‚ # Pair it with the length of the entire input-string
# i.e. 2 and "zipperoni" → [2,9]
£ # Split the (implicit) input-string into parts of that size
# i.e. "ZipPeroni" and [2,9] → ["Zi","pPeroni"]
ć # Extract head: push the head and remainder separately to the stack
# i.e. ["Zi","pPeroni"] → ["pPeroni"] and "Zi"
…iao # Push string "iao"
DÀ # Duplicate, and rotate it once towards the left: "aoi"
‚ # Pair them up: ["iao","aoi"]
Du # Duplicate and transform it to uppercase: ["IAO","AOI"]
+ # Python-style merge them together: ["iaoIAO","aoiAOI"]
` # Push both strings to the stack
‡ # Transliterate; replacing all characters at the same indices
# i.e. "Zi", "iaoIAO" and "aoiAOI" → "Za"
ì # Prepend it to the remainder (and output implicitly)
# i.e. ["pPeroni"] and "Za" → ["ZapPeroni"]
$endgroup$
05AB1E (legacy), 22 bytes
l'pkIg‚£ć…iaoDÀ‚Du+`‡ì
Try it online or verify all test cases.
Can definitely be golfed a bit more..
Uses the legacy version of 05AB1E instead of the Elixir rewrite, because +
merges fields in same-length lists, whereas the new version would need a pair-zip-join ‚øJ
instead.
Explanation:
l # Lowercase the (implicit) input-string
# i.e. "ZipPeroni" → "zipperoni"
'pk '# Get the index of the first "p"
# i.e. "zipperoni" → 2
Ig‚ # Pair it with the length of the entire input-string
# i.e. 2 and "zipperoni" → [2,9]
£ # Split the (implicit) input-string into parts of that size
# i.e. "ZipPeroni" and [2,9] → ["Zi","pPeroni"]
ć # Extract head: push the head and remainder separately to the stack
# i.e. ["Zi","pPeroni"] → ["pPeroni"] and "Zi"
…iao # Push string "iao"
DÀ # Duplicate, and rotate it once towards the left: "aoi"
‚ # Pair them up: ["iao","aoi"]
Du # Duplicate and transform it to uppercase: ["IAO","AOI"]
+ # Python-style merge them together: ["iaoIAO","aoiAOI"]
` # Push both strings to the stack
‡ # Transliterate; replacing all characters at the same indices
# i.e. "Zi", "iaoIAO" and "aoiAOI" → "Za"
ì # Prepend it to the remainder (and output implicitly)
# i.e. ["pPeroni"] and "Za" → ["ZapPeroni"]
edited Feb 27 at 12:01
answered Feb 27 at 11:54
Kevin CruijssenKevin Cruijssen
41.9k569217
41.9k569217
add a comment |
add a comment |
$begingroup$
PHP, 30 bytes
too simple for a TiO:
<?=strtr($argn,oiaOIA,iaoIAO);
Run as pipe with -nF
. For PHP 7.2, put the string literals in quotes.
$endgroup$
$begingroup$
This transliterates alloia
vowels instead of only the ones before the firstp
/P
, doesn't it?
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:39
add a comment |
$begingroup$
PHP, 30 bytes
too simple for a TiO:
<?=strtr($argn,oiaOIA,iaoIAO);
Run as pipe with -nF
. For PHP 7.2, put the string literals in quotes.
$endgroup$
$begingroup$
This transliterates alloia
vowels instead of only the ones before the firstp
/P
, doesn't it?
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:39
add a comment |
$begingroup$
PHP, 30 bytes
too simple for a TiO:
<?=strtr($argn,oiaOIA,iaoIAO);
Run as pipe with -nF
. For PHP 7.2, put the string literals in quotes.
$endgroup$
PHP, 30 bytes
too simple for a TiO:
<?=strtr($argn,oiaOIA,iaoIAO);
Run as pipe with -nF
. For PHP 7.2, put the string literals in quotes.
answered Mar 1 at 8:27
TitusTitus
13.4k11240
13.4k11240
$begingroup$
This transliterates alloia
vowels instead of only the ones before the firstp
/P
, doesn't it?
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:39
add a comment |
$begingroup$
This transliterates alloia
vowels instead of only the ones before the firstp
/P
, doesn't it?
$endgroup$
– Kevin Cruijssen
Mar 1 at 15:39
$begingroup$
This transliterates all
oia
vowels instead of only the ones before the first p
/P
, doesn't it?$endgroup$
– Kevin Cruijssen
Mar 1 at 15:39
$begingroup$
This transliterates all
oia
vowels instead of only the ones before the first p
/P
, doesn't it?$endgroup$
– Kevin Cruijssen
Mar 1 at 15:39
add a comment |
$begingroup$
C/C++ (VC++ compiler) 192bytes
this is a rather naive try but anyway
void f(char*I){int c={-8,14,6},B=1,v={105,97,111},j=0;for(*I;*I>0&B;I++){if(*I==80|*I==112){B=0;break;}if(*I==90|*I==122){}else{for(j;j<3;j++){if(*I==v[j]|*I==v[j]-32){*I+=c[j];break;}}}}}
some slightly more readable Version is this
#include "stdafx.h"
void f(char * theString)
{
signed int change = {'a'-'i','o'-'a','o'-'i'}; // add this to the vowel to get the next one
char theVowels = {'i','a','o'};
int breaker = 1;
printf("Input %sn",theString);
for (int i = 0;(theString[i] != '') && breaker; i++)
{
switch (theString[i])
{
case 'Z': /*fall through*/
case 'z': break;
case 'P': /*fall through*/
case 'p': breaker = 0;
break;
default:
{
for (int j = 0; j < 3; j++)
{
if ((theString[i] == theVowels[j]) || (theString[i]==(theVowels[j]-'a'+'A')))
{
theString[i] += change[j];
break;
}
}
}
break;
}
}
printf("Output %sn",theString);
}
int main()
{
char theString= "zzzzIIIIp0815-4711"; // a test string
f(theString);
return 0;
}
$endgroup$
$begingroup$
tio: tio.run/…
$endgroup$
– der bender
Mar 25 at 16:13
$begingroup$
tio golfed : tio.run/…
$endgroup$
– der bender
Mar 25 at 16:16
add a comment |
$begingroup$
C/C++ (VC++ compiler) 192bytes
this is a rather naive try but anyway
void f(char*I){int c={-8,14,6},B=1,v={105,97,111},j=0;for(*I;*I>0&B;I++){if(*I==80|*I==112){B=0;break;}if(*I==90|*I==122){}else{for(j;j<3;j++){if(*I==v[j]|*I==v[j]-32){*I+=c[j];break;}}}}}
some slightly more readable Version is this
#include "stdafx.h"
void f(char * theString)
{
signed int change = {'a'-'i','o'-'a','o'-'i'}; // add this to the vowel to get the next one
char theVowels = {'i','a','o'};
int breaker = 1;
printf("Input %sn",theString);
for (int i = 0;(theString[i] != '') && breaker; i++)
{
switch (theString[i])
{
case 'Z': /*fall through*/
case 'z': break;
case 'P': /*fall through*/
case 'p': breaker = 0;
break;
default:
{
for (int j = 0; j < 3; j++)
{
if ((theString[i] == theVowels[j]) || (theString[i]==(theVowels[j]-'a'+'A')))
{
theString[i] += change[j];
break;
}
}
}
break;
}
}
printf("Output %sn",theString);
}
int main()
{
char theString= "zzzzIIIIp0815-4711"; // a test string
f(theString);
return 0;
}
$endgroup$
$begingroup$
tio: tio.run/…
$endgroup$
– der bender
Mar 25 at 16:13
$begingroup$
tio golfed : tio.run/…
$endgroup$
– der bender
Mar 25 at 16:16
add a comment |
$begingroup$
C/C++ (VC++ compiler) 192bytes
this is a rather naive try but anyway
void f(char*I){int c={-8,14,6},B=1,v={105,97,111},j=0;for(*I;*I>0&B;I++){if(*I==80|*I==112){B=0;break;}if(*I==90|*I==122){}else{for(j;j<3;j++){if(*I==v[j]|*I==v[j]-32){*I+=c[j];break;}}}}}
some slightly more readable Version is this
#include "stdafx.h"
void f(char * theString)
{
signed int change = {'a'-'i','o'-'a','o'-'i'}; // add this to the vowel to get the next one
char theVowels = {'i','a','o'};
int breaker = 1;
printf("Input %sn",theString);
for (int i = 0;(theString[i] != '') && breaker; i++)
{
switch (theString[i])
{
case 'Z': /*fall through*/
case 'z': break;
case 'P': /*fall through*/
case 'p': breaker = 0;
break;
default:
{
for (int j = 0; j < 3; j++)
{
if ((theString[i] == theVowels[j]) || (theString[i]==(theVowels[j]-'a'+'A')))
{
theString[i] += change[j];
break;
}
}
}
break;
}
}
printf("Output %sn",theString);
}
int main()
{
char theString= "zzzzIIIIp0815-4711"; // a test string
f(theString);
return 0;
}
$endgroup$
C/C++ (VC++ compiler) 192bytes
this is a rather naive try but anyway
void f(char*I){int c={-8,14,6},B=1,v={105,97,111},j=0;for(*I;*I>0&B;I++){if(*I==80|*I==112){B=0;break;}if(*I==90|*I==122){}else{for(j;j<3;j++){if(*I==v[j]|*I==v[j]-32){*I+=c[j];break;}}}}}
some slightly more readable Version is this
#include "stdafx.h"
void f(char * theString)
{
signed int change = {'a'-'i','o'-'a','o'-'i'}; // add this to the vowel to get the next one
char theVowels = {'i','a','o'};
int breaker = 1;
printf("Input %sn",theString);
for (int i = 0;(theString[i] != '') && breaker; i++)
{
switch (theString[i])
{
case 'Z': /*fall through*/
case 'z': break;
case 'P': /*fall through*/
case 'p': breaker = 0;
break;
default:
{
for (int j = 0; j < 3; j++)
{
if ((theString[i] == theVowels[j]) || (theString[i]==(theVowels[j]-'a'+'A')))
{
theString[i] += change[j];
break;
}
}
}
break;
}
}
printf("Output %sn",theString);
}
int main()
{
char theString= "zzzzIIIIp0815-4711"; // a test string
f(theString);
return 0;
}
answered Mar 25 at 16:08
der benderder bender
112
112
$begingroup$
tio: tio.run/…
$endgroup$
– der bender
Mar 25 at 16:13
$begingroup$
tio golfed : tio.run/…
$endgroup$
– der bender
Mar 25 at 16:16
add a comment |
$begingroup$
tio: tio.run/…
$endgroup$
– der bender
Mar 25 at 16:13
$begingroup$
tio golfed : tio.run/…
$endgroup$
– der bender
Mar 25 at 16:16
$begingroup$
tio: tio.run/…
$endgroup$
– der bender
Mar 25 at 16:13
$begingroup$
tio: tio.run/…
$endgroup$
– der bender
Mar 25 at 16:13
$begingroup$
tio golfed : tio.run/…
$endgroup$
– der bender
Mar 25 at 16:16
$begingroup$
tio golfed : tio.run/…
$endgroup$
– der bender
Mar 25 at 16:16
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
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%2f180463%2fplay-zip-zap-zop%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
2
$begingroup$
ziop -> what does this do?
$endgroup$
– Joshua
Feb 27 at 16:09
2
$begingroup$
@Joshua This is invalid according to the description (see "all the same letter").
$endgroup$
– Arnauld
Feb 27 at 16:23
1
$begingroup$
@Arnauld: And the test case for zoopzaap disagrees with the description.
$endgroup$
– Joshua
Feb 27 at 16:25
4
$begingroup$
@Joshua Why? This only applies to the vowels between the leading
z
's and the firstp
. The suffix may contain anything.$endgroup$
– Arnauld
Feb 27 at 16:27