4 kyu
Range Extraction
18,970 of 60,938jhoffner
Description:
A format for expressing an ordered list of integers is to use a comma separated list of either
- individual integers
- or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. The range includes all integers in the interval including both endpoints. It is not considered a range unless it spans at least 3 numbers. For example "12,13,15-17"
Complete the solution so that it takes a list of integers in increasing order and returns a correctly formatted string in the range format.
Example:
solution([-10, -9, -8, -6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20]);
// returns "-10--8,-6,-3-1,3-5,7-11,14,15,17-20"
Courtesy of rosettacode.org
Algorithms
Similar Kata:
Stats:
Created | Jun 14, 2013 |
Published | Jun 14, 2013 |
Warriors Trained | 132469 |
Total Skips | 21832 |
Total Code Submissions | 306017 |
Total Times Completed | 60938 |
JavaScript Completions | 18970 |
CoffeeScript Completions | 121 |
Ruby Completions | 1984 |
Go Completions | 1500 |
Python Completions | 22126 |
Java Completions | 5719 |
Haskell Completions | 666 |
C# Completions | 3940 |
C++ Completions | 3381 |
Julia Completions | 67 |
Kotlin Completions | 535 |
Rust Completions | 1185 |
Scala Completions | 280 |
Racket Completions | 35 |
C Completions | 1000 |
NASM Completions | 12 |
Nim Completions | 21 |
PHP Completions | 685 |
COBOL Completions | 15 |
VB Completions | 17 |
Total Stars | 3086 |
% of votes with a positive feedback rating | 91% of 5719 |
Total "Very Satisfied" Votes | 4764 |
Total "Somewhat Satisfied" Votes | 855 |
Total "Not Satisfied" Votes | 100 |