Skip to content

gmotzespina/Tidy_Numbers-ELIXIR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TidyNumbers

Problem
Tatiana likes to keep things tidy. Her toys are sorted from smallest to largest, her pencils are sorted from shortest to longest and her computers from oldest to newest. One day, when practicing her counting skills, she noticed that some integers, when written in base 10 with no leading zeroes, have their digits sorted in non-decreasing order. Some examples of this are 8, 123, 555, and 224488. She decided to call these numbers tidy. Numbers that do not have this property, like 20, 321, 495 and 999990, are not tidy.
She just finished counting all positive integers in ascending order from 1 to N. What was the last tidy number she counted?
Input
The first line of the input gives the number of test cases, T. T lines follow. Each line describes a test case with a single integer N, the last number counted by Tatiana.
Output
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the last tidy number counted by Tatiana.
Limits
1 ≤ T ≤ 100. Small dataset
1 ≤ N ≤ 1000. Large dataset
1 ≤ N ≤ 1018.

Compile the project

mix compile

Run the project

iex -S mix

Execute

TN.st

About

Solution to tidy numbers in elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages