tritri fixed description

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

A well formatted description can
be found here: http://fmnssun.ibone.ch/tritri/

Description

Production rules
a -> bc
b -> dd
c -> da
d -> ac

What to do
Construct a (ternary) tree by applying the
production rules. The initial node is given as
input. Print out every possible path in the tree.
A path consists of five characters. Construct the
tree to the appropriate depth.

Construction rules
For each node H (with value h) with its relative position p
to its parent node Hp create a new child node Hc
at position p with value h. Fill up the remaining child nodes (so that |╬Śc|=3) with
data taken from the production rules in order left to right.

Positions

l := left
m := middle
r := right

l
/|\
l m r

Example
Initial node: a
Required depth: 3
Output path length: 2
1.) Use production rule a -> bc
a
/|\
a b c
*
2.) Visit child nodes
3.) For a use production rule a -> bc
a
/ | \
a b c
/|\ /|\ /|\
a b c
*
4.) For b use production rule b -> dd
a
/ | \
a b c
/|\ /|\ /|\
a b c d b d
*
5.) For c use production rule c -> da
a
/ | \
a b c
/|\ /|\ /|\
a b c d b d d a c
*
6.) Find a/next path
a.
/ | \
a. b c
/|\ /|\ /|\
a.b c d b d d a c
7.) Concatenate the data
aaa
8.) Drop the root
aa
9.) Print it
10.) Go back to 6 until done.

Output should be
aa
ab
ac
bd
bb
bd
cd
ca
cc

-- mroman

Options

exec is denied

no deadline, the server will not save your submission

Sample input:_

a

Sample output:

aaaaa
aaaab
aaaac
aaabd
aaabb
aaabd
aaacd
aaaca
aaacc
aabdd
aabda
aabdc
aabbd
aabbb
aabbd
aabda
aabdc
aabdd
aacdd
aacda
aacdc
aacab
aacaa
aacac
aaccd
aacca
aaccc
abddd
abdda
abddc
abdab
abdaa
abdac
abdcd
abdca
abdcc
abbdd
abbda
abbdc
abbbd
abbbb
abbbd
abbda
abbdc
abbdd
abdaa
abdab
abdac
abdcd
abdcc
abdca
abdda
abddc
abddd
acddd
acdda
acddc
acdab
acdaa
acdac
acdcd
acdca
acdcc
acabb
acabd
acabd
acaab
acaaa
acaac
acacd
acaca
acacc
accdd
accda
accdc
accab
accaa
accac
acccd
accca
acccc
bdddd
bddda
bdddc
bddab
bddaa
bddac
bddcd
bddca
bddcc
bdabb
bdabd
bdabd
bdaab
bdaaa
bdaac
bdacd
bdaca
bdacc
bdcdd
bdcda
bdcdc
bdcab
bdcaa
bdcac
bdccd
bdcca
bdccc
bbddd
bbdda
bbddc
bbdab
bbdaa
bbdac
bbdcd
bbdca
bbdcc
bbbdd
bbbda
bbbdc
bbbbd
bbbbb
bbbbd
bbbda
bbbdc
bbbdd
bbdaa
bbdab
bbdac
bbdcd
bbdcc
bbdca
bbdda
bbddc
bbddd
bdaaa
bdaab
bdaac
bdabd
bdabb
bdabd
bdacd
bdaca
bdacc
bdcdd
bdcda
bdcdc
bdccd
bdccc
bdcca
bdcab
bdcac
bdcaa
bddaa
bddab
bddac
bddcd
bddcc
bddca
bddda
bdddc
bdddd
cdddd
cddda
cdddc
cddab
cddaa
cddac
cddcd
cddca
cddcc
cdabb
cdabd
cdabd
cdaab
cdaaa
cdaac
cdacd
cdaca
cdacc
cdcdd
cdcda
cdcdc
cdcab
cdcaa
cdcac
cdccd
cdcca
cdccc
cabbb
cabbd
cabbd
cabda
cabdd
cabdc
cabda
cabdc
cabdd
caabb
caabd
caabd
caaab
caaaa
caaac
caacd
caaca
caacc
cacdd
cacda
cacdc
cacab
cacaa
cacac
caccd
cacca
caccc
ccddd
ccdda
ccddc
ccdab
ccdaa
ccdac
ccdcd
ccdca
ccdcc
ccabb
ccabd
ccabd
ccaab
ccaaa
ccaac
ccacd
ccaca
ccacc
cccdd
cccda
cccdc
cccab
cccaa
cccac
ccccd
cccca
ccccc

