import codecs
from jinja2 import Template
import string
import glob
import PySimpleGUI as sg
from flask import Flask, render_template
import pandas as pd
import csv
import numpy as np
from pulp import *
from difflib import get_close_matches
import urllib.request
from bs4 import BeautifulSoup
import re
import itertools
import reprlib
import requests
import regex
import time
from pulp import LpProblem, LpMaximize, lpDot, lpSum, value, GLPK_CMD
from ortoolpy import addvar, addvars, addbinvars
from multiprocessing.pool import ThreadPool
from dask.distributed import Client
import numpy as np
from pymoo.util.misc import stack
from pymoo.core.problem import Problem
from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.factory import get_sampling, get_crossover, get_mutation, get_termination, get_problem
from pymoo.optimize import minimize
from pymoo.visualization.scatter import Scatter
from pymoo.core.problem import ElementwiseProblem, dask_parallelized_eval
from pymoo.core.crossover import Crossover
from pymoo.core.mutation import Mutation 
from pymoo.core.sampling import Sampling
from pymoo.algorithms.soo.nonconvex.ga import GA
from pymoo.optimize import minimize
from pymoo.util.display import Display
import matplotlib.pyplot as plt
from PIL import Image
import shutil



sg.theme('DarkAmber')   # デザインテーマの設定
# ウィンドウに配置するコンポーネント
layout1 = [  [sg.Text('ようこそ')],
            [sg.Text('人数を入力してください'), sg.InputText(default_text='1', size=(10, 1), key='ninzu')],
            [sg.Button('決定'), sg.Button('キャンセル')],
             ]
#\n高い:立ち仕事や移動が多い仕事、または活発な運動習慣を持っている。 → 0と入力\n普通:座り仕事が中心だが、軽い運動や散歩などをする。 → 1と入力\n低い:1日のうち、座っていることがほとんど。 → 2と入力\n"))
# gender = int(input("性別を入力してください、男性は0、女性は1と入力してください。\n"))
window = sg.Window('入力画面', layout1)# ウィンドウの生成
# イベントループ
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'キャンセル':
        print('プログラムが終了しました。')
        quit()

    elif event == '決定':
        print('人数:', str(values['ninzu']))
        ninzu = int(values['ninzu'])
        break
window.close()

#↓exec()で繰り返す構文
code = '''
sg.theme('DarkAmber')   # デザインテーマの設定
# ウィンドウに配置するコンポーネント
layout2 = [ [sg.Text(str(i+1)+'人目の情報を入力してください')],
            [sg.Text('名前'), sg.InputText(default_text='水上和秀', size=(10, 1), key='name')],
            [sg.Text('年齢'), sg.InputText(default_text='21',size=(10, 1), key='age')],
            [sg.Text('身長'), sg.InputText(default_text='170',size=(10, 1), key='height'), sg.Text('cm', size=(10, 1)) ],
            [sg.Text('体重'), sg.InputText(default_text='65',size=(10, 1), key='weight'), sg.Text('kg', size=(10, 1))],
            [sg.Text('性別'),sg.Combo(('男', '女'), default_value="男",size=(10, 1), key='gender')],
            [sg.Text('運動の度合い')],[sg.Combo(('低い', '普通','高い'), size=(10, 1),default_value="低い", key='actlevel')],
            [sg.Button('決定'), sg.Button('キャンセル')],
             ]

window = sg.Window('入力画面', layout2)# ウィンドウの生成
# イベントループ
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'キャンセル':
        print('プログラムが終了しました。')
        quit()

    elif event == '決定':
        print('あなたの名前:', str(values['name']))
        namelist.append(str(values['name']))

        print('あなたの年齢:', int(values['age']))
        age = int(values['age'])
        agelist.append(int(values['age']))

        print('あなたの身長:', float(values['height']))
        height = float(values['height'])
        heightlist.append(float(values['height']))

        print('あなたの体重:', float(values['weight']))
        weight = float(values['weight'])
        weightlist.append(float(values['weight']))

        print('あなたの性別:', str(values['gender']))
        gender = str(values['gender'])
        genderlist.append(gender)

        print('あなたの運動レベル:', str(values['actlevel']))
        actlevel = str(values['actlevel'])

        if 1 <= age <= 2:
            if actlevel == "低い":
                actlevel = 0
            if actlevel == "普通":
                actlevel = 1.35
            if actlevel == "高い":
                actlevel = 0

        if 3 <= age <= 5:
            if actlevel == "低い":
                actlevel = 0
            if actlevel == "普通":
                actlevel = 1.45
            if actlevel == "高い":
                actlevel = 0

        if 6 <= age <= 7:
            if actlevel == "低い":
                actlevel = 1.35
            if actlevel == "普通":
                actlevel = 1.55
            if actlevel == "高い":
                actlevel = 1.75

        if 8 <= age <= 9:
            if actlevel == "低い":
                actlevel = 1.4
            if actlevel == "普通":
                actlevel = 1.6
            if actlevel == "高い":
                actlevel = 1.8

        if 10 <= age <= 11:
            if actlevel == "低い":
                actlevel = 1.45
            if actlevel == "普通":
                actlevel = 1.65
            if actlevel == "高い":
                actlevel = 1.85

        if 12 <= age <= 14:
            if actlevel == "低い":
                actlevel = 1.45
            if actlevel == "普通":
                actlevel = 1.65
            if actlevel == "高い":
                actlevel = 1.85

        if 15 <= age <= 17:
            if actlevel == "低い":
                actlevel = 1.55
            if actlevel == "普通":
                actlevel = 1.75
            if actlevel == "高い":
                actlevel = 1.95

        if 18 <= age <= 29:
            if actlevel == "低い":
                actlevel = 1.55
            if actlevel == "普通":
                actlevel = 1.75
            if actlevel == "高い":
                actlevel = 1.95

        if 30 <= age <= 49:
            if actlevel == "低い":
                actlevel = 1.55
            if actlevel == "普通":
                actlevel = 1.75
            if actlevel == "高い":
                actlevel = 1.95

        if 50 <= age <= 69:
            if actlevel == "低い":
                actlevel = 1.55
            if actlevel == "普通":
                actlevel = 1.75
            if actlevel == "高い":
                actlevel = 1.95

        if 70 <= age:
            if actlevel == "低い":
                actlevel = 1.45
            if actlevel == "普通":
                actlevel = 1.70
            if actlevel == "高い":
                actlevel = 1.95
        
        actlevellist.append(actlevel)
        #bms基礎代謝基準値
        if gender == "男":
            if 1 <= age <= 2:
                bms = 61
            
            if 3 <= age <= 5:
                bms = 54.8

            if 6 <= age <= 7:
                bms = 44.3

            if 8 <= age <= 9:
                bms = 40.8

            if 10 <= age <= 11:
                bms = 37.4

            if 12 <= age <= 14:
                bms = 31.0

            if 15 <= age <= 17:
                bms = 27.0

            if 18 <= age <= 29:
                bms = 24.0

            if 30 <= age <= 49:
                bms = 22.3

            if 50 <= age <= 69:
                bms = 21.5

            if 70 <= age:
                bms = 21.5

        if gender == "女":
            if 1 <= age <= 2:
                bms = 59.7
            
            if 3 <= age <= 5:
                bms = 52.2

            if 6 <= age <= 7:
                bms = 41.9

            if 8 <= age <= 9:
                bms = 38.3

            if 10 <= age <= 11:
                bms = 34.8

            if 12 <= age <= 14:
                bms = 29.6

            if 15 <= age <= 17:
                bms = 25.3

            if 18 <= age <= 29:
                bms = 22.1

            if 30 <= age <= 49:
                bms = 21.7

            if 50 <= age <= 69:
                bms = 20.7

            if 70 <= age:
                bms = 20.7
            
        bmslist.append(bms)

        #基礎代謝量
        fma = bms * weight
        fmalist.append(fma)

        #必要推定エネルギー量
        eer = fma * actlevel
        eerlist.append(eer)

        #必要タンパク質
        rtanpaku = (eer * 0.13) / 4
        rtanpakulist.append(rtanpaku)

        #必要脂質
        rsisitu = (eer * 0.15) / 9
        rsisitulist.append(rsisitu)

        #必要炭水化物
        rtansui = (eer * 0.4) / 4
        rtansuilist.append(rtansui)

        g = int(i)
        #カロリーの倍率
        if g == 0:#1人目のカロリーbai1
            bai1 = eer 

        bai2 = eer/bai1 #2人目は1人目を基準にカロリーの倍率を計算
        bai.append(bai2)
        break
window.close()
'''
bai = []
namelist = []
agelist = []
heightlist = []
weightlist = []
genderlist = []
actlevellist = []
bmslist = []
fmalist = []
eerlist = []
rtanpakulist = []
rtansuilist = []
rsisitulist = []

#execでcodeを人数分回す
for i in range(ninzu):
    exec(code)

#入力情報のデータフレームを作成
pd_login = pd.DataFrame()
pd_login.insert(0,'何人前を作るか',bai)
pd_login.insert(0,'必要炭水化物(rtansui)',rtansuilist)
pd_login.insert(0,'必要脂質(rsisitu)',rsisitulist)
pd_login.insert(0,'必要タンパク質(rtanpaku)',rtanpakulist)
pd_login.insert(0,'必要推定エネルギー量(eer)',eerlist)
pd_login.insert(0,'基礎代謝量(fma)',fmalist)
pd_login.insert(0,'基礎代謝基準値(bms)',bmslist)
pd_login.insert(0,'身体活動量',actlevellist)
pd_login.insert(0,'性別',genderlist)
pd_login.insert(0,'体重',weightlist)
pd_login.insert(0,'身長',heightlist)
pd_login.insert(0,'年齢',agelist)
pd_login.insert(0,'名前',namelist)
print(pd_login)

#必要カロリーeer
eer = pd_login.iloc[0,8]
#必要タンパク質rtanpaku
rtanpaku = pd_login.iloc[0,9]
#必要脂質rsisitu
rsisitu = pd_login.iloc[0,10]
#必要炭水化物rtansui
rtansui = pd_login.iloc[0,11]


#pd_login.to_csv('login.csv', encoding="shift_jis",errors='ignore', index=False) #レシピと献立をcsvに保存 確認用
##############################################ここまでレシピを作る人数を入力する画面#######################################

#################ここからcsvからレシピのデータベースを作成#####################################################################
#t1 = time.time()
####変数のセット####
#レシピの数R
R = 400
gen = 20
#レシピの内部番号i(0~399)
i = list(range(R))
#レシピ番号num(1~400)
num = []
for n in i:
    num.append(n+1)  


#食材の数Q
Q = 0
#栄養素の数N
N = 0
#レシピナンバー
recinoi = list(range(R))
#レシピの名前yi
yi = list(range(R))
#調理時間Ti
Ti = list(range(R))
#主菜フラグsigmai
sigmai = list(range(R))
#摂取カロリーCi
Ci = list(range(R))
#コストGi
Gi = list(range(R))
#材料名qij
qij = [['' for i in range(25)] for j in range(R)]

mf = list(range(R))
#vはcsvから入手する用の変数
v = list(range(25))
Nm = 0
Qm = 0

##########################################ここからcsvからレシピのデータベースを作成#####################################################################
#t1 = time.time()
#使うレシピデータリスト
for j in i:

    #csvの読み取り
    df = pd.read_csv("../recipe_data/recipe_no"+ str(j+1) +".csv",encoding="cp932")    
    for m in v:
	#ilocは行と列を指定することによりその値を抽出できる
    #CSVから栄養素、食材を読み込み
        #材料名qij
        qij[j][m] = df.iloc[m,4]
        #データの成型（数値しか入らないように単位を消す、単位をそろえる）
        if('(A)'or '(a)'or'(B)'or '(b)'or'・' in qij[j][m]):
            qij[j][m] = qij[j][m].replace('(A)','NAN')
            qij[j][m] = qij[j][m].replace('(a)','NAN')
            qij[j][m] = qij[j][m].replace('(B)','NAN')
            qij[j][m] = qij[j][m].replace('(b)','NAN')
            qij[j][m] = qij[j][m].replace('・','')

        yi[j] = df.iloc[1,0]
        #NANじゃなかったら食材数を数える
        if not qij[j][m]=="NAN":
            Q = Q + 1        

#インデックス作成
index1 = list(range(R))
#pd_nameはレシピ名と食材が入ったdataframe
print("データフレーム作成しました")
pd_name = pd.DataFrame(data=qij,index = index1)
pd_name.insert(0,'name',yi)
pd_name.insert(0,'number',i)
pd_name.to_csv('recipename.csv', encoding="shift_jis",errors='ignore', index=False)
########################################ここまでdataframe作成#########################


#xが含まれる食材番号をyの配列に入れる関数の定義
def kensaku(x,y):
    c = []
    for j in range(24):
        #xが含まれる行を特定
        a = pd_name[j].str.contains(x)
        #xが含まれる行番号を取得
        b = pd_name.loc[a,'number']
        c = b.values.tolist()
        y.extend(c)
    return y

#########################ここからアレルギー情報を入力する画面###############################################
# ウィンドウに配置するコンポーネント
layout3 = [
    [sg.Text('アレルギー項目をチェックしてください(複数回答可)')],
    [sg.Checkbox('特になし', key='normal',default = True)],
    [sg.Checkbox('卵', key='egg'),sg.Checkbox('乳', key='milk'),sg.Checkbox('らっかせい', key='rakkasei')],
    [sg.Checkbox('えび', key='ebi'),sg.Checkbox('小麦', key='komugi'),sg.Checkbox('かに', key='kani')],
    [[sg.Checkbox('そば', key='soba')]],
    [sg.Text('何か抜いてほしい食材があれば入力してください。'),sg.InputText(default_text='',size=(10, 1), key='syokuzai')],
    [sg.Button('回答', key='-Btn-')]
]

window = sg.Window('アレルギー', layout3)# ウィンドウの生成

# イベントループ
while True:
    event,values = window.read()  # イベントの入力を待つ

    if event == '-Btn-':
        
        for q in range(8):
            exec(f"f{q+1} = []")#execはカッコ内の処理を行う,この場合はf1~f8までの配列を作る
        firstloop = False#firstloopというフラグを作成,Trueで回答されている状態,Falseで何も回答されていない状態
        if values['normal'] == True:
            print('アレルギーはないですね')
            firstloop = True
            arerugi = []
            break
        if values['egg'] == True:
            #卵が含まれる代表的な食品のリストの削除
            kensaku('卵',f1)
            kensaku('パン',f1)
            kensaku('サンドイッチ',f1)
            kensaku('ケーキ',f1)
            kensaku('クッキー',f1)
            kensaku('ビスケット',f1)
            kensaku('アイスクリーム',f1)
            kensaku('マヨネーズ',f1)
            kensaku('とんかつ',f1)
            kensaku('ラーメン',f1)
            if f1:#リストがある場合の処理
                print('卵が含まれるレシピ番号')
                print(sorted(f1))
            else:#リストが空の場合の処理
                print('卵が含まれるレシピはありませんでした')
            firstloop = True
        if values['milk'] == True:
            kensaku('乳',f2)
            kensaku('チーズ',f2)
            kensaku('ヨーグルト',f2)
            kensaku('バター',f2)
            kensaku('ケーキ',f2)
            kensaku('チョコレート',f2)
            kensaku('アイスクリーム',f2)
            kensaku('ミルク',f2)
            kensaku('生クリーム',f2)
            if f2:#リストがある場合の処理
                print('乳が含まれるレシピ番号')
                print(sorted(f2))
            else:#リストが空の場合の処理
                print('乳が含まれるレシピはありませんでした')
            firstloop = True
        if values['rakkasei'] == True:
            kensaku('落花生',f3)
            kensaku('らっかせい',f3)
            kensaku('ピーナッツ',f3)
            if f3:#リストがある場合の処理
                print('落花生が含まれるレシピ番号')
                print(sorted(f3))
            else:#リストが空の場合の処理
                print('落花生が含まれるレシピはありませんでした')
            firstloop = True
        if values['ebi'] == True:
            kensaku('えび',f4)
            kensaku('エビ',f4)
            kensaku('海老',f4)
            if f4:#リストがある場合の処理
                print('えびが含まれるレシピ番号')
                print(sorted(f4))
            else:#リストが空の場合の処理
                print('えびが含まれるレシピはありませんでした')
            firstloop = True
        if values['komugi'] == True:
            kensaku('小麦',f5)
            kensaku('うどん',f5)
            kensaku('カレー',f5)
            kensaku('パスタ',f5)
            kensaku('パン',f5)
            kensaku('クッキー',f5)
            if f5:#リストがある場合の処理
                print('小麦が含まれるレシピ番号')
                print(sorted(f5))
            else:#リストが空の場合の処理
                print('小麦が含まれるレシピはありませんでした')
            firstloop = True
        if values['kani'] == True:
            kensaku('かに',f6)
            kensaku('カニ',f6)
            kensaku('蟹',f6)
            if f6:#リストがある場合の処理
                print('かにが含まれるレシピ番号')
                print(sorted(f6))
            else:#リストが空の場合の処理
                print('かにが含まれるレシピはありませんでした')
            firstloop = True
        if values['soba'] == True:
            kensaku('そば',f7)
            if f7:#リストがある場合の処理
                print('そばが含まれるレシピ番号')
                print(sorted(f7))
            else:#リストが空の場合の処理
                print('そばが含まれるレシピはありませんでした')
            firstloop = True
        if values['syokuzai']:
            kensaku(values['syokuzai'],f8)
            firstloop = True
            if f8:#リストがある場合の処理
                print(str(values['syokuzai'])+'が含まれるレシピ番号')
                print(sorted(f8))
            else:#リストが空の場合の処理
                print(str(values['syokuzai'])+'が含まれるレシピはありませんでした')
            
        #最後に回答されているか判定
        if not firstloop:
            sg.popup_ok('回答してください')  # ポップアップを表示
            continue #whileの一番上に移動
        
        arerugi = []
        for w in range (8):
            exec(f"arerugi.extend(f{w+1})") #execはカッコ内の処理を行う,この場合はf1~f7までの配列をarerugiにまとめている
        arerugi = set(arerugi) #まとめた番号の重複削除
        arerugi = sorted(arerugi) #まとめた番号を並べる
        print('アレルギーが含まれるもの（重複削除）')
        print(len(arerugi))#アレルギーが含まれる個数
        print(arerugi)

        if firstloop == True:#firstloopフラグがTrueならウィンドウを閉じる
            break
    
    elif event is None:#ウィンドウを閉じたらプログラムを終了する
        print('プログラムが終了しました。')
        quit()

