10
Challenge
We take three positive integers a
, b
, and c
as input. Using these integers, first create a sequence in the range [0, c]
(inclusive on both ends), in steps of b
. For example, for a=4, b=2, c=100
, the sequence would be [0,2,4,...,96,98,100]
.
For every number in this sequence which is divisible by a
, replace it with the next letter in the lowercase alphabet, starting with the letter 'a' and wrapping back around to 'a' after you reach 'z'.
Example:
Input: a=4, b=2, c=100
Output: a2b6c10d14e18f22g26h30i34j38k42l46m50n54o58p62q66r70s74t78u82v86w90x94y98z
Challenge rules:
- You can assume that
a
,b
, andc
are positive integers only, whereb ≤ a ≤ c
. - You can assume
a
is a multiple ofb
. - You can assume
c
is divisible byb
. - The preferred output is a single concatenated string as above, but a list/array is acceptable as well.
Test cases:
Input: a=4, b=2, c=100
Output:
a2b6c10d14e18f22g26h30i34j38k42l46m50n54o58p62q66r70s74t78u82v86w90x94y98z
Input: a=9, b=3, c=174
Output:
a36b1215c2124d3033e3942f4851g5760h6669i7578j8487k9396l102105m111114n120123o129132p138141q147150r156159s165168t174
Input: a=10, b=2, c=50
Output:
a2468b12141618c22242628d32343638e42444648f
Input: a=25, b=1, c=25
Output:
a123456789101112131415161718192021222324b
Input: a=6, b=6, c=48
Output:
abcdefghi
Input: a=6, b=3, c=48
Output: a3b9c15d21e27f33g39h45i
Input: a=2, b=1, c=100
Output: a1b3c5d7e9f11g13h15i17j19k21l23m25n27o29p31q33r35s37t39u41v43w45x47y49z51a53b55c57d59e61f63g65h67i69j71k73l75m77n79o81p83q85r87s89t91u93v95w97x99y
I'd really like to see an answer in PHP, but this challenge is open to any language. This is codegolf, so the answer should be as short as possible. Standard rules apply for functions/programs and default loopholes are forbidden.
1
Also consider using The Sandbox to get advice and feedback on questions before posting it to main.
– Jo King – 2018-08-08T09:33:39.5933
Hi welcome to PPCG! Although I like the challenge itself, the description is lacking a lot of things. As mentioned by @JoKing A primary winning tag is mandatory, where
– Kevin Cruijssen – 2018-08-08T09:43:04.970[codegolf]
is the most common one I would recommend. Also mentioned by JoKing, making it language specific is not recommended. It's best to open it to all languages instead. As for the challenge itself, please specify a bit more and add a few more test cases. Based on the example I can see the range is[0,c]
, but this should be clear without looking at the example.1I think all you need to do is change the title to something more descriptive and this is good to go – Jo King – 2018-08-08T10:34:04.947
Is it necessary to output a string where all the numbers/letters are concatenated or can we also return a list? – wastl – 2018-08-08T10:50:56.867
I prefer concatenation of numbers and letters but a list is also ok – Mochesane – 2018-08-08T10:53:09.953
1I took the liberty of fixing your challenge so it can be re-opened. Next time please use the Sandbox as advised to perfect a challenge before posting it in the main. Please take a look at what I've edited so you know this for future challenges. If anything is incorrect or I misinterpret something, feel free to edit it again. – Kevin Cruijssen – 2018-08-08T12:04:41.550
1Wow thank you @KevinCruijssen , this is really it. Thank you very much and next time I will use the sandbox as advised – Mochesane – 2018-08-08T12:22:35.300
1@labmann You're welcome. Now all we have to do is wait for re-open votes (you've already got 3 and need 5), and then the answer (hopefully including a PHP one) will come in. PS: You're lucky I had the time to edit your challenge. ;) And that it's a good challenge to begin with, otherwise I wouldn't have bothered. Enjoy your stay, and I indeed hope to see you use the Sandbox to perfect challenges before posting them here next time. – Kevin Cruijssen – 2018-08-08T12:26:10.333
5It seems none of your test-cases wrap around from
'z'
to'a'
. Could you please include one that does? – O.O.Balance – 2018-08-08T13:17:34.197