7 kyu
Parts of a list
589 of 17,739g964
Description:
Write a function partlist
that gives all the ways to divide a list (an array) of at least two elements into two non-empty parts.
- Each two non empty parts will be in a pair (or an array for languages without tuples or a
struct
in C - C: see Examples test Cases - ) - Each part will be in a string
- Elements of a pair must be in the same order as in the original array.
Examples of returns in different languages:
a = ["az", "toto", "picaro", "zone", "kiwi"] -->
[["az", "toto picaro zone kiwi"], ["az toto", "picaro zone kiwi"], ["az toto picaro", "zone kiwi"], ["az toto picaro zone", "kiwi"]]
or
a = {"az", "toto", "picaro", "zone", "kiwi"} -->
{{"az", "toto picaro zone kiwi"}, {"az toto", "picaro zone kiwi"}, {"az toto picaro", "zone kiwi"}, {"az toto picaro zone", "kiwi"}}
or
a = ["az", "toto", "picaro", "zone", "kiwi"] -->
[("az", "toto picaro zone kiwi"), ("az toto", "picaro zone kiwi"), ("az toto picaro", "zone kiwi"), ("az toto picaro zone", "kiwi")]
or
a = [|"az", "toto", "picaro", "zone", "kiwi"|] -->
[("az", "toto picaro zone kiwi"), ("az toto", "picaro zone kiwi"), ("az toto picaro", "zone kiwi"), ("az toto picaro zone", "kiwi")]
or
a = ["az", "toto", "picaro", "zone", "kiwi"] -->
"(az, toto picaro zone kiwi)(az toto, picaro zone kiwi)(az toto picaro, zone kiwi)(az toto picaro zone, kiwi)"
Note
You can see other examples for each language in "Your test cases"
Arrays
Lists
Data Structures
Algorithms
Similar Kata:
Stats:
Created | Mar 24, 2016 |
Published | Mar 24, 2016 |
Warriors Trained | 49501 |
Total Skips | 9888 |
Total Code Submissions | 57786 |
Total Times Completed | 17739 |
Ruby Completions | 589 |
Python Completions | 4501 |
JavaScript Completions | 5465 |
CoffeeScript Completions | 23 |
Haskell Completions | 290 |
Clojure Completions | 165 |
Java Completions | 1319 |
C# Completions | 553 |
Elixir Completions | 250 |
TypeScript Completions | 486 |
C++ Completions | 960 |
PHP Completions | 823 |
Crystal Completions | 19 |
F# Completions | 94 |
C Completions | 196 |
OCaml Completions | 47 |
Shell Completions | 123 |
Kotlin Completions | 485 |
Julia Completions | 40 |
PowerShell Completions | 78 |
Go Completions | 751 |
Nim Completions | 20 |
Rust Completions | 496 |
Reason Completions | 12 |
Racket Completions | 31 |
Scala Completions | 131 |
VB Completions | 44 |
Dart Completions | 445 |
Perl Completions | 21 |
D Completions | 10 |
Erlang Completions | 17 |
Prolog Completions | 11 |
Total Stars | 506 |
% of votes with a positive feedback rating | 90% of 2193 |
Total "Very Satisfied" Votes | 1787 |
Total "Somewhat Satisfied" Votes | 358 |
Total "Not Satisfied" Votes | 48 |