Question: **The text file is as follows**

```
City Name:           Timber
Date:                24/23/2020
Maximum Temperature: 34°C
Minimum Temperature: 20°C
Precipitation:       30%
Humidity:            40%
Wind Speed:          15km\h

City Name:           Timber
Date:                24/24/2020
Maximum Temperature: 32°C
Minimum Temperature: 22°C
Precipitation:       28%
Humidity:            38%
Wind Speed:          13km\h

City Name:           yellow
Date:                24/23/2020
Maximum Temperature: 25°C
Minimum Temperature: 16°C
Precipitation:       23%
Humidity:            21%
Wind Speed:          10km\h

```

I Would like to save the information into 7 different arrays as follows :

where the line starts with `City Name:` store those line into an array and count the entry.

where the line starts with `Date:` store those lines into an array and count the entry.

Etc.....

Answer: 
Here is a simple recursive approach, basically exploring all the possibilities.  

It stops once a solution is found.

Output:

```
11 : 1 2 4 10
50 : 1 3 5 8 49

```

And the code:

```
#include    <iostream>
#include    <vector>
#include    <algorithm>
#include    <cmath>

bool decompose_dp (long long int sum, long long int k, std::vector<long long int> &seq) {

    while (k > 0) {
        long long int sump = sum - k*k;
        if (sump == 0) {
            seq.push_back(k);
            return true;
        }
        if (sump < 0) {
            k--;
            continue;
        }
        long long int kp = k-1;

        while (kp > 0) {
            if (decompose_dp(sump, kp, seq)) {
                seq.push_back(k);
                return true;
            }
            kp --;
        }
        k--;
    }
    return false;
}

std::vector<long long int> decompose(long long int n){
    long long int square = n * n, j = 1, nextterm = n - 1, remainder, sum = 0;
    float root;
    std::vector<long long int> sequence;

    auto check = decompose_dp (n*n, n-1, sequence);
    return sequence;
}

void pr (long long int n, const std::vector<long long int> &vec) {
    std::cout << n << " : ";
    for (auto k: vec) {
        std::cout << k << " ";
    }
    std::cout << "\n";
}

int main() {
    long long int n = 11;
    auto sequence = decompose (n);
    pr (n, sequence);
    n = 50;
    sequence = decompose (n);
    pr (n, sequence);
}

```
Here's BFS, DFS and brute force in Python. BFS seems slow for input 50. Brute force yielded 91020 different combinations for input 50.

```
from collections import deque

def bfs(n):
  target = n * n
  queue = deque([(target, [], 1)])
  while queue:
    t, seq, i = queue.popleft()
    if t == 0:
      return seq
    if (t == target and i*i < t) or (t != target and i*i <= t):
      queue.append((t - i*i, seq[:] + [i], i + 1))
      queue.append((t, seq, i + 1))

def dfs(n):
  target = n * n
  stack = [(target, [], 1)]
  while stack:
    t, seq, i = stack.pop()
    if t == 0:
      return seq
    if (t == target and i*i < t) or (t != target and i*i <= t):
      stack.append((t - i*i, seq[:] + [i], i + 1))
      stack.append((t, seq, i + 1))

def brute(n):
  target = n * n
  stack = [(target, [], 1)]
  result = []
  while stack:
    t, seq, i = stack.pop()
    if t == 0:
      result.append(seq)
    if (t == target and i*i < t) or (t != target and i*i <= t):
      stack.append((t - i*i, seq[:] + [i], i + 1))
      stack.append((t, seq, i + 1))
  return result

print bfs(50) # [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20]
print dfs(50) # [30, 40]
#print brute(50)

```