Skip to content

Commit 6d18367

Browse files
authored
Merge pull request #354 from bencoman/324-AtbashCipher--splitInGroupsOfFive
324-AtbashCipher--splitInGroupsOfFive
2 parents e913aca + 75c1ebc commit 6d18367

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

dev/src/Exercise@AtbashCipher/AtbashCipher.class.st

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ AtbashCipher >> sanitizeString: aString [
3636
]
3737

3838
{ #category : #splitjoin }
39-
AtbashCipher >> splitInGroupsOfFive: aString [
40-
aString size < 6
41-
ifTrue: [ ^ aString ].
42-
^ String streamContents: [ :stream |
43-
aString doWithIndex: [ :each :i |
44-
(i > 1 and: [ i - 1 isDivisibleBy: 5 ])
45-
ifTrue: [ stream << Character space ].
46-
stream << each ] ]
39+
AtbashCipher >> splitInGroupsOfFive: stringToSplit [
40+
|input|
41+
input := ReadStream on: stringToSplit.
42+
^ String streamContents: [ :output |
43+
output << (input next: 5).
44+
[ input atEnd ] whileFalse: [ output space << (input next: 5) ]
45+
].
46+
4747
]
4848

4949
{ #category : #encoding }

0 commit comments

Comments
 (0)