window.close()

##############ここまででarerugiにアレルギーが含まれるレシピ番号を格納した。######################################################

########################################ここから制限食の設定####################################################
# ウィンドウに配置するコンポーネント
layout4 = [
    [sg.Text('患っている、または予防したい生活習慣病があれば選択してください。')],
    [sg.Checkbox('特になし', key='normal2',default = True)],
    [sg.Checkbox('糖尿病', key='tounyou')],
    [sg.Checkbox('腎臓病', key='jinzou')],
    [sg.Checkbox('脂質異常症', key='sisituijou')],
    [sg.Checkbox('高血圧', key='kouketu')],
    [sg.Button('回答', key='-Btn-')]
]

window = sg.Window('制限食設定', layout4)# ウィンドウの生成

# イベントループ
while True:
    frug = 0
    no = 0
    tounyoufrug = 0
    jinzoufrug = 0
    sisituijoufrug = 0
    kouketufrug = 0
    firstloop2 = False
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == '終了':
        print('プログラムが終了しました。')
        quit()
    
    elif event == '-Btn-':
            firstloop2 = False
            if values['normal2'] == True:
                firstloop2 = True
                no = 1
                frug +=1
                #break
            if values['tounyou'] == True:
                tounyoufrug = 1
                frug +=1
                #print('糖尿病')
                firstloop2 = True
            if values['jinzou'] == True:
                jinzoufrug = 1
                frug +=1
                #print('腎臓病')
                firstloop2 = True
            if values['sisituijou'] == True:
                sisituijoufrug = 1
                frug +=1
                #print('脂質異常症')
                firstloop2 = True
            if values['kouketu'] == True:
                kouketufrug = 1
                frug +=1
                #print('高血圧')
                firstloop2 = True
            #最後に回答されているか判定
            if no == 1 and frug == 1:
                print("制限食はないですね")
                tounyoufrug = 0
                jinzoufrug = 0
                sisituijoufrug = 0
                kouketufrug = 0
                break
            if frug > 1:
                sg.popup_ok("回答は一つにしてください")
                print(frug)
                continue
            if not firstloop2:
                sg.popup_ok('回答してください')  # ポップアップを表示
                continue #whileの一番上に移動
            if firstloop2 == True:#firstloopフラグがTrueならウィンドウを閉じる
                break
window.close()

# print("糖尿病"+str(tounyoufrug))
# print("腎臓病"+str(jinzoufrug))
# print("脂質異常症"+str(sisituijoufrug))
# print("高血圧"+str(kouketufrug))

########################################制限食の設定おわり###########################################################

########################################ここから出力する日数の設定####################################################
# ウィンドウに配置するコンポーネント
layout5 = [
    [sg.Text('出力する日数を入力してください(1~7)'),sg.InputText(default_text='1',size=(10, 1), key='day')],
    [sg.Text('朝食の準備にかける時間を入力してください'),sg.InputText(default_text='30',size=(10, 1), key='timea')],
    [sg.Text('昼食の準備にかける時間を入力してください'),sg.InputText(default_text='60',size=(10, 1), key='timeb')],
    [sg.Text('夕食の準備にかける時間を入力してください'),sg.InputText(default_text='60',size=(10, 1), key='timec')],
    [sg.Button('決定'),sg.Button('終了')]
]

window = sg.Window('日数設定', layout5)# ウィンドウの生成

# イベントループ
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == '終了':
        print('プログラムが終了しました。')
        quit()
    
    elif event == '決定':
        try:
            day = int(values['day'])
            timea = int(values['timea'])
            timeb = int(values['timeb'])
            timec = int(values['timec'])

            if not(1<= day <=7):#出力する日数の入力値が1~7以外の場合の処理
                sg.popup_ok('日数が間違っています。(1~7で入力してください)')  # ポップアップを表示
                continue
            if not(0 <= timea) or not(0 <= timeb) or not(0 <= timec):# かける時間にマイナスの値が入力された時の処理
                sg.popup_ok('時間が間違っています。整数で入力してください')  # ポップアップを表示
                continue
            break
        except:
            sg.popup_ok('数字を入力してください')  # ポップアップを表示
            continue
window.close()

########################################出力する日数の設定おわり###############################################################################
print("レシピデータを作成します")
########################################ここからレシピのデータベースの作成######################################################################
gen = 10
#レシピの番号i
i = list(range(R))
#食材の数Q
Q = 0

#栄養素の数N
N = 0
#レシピナンバー
recinoi = list(range(R))

#レシピの名前yi
yi = list(range(R))
#調理時間Ti
Ti = list(range(R))
#主菜フラグsigmai
sigmai = list(range(R))
#摂取カロリーCi
Ci = list(range(R))
#コストGi
Gi = list(range(R))
#材料量e
eij = [['' for i in range(25)] for j in range(R)]
#栄養素名nij
nij = [['' for i in range(25)] for j in range(R)]
#栄養素量fij
fij = [['' for i in range(25)] for j in range(R)]

mf = list(range(R))

#vはcsvから入手する用の変数
v = list(range(25))
Nm = 0
Qm = 0
for j in i:

    #if(j==0):
        #continue
    #################################################################################################
    df = pd.read_csv("../recipe_data/recipe_no"+ str(j+1) +".csv",encoding="cp932")
    #################################################################################################
    
    for m in v:
	#ilocは行と列を指定することによりその値を抽出できる
    #CSVから栄養素、食材を読み込み
        eij[j][m] = df.iloc[m,5]
        #栄養素名nij
        nij[j][m] = df.iloc[m,6]
        #栄養素量fij
        fij[j][m] = df.iloc[m,7]
        
        #データの成型（数値しか入らないように単位を消す、単位をそろえる）
        if ('mg' in fij[j][m]):
            fij[j][m] = fij[j][m].replace('mg','')
            fij[j][m] = fij[j][m].replace(',','.')
            fij[j][m] = str(fij[j][m])

        if ('μg' in fij[j][m]):#
            fij[j][m] = fij[j][m].replace('μg','')
            fij[j][m] = fij[j][m].replace(',','.')
            fij[j][m] = str(fij[j][m])
        
        if ('g' in fij[j][m]):
            fij[j][m] = fij[j][m].replace('g','')
            fij[j][m] = fij[j][m].replace(',','.')
            fij[j][m] = str(fij[j][m])

        
        fij[j][m] = float(fij[j][m])
        yi[j] = df.iloc[1,0]
        Gi[j] = df.iloc[1,8]
        Ti[j] = df.iloc[1,2]
        sigmai[j] = df.iloc[1,1]
        Ci[j] = df.iloc[1,3]
        
        N = N + 1
        ###mf朝食フラグ
        mf[j] = df.iloc[1,9]
        ###############################################################
        
        #NANじゃなかったら食材数を数える
        if not qij[j][m]=="NAN":
            Q = Q + 1        


#辞書データの作成
dict1 = {'レシピNo':i,"レシピの名前":yi,"主菜フラグ":sigmai,"調理時間":Ti,"摂取カロリー":Ci,"コスト":Gi}
#レシピデータのデータフレーム作成
df_reci = pd.DataFrame(data = dict1)
#栄養素のデータフレーム作成
df_fij = pd.DataFrame(data = fij,columns = ['たんぱく質',
'炭水化物','糖質','脂質','食塩相当量',
'食物繊維','ビタミンA','ビタミンB1','ビタミンB2','ビタミンB6',
'ビタミンB12','ビタミンC','ビタミンD','ビタミンE','ビタミンK',
'カリウム','カルシウム','鉄','葉酸','マグネシウム','リン','亜鉛',
'パントテン酸','銅','マンガン'])

df_recipe = df_reci.join(df_fij)#df_recipeは料理名と栄養素の名前が入っているdataframe
#print("レシピデータ:")
#print(df_recipe)
df_recipe.to_csv('recipedata.csv', encoding="shift_jis",errors='ignore', index=False) #レシピデータをcsvに保存(確認用)
df_recipe['献立フラグ'] = addvars(len(df_recipe))

if arerugi:#アレルギーの配列に数字が入ってる場合実行
    df_recipe =df_recipe.drop(arerugi)#アレルギーの配列に入ってる数字を削除
    print("アレルギーを削除した後のレシピデータ:")
    R = len(df_recipe.index)#データ数の変更
    print("データ数R:")
    print(R)
    yi = df_recipe['レシピの名前'].values.tolist()#レシピの名前を変更
    Gi = df_recipe['コスト'].values.tolist()#コストを変更
    Ti = df_recipe['調理時間'].values.tolist()#調理時間を変更
    sigmai = df_recipe['主菜フラグ'].values.tolist()#主菜フラグを変更
    Ci = df_recipe['摂取カロリー'].values.tolist()#摂取カロリーを変更
    mf = list(range(R))
    print('カロリーの個数'+ str(len(Ci)))
    df_recipe.to_csv('recipedata2.csv', encoding="shift_jis",errors='ignore', index=False)


#最適化に使う各栄養素をリスト化する
f0j = df_recipe['たんぱく質'].values.tolist()#g
f1j = df_recipe['脂質'].values.tolist()#g
f2j = df_recipe['炭水化物'].values.tolist()#g
f3j = df_recipe['糖質'].values.tolist()#g
f4j = df_recipe['食塩相当量'].values.tolist()#g
f5j = df_recipe['食物繊維'].values.tolist()#g
f6j = df_recipe['ビタミンA'].values.tolist()#μg
f7j = df_recipe['ビタミンB1'].values.tolist()#mg
f8j = df_recipe['ビタミンB2'].values.tolist()#mg
f9j = df_recipe['ビタミンB6'].values.tolist()#mg
f10j = df_recipe['ビタミンB12'].values.tolist()#μg
f11j = df_recipe['ビタミンC'].values.tolist()#mg
f12j = df_recipe['ビタミンD'].values.tolist()#μg
f13j = df_recipe['ビタミンE'].values.tolist()#mg
f14j = df_recipe['ビタミンK'].values.tolist()#μg
f15j = df_recipe['カリウム'].values.tolist()#mg
f16j = df_recipe['カルシウム'].values.tolist()#mg
f17j = df_recipe['鉄'].values.tolist()#mg
f18j = df_recipe['葉酸'].values.tolist()#μg
f19j = df_recipe['マグネシウム'].values.tolist()#mg
f20j = df_recipe['リン'].values.tolist()#mg
f21j = df_recipe['亜鉛'].values.tolist()#mg
f22j = df_recipe['パントテン酸'].values.tolist()#mg
f23j = df_recipe['銅'].values.tolist()#mg
f24j = df_recipe['マンガン'].values.tolist()#mg

for h in range(len(f0j)):
    f0j[0] = 0
    f1j[0] = 0
    f2j[0] = 0
    f3j[0] = 0
    f4j[0] = 0
    f5j[0] = 0
    f6j[0] = 0
    f7j[0] = 0
    f8j[0] = 0
    f9j[0] = 0
    f10j[0] = 0
    f11j[0] = 0
    f12j[0] = 0
    f13j[0] = 0
    f14j[0] = 0
    f15j[0] = 0
    f16j[0] = 0
    f17j[0] = 0
    f18j[0] = 0
    f19j[0] = 0
    f20j[0] = 0
    f21j[0] = 0
    f22j[0] = 0
    f23j[0] = 0
    f24j[0] = 0


#ゴミとり
for g in range(len(Ci)):
    Ci[g] = str(Ci[g]).replace(',', '')
    Ci[g] = int(Ci[g])

#それぞれのリストをnp配列に変換
Gi = np.array(Gi)
Ti = np.array(Ti)
Ci = np.array(Ci)
f0j = np.array(f0j)
f1j = np.array(f1j)
f2j = np.array(f2j)
f3j = np.array(f3j)
f4j = np.array(f4j)
f5j = np.array(f5j)
f6j = np.array(f6j)
f7j = np.array(f7j)
f8j = np.array(f8j)
f9j = np.array(f9j)
f10j = np.array(f10j)
f11j = np.array(f11j)
f12j = np.array(f12j)
f13j = np.array(f13j)
f14j = np.array(f14j)
f15j = np.array(f15j)
f16j = np.array(f16j)
f17j = np.array(f17j)
f18j = np.array(f18j)
f19j = np.array(f19j)
f20j = np.array(f20j)
f21j = np.array(f21j)
f22j = np.array(f22j)
f23j = np.array(f23j)
f24j = np.array(f24j)
sigmai = np.array(sigmai)
mf = np.array(mf)

print("データ作成完了\n")
#################ここまでcsvからレシピのデータベースを作成####################################################



#################ここからnsga2の変数設定#####################################################################
#client = Client("tcp://192.168.11.2:8786")

#必要推定エネルギー量
eer = pd_login.iloc[0,8]
#必要タンパク質
rtanpaku = pd_login.iloc[0,9]
#必要脂質
rsisitu = pd_login.iloc[0,10]
#必要炭水化物
rtansui = pd_login.iloc[0,11]

#Subsetproblemは組み合わせ最適化問題を用いるときに使うclass
#problem = SubsetProblem(Ti, n_max,c_max,Gi,Ci,f0j,f1j,f2j,sigmai,mf,eer,rtanpaku,rsisitu,rtansui)
class SubsetProblem(ElementwiseProblem):
    def __init__(self,
                 T,
                 n_max,
                 c_max,
                 cost,
                 cal,
                 f0,
                 f1,
                 f2,
                 sigmai,
                 mf,
                 day,
                 timea,
                 timeb,
                 timec,
                 eer,
                 tanpakumin,
                 sisitumin,
                 tansuimin,
                 elementwise_evaluation=True,
                 *args,
                 **kwargs
                 ):
        super().__init__(n_var=len(T),# 入力変数の次元(選ぶレシピの数)
                         n_obj=2,# 目的関数の数
                        n_constr=13,# 制約条件の数
                        *args,#*argsは複数の因数をタプルとして受け取る。
                        **kwargs)#**kwargsは複数の値を辞書（ディクショナリ）として受け取る
        
    #関数内で使用する変数の設定 
    #T時間,#nmax選ぶレシピの数,c_max,COSTコスト,Cカロリー,f0タンパク質,f1脂質,f2炭水化物,sigmai主菜フラグ,mf必要栄養素の変数
    #eer推定エネルギー,tanpakumin必要タンパク質,sisitumin必要脂質,tansuimin必要炭水化物の変数
        self.T = T
        self.n_max = n_max
        self.c_max = c_max
        self.cost = cost
        self.cal = cal
        self.f0 = f0
        self.f1 = f1
        self.f2 = f2
        self.sigmai = sigmai
        self.mf = mf
        self.day = day
        self.timea = timea
        self.timeb = timeb
        self.timec = timec
        self.eer = eer
        self.tanpakumin = tanpakumin,
        self.sisitumin = sisitumin,
        self.tansuimin = tansuimin,

    def _evaluate(self, x, out, *args, **kwargs):
        #目的関数、制約条件の定義とそれに使う変数の定義
        #必要タンパク質
        f0jmin = rtanpaku #70

    	#必要脂質 
        f1jmin = rsisitu #38

    	#必要炭水化物
        f2jmin = rtansui #283
        f0jmax = 100
        f1jmax = 100
        f2jmax = 300
        
        #必要カロリーとカロリーの最大値
        calmax = 2500
        calmin = 2000
        calmin = eer - 100 #2500
        calmax = eer + 400 #3000
        #最大時間
        timemax1 = timea#朝
        timemax2 = timeb#昼
        timemax3 = timec#夜
        #コスト,カロリー,たんぱく質,脂質,炭水化物の初期値設定
        cost1 = 0
        cal1 = 0
        tanpaku1 = 0
        sisitu1 = 0
        tansui1 = 0

        p = list(range(200))
        #f1は選んだレシピの時間の合計
        f1 = np.sum(self.T[x])
        #f2は選んだレシピのコストの合計
        f2 = np.sum(self.cost[x])
        #gnはxの選ぶ個数(49個)
        gn = self.n_max - np.sum(x)

        #朝の調理時間
        time1 = self.T[x][0]
        #昼の調理時間の合計
        time2 = self.T[x][1] + self.T[x][2] + self.T[x][3]
        #夜の調理時間の合計
        time3 = self.T[x][4] + self.T[x][5] + self.T[x][6]

        
        for i in range(7):
            #1日のたんぱく質の合計
            tanpaku1 += self.f0[x][i]
            #1日の脂質の合計
            sisitu1 += self.f1[x][i]
            #1日の炭水化物の合計
            tansui1 += self.f2[x][i]
            #1日のカロリーの合計
            cal1 += self.cost[x][i]
            #1日のコストの合計
            cost1 += self.cost[x][i]
        

        #p[0] = 24 - np.sum(self.sigmai[x])
        #p[1] = np.sum(self.sigmai[x]) - 30
        #f0min - tanpaku1 <=0 → f0min(必要タンパク質) <tanpaku
        p[2] = f0jmin - tanpaku1

        #f1min - sisitu1 <=0 → f1min(必要脂質) <sisitu
        p[3] = f1jmin - sisitu1

        #f2min - tansui <=0 → f2min(必要炭水化物) <tansui
        p[4] = f2jmin - tansui1

        #cmin - cost1 <=0 → cmin(必要カロリー) < cost1
        p[5] = calmin - cal1
        
        #time1 - timemax1 <=0 → time1 <timemax1(時間の最大値,45)
        p[6] = time1 - timemax1

        #time2 - tomemax2 <=0 → time2 <timemax2(時間の最大値2,60)
        p[7] = time2 - timemax2

        p[8] = time3 - timemax3

        #1- self.sigmai[x][0] <=0 →  1<=self.sigmai[x][0] 昼の1品目の主菜フラグが1
        p[9] = 1 - self.sigmai[x][1]

        #self.sigmai[x][0] -0.5<= 0 →  self.sigmai[x][0]<=0.5 昼の2品目と3品目の主菜フラグが0
        p[10] = self.sigmai[x][2] - 0.5
        p[11] = self.sigmai[x][3] - 0.5

        #cal1 - cmax < 0 → cal1< cmax(カロリーの最大摂取量) 
        p[12] = cal1 - calmax

        #1 - self.mf[x][0]<=0 → 1 <= self.mf[x][0] 朝食のフラグが1になる
        p[13] = 1 - self.mf[x][0]

        out["F"] = [f1,f2]#二つの目的関数,コスト,時間の合計
        out["G"] = [#p[1],
        #p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],
        p[13]
                    ]

#サンプリングは、サブセット制約が常に満たされるランダムなソリューションを作成する
class MySampling(Sampling):

    def _do(self, problem, n_samples, **kwargs):
        X = np.full((n_samples, problem.n_var), False, dtype=bool)

        for k in range(n_samples):
            I = np.random.permutation(problem.n_var)[:problem.n_max]
            X[k, I] = True

        return X

#クロスオーバーは両方の親の値を取得し、十分な数が選択されるまで、最初または 2 番目の親からいずれかをランダムに選択します。
class BinaryCrossover(Crossover):
    def __init__(self):
        super().__init__(2, 1)

    def _do(self, problem, X, **kwargs):
        n_parents, n_matings, n_var = X.shape

        _X = np.full((self.n_offsprings, n_matings, problem.n_var), False)

        for k in range(n_matings):
            p1, p2 = X[0, k], X[1, k]

            both_are_true = np.logical_and(p1, p2)
            _X[0, k, both_are_true] = True

            n_remaining = problem.n_max - np.sum(both_are_true)

            I = np.where(np.logical_xor(p1, p2))[0]

            S = I[np.random.permutation(len(I))][:n_remaining]
            _X[0, k, S] = True

        return _X

#ミューテーションはランダムに数字を削除し、別の数字を選択します。
class MyMutation(Mutation):
    def _do(self, problem, X, **kwargs):
        for i in range(X.shape[0]):
            X[i, :] = X[i, :]
            is_false = np.where(np.logical_not(X[i, :]))[0]
            is_true = np.where(X[i, :])[0]
            X[i, np.random.choice(is_false)] = True
            X[i, np.random.choice(is_true)] = False

        return X

# create the actual problem to be solved
np.random.seed(1)
cvavg = list()
cvmin = list()

Gi = np.array(Gi)
Ti = np.array(Ti)
Ci = np.array(Ci)
f0j = np.array(f0j)
f1j = np.array(f1j)
f2j = np.array(f2j)
###############################################################
n_max = 7*day#nmaxはレシピの数(1日7品,７日分で49個)
###############################################################
c_max = 300

problem = SubsetProblem(Ti, n_max,c_max,Gi,Ci,f0j,f1j,f2j,sigmai,mf,day,timea,timeb,timec,eer,rtanpaku,rsisitu,rtansui)
#problem = SubsetProblem(Ti, n_max,c_max,Gi,Ci,f0j,f1j,f2j,sigmai,parallelization=("dask",client))

#################ここまでnsga2の変数設定#####################################################################
algorithm = NSGA2(
    pop_size=R,
    sampling=MySampling(),
    crossover=BinaryCrossover(),
    mutation=MyMutation(),
    eliminate_duplicates=True)

res = minimize(problem,
               algorithm,
               ('n_gen',gen),
               seed=1,
               #display=MyDisplay(),
               verbose=True)

#np.set_printoptions()でnpの表示数の設定している。
#threshold=np.inf(無限大)で常に省略されずすべての要素が表示される。
np.set_printoptions(threshold=np.inf)
#print('res.x')
#print(res.X)
print(f'nomaltime:{res.exec_time}秒')
print('res.F')
print(res.F)


T_all = list(range(len(res.F)))
G_all = list(range(len(res.F)))


print('res.f')
print(res.F)
Scatter().add(res.F).show()

#Scatter().add(a).show()

#正規化の関数,引数keepdims=Trueとすることで次元が保持されるのでそのまま加算減算が可能。
# 二次元配列用の関数は一次元配列に対しても使える。
def min_max(x, axis=None):
    min = x.min(axis=axis, keepdims=True)
    max = x.max(axis=axis, keepdims=True)
    result = (x-min)/(max-min)
    return result



for i in range(len(res.F)):
    T_all[i] = res.F[i][0]
    G_all[i] = res.F[i][1]

print("T_all")
print(T_all)
print("G_all")
print(G_all)

T_all = [int(i) for i in T_all]
G_all = [int(i) for i in G_all]
# T_all = np.array(T_all)
# G_all = np.array(G_all)

# T_all = min_max(T_all)
# G_all = min_max(G_all)

# print("正規化後T_all")
# print(T_all)
# print("正規化後G_all")
# print(G_all)

####################################献立の候補を表示するコード########################################################
layout6 = [
    [sg.Text('献立の候補が'+(str(len(T_all)))+'個見つかりました')],
]

for i in range(len(T_all)):#候補を追加するコード
    kouho = [
        [sg.Text('候補'+str(i+1)+': 時間:'+str(T_all[i])+'分,コスト:'+str(G_all[i])+'円')],
    ]
    layout6 += kouho

layout7 = [
    [sg.Text('番号を入力してください(1~'+(str(len(T_all)))+')'),sg.InputText(default_text='1',size=(10, 1), key='bango')],
    [sg.Button('決定'),sg.Button('終了')]
]

layout6 += layout7

window = sg.Window('候補の設定', layout6)# ウィンドウの生成

# イベントループ
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == '終了':
        print('プログラムが終了しました。')
        quit()
    
    elif event == '決定':
        try:
            gga = int(values['bango'])

            if not(1<= gga <=int(len(T_all))):#出力する日数の入力値が1~7以外の場合の処理
                sg.popup_ok('番号が間違っています。(1~'+str(len(T_all))+'で入力してください)')  # ポップアップを表示
                continue
            break
        except:
            sg.popup_ok('数字を入力してください')  # ポップアップを表示
            continue
window.close()



gga2 = int(gga)-1
number = list()

#最適化された献立の番号をnumberの配列に入れる
for c in range(R):#レシピ数
    if res.X[gga2][c] == True:
        number.append(c)

print('レシピnumber')
print(number)
#quit()
# for d in range(len(number)):
#     print("=====================================================")
#     print("No" + str(int(number[d]))+ "のレシピ名は"+str(yi[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の調理時間は"+str(Ti[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取カロリーは"+str(Ci[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取たんぱく質は"+str(f0j[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取脂質は"+str(f1j[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取炭水化物は"+str(f2j[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取糖質は"+str(f3j[int(number[d])]))

#     print("=====================================================")


dfh = pd.read_csv("../howto_data/howto.csv",encoding="cp932",usecols=[2])#作り方
dfn = pd.read_csv("../howto_data/howto.csv",encoding="cp932",usecols=[1])#名前
dfr = pd.read_csv("../howto_data/howto.csv",encoding="cp932",usecols=[0])#no
dfg = pd.read_csv("../howto_data/howto.csv",encoding="cp932",usecols=[3])#画像

how2 = dfh['作り方'].to_list()
#print(how)
rname = dfn['レシピの名前'].to_list()
#print(rname)
gazo2 = dfg['画像'].to_list()
#print(gazo)
gazo = []
how = []
for i in range(len(number)):
    howtonum = rname.index(str(yi[int(number[i])]))
    how.append(how2[howtonum])
    gazonum = rname.index(str(yi[int(number[i])]))
    gazo.append(gazo2[howtonum])

# print("how")
# print(how)
# print("gazo")
# print(gazo)

def checkURL(urls):#URLが有効ならそのまま、有効でなければ違うurlに書き換える関数
    for i, url in enumerate(urls):
        try:
            f = urllib.request.urlopen(url)
            f.close()
        except:
            urls[i] = "noimage.jpg"

# print("mae")
# print(gazo)
checkURL(gazo)
# print("ato")
# print(gazo)


################################# htmlの出力画面のコード#################################################

html1 = """
<!DOCTYPE html>
<html lang="ja">
    <head>
        <title>テスト</title>
        <meta charset="utf-8"/>
        <style>
            .flex {
              display: flex;
            }
          </style>
        
    </head>
    <body　bgcolor="lightyellow">
        <h1>朝食</h1>
        <h2>{{mtitle}}</h2>
        <table border=0>
            <tr>
            <td>
            <img src={{mgazo}} width="300" height="200">
            </td>
            <td valign="top">
            <table border="1" width=300 height=100 align="left">
            <tr>
            <th>調理時間</th><th>摂取カロリー</th><th>食材コスト</th>
            </tr>
            <tr>
            <td>{{mtime}}分</td><td>{{mcalo}}kcal</td><td>{{mcost}}円</td>
            </tr>
            </table>
            </td>
        </table>

        <div class="flex">
            <table border="1">
                <tr>
                  <th>栄養名</th>
                  <th>栄養素量</th>
                </tr>
                <tr>
                  <td>たんぱく質</td>
                  <td>{{mf0}}g</td>
                </tr>
                <tr>
                  <td>脂質</td>
                  <td>{{mf1}}g</td>
                </tr>
                <tr>
                    <td>炭水化物</td>
                    <td>{{mf2}}g</td>
                </tr>
                <tr>
                    <td>糖質</td>
                    <td>{{mf3}}g</td>
                </tr>
                <tr>
                    <td>食塩相当量</td>
                    <td>{{mf4}}g</td>
                </tr>
                <tr>
                    <td>食物繊維</td>
                    <td>{{mf5}}g</td>
                  </tr>
                  <tr>
                      <td>ビタミンA</td>
                      <td>{{mf6}}mg</td>
                  </tr>
                  <tr>
                      <td>ビタミンB1</td>
                      <td>{{mf7}}mg</td>
                  </tr>
                  <tr>
                      <td>ビタミンB2</td>
                      <td>{{mf8}}mg</td>
                  </tr>
                  
                  <tr>
                    <td>ビタミンB6</td>
                    <td>{{mf9}}mg</td>
                  </tr>
                  <tr>
                      <td>ビタミンB12</td>
                      <td>{{mf10}}μg</td>
                  </tr>
                  <tr>
                      <td>ビタミンC</td>
                      <td>{{mf11}}mg</td>
                  </tr>
                  <tr>
                      <td>ビタミンD</td>
                      <td>{{mf12}}μg</td>
                  </tr>
                  <tr>
                    <td>ビタミンE</td>
                    <td>{{mf13}}mg</td>
                  </tr>
                  <tr>
                      <td>ビタミンK</td>
                      <td>{{mf14}}μg</td>
                  </tr>
                  <tr>
                      <td>カリウム</td>
                      <td>{{mf15}}mg</td>
                  </tr>
                  <tr>
                      <td>カルシウム</td>
                      <td>{{mf16}}mg</td>
                  </tr>
                  <tr>
                    <td>鉄</td>
                    <td>{{mf17}}mg</td>
                  </tr>
                  <tr>
                      <td>葉酸</td>
                      <td>{{mf18}}μg</td>
                  </tr>
                  <tr>
                      <td>マグネシウム</td>
                      <td>{{mf19}}mg</td>
                  </tr>
                  <tr>
                      <td>リン</td>
                      <td>{{mf20}}mg</td>
                  </tr>
                  <tr>
                    <td>亜鉛</td>
                    <td>{{mf21}}mg</td>
                  
    
          
            </table>
    
            <table border="1">
                <tr>
                    <th>食材名</th>
                    <th>食材量</th>
                </tr>
                <tr> <td>{{mq0}}</td> <td>{{me0}}</td> </tr>
                <tr> <td>{{mq1}}</td> <td>{{me1}}</td> </tr>
                <tr> <td>{{mq2}}</td> <td>{{me2}}</td> </tr>
                <tr> <td>{{mq3}}</td> <td>{{me3}}</td> </tr>
                <tr> <td>{{mq4}}</td> <td>{{me4}}</td> </tr>
                <tr> <td>{{mq5}}</td> <td>{{me5}}</td> </tr>
                <tr> <td>{{mq6}}</td> <td>{{me6}}</td> </tr>
                <tr> <td>{{mq7}}</td> <td>{{me7}}</td> </tr>
                <tr> <td>{{mq8}}</td> <td>{{me8}}</td> </tr>
                <tr> <td>{{mq9}}</td> <td>{{me9}}</td> </tr>
                <tr> <td>{{mq10}}</td> <td>{{me10}}</td> </tr>
                <tr> <td>{{mq11}}</td> <td>{{me11}}</td> </tr>
                <tr> <td>{{mq12}}</td> <td>{{me12}}</td> </tr>
                <tr> <td>{{mq13}}</td> <td>{{me13}}</td> </tr>
                <tr> <td>{{mq14}}</td> <td>{{me14}}</td> </tr>
                <tr> <td>{{mq15}}</td> <td>{{me15}}</td> </tr>
                <tr> <td>{{mq16}}</td> <td>{{me16}}</td> </tr>
                <tr> <td>{{mq17}}</td> <td>{{me17}}</td> </tr>
                <tr> <td>{{mq18}}</td> <td>{{me18}}</td> </tr>
                <tr> <td>{{mq19}}</td> <td>{{me19}}</td> </tr>
                <tr> <td>{{mq20}}</td> <td>{{me20}}</td> </tr>
                <tr> <td>{{mq21}}</td> <td>{{me21}}</td> </tr>
                <tr> <td>{{mq22}}</td> <td>{{me22}}</td> </tr>
                <tr> <td>{{mq23}}</td> <td>{{me23}}</td> </tr>
                <tr> <td>{{mq24}}</td> <td>{{me24}}</td> </tr>
    
            </table>

            <table border="1" width=450 height=100>
                <tr>
                  <th>作り方</th>
                </tr>
                <tr>
                  <td>{{mhow}}</td>
                </tr>
            </tr>
            </table>
          </div>




        <h1>昼食</h1>
        <h2>{{l1title}}</h2>
        
        <table border=0>
            <tr>
            <td>
            <img src={{l1gazo}} width="300" height="200">
            </td>
            <td valign="top">
            <table border="1" width=300 height=100 align="left">
            <tr>
            <th>調理時間</th><th>摂取カロリー</th><th>食材コスト</th>
            </tr>
            <tr>
            <td>{{l1time}}分</td><td>{{l1calo}}kcal</td><td>{{l1cost}}円</td>
            </tr>
            </table>
            </td>
        </table>
            
        <div class="flex">
        <table border="1">
            <tr>
              <th>栄養名</th>
              <th>栄養素量</th>
            </tr>
            <tr>
              <td>たんぱく質</td>
              <td>{{l1f0}}g</td>
            </tr>
            <tr>
              <td>脂質</td>
              <td>{{l1f1}}g</td>
            </tr>
            <tr>
                <td>炭水化物</td>
                <td>{{l1f2}}g</td>
            </tr>
            <tr>
                <td>糖質</td>
                <td>{{l1f3}}g</td>
            </tr>
            <tr>
                <td>食塩相当量</td>
                <td>{{l1f4}}g</td>
            </tr>
            <tr>
                <td>食物繊維</td>
                <td>{{l1f5}}g</td>
              </tr>
              <tr>
                  <td>ビタミンA</td>
                  <td>{{l1f6}}μg</td>
              </tr>
              <tr>
                  <td>ビタミンB1</td>
                  <td>{{l1f7}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンB2</td>
                  <td>{{l1f8}}mg</td>
              </tr>
              
              <tr>
                <td>ビタミンB6</td>
                <td>{{l1f9}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンB12</td>
                  <td>{{l1f10}}μg</td>
              </tr>
              <tr>
                  <td>ビタミンC</td>
                  <td>{{l1f11}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンD</td>
                  <td>{{l1f12}}μg</td>
              </tr>
              <tr>
                <td>ビタミンE</td>
                <td>{{l1f13}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンK</td>
                  <td>{{l1f14}}μg</td>
              </tr>
              <tr>
                  <td>カリウム</td>
                  <td>{{l1f15}}mg</td>
              </tr>
              <tr>
                  <td>カルシウム</td>
                  <td>{{l1f16}}mg</td>
              </tr>
              <tr>
                <td>鉄</td>
                <td>{{l1f17}}mg</td>
              </tr>
              <tr>
                  <td>葉酸</td>
                  <td>{{l1f18}}μg</td>
              </tr>
              <tr>
                  <td>マグネシウム</td>
                  <td>{{l1f19}}mg</td>
              </tr>
              <tr>
                  <td>リン</td>
                  <td>{{l1f20}}mg</td>
              </tr>
              <tr>
                <td>亜鉛</td>
                <td>{{l1f21}}mg</td>
              </tr>
              <tr>
                  <td>パントテン酸</td>
                  <td>{{l1f22}}mg</td>
              </tr>
              <tr>
                  <td>銅</td>
                  <td>{{l1f23}}mg</td>
              </tr>
              <tr>
                  <td>マンガン</td>
                  <td>{{l1f24}}mg</td>
              </tr>

      
        </table>

        <table border="1">
            <tr>
                <th>食材名</th>
                <th>食材量</th>
            </tr>
            <tr> <td>{{l1q0}}</td> <td>{{l1e0}}</td> </tr>
            <tr> <td>{{l1q1}}</td> <td>{{l1e1}}</td> </tr>
            <tr> <td>{{l1q2}}</td> <td>{{l1e2}}</td> </tr>
            <tr> <td>{{l1q3}}</td> <td>{{l1e3}}</td> </tr>
            <tr> <td>{{l1q4}}</td> <td>{{l1e4}}</td> </tr>
            <tr> <td>{{l1q5}}</td> <td>{{l1e5}}</td> </tr>
            <tr> <td>{{l1q6}}</td> <td>{{l1e6}}</td> </tr>
            <tr> <td>{{l1q7}}</td> <td>{{l1e7}}</td> </tr>
            <tr> <td>{{l1q8}}</td> <td>{{l1e8}}</td> </tr>
            <tr> <td>{{l1q9}}</td> <td>{{l1e9}}</td> </tr>
            <tr> <td>{{l1q10}}</td> <td>{{l1e10}}</td> </tr>
            <tr> <td>{{l1q11}}</td> <td>{{l1e11}}</td> </tr>
            <tr> <td>{{l1q12}}</td> <td>{{l1e12}}</td> </tr>
            <tr> <td>{{l1q13}}</td> <td>{{l1e13}}</td> </tr>
            <tr> <td>{{l1q14}}</td> <td>{{l1e14}}</td> </tr>
            <tr> <td>{{l1q15}}</td> <td>{{l1e15}}</td> </tr>
            <tr> <td>{{l1q16}}</td> <td>{{l1e16}}</td> </tr>
            <tr> <td>{{l1q17}}</td> <td>{{l1e17}}</td> </tr>
            <tr> <td>{{l1q18}}</td> <td>{{l1e18}}</td> </tr>
            <tr> <td>{{l1q19}}</td> <td>{{l1e19}}</td> </tr>
            <tr> <td>{{l1q20}}</td> <td>{{l1e20}}</td> </tr>
            <tr> <td>{{l1q21}}</td> <td>{{l1e21}}</td> </tr>
            <tr> <td>{{l1q22}}</td> <td>{{l1e22}}</td> </tr>
            <tr> <td>{{l1q23}}</td> <td>{{l1e23}}</td> </tr>
            <tr> <td>{{l1q24}}</td> <td>{{l1e24}}</td> </tr>

        </table>
        
        <table border="1" width=450 height=100 >
            <tr>
              <th>作り方</th>
            </tr>
            <tr>
              <td>{{l1how}}</td>
            </tr>
        </tr>
        </table>
    </div>

<h2>{{l2title}}</h2>
        
        <table border=0>
            <tr>
            <td>
            <img src={{l2gazo}} width="300" height="200">
            </td>
            <td valign="top">
            <table border="1" width=300 height=100 align="left">
            <tr>
            <th>調理時間</th><th>摂取カロリー</th><th>食材コスト</th>
            </tr>
            <tr>
            <td>{{l2time}}分</td><td>{{l2calo}}kcal</td><td>{{l2cost}}円</td>
            </tr>
            </table>
            </td>
        </table>
            
        <div class="flex">
        <table border="1">
            <tr>
              <th>栄養名</th>
              <th>栄養素量</th>
            </tr>
            <tr>
              <td>たんぱく質</td>
              <td>{{l2f0}}g</td>
            </tr>
            <tr>
              <td>脂質</td>
              <td>{{l2f1}}g</td>
            </tr>
            <tr>
                <td>炭水化物</td>
                <td>{{l2f2}}g</td>
            </tr>
            <tr>
                <td>糖質</td>
                <td>{{l2f3}}g</td>
            </tr>
            <tr>
                <td>食塩相当量</td>
                <td>{{l2f4}}g</td>
            </tr>
            <tr>
                <td>食物繊維</td>
                <td>{{l2f5}}g</td>
              </tr>
              <tr>
                  <td>ビタミンA</td>
                  <td>{{l2f6}}μg</td>
              </tr>
              <tr>
                  <td>ビタミンB1</td>
                  <td>{{l2f7}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンB2</td>
                  <td>{{l2f8}}mg</td>
              </tr>
              
              <tr>
                <td>ビタミンB6</td>
                <td>{{l2f9}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンB12</td>
                  <td>{{l2f10}}μg</td>
              </tr>
              <tr>
                  <td>ビタミンC</td>
                  <td>{{l2f11}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンD</td>
                  <td>{{l2f12}}μg</td>
              </tr>
              <tr>
                <td>ビタミンE</td>
                <td>{{l2f13}}mg</td>
              </tr>
              <tr>
                  <td>ビタミンK</td>
                  <td>{{l2f14}}μg</td>
              </tr>
              <tr>
                  <td>カリウム</td>
                  <td>{{l2f15}}mg</td>
              </tr>
              <tr>
                  <td>カルシウム</td>
                  <td>{{l2f16}}mg</td>
              </tr>
              <tr>
                <td>鉄</td>
                <td>{{l2f17}}mg</td>
              </tr>
              <tr>
                  <td>葉酸</td>
                  <td>{{l2f18}}μg</td>
              </tr>
              <tr>
                  <td>マグネシウム</td>
                  <td>{{l2f19}}mg</td>
              </tr>
              <tr>
                  <td>リン</td>
                  <td>{{l2f20}}mg</td>
              </tr>
              <tr>
                <td>亜鉛</td>
                <td>{{l2f21}}mg</td>
              </tr>
              <tr>
                  <td>パントテン酸</td>
                  <td>{{l2f22}}mg</td>
              </tr>
              <tr>
                  <td>銅</td>
                  <td>{{l2f23}}mg</td>
              </tr>
              <tr>
                  <td>マンガン</td>
                  <td>{{l2f24}}mg</td>
              </tr>

      
        </table>

        <table border="1">
            <tr>
                <th>食材名</th>
                <th>食材量</th>
            </tr>
            <tr> <td>{{l2q0}}</td> <td>{{l2e0}}</td> </tr>
            <tr> <td>{{l2q1}}</td> <td>{{l2e1}}</td> </tr>
            <tr> <td>{{l2q2}}</td> <td>{{l2e2}}</td> </tr>
            <tr> <td>{{l2q3}}</td> <td>{{l2e3}}</td> </tr>
            <tr> <td>{{l2q4}}</td> <td>{{l2e4}}</td> </tr>
            <tr> <td>{{l2q5}}</td> <td>{{l2e5}}</td> </tr>
            <tr> <td>{{l2q6}}</td> <td>{{l2e6}}</td> </tr>
            <tr> <td>{{l2q7}}</td> <td>{{l2e7}}</td> </tr>
            <tr> <td>{{l2q8}}</td> <td>{{l2e8}}</td> </tr>
            <tr> <td>{{l2q9}}</td> <td>{{l2e9}}</td> </tr>
            <tr> <td>{{l2q10}}</td> <td>{{l2e10}}</td> </tr>
            <tr> <td>{{l2q11}}</td> <td>{{l2e11}}</td> </tr>
            <tr> <td>{{l2q12}}</td> <td>{{l2e12}}</td> </tr>
            <tr> <td>{{l2q13}}</td> <td>{{l2e13}}</td> </tr>
            <tr> <td>{{l2q14}}</td> <td>{{l2e14}}</td> </tr>
            <tr> <td>{{l2q15}}</td> <td>{{l2e15}}</td> </tr>
            <tr> <td>{{l2q16}}</td> <td>{{l2e16}}</td> </tr>
            <tr> <td>{{l2q17}}</td> <td>{{l2e17}}</td> </tr>
            <tr> <td>{{l2q18}}</td> <td>{{l2e18}}</td> </tr>
            <tr> <td>{{l2q19}}</td> <td>{{l2e19}}</td> </tr>
            <tr> <td>{{l2q20}}</td> <td>{{l2e20}}</td> </tr>
            <tr> <td>{{l2q21}}</td> <td>{{l2e21}}</td> </tr>
            <tr> <td>{{l2q22}}</td> <td>{{l2e22}}</td> </tr>
            <tr> <td>{{l2q23}}</td> <td>{{l2e23}}</td> </tr>
            <tr> <td>{{l2q24}}</td> <td>{{l2e24}}</td> </tr>

        </table>
        
        <table border="1" width=450 height=100 >
            <tr>
              <th>作り方</th>
            </tr>
            <tr>
              <td>{{l2how}}</td>
            </tr>
        </tr>
        </table>
    </div>


    <h2>{{l3title}}</h2>
        
    <table border=0>
        <tr>
        <td>
        <img src={{l3gazo}} width="300" height="200">
        </td>
        <td valign="top">
        <table border="1" width=300 height=100 align="left">
        <tr>
        <th>調理時間</th><th>摂取カロリー</th><th>食材コスト</th>
        </tr>
        <tr>
        <td>{{l3time}}分</td><td>{{l3calo}}kcal</td><td>{{l3cost}}円</td>
        </tr>
        </table>
        </td>
    </table>
        
    <div class="flex">
    <table border="1">
        <tr>
          <th>栄養名</th>
          <th>栄養素量</th>
        </tr>
        <tr>
          <td>たんぱく質</td>
          <td>{{l3f0}}g</td>
        </tr>
        <tr>
          <td>脂質</td>
          <td>{{l3f1}}g</td>
        </tr>
        <tr>
            <td>炭水化物</td>
            <td>{{l3f2}}g</td>
        </tr>
        <tr>
            <td>糖質</td>
            <td>{{l3f3}}g</td>
        </tr>
        <tr>
            <td>食塩相当量</td>
            <td>{{l3f4}}g</td>
        </tr>
        <tr>
            <td>食物繊維</td>
            <td>{{l3f5}}g</td>
          </tr>
          <tr>
              <td>ビタミンA</td>
              <td>{{l3f6}}μg</td>
          </tr>
          <tr>
              <td>ビタミンB1</td>
              <td>{{l3f7}}mg</td>
          </tr>
          <tr>
              <td>ビタミンB2</td>
              <td>{{l3f8}}mg</td>
          </tr>
          
          <tr>
            <td>ビタミンB6</td>
            <td>{{l3f9}}mg</td>
          </tr>
          <tr>
              <td>ビタミンB12</td>
              <td>{{l3f10}}μg</td>
          </tr>
          <tr>
              <td>ビタミンC</td>
              <td>{{l3f11}}mg</td>
          </tr>
          <tr>
              <td>ビタミンD</td>
              <td>{{l3f12}}μg</td>
          </tr>
          <tr>
            <td>ビタミンE</td>
            <td>{{l3f13}}mg</td>
          </tr>
          <tr>
              <td>ビタミンK</td>
              <td>{{l3f14}}μg</td>
          </tr>
          <tr>
              <td>カリウム</td>
              <td>{{l3f15}}mg</td>
          </tr>
          <tr>
              <td>カルシウム</td>
              <td>{{l3f16}}mg</td>
          </tr>
          <tr>
            <td>鉄</td>
            <td>{{l3f17}}mg</td>
          </tr>
          <tr>
              <td>葉酸</td>
              <td>{{l3f18}}μg</td>
          </tr>
          <tr>
              <td>マグネシウム</td>
              <td>{{l3f19}}mg</td>
          </tr>
          <tr>
              <td>リン</td>
              <td>{{l3f20}}mg</td>
          </tr>
          <tr>
            <td>亜鉛</td>
            <td>{{l3f21}}mg</td>
          </tr>
          <tr>
              <td>パントテン酸</td>
              <td>{{l3f22}}mg</td>
          </tr>
          <tr>
              <td>銅</td>
              <td>{{l3f23}}mg</td>
          </tr>
          <tr>
              <td>マンガン</td>
              <td>{{l3f24}}mg</td>
          </tr>

  
    </table>

    <table border="1">
        <tr>
            <th>食材名</th>
            <th>食材量</th>
        </tr>
        <tr> <td>{{l3q0}}</td> <td>{{l3e0}}</td> </tr>
        <tr> <td>{{l3q1}}</td> <td>{{l3e1}}</td> </tr>
        <tr> <td>{{l3q2}}</td> <td>{{l3e2}}</td> </tr>
        <tr> <td>{{l3q3}}</td> <td>{{l3e3}}</td> </tr>
        <tr> <td>{{l3q4}}</td> <td>{{l3e4}}</td> </tr>
        <tr> <td>{{l3q5}}</td> <td>{{l3e5}}</td> </tr>
        <tr> <td>{{l3q6}}</td> <td>{{l3e6}}</td> </tr>
        <tr> <td>{{l3q7}}</td> <td>{{l3e7}}</td> </tr>
        <tr> <td>{{l3q8}}</td> <td>{{l3e8}}</td> </tr>
        <tr> <td>{{l3q9}}</td> <td>{{l3e9}}</td> </tr>
        <tr> <td>{{l3q10}}</td> <td>{{l3e10}}</td> </tr>
        <tr> <td>{{l3q11}}</td> <td>{{l3e11}}</td> </tr>
        <tr> <td>{{l3q12}}</td> <td>{{l3e12}}</td> </tr>
        <tr> <td>{{l3q13}}</td> <td>{{l3e13}}</td> </tr>
        <tr> <td>{{l3q14}}</td> <td>{{l3e14}}</td> </tr>
        <tr> <td>{{l3q15}}</td> <td>{{l3e15}}</td> </tr>
        <tr> <td>{{l3q16}}</td> <td>{{l3e16}}</td> </tr>
        <tr> <td>{{l3q17}}</td> <td>{{l3e17}}</td> </tr>
        <tr> <td>{{l3q18}}</td> <td>{{l3e18}}</td> </tr>
        <tr> <td>{{l3q19}}</td> <td>{{l3e19}}</td> </tr>
        <tr> <td>{{l3q20}}</td> <td>{{l3e20}}</td> </tr>
        <tr> <td>{{l3q21}}</td> <td>{{l3e21}}</td> </tr>
        <tr> <td>{{l3q22}}</td> <td>{{l3e22}}</td> </tr>
        <tr> <td>{{l3q23}}</td> <td>{{l3e23}}</td> </tr>
        <tr> <td>{{l3q24}}</td> <td>{{l3e24}}</td> </tr>

    </table>
    
    <table border="1" width=450 height=100 >
        <tr>
          <th>作り方</th>
        </tr>
        <tr>
          <td>{{l3how}}</td>
        </tr>
    </tr>
    </table>
    </div>




    <h1>夕食</h1>
    <h2>{{d1title}}</h2>
        
    <table border=0>
        <tr>
        <td>
        <img src={{d1gazo}} width="300" height="200">
        </td>
        <td valign="top">
        <table border="1" width=300 height=100 align="left">
        <tr>
        <th>調理時間</th><th>摂取カロリー</th><th>食材コスト</th>
        </tr>
        <tr>
        <td>{{d1time}}分</td><td>{{d1calo}}kcal</td><td>{{d1cost}}円</td>
        </tr>
        </table>
        </td>
    </table>
        
    <div class="flex">
    <table border="1">
        <tr>
          <th>栄養名</th>
          <th>栄養素量</th>
        </tr>
        <tr>
          <td>たんぱく質</td>
          <td>{{d1f0}}g</td>
        </tr>
        <tr>
          <td>脂質</td>
          <td>{{d1f1}}g</td>
        </tr>
        <tr>
            <td>炭水化物</td>
            <td>{{d1f2}}g</td>
        </tr>
        <tr>
            <td>糖質</td>
            <td>{{d1f3}}g</td>
        </tr>
        <tr>
            <td>食塩相当量</td>
            <td>{{d1f4}}g</td>
        </tr>
        <tr>
            <td>食物繊維</td>
            <td>{{d1f5}}g</td>
          </tr>
          <tr>
              <td>ビタミンA</td>
              <td>{{d1f6}}μg</td>
          </tr>
          <tr>
              <td>ビタミンB1</td>
              <td>{{d1f7}}mg</td>
          </tr>
          <tr>
              <td>ビタミンB2</td>
              <td>{{d1f8}}mg</td>
          </tr>
          
          <tr>
            <td>ビタミンB6</td>
            <td>{{d1f9}}mg</td>
          </tr>
          <tr>
              <td>ビタミンB12</td>
              <td>{{d1f10}}μg</td>
          </tr>
          <tr>
              <td>ビタミンC</td>
              <td>{{d1f11}}mg</td>
          </tr>
          <tr>
              <td>ビタミンD</td>
              <td>{{d1f12}}μg</td>
          </tr>
          <tr>
            <td>ビタミンE</td>
            <td>{{d1f13}}mg</td>
          </tr>
          <tr>
              <td>ビタミンK</td>
              <td>{{d1f14}}μg</td>
          </tr>
          <tr>
              <td>カリウム</td>
              <td>{{d1f15}}mg</td>
          </tr>
          <tr>
              <td>カルシウム</td>
              <td>{{d1f16}}mg</td>
          </tr>
          <tr>
            <td>鉄</td>
            <td>{{d1f17}}mg</td>
          </tr>
          <tr>
              <td>葉酸</td>
              <td>{{d1f18}}μg</td>
          </tr>
          <tr>
              <td>マグネシウム</td>
              <td>{{d1f19}}mg</td>
          </tr>
          <tr>
              <td>リン</td>
              <td>{{d1f20}}mg</td>
          </tr>
          <tr>
            <td>亜鉛</td>
            <td>{{d1f21}}mg</td>
          </tr>
          <tr>
              <td>パントテン酸</td>
              <td>{{d1f22}}mg</td>
          </tr>
          <tr>
              <td>銅</td>
              <td>{{d1f23}}mg</td>
          </tr>
          <tr>
              <td>マンガン</td>
              <td>{{d1f24}}mg</td>
          </tr>

  
    </table>

    <table border="1">
        <tr>
            <th>食材名</th>
            <th>食材量</th>
        </tr>
        <tr> <td>{{d1q0}}</td> <td>{{d1e0}}</td> </tr>
        <tr> <td>{{d1q1}}</td> <td>{{d1e1}}</td> </tr>
        <tr> <td>{{d1q2}}</td> <td>{{d1e2}}</td> </tr>
        <tr> <td>{{d1q3}}</td> <td>{{d1e3}}</td> </tr>
        <tr> <td>{{d1q4}}</td> <td>{{d1e4}}</td> </tr>
        <tr> <td>{{d1q5}}</td> <td>{{d1e5}}</td> </tr>
        <tr> <td>{{d1q6}}</td> <td>{{d1e6}}</td> </tr>
        <tr> <td>{{d1q7}}</td> <td>{{d1e7}}</td> </tr>
        <tr> <td>{{d1q8}}</td> <td>{{d1e8}}</td> </tr>
        <tr> <td>{{d1q9}}</td> <td>{{d1e9}}</td> </tr>
        <tr> <td>{{d1q10}}</td> <td>{{d1e10}}</td> </tr>
        <tr> <td>{{d1q11}}</td> <td>{{d1e11}}</td> </tr>
        <tr> <td>{{d1q12}}</td> <td>{{d1e12}}</td> </tr>
        <tr> <td>{{d1q13}}</td> <td>{{d1e13}}</td> </tr>
        <tr> <td>{{d1q14}}</td> <td>{{d1e14}}</td> </tr>
        <tr> <td>{{d1q15}}</td> <td>{{d1e15}}</td> </tr>
        <tr> <td>{{d1q16}}</td> <td>{{d1e16}}</td> </tr>
        <tr> <td>{{d1q17}}</td> <td>{{d1e17}}</td> </tr>
        <tr> <td>{{d1q18}}</td> <td>{{d1e18}}</td> </tr>
        <tr> <td>{{d1q19}}</td> <td>{{d1e19}}</td> </tr>
        <tr> <td>{{d1q20}}</td> <td>{{d1e20}}</td> </tr>
        <tr> <td>{{d1q21}}</td> <td>{{d1e21}}</td> </tr>
        <tr> <td>{{d1q22}}</td> <td>{{d1e22}}</td> </tr>
        <tr> <td>{{d1q23}}</td> <td>{{d1e23}}</td> </tr>
        <tr> <td>{{d1q24}}</td> <td>{{d1e24}}</td> </tr>

    </table>
    
    <table border="1" width=450 height=100 >
        <tr>
          <th>作り方</th>
        </tr>
        <tr>
          <td>{{d1how}}</td>
        </tr>
    </tr>
    </table>
</div>

<h2>{{d2title}}</h2>
    
    <table border=0>
        <tr>
        <td>
        <img src={{d2gazo}} width="300" height="200">
        </td>
        <td valign="top">
        <table border="1" width=300 height=100 align="left">
        <tr>
        <th>調理時間</th><th>摂取カロリー</th><th>食材コスト</th>
        </tr>
        <tr>
        <td>{{d2time}}分</td><td>{{d2calo}}kcal</td><td>{{d2cost}}円</td>
        </tr>
        </table>
        </td>
    </table>
        
    <div class="flex">
    <table border="1">
        <tr>
          <th>栄養名</th>
          <th>栄養素量</th>
        </tr>
        <tr>
          <td>たんぱく質</td>
          <td>{{d2f0}}g</td>
        </tr>
        <tr>
          <td>脂質</td>
          <td>{{d2f1}}g</td>
        </tr>
        <tr>
            <td>炭水化物</td>
            <td>{{d2f2}}g</td>
        </tr>
        <tr>
            <td>糖質</td>
            <td>{{d2f3}}g</td>
        </tr>
        <tr>
            <td>食塩相当量</td>
            <td>{{d2f4}}g</td>
        </tr>
        <tr>
            <td>食物繊維</td>
            <td>{{d2f5}}g</td>
          </tr>
          <tr>
              <td>ビタミンA</td>
              <td>{{d2f6}}μg</td>
          </tr>
          <tr>
              <td>ビタミンB1</td>
              <td>{{d2f7}}mg</td>
          </tr>
          <tr>
              <td>ビタミンB2</td>
              <td>{{d2f8}}mg</td>
          </tr>
          
          <tr>
            <td>ビタミンB6</td>
            <td>{{d2f9}}mg</td>
          </tr>
          <tr>
              <td>ビタミンB12</td>
              <td>{{d2f10}}μg</td>
          </tr>
          <tr>
              <td>ビタミンC</td>
              <td>{{d2f11}}mg</td>
          </tr>
          <tr>
              <td>ビタミンD</td>
              <td>{{d2f12}}μg</td>
          </tr>
          <tr>
            <td>ビタミンE</td>
            <td>{{d2f13}}mg</td>
          </tr>
          <tr>
              <td>ビタミンK</td>
              <td>{{d2f14}}μg</td>
          </tr>
          <tr>
              <td>カリウム</td>
              <td>{{d2f15}}mg</td>
          </tr>
          <tr>
              <td>カルシウム</td>
              <td>{{d2f16}}mg</td>
          </tr>
          <tr>
            <td>鉄</td>
            <td>{{d2f17}}mg</td>
          </tr>
          <tr>
              <td>葉酸</td>
              <td>{{d2f18}}μg</td>
          </tr>
          <tr>
              <td>マグネシウム</td>
              <td>{{d2f19}}mg</td>
          </tr>
          <tr>
              <td>リン</td>
              <td>{{d2f20}}mg</td>
          </tr>
          <tr>
            <td>亜鉛</td>
            <td>{{d2f21}}mg</td>
          </tr>
          <tr>
              <td>パントテン酸</td>
              <td>{{d2f22}}mg</td>
          </tr>
          <tr>
              <td>銅</td>
              <td>{{d2f23}}mg</td>
          </tr>
          <tr>
              <td>マンガン</td>
              <td>{{d2f24}}mg</td>
          </tr>

  
    </table>

    <table border="1">
        <tr>
            <th>食材名</th>
            <th>食材量</th>
        </tr>
        <tr> <td>{{d2q0}}</td> <td>{{d2e0}}</td> </tr>
        <tr> <td>{{d2q1}}</td> <td>{{d2e1}}</td> </tr>
        <tr> <td>{{d2q2}}</td> <td>{{d2e2}}</td> </tr>
        <tr> <td>{{d2q3}}</td> <td>{{d2e3}}</td> </tr>
        <tr> <td>{{d2q4}}</td> <td>{{d2e4}}</td> </tr>
        <tr> <td>{{d2q5}}</td> <td>{{d2e5}}</td> </tr>
        <tr> <td>{{d2q6}}</td> <td>{{d2e6}}</td> </tr>
        <tr> <td>{{d2q7}}</td> <td>{{d2e7}}</td> </tr>
        <tr> <td>{{d2q8}}</td> <td>{{d2e8}}</td> </tr>
        <tr> <td>{{d2q9}}</td> <td>{{d2e9}}</td> </tr>
        <tr> <td>{{d2q10}}</td> <td>{{d2e10}}</td> </tr>
        <tr> <td>{{d2q11}}</td> <td>{{d2e11}}</td> </tr>
        <tr> <td>{{d2q12}}</td> <td>{{d2e12}}</td> </tr>
        <tr> <td>{{d2q13}}</td> <td>{{d2e13}}</td> </tr>
        <tr> <td>{{d2q14}}</td> <td>{{d2e14}}</td> </tr>
        <tr> <td>{{d2q15}}</td> <td>{{d2e15}}</td> </tr>
        <tr> <td>{{d2q16}}</td> <td>{{d2e16}}</td> </tr>
        <tr> <td>{{d2q17}}</td> <td>{{d2e17}}</td> </tr>
        <tr> <td>{{d2q18}}</td> <td>{{d2e18}}</td> </tr>
        <tr> <td>{{d2q19}}</td> <td>{{d2e19}}</td> </tr>
        <tr> <td>{{d2q20}}</td> <td>{{d2e20}}</td> </tr>
        <tr> <td>{{d2q21}}</td> <td>{{d2e21}}</td> </tr>
        <tr> <td>{{d2q22}}</td> <td>{{d2e22}}</td> </tr>
        <tr> <td>{{d2q23}}</td> <td>{{d2e23}}</td> </tr>
        <tr> <td>{{d2q24}}</td> <td>{{d2e24}}</td> </tr>

    </table>
    
    <table border="1" width=450 height=100 >
        <tr>
          <th>作り方</th>
        </tr>
        <tr>
          <td>{{d2how}}</td>
        </tr>
    </tr>
    </table>
</div>


<h2>{{d3title}}</h2>
    
<table border=0>
    <tr>
    <td>
    <img src={{d3gazo}} width="300" height="200">
    </td>
    <td valign="top">
    <table border="1" width=300 height=100 align="left">
    <tr>
    <th>調理時間</th><th>摂取カロリー</th><th>食材コスト</th>
    </tr>
    <tr>
    <td>{{d3time}}分</td><td>{{d3calo}}kcal</td><td>{{d3cost}}円</td>
    </tr>
    </table>
    </td>
</table>
    
<div class="flex">
<table border="1">
    <tr>
      <th>栄養名</th>
      <th>栄養素量</th>
    </tr>
    <tr>
      <td>たんぱく質</td>
      <td>{{d3f0}}g</td>
    </tr>
    <tr>
      <td>脂質</td>
      <td>{{d3f1}}g</td>
    </tr>
    <tr>
        <td>炭水化物</td>
        <td>{{d3f2}}g</td>
    </tr>
    <tr>
        <td>糖質</td>
        <td>{{d3f3}}g</td>
    </tr>
    <tr>
        <td>食塩相当量</td>
        <td>{{d3f4}}g</td>
    </tr>
    <tr>
        <td>食物繊維</td>
        <td>{{d3f5}}g</td>
      </tr>
      <tr>
          <td>ビタミンA</td>
          <td>{{d3f6}}μg</td>
      </tr>
      <tr>
          <td>ビタミンB1</td>
          <td>{{d3f7}}μg</td>
      </tr>
      <tr>
          <td>ビタミンB2</td>
          <td>{{d3f8}}mg</td>
      </tr>
      
      <tr>
        <td>ビタミンB6</td>
        <td>{{d3f9}}mg</td>
      </tr>
      <tr>
          <td>ビタミンB12</td>
          <td>{{d3f10}}μg</td>
      </tr>
      <tr>
          <td>ビタミンC</td>
          <td>{{d3f11}}mg</td>
      </tr>
      <tr>
          <td>ビタミンD</td>
          <td>{{d3f12}}μg</td>
      </tr>
      <tr>
        <td>ビタミンE</td>
        <td>{{d3f13}}mg</td>
      </tr>
      <tr>
          <td>ビタミンK</td>
          <td>{{d3f14}}μg</td>
      </tr>
      <tr>
          <td>カリウム</td>
          <td>{{d3f15}}mg</td>
      </tr>
      <tr>
          <td>カルシウム</td>
          <td>{{d3f16}}mg</td>
      </tr>
      <tr>
        <td>鉄</td>
        <td>{{d3f17}}mg</td>
      </tr>
      <tr>
          <td>葉酸</td>
          <td>{{d3f18}}μg</td>
      </tr>
      <tr>
          <td>マグネシウム</td>
          <td>{{d3f19}}mg</td>
      </tr>
      <tr>
          <td>リン</td>
          <td>{{d3f20}}mg</td>
      </tr>
      <tr>
        <td>亜鉛</td>
        <td>{{d3f21}}mg</td>
      </tr>
      <tr>
          <td>パントテン酸</td>
          <td>{{d3f22}}mg</td>
      </tr>
      <tr>
          <td>銅</td>
          <td>{{d3f23}}mg</td>
      </tr>
      <tr>
          <td>マンガン</td>
          <td>{{d3f24}}mg</td>
      </tr>


</table>

<table border="1">
    <tr>
        <th>食材名</th>
        <th>食材量</th>
    </tr>
    <tr> <td>{{d3q0}}</td> <td>{{d3e0}}</td> </tr>
    <tr> <td>{{d3q1}}</td> <td>{{d3e1}}</td> </tr>
    <tr> <td>{{d3q2}}</td> <td>{{d3e2}}</td> </tr>
    <tr> <td>{{d3q3}}</td> <td>{{d3e3}}</td> </tr>
    <tr> <td>{{d3q4}}</td> <td>{{d3e4}}</td> </tr>
    <tr> <td>{{d3q5}}</td> <td>{{d3e5}}</td> </tr>
    <tr> <td>{{d3q6}}</td> <td>{{d3e6}}</td> </tr>
    <tr> <td>{{d3q7}}</td> <td>{{d3e7}}</td> </tr>
    <tr> <td>{{d3q8}}</td> <td>{{d3e8}}</td> </tr>
    <tr> <td>{{d3q9}}</td> <td>{{d3e9}}</td> </tr>
    <tr> <td>{{d3q10}}</td> <td>{{d3e10}}</td> </tr>
    <tr> <td>{{d3q11}}</td> <td>{{d3e11}}</td> </tr>
    <tr> <td>{{d3q12}}</td> <td>{{d3e12}}</td> </tr>
    <tr> <td>{{d3q13}}</td> <td>{{d3e13}}</td> </tr>
    <tr> <td>{{d3q14}}</td> <td>{{d3e14}}</td> </tr>
    <tr> <td>{{d3q15}}</td> <td>{{d3e15}}</td> </tr>
    <tr> <td>{{d3q16}}</td> <td>{{d3e16}}</td> </tr>
    <tr> <td>{{d3q17}}</td> <td>{{d3e17}}</td> </tr>
    <tr> <td>{{d3q18}}</td> <td>{{d3e18}}</td> </tr>
    <tr> <td>{{d3q19}}</td> <td>{{d3e19}}</td> </tr>
    <tr> <td>{{d3q20}}</td> <td>{{d3e20}}</td> </tr>
    <tr> <td>{{d3q21}}</td> <td>{{d3e21}}</td> </tr>
    <tr> <td>{{d3q22}}</td> <td>{{d3e22}}</td> </tr>
    <tr> <td>{{d3q23}}</td> <td>{{d3e23}}</td> </tr>
    <tr> <td>{{d3q24}}</td> <td>{{d3e24}}</td> </tr>

</table>

<table border="1" width=450 height=100 >
    <tr>
      <th>作り方</th>
    </tr>
    <tr>
      <td>{{d3how}}</td>
    </tr>
</tr>
</table>
</div>
    </body>
</html>
"""

temp="""
template = Template(html1)
d1 = template.render(
    mtitle = str(yi[number[7*i]]),
        mtime = str(Ti[number[7*i]]),
        mcalo = str(Ci[number[7*i]]),
        mcost = str(Gi[number[7*i]]),
        mf0 = str(f0j[number[7*i]]),
        mf1 = str(f1j[number[7*i]]),
        mf2 = str(f2j[number[7*i]]),
        mf3 = str(f3j[number[7*i]]),
        mf4 = str(f4j[number[7*i]]),
        mf5 = str(f5j[number[7*i]]),
        mf6 = str(f6j[number[7*i]]),
        mf7 = str(f7j[number[7*i]]),
        mf8 = str(f8j[number[7*i]]),
        mf9 = str(f9j[number[7*i]]),
        mf10 = str(f10j[number[7*i]]),
        mf11 = str(f11j[number[7*i]]),
        mf12 = str(f12j[number[7*i]]),
        mf13 = str(f13j[number[7*i]]),
        mf14 = str(f14j[number[7*i]]),
        mf15 = str(f15j[number[7*i]]),
        mf16 = str(f16j[number[7*i]]),
        mf17 = str(f17j[number[7*i]]),
        mf18 = str(f18j[number[7*i]]),
        mf19 = str(f19j[number[7*i]]),
        mf20 = str(f20j[number[7*i]]),
        mf21 = str(f21j[number[7*i]]),
        mf22 = str(f22j[number[7*i]]),
        mf23 = str(f23j[number[7*i]]),
        mf24 = str(f24j[number[7*i]]),
        mq0 = str(qij[number[7*i]][0]),
        mq1 = str(qij[number[7*i]][1]),
        mq2 = str(qij[number[7*i]][2]),
        mq3 = str(qij[number[7*i]][3]),
        mq4 = str(qij[number[7*i]][4]),
        mq5 = str(qij[number[7*i]][5]),
        mq6 = str(qij[number[7*i]][6]),
        mq7 = str(qij[number[7*i]][7]),
        mq8 = str(qij[number[7*i]][8]),
        mq9 = str(qij[number[7*i]][9]),
        mq10 = str(qij[number[7*i]][10]),
        mq11 = str(qij[number[7*i]][11]),
        mq12 = str(qij[number[7*i]][12]),
        mq13 = str(qij[number[7*i]][13]),
        mq14 = str(qij[number[7*i]][14]),
        mq15 = str(qij[number[7*i]][15]),
        mq16 = str(qij[number[7*i]][16]),
        mq17 = str(qij[number[7*i]][17]),
        mq18 = str(qij[number[7*i]][18]),
        mq19 = str(qij[number[7*i]][19]),
        mq20 = str(qij[number[7*i]][20]),
        mq21 = str(qij[number[7*i]][21]),
        mq22 = str(qij[number[7*i]][22]),
        mq23 = str(qij[number[7*i]][23]),
        mq24 = str(qij[number[7*i]][24]),
        me0 = str(eij[number[7*i]][0]),
        me1 = str(eij[number[7*i]][1]),
        me2 = str(eij[number[7*i]][2]),
        me3 = str(eij[number[7*i]][3]),
        me4 = str(eij[number[7*i]][4]),
        me5 = str(eij[number[7*i]][5]),
        me6 = str(eij[number[7*i]][6]),
        me7 = str(eij[number[7*i]][7]),
        me8 = str(eij[number[7*i]][8]),
        me9 = str(eij[number[7*i]][9]),
        me10 = str(eij[number[7*i]][10]),
        me11 = str(eij[number[7*i]][11]),
        me12 = str(eij[number[7*i]][12]),
        me13 = str(eij[number[7*i]][13]),
        me14 = str(eij[number[7*i]][14]),
        me15 = str(eij[number[7*i]][15]),
        me16 = str(eij[number[7*i]][16]),
        me17 = str(eij[number[7*i]][17]),
        me18 = str(eij[number[7*i]][18]),
        me19 = str(eij[number[7*i]][19]),
        me20 = str(eij[number[7*i]][20]),
        me21 = str(eij[number[7*i]][21]),
        me22 = str(eij[number[7*i]][22]),
        me23 = str(eij[number[7*i]][23]),
        me24 = str(eij[number[7*i]][24]), 
        mhow = str(how[7*i]),
        mgazo = str(gazo[7*i]),

        l1title = str(yi[number[7*i+1]]),
        l1time = str(Ti[number[7*i+1]]),
        l1calo = str(Ci[number[7*i+1]]),
        l1cost = str(Gi[number[7*i+1]]),
        l1f0 = str(f0j[number[7*i+1]]),
        l1f1 = str(f1j[number[7*i+1]]),
        l1f2 = str(f2j[number[7*i+1]]),
        l1f3 = str(f3j[number[7*i+1]]),
        l1f4 = str(f4j[number[7*i+1]]),
        l1f5 = str(f5j[number[7*i+1]]),
        l1f6 = str(f6j[number[7*i+1]]),
        l1f7 = str(f7j[number[7*i+1]]),
        l1f8 = str(f8j[number[7*i+1]]),
        l1f9 = str(f9j[number[7*i+1]]),
        l1f10 = str(f10j[number[7*i+1]]),
        l1f11 = str(f11j[number[7*i+1]]),
        l1f12 = str(f12j[number[7*i+1]]),
        l1f13 = str(f13j[number[7*i+1]]),
        l1f14 = str(f14j[number[7*i+1]]),
        l1f15 = str(f15j[number[7*i+1]]),
        l1f16 = str(f16j[number[7*i+1]]),
        l1f17 = str(f17j[number[7*i+1]]),
        l1f18 = str(f18j[number[7*i+1]]),
        l1f19 = str(f19j[number[7*i+1]]),
        l1f20 = str(f20j[number[7*i+1]]),
        l1f21 = str(f21j[number[7*i+1]]),
        l1f22 = str(f22j[number[7*i+1]]),
        l1f23 = str(f23j[number[7*i+1]]),
        l1f24 = str(f24j[number[7*i+1]]),
        l1q0 = str(qij[number[7*i+1]][0]),
        l1q1 = str(qij[number[7*i+1]][1]),
        l1q2 = str(qij[number[7*i+1]][2]),
        l1q3 = str(qij[number[7*i+1]][3]),
        l1q4 = str(qij[number[7*i+1]][4]),
        l1q5 = str(qij[number[7*i+1]][5]),
        l1q6 = str(qij[number[7*i+1]][6]),
        l1q7 = str(qij[number[7*i+1]][7]),
        l1q8 = str(qij[number[7*i+1]][8]),
        l1q9 = str(qij[number[7*i+1]][9]),
        l1q10 = str(qij[number[7*i+1]][10]),
        l1q11 = str(qij[number[7*i+1]][11]),
        l1q12 = str(qij[number[7*i+1]][12]),
        l1q13 = str(qij[number[7*i+1]][13]),
        l1q14 = str(qij[number[7*i+1]][14]),
        l1q15 = str(qij[number[7*i+1]][15]),
        l1q16 = str(qij[number[7*i+1]][16]),
        l1q17 = str(qij[number[7*i+1]][17]),
        l1q18 = str(qij[number[7*i+1]][18]),
        l1q19 = str(qij[number[7*i+1]][19]),
        l1q20 = str(qij[number[7*i+1]][20]),
        l1q21 = str(qij[number[7*i+1]][21]),
        l1q22 = str(qij[number[7*i+1]][22]),
        l1q23 = str(qij[number[7*i+1]][23]),
        l1q24 = str(qij[number[7*i+1]][24]),
        l1e0 = str(eij[number[7*i+1]][0]),
        l1e1 = str(eij[number[7*i+1]][1]),
        l1e2 = str(eij[number[7*i+1]][2]),
        l1e3 = str(eij[number[7*i+1]][3]),
        l1e4 = str(eij[number[7*i+1]][4]),
        l1e5 = str(eij[number[7*i+1]][5]),
        l1e6 = str(eij[number[7*i+1]][6]),
        l1e7 = str(eij[number[7*i+1]][7]),
        l1e8 = str(eij[number[7*i+1]][8]),
        l1e9 = str(eij[number[7*i+1]][9]),
        l1e10 = str(eij[number[7*i+1]][10]),
        l1e11 = str(eij[number[7*i+1]][11]),
        l1e12 = str(eij[number[7*i+1]][12]),
        l1e13 = str(eij[number[7*i+1]][13]),
        l1e14 = str(eij[number[7*i+1]][14]),
        l1e15 = str(eij[number[7*i+1]][15]),
        l1e16 = str(eij[number[7*i+1]][16]),
        l1e17 = str(eij[number[7*i+1]][17]),
        l1e18 = str(eij[number[7*i+1]][18]),
        l1e19 = str(eij[number[7*i+1]][19]),
        l1e20 = str(eij[number[7*i+1]][20]),
        l1e21 = str(eij[number[7*i+1]][21]),
        l1e22 = str(eij[number[7*i+1]][22]),
        l1e23 = str(eij[number[7*i+1]][23]),
        l1e24 = str(eij[number[7*i+1]][24]), 
        l1how = str(how[7*i+1]),
        l1gazo = str(gazo[7*i+1]),

        l2title = str(yi[number[7*i+2]]),
        l2time = str(Ti[number[7*i+2]]),
        l2calo = str(Ci[number[7*i+2]]),
        l2cost = str(Gi[number[7*i+2]]),
        l2f0 = str(f0j[number[7*i+2]]),
        l2f1 = str(f1j[number[7*i+2]]),
        l2f2 = str(f2j[number[7*i+2]]),
        l2f3 = str(f3j[number[7*i+2]]),
        l2f4 = str(f4j[number[7*i+2]]),
        l2f5 = str(f5j[number[7*i+2]]),
        l2f6 = str(f6j[number[7*i+2]]),
        l2f7 = str(f7j[number[7*i+2]]),
        l2f8 = str(f8j[number[7*i+2]]),
        l2f9 = str(f9j[number[7*i+2]]),
        l2f10 = str(f10j[number[7*i+2]]),
        l2f11 = str(f11j[number[7*i+2]]),
        l2f12 = str(f12j[number[7*i+2]]),
        l2f13 = str(f13j[number[7*i+2]]),
        l2f14 = str(f14j[number[7*i+2]]),
        l2f15 = str(f15j[number[7*i+2]]),
        l2f16 = str(f16j[number[7*i+2]]),
        l2f17 = str(f17j[number[7*i+2]]),
        l2f18 = str(f18j[number[7*i+2]]),
        l2f19 = str(f19j[number[7*i+2]]),
        l2f20 = str(f20j[number[7*i+2]]),
        l2f21 = str(f21j[number[7*i+2]]),
        l2f22 = str(f22j[number[7*i+2]]),
        l2f23 = str(f23j[number[7*i+2]]),
        l2f24 = str(f24j[number[7*i+2]]),
        l2q0 = str(qij[number[7*i+2]][0]),
        l2q1 = str(qij[number[7*i+2]][1]),
        l2q2 = str(qij[number[7*i+2]][2]),
        l2q3 = str(qij[number[7*i+2]][3]),
        l2q4 = str(qij[number[7*i+2]][4]),
        l2q5 = str(qij[number[7*i+2]][5]),
        l2q6 = str(qij[number[7*i+2]][6]),
        l2q7 = str(qij[number[7*i+2]][7]),
        l2q8 = str(qij[number[7*i+2]][8]),
        l2q9 = str(qij[number[7*i+2]][9]),
        l2q10 = str(qij[number[7*i+2]][10]),
        l2q11 = str(qij[number[7*i+2]][11]),
        l2q12 = str(qij[number[7*i+2]][12]),
        l2q13 = str(qij[number[7*i+2]][13]),
        l2q14 = str(qij[number[7*i+2]][14]),
        l2q15 = str(qij[number[7*i+2]][15]),
        l2q16 = str(qij[number[7*i+2]][16]),
        l2q17 = str(qij[number[7*i+2]][17]),
        l2q18 = str(qij[number[7*i+2]][18]),
        l2q19 = str(qij[number[7*i+2]][19]),
        l2q20 = str(qij[number[7*i+2]][20]),
        l2q21 = str(qij[number[7*i+2]][21]),
        l2q22 = str(qij[number[7*i+2]][22]),
        l2q23 = str(qij[number[7*i+2]][23]),
        l2q24 = str(qij[number[7*i+2]][24]),
        l2e0 = str(eij[number[7*i+2]][0]),
        l2e1 = str(eij[number[7*i+2]][1]),
        l2e2 = str(eij[number[7*i+2]][2]),
        l2e3 = str(eij[number[7*i+2]][3]),
        l2e4 = str(eij[number[7*i+2]][4]),
        l2e5 = str(eij[number[7*i+2]][5]),
        l2e6 = str(eij[number[7*i+2]][6]),
        l2e7 = str(eij[number[7*i+2]][7]),
        l2e8 = str(eij[number[7*i+2]][8]),
        l2e9 = str(eij[number[7*i+2]][9]),
        l2e10 = str(eij[number[7*i+2]][10]),
        l2e11 = str(eij[number[7*i+2]][11]),
        l2e12 = str(eij[number[7*i+2]][12]),
        l2e13 = str(eij[number[7*i+2]][13]),
        l2e14 = str(eij[number[7*i+2]][14]),
        l2e15 = str(eij[number[7*i+2]][15]),
        l2e16 = str(eij[number[7*i+2]][16]),
        l2e17 = str(eij[number[7*i+2]][17]),
        l2e18 = str(eij[number[7*i+2]][18]),
        l2e19 = str(eij[number[7*i+2]][19]),
        l2e20 = str(eij[number[7*i+2]][20]),
        l2e21 = str(eij[number[7*i+2]][21]),
        l2e22 = str(eij[number[7*i+2]][22]),
        l2e23 = str(eij[number[7*i+2]][23]),
        l2e24 = str(eij[number[7*i+2]][24]), 
        l2how = str(how[7*i+2]),
        l2gazo = str(gazo[7*i+2]),

        l3title = str(yi[number[7*i+3]]),
        l3time = str(Ti[number[7*i+3]]),
        l3calo = str(Ci[number[7*i+3]]),
        l3cost = str(Gi[number[7*i+3]]),
        l3f0 = str(f0j[number[7*i+3]]),
        l3f1 = str(f1j[number[7*i+3]]),
        l3f2 = str(f2j[number[7*i+3]]),
        l3f3 = str(f3j[number[7*i+3]]),
        l3f4 = str(f4j[number[7*i+3]]),
        l3f5 = str(f5j[number[7*i+3]]),
        l3f6 = str(f6j[number[7*i+3]]),
        l3f7 = str(f7j[number[7*i+3]]),
        l3f8 = str(f8j[number[7*i+3]]),
        l3f9 = str(f9j[number[7*i+3]]),
        l3f10 = str(f10j[number[7*i+3]]),
        l3f11 = str(f11j[number[7*i+3]]),
        l3f12 = str(f12j[number[7*i+3]]),
        l3f13 = str(f13j[number[7*i+3]]),
        l3f14 = str(f14j[number[7*i+3]]),
        l3f15 = str(f15j[number[7*i+3]]),
        l3f16 = str(f16j[number[7*i+3]]),
        l3f17 = str(f17j[number[7*i+3]]),
        l3f18 = str(f18j[number[7*i+3]]),
        l3f19 = str(f19j[number[7*i+3]]),
        l3f20 = str(f20j[number[7*i+3]]),
        l3f21 = str(f21j[number[7*i+3]]),
        l3f22 = str(f22j[number[7*i+3]]),
        l3f23 = str(f23j[number[7*i+3]]),
        l3f24 = str(f24j[number[7*i+3]]),
        l3q0 = str(qij[number[7*i+3]][0]),
        l3q1 = str(qij[number[7*i+3]][1]),
        l3q2 = str(qij[number[7*i+3]][2]),
        l3q3 = str(qij[number[7*i+3]][3]),
        l3q4 = str(qij[number[7*i+3]][4]),
        l3q5 = str(qij[number[7*i+3]][5]),
        l3q6 = str(qij[number[7*i+3]][6]),
        l3q7 = str(qij[number[7*i+3]][7]),
        l3q8 = str(qij[number[7*i+3]][8]),
        l3q9 = str(qij[number[7*i+3]][9]),
        l3q10 = str(qij[number[7*i+3]][10]),
        l3q11 = str(qij[number[7*i+3]][11]),
        l3q12 = str(qij[number[7*i+3]][12]),
        l3q13 = str(qij[number[7*i+3]][13]),
        l3q14 = str(qij[number[7*i+3]][14]),
        l3q15 = str(qij[number[7*i+3]][15]),
        l3q16 = str(qij[number[7*i+3]][16]),
        l3q17 = str(qij[number[7*i+3]][17]),
        l3q18 = str(qij[number[7*i+3]][18]),
        l3q19 = str(qij[number[7*i+3]][19]),
        l3q20 = str(qij[number[7*i+3]][20]),
        l3q21 = str(qij[number[7*i+3]][21]),
        l3q22 = str(qij[number[7*i+3]][22]),
        l3q23 = str(qij[number[7*i+3]][23]),
        l3q24 = str(qij[number[7*i+3]][24]),
        l3e0 = str(eij[number[7*i+3]][0]),
        l3e1 = str(eij[number[7*i+3]][1]),
        l3e2 = str(eij[number[7*i+3]][2]),
        l3e3 = str(eij[number[7*i+3]][3]),
        l3e4 = str(eij[number[7*i+3]][4]),
        l3e5 = str(eij[number[7*i+3]][5]),
        l3e6 = str(eij[number[7*i+3]][6]),
        l3e7 = str(eij[number[7*i+3]][7]),
        l3e8 = str(eij[number[7*i+3]][8]),
        l3e9 = str(eij[number[7*i+3]][9]),
        l3e10 = str(eij[number[7*i+3]][10]),
        l3e11 = str(eij[number[7*i+3]][11]),
        l3e12 = str(eij[number[7*i+3]][12]),
        l3e13 = str(eij[number[7*i+3]][13]),
        l3e14 = str(eij[number[7*i+3]][14]),
        l3e15 = str(eij[number[7*i+3]][15]),
        l3e16 = str(eij[number[7*i+3]][16]),
        l3e17 = str(eij[number[7*i+3]][17]),
        l3e18 = str(eij[number[7*i+3]][18]),
        l3e19 = str(eij[number[7*i+3]][19]),
        l3e20 = str(eij[number[7*i+3]][20]),
        l3e21 = str(eij[number[7*i+3]][21]),
        l3e22 = str(eij[number[7*i+3]][22]),
        l3e23 = str(eij[number[7*i+3]][23]),
        l3e24 = str(eij[number[7*i+3]][24]), 
        l3how = str(how[7*i+3]),
        l3gazo = str(gazo[7*i+3]),

        d1title = str(yi[number[7*i+4]]),
        d1time = str(Ti[number[7*i+4]]),
        d1calo = str(Ci[number[7*i+4]]),
        d1cost = str(Gi[number[7*i+4]]),
        d1f0 = str(f0j[number[7*i+4]]),
        d1f1 = str(f1j[number[7*i+4]]),
        d1f2 = str(f2j[number[7*i+4]]),
        d1f3 = str(f3j[number[7*i+4]]),
        d1f4 = str(f4j[number[7*i+4]]),
        d1f5 = str(f5j[number[7*i+4]]),
        d1f6 = str(f6j[number[7*i+4]]),
        d1f7 = str(f7j[number[7*i+4]]),
        d1f8 = str(f8j[number[7*i+4]]),
        d1f9 = str(f9j[number[7*i+4]]),
        d1f10 = str(f10j[number[7*i+4]]),
        d1f11 = str(f11j[number[7*i+4]]),
        d1f12 = str(f12j[number[7*i+4]]),
        d1f13 = str(f13j[number[7*i+4]]),
        d1f14 = str(f14j[number[7*i+4]]),
        d1f15 = str(f15j[number[7*i+4]]),
        d1f16 = str(f16j[number[7*i+4]]),
        d1f17 = str(f17j[number[7*i+4]]),
        d1f18 = str(f18j[number[7*i+4]]),
        d1f19 = str(f19j[number[7*i+4]]),
        d1f20 = str(f20j[number[7*i+4]]),
        d1f21 = str(f21j[number[7*i+4]]),
        d1f22 = str(f22j[number[7*i+4]]),
        d1f23 = str(f23j[number[7*i+4]]),
        d1f24 = str(f24j[number[7*i+4]]),
        d1q0 = str(qij[number[7*i+4]][0]),
        d1q1 = str(qij[number[7*i+4]][1]),
        d1q2 = str(qij[number[7*i+4]][2]),
        d1q3 = str(qij[number[7*i+4]][3]),
        d1q4 = str(qij[number[7*i+4]][4]),
        d1q5 = str(qij[number[7*i+4]][5]),
        d1q6 = str(qij[number[7*i+4]][6]),
        d1q7 = str(qij[number[7*i+4]][7]),
        d1q8 = str(qij[number[7*i+4]][8]),
        d1q9 = str(qij[number[7*i+4]][9]),
        d1q10 = str(qij[number[7*i+4]][10]),
        d1q11 = str(qij[number[7*i+4]][11]),
        d1q12 = str(qij[number[7*i+4]][12]),
        d1q13 = str(qij[number[7*i+4]][13]),
        d1q14 = str(qij[number[7*i+4]][14]),
        d1q15 = str(qij[number[7*i+4]][15]),
        d1q16 = str(qij[number[7*i+4]][16]),
        d1q17 = str(qij[number[7*i+4]][17]),
        d1q18 = str(qij[number[7*i+4]][18]),
        d1q19 = str(qij[number[7*i+4]][19]),
        d1q20 = str(qij[number[7*i+4]][20]),
        d1q21 = str(qij[number[7*i+4]][21]),
        d1q22 = str(qij[number[7*i+4]][22]),
        d1q23 = str(qij[number[7*i+4]][23]),
        d1q24 = str(qij[number[7*i+4]][24]),
        d1e0 = str(eij[number[7*i+4]][0]),
        d1e1 = str(eij[number[7*i+4]][1]),
        d1e2 = str(eij[number[7*i+4]][2]),
        d1e3 = str(eij[number[7*i+4]][3]),
        d1e4 = str(eij[number[7*i+4]][4]),
        d1e5 = str(eij[number[7*i+4]][5]),
        d1e6 = str(eij[number[7*i+4]][6]),
        d1e7 = str(eij[number[7*i+4]][7]),
        d1e8 = str(eij[number[7*i+4]][8]),
        d1e9 = str(eij[number[7*i+4]][9]),
        d1e10 = str(eij[number[7*i+4]][10]),
        d1e11 = str(eij[number[7*i+4]][11]),
        d1e12 = str(eij[number[7*i+4]][12]),
        d1e13 = str(eij[number[7*i+4]][13]),
        d1e14 = str(eij[number[7*i+4]][14]),
        d1e15 = str(eij[number[7*i+4]][15]),
        d1e16 = str(eij[number[7*i+4]][16]),
        d1e17 = str(eij[number[7*i+4]][17]),
        d1e18 = str(eij[number[7*i+4]][18]),
        d1e19 = str(eij[number[7*i+4]][19]),
        d1e20 = str(eij[number[7*i+4]][20]),
        d1e21 = str(eij[number[7*i+4]][21]),
        d1e22 = str(eij[number[7*i+4]][22]),
        d1e23 = str(eij[number[7*i+4]][23]),
        d1e24 = str(eij[number[7*i+4]][24]), 
        d1how = str(how[7*i+4]),
        d1gazo = str(gazo[7*i+4]),

        d2title = str(yi[number[7*i+5]]),
        d2time = str(Ti[number[7*i+5]]),
        d2calo = str(Ci[number[7*i+5]]),
        d2cost = str(Gi[number[7*i+5]]),
        d2f0 = str(f0j[number[7*i+5]]),
        d2f1 = str(f1j[number[7*i+5]]),
        d2f2 = str(f2j[number[7*i+5]]),
        d2f3 = str(f3j[number[7*i+5]]),
        d2f4 = str(f4j[number[7*i+5]]),
        d2f5 = str(f5j[number[7*i+5]]),
        d2f6 = str(f6j[number[7*i+5]]),
        d2f7 = str(f7j[number[7*i+5]]),
        d2f8 = str(f8j[number[7*i+5]]),
        d2f9 = str(f9j[number[7*i+5]]),
        d2f10 = str(f10j[number[7*i+5]]),
        d2f11 = str(f11j[number[7*i+5]]),
        d2f12 = str(f12j[number[7*i+5]]),
        d2f13 = str(f13j[number[7*i+5]]),
        d2f14 = str(f14j[number[7*i+5]]),
        d2f15 = str(f15j[number[7*i+5]]),
        d2f16 = str(f16j[number[7*i+5]]),
        d2f17 = str(f17j[number[7*i+5]]),
        d2f18 = str(f18j[number[7*i+5]]),
        d2f19 = str(f19j[number[7*i+5]]),
        d2f20 = str(f20j[number[7*i+5]]),
        d2f21 = str(f21j[number[7*i+5]]),
        d2f22 = str(f22j[number[7*i+5]]),
        d2f23 = str(f23j[number[7*i+5]]),
        d2f24 = str(f24j[number[7*i+5]]),
        d2q0 = str(qij[number[7*i+5]][0]),
        d2q1 = str(qij[number[7*i+5]][1]),
        d2q2 = str(qij[number[7*i+5]][2]),
        d2q3 = str(qij[number[7*i+5]][3]),
        d2q4 = str(qij[number[7*i+5]][4]),
        d2q5 = str(qij[number[7*i+5]][5]),
        d2q6 = str(qij[number[7*i+5]][6]),
        d2q7 = str(qij[number[7*i+5]][7]),
        d2q8 = str(qij[number[7*i+5]][8]),
        d2q9 = str(qij[number[7*i+5]][9]),
        d2q10 = str(qij[number[7*i+5]][10]),
        d2q11 = str(qij[number[7*i+5]][11]),
        d2q12 = str(qij[number[7*i+5]][12]),
        d2q13 = str(qij[number[7*i+5]][13]),
        d2q14 = str(qij[number[7*i+5]][14]),
        d2q15 = str(qij[number[7*i+5]][15]),
        d2q16 = str(qij[number[7*i+5]][16]),
        d2q17 = str(qij[number[7*i+5]][17]),
        d2q18 = str(qij[number[7*i+5]][18]),
        d2q19 = str(qij[number[7*i+5]][19]),
        d2q20 = str(qij[number[7*i+5]][20]),
        d2q21 = str(qij[number[7*i+5]][21]),
        d2q22 = str(qij[number[7*i+5]][22]),
        d2q23 = str(qij[number[7*i+5]][23]),
        d2q24 = str(qij[number[7*i+5]][24]),
        d2e0 = str(eij[number[7*i+5]][0]),
        d2e1 = str(eij[number[7*i+5]][1]),
        d2e2 = str(eij[number[7*i+5]][2]),
        d2e3 = str(eij[number[7*i+5]][3]),
        d2e4 = str(eij[number[7*i+5]][4]),
        d2e5 = str(eij[number[7*i+5]][5]),
        d2e6 = str(eij[number[7*i+5]][6]),
        d2e7 = str(eij[number[7*i+5]][7]),
        d2e8 = str(eij[number[7*i+5]][8]),
        d2e9 = str(eij[number[7*i+5]][9]),
        d2e10 = str(eij[number[7*i+5]][10]),
        d2e11 = str(eij[number[7*i+5]][11]),
        d2e12 = str(eij[number[7*i+5]][12]),
        d2e13 = str(eij[number[7*i+5]][13]),
        d2e14 = str(eij[number[7*i+5]][14]),
        d2e15 = str(eij[number[7*i+5]][15]),
        d2e16 = str(eij[number[7*i+5]][16]),
        d2e17 = str(eij[number[7*i+5]][17]),
        d2e18 = str(eij[number[7*i+5]][18]),
        d2e19 = str(eij[number[7*i+5]][19]),
        d2e20 = str(eij[number[7*i+5]][20]),
        d2e21 = str(eij[number[7*i+5]][21]),
        d2e22 = str(eij[number[7*i+5]][22]),
        d2e23 = str(eij[number[7*i+5]][23]),
        d2e24 = str(eij[number[7*i+5]][24]), 
        d2how = str(how[7*i+5]),
        d2gazo = str(gazo[7*i+5]),

        d3title = str(yi[number[7*i+6]]),
        d3time = str(Ti[number[7*i+6]]),
        d3calo = str(Ci[number[7*i+6]]),
        d3cost = str(Gi[number[7*i+6]]),
        d3f0 = str(f0j[number[7*i+6]]),
        d3f1 = str(f1j[number[7*i+6]]),
        d3f2 = str(f2j[number[7*i+6]]),
        d3f3 = str(f3j[number[7*i+6]]),
        d3f4 = str(f4j[number[7*i+6]]),
        d3f5 = str(f5j[number[7*i+6]]),
        d3f6 = str(f6j[number[7*i+6]]),
        d3f7 = str(f7j[number[7*i+6]]),
        d3f8 = str(f8j[number[7*i+6]]),
        d3f9 = str(f9j[number[7*i+6]]),
        d3f10 = str(f10j[number[7*i+6]]),
        d3f11 = str(f11j[number[7*i+6]]),
        d3f12 = str(f12j[number[7*i+6]]),
        d3f13 = str(f13j[number[7*i+6]]),
        d3f14 = str(f14j[number[7*i+6]]),
        d3f15 = str(f15j[number[7*i+6]]),
        d3f16 = str(f16j[number[7*i+6]]),
        d3f17 = str(f17j[number[7*i+6]]),
        d3f18 = str(f18j[number[7*i+6]]),
        d3f19 = str(f19j[number[7*i+6]]),
        d3f20 = str(f20j[number[7*i+6]]),
        d3f21 = str(f21j[number[7*i+6]]),
        d3f22 = str(f22j[number[7*i+6]]),
        d3f23 = str(f23j[number[7*i+6]]),
        d3f24 = str(f24j[number[7*i+6]]),
        d3q0 = str(qij[number[7*i+6]][0]),
        d3q1 = str(qij[number[7*i+6]][1]),
        d3q2 = str(qij[number[7*i+6]][2]),
        d3q3 = str(qij[number[7*i+6]][3]),
        d3q4 = str(qij[number[7*i+6]][4]),
        d3q5 = str(qij[number[7*i+6]][5]),
        d3q6 = str(qij[number[7*i+6]][6]),
        d3q7 = str(qij[number[7*i+6]][7]),
        d3q8 = str(qij[number[7*i+6]][8]),
        d3q9 = str(qij[number[7*i+6]][9]),
        d3q10 = str(qij[number[7*i+6]][10]),
        d3q11 = str(qij[number[7*i+6]][11]),
        d3q12 = str(qij[number[7*i+6]][12]),
        d3q13 = str(qij[number[7*i+6]][13]),
        d3q14 = str(qij[number[7*i+6]][14]),
        d3q15 = str(qij[number[7*i+6]][15]),
        d3q16 = str(qij[number[7*i+6]][16]),
        d3q17 = str(qij[number[7*i+6]][17]),
        d3q18 = str(qij[number[7*i+6]][18]),
        d3q19 = str(qij[number[7*i+6]][19]),
        d3q20 = str(qij[number[7*i+6]][20]),
        d3q21 = str(qij[number[7*i+6]][21]),
        d3q22 = str(qij[number[7*i+6]][22]),
        d3q23 = str(qij[number[7*i+6]][23]),
        d3q24 = str(qij[number[7*i+6]][24]),
        d3e0 = str(eij[number[7*i+6]][0]),
        d3e1 = str(eij[number[7*i+6]][1]),
        d3e2 = str(eij[number[7*i+6]][2]),
        d3e3 = str(eij[number[7*i+6]][3]),
        d3e4 = str(eij[number[7*i+6]][4]),
        d3e5 = str(eij[number[7*i+6]][5]),
        d3e6 = str(eij[number[7*i+6]][6]),
        d3e7 = str(eij[number[7*i+6]][7]),
        d3e8 = str(eij[number[7*i+6]][8]),
        d3e9 = str(eij[number[7*i+6]][9]),
        d3e10 = str(eij[number[7*i+6]][10]),
        d3e11 = str(eij[number[7*i+6]][11]),
        d3e12 = str(eij[number[7*i+6]][12]),
        d3e13 = str(eij[number[7*i+6]][13]),
        d3e14 = str(eij[number[7*i+6]][14]),
        d3e15 = str(eij[number[7*i+6]][15]),
        d3e16 = str(eij[number[7*i+6]][16]),
        d3e17 = str(eij[number[7*i+6]][17]),
        d3e18 = str(eij[number[7*i+6]][18]),
        d3e19 = str(eij[number[7*i+6]][19]),
        d3e20 = str(eij[number[7*i+6]][20]),
        d3e21 = str(eij[number[7*i+6]][21]),
        d3e22 = str(eij[number[7*i+6]][22]),
        d3e23 = str(eij[number[7*i+6]][23]),
        d3e24 = str(eij[number[7*i+6]][24]), 
        d3how = str(how[7*i+6]),
        d3gazo = str(gazo[7*i+6])
        )

with open("home/"+str(i+1)+"日目.html", mode="w",encoding="utf_8") as f:
        f.write(d1)
"""

for i in range(day):
    print(i)
    exec(temp)

# for d in range(len(number)):
#     print("=====================================================")
#     print("No" + str(int(number[d]))+ "のレシピ名は"+str(yi[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の調理時間は"+str(Ti[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取カロリーは"+str(Ci[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取たんぱく質は"+str(f0j[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取脂質は"+str(f1j[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取炭水化物は"+str(f2j[int(number[d])]))
#     print("No" + str(int(number[d]))+ "の摂取糖質は"+str(f3j[int(number[d])]))

#     print("=====================================================")
########################################ここまで日にちのhtmlの出力コード入力############################

head = """
<!DOCTYPE html>
<html lang = "ja">
    <head><meta charset="shift-jis" /></head>
<body bgcolor="lightyellow">
    <h1>レシピはこちらです</h1>
"""

home1='''
   	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<a href="home/1日目.html"　target="_blank" style="font-size: 26pt">1日目</a></div><br>
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<h3>朝食</h3>	
	<ul>
	  <li><p>{{i0}}</li>
	</ul>
	<h3>昼食</h3>
	<ul>
	  <li><p>{{i1}}</li>
	  <li><p>{{i2}}</li>
	  <li><p>{{i3}}</li>
	</ul>
	<h3>夕食</h3>
	<ul>
	  <li>{{i4}}</li>
	  <li><p>{{i5}}</li>
	  <li><p>{{i6}}</li>
	</ul>
	</div>
	<br>
	<br>
	<br>
'''

home2="""
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<a href="home/2日目.html"　target="_blank" style="font-size: 26pt">2日目</a></div><br>
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<h3>朝食</h3>
	<ul>
	  <li><p>{{i7}}</li>
	</ul>
	<h3>昼食</h3>
	<ul>
	  <li><p>{{i8}}</li>
	  <li><p>{{i9}}</li>
	  <li><p>{{i10}}</li>
	</ul>
	<h3>夕食</h3>
	<ul>
	  <li><p>{{i11}}</li>
	  <li><p>{{i12}}</li>
	  <li><p>{{i13}}</li>
	</ul>
	</div>
	<br>
	<br>
	<br>
	"""

home3="""
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<a href="home/3日目.html"　target="_blank" style="font-size: 26pt">3日目</a></div><br>
	<div style="display:inline-block; line-height: 1;padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<h3>朝食</h3>
	<ul>
	  <li><p>{{i14}}</li>
	</ul>
	<h3>昼食</h3>
	<ul>
	  <li><p>{{i15}}</li>
	  <li><p>{{i16}}</li>
	  <li><p>{{i17}}</li>
	</ul>
	<h3>夕食</h3>
	<ul>
	  <li><p>{{i18}}</li>
	  <li><p>{{i19}}</li>
	  <li><p>{{i20}}</li>
	</ul>
	</div>
	<br>
	<br>
	<br>
"""

home4="""
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<a href="home/4日目.html"　target="_blank" style="font-size: 26pt">4日目</a></div><br>
	<div style="display:inline-block; line-height: 1;padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<h3>朝食</h3>
	<ul>
	  <li><p>{{i21}}</li>
	</ul>
	<h3>昼食</h3>
	<ul>
	  <li><p>{{i22}}</li>
	  <li><p>{{i23}}</li>
	  <li><p>{{i24}}</li>
	</ul>
	<h3>夕食</h3>
	<ul>
	  <li><p>{{i25}}</li>
	  <li><p>{{i26}}</li>
	  <li><p>{{i27}}</li>
	</ul>
	</div>
	<br>
	<br>
	<br>
"""
home5="""
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<a href="home/5日目.html"　target="_blank" style="font-size: 26pt">5日目</a></div><br>
	<div style="display:inline-block; line-height: 1;padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<h3>朝食</h3>
	<ul>
	  <li><p>{{i28}}</li>
	</ul>
	<h3>昼食</h3>
	<ul>
	  <li><p>{{i29}}</li>
	  <li><p>{{i30}}</li>
	  <li><p>{{i31}}</li>
	</ul>
	<h3>夕食</h3>
	<ul>
	  <li><p>{{i32}}</li>
	  <li><p>{{i33}}</li>
	  <li><p>{{i34}}</li>
	</ul>
	</div>
	<br>
	<br>
	<br>
"""
home6="""
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<a href="home/6日目.html"　target="_blank" style="font-size: 26pt">6日目</a></div><br>
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<h3>朝食</h3>
	<ul>
	  <li><p>{{i35}}</li>
	</ul>
	<h3>昼食</h3>
	<ul>
	  <li><p>{{i36}}</li>
	  <li><p>{{i37}}</li>
	  <li><p>{{i38}}</li>
	</ul>
	<h3>夕食</h3>
	<ul>
	  <li><p>{{i39}}</li>
	  <li><p>{{i40}}</li>
	  <li><p>{{i41}}</li>
	</ul>
	</div>
	<br>
	<br>
	<br>
"""
home7="""
	<div style="display:inline-block;line-height: 1; padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<a href="home/7日目.html"　target="_blank" style="font-size: 26pt">7日目</a></div><br>

	<div style="display:inline-block; line-height: 1;padding: 8px; border: double 6px #4169e1; background-color: #f0f8ff; margin-top: 30px; margin-bottom: 30px;">
	<h3>朝食</h3>
	<ul>
	  <li><p>{{i42}}</li>
	</ul>
	<h3>昼食</h3>
	<ul>
	  <li><p>{{i43}}</li>
	  <li><p>{{i44}}</li>
	  <li><p>{{i45}}</li>
	</ul>
	<h3>夕食</h3>
	<ul>
	  <li><p>{{i46}}</li>
	  <li><p>{{i47}}</li>
	  <li><p>{{i48}}</li>
	</ul>
	</div>
	<br>
	<br>
	<br>
"""

end = """
</body>
</html>
"""

if day == 1:
	body = home1
if day == 2:
	body = home1 + home2 
if day ==3:
	body = home1 + home2 + home3
if day == 4:
	body = home1 + home2 + home3 + home4
if day == 5:
	body = home1 + home2 + home3 + home4 + home5
if day == 6:
	body = home1 + home2 + home3 + home4 + home5 + home6
if day == 7:
	body = home1 + home2 + home3 + home4 + home5 + home6 + home7

html = head + body + end

html = html.replace('</html>\n\n<html>\n', '')
html = html.replace('<html>', '')
html = html.replace('</html>', '')


html = html + "</html>"
#print(html)

if day ==1:
	template = Template(html)
	test = template.render(
		i0 = str(yi[int(number[0])]),
		i1 = str(yi[int(number[1])]),
		i2 = str(yi[int(number[2])]),
		i3 = str(yi[int(number[3])]),
		i4 = str(yi[int(number[4])]),
		i5 = str(yi[int(number[5])]),
		i6 = str(yi[int(number[6])])
	)

if day ==2:
	template = Template(html)
	test = template.render(
		i0 = str(yi[int(number[0])]),
		i1 = str(yi[int(number[1])]),
		i2 = str(yi[int(number[2])]),
		i3 = str(yi[int(number[3])]),
		i4 = str(yi[int(number[4])]),
		i5 = str(yi[int(number[5])]),
		i6 = str(yi[int(number[6])]),
		i7 = str(yi[int(number[7])]),
		i8 = str(yi[int(number[8])]),
		i9 = str(yi[int(number[9])]),
		i10 = str(yi[int(number[10])]),
		i11 = str(yi[int(number[11])]),
		i12 = str(yi[int(number[12])]),
		i13 = str(yi[int(number[13])])
	)

if day ==3:
	template = Template(html)
	test = template.render(
		i0 = str(yi[int(number[0])]),
		i1 = str(yi[int(number[1])]),
		i2 = str(yi[int(number[2])]),
		i3 = str(yi[int(number[3])]),
		i4 = str(yi[int(number[4])]),
		i5 = str(yi[int(number[5])]),
		i6 = str(yi[int(number[6])]),
		i7 = str(yi[int(number[7])]),
		i8 = str(yi[int(number[8])]),
		i9 = str(yi[int(number[9])]),
		i10 = str(yi[int(number[10])]),
		i11 = str(yi[int(number[11])]),
		i12 = str(yi[int(number[12])]),
		i13 = str(yi[int(number[13])]),
		i14 = str(yi[int(number[14])]),
		i15 = str(yi[int(number[15])]),
		i16 = str(yi[int(number[16])]),
		i17 = str(yi[int(number[17])]),
		i18 = str(yi[int(number[18])]),
		i19 = str(yi[int(number[19])]),
		i20 = str(yi[int(number[20])]),
	)


if day ==4:
	template = Template(html)
	test = template.render(
		i0 = str(yi[int(number[0])]),
		i1 = str(yi[int(number[1])]),
		i2 = str(yi[int(number[2])]),
		i3 = str(yi[int(number[3])]),
		i4 = str(yi[int(number[4])]),
		i5 = str(yi[int(number[5])]),
		i6 = str(yi[int(number[6])]),
		i7 = str(yi[int(number[7])]),
		i8 = str(yi[int(number[8])]),
		i9 = str(yi[int(number[9])]),
		i10 = str(yi[int(number[10])]),
		i11 = str(yi[int(number[11])]),
		i12 = str(yi[int(number[12])]),
		i13 = str(yi[int(number[13])]),
		i14 = str(yi[int(number[14])]),
		i15 = str(yi[int(number[15])]),
		i16 = str(yi[int(number[16])]),
		i17 = str(yi[int(number[17])]),
		i18 = str(yi[int(number[18])]),
		i19 = str(yi[int(number[19])]),
		i20 = str(yi[int(number[20])]),
		i21 = str(yi[int(number[21])]),
		i22 = str(yi[int(number[22])]),
		i23 = str(yi[int(number[23])]),
		i24 = str(yi[int(number[24])]),
		i25 = str(yi[int(number[25])]),
		i26 = str(yi[int(number[26])]),
		i27 = str(yi[int(number[27])]),
	)


if day ==5:
	template = Template(html)
	test = template.render(
		i0 = str(yi[int(number[0])]),
		i1 = str(yi[int(number[1])]),
		i2 = str(yi[int(number[2])]),
		i3 = str(yi[int(number[3])]),
		i4 = str(yi[int(number[4])]),
		i5 = str(yi[int(number[5])]),
		i6 = str(yi[int(number[6])]),
		i7 = str(yi[int(number[7])]),
		i8 = str(yi[int(number[8])]),
		i9 = str(yi[int(number[9])]),
		i10 = str(yi[int(number[10])]),
		i11 = str(yi[int(number[11])]),
		i12 = str(yi[int(number[12])]),
		i13 = str(yi[int(number[13])]),
		i14 = str(yi[int(number[14])]),
		i15 = str(yi[int(number[15])]),
		i16 = str(yi[int(number[16])]),
		i17 = str(yi[int(number[17])]),
		i18 = str(yi[int(number[18])]),
		i19 = str(yi[int(number[19])]),
		i20 = str(yi[int(number[20])]),
		i21 = str(yi[int(number[21])]),
		i22 = str(yi[int(number[22])]),
		i23 = str(yi[int(number[23])]),
		i24 = str(yi[int(number[24])]),
		i25 = str(yi[int(number[25])]),
		i26 = str(yi[int(number[26])]),
		i27 = str(yi[int(number[27])]),
		i28 = str(yi[int(number[28])]),
		i29 = str(yi[int(number[29])]),
		i30 = str(yi[int(number[30])]),
		i31 = str(yi[int(number[31])]),
		i32 = str(yi[int(number[32])]),
		i33 = str(yi[int(number[33])]),
		i34 = str(yi[int(number[34])])
	)

if day ==6:
	template = Template(html)
	test = template.render(
		i0 = str(yi[int(number[0])]),
		i1 = str(yi[int(number[1])]),
		i2 = str(yi[int(number[2])]),
		i3 = str(yi[int(number[3])]),
		i4 = str(yi[int(number[4])]),
		i5 = str(yi[int(number[5])]),
		i6 = str(yi[int(number[6])]),
		i7 = str(yi[int(number[7])]),
		i8 = str(yi[int(number[8])]),
		i9 = str(yi[int(number[9])]),
		i10 = str(yi[int(number[10])]),
		i11 = str(yi[int(number[11])]),
		i12 = str(yi[int(number[12])]),
		i13 = str(yi[int(number[13])]),
		i14 = str(yi[int(number[14])]),
		i15 = str(yi[int(number[15])]),
		i16 = str(yi[int(number[16])]),
		i17 = str(yi[int(number[17])]),
		i18 = str(yi[int(number[18])]),
		i19 = str(yi[int(number[19])]),
		i20 = str(yi[int(number[20])]),
		i21 = str(yi[int(number[21])]),
		i22 = str(yi[int(number[22])]),
		i23 = str(yi[int(number[23])]),
		i24 = str(yi[int(number[24])]),
		i25 = str(yi[int(number[25])]),
		i26 = str(yi[int(number[26])]),
		i27 = str(yi[int(number[27])]),
		i28 = str(yi[int(number[28])]),
		i29 = str(yi[int(number[29])]),
		i30 = str(yi[int(number[30])]),
		i31 = str(yi[int(number[31])]),
		i32 = str(yi[int(number[32])]),
		i33 = str(yi[int(number[33])]),
		i34 = str(yi[int(number[34])]),
		i35 = str(yi[int(number[35])]),
		i36 = str(yi[int(number[36])]),
		i37 = str(yi[int(number[37])]),
		i38 = str(yi[int(number[38])]),
		i39 = str(yi[int(number[39])]),
		i40 = str(yi[int(number[40])]),
		i41 = str(yi[int(number[41])])
	)


if day ==7:
	template = Template(html)
	test = template.render(
		i0 = str(yi[int(number[0])]),
		i1 = str(yi[int(number[1])]),
		i2 = str(yi[int(number[2])]),
		i3 = str(yi[int(number[3])]),
		i4 = str(yi[int(number[4])]),
		i5 = str(yi[int(number[5])]),
		i6 = str(yi[int(number[6])]),
		i7 = str(yi[int(number[7])]),
		i8 = str(yi[int(number[8])]),
		i9 = str(yi[int(number[9])]),
		i10 = str(yi[int(number[10])]),
		i11 = str(yi[int(number[11])]),
		i12 = str(yi[int(number[12])]),
		i13 = str(yi[int(number[13])]),
		i14 = str(yi[int(number[14])]),
		i15 = str(yi[int(number[15])]),
		i16 = str(yi[int(number[16])]),
		i17 = str(yi[int(number[17])]),
		i18 = str(yi[int(number[18])]),
		i19 = str(yi[int(number[19])]),
		i20 = str(yi[int(number[20])]),
		i21 = str(yi[int(number[21])]),
		i22 = str(yi[int(number[22])]),
		i23 = str(yi[int(number[23])]),
		i24 = str(yi[int(number[24])]),
		i25 = str(yi[int(number[25])]),
		i26 = str(yi[int(number[26])]),
		i27 = str(yi[int(number[27])]),
		i28 = str(yi[int(number[28])]),
		i29 = str(yi[int(number[29])]),
		i30 = str(yi[int(number[30])]),
		i31 = str(yi[int(number[31])]),
		i32 = str(yi[int(number[32])]),
		i33 = str(yi[int(number[33])]),
		i34 = str(yi[int(number[34])]),
		i35 = str(yi[int(number[35])]),
		i36 = str(yi[int(number[36])]),
		i37 = str(yi[int(number[37])]),
		i38 = str(yi[int(number[38])]),
		i39 = str(yi[int(number[39])]),
		i40 = str(yi[int(number[40])]),
		i41 = str(yi[int(number[41])]),
		i42 = str(yi[int(number[42])]),
		i43 = str(yi[int(number[43])]),
		i44 = str(yi[int(number[44])]),
		i45 = str(yi[int(number[45])]),
		i46 = str(yi[int(number[46])]),
		i47 = str(yi[int(number[47])]),
		i48 = str(yi[int(number[48])])
	)

with open("home.html", mode="w") as f:
            f.write(test)

print("献立の出力が完了しました。")