challenges

Some problem solving programming challenges, i have solved. Not all are here, but started adding them slowly.

This project is maintained by chankruze

Splitting Strings

You are given a word and want to split it into even parts based on a number that is provided, each half being the size of the number.

Task

Write a program that takes in a string, and a number as input. Split the string into even parts sized by the number, and output the parts separated by hyphens. The last part of the output will be any leftover, as the input string might not split into the provided parts evenly.

Input Format

Two inputs: a string and an integer.

Output Format

A string, representing the hyphen-separated parts.

Sample Input

hello
2

Sample Output

he-ll-o

Explanation

We split the word “hello” into 2-sized parts. The last letter o was leftover, resulting in the output he-ll-o.

Solutions

Language Solution
C not available
CPP not available
C# not available
Python available
Java not available
Ruby not available
Swift not available