Skip to content

Add transpose test cases #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 231 additions & 0 deletions transpose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
{
"#": [
"JSON doesn't allow for multi-line strings, so all multi-line input is ",
"presented here as arrays of strings. It's up to the test generator to join the ",
"lines together with line breaks."
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{"multi_line_string":"Multi\nLine\nString\n"}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it should be: JSON doesn't allow for elegant formatting of multi-line strings, so all multi-line input and output is...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a good wording. I copied the text from the existing JSON data from food-chain by the way.

"cases": [
{
"description": "empty string",
"input": "",
"expected": ""
},
{
"description": "two characters",
"input": "A1",
"expected": [
"A",
"1"
]
},
{
"description": "simple",
"input": [
"ABC",
"123"
],
"expected": [
"A1",
"B2",
"C3"
]
},
{
"description": "single line",
"input": "Single line.",
"expected": [
"S",
"i",
"n",
"g",
"l",
"e",
" ",
"l",
"i",
"n",
"e",
"."
]
},
{
"description": "first line longer than second line",
"input": [
"The fourth line.",
"The fifth line."
],
"expected": [
"TT",
"hh",
"ee",
" ",
"ff",
"oi",
"uf",
"rt",
"th",
"h ",
" l",
"li",
"in",
"ne",
"e.",
"."
]
},
{
"description": "second line longer than first line",
"input": [
"The first line.",
"The second line."
],
"expected": [
"TT",
"hh",
"ee",
" ",
"fs",
"ie",
"rc",
"so",
"tn",
" d",
"l ",
"il",
"ni",
"en",
".e",
" ."
]
},
{
"description": "square",
"input": [
"HEART",
"EMBER",
"ABUSE",
"RESIN",
"TREND"
],
"expected": [
"HEART",
"EMBER",
"ABUSE",
"RESIN",
"TREND"
]
},
{
"description": "rectangle",
"input": [
"FRACTURE",
"OUTLINED",
"BLOOMING",
"SEPTETTE"
],
"expected": [
"FOBS",
"RULE",
"ATOP",
"CLOT",
"TIME",
"UNIT",
"RENT",
"EDGE"
]
},
{
"description": "triangle",
"input": [
"T",
"EE",
"AAA",
"SSSS",
"EEEEE",
"RRRRRR"
],
"expected": [
"TEASER",
" EASER",
" ASER",
" SER",
" ER",
" R"
]
},
{
"description": "many lines",
"input": [
"Chor. Two households, both alike in dignity,",
"In fair Verona, where we lay our scene,",
"From ancient grudge break to new mutiny,",
"Where civil blood makes civil hands unclean.",
"From forth the fatal loins of these two foes",
"A pair of star-cross'd lovers take their life;",
"Whose misadventur'd piteous overthrows",
"Doth with their death bury their parents' strife.",
"The fearful passage of their death-mark'd love,",
"And the continuance of their parents' rage,",
"Which, but their children's end, naught could remove,",
"Is now the two hours' traffic of our stage;",
"The which if you with patient ears attend,",
"What here shall miss, our toil shall strive to mend."
],
"expected": [
"CIFWFAWDTAWITW",
"hnrhr hohnhshh",
"o oeopotedi ea",
"rfmrmash cn t",
".a e ie fthow ",
" ia fr weh,whh",
"Trnco miae ie",
"w ciroitr btcr",
"oVivtfshfcuhhe",
" eeih a uote ",
"hrnl sdtln is",
"oot ttvh tttfh",
"un bhaeepihw a",
"saglernianeoyl",
"e,ro -trsui ol",
"h uofcu sarhu ",
"owddarrdan o m",
"lhg to'egccuwi",
"deemasdaeehris",
"sr als t ists",
",ebk 'phool'h,",
" reldi ffd ",
"bweso tb rtpo",
"oea ileutterau",
"t kcnoorhhnatr",
"hl isvuyee'fi ",
" atv es iisfet",
"ayoior trr ino",
"l lfsoh ecti",
"ion vedpn l",
"kuehtteieadoe ",
"erwaharrar,fas",
" nekt te rh",
"ismdsehphnnosa",
"ncuse ra-tau l",
" et tormsural",
"dniuthwea'g t ",
"iennwesnr hsts",
"g,ycoi tkrttet",
"n ,l r s'a anr",
"i ef 'dgcgdi",
"t aol eoe,v",
"y nei sl,u; e",
", .sf to l ",
" e rv d t",
" ; ie o",
" f, r ",
" e e m",
" . m e",
" o n",
" v d",
" e .",
" , "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I missed a small thing - no spaces after the comma, right?

(I also haven't checked with code, so I may have missed others, but I least see this)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll send the PR. This was the only thing.

]
}
]
}
39 changes: 39 additions & 0 deletions transpose.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,42 @@ CF
```

Rows become columns and columns become rows. See <https://en.wikipedia.org/wiki/Transpose>.

If the input has rows of different lengths, this is to be solved as follows:

- Pad to the left with spaces.
- Don't pad to the right.

Therefore, transposing this matrix:

```
ABC
DE
```

results in:

```
AD
BE
C
```

And transposing:

```
AB
DEF
```

results in:

```
AD
BE
F
```

In general, all characters from the input should also be present in the transposed output.
That means that if a column in the input text contains only spaces on its bottom-most row(s),
the corresponding output row should contain the spaces in its right-most column(s).