Skip to content
Merged
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
12 changes: 5 additions & 7 deletions exercises/practice/crypto-square/.meta/proof.ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ export class Crypto {
}

const splitRegex = new RegExp(`.{1,${chunkSize}}`, 'g')
return this.ciphertextSegments()
.join('')
.match(splitRegex)
.map((item) => item.padEnd(chunkSize, ' '))
.join(' ')
const segments = this.ciphertextSegments() ?? []
const chunks = segments.join('').match(splitRegex) ?? []
return chunks.map((item) => item.padEnd(chunkSize, ' ')).join(' ')
}

public get size(): number {
Expand All @@ -25,7 +23,7 @@ export class Crypto {
}

private ciphertextSegments(): string[] {
const textSegments = this.plaintextSegments()
const textSegments = this.plaintextSegments() ?? []
const columns: string[][] = []
let i: number
let j: number
Expand Down Expand Up @@ -53,7 +51,7 @@ export class Crypto {
return result
}

private plaintextSegments(): RegExpMatchArray {
private plaintextSegments(): RegExpMatchArray | null {
const plainText = this.plaintext
const chunkSize = this.size

Expand Down
Loading