<commit_before>// Licensed under the Apache License, Version 2.0.

#ifndef print_h
#define print_h

#include "compiler.h"

#include <cstdint>
#include <cstdio>
#include <cwchar>
#include <limits>

template <typename S, size_t X, size_t Y>
NO_INLINE void print(S (&scene_i)[X][Y], S (&scene_z)[X][Y]) {
  constexpr auto max_s = std::numeric_limits<S>::max();
  constexpr wchar_t shades[] = {L'#', L'X', L'*', L'+', L'-', L'.', L' ', L' '};
  constexpr size_t num_shades = sizeof(shades) / sizeof(shades[0]) - 1;
  constexpr size_t shade_sections = std::numeric_limits<S>::max() / num_shades;
  constexpr const wchar_t *colors[] = {L"\033[30m", L"\033[31m", L"\033[32m",
                                       L"\033[33m", L"\033[34m", L"\033[35m",
                                       L"\033[36m", L"\033[37m", L"\033[37m"};
  constexpr const wchar_t *reset = L"\033[0m";
  constexpr size_t num_colors = sizeof(colors) / sizeof(colors[0]) - 1;
  constexpr size_t color_sections = max_s / num_colors;
  for (size_t i = 0; i < X; ++i) {
    for (size_t j = 0; j < Y; ++j) {
      fputws(colors[scene_z[i][j] / color_sections], stdout);
      putwchar(shades[scene_i[i][j] / shade_sections]);
      fputws(reset, stdout);
    }
    putwchar(L'\n');
  }
  fflush(stdout);
}

#endif<commit_msg>Color background instead of foreground.<commit_after>// Licensed under the Apache License, Version 2.0.

#ifndef print_h
#define print_h

#include "compiler.h"

#include <cstdint>
#include <cstdio>
#include <cwchar>
#include <limits>

template <typename S, size_t X, size_t Y>
NO_INLINE void print(S (&scene_i)[X][Y], S (&scene_z)[X][Y]) {
  constexpr auto max_s = std::numeric_limits<S>::max();
  constexpr wchar_t shades[] = {L'#', L'X', L'*', L'+', L'-', L'.', L' ', L' '};
  constexpr size_t num_shades = sizeof(shades) / sizeof(shades[0]) - 1;
  constexpr size_t shade_sections = std::numeric_limits<S>::max() / num_shades;
  constexpr const wchar_t *colors[] = {L"\033[40m", L"\033[41m", L"\033[42m",
                                       L"\033[43m", L"\033[44m", L"\033[45m",
                                       L"\033[46m", L"\033[47m", L"\033[47m"};
  constexpr const wchar_t *reset = L"\033[0m";
  constexpr size_t num_colors = sizeof(colors) / sizeof(colors[0]) - 1;
  constexpr size_t color_sections = max_s / num_colors;
  for (size_t i = 0; i < X; ++i) {
    for (size_t j = 0; j < Y; ++j) {
      auto shade = shades[scene_i[i][j] / shade_sections];
      if (shade != L' ') fputws(colors[scene_z[i][j] / color_sections], stdout);
      putwchar(shade);
      if (shade != L' ') fputws(reset, stdout);
    }
    putwchar(L'\n');
  }
  fflush(stdout);
}

#endif
{'fraction_non_alphanumeric': 0.1853932584269663, 'fraction_numerical': 0.04269662921348315, 'mean_word_length': 3.2396825396825397, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7066759', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1031, 'n_words': 240}