Lithp Tranthlator

27

6

My friend made a lisp translator the other day, that is to say it took a string and converted s=>th and S=>Th. It was quite long and I thought that it could be golfed.

So the task is to make a program/function that takes an input string, translates it in to lisp and outputs the string

Test case

Sam and Sally like Sheep        Tham and Thally like Thheep
Sally likes sausages            Thally liketh thauthageth
Sally sells seashells           Thally thellth theathhellth

Note that it doesn't matter that h gets repeated all the time

This is code golf so shortest answer wins

george

Posted 2016-06-17T10:17:06.343

Reputation: 1 495

13I wished everyone would change the bytes in their headers to byteth. – Leaky Nun – 2016-06-17T17:14:49.153

May someone show this challenge to Mike Tyson? – user8397947 – 2016-06-17T18:25:23.133

6There should be bonus points if the program doesn't use s nor S anywhere in it. – Nate Diamond – 2016-06-17T18:41:14.557

@NateDiamond great idea, but too late for that, i'm afraid. – Mindwin – 2016-06-17T19:15:19.080

Thufferin' thuccotathh! – mbomb007 – 2016-06-17T20:58:56.860

1I think the language names should be made clear. Without the replacement. Some languages contain "th" already, so it's ambiguous. And who's to say that someone won't create a different language actually called "Common Lithp" in the future? – mbomb007 – 2016-06-17T21:02:27.783

1@mbomb007 I wouldn't worry about it too much. I'm not sure if there is actually a default way to title your answer. Most question I see if they do state how to do it it is normally the same way. As I haven't explain how the answer should be set out, then users are free to title them how they want to. Being a pedant, I didn't even ask for a language, so I could argue against them even writing them. But I do understand your point. I just don't think it is of concern – george – 2016-06-17T21:09:40.213

2A thing that would have made this challenge more interesting would be overall case preservation, e.g. LOOK OUT A SNAKE!!! -> LOOK OUT A THNAKE!!! – fluffy – 2016-06-18T03:06:05.760

1@fluffy after writing the question I did realise a case like that would fail, but it is too late to change now – george – 2016-06-18T07:37:13.013

1Welcome to Programming Puzzleth & Code Golf! That Ith a Good quethtion and thothe help the community a lot! – None – 2016-07-05T10:15:42.830

Answers

36

Common Lithp, 62