Sample input:_

b

Sample output:

bbbbb
bbbbd
bbbbd
bbbda
bbbdd
bbbdc
bbbda
bbbdc
bbbdd
bbdaa
bbdab
bbdac
bbdda
bbddd
bbddc
bbdcd
bbdca
bbdcc
bbdaa
bbdab
bbdac
bbdcd
bbdcc
bbdca
bbdda
bbddc
bbddd
bdaaa
bdaab
bdaac
bdabd
bdabb
bdabd
bdacd
bdaca
bdacc
bddaa
bddab
bddac
bddda
bdddd
bdddc
bddcd
bddca
bddcc
bdcdd
bdcda
bdcdc
bdcab
bdcaa
bdcac
bdccd
bdcca
bdccc
bdaaa
bdaab
bdaac
bdabd
bdabb
bdabd
bdacd
bdaca
bdacc
bdcdd
bdcda
bdcdc
bdccd
bdccc
bdcca
bdcab
bdcac
bdcaa
bddaa
bddab
bddac
bddcd
bddcc
bddca
bddda
bdddc
bdddd
daaaa
daaab
daaac
daabd
daabb
daabd
daacd
daaca
daacc
dabdd
dabda
dabdc
dabbd
dabbb
dabbd
dabda
dabdc
dabdd
dacdd
dacda
dacdc
dacab
dacaa
dacac
daccd
dacca
daccc
ddaaa
ddaab
ddaac
ddabd
ddabb
ddabd
ddacd
ddaca
ddacc
dddaa
dddab
dddac
dddda
ddddd
ddddc
dddcd
dddca
dddcc
ddcdd
ddcda
ddcdc
ddcab
ddcaa
ddcac
ddccd
ddcca
ddccc
dcddd
dcdda
dcddc
dcdab
dcdaa
dcdac
dcdcd
dcdca
dcdcc
dcabb
dcabd
dcabd
dcaab
dcaaa
dcaac
dcacd
dcaca
dcacc
dccdd
dccda
dccdc
dccab
dccaa
dccac
dcccd
dccca
dcccc
daaaa
daaab
daaac
daabd
daabb
daabd
daacd
daaca
daacc
dabdd
dabda
dabdc
dabbd
dabbb
dabbd
dabda
dabdc
dabdd
dacdd
dacda
dacdc
dacab
dacaa
dacac
daccd
dacca
daccc
dcddd
dcdda
dcddc
dcdab
dcdaa
dcdac
dcdcd
dcdca
dcdcc
dccdd
dccda
dccdc
dcccd
dcccc
dccca
dccab
dccac
dccaa
dcabb
dcabd
dcabd
dcacd
dcacc
dcaca
dcaab
dcaac
dcaaa
ddaaa
ddaab
ddaac
ddabd
ddabb
ddabd
ddacd
ddaca
ddacc
ddcdd
ddcda
ddcdc
ddccd
ddccc
ddcca
ddcab
ddcac
ddcaa
dddaa
dddab
dddac
dddcd
dddcc
dddca
dddda
ddddc
ddddd

Sample input:_

c

Sample output:

