UVA 11687 – Digits

This question is terribly worded I think. Basically it wants you to find the length of the input string and let this length become the new string. Keep following this process until the length of the string and string are the same.

import java.io.PrintWriter;
import java.util.Scanner;

 * @author Sanchit M. Bhatnagar
 * @see http://uhunt.felix-halim.net/id/74004
public class P11687 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    while (sc.hasNext()) {
      String input = sc.next();
      if (input.equals("END"))


  private static int solve(String input) {
    int count = 1;
    int len = input.length();
    if ((len + "").equals(input))
      return count;
      return count + solve(len + "");

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.