def popcount(value):
  return bin(value).count("1")

def make_popcount_table(mask):
  for high_nibble in range(0, 16):
    line = "\t"
    for low_nibble in range(0, 16):
      value = (high_nibble << 4) | low_nibble
      line += str(popcount(value & mask))
      if low_nibble != 15:
        line += ", "
      elif high_nibble != 15:
        line += ","
    print line

if __name__ == "__main__":
  print "static const uint8 number_of_ones_for_visible[256] = {"
  make_popcount_table(0b01010101) # for each bit pair, the lower bit
  print "};"
  print "static const uint8 number_of_ones_for_frozen[256] = {"
  make_popcount_table(0b10101010) # for each bit pair, the higher bit
  print "};"
