How to resolve the algorithm Comma quibbling step by step in the VBA programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Comma quibbling step by step in the VBA programming language
Table of Contents
Problem Statement
Comma quibbling is a task originally set by Eric Lippert in his blog.
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
Test your function with the following series of inputs showing your output here on this page:
Note: Assume words are non-empty strings of uppercase characters for this task.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Comma quibbling step by step in the VBA programming language
Source code in the vba programming language
Option Explicit
Sub Main()
Debug.Print Quibbling("")
Debug.Print Quibbling("ABC")
Debug.Print Quibbling("ABC, DEF")
Debug.Print Quibbling("ABC, DEF, G, H")
Debug.Print Quibbling("ABC, DEF, G, H, IJKLM, NO, PQRSTUV")
End Sub
Private Function Quibbling(MyString As String) As String
Dim s As String, n As Integer
s = "{" & MyString & "}": n = InStrRev(s, ",")
If n > 0 Then s = Left(s, n - 1) & " and " & Right(s, Len(s) - (n + 1))
Quibbling = s
End Function
You may also check:How to resolve the algorithm Multifactorial step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Plasma effect step by step in the Raku programming language
You may also check:How to resolve the algorithm Yellowstone sequence step by step in the Wren programming language
You may also check:How to resolve the algorithm Day of the week step by step in the TypeScript programming language
You may also check:How to resolve the algorithm Shell one-liner step by step in the Perl programming language