[Question]
  [
# Challenge
Given a string and a number, divide the string into *that many* equal-sized parts. For example, if the number is 3, you should divide the string into 3 pieces no matter how long the string is.
If the length of the string does not divide evenly into the number provided, you should round down the size of each piece and return a "remainder" string. For example, if the length of the input string is 13, and the number is 4, you should return four strings each of size 3, plus a remainder string of size 1.
If there is no remainder, you may simply not return one, or return the empty string.
The provided number is guaranteed to be less than or equal to the length of the string. For example, the input `"PPCG", 7` will not occur because `"PPCG"` cannot be divided into 7 strings. (I suppose the proper result would be `(["", "", "", "", "", "", ""], "PPCG")`. It's easier to simply disallow this as input.)
As usual, I/O is flexible. You may return a pair of the strings and the remainder string, or one list of strings with the remainder at the end.
# Test cases
```
"Hello, world!", 4 -> (["Hel", "lo,", " wo", "rld"], "!") ("!" is the remainder)
"Hello, world!", 5 -> (["He", "ll", "o,", " w", "or"], "ld!")
"ABCDEFGH", 2 -> (["ABCD", "EFGH"], "") (no remainder; optional "")
"123456789", 5 -> (["1", "2", "3", "4", "5"], "6789")
"ALABAMA", 3 -> (["AL", "AB", "AM"], "A")
"1234567", 4 -> (["1", "2", "3", "4"], "567")
```
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in each language wins.
Bonus points (not really üòõ) for making your solution actually use your language's division operator.
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~63~~ 59 bytes
```
s,n=input()
b=len(s)/n
exec'print s[:b];s=s[b:];'*n
print s
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v1gnzzYzr6C0REOTK8k2JzVPo1hTP48rtSI1Wb2gKDOvRKE42iop1rrYtjg6ySrWWl0rjwsq/v@/uqGRsYmpmbmFpbqOgikA "Python 2 ‚Äì Try It Online")
[Answer]
# PHP>=7.1, 75 bytes
```
[,$s,$d]=$argv;print_r(preg_split('/.{'.(strlen($s)/$d^0).'}\K/',$s,$d+1));
```
[Testcases](http://sandbox.onlinephpfunctions.com/code/73efe68d002d61949b9d550f86ba52887009babc)
# PHP>=7.1, 52 bytes
print only the remainder
```
[,$s,$d]=$argv;echo substr($s,(strlen($s)/$d^0)*$d);
```
[Test Cases](http://sandbox.onlinephpfunctions.com/code/1c139a47686ded9bc3dff5ae27c90ec3dfe5045e)
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 21 bytes
20 bytes of code, +1 for `-n` flag.
```
a~C(#a//b*XX)XbP$$$'
```
Takes inputs as command-line arguments; outputs strings and remainder newline-separated. [Try it online!](https://tio.run/##K8gs@P8/sc5ZQzlRXz9JKyJCMyIpQEVFRf3///@6Bf8NjYxNTM3MLSz/mwIA "Pip ‚Äì Try It Online")
### Explanation
Fun with regex operations!
Let's take `abcdefg` as our string and `3` as our number. We construct the regex `(.{2})(.{2})(.{2})`, which matches three runs of two characters and stores them in three capture groups. Then, using Pip's regex match variables, we can print 1) the list of capture groups `["ab";"cd";"ef"]`, and 2) the remainder of the string that wasn't matched `"g"`.
```
                      a,b are cmdline args; XX is the regex `.` (match any one character)
    #a//b             Len(a) int-divided by b: the length of each chunk
         *XX          Apply regex repetition by that number to `.`, resulting in something
                        that looks like `.{n}`
  C(        )         Wrap that regex in a capturing group
             Xb       Repeat the whole thing b times
a~                    Match the regex against a
               P$$    Print $$, the list of all capture groups (newline separated via -n)
                  $'  Print $', the portion of the string after the match
```
[Answer]
# [Haskell](https://www.haskell.org/), 62 bytes
`#` is an operator taking a `String` and an `Int`, and returning a list of `String`s.
Use as `"Hello, world!"#4`.
```
s#n|d<-length s`div`n=[take(d+n*0^(n-i))$drop(i*d)s|i<-[0..n]]
```
[Try it online!](https://tio.run/##ZY7LCsIwEEX3fkV9LBJtg9b6RIX6FnTlUioNJthgnEqSWgT/vVYLIribc@6dYSKqL1zK7EoFjAUYrujJ1BKQArgmV3pDOopTksApUeqBqpggxSkbDvdGCTg7E1QM9gYMxph89jJdhScbOZLD2USWDpm4hzA@GHrhiDWg3jwicATGNabiGxJ1hvVTjJxDkxAIgixDlXX@VGxbaawkK1dsy8Olf9l5S386my@Wq3XO7ptbbtvrdHv9wbew9af@zs@x/ZMXN18 "Haskell ‚Äì Try It Online")
# How it works
* `s` is the input string and `n` is the number of non-remainder pieces.
* `d` is the length of each "normal" piece. `div` is integer division.
* The list comprehension constructs `n+1` pieces, with the last being the remainder.
	+ `i` iterates from `0` to `n`, inclusive.
	+ For each piece, first the right amount (`i*d`) of initial characters are `drop`ped from the beginning of `s`, then an initial substring is `take`n from the result.
	+ The substring length taken should be `d`, except for the remainder piece.
		- The actual remainder must be shorter than `n`, as otherwise the normal pieces would be lengthened instead.
		- `take` returns the whole string if the length given is too large, so we can use any number `>=n-1` for the remainder piece.
		- The expression `d+n*0^(n-i)` gives `d` if `i<n` and `d+n` if `i==n`. It uses that `0^x` is `1` when `x==0`, but `0` if `x>0`.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~68 67~~ 65 bytes
* @musicman123 saved 2 bytes:output without enclosing with `[]`
* Thanks to @Chas Brown for 1 Byte: `x[p*i:p+p*i]` as `x[p*i][:p]`
```
def f(x,n):p=len(x)/n;print[x[p*i:][:p]for i in range(n)],x[p*n:]
```
[Try it online!](https://tio.run/##FclBCoAgEAXQq0ytNIQgWhntu4O4CNQS5DuIkJ3e6G0fv/XOWHp3PlAQTUFq3pOHaHLGxiWimmZ4itoazTbkQpEiqJy4vIC06l9o24MYD59SVvTkktwwqlX2Dw "Python 2 ‚Äì Try It Online")
[Answer]
# C++14, ~~209~~ 180 bytes
That's a bit too long, but uses the division operator:
```
#include<bits/stdc++.h>
using q=std::string;using z=std::vector<q>;z operator/(q s,int d){int p=s.length()/d,i=0;z a;for(;i<d+1;){a.push_back(s.substr(i++*p,i^d?p:-1));}return a;}
```
Usage:
```
vector<string> result = string("abc")/3;
```
Online version: <http://ideone.com/hbBW9u>
[Answer]
# Pyth, 9 bytes
```
cz*L/lzQS
```
[Try it online](https://pyth.herokuapp.com/?code=cz%2aL%2FlzQS&input=5%0AHello%2C+world%21)
### How it works
First `Q` is autoinitialized to `eval(input())` and `z` is autoinitialized to `input()`.
```
cz*L/lzQSQ
     lz      length of z
    /  Q     integer division by Q
  *L         times every element of
        SQ       [1, 2, ‚Ä¶, Q]
cz           chop z at those locations
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
Ld‚Åπx,1$}R‚Å∏·πÅ
```
[Try it online!](https://tio.run/##y0rNyan8/98n5VHjzgodQ5XaoEeNOx7ubPx/eLlS5KOmNVmPGuYc2qYLBYe2/f@v5AHUkq@jUJ5flJOiqKSjgCng6OTs4ubq7gFiGxoZm5iamVtYgiV8HJ0cfR2V/pvoKJjqKBiBSWMA "Jelly ‚Äì Try It Online")
[Answer]
# [Rust](https://www.rust-lang.org/), 107 bytes
```
fn f(s:&str,n:usize)->(Vec<&str>,&str){let c=s.len()/n;((0..n).map(|i|&s[i*c..i*c+c]).collect(),&s[c*n..])}
```
[Try it online!](https://tio.run/##jZJdT8IwFIbv@RXdLkiLs8oYfjAlKX5xAbfeLItZapcsKR2uRROB3z7PaUKEKMZdvKc5532fnXRrVta1pSGLojKUkXWHwFNYqxr3ot4CWtJwqrSuI/JRN/o1CCOSsIjQdyWDDEfQCGGMBSxYwBbmUIOQsfQfvOE@z@M8dMf058YT0f87U0zu7h8en6Zgjr9x2MW4nyDgSLofD5LhxeXV9eE2fczGKAOUBGXoOd57ZJOZmIi5AO9gb5EZZsXE69wjxN@7HN7zj02QgK4dY9lUxmkTwPu1Jk5ZZ8kSwHBfaWeLH7ikdtS1ronMaGWrT8VOx/RZyRvsjSNUttbKEXlruVbwL5yZlNJzzg3ji2JJN9Wma7OqJzkHOZE547LWWklHGcQz2TOc52zbtl8 "Rust ‚Äì Try It Online")
Formatted:
```
fn q129259(s: &str, n: usize) -> (Vec<&str>, &str) {
    let c = s.len() / n;
    ((0..n).map(|i| &s[i * c..i * c + c]).collect(), &s[c * n..])
}
```
This simply `map`s indices onto the correct slices of the source `str` (`collect`ing into a `Vec`) and slices out the remainder.
Unfortunately, I cannot make this a closure (74 bytes):
```
|s,n|{let c=s.len()/n;((0..n).map(|i|&s[i*c..i*c+c]).collect(),&s[c*n..])}
```
as the compiler fails with
```
error: the type of this value must be known in this context
 --> src\q129259.rs:5:18
  |
5 |          let c = s.len() / n;
  |                  ^^^^^^^
```
and if I provide the type of `s:&str`, the lifetimes are wrong:
```
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements
 --> src\q129259.rs:6:27
  |
6 |          ((0..n).map(|i| &s[i * c..i * c + c]).collect(), &s[c * n..])
  |                           ^^^^^^^^^^^^^^^^^^^
  |
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the body at 4:18...
 --> src\q129259.rs:4:19
  |
4 |       (|s: &str, n| {
  |  ___________________^
5 | |          let c = s.len() / n;
6 | |          ((0..n).map(|i| &s[i * c..i * c + c]).collect(), &s[c * n..])
7 | |      })(s, n)
  | |______^
note: ...so that reference does not outlive borrowed content
 --> src\q129259.rs:6:27
  |
6 |          ((0..n).map(|i| &s[i * c..i * c + c]).collect(), &s[c * n..])
  |                           ^
note: but, the lifetime must be valid for the lifetime 'a as defined on the body at 3:58...
 --> src\q129259.rs:3:59
  |
3 |   fn q129259<'a>(s: &'a str, n: usize) -> (Vec<&str>, &str) {
  |  ___________________________________________________________^
4 | |     (|s: &str, n| {
5 | |          let c = s.len() / n;
6 | |          ((0..n).map(|i| &s[i * c..i * c + c]).collect(), &s[c * n..])
7 | |      })(s, n)
8 | | }
  | |_^
note: ...so that expression is assignable (expected (std::vec::Vec<&'a str>, &'a str), found (std::vec::Vec<&str>, &str))
 --> src\q129259.rs:4:5
  |
4 | /     (|s: &str, n| {
5 | |          let c = s.len() / n;
6 | |          ((0..n).map(|i| &s[i * c..i * c + c]).collect(), &s[c * n..])
7 | |      })(s, n)
  | |_____________^
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 92 bytes
```
(.+)¬∂(.+)
$2$*1¬∂$.1$*1¬∂$1
(1+)¬∂(\1)+
$1¬∂$#2$*1¬∂
\G1(?=1*¬∂(1+))
$1¬∂
¬∂¬∂1+
O^$`.
¬∂1+$
O^$`.
```
[Try it online!](https://tio.run/##K0otycxL/P9fQ09b89A2EMmlYqSiZXhom4qeIYQ25NIwBEvGGGpqc6mAhJQhSrhi3A017G0NtYCSQCWaYEmuQ9sObTPU5uLyj1NJ0OPiAnFUYLz//z1Sc3LydRTK84tyUhS5TAE "Retina ‚Äì Try It Online") Explanation: The first stage converts the number of parts to unary and also takes the length of the string. The second stage then divides the length by the number of parts, leaving any remainder. The third stage multiplies the result by the number of parts again. This gives us the correct number of strings of the correct length, but they don't have the content yet. The number of parts can now be deleted by the fourth stage. The fifth stage reverses all of the characters. This has the effect of switching the original content with the placeholder strings, but although it's now in the right place, it's in reverse order. The placeholders have served their purpose and are deleted by the sixth stage. Finally the seventh stage reverses the characters back into their original order.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 36 bytes
```
{$^a.comb.rotor($a.comb/$^b xx$b,*)}
```
[Try it online!](https://tio.run/##ZZBtS8MwFIU/r7/iLgRJZm3t21SGSjdf9mH7BdZBa1MstM1IC26M/faaG50W9uXc5J6T50C2QlXTvt7DRQH30B/oJnU@ZJ05SnZSMfpzc@kmg92OZvaEH/tCKmBV2YiWw8Ea1W5CmDN55AlxkpYl@SV3Z9aoTfdQMHptA/W4dezJUlSVtOFLqiofExtCuHoA9oZ7fSPaw6F9HDpD3vUcEw5MK5QtdJ8ClKjTssmF4tYZMPoDGp6hnqDmrAwSw/p1PF88Pb@8LrXj/z7EFQbNGqNY3sj/0hnIbVfKJq3Qs4jnB2E0vbm9G7R7SPBRApQQJTI0E8TmVTyP17E2glPxClPx3OjahOMBf/BZZ3TMYoR/Aw "Perl 6 ‚Äì Try It Online")
Returns a list of lists of strings, where the last element is the remainder (if there is one).
### Explanation:
```
{                                  }  # Anonymous code block
 $^a.comb                             # Split the string into a list of chars
         .rotor(                  )   # And split into
                            xx$b      # N lists
                $a.comb/$^b           # With string length/n size
                                ,*    # And whatever is left over  
```
[Answer]
# JavaScript (ES6), 77 bytes
```
(s,d,n=s.length)=>[s.match(eval(`/.{${n/d|0}}/g`)).slice(0,d),s.slice(n-n%d)]
```
Returns an array of two elements: the divided string parts and the remainder part.
## Test Snippet
```
f=
(s,d,n=s.length)=>[s.match(eval(`/.{${n/d|0}}/g`)).slice(0,d),s.slice(n-n%d)]
```
```
<div oninput="O.innerHTML=I.value&&J.value?JSON.stringify(f(I.value,+J.value)):''">String: <input id=I> Number: <input id=J size=3></div>
<pre id=O>
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 18 bytes
```
¬ØW=Ul fV)√≤W/V pUsW
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.5&code=r1c9VWwgZlYp8lcvViBwVXNX&input=IjEyMzQ1Njc4OSIKNSAtUQ==) (uses `-Q` flag to visualize the output)
### Explanation
```
¬ØW=Ul fV)√≤W/V pUsW  : Implicit: U = input string, V = input integer
   Ul fV            : Floor U.length to a multiple of V.
 W=                 : Assign this value to variable W.
¬Ø       )           : Take the first W characters of U (everything but the remainder).
         √≤W/V       : Partition this into runs of length W / V, giving V runs.
              pUsW  : Push the part of U past index W (the remainder) to the resulting array.
                    : Implicit: output result of last expression
```
[Answer]
# Python, ~~82~~ ~~76~~ 74 bytes
```
def G(h,n):l=len(h);r=l/n;print[h[i:i+r]for i in range(0,n*r,r)],h[l-l%n:]
```
Well, looks like this qualifies for the bonus points.  May I please receive a cookie instead? Oh wait, they aren't real? Darn...
[Try It Online!](https://tio.run/##BcFBCsIwEAXQq4wFIdERRVyldF3vELIQmjoDw08ZCsXTx/e23y4Nz96XutIchBGTTVYRJI4@2R3j5oo9S9akVy9rc1JSkH/wreHBuDh7LCzZbnZGKn0Ow7uaNaajuS2ngV@x/wE)
[Answer]
## Python, ~~95, 87, 76~~ 73 Bytes
```
def f(s,n):
 a=[];i=len(s)/n
 while n:a+=s[:i],;s=s[i:];n-=1
 print a+[s]
```
[Try it online!](https://tio.run/##DcbBCoQgEADQu18xdVJyWXahi@K9fxAPQkoDwxhNEH299U5vv8@t8b/3tVSoWiwbpyCHmDwGKqzFfFnBtSEVYJenINFhsl7eoEueP@GnYD@QT8hTlNSrHpdC1Cxc7aB1GC3Mpj8 "Python 2 ‚Äì Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 12 bytes
```
¬≤g¬π‚Ä∞`s¬π.D)R¬£
```
[Try it online!](https://tio.run/##MzBNTDJM/f//0Kb0QzsfNWxIKD60U89FM@jQ4v//Tbg8UnNy8nUUyvOLclIUAQ "05AB1E ‚Äì Try It Online")
### Explanation
```
¬≤g¬π‚Ä∞`s¬π.D)R¬£
¬≤g           # Push length of string
  ¬π          # Push amount of pieces
   ‚Ä∞         # divmod of the two
    `s       # Flatten the resulting array and flip it around
      ¬π.D    # Repeat the resulting length of the pieces amount of pieces times(wow that sounds weird)
         )   # Wrap stack to array
          R  # Reverse (so the remainder is at the end)
           ¬£ # Split the input string into pieces defined by the array
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 16 bytes
```
k ∞‚ÜôX·∏ç‚ÇéYl·µõ&ht‚ÜôX;Y
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3wP/vUhkdtMyMe7uh91NQXmfNw62y1jBKQiHXk///RCtFKHqk5OfnWCuX5RTkpiko6JrE6GGKmIDFHJ2cXVzd3DyUdIxDX0MjYxNTM3MISJu3j6OTo66ikY4wkCzUupDw1r6RSISe1pCS1qFghJz8vXQ8kpRALAA "Brachylog ‚Äì Try It Online")
Takes input as a list `[string, number]` and outputs as a list `[remainder, parts]`. (Commas were replaced with semicolons in the "Hello, world!" test cases for clarity, since the string fragments don't get printed with quotes.)
```
                    The input
  ∞                  with its first element
k ‚ÜôX                having the last X elements removed
    ·∏ç               and being cut into a number of pieces
     ‚Çé              where that number is the last element of the input
      Y             is Y
       l·µõ           the elements of which all have the same length,
         &          and the input
          h         's first element
           t‚ÜôX      's last X elements
              ;     paired with
               Y    Y
                    are the output.
```
(I also replaced a comma in the code with a semicolon for a consistent output format. [With the comma](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3wP/vUhkdtMyMe7uh91NQXmfNw62y1jBKQiE7k///RCtFKHqk5OfnWCuX5RTkpiko6JrE6GGKmIDFHJ2cXVzd3DyUdIxDX0MjYxNTM3MISJu3j6OTo66ikY4wkCzUupDw1r6RSISe1pCS1qFghJz8vXQ8kpRALAA), cases with no remainder would just output the parts without an empty remainder, and as nice as that is for some purposes, I don't actually know why it works that way...)
After this came out to be a whole 16 bytes, I tried to make something based on `+‚ÇÅ·µó‚ü®ƒ°l‚ü©` work, but as the fixes got longer and longer I decided that I would just stick with my original solution for now.
[Answer]
## C(gcc), 72 bytes
```
d;f(s,n)char*s;{for(d=strlen(s)/n;n--;puts(""))s+=write(1,s,d);puts(s);}
```
[Try It Online](https://tio.run/##JYw7DsIwEAX7nMK42gVbKFCu3HMDCkQR@QORjB15jSiinN2Q8MqZ0bP6YW1rjgKwSmifQ9kzzSEXcIZriT4B4zFR0pqmd2WQEpEP5lPG6qFXrBz@BSMt7TWMCbCbO/Hb@iaq53q7CyPkxceYxTWX6Hb9SdLWBFgDJc5I3bKR9gU)
[Answer]
# Excel Formula, ~~185~~ ~~173~~ ~~165~~ ~~161~~ 149 bytes
The following should be entered as an array formula (`Ctrl`+`Shift`+`Enter`):
```
=MID(A1,(ROW(OFFSET(A1,,,B1+1))-1)*INT(LEN(A1)/B1)+1,INT(LEN(A1)/B1)*ROW(OFFSET(A1,,,B1+1))/IF(ROW(OFFSET(A1,,,B1+1))=B1+1,1,ROW(OFFSET(A1,,,B1+1))))
```
Where `A1` contains your input (e.g. `12345678`) and `B1` contains the divisor. This also uses Excel's division operator for a bonus.
After entering the formula as an array formula, highlight it in the formula bar and evaluate it using `F9` to return the result, for example:
[![Excel formula evaluation showing split groups](https://i.stack.imgur.com/eVand.png)](https://i.stack.imgur.com/eVand.png)
**-12 bytes:** replace each `INDIRECT("1:"&B1+1)` with `OFFSET(A1,,,B1+1)` to save 2 bytes per occurence, plus some tidying removing redundant brackets.
**-8 bytes:** remove redundant `INDEX` function.
**-4 bytes:** rework "remainder" handling.
**-12 bytes:** remove redundant `INT(LEN(A1)/B1)` by offsetting array generated by `ROW(OFFSET(A1,,,B1+1))` by -1.
[Answer]
# [V (vim)](https://github.com/DJMcMayhem/V), 62 bytes
```
YpC<c-r>=strlen('<c-r>"')
<esc>jYp<c-x>"aDkk:s:\n:/
C<c-r>=<c-r>"
<esc>"bDkkqq@blha
<esc>q@a@q
```
[Try it online!](https://tio.run/##K/v/P7LA2SZZt8jOtrikKCc1T0MdzFNS1@SySS1OtsuKLAAKVNgpJbpkZ1sVW8XkWelzQXVAVELUKSUB5QsLHZJyMhIhIoUOiQ6F//97pObk5OsolOcX5aQocpn81y0DAA "V (vim) ‚Äì Try It Online")
takes input as 2 lines, returns the divisions on separate lines.
`a` is useful here to append a newline after the current character.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~77~~ 76 bytes
*-1 byte thanks to musicman523.*
```
def f(s,n):l=len(s);print[s[i:i+l/n]for i in range(0,l-n+1,l/n)]+[s[l-l%n:]]
```
[Try it online!](https://tio.run/##K6gsycjPM/r/PyU1TSFNo1gnT9MqxzYnNU@jWNO6oCgzryS6ODrTKlM7Rz8vNi2/SCFTITNPoSgxLz1Vw0AnRzdP21AHKKUZqw1Ul6Obo5pnFRv7P01D3SM1JydfR6E8vygnRVFdR8FEkwuLqClY1NHJ2cXVzd0DKGAEFjA0MjYxNTO3sEQo8XF0cvR1BPKNkVWADf4PAA "Python 2 ‚Äì Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 53 bytes
```
->s,n{a=s.scan(/.{,#{s.size/n}}/);[a[0,n],a[n,n]*'']}
```
[Try it online!](https://tio.run/##KypNqvyfZhvzX9euWCevOtG2WK84OTFPQ1@vWke5GsjJrErVz6ut1de0jk6MNtDJi9VJjM4DUlrq6rG1/wsU0qLTU0uK9ZIz8nMLdBTA7JL8@MzY/4ZGxiamZuYWllymAA "Ruby ‚Äì Try It Online")
[Answer]
# Mathematica, 58 bytes
```
{#~Partition~a,#2}&@@TakeDrop[#,(a=Floor[Length@#/#2])#2]&
```
Pure function taking a list of characters and a positive integer as input. For example, the last test case is called by
```
{#~Partition~a,#2}&@@TakeDrop[#,(a=Floor[Length@#/#2])#2]&[{"1","2","3","4","5","6","7"},4]
```
and returns:
```
{{{"1"}, {"2"}, {"3"}, {"4"}}, {"5", "6", "7"}}
```
[Answer]
# Haskell, ~~120~~ 88 bytes (thanks to √òrjan Johansen!)
Does `div` count as the division operator?
I am curious how I could cut this down, I haven't learned all the tricks yet.
```
q=splitAt;x!s|n<-div(length s)x,let g""=[];g s|(f,r)<-q n s=f:g r,(a,b)<-q(n*x)s=(g a,b)
```
[Answer]
## Ohm, 3 bytes (non-competing?)
```
lvœÉ
```
Non competing because the built-in isn't implemented yet in TIO and i have no PC handy to test whether it works in the latest pull in the repo.
~~Built-in ¬Ø\\\_(„ÉÑ)\_/¬Ø. I used the wrong built-in... But hey there is still an other one laying around.~~ Now I used the wrong built-in two times (or one built-in works wrong with remainders).
Do I get bonus points because `v` is (floor) division?
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 16 bytes
```
{_,2$//_2$<@@>s}
```
Anonymous block expecting the arguments on the stack and leaves the result on the stack after.
[Try it online!](https://tio.run/##S85KzP1fWPe/Ol7HSEVfP95IxcbBwa649n9dakqs9X9TBSWP1JycfB2F8PyinBRFJQA "CJam ‚Äì Try It Online")
### Explanation
Expects arguments as `number "string"`.
```
_,              e# Copy the string and get its length.
  2$            e# Copy the number.
    /           e# Integer divide the length by the number.
     /          e# Split the string into slices of that size.
      _         e# Copy the resulting array.
       2$       e# Copy the number.
         <      e# Slice the array, keeping only the first <number> elements.
          @@    e# Bring the number and original array to the top.
            >   e# Slice away the first <number> elements,
             s  e# and join the remaining elements into a string.
```
[Answer]
# [J](http://www.jsoftware.com), 26 bytes
```
(]$~[,(<.@%~#));]{.~0-(|#)
```
Apart from elminating spaces and intermediate steps, this hasn't been golfed. I expect that I've taken the long way somehow, what with my parentheses and argument references (`[` and `]`).
See [Jupyter notebook](https://github.com/DaneWeber/JlangLearning/blob/master/Divide%20a%20string%20-%20Programming%20Puzzles%20%26%20Code%20Golf.ipynb) for test cases, such as the following:
```
   5 chunk test2
‚îå‚îÄ‚îÄ‚î¨‚îÄ‚îÄ‚îÄ‚îê
‚îÇHe‚îÇld!‚îÇ
‚îÇll‚îÇ   ‚îÇ
‚îÇo,‚îÇ   ‚îÇ
‚îÇ w‚îÇ   ‚îÇ
‚îÇor‚îÇ   ‚îÇ
‚îî‚îÄ‚îÄ‚î¥‚îÄ‚îÄ‚îÄ‚îò
```
[Answer]
# [R](https://www.r-project.org/), ~~79~~ 63 bytes
*-16 from Giuseppe fixing the indexing*
```
function(s,n,k=nchar(s),l=k%/%n)substring(s,0:n*l+1,c(1:n*l,k))
```
[Try it online!](https://tio.run/##JYxNCsIwEEb3nmJclCY6YAOuhCz87wG8QK1JWxImMkkRTx8j/VYfj8fjbHW2M/VpCiQiEjpN/dixiBK9dtWuIhnnZ0w80VCE5kAbv1XYC/V/6KTMVtSt8T4gfAL717pGgL1cFXw8nS/X270tZAEPE1MJQQc@0GAYljDYwPAOMRme0rfYqpG57Ac "R ‚Äì Try It Online")
Built around giving vector inputs to `substring()`
[Answer]
## JavaScript, 49 bytes
```
d=(s,n)=>s.match(eval(`/.{1,${0|s.length/n}}/g`))
```
[Try It Online](https://tio.run/##HcqxCsIwFEDRvV/xLA55EBMFB6HE2T9wEKEhiW3lmUgSstR@e6ze8XKeuuhk4vTOu3Kq1SqWuEd1TuKlsxmZK5pYL8V84Nt5/0mCnB/yKP2yyKFHrEVHiC6DAsvaiyMKHK4hkt20HI7YNY8Qgf0VTP5HsYE1E3wK5ASFga3zFu/Y1S8)
```
d=(s,n)=>s.match(eval(`/.{1,${0|s.length/n}}/g`))
var ret = d("######.######..#####..########..##.##..##.##.....##.....######.######.##.....##..#####.....##.....##.....##...####.....##......####...######", 5);
for (var r in ret)
    console.log(ret[r]);
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 12 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
√Æ‚ï©‚ïò30¬•‚ôÇ‚î¥√ø&‚ïï¬°
```
[Run and debug it](https://staxlang.xyz/#p=8ccad433309d0bc19826b8ad&i=%22Hello,+world%21%22,+4%0A%22Hello,+world%21%22,+5%0A%22ABCDEFGH%22,+2%0A%22123456789%22,+5%0A%22ALABAMA%22,+3%0A%221234567%22,+4%0A&a=1&m=2)
]