ccccc
ccccd
cccca
cccda
cccdd
cccdc
cccab
cccac
cccaa
ccdaa
ccdab
ccdac
ccdda
ccddd
ccddc
ccdcd
ccdca
ccdcc
ccabb
ccabd
ccabd
ccacd
ccacc
ccaca
ccaab
ccaac
ccaaa
cdaaa
cdaab
cdaac
cdabd
cdabb
cdabd
cdacd
cdaca
cdacc
cddaa
cddab
cddac
cddda
cdddd
cdddc
cddcd
cddca
cddcc
cdcdd
cdcda
cdcdc
cdcab
cdcaa
cdcac
cdccd
cdcca
cdccc
cabbb
cabbd
cabbd
cabda
cabdd
cabdc
cabda
cabdc
cabdd
cacdd
cacda
cacdc
caccd
caccc
cacca
cacab
cacac
cacaa
caabb
caabd
caabd
caacd
caacc
caaca
caaab
caaac
caaaa
daaaa
daaab
daaac
daabd
daabb
daabd
daacd
daaca
daacc
dabdd
dabda
dabdc
dabbd
dabbb
dabbd
dabda
dabdc
dabdd
dacdd
dacda
dacdc
dacab
dacaa
dacac
daccd
dacca
daccc
ddaaa
ddaab
ddaac
ddabd
ddabb
ddabd
ddacd
ddaca
ddacc
dddaa
dddab
dddac
dddda
ddddd
ddddc
dddcd
dddca
dddcc
ddcdd
ddcda
ddcdc
ddcab
ddcaa
ddcac
ddccd
ddcca
ddccc
dcddd
dcdda
dcddc
dcdab
dcdaa
dcdac
dcdcd
dcdca
dcdcc
dcabb
dcabd
dcabd
dcaab
dcaaa
dcaac
dcacd
dcaca
dcacc
dccdd
dccda
dccdc
dccab
dccaa
dccac
dcccd
dccca
dcccc
abbbb
abbbd
abbbd
abbda
abbdd
abbdc
abbda
abbdc
abbdd
abdaa
abdab
abdac
abdda
abddd
abddc
abdcd
abdca
abdcc
abdaa
abdab
abdac
abdcd
abdcc
abdca
abdda
abddc
abddd
acddd
acdda
acddc
acdab
acdaa
acdac
acdcd
acdca
acdcc
accdd
accda
accdc
acccd
acccc
accca
accab
accac
accaa
acabb
acabd
acabd
acacd
acacc
acaca
acaab
acaac
acaaa
aabbb
aabbd
aabbd
aabda
aabdd
aabdc
aabda
aabdc
aabdd
aacdd
aacda
aacdc
aaccd
aaccc
aacca
aacab
aacac
aacaa
aaabb
aaabd
aaabd
aaacd
aaacc
aaaca
aaaab
aaaac
aaaaa

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1mitchs970.05692015/11/09 17:27:031B / 47B / 44B
2leonid1030.05552012/06/07 07:46:230B / 54B / 43B

Ruby2 _

RankUserSizeTimeDateStatistics
1mitchs970.17902016/05/15 23:10:460B / 43B / 52B

Perl _

RankUserSizeTimeDateStatistics
1tails1050.07522016/05/15 23:30:200B / 48B / 57B
2nfouille1770.05092012/06/07 23:13:420B / ?B / ?B

Python _

RankUserSizeTimeDateStatistics
1mitchs1170.19682016/05/15 10:20:330B / 57B / 57B
2twobit1260.10432012/06/30 19:14:230B / 63B / 55B
3hallvabo1290.08452012/07/01 08:15:480B / 65B / 53B
4rolf1440.22932013/10/01 04:23:430B / 77B / 58B
5mroman (reference implementation)2660.12172012/06/30 01:00:580B / 131B / 112B

Python3 _

RankUserSizeTimeDateStatistics
1mitchs1180.25082016/05/16 00:30:240B / 57B / 59B

JavaScript _

RankUserSizeTimeDateStatistics
1nn1180.08692012/06/20 10:43:000B / 62B / 55B

J _

RankUserSizeTimeDateStatistics
1I., S.860.09132012/06/09 06:10:470B / 37B / 44B
2I., S.(sorry for misposting to tritri)900.10462012/06/09 06:04:540B / 38B / 47B

C _

RankUserSizeTimeDateStatistics
1nu1110.04072012/06/26 01:29:430B / 57B / 54B
2nn1140.03322012/06/24 00:04:270B / 57B / 56B
3ush1230.03552012/06/18 11:46:460B / 64B / 58B

sed _

RankUserSizeTimeDateStatistics
1tails1610.12072016/05/16 12:41:140B / 73B / 83B

Brainfuck _

RankUserSizeTimeDateStatistics
1mitchs3390.05762016/05/30 12:54:110B / 0B / 339B

Groovy _

RankUserSizeTimeDateStatistics
1nn1284.50742012/06/20 11:15:050B / 68B / 59B

Language Ranking_

RankLangUserSizeScore
1JI., S.8610000
2Rubymitchs978865
3Ruby2mitchs978865
4Perltails1058190
5Cnu1117747
6Pythonmitchs1177350
7JavaScriptnn1187288
8Python3mitchs1187288
9Groovynn1286718
10sedtails1615341
11Brainfuckmitchs3392536

return top