String Halving

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

For the given input string, split the string into two halves. If the string does not split evenly, the left side will always be larger. For each of those two halves, the process is repeated. If a half only contains one character, it does not need to be halved further. This is continued until the string is split into several single character parts. The result is printed with each half recursively enclosed in {} brackets.

eg.

This is a sample string.
{{{{{{T}{h}}{i}}{{{s}{ }}{i}}}{{{{s}{ }}{a}}{{{ }{s}}{a}}}}{{{{{m}{p}}{l}}{{{e}{ }}{s}}}{{{{t}{r}}{i}}{{{n}{g}}{.}}}}}


step by step:

This is a sample string.
{This is a sample string.}
{{This is a sa}{mple string.}}
{{{This i}{s a sa}}{{mple s}{tring.}}}
{{{{Thi}{s i}}{{s a}{ sa}}}{{{mpl}{e s}}{{tri}{ng.}}}}
{{{{{Th}{i}}{{s }{i}}}{{{s }{a}}{{ s}{a}}}}{{{{mp}{l}}{{e }{s}}}{{{tr}{i}}{{ng}{.}}}}}
{{{{{{T}{h}}{i}}{{{s}{ }}{i}}}{{{{s}{ }}{a}}{{{ }{s}}{a}}}}{{{{{m}{p}}{l}}{{{e}{ }}{s}}}{{{{t}{r}}{i}}{{{n}{g}}{.}}}}}



--david_werecat

Options

exec is denied

now post-mortem time, all source codes will be revealed

Sample input:_

ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort. ASCII was developed a long time ago and now the non-printing characters are rarely used for their original purpose. Below is the ASCII character table and this includes descriptions of the first 32 non-printing characters. ASCII was actually designed for use with teletypes and so the descriptions are somewhat obscure. If someone says they want your CV however in ASCII format, all this means is they want 'plain' text with no formatting such as tabs, bold or underscoring - the raw format that any computer can understand. This is usually so they can easily import the file into their own applications without issues. Notepad.exe creates ASCII text, or in MS Word you can save a file as 'text only' 

Sample output:

{{{{{{{{{{{A}{S}}{{C}{I}}}{{{I}{ }}{{s}{t}}}}{{{{a}{n}}{{d}{s}}}{{{ }{f}}{o}}}}{{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}}{{.}{ }}}{{{N}{o}}{t}}}{{{{e}{p}}{{a}{d}}}{{{.}{e}}{x}}}}{{{{{e}{ }}{{c}{r}}}{{{e}{a}}{t}}}{{{{e}{s}}{{ }{A}}}{{{S}{C}}{I}}}}}}{{{{{{{I}{ }}{{t}{e}}}{{{x}{t}}{{,}{ }}}}{{{{o}{r}}{{ }{i}}}{{{n}{ }}{M}}}}{{{{{S}{ }}{{W}{o}}}{{{r}{d}}{ }}}{{{{y}{o}}{{u}{ }}}{{{c}{a}}{n}}}}}{{{{{{ }{s}}{{a}{v}}}{{{e}{ }}{a}}}{{{{ }{f}}{{i}{l}}}{{{e}{ }}{a}}}}{{{{{s}{ }}{{'}{t}}}{{{e}{x}}{t}}}{{{{ }{o}}{{n}{l}}}{{{y}{'}}{ }}}}}}}}}}

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1leonid680.02632012/08/16 04:41:170B / 27B / 40B
2david_werecat720.02332012/08/16 02:01:520B / 36B / 33B
3clock720.02032012/09/11 12:05:500B / 32B / 38B
4clock(leonid)670.02452012/09/12 02:12:400B / 28B / 38B

Perl _

RankUserSizeTimeDateStatistics
1tails620.02962012/09/05 22:09:070B / 16B / 44B
2ais523760.29952012/08/15 16:19:453B / ?B / ?B
3tanon880.82802012/09/11 16:04:490B / ?B / ?B
4tails (ush)600.01372012/09/12 21:45:540B / 19B / 39B
5BioFALSE1421.02852014/01/02 09:04:480B / 38B / 98B
6BioFALSE (cheat)46000.01052012/12/25 05:10:460B / 745B / 3700B

Python _

RankUserSizeTimeDateStatistics
1leonid840.03102012/09/11 06:48:120B / 43B / 36B
2twobit850.02112012/08/23 08:42:110B / 43B / 38B
3recursive850.01972012/09/11 01:10:190B / 42B / 38B
4hallvabo880.02702012/08/23 08:25:060B / 40B / 43B
5david_werecat920.01942012/08/15 23:03:490B / 48B / 39B
6cornchz920.04332012/09/02 17:54:360B / 48B / 38B

Scheme _

