Skip to main content
edited body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37

#Python 2.7, 390 342 341 339339 335 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambdaW=X="";S,s=split,sub;D='[^\w\s*]';Q=lambda c,t:len(subs(D,X,c.group()).split()[t])
 for m in S(D+'\n''\W\n',subs(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),subs("'",X,subs("--"," ",i)))):
  for g in S(D+''\W  ',m):
   for q in S('\W',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print subs("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

#Python 2.7, 390 342 341 339 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambda c,t:len(sub(D,X,c.group()).split()[t])
 for m in S(D+'\n',sub(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),sub("'",X,sub("--"," ",i)))):
  for g in S(D+'  ',m):
   for q in S('\W',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print sub("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

#Python 2.7, 390 342 341 339 335 bytes:

from re import*
def F(i):
 W=X="";S,s=split,sub;D='[^\w\s*]';Q=lambda c,t:len(s(D,X,c.group()).split()[t])
 for m in S('\W\n',s(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),s("'",X,s("--"," ",i)))):
  for g in S('\W  ',m):
   for q in S('\W',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print s("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

added 9 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37

#Python 2.7, 390 342 341341 339 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambda c,t:len(sub(D,X,c.group()).split()[t])
 for m in S(D+'\n',sub(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),sub("'",X,sub("--"," ",i)))):
  for g in S(D+'  ',m):
   for q in S('[\W]''\W',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print sub("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

#Python 2.7, 390 342 341 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambda c,t:len(sub(D,X,c.group()).split()[t])
 for m in S(D+'\n',sub(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),sub("'",X,sub("--"," ",i)))):
  for g in S(D+'  ',m):
   for q in S('[\W]',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print sub("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

#Python 2.7, 390 342 341 339 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambda c,t:len(sub(D,X,c.group()).split()[t])
 for m in S(D+'\n',sub(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),sub("'",X,sub("--"," ",i)))):
  for g in S(D+'  ',m):
   for q in S('\W',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print sub("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

added 6 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37

#Python 2.7, 390 342342 341 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambda c,t:len(sub(D,X,c.group()).split()[t])
 for m in S(D+'\n',sub(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),sub("'",X,sub("--"," ",i)))):
  for g in S(D+'  ',m):
   for q in S('[\W ]''[\W]',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print sub("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by 2 spacesa single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

#Python 2.7, 390 342 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambda c,t:len(sub(D,X,c.group()).split()[t])
 for m in S(D+'\n',sub(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),sub("'",X,sub("--"," ",i)))):
  for g in S(D+'  ',m):
   for q in S('[\W ]',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print sub("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by 2 spaces.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

#Python 2.7, 390 342 341 bytes:

from re import*
def F(i):
 W=X="";S=split;D='[^\w\s*]';Q=lambda c,t:len(sub(D,X,c.group()).split()[t])
 for m in S(D+'\n',sub(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),sub("'",X,sub("--"," ",i)))):
  for g in S(D+'  ',m):
   for q in S('[\W]',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print sub("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

##Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

  1. Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

  1. Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

  2. Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

deleted 62 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
added 8 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
added 72 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
added 205 characters in body
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading
Source Link
R. Kap
  • 4.9k
  • 2
  • 15
  • 37
Loading