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

 

zbaharav@kehillah.org 22-inpairs-warmup-logicandloops > oneTo1
prev  |  next  |  chance

Given an input String, return a new String where every occurrence of "1" is replaced by "one", and every occurrence of "one" is replaced by "1". Use ONLY String methods from the below as needed: length() ; substring(int from, int to) ; substring(int from) ; indexOf(String str) ; compareTo(String other)


oneTo1("1 and one") → "one and 1"
oneTo1("one1") → "1one"
oneTo1("one at a time, 1 and one, 1") → "1 at a time, one and 1, one"

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

public String oneTo1(String str) { }

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

Copyright Nick Parlante 2017 - privacy