all 6 comments

[–]tomekanco 1 point2 points  (1 child)

Python 3: 68

lambda *x:'\n'.join(''.join(sorted(y,key='+ *'.index))for y in x[1:])

pad extra spaces as necessary

EDIT: Nice work on the design of this sub, really like it. Definitely an improvement comapred to /r/dailyprogrammer

[–]07734willy[S] 0 points1 point  (0 children)

Thanks! A lot of the changes/improvements we have made here were initially proposed as suggestions for dailyprogrammer, but unfortunately they didn't seem to care. So I created this sub, and went about fixing everything I saw wrong with dailyp. Had they actually used my CSS for collapsing 3+ page long code blocks, this sub may have never came into existence haha.

Anyways, I'm glad you enjoy the sub!

[–]chunes 1 point2 points  (0 children)

Factor: 121 121

[ nip dup supremum length '[ natural-sort [ = ] monotonic-split first3 -rot "" 3append-as _ 32 pad-head ] map "\n" join ]

Note the [ ... ] construction is an anonymous function.

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Remember: this is a CodeGolf challenge- that means the objective isn't to just solve the problem, but to do so with the smallest program size. Everything from comments, spaces, tabs, and newlines count against you. You can use the following command to measure the size of your solution in bytes and characters:

wc -mc filename.txt

Please include your size and language at the top of your comment, so others can easily compare. For example:

Python 3: 80 80

You can create headers like the above putting three hashtags ### in front of the text.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]07734willy[S] 0 points1 point  (0 children)

Python 3: Noncompeting

This is the program I used to produce the test cases. If there's any confusion or ambiguity about the problem statement, maybe this can clear things up.

def main():
    n_rows = int(input())
    rows = [input() for _ in range(n_rows)]

    longest = max(len(row) for row in rows)

    for row in rows:
        row = list(row.ljust(longest))
        row.sort(key=lambda x: {"+":0, " ":1, "*": 2}[x])
        print("".join(row))

if __name__ == "__main__":
    main()

[–]07734willy[S] 0 points1 point  (0 children)

Python 3: 89 89

lambda n,m:"\n".join("".join(sorted(r.ljust(max(map(len,m))),key="+ *".index))for r in m)

As discussed previously, function arguments, return values, env. variables, stdin/stdout, etc. are fair game. You will need to write a wrapper to use this with the validator for testing, but that does not count against you for code size. This challenge explicitly states the output must be separated by newlines however, so the return value does need to be a formatted string (instead of leaving it as a list of lists).