(map()(lambda(u)(princ(case u(#\s"th")(#\S"Th")(t u))))(read))

First, (read) the input (it should be a string). Strings in CL are sequences so we use map to iterate on each character. The first argument to map represents the type of the result (e.g. I could build a list from a vector). When it is nil, a.k.a. (), results are discarded. The function that is mapped to the input simply princ (print non-readably) each character, except the ones that should be replaced.

coredump

Posted 2016-06-17T10:17:06.343

Reputation: 6 292

14That language name though. – Joe Z. – 2016-06-17T15:02:06.710

1@JoeZ. I just replaced the s by th, like everybody else did: look at those Pyson answers. – coredump – 2016-06-17T16:04:46.903

@coredump They're all wrong: it's one-way: s->th, S->Th, th->th, Th->Th. – Erik the Outgolfer – 2016-06-17T16:05:45.797

I think thith ith invalid. You want cathe u(#\s"th") inthtead. – James – 2016-06-17T18:01:43.533

1@DrGreenEggsandIronMan Sure, (defmacro cathe (&rest args) \(case ,@args))` – coredump – 2016-06-17T18:07:50.597

umm What is Common lithp – None – 2016-07-05T13:20:58.100

@Matthew Not sure if you are joking or not, but Common Lisp is a language and Common Lithp is a pun based on the question. BTW, when I first read the question, I imagined it was about the programming language. – coredump – 2016-07-05T15:19:46.493

1Ok lol that makes more sense – None – 2016-07-05T15:20:20.840

17

Retina, 9 bytes

S
Th
s
th

Try it online!

The obvious answer.

user48538

Posted 2016-06-17T10:17:06.343

Reputation: 1 478

13

JavaThcript ETh6, 38 bytes

At first I went with the obvious solution

a=>a.replace(/s/g,'th').replace(/S/g,'Th')

But I golfed it down 4 bytes

a=>a.replace(/s/gi,b=>b>'r'?'th':'Th')

This makes use of the regex i flag, which searches for case-insensitive patterns. The good thing about Javascript is that you can specify an anonymous function to handle (regex) replacing.

Try it here

f=
a=>a.replace(/s/gi,b=>b>'r'?'th':'Th')

s.innerHTML = [
    'abScdsefSghsij',
    'Sam and Sally like Sheep',
    'Sally likes sausages',
    'Sally sells seashells'
].map(c=>c + ' => ' + f(c)).join`<br>`
<pre id=s>

Bassdrop Cumberwubwubwub

Posted 2016-06-17T10:17:06.343

Reputation: 5 707

11"E eth thickth"? – Joe Z. – 2016-06-17T15:02:40.103

I was thinking in 'Tt'[b>'r']+'h', but it is the same length – Washington Guedes – 2016-06-17T18:48:33.630

1You mean 38 byteth – Downgoat – 2016-06-17T19:41:31.000

+1 for TIL that string comparison is done via Code Point Value – MayorMonty – 2016-06-17T21:08:27.610

@Upgoat That was my fault sorry. – Neil – 2016-06-19T22:57:46.913

¡ʇɐoƃ 'ıH lolol – None – 2016-07-05T13:22:55.953

11

GNU Sed - 17

s/S/Th/g;s/s/th/g

The obvious answer.

$ sed -e "s/S/Th/g;s/s/th/g"

Sam and Sally like Sheep
Tham and Thally like Thheep

Sally likes sausages
Thally liketh thauthageth

Sally sells seashells
Thally thellth theathhellth

C. Quilley

Posted 2016-06-17T10:17:06.343

Reputation: 546

17Did you mean GNU Thed? ;) – m654 – 2016-06-17T15:57:21.067

9

Jelly, 13 bytes

“Ss”,“Th“th”y

Thhowing off Jelly'th thhiny new tranthlate atom. Try it online!

Dennis

Posted 2016-06-17T10:17:06.343

Reputation: 196 637

7

Python 3 - 40 byteth

First golfing!

lambda s:s.translate({115:'th',83:'Th'})

It uses the str module's translate method which accepts a translation table. The translation table is a simple dict with keycode as keys and the str in place of it as value.

Gabor Fekete

Posted 2016-06-17T10:17:06.343

Reputation: 71

1Welcome to the PP&CG community! – Erik the Outgolfer – 2016-06-17T15:23:28.803

4Can I ask you, why you have 2 separate accounts? – Bálint – 2016-06-17T20:50:14.610

@Bálint Apparently, he forgot to log into his current account with only 3 rep, but an experience on [so]. And posted with a new account. – user48538 – 2016-06-18T07:54:20.423

6

JavaThcript ETh6, 43 byteth

s=>s.replace(/s/gi,m=>({s:'th',S:'Th'})[m])

Tetht Thuite:

th=s=>s.replace(/s/gi,m=>({s:'th',S:'Th'})[m])
  
console.log(th('Sam and Sally like Sheep'));
console.log(th('Sally likes sausages'));
console.log(th('Sally sells seashells'));

Patrick Roberts

Posted 2016-06-17T10:17:06.343

Reputation: 2 475

6Confethth: thou only wroteth that tetht thuite for the thake of itth title! – ceased to turn counterclockwis – 2016-06-18T00:21:53.107

6

V, 11 byteth

Ís/th
ÍS/Th

Try it online!

V ith a language I made. It'th not finithed, but it'th really good at regekth.

James

Posted 2016-06-17T10:17:06.343

Reputation: 54 537

5

05AB1E, 14 12 bytes

's„th:'S„Th:

The straight forward answer.

Try it online

Saved 2 bytes thanks to @Adnan

Emigna

Posted 2016-06-17T10:17:06.343

Reputation: 50 798

Isn't this the thtraight forward anthwer rather than the straight forward answer? – user8397947 – 2016-07-17T02:59:28.627

5

C, 50 bytes

s(c){c=getchar();c+=c-83&95?0:'h\1';s(printf(&c));}

Replace \1 with an actual \x01 byte.

jimmy23013 saved a byte, and then I saved two more using his approach! Thanks.

Lynn

Posted 2016-06-17T10:17:06.343

Reputation: 55 648

I was about to comment that the &c parameter is broken. But it's not, because on a little-endian architecture the second byte of that int will be 0x00 and actually terminate the "string"... This is horribly clever, I love it ! – Quentin – 2016-06-17T13:51:50.117

s(c){c=getchar();c+=c-83&~32?0:26625;s(printf(&c));} – jimmy23013 – 2016-06-17T13:58:49.623

You can't push 2 bytes into a char. 'h\1' – Erik the Outgolfer – 2016-06-18T07:53:06.103

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Multi-character constants are implementation defined, bu perfectly valid C. – Dennis – 2016-07-05T02:23:47.520

4

Java, 71 65 bytes

String t(String s){return s.replace("S","Th").replace("s","th");}

First attempt at golfing, so why not with Java.

Insane

Posted 2016-06-17T10:17:06.343

Reputation: 280

2You can use replace instead of replaceAll – aditsu quit because SE is EVIL – 2016-06-17T12:23:42.567

Oh, yeah you're right. Thanks! @aditsu – Insane – 2016-06-17T12:25:19.590

3You can save some bytes by using a lambda expression instead of a function. s->s.replace("S","Th").replace("s","th") – Denker – 2016-06-17T12:45:21.877

4

GNU AWK, 31 bytes

Just using gsub function to translate lower or upper S via regex and print it afterwards. Can work with files, or with stdin as in this case

$ awk '{gsub(/s/,"th");gsub(/S/,"Th")}1' <<< "This is Sparta"                   
Thith ith Thparta

Sergiy Kolodyazhnyy

Posted 2016-06-17T10:17:06.343

Reputation: 331

3

Python3 - 46 bytes

lambda s:s.replace("s","th").replace("S","Th")

Dropped 4 bytes with the help of @DenkerAffe!

Yytsi

Posted 2016-06-17T10:17:06.343

Reputation: 3 582

1Python 3 was the language it was originally written in. My version of his code was 59 bytes, so we'll done! – george – 2016-06-17T10:39:38.893

1lambda s:s.replace("s","th").replace("S","Th") is a bit shorter. – Denker – 2016-06-17T10:51:15.717

@DenkerAffe Yes it is shorter but to use lambda in this case, you would still need an input and an output to answer the original question. – george – 2016-06-17T10:55:58.033

1

@george Community consensus is that functions can use arguments and returns values instead of using stdin/stdout. Have a look at our defaults for I/O. While you can of course override them if you want, it wouldn't make much sense in this particular challenge.

– Denker – 2016-06-17T11:02:49.073

@DenkerAffe okay that's fine. When I asked the question I mean the output would be an echo or print. But I shall leave it to the defaults. So yes using lambda would be shorter – george – 2016-06-17T11:12:43.340

3

CJam, 15 bytes

q"sS""thTh"2/er

Test it here.

Explanation

q      e# Read input.
"sS"   e# Push string.
"thTh" e# Push string.
2/     e# Split into pairs, i.e. ["th" "Th"].
er     e# Transliteration, replaces 's' with 'th' and 'S' with 'Th'.

Martin Ender

Posted 2016-06-17T10:17:06.343

Reputation: 184 808

3

Haskell, 36 bytes

f 's'="th";f 'S'="Th";f x=[x]
(>>=f)

Lynn

Posted 2016-06-17T10:17:06.343

Reputation: 55 648

You don't need the space: f's'=... – ThreeFx – 2016-06-17T14:22:13.780

1Sadly, I do. Haskell names may contain apostrophes. :( – Lynn – 2016-06-17T14:36:54.630

Oh damn I completely forgot that. I almost never need Chars... – ThreeFx – 2016-06-17T14:51:00.487

8I thought it wath "Hathkell" – Patrick Roberts – 2016-06-17T15:42:22.423

3

PHP, 42 Bytes

if run from a file:

<?=strtr($argv[1],["s"=>"th","S"=>"Th"]);

Run as:

~$ php [file] "This is Silly"

InaScuffle

Posted 2016-06-17T10:17:06.343

Reputation: 31

-1 byte: remove the newline at the end – Erik the Outgolfer – 2016-06-17T16:03:06.657

-8 bytes: remove quotes. -> use php -d error_reporting=0 to suppress notices. – Titus – 2016-07-06T10:03:05.147

3

Rust, 46 bytes

|s:&str|s.replace("s","th").replace("S","Th");

Try it online!

Kek

Posted 2016-06-17T10:17:06.343

Reputation: 31

1@mbomb007. I'm not sure you should edit that. – Washington Guedes – 2016-06-17T21:02:47.220

I'm making it follow the answering guidelines. I should be able to view a post and know what language it is. Some languages contain "th" already, so it's ambiguous. And who's to say that someone won't create a different language actually called "Rutht" in the future? – mbomb007 – 2016-06-17T21:04:18.653

2@mbomb007, who's to say someone won't create a different language called "Rust" in the future? – msh210 – 2016-06-17T21:24:31.957

@msh210 Moot point, because if used the poster will need to clarify. – mbomb007 – 2016-06-17T21:32:36.533

3

TI-Basic, 126 bytes

Input Str1
inString(Str1,"s
While Ans
sub(Str1,1,Ans-1)+"th"+sub(Str1,Ans+1,length(Str1)-Ans->Str1
inString(Str1,"s
End
inString(Str1,"S
While Ans
sub(Str1,1,Ans-1)+"Th"+sub(Str1,Ans+1,length(Str1)-Ans->Str1
inString(Str1,"S
End
Str1

Timtech

Posted 2016-06-17T10:17:06.343

Reputation: 12 038

This is wrong. Str1 never changes, and Ans will hold a number at the end. – lirtosiast – 2016-07-14T22:45:19.890

Thanks for the note, fixed now. I don't know how I forgot to save Str1 back again... – Timtech – 2016-07-15T23:08:50.777

This is still wrong; it errors when the first or last character is S. As I've said before, please test your code before you post it. – lirtosiast – 2016-07-18T04:24:32.267

3

Java, 101 byteth

interface a{static void main(String[]A){System.out.print(A[0].replace("S","Th").replace("s","th"));}}

Note that this is a complete program unlike the previous Java answer.

Bonus (has to be fed to the C preprocessor THEE preprothethor first):

#define interfaith interface
#define thtatic static
#define Thtring String
#define Thythtem System
#define replaith(x,y) replace(x,y)

interfaith a{thtatic void main(Thtring[]A){Thythtem.out.print(A[0].replaith("S","Th").replaith("s","th"));}}

user8397947

Posted 2016-06-17T10:17:06.343

Reputation: 1 242

2

C# 6.0 - 58 bytes

string f(string s)=>s.Replace("s","th").Replace("S","Th");

Takes the input string as an argument to the function.

Yytsi

Posted 2016-06-17T10:17:06.343

Reputation: 3 582

2

Pyth, 14 bytes

::z\s"th"\S"Th

Test suite

Thanks to @LeakyNun for spotting a typo!

Denker

Posted 2016-06-17T10:17:06.343

Reputation: 6 639

5So the language is "Pys"? :P – mbomb007 – 2016-06-17T21:00:54.133

2

MATL, 17 bytes

115'th'YX83'Th'YX

Try it online!

Explanation

115    % 's' (ASCII)
'th'   % String 'th'
YX     % Regex replacement
83     % 'S' (ASCII)
'Th'   % String 'Th'
YX     % Regex replacement

Luis Mendo

Posted 2016-06-17T10:17:06.343

Reputation: 87 464

2

Python 3, 53 bytes

def l(s):return s.replace("s","th").replace("S","Th")

Usage:

>> l('Sam and Sally like Sheep')

Tham and Thally like Thheep

m654

Posted 2016-06-17T10:17:06.343

Reputation: 765

-7 bytes: lambda s:s.replace("s","th").replace("S","Th") Usage: (lambda s:s.replace("s","th").replace("S","Th"))(s) – Erik the Outgolfer – 2016-06-17T16:02:10.077

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Well, that's identical to TuukkaX's answer (which was posted before mine), so... – m654 – 2016-06-17T16:04:06.927

There's no reason to post another answer then. – Erik the Outgolfer – 2016-06-17T16:08:41.577

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I didn't notice his when I posted mine. – m654 – 2016-06-17T16:09:52.600

You can delete your answer once you notice there is a shorter one posted before yours. – Erik the Outgolfer – 2016-06-17T16:11:29.340

2

Befunge 98, 37 49 bytes

Original version :

~:"s"- #v_$"ht",>,
_;#-"S":<;$"hT",^ 

Terminating edition, as per consensus :

~:a-!#@_:"s"-#v_$"ht",>,
_;#-"S":      <;$"hT",^ 

This leaves a big honking hole in the code grid that I'm not very happy about. I'll look into that when I have the time.
The 49th byte is a space at the end of the second line, included to have a rectangular grid, required to prevent ccbi (and probably other interpreters) from bugging out and printing an infinite line of "Th"s.

karhell

Posted 2016-06-17T10:17:06.343

Reputation: 411

2

GameMaker Language, 74 bytes

return string_replace_all(string_replace_all(argument0,'s','th'),'S','Th')

Timtech

Posted 2016-06-17T10:17:06.343

Reputation: 12 038

2

Matlab, 39 byteth

A straitforward approach:

@(t)strrep(strrep(t,'s','th'),'S','Th')

pajonk

Posted 2016-06-17T10:17:06.343

Reputation: 2 480

2

Emacth Lithp, 61 byteth

(lambda(s)(replace-regexp-in-string"[Ss]\\(\\w*\\)""th\\1"s))

Emacs Lisp tries to be smart when replacing text, but that smartness breaks when the replaced string only takes up one space, i.e. the capital letter S. To prevent this from converting "Sam and Sally" to "THam and THally", the whole word is matched instead. However, this also handles "SAM and Sally" in the way that one would want, i.e. producing "THAM and Thally".

Lord Yuuma

Posted 2016-06-17T10:17:06.343

Reputation: 587

2

x86 machine code, 19 bytes

In hex:

86ac3c5374043c73750440aab068aa84c075eec3

Input: ESI: input string, EDI: output buffer.

Disassembly:

_loop:
0:  ac          lodsb       
1:  3c 53       cmp al,'S'  
3:  74 04       je _th      
5:  3c 73       cmp al,'s'  
7:  75 04       jne _nth    
_th:
9:  40          inc eax     ;[Ss]->[Tt]
a:  aa          stosb       
b:  b0 68       mov al,'h'  
_nth:
d:  aa          stosb       
e:  84 c0       test al,al  
10: 75 ee       jnz _loop   
12: c3          ret         

meden

Posted 2016-06-17T10:17:06.343

Reputation: 711

You can use test al, 'S' to check both at once – anatolyg – 2016-08-07T22:40:26.590

2

35 Byteth of Julia:

s->replace(s,r"s"i,s->"$(s[1]+1)h")

Try it online! (includes all test cases)

one-more-minute

Posted 2016-06-17T10:17:06.343

Reputation: 220

Hey, don't I know you from somewhere? ;) – Alex A. – 2016-07-29T18:02:53.393

1

SpecBAS ThpecBATh - 53 bytes

1 INPUT a$: ?REPLACE$(REPLACE$(a$,"S","Th"),"s","th")

Brian

Posted 2016-06-17T10:17:06.343

Reputation: 1 209

1

Matlab, 38 42 bytes

@(t)regexprep(t,{'s','S'},{'th','Th'})

Shout out to @LuisMendo for the tip about cell arrays!

For 'Miss Sissy' yields ans = Mithth Thiththy.

sintax

Posted 2016-06-17T10:17:06.343

Reputation: 291

I think straightforward approach is shorter: http://codegolf.stackexchange.com/a/83190/55372

– pajonk – 2016-06-17T18:37:59.073

1You can use a single call to regexprep with cell arrays: @(t)regexprep(t,{'s' 'S'},{'th' 'Th'}), 38 bytes – Luis Mendo – 2016-06-18T15:26:51.573

@LuisMendo I had had problems using cell arrays in regexprep before, but they seem to have straightened that out. Edited! – sintax – 2016-06-20T13:43:34.727

1

Perl 5, 18 byteth

The obviouth anthwer; I don't thee anything thhorter. 17 byteth, pluth 1 for -pe inthtead of -e.

s/s/th/g;s/S/Th/g

I wathn't thure whether, tho ath to follow the thandard for anthwerth of thith quethtion, I thhould lithpify my code ath well ath my prothe. Jutht in cathe, here'th the lithpy verthion:

th/th/th/g;th/Th/Th/g

msh210

Posted 2016-06-17T10:17:06.343

Reputation: 3 094

1

J, 38 bytes

load'strings'
rplc&('s';'th';'S';'Th')

In J, rplc is the string replace verb in the strings addon, and it takes a list of boxes where each pair [x, y] represents the string x to be replaced with y.

Usage

   f =: rplc&('s';'th';'S';'Th')
   f 'Sam and Sally like Sheep'
Tham and Thally like Thheep
   f 'Sally likes sausages'
Thally liketh thauthageth
   f 'Sally sells seashells'
Thally thellth theathhellth

miles

Posted 2016-06-17T10:17:06.343

Reputation: 15 654

1

C, 101 bytes

Note this is a complete C program, unlike the previous C answer.

It takes the first command line argument as input. Compile w/ gcc and run ./a.out "Sally sells seashells"

#include<stdio.h>
main(int d,char**c){for(d=**++c;d;putchar(d&223^83?d:d+(*0[c]--=104,1)),d=*++*c);}

McKay Davis

Posted 2016-06-17T10:17:06.343

Reputation: 11

Hello, and welcome to PPCG! – NoOneIsHere – 2016-06-18T01:27:31.577

2Erm, whether the program is complete doesn't matter. On PPCG we accept both full programs and functions. – user48538 – 2016-06-18T07:57:15.127

1

s-lang, 16 15 8 bytes (non-competing)

Saved one byte because s-lang no longer requires last argument bracket

Saved seven bytes because of ! paramater

Try it online!

t![s][th

s-lang (or, th-lang) is a string manipulation language I am working on for fun. I am still optimizing argument brackets...

Explantion

  • t replace function with search argument and replace argument.
  • ! "preserve case" parameter
  • [s] the first search argument (searches for the character "s")
  • [th the first replace argument (now this will replace each "s" with a "th"). End bracket is omitted because it is unnecessary.

MCMastery

Posted 2016-06-17T10:17:06.343

Reputation: 783

Doesn't p parameter need +1 byte? – Erik the Outgolfer – 2016-07-04T18:36:37.580

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ Oh.. it is now "!" instead of "!". I'll fix that – MCMastery – 2016-07-09T22:58:47.023

1

C, 69 byteth

Reads from stdin, writes to stdout. Nothing terrific, but somebody had to do it!

c;main(){while((c=getchar())>0)printf(c-'s'?c-'S'?"%c":"Th":"th",c);}

Stefano Sanfilippo

Posted 2016-06-17T10:17:06.343

Reputation: 1 059

1

Brainfuck, 235 byteth

(Newlines included only for readability)

,[[>+>+>+<<<-]>>>>-[>+<---]>--[-<<->>]+<<[>>-<<[-]]>>[>-[--->+<]>-.[---->+++++<]>-.<<<-]>>>>
[-]<[>+<[-]]+>[<->-]<[<<<<<-[>++<+++++++++]>+[-<<->>]+<<[>>-<<[-]]>>[>--------[-->+++<]>.---
---------.>]<>[-]<[>+<[-]]+>[<->-]<[<<.>]]>>>>>>>,]

Requires 8-bit cells, and 0 on EOF. Try it online! I thought I could golf tt using some "if = s OR = S" wizardry, but it turns out that this just confounds the system.

Readable

,
[
 [>+>+>+<<<-]>>>
 >-[>+<---]>--
 [-<<->>]+<<[>>-<<[-]]>>
 [ if char = "S"
  >-[--->+<]>-.[---->+++++<]>-.<<<-  output Th
 ]
 >>>

 >[-]
 <[>+<[-]]+
 >[<->-]<    logical negation

 [ else
  <<<<<
  -[>++<+++++++++]>+
  [-<<->>]+<<[>>-<<[-]]>>

   [ if char = "s"
    >--------[-->+++<]>.------------.>  output th
   ]

  <

  >[-]
  <[>+<[-]]+
  >[<->-]<    logical negation

  [<<.>] otherwise output and move to zero cell
 ]
 >>>>>>> we're going to move over some so we can use new cells
 , take more input
]

Conor O'Brien

Posted 2016-06-17T10:17:06.343

Reputation: 36 228

1

J, 47 bytes

Without using the strings library.

[:;(]`('h',~[:u:1+3&u:)@.([:+/'sS'-:"0]))&.>@;/

Conor O'Brien

Posted 2016-06-17T10:17:06.343

Reputation: 36 228

1

Javathcript, 27 Byteth

b=a=>a.replace(/s/gi,'th');

Although it is case insensitive it is the smallest JS version so far :)

Shubshub

Posted 2016-06-17T10:17:06.343

Reputation: 31

0

Thue, Full program: 27 byteth, function: 13 byteth

s::=th
S::=Th

Thince Thue can read input, a correct input routine will be too long. Tho i potht it ath a "function"

EDIT: I have forgotten, Thue read lineth from thtdin, not characterth

Tho, here ith a full program:

s::=th
S::=Th
I::=:::
::=
I

TuxCrafting

Posted 2016-06-17T10:17:06.343

Reputation: 4 547

Is the language Thue or Sue? – clismique – 2016-07-10T16:44:46.663

1@DerpfacePython The tranthformationth are only s => th and S => Th, tho it'th Thue. – TuxCrafting – 2016-07-10T16:50:29.367

Ah, I underthtand now. Thankth! – clismique – 2016-07-10T16:51:33.523

0

Pyke, 14 byteth

\s"th":\S"Th":

Try it here!

Thith anthwer ith very thimple and boring.

Blue

Posted 2016-06-17T10:17:06.343

Reputation: 26 661

0

PowerThhell, 41 bytes

$args.replace('S','Th').replace('s','th')

I can't beat this simple approach; there is a string.translate buried in XPath and there are map style approaches in the Linq library - but they're wordy. Can't easily do a dictionary lookup per character because PS is case insensitive and thinks 's' and 'S' are duplicate keys.

Best novelty alternative so far:

$OFS='Th';''+$args.split('S')-replace's','th'

TessellatingHeckler

Posted 2016-06-17T10:17:06.343

Reputation: 2 412

0

Thilicon, 13 byteth

i`s|th``S|Th`

Pretty simple. i to get input, and the rest of it is replacing stuff. Output is implicit.

m654

Posted 2016-06-17T10:17:06.343

Reputation: 765

-1

TCC - 28 bytes

=SO;i;{'s';'th';{'S';'Th';SO

Try it online!

Explanation:

=SO;i;                       - Load input (i) into SO (string operations)
      {'s';'th';             - Replace 's' with 'th' in SO
                {'S';'Th';   - Replace 'S' with 'Th' in SO
                          SO - Implicit print of SO

brianush1

Posted 2016-06-17T10:17:06.343

Reputation: 300

Did this work with a version of tcc.lua before the challenge was posted? Given that you've recently added commands to solve several other challenges, I assume it didn't. If your answer requires a version of the language that postdates the challenge, you must label it as non-competing in the header. I'll remove my downvote when you add the label or provide proof that your code worked in an earlier version. – Dennis – 2016-07-31T21:20:44.580