Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 209 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Python, 222 bytes

(202 characters)

import re
def f(s):y=[w[0]in'ˈˌ'and w or' '+w for w in re.split('([ˈˌ]?[bdfhjklmnprstvwzðŋɡʃʒθ]?[aeiouæɑɔəɛɜɪʊʌː]*)',s)[1::2]];return[[x[i-1:i]or' 'for x in y]for i in range(max(len(w)for w in y),0,-1)]

Returns an array of unicode characters with an array for each row (containing single spaces for each space required)

Not sure where one can get decent output online yet (and I haven't even got the tools to test it properly here either).
I have loaded a version to ideone that just uses English consonants and vowels with , and . as stress marks, where I have fudged the test cases to conform.

Python, 222 bytes

(202 characters)

import re
def f(s):y=[w[0]in'ˈˌ'and w or' '+w for w in re.split('([ˈˌ]?[bdfhjklmnprstvwzðŋɡʃʒθ]?[aeiouæɑɔəɛɜɪʊʌː]*)',s)[1::2]];return[[x[i-1:i]or' 'for x in y]for i in range(max(len(w)for w in y),0,-1)]

Returns an array of unicode characters with an array for each row (containing single spaces for each space required)

Not sure where one can get decent output online yet (and I haven't even got the tools to test it properly here either).

Python, 222 bytes

(202 characters)

import re
def f(s):y=[w[0]in'ˈˌ'and w or' '+w for w in re.split('([ˈˌ]?[bdfhjklmnprstvwzðŋɡʃʒθ]?[aeiouæɑɔəɛɜɪʊʌː]*)',s)[1::2]];return[[x[i-1:i]or' 'for x in y]for i in range(max(len(w)for w in y),0,-1)]

Returns an array of unicode characters with an array for each row (containing single spaces for each space required)

Not sure where one can get decent output online yet (and I haven't even got the tools to test it properly here either).
I have loaded a version to ideone that just uses English consonants and vowels with , and . as stress marks, where I have fudged the test cases to conform.

Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Python, 222 bytes

(202 characters)

import re
def f(s):y=[w[0]in'ˈˌ'and w or' '+w for w in re.split('([ˈˌ]?[bdfhjklmnprstvwzðŋɡʃʒθ]?[aeiouæɑɔəɛɜɪʊʌː]*)',s)[1::2]];return[[x[i-1:i]or' 'for x in y]for i in range(max(len(w)for w in y),0,-1)]

Returns an array of unicode characters with an array for each row (containing single spaces for each space required)

Not sure where one can get decent output online yet (and I haven't even got the tools to test it properly here either).

AltStyle によって変換されたページ (->オリジナル) /