let tiles = {
"2477": [
"....#...#.",
"#..##...#.",
"...#.....#",
"..#...#.#.",
"#.#......#",
".#.#######",
"..#.#...#.",
".#.....#..",
"#..#......",
".###.####."],
"2609": [
".##...####",
"...#.##.##",
"...#......",
"...#....#.",
".##....#.#",
"..........",
"....##....",
"#....#..##",
"..######..",
".##.##.#.#"],
"3461": [
"##.##..##.",
".##....#..",
"...#....#.",
"#.#.#...#.",
"........#.",
".#.#..#..#",
"..#.......",
"#..##.....",
"...#.....#",
".#..####.."],
"1753": [
"#...#####.",
"#...#.#..#",
"#.#....#..",
"#.......#.",
".....###.#",
".......#..",
".....#....",
"..##...#.#",
"#......#..",
"#.#..##.#."],
"1259": [
"...##...##",
"#.##.#.###",
"#.#.....#.",
"###..#...#",
"...#......",
"##.#..#...",
"#........#",
"..##.####.",
"..##....##",
"....##.#.."],
"3181": [
".#######.#",
"#...#....#",
"#.....#..#",
"#.#.#...#.",
".#..#.....",
"....#.....",
"#.......#.",
"#.........",
"..#..###..",
".##..#...#"],
"1123": [
"#..####.#.",
"#...#.....",
"#.........",
"....#.#..#",
"..........",
"..##...#.#",
"#..#......",
"#...#.#..#",
".##.##....",
"#####.####"],
"2699": [
"....###.#.",
"#.#......#",
"#..##....#",
"..#.....#.",
"#.#......#",
"....#...##",
".##...#.##",
"..........",
"#.#...#...",
"##.#...#.#"],
"2897": [
"#.#.##..##",
"#....#..##",
"....#...#.",
"..........",
"#..#..#..#",
"#.........",
"##.......#",
"##.##....#",
"........##",
"#.##.#...#"],
"2531": [
".##....#.#",
"#...#..###",
"...#....#.",
"#.......##",
"#.......##",
"......#...",
"#.#.......",
"#......#.#",
"#..#.#...#",
"...#.##..#"],
"3917": [
".#.#.#..#.",
"##..#....#",
"....#....#",
"#.##..#..#",
"#...#....#",
".....#.#.#",
".....#.#.#",
"##..#.#.##",
".....#...#",
".##.###.##"],
"1193": [
"#.###...##",
"#..##.####",
"#.#......#",
"...###....",
".#.#..#...",
"##...#...#",
"##.......#",
"..........",
"...#......",
"##..#.#.#."],
"2011": [
"####.#..#.",
"..#...#..#",
"#.....#...",
"..........",
"..#.#.....",
"#........#",
".....#...#",
"#........#",
".........#",
".###..##.."],
"3209": [
"######.##.",
"......#..#",
"....#...##",
"..##..#...",
"...#.....#",
"....##...#",
"#.......##",
"..#..#....",
"....#.....",
".#..#.####"],
"3659": [
".#...##..#",
"........#.",
"#...#.....",
"#........#",
"....##...#",
"#..#....#.",
".#..#..#..",
"#....#.#.#",
".........#",
"###.#.#..#"],
"3623": [
".##..##...",
"..#.....##",
"#.........",
".#.#.....#",
"...#.....#",
".......##.",
"#.......#.",
"...#.#...#",
"#......#.#",
"..#####..."],
"3049": [
"####.#####",
"..#.....#.",
".#..#...#.",
".#..##...#",
"#........#",
"#.#.......",
"#.##......",
".#....#..#",
"##........",
".####..#.#"],
"3361": [
"....#.#..#",
"...#...###",
"#....#...#",
"#....##..#",
"###.#.##.#",
"...#.#...#",
"##.#......",
"#....##..#",
".#.....###",
".##.#....."],
"2861": [
".#.##.#..#",
"#..#...#..",
"....#....#",
"..#.....##",
"...#.....#",
"#..##.....",
"##.......#",
".....#...#",
".#..#..#..",
"..#.#.#.#."],
"3797": [
".......##.",
"#....#....",
"#..#...#..",
"#..#..###.",
"#.#...#..#",
".#...#...#",
"...##.....",
".#.....#..",
"..#.....#.",
"#.##.##..#"],
"3593": [
".#.....###",
"..##....#.",
"..##..#...",
"#...#...##",
".#.....#.#",
"#.#...#..#",
"#....#...#",
"#.....#..#",
"###..#.###",
".##..##.#."],
"2161": [
".#.##....#",
"#....#....",
"....#....#",
"####...##.",
"#..#..##.#",
"#.........",
"..#.#...##",
"#.....#..#",
".........#",
"#.###.#..."],
"3769": [
"#..###....",
"##........",
"#.#....#..",
"....#.....",
"#..##.#...",
"#....#.#..",
"#........#",
"......#.#.",
"##.....#.#",
".#....#..#"],
"3467": [
"..#.#.####",
"##.......#",
".##..#....",
"...###...#",
".##.###..#",
"....###..#",
".....#....",
"##.......#",
"#....##...",
"#.#..#..#."],
"2503": [
"#..###.###",
".#.....#.#",
"#......#.#",
"...#.##...",
"###.#....#",
"....#....#",
"#.#...##..",
"#.......#.",
"#.#.#....#",
"....######"],
"3389": [
"#..###..##",
"..........",
".......##.",
"..........",
"..........",
"..........",
"#.....###.",
".........#",
"##.#.##..#",
".##.##.#.."],
"3919": [
"..#..#.#..",
"##....##.#",
"##..#...#.",
"#.......##",
"#.#.#.#...",
"##..#.#..#",
"......##.#",
"...###...#",
"#...#.....",
"..#.#.#..."],
"2663": [
"#.#...####",
".......#.#",
".#.....#..",
"#.....#.##",
".#..#.....",
"..##..#..#",
"#......##.",
"...#...#..",
"#.##...#.#",
"...##....."],
"3253": [
".#####..#.",
".......#.#",
"#..#...##.",
"....#.....",
".........#",
"...#.#....",
"##........",
"........#.",
"#....#...#",
".####.##.#"],
"3329": [
"......####",
".......#.#",
"..##......",
"#....#...#",
".....##...",
".....#..##",
".....#....",
".#.#.#....",
".#.......#",
"#.##......"],
"2393": [
".#...#...#",
"....#.....",
"....#...##",
"#.#..##.#.",
"...#.#...#",
".....#..#.",
".##..##..#",
"##..#..#..",
".#........",
".##.#.#.#."],
"2339": [
"##....##.#",
"..#......#",
"##.....##.",
".........#",
"...##....#",
"#....#.##.",
"#.#.....##",
".#..#.##..",
"##.###..#.",
"######..#."],
"1097": [
"###.##.#.#",
".#.#.....#",
"...#.#....",
"##...##...",
".#....##..",
"#....##.##",
"....##....",
"#.#......#",
"#.#..#...#",
"#.####...."],
"2423": [
"#....#.#..",
"#.....#...",
"#.........",
"#...#.....",
"..###.#..#",
"#...##....",
"#.........",
"#..#.....#",
"...#..#...",
"#..##.#..."],
"3067": [
".#####.#.#",
"###..#.#..",
"..........",
"#........#",
"..##.....#",
"#......#..",
".#..#.#...",
"##...#..##",
"....#.....",
"...#.##.##"],
"3541": [
"#.#.##.###",
"..........",
"..#.#...##",
"#..##.#..#",
".........#",
"#.....#...",
"#..#......",
"#.##......",
".#...#.#.#",
".#####..##"],
"3559": [
"##.#.#.#..",
"#....#..#.",
"##...#....",
".....#..##",
"#.........",
"..#...#...",
".#...#...#",
"#...#..#..",
"....#....#",
".....###.#"],
"2797": [
".....#..##",
"#.#....#..",
"##...#....",
"#.........",
"...#......",
"...#...#..",
"#.......#.",
"..........",
"....#....#",
"#......###"],
"2803": [
"##....#.##",
"..#.......",
".###.#....",
"#.#.#.....",
".........#",
"#..#...##.",
"#.#.##..#.",
".##...##.#",
"#.#......#",
".###.#.#.."],
"2297": [
".#.#.##.#.",
"#.##.....#",
"#.##....#.",
".......#.#",
"#..#......",
".##.#..#..",
"..........",
"..#.##..##",
"#.......##",
".###.##.#."],
"3511": [
"...#.#....",
"#.....#..#",
".......#..",
"..##.#.##.",
"#.#....#..",
"#.#.#.#...",
".#........",
"#.#.....##",
".#....#..#",
"####..#.#."],
"2083": [
"#####.....",
"##..#.#..#",
"....#....#",
"...#......",
"##....##.#",
"#....#.#..",
"##.....##.",
".......#.#",
"##........",
"###..##.##"],
"1567": [
"####.###.#",
"....#....#",
".#..##.#..",
"#........#",
"...#.#...#",
"#.#..##.##",
"##...#....",
"##........",
"#........#",
"#...#.#..#"],
"2767": [
"..###.##..",
"#..#..#..#",
".###.....#",
"#..#......",
"......####",
"....#..#..",
"#.....##.#",
"#.#...#..#",
".#....##..",
".#..####.."],
"2081": [
".#.##.####",
"#...#.#...",
"#...#.##..",
"..#.....##",
"...##....#",
"...#......",
"...#.#....",
"..........",
"..........",
".####..###"],
"1697": [
"...#...###",
"#..#..#...",
".....#..#.",
"#........#",
"#..#......",
"#.......#.",
"#....#....",
"#...#.##..",
"#....#..##",
"#.##..#..."],
"3433": [
".###...##.",
"#........#",
".#...###.#",
"##.......#",
".......#.#",
".....##.#.",
"#..#..#...",
".......#..",
".....###..",
".....#.#.#"],
"1543": [
"#.###.##..",
".#...#....",
"##.....###",
"#..####.#.",
"#...#.....",
".#......##",
"#.........",
"....#.#.##",
"##.......#",
".#........"],
"2389": [
"#....#####",
".##......#",
"###.#....#",
"..#.......",
"...#.#...#",
".......#.#",
"#....#....",
"...#...#..",
"#.#.......",
".##..###.#"],
"2347": [
"#....##..#",
"#......###",
"........#.",
".#...#.#..",
"#........#",
".....##...",
"#........#",
"#.....#...",
"##....#..#",
"##...#.###"],
"1877": [
".#.#.##.#.",
"#..##...##",
"#...#...##",
"##.#......",
"........##",
"....#.#..#",
"#..##.....",
"....#...##",
"#.#.#.#..#",
".#..#..#.#"],
"2927": [
".#.#...###",
"#...#.....",
"..#.......",
"##...#...#",
"#..#...#.#",
"..........",
"#.#..##...",
"#.#.......",
".....#...#",
"......###."],
"1483": [
"..#.#...#.",
"###.##....",
"#..##.....",
".#...##..#",
"...#.##.##",
"#.#..#.#.#",
"..#..#....",
"#..#......",
"#........#",
"....##.##."],
"1493": [
"#.#....##.",
"..#....#..",
"..........",
".....#...#",
".....##..#",
"...#..#..#",
".........#",
"#.#.#....#",
".#.....#.#",
"..###...#."],
"2621": [
"#..##.#..#",
"..##.#...#",
"..........",
"#......#..",
".###..#...",
"###.#....#",
"##..#....#",
"##..#....#",
".........#",
"##.#......"],
"3167": [
"..#.###..#",
"###.#....#",
"#........#",
"..##......",
"###.#..#..",
"##...#...#",
"..........",
"##.#...#.#",
".###.....#",
"####.##..."],
"3701": [
".#.#...##.",
"......#...",
"#.........",
"......#..#",
"....#....#",
"....#.#..#",
"#..##....#",
"#.....#..#",
"#...###..#",
"..##.#...."],
"1663": [
"##.#..##..",
"#.....#...",
"....###...",
"#....##..#",
"....#...#.",
"#..####..#",
"...##.....",
".##..#....",
"#.#....#..",
"#..##.#.##"],
"1879": [
".#....#...",
"....###.#.",
"#....#...#",
"#..##.....",
"#......#.#",
".....#....",
"#.........",
".........#",
".#........",
"##.#...#.#"],
"1021": [
"..#.......",
".#......##",
".##...#...",
".##.......",
"##.#...#.#",
"#..#.....#",
".#........",
"...###...#",
"###.......",
"....#..###"],
"3767": [
"..#.#....#",
".....#.#..",
"..#..#....",
"##..##....",
".#.......#",
"...#......",
"......##.#",
"#.......##",
"#........#",
".######.##"],
"1847": [
"....####.#",
"##.#...#..",
"##.#.##..#",
"..####...#",
"#........#",
"#.........",
"#...#....#",
"##.#.#..##",
"..##.....#",
"##.##..#.."],
"3691": [
"#.##..#...",
"...#....#.",
"#...#.....",
".....#....",
"......#.#.",
".#........",
".#........",
".........#",
"..........",
"#.....##.#"],
"2351": [
"###..###.#",
"#....##...",
"#......#..",
"###......#",
"#...##.###",
"##...##..#",
"..#.......",
".#....##..",
"...#......",
".###.##.##"],
"2753": [
"#.####..#.",
"#.......#.",
"..#.#.....",
".....#....",
"#..#..#...",
"#......#..",
"..#...####",
"#.......##",
"....#...#.",
"....#.#..#"],
"2141": [
"....##...#",
"..#..#....",
"..........",
"..........",
"###....#..",
"...##.#...",
"##.#.....#",
".#....#..#",
"#.#....#..",
".#########"],
"1901": [
".....#.#.#",
"#......#..",
"#...#...#.",
"...#....##",
"#..#.#....",
"........#.",
".......#.#",
"#.....##..",
"#...#.#.##",
".#....##.#"],
"3137": [
".##...#...",
".#.....###",
"#.#.#..#.#",
"#.###.#...",
"#..##...#.",
".........#",
"#.#..###.#",
"#......#.#",
"#......#..",
".#..#.#..."],
"3407": [
".#.###.###",
"...#......",
"..#.##....",
".#.....#..",
"....#.#..#",
"...#...#..",
"....#..#..",
"##...#....",
".#....###.",
"##.###.##."],
"1013": [
"##.#.###..",
"#...#.##.#",
"#........#",
"#..#.....#",
"..........",
".........#",
"...#......",
".#.....#.#",
".......#..",
".#...####."],
"1049": [
"...#....##",
"#.........",
"#.....#..#",
"#..#....##",
".##...#...",
"......#..#",
"##..#.#...",
"#.##....##",
"....#....#",
"#####.#.#."],
"2549": [
"#.#..###.#",
"#..#......",
"...#....#.",
".....#...#",
"#.##.....#",
"###..#.#..",
"...##.....",
"##...#....",
"#......#..",
"..##.####."],
"2843": [
".##.###...",
"....#....#",
"#.......##",
"#........#",
".......#.#",
"#.......##",
"#.#..#...#",
"#...#.....",
"#...#....#",
".....###.."],
"1889": [
"##.##..#..",
"...#....##",
"#........#",
"#......#..",
"##..#.#.##",
"......#...",
"..#.......",
"..#......#",
"#.#..#....",
"..#......#"],
"2887": [
".####.##.#",
"#..#......",
"#.........",
"#....#....",
"#....#...#",
".....#...#",
"#.#.#.##.#",
".#........",
"##.#.#....",
"...#.#.##."],
"1579": [
"..######.#",
"..........",
"#.##..#...",
"####..#..#",
"#........#",
"...##....#",
"..#.......",
"..........",
"..........",
"....#....#"],
"3079": [
"##.#....#.",
"###.....##",
"...##...##",
"#....#..#.",
"....###...",
"...####...",
"...#.#....",
".#.#.#..##",
".....#..#.",
"##...#..#."],
"1297": [
".####.###.",
"##...#...#",
".....#..#.",
"#...#.....",
"###......#",
".#..#....#",
"#....#..##",
".##...#...",
"#....#....",
"###.####.#"],
"1783": [
"...#.#.#..",
"#...#.....",
"..#..#...#",
"......##..",
"###..#.##.",
".#...###..",
"#.........",
"#........#",
"..#......#",
"..#..##.#."],
"1609": [
".#.##..#.#",
".#.#....#.",
"#.##......",
"..#......#",
".##.#.#.##",
"..#.......",
"###......#",
"...#...#.#",
"...###....",
"..#.....#."],
"3793": [
"##.#.##.#.",
"...#......",
"..##....#.",
"#...#...##",
".......#.#",
".....#.#..",
"....#....#",
"#.##.....#",
"#..#.##..#",
"###.##..#."],
"1069": [
"..#.#...#.",
"..#.#....#",
"##..#.#..#",
".....#....",
".....##.#.",
".#.##.#...",
"#.......##",
"##........",
"....#.#..#",
".#..###.##"],
"1229": [
"..#.#####.",
".......#..",
"....#.#.##",
".#........",
"#...#..##.",
"##....#.#.",
"#........#",
"..........",
".......#..",
"##.##....#"],
"1163": [
"....#.#.#.",
"#..#.#...#",
".........#",
"#........#",
"#....#....",
"..#.#....#",
"#...#....#",
"#....##...",
"#..#......",
"#..##.#.##"],
"3847": [
"#...#.####",
".........#",
"......#...",
"#..#..#.##",
".....##...",
"#........#",
"#...#....#",
"#.#....#.#",
"#...#....#",
"#....#####"],
"3823": [
"#..##.....",
"..#..#.#..",
"#.........",
"#.#.##....",
"#....#...#",
"#..#......",
"#...#.....",
"..........",
"..........",
"...#..#..#"],
"3583": [
"#...#.###.",
"##......##",
".#........",
"..#.......",
"....##..#.",
".........#",
"##........",
"###.#...#.",
".#........",
"#.#..####."],
"2399": [
"#..##..#..",
"##......#.",
"#.#.#.#...",
"...##.#..#",
"......#..#",
"#.#.###...",
".#.....#.#",
"###..#....",
".#.#..#..#",
"###..##..."],
"3347": [
".#.#....#.",
"..#.#....#",
"..........",
"#.##.#.#.#",
"....#.....",
".#....#...",
"#........#",
"#....#...#",
"#..####..#",
"..#####.#."],
"1307": [
"#...#...#.",
"....#....#",
".#.......#",
".......#..",
"#.#.#...##",
"#..#.#.#.#",
"##.#.#.##.",
"....##....",
"#.....#.##",
".#..#...#."],
"2099": [
".##...####",
"...#.##.##",
".....##...",
"#...#.#...",
".#......#.",
"#........#",
"...#..####",
"....##..#.",
".....#....",
"..#.###..."],
"3109": [
"#..#.###.#",
"....#.#.##",
"....##..##",
"#.#...#...",
"#.......#.",
"#..#......",
".#.....#.#",
"#.##....#.",
"..#.......",
"....##..#."],
"1787": [
"#...#...##",
"#.........",
"###.......",
"...#..##..",
"#.#.##....",
"##....#..#",
"##........",
"#..##.##.#",
"..#....###",
"....#..#.#"],
"3019": [
"#.##...#.#",
"#...##...#",
"...#..#.#.",
"......##.#",
".#..####..",
"#.#.....#.",
"#......#..",
"#.........",
"..........",
"...###...#"],
"2857": [
".#...##.#.",
"#.....#..#",
"#.....##..",
"#......#.#",
"...#..#...",
"...#.....#",
"#...###..#",
".....##..#",
"...#...#..",
"##.#....##"],
"3083": [
"#..##..##.",
".#....#.##",
"#..#....##",
"..........",
"#...#..#.#",
".........#",
".#........",
"##.......#",
"..........",
".##...##.."],
"1583": [
"#.###.....",
"....##.#..",
"..........",
"#.....#.##",
"#........#",
"##........",
"#......#..",
".........#",
"#.#.#.....",
".#.####..."],
"2693": [
"...####.#.",
".........#",
"#.........",
"....#.##.#",
"#.......#.",
".........#",
"...#......",
".......#.#",
"..#.#....#",
".#..#..#.."],
"1019": [
".#.#......",
"#......#.#",
".#...#.#.#",
"#.#.......",
"......#.#.",
"#........#",
"##..#..#.#",
"#.#####.#.",
".....#...#",
".......###"],
"1031": [
"#..#......",
".........#",
"#.....#..#",
"....#.#.#.",
"..#......#",
"#...#....#",
"...#..##..",
".#..#...#.",
".......##.",
".#.#..#..."],
"3119": [
"...#.#..##",
"#.##......",
"....#.#.##",
"##..#.#..#",
"........#.",
"#...#.#...",
"...#.....#",
"..##....##",
"#..#...#.#",
"###...#.#."],
"1811": [
".####..###",
"#......#.#",
"#.........",
".......#..",
"..#.##...#",
"........##",
"#....#....",
"#..#.#.#.#",
"#..#...#..",
"..####.###"],
"2473": [
".#....####",
"##.....#..",
"....#..###",
"#..#....#.",
"###...##..",
"..........",
"...#.#...#",
"........##",
"##......##",
"....#....."],
"1373": [
"..#..#....",
"#...####.#",
"....#....#",
"....###...",
"...#.##.#.",
"#..#.#...#",
"...#..#..#",
"#..#.#...#",
"##.###....",
".#.#####.."],
"3803": [
"#...##.#.#",
"#.#..#..#.",
".........#",
"..#......#",
".#.#..#..#",
"..........",
"##..#.###.",
"..#####.##",
"....##...#",
".#.##.##.."],
"1291": [
"#..#.....#",
"#..#..##.#",
"#.#......#",
"....#...#.",
"##.######.",
"#........#",
"#....#....",
"#.....#...",
"#####.....",
"#######.#."],
"1489": [
"#...#...##",
"#..#....#.",
"....##....",
"....#.....",
"#........#",
"#.#......#",
"##......##",
"#.#.#.....",
".....#.#.#",
"#.#.###.##"],
"2633": [
".#..##.#..",
"..#.#...##",
"#.........",
"#..#......",
"#..#.....#",
"#.........",
"#....#..##",
"#.###.....",
"#.##.#..#.",
"...#..###."],
"2441": [
"#.#..###..",
"...#.....#",
"#...##...#",
"#.##...#..",
"#.....####",
"#..#....#.",
"...#......",
"#.........",
"#.#.......",
"....###.#."],
"2689": [
"##..#.....",
".#........",
"..........",
"#.#.......",
"....#...##",
"..........",
"#.....#...",
"#...#.....",
"#.....#...",
"####...#.."],
"1559": [
"#..###..#.",
"#.......##",
"......#...",
".##..###..",
"#..#..##.#",
"..#...##.#",
"#.........",
"#..#.#...#",
"##.....###",
".#.....#.."],
"1973": [
".###......",
"#......#.#",
".#........",
"...#.....#",
"..#....#..",
"....##....",
"..........",
"......#..#",
".....#....",
"#..#.#...#"],
"2113": [
"#.##.#.#.#",
"..#..##...",
"#...#.#...",
".#.#......",
".#..###..#",
"........#.",
"#........#",
"#.#.#..#..",
"..........",
"##.##...#."],
"2903": [
"..#...##.#",
"#...#.....",
"#..###.###",
"...#.#...#",
"#...#...##",
"#..#..#..#",
"#........#",
"##.###...#",
"#.#..#...#",
".#....#..."],
"2003": [
".##.#..#..",
"...##...##",
".#.....#.#",
"##..##...#",
"...#.#.#.#",
".........#",
"#...#.##..",
".....##..#",
"#.#..#....",
"###...##.#"],
"2273": [
"...##.#...",
".##....##.",
"#......##.",
"#.......##",
"....##...#",
"......#...",
"..#.#.....",
".#.#..##.#",
"#........#",
"..#.#..#.."],
"2111": [
"#.#..#..##",
"#...##...#",
"..........",
"###.....##",
"##......#.",
"..........",
"#....#####",
"#...#.#.#.",
"....#..#.#",
"#...#.###."],
"2203": [
".#####.##.",
"#...##...#",
"#..#...#..",
"#.###...##",
"#....##.##",
"#....#..##",
"....#.....",
"...#....##",
"#.#...#...",
"#.#.#..###"],
"2153": [
"#.###..#..",
"..........",
"...#.....#",
"..###..##.",
"...#.....#",
"....#....#",
"#...#....#",
"#.........",
"#..##...#.",
"###.##..#."],
"2963": [
".#.#.####.",
"#....#....",
".........#",
"#........#",
"#..#.....#",
"#.#......#",
"......#.##",
".....#....",
"#...###...",
".####..##."],
"3491": [
"...##.####",
"#.#.....##",
".#..#..##.",
"#........#",
".#...#...#",
"....#...#.",
"#.#......#",
".........#",
"....#...#.",
"##.##..#.#"],
"2087": [
"#.#......#",
"#..##..#..",
"#..#......",
"#...##...#",
"#......#.#",
"#.#...#...",
"......#..#",
"#...#....#",
"#....#....",
"##.#..#..#"],
"2063": [
"..##...##.",
"....#....#",
"#..#...#.#",
"#........#",
"##......##",
"..#..##..#",
"......#.#.",
"#.#.......",
"..##.#....",
".#######.."],
"3851": [
".#........",
"#.#.....#.",
".........#",
"......#...",
".#....#..#",
"...##.....",
"#........#",
"#.......#.",
"#.#......#",
"##.####..#"],
"1117": [
"##.......#",
"..#......#",
"##.......#",
"##........",
"...####.#.",
"..##.##..#",
"...#....#.",
"##.#......",
".........#",
".#.##....#"],
"3967": [
"...#.##...",
"#..#..##.#",
"#.....##.#",
"#......#.#",
"#.......#.",
"##........",
"#..#.#.#..",
"....#.#.##",
".#.#..#...",
"###.##.##."],
"2879": [
"###..#..##",
".....#.#..",
"...##.....",
"#.###.#..#",
".........#",
".#.#.....#",
"#.#.##....",
"#..##....#",
"##.......#",
"#.##.#####"],
"2851": [
"###..#.##.",
".###...##.",
"...##.#.#.",
"#........#",
"#........#",
".#.#......",
"##.#......",
"..###.....",
".#...#..#.",
"#.####..#."],
"3529": [
".#.#.#####",
"..........",
"...#..#..#",
"...#.....#",
"#.#......#",
"#....####.",
".....#...#",
"#.##......",
".#...#...#",
"#.#..###.#"],
"3307": [
"#.#..###..",
"....#..###",
"#.##....##",
"#..#.##.#.",
"#.#...##.#",
".#....#...",
"...#.#...#",
"...#...#.#",
"##......#.",
"...#......"],
"3739": [
"#.###.#...",
".#.#..##.#",
"..#..#..##",
"#...##...#",
"#...#..#..",
".........#",
".....#...#",
"##....#...",
".#......##",
"...#..#..#"],
"2617": [
"##.###.#..",
"..#......#",
"..#....#..",
".#....#...",
".#..#.....",
"...#..##..",
"...#.....#",
"#.......#.",
"#.#..#...#",
"..###..#.."],
"2053": [
".#....#.##",
"#...#.....",
".........#",
"#........#",
"...#..##..",
"###..#.###",
"........#.",
".....#####",
"##....#...",
".###.##..#"],
"2447": [
".#.....##.",
"......##.#",
"#......#..",
".#......#.",
".#.##.#..#",
"#.#....###",
"#.#......#",
"##........",
".#.......#",
"#.#.#....#"],
"1999": [
".#...###..",
"#...#..#..",
"#.#.......",
"...#....##",
"#.#.......",
"##...###..",
"#......#..",
"...###.#..",
"####...##.",
".....#..#."],
"1009": [
"...#####.#",
"....##...#",
"...#.#....",
"#..#.#.#.#",
"#...##....",
"........##",
"#.....#..#",
".#..##.#.#",
"#..#...#..",
"...#.#..##"],
"2267": [
".#.#..##..",
".#.......#",
"#........#",
".#.......#",
"#..#...#.#",
"#..#..#..#",
".####.....",
"..#......#",
"##.....#..",
"##...####."],
"2131": [
"###.#..##.",
".#....#...",
"...##.####",
"..#.#..#..",
"#.#....#.#",
"...###.#..",
"#.....#..#",
"..#...####",
"##.#..#..#",
"#..###..##"],
"2251": [
"###.......",
"....#.#..#",
".....#....",
"...#..#...",
".........#",
"##..#.....",
"##.......#",
".#.....#.#",
"#.#.....#.",
"#...#....."],
"1109": [
"..##....#.",
".#...#..##",
"#.........",
"#..##....#",
"...#...#..",
"#.##......",
".#...#.#..",
"...#..##..",
".#...##...",
".##.###.#."],
"3343": [
"..###.#.##",
"#....#.###",
"....#....#",
".........#",
"..##....#.",
"#.....##..",
"#..#......",
".........#",
".###...#..",
".#..######"],
"2383": [
".#.####.##",
"#.....#..#",
"#......#.#",
"##.....##.",
"#......###",
"....#...#.",
"....#...#.",
"##....#..#",
"##..###..#",
".####.#..."],
"2281": [
"..#...##..",
"#..#...#.#",
".#........",
".#.#....##",
"..##.#.#..",
"..#...#...",
"###.#..#.#",
"#...##.#.#",
"...##.#..#",
"#..#.....#"],
"3191": [
".###.###.#",
"..#.......",
".##....###",
"...#..#...",
"..#......#",
"#...#.....",
"#........#",
"#....#..##",
"#.#.#...#.",
"#.......#."]
};
function flipX(tile) {
let size = tile.length;
let res = [];
for (let row of tile) {
let resrow = [];
for (let i = size - 1; i >= 0; --i) {
resrow.push(row[i]);
}
res.push(resrow.join(''));
}
return res;
}
function flipY(tile) {
let size = tile.length;
let res = [];
for (let i = size - 1; i >= 0; --i) {
res.push(tile[i]);
}
return res;
}
function rotate90(tile) {
let size = tile.length;
let res = [];
for (let i = 0; i < size; ++i) {
let resrow = [];
for (let j = size - 1; j >= 0; --j) {
resrow.push(tile[j][i]);
}
res.push(resrow.join(''));
}
return res;
}
function print(tile) {
for (let row of tile) {
console.log(row);
}
console.log('');
}
function gen_orientations(tile) {
let a = rotate90(tile);
let b = rotate90(a);
let c = rotate90(b);
return [
tile,
a,
b,
c,
flipX(a),
flipX(b),
flipX(c),
flipX(tile),
]
}
let placements = [];
let placedIds = new Set([]);
function canBePlaced(x, y, tile) {
for (let pl of placements) {
if (pl.x == x && pl.y == y) {
return false;
}
if (pl.x == x && pl.y == y - 1) {
let above = pl.t;
let below = tile;
for (let i = 0; i < 10; ++i) {
if (above[9][i] != below[0][i]) {
return false;
}
}
}
if (pl.x == x && pl.y == y + 1) {
let above = tile;
let below = pl.t;
for (let i = 0; i < 10; ++i) {
if (above[9][i] != below[0][i]) {
return false;
}
}
}
if (pl.x == x + 1 && pl.y == y) {
let left = tile;
let right = pl.t;
for (let i = 0; i < 10; ++i) {
if (left[i][9] != right[i][0]) {
return false;
}
}
}
if (pl.x == x - 1 && pl.y == y) {
let left = pl.t;
let right = tile;
for (let i = 0; i < 10; ++i) {
if (left[i][9] != right[i][0]) {
return false;
}
}
}
}
return true;
}
function listCandidates(x, y) {
let candidates = [];
for (let id in tiles) {
if (placedIds.has(id)) continue;
for (let t of gen_orientations(tiles[id])) {
if (canBePlaced(x, y, t)) {
candidates.push({
id: id,
t: t,
x: x,
y: y,
});
}
}
}
return candidates;
}
let initialId = "2477";
placements.push({
id: initialId,
t: tiles[initialId],
x: 0,
y: 0,
});
placedIds.add(initialId);
let order = [
[-1, 0],
[-2, 0],
[-3, 0],
[-4, 0],
[-5, 0],
[-6, 0],
[-7, 0],
[-8, 0],
[1, 0],
[2, 0],
[3, 0],
[4, 0],
[5, 0],
[6, 0],
[7, 0],
[8, 0],
[0, 1],
[0, 2],
[0, 3],
[0, 4],
[0, 5],
[0, 6],
[0, 7],
[0, 8],
[0, -1],
[0, -2],
[0, -3],
[0, -4],
[0, -5],
[0, -6],
[0, -7],
[0, -8],
[3, 1],
[3, 2],
[3, 3],
[3, 4],
[3, 5],
[3, 6],
[3, 7],
[3, 8],
[3, -1],
[3, -2],
[3, -3],
[3, -4],
[3, -5],
[3, -6],
[3, -7],
[3, -8],
[6, 1],
[6, 2],
[6, 3],
[6, 4],
[6, 5],
[6, 6],
[6, 7],
[6, 8],
[6, -1],
[6, -2],
[6, -3],
[6, -4],
[6, -5],
[6, -6],
[6, -7],
[6, -8],
[-3, 1],
[-3, 2],
[-3, 3],
[-3, 4],
[-3, 5],
[-3, 6],
[-3, 7],
[-3, 8],
[-3, -1],
[-3, -2],
[-3, -3],
[-3, -4],
[-3, -5],
[-3, -6],
[-3, -7],
[-3, -8],
[-6, 1],
[-6, 2],
[-6, 3],
[-6, 4],
[-6, 5],
[-6, 6],
[-6, 7],
[-6, 8],
[-6, -1],
[-6, -2],
[-6, -3],
[-6, -4],
[-6, -5],
[-6, -6],
[-6, -7],
[-6, -8],
];
let order2 = [];
for (let x = -12; x <= 12; ++x) {
for (let y = -12; y <= 12; ++y) {
order2.push([x, y]);
}
}
// from https://stackoverflow.com/a/2450976
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
//shuffle(order2);
for (let e of order2) {
order.push(e);
}
let minx = 1000;
let miny = 1000;
let maxx = -999;
let maxy = -999;
while (placedIds.size < 144) {
for (let pos of order) {
let cands = listCandidates(pos[0], pos[1]);
//console.log(cands.length, 'candidates');
if (cands.length == 1) {
placements.push(cands[0]);
placedIds.add(cands[0].id);
let x = cands[0].x;
let y = cands[0].y;
//console.log('placed', cands[0].id, 'at', x, y);
if (x < minx) minx = x;
if (y < miny) miny = y;
if (x > maxx) maxx = x;
if (y > maxy) maxy = y;
} else if (cands.length == 0) {
//console.log("no candidates for ", pos);
}
}
}
let product = 1;
for (let pl of placements) {
if (pl.x == maxx && pl.y == maxy) {
product *= pl.id;
}
if (pl.x == minx && pl.y == maxy) {
product *= pl.id;
}
if (pl.x == maxx && pl.y == miny) {
product *= pl.id;
}
if (pl.x == minx && pl.y == miny) {
product *= pl.id;
}
}
console.log(product);
let combinedBorderedImage = [];
let combinedImage = [];
for (let x = 0; x < 12 * 10; ++x) {
let row = [];
for (let y = 0; y < 120; ++y) {
row.push('~');
}
combinedBorderedImage.push(row);
}
for (let x = 0; x < 12 * 8; ++x) {
let row = [];
for (let y = 0; y < 96; ++y) {
row.push('~');
}
combinedImage.push(row);
}
for (let pl of placements) {
for (let x = 0; x < 10; ++x) {
for (let y = 0; y < 10; ++y) {
combinedBorderedImage[(pl.y - miny) * 10 + y][(pl.x - minx) * 10 + x] = pl.t[y][x];
}
}
}
for (let row of combinedBorderedImage) {
//console.log(row.join(''));
}
for (let pl of placements) {
for (let x = 1; x < 9; ++x) {
for (let y = 1; y < 9; ++y) {
combinedImage[(pl.y - miny) * 8 + y - 1][(pl.x - minx) * 8 + x - 1] = pl.t[y][x];
}
}
}
for (let row of combinedImage) {
//console.log(row.join(''));
}
let monster =[
" # ",
"# ## ## ###",
" # # # # # # "];
function testForMonster(tile, x, y) {
let squares = 0;
for (let i = 0; i < 3 && i + y < 96; ++i) {
for (let j = 0; j < 20 && j + x < 96; ++j) {
if (monster[i][j] == ' ') continue;
if (tile[i+y][j+x] == ' ') return 0;
if (monster[i][j] == '#' && tile[i+y][j+x] == '#') {
squares++;
}
}
}
if (squares < 15) return 0;
return squares;
}
let min = 10000;
for (let variant of gen_orientations(combinedImage)) {
let otherTiles = 0;
let foundAny = false;
for (let x = 0; x < 96; ++x) {
for (let y = 0; y < 96; ++y) {
if (variant[y][x] == '#') otherTiles++;
let c = testForMonster(variant, x, y);
if (c > 0) foundAny = true;
otherTiles -= c;
}
}
if (otherTiles < min) min = otherTiles;
}
console.log(min);