Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
12
Task/Comma-quibbling/Python/comma-quibbling-1.py
Normal file
12
Task/Comma-quibbling/Python/comma-quibbling-1.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
>>> def strcat(sequence):
|
||||
return '{%s}' % ', '.join(sequence)[::-1].replace(',', 'dna ', 1)[::-1]
|
||||
|
||||
>>> for seq in ([], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]):
|
||||
print('Input: %-24r -> Output: %r' % (seq, strcat(seq)))
|
||||
|
||||
|
||||
Input: [] -> Output: '{}'
|
||||
Input: ['ABC'] -> Output: '{ABC}'
|
||||
Input: ['ABC', 'DEF'] -> Output: '{ABC and DEF}'
|
||||
Input: ['ABC', 'DEF', 'G', 'H'] -> Output: '{ABC, DEF, G and H}'
|
||||
>>>
|
||||
5
Task/Comma-quibbling/Python/comma-quibbling-2.py
Normal file
5
Task/Comma-quibbling/Python/comma-quibbling-2.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def commaQuibble(s):
|
||||
return '{%s}' % ' and '.join(s).replace(' and ', ', ', len(s) - 2)
|
||||
|
||||
for seq in ([], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]):
|
||||
print('Input: %-24r -> Output: %r' % (seq, commaQuibble(seq)))
|
||||
15
Task/Comma-quibbling/Python/comma-quibbling-3.py
Normal file
15
Task/Comma-quibbling/Python/comma-quibbling-3.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
>>> def quibble(s):
|
||||
return ('{' +
|
||||
(', '.join(s[:-1]) + ' and ' if len(s) > 1 else '') +
|
||||
(s[-1] if s else '') +
|
||||
'}')
|
||||
|
||||
>>> for seq in ([], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]):
|
||||
print('Input: %-24r -> Output: %r' % (seq, quibble(seq)))
|
||||
|
||||
|
||||
Input: [] -> Output: '{}'
|
||||
Input: ['ABC'] -> Output: '{ABC}'
|
||||
Input: ['ABC', 'DEF'] -> Output: '{ABC and DEF}'
|
||||
Input: ['ABC', 'DEF', 'G', 'H'] -> Output: '{ABC, DEF, G and H}'
|
||||
>>>
|
||||
Loading…
Add table
Add a link
Reference in a new issue