4 kyu

How many numbers III?

2,205 of 4,440raulbc777

Description:

We want to generate all the numbers of three digits where:

  • the sum of their digits is equal to 10
  • their digits are in increasing order (the numbers may have two or more equal contiguous digits)

The numbers that fulfill these constraints are: [118, 127, 136, 145, 226, 235, 244, 334]. There are 8 numbers in total with 118 being the lowest and 334 being the greatest.


Task

Implement a function which receives two arguments:

  1. the sum of digits (sum)
  2. the number of digits (count)

This function should return three values:

  1. the total number of values which have count digits that add up to sum and are in increasing order
  2. the lowest such value
  3. the greatest such value

Note: if there are no values which satisfy these constaints, you should return an empty value (refer to the examples to see what exactly is expected).

Examples

find_all(10, 3)  =>  [8, 118, 334]
find_all(27, 3)  =>  [1, 999, 999]
find_all(84, 4)  =>  []
find_all(10, 3)  =>  [8, 118, 334]
find_all(27, 3)  =>  [1, 999, 999]
find_all(84, 4)  =>  []
find_all(10, 3)  =>  [8, 118, 334]
find_all(27, 3)  =>  [1, 999, 999]
find_all(84, 4)  =>  []
findAll(10, 3)  =>  [8, "118", "334"]
findAll(27, 3)  =>  [1, "999", "999"]
findAll(84, 4)  =>  []
findAll 10 3  =>  ( 8, Just 118, Just 334 )
findAll 27 3  =>  ( 1, Just 999, Just 999 )
findAll 84 4  =>  ( 0, Nothing, Nothing )
// The output type is List<Long>
HowManyNumbers.findAll(10, 3)  =>  [8, 118, 334]
HowManyNumbers.findAll(27, 3)  =>  [1, 999, 999]
HowManyNumbers.findAll(84, 4)  =>  []
// The output type is List<long>
HowManyNumbers.FindAll(10, 3)  =>  [8, 118, 334]
HowManyNumbers.FindAll(27, 3)  =>  [1, 999, 999]
HowManyNumbers.FindAll(84, 4)  =>  []
// The output type is optional<tuple<uint32_t, uint64_t, uint64_t>>
find_all(10, 3)  =>  (8, 118, 334)
find_all(27, 3)  =>  (1, 999, 999)
find_all(84, 4)  =>  nullopt
// (Long, Long) => Option[(Long, Long, Long)]
findAll(10, 3)  =>  Some(8L, 118L, 334L)
findAll(27, 3)  =>  Some(1L, 999L, 999L)
findAll(84, 4)  =>  None
find_all 10 3  =>  Some (8, 188, 334)
find_all 27 3  =>  Some (1, 999, 999)
find_all 84 4  =>  None

Features of the random tests:

  • Number of tests: 112
  • Sum of digits value between 20 and 65
  • Amount of digits between 2 and 17
Fundamentals
Data Structures
Algorithms
Mathematics
Logic

Stats:

CreatedJan 12, 2017
PublishedJan 12, 2017
Warriors Trained25518
Total Skips7852
Total Code Submissions31360
Total Times Completed4440
Python Completions2205
Ruby Completions197
JavaScript Completions940
Java Completions612
C# Completions245
Crystal Completions8
Haskell Completions83
Rust Completions71
Go Completions62
D Completions2
Julia Completions8
C++ Completions131
Swift Completions10
Scala Completions6
OCaml Completions3
Total Stars969
% of votes with a positive feedback rating92% of 658
Total "Very Satisfied" Votes571
Total "Somewhat Satisfied" Votes75
Total "Not Satisfied" Votes12
Total Rank Assessments8
Average Assessed Rank
4 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • raulbc777 Avatar
  • natan Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • Firefly2002 Avatar
  • Voile Avatar
  • KataSideKick Avatar
  • eb110 Avatar
  • FArekkusu Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • user8436785 Avatar
  • eurydice5717 Avatar
  • akar-0 Avatar
  • depial Avatar
  • KayleighWasTaken Avatar
  • brodiemark Avatar
  • saudiGuy Avatar
Ad