RankUserSizeTimeDateStatistics
1youz830.11172012/09/11 17:24:530B / 33B / 43B

Arc _

RankUserSizeTimeDateStatistics
1youz771.27292012/09/11 17:25:010B / 22B / 46B

Io _

RankUserSizeTimeDateStatistics
1pooq1150.12962012/09/06 22:13:550B / 68B / 40B

JavaScript _

RankUserSizeTimeDateStatistics
1youz830.01382012/09/11 14:53:440B / 42B / 38B
2nn(cheat)840.01422012/09/11 17:35:360B / 43B / 40B
3nn890.01492012/09/11 17:23:520B / 47B / 41B
4clock1050.02102012/09/11 12:35:270B / 62B / 41B
50mg1060.01402012/09/03 15:58:470B / 52B / 53B
6youz(nu)790.01962012/09/12 12:03:180B / 40B / 36B

Lua _

RankUserSizeTimeDateStatistics
1twobit1070.01302012/08/26 23:49:310B / 58B / 43B

BASIC _

RankUserSizeTimeDateStatistics
1pooq1160.01752012/09/06 22:45:150B / 57B / 51B

J _

RankUserSizeTimeDateStatistics
1I., S.550.04002012/08/16 19:54:540B / 13B / 42B
2I., S.(ad hoc)700.03862012/08/16 19:39:080B / 21B / 48B

Jelly _

RankUserSizeTimeDateStatistics
1Erik the Outgolfer140.24282021/04/15 01:16:429B / 3B / 2B

C _

RankUserSizeTimeDateStatistics
1ush(cheat)930.01462012/08/21 13:48:050B / 39B / 54B
2ush990.01582012/08/21 13:17:400B / 44B / 55B
3inaniwa1090.01082012/08/15 16:20:400B / 53B / 51B
4nn1120.01102012/09/11 21:17:280B / 48B / 63B
5david_werecat1150.01342012/08/15 03:33:060B / 62B / 52B
6tails (ush)830.01122012/09/12 21:16:150B / 37B / 46B
7nu(nn,youz)850.01142012/09/12 11:40:460B / 37B / 48B
8nn(youz)880.01082012/09/12 09:27:330B / 39B / 49B

Haskell _

RankUserSizeTimeDateStatistics
1henkma860.02002012/08/18 12:33:320B / 44B / 35B

Pascal _

RankUserSizeTimeDateStatistics
1uru1950.02872012/08/18 17:09:040B / 110B / 72B

C# _

RankUserSizeTimeDateStatistics
1Hendrik1870.04292012/09/08 16:03:260B / 116B / 63B
2George2k2390.04302012/08/22 07:20:270B / ?B / ?B

Maxima _

RankUserSizeTimeDateStatistics
1pooq1400.44222012/09/07 05:12:160B / 76B / 62B

AWK _

RankUserSizeTimeDateStatistics
1nn880.01172012/09/11 21:50:200B / 41B / 46B
2nn(youz)780.01132012/11/16 18:14:300B / 35B / 42B

sed _

RankUserSizeTimeDateStatistics
1tails700.84442012/09/08 20:57:420B / 9B / 55B
2nn831.12352012/08/27 00:46:440B / 11B / 64B

GolfScript _

RankUserSizeTimeDateStatistics
1tails230.28302012/08/16 00:36:320B / 4B / 19B

gs2 _

RankUserSizeTimeDateStatistics
1tails190.14832021/04/15 18:10:527B / 3B / 7B

Vim _

RankUserSizeTimeDateStatistics
1nn520.43872012/08/26 12:14:454B / 19B / 23B

goruby _

RankUserSizeTimeDateStatistics
1leonid580.04522012/09/11 08:52:390B / 20B / 36B
2david_werecat650.03022012/08/16 03:19:060B / 29B / 33B

Groovy _

RankUserSizeTimeDateStatistics
1nn831.31332012/09/11 20:08:460B / 42B / 38B
2nn(youz)741.12612012/09/13 00:04:170B / 37B / 33B

Language Ranking_

RankLangUserSizeScore
1JellyErik the Outgolfer1410000
2gs2tails197368
3GolfScripttails236086
4Vimnn522692
5JI., S.552545
6gorubyleonid582413
7Perltails (ush)602333
8Rubyclock(leonid)672089
9sedtails702000
10Groovynn(youz)741891
11Arcyouz771818
12AWKnn(youz)781794
13JavaScriptyouz(nu)791772
14Schemeyouz831686
15Ctails (ush)831686
16Pythonleonid841666
17Haskellhenkma861627
18Luatwobit1071308
19Iopooq1151217
20BASICpooq1161206
21Maximapooq1401000
22C#Hendrik187748
23Pascaluru195717

return to the top page