id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

letterPattern


Given a String s, int a, and int b, Create a letter pattern by taking every ath character in s and repeating it b times unless it is a space, in which case you should ignore it. Examples:

lettterPattern("Aaron",1,1)
returns "Aaron", the same String because each character from the original string is repeated once.
lettterPattern("Aaron",1,2)
returns "AAaarroonn" because each character from the original string is repeated twice.
lettterPattern("Aaron",2,2)
returns "AArrnn" because every other character from the original string is repeated twice.

letterPattern("Aaron", 1, 1) → "Aaron"
letterPattern("Aaron", 1, 2) → "AAaarroonn"
letterPattern("Aaron", 2, 2) → "AArrnn"

...Save, Compile, Run (ctrl-enter)

String letterPattern(String s, int a, int b) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200 Post-solution available

Copyright Nick Parlante 2017 - privacy