# Question
Title: Pairs of palindromic anagramic dates separated by a palindromic number of days
**Definitions:**

A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when its dd-mm-yyyy format is a palindrome (or any other local representation).

Two strings are said to be anagrams when the contain the same characters (modulo a rearrangement), such as "Silent" and "Listen". Two dates are anagrams when their representation (the same as the one chosen for 1.) are anagrams.

**Challenge:**

The challenge is to find all the pairs (a,b) of dates (between 1/1/01 and 12/31/9999) which satisfy the following three conditions :

1. a and b are different
2. a and b are palindromes
3. a and b are anagrams
4. a and b are separated by a number of days which is a palindrome.

**Constraints**

You can choose one of the three date formats :

* yyyy-mm-dd
* dd-mm-yyyy
* mm-dd-yyyy

That means left padding with zeros for days and month (02/02/1999) and a 4 zeros padding for years.

You must respect leap years + every 100 years leap + every 400 years leap such as specified in the Proleptic Gregorian calendar

**Input** None.

**Output**

Pairs of dates (same format) and the number of days separating them Display format can be different to the computation format.

31-03-3013 - 13-03-3031 :: 6556

\[EDIT\]

Standard loopholes apply

This is code golf, shortest code wins!

# Answer
> 10 votes
# Polyglot, 0 bytes

When using the formats `yyyy-mm-dd` or `mm-dd-yyyy`, the list of palindrome dates are:

```
yyyy-mm-dd: [0101-10-10, 0110-01-10, 0111-11-10, 0120-02-10, 0121-12-10, 0130-03-10, 0140-04-10, 0150-05-10, 0160-06-10, 0170-07-10, 0180-08-10, 0190-09-10, 0201-10-20, 0210-01-20, 0211-11-20, 0220-02-20, 0221-12-20, 0230-03-20, 0240-04-20, 0250-05-20, 0260-06-20, 0270-07-20, 0280-08-20, 0290-09-20, 0301-10-30, 0310-01-30, 0311-11-30, 0321-12-30, 0330-03-30, 0340-04-30, 0350-05-30, 0360-06-30, 0370-07-30, 0380-08-30, 0390-09-30, 1001-10-01, 1010-01-01, 1011-11-01, 1020-02-01, 1021-12-01, 1030-03-01, 1040-04-01, 1050-05-01, 1060-06-01, 1070-07-01, 1080-08-01, 1090-09-01, 1101-10-11, 1110-01-11, 1111-11-11, 1120-02-11, 1121-12-11, 1130-03-11, 1140-04-11, 1150-05-11, 1160-06-11, 1170-07-11, 1180-08-11, 1190-09-11, 1201-10-21, 1210-01-21, 1211-11-21, 1220-02-21, 1221-12-21, 1230-03-21, 1240-04-21, 1250-05-21, 1260-06-21, 1270-07-21, 1280-08-21, 1290-09-21, 1301-10-31, 1310-01-31, 1321-12-31, 1330-03-31, 1350-05-31, 1370-07-31, 1380-08-31, 2001-10-02, 2010-01-02, 2011-11-02, 2020-02-02, 2021-12-02, 2030-03-02, 2040-04-02, 2050-05-02, 2060-06-02, 2070-07-02, 2080-08-02, 2090-09-02, 2101-10-12, 2110-01-12, 2111-11-12, 2120-02-12, 2121-12-12, 2130-03-12, 2140-04-12, 2150-05-12, 2160-06-12, 2170-07-12, 2180-08-12, 2190-09-12, 2201-10-22, 2210-01-22, 2211-11-22, 2220-02-22, 2221-12-22, 2230-03-22, 2240-04-22, 2250-05-22, 2260-06-22, 2270-07-22, 2280-08-22, 2290-09-22, 3001-10-03, 3010-01-03, 3011-11-03, 3020-02-03, 3021-12-03, 3030-03-03, 3040-04-03, 3050-05-03, 3060-06-03, 3070-07-03, 3080-08-03, 3090-09-03, 3101-10-13, 3110-01-13, 3111-11-13, 3120-02-13, 3121-12-13, 3130-03-13, 3140-04-13, 3150-05-13, 3160-06-13, 3170-07-13, 3180-08-13, 3190-09-13, 3201-10-23, 3210-01-23, 3211-11-23, 3220-02-23, 3221-12-23, 3230-03-23, 3240-04-23, 3250-05-23, 3260-06-23, 3270-07-23, 3280-08-23, 3290-09-23, 4001-10-04, 4010-01-04, 4011-11-04, 4020-02-04, 4021-12-04, 4030-03-04, 4040-04-04, 4050-05-04, 4060-06-04, 4070-07-04, 4080-08-04, 4090-09-04, 4101-10-14, 4110-01-14, 4111-11-14, 4120-02-14, 4121-12-14, 4130-03-14, 4140-04-14, 4150-05-14, 4160-06-14, 4170-07-14, 4180-08-14, 4190-09-14, 4201-10-24, 4210-01-24, 4211-11-24, 4220-02-24, 4221-12-24, 4230-03-24, 4240-04-24, 4250-05-24, 4260-06-24, 4270-07-24, 4280-08-24, 4290-09-24, 5001-10-05, 5010-01-05, 5011-11-05, 5020-02-05, 5021-12-05, 5030-03-05, 5040-04-05, 5050-05-05, 5060-06-05, 5070-07-05, 5080-08-05, 5090-09-05, 5101-10-15, 5110-01-15, 5111-11-15, 5120-02-15, 5121-12-15, 5130-03-15, 5140-04-15, 5150-05-15, 5160-06-15, 5170-07-15, 5180-08-15, 5190-09-15, 5201-10-25, 5210-01-25, 5211-11-25, 5220-02-25, 5221-12-25, 5230-03-25, 5240-04-25, 5250-05-25, 5260-06-25, 5270-07-25, 5280-08-25, 5290-09-25, 6001-10-06, 6010-01-06, 6011-11-06, 6020-02-06, 6021-12-06, 6030-03-06, 6040-04-06, 6050-05-06, 6060-06-06, 6070-07-06, 6080-08-06, 6090-09-06, 6101-10-16, 6110-01-16, 6111-11-16, 6120-02-16, 6121-12-16, 6130-03-16, 6140-04-16, 6150-05-16, 6160-06-16, 6170-07-16, 6180-08-16, 6190-09-16, 6201-10-26, 6210-01-26, 6211-11-26, 6220-02-26, 6221-12-26, 6230-03-26, 6240-04-26, 6250-05-26, 6260-06-26, 6270-07-26, 6280-08-26, 6290-09-26, 7001-10-07, 7010-01-07, 7011-11-07, 7020-02-07, 7021-12-07, 7030-03-07, 7040-04-07, 7050-05-07, 7060-06-07, 7070-07-07, 7080-08-07, 7090-09-07, 7101-10-17, 7110-01-17, 7111-11-17, 7120-02-17, 7121-12-17, 7130-03-17, 7140-04-17, 7150-05-17, 7160-06-17, 7170-07-17, 7180-08-17, 7190-09-17, 7201-10-27, 7210-01-27, 7211-11-27, 7220-02-27, 7221-12-27, 7230-03-27, 7240-04-27, 7250-05-27, 7260-06-27, 7270-07-27, 7280-08-27, 7290-09-27, 8001-10-08, 8010-01-08, 8011-11-08, 8020-02-08, 8021-12-08, 8030-03-08, 8040-04-08, 8050-05-08, 8060-06-08, 8070-07-08, 8080-08-08, 8090-09-08, 8101-10-18, 8110-01-18, 8111-11-18, 8120-02-18, 8121-12-18, 8130-03-18, 8140-04-18, 8150-05-18, 8160-06-18, 8170-07-18, 8180-08-18, 8190-09-18, 8201-10-28, 8210-01-28, 8211-11-28, 8220-02-28, 8221-12-28, 8230-03-28, 8240-04-28, 8250-05-28, 8260-06-28, 8270-07-28, 8280-08-28, 8290-09-28, 9001-10-09, 9010-01-09, 9011-11-09, 9020-02-09, 9021-12-09, 9030-03-09, 9040-04-09, 9050-05-09, 9060-06-09, 9070-07-09, 9080-08-09, 9090-09-09, 9101-10-19, 9110-01-19, 9111-11-19, 9120-02-19, 9121-12-19, 9130-03-19, 9140-04-19, 9150-05-19, 9160-06-19, 9170-07-19, 9180-08-19, 9190-09-19, 9201-10-29, 9210-01-29, 9211-11-29, 9220-02-29, 9221-12-29, 9230-03-29, 9240-04-29, 9250-05-29, 9260-06-29, 9270-07-29, 9280-08-29, 9290-09-29]
mm-dd-yyyy: [10-10-0101, 01-10-0110, 11-10-0111, 02-10-0120, 12-10-0121, 03-10-0130, 04-10-0140, 05-10-0150, 06-10-0160, 07-10-0170, 08-10-0180, 09-10-0190, 10-20-0201, 01-20-0210, 11-20-0211, 02-20-0220, 12-20-0221, 03-20-0230, 04-20-0240, 05-20-0250, 06-20-0260, 07-20-0270, 08-20-0280, 09-20-0290, 10-30-0301, 01-30-0310, 11-30-0311, 12-30-0321, 03-30-0330, 04-30-0340, 05-30-0350, 06-30-0360, 07-30-0370, 08-30-0380, 09-30-0390, 10-01-1001, 01-01-1010, 11-01-1011, 02-01-1020, 12-01-1021, 03-01-1030, 04-01-1040, 05-01-1050, 06-01-1060, 07-01-1070, 08-01-1080, 09-01-1090, 10-11-1101, 01-11-1110, 11-11-1111, 02-11-1120, 12-11-1121, 03-11-1130, 04-11-1140, 05-11-1150, 06-11-1160, 07-11-1170, 08-11-1180, 09-11-1190, 10-21-1201, 01-21-1210, 11-21-1211, 02-21-1220, 12-21-1221, 03-21-1230, 04-21-1240, 05-21-1250, 06-21-1260, 07-21-1270, 08-21-1280, 09-21-1290, 10-31-1301, 01-31-1310, 12-31-1321, 03-31-1330, 05-31-1350, 07-31-1370, 08-31-1380, 10-02-2001, 01-02-2010, 11-02-2011, 02-02-2020, 12-02-2021, 03-02-2030, 04-02-2040, 05-02-2050, 06-02-2060, 07-02-2070, 08-02-2080, 09-02-2090, 10-12-2101, 01-12-2110, 11-12-2111, 02-12-2120, 12-12-2121, 03-12-2130, 04-12-2140, 05-12-2150, 06-12-2160, 07-12-2170, 08-12-2180, 09-12-2190, 10-22-2201, 01-22-2210, 11-22-2211, 02-22-2220, 12-22-2221, 03-22-2230, 04-22-2240, 05-22-2250, 06-22-2260, 07-22-2270, 08-22-2280, 09-22-2290, 10-03-3001, 01-03-3010, 11-03-3011, 02-03-3020, 12-03-3021, 03-03-3030, 04-03-3040, 05-03-3050, 06-03-3060, 07-03-3070, 08-03-3080, 09-03-3090, 10-13-3101, 01-13-3110, 11-13-3111, 02-13-3120, 12-13-3121, 03-13-3130, 04-13-3140, 05-13-3150, 06-13-3160, 07-13-3170, 08-13-3180, 09-13-3190, 10-23-3201, 01-23-3210, 11-23-3211, 02-23-3220, 12-23-3221, 03-23-3230, 04-23-3240, 05-23-3250, 06-23-3260, 07-23-3270, 08-23-3280, 09-23-3290, 10-04-4001, 01-04-4010, 11-04-4011, 02-04-4020, 12-04-4021, 03-04-4030, 04-04-4040, 05-04-4050, 06-04-4060, 07-04-4070, 08-04-4080, 09-04-4090, 10-14-4101, 01-14-4110, 11-14-4111, 02-14-4120, 12-14-4121, 03-14-4130, 04-14-4140, 05-14-4150, 06-14-4160, 07-14-4170, 08-14-4180, 09-14-4190, 10-24-4201, 01-24-4210, 11-24-4211, 02-24-4220, 12-24-4221, 03-24-4230, 04-24-4240, 05-24-4250, 06-24-4260, 07-24-4270, 08-24-4280, 09-24-4290, 10-05-5001, 01-05-5010, 11-05-5011, 02-05-5020, 12-05-5021, 03-05-5030, 04-05-5040, 05-05-5050, 06-05-5060, 07-05-5070, 08-05-5080, 09-05-5090, 10-15-5101, 01-15-5110, 11-15-5111, 02-15-5120, 12-15-5121, 03-15-5130, 04-15-5140, 05-15-5150, 06-15-5160, 07-15-5170, 08-15-5180, 09-15-5190, 10-25-5201, 01-25-5210, 11-25-5211, 02-25-5220, 12-25-5221, 03-25-5230, 04-25-5240, 05-25-5250, 06-25-5260, 07-25-5270, 08-25-5280, 09-25-5290, 10-06-6001, 01-06-6010, 11-06-6011, 02-06-6020, 12-06-6021, 03-06-6030, 04-06-6040, 05-06-6050, 06-06-6060, 07-06-6070, 08-06-6080, 09-06-6090, 10-16-6101, 01-16-6110, 11-16-6111, 02-16-6120, 12-16-6121, 03-16-6130, 04-16-6140, 05-16-6150, 06-16-6160, 07-16-6170, 08-16-6180, 09-16-6190, 10-26-6201, 01-26-6210, 11-26-6211, 02-26-6220, 12-26-6221, 03-26-6230, 04-26-6240, 05-26-6250, 06-26-6260, 07-26-6270, 08-26-6280, 09-26-6290, 10-07-7001, 01-07-7010, 11-07-7011, 02-07-7020, 12-07-7021, 03-07-7030, 04-07-7040, 05-07-7050, 06-07-7060, 07-07-7070, 08-07-7080, 09-07-7090, 10-17-7101, 01-17-7110, 11-17-7111, 02-17-7120, 12-17-7121, 03-17-7130, 04-17-7140, 05-17-7150, 06-17-7160, 07-17-7170, 08-17-7180, 09-17-7190, 10-27-7201, 01-27-7210, 11-27-7211, 02-27-7220, 12-27-7221, 03-27-7230, 04-27-7240, 05-27-7250, 06-27-7260, 07-27-7270, 08-27-7280, 09-27-7290, 10-08-8001, 01-08-8010, 11-08-8011, 02-08-8020, 12-08-8021, 03-08-8030, 04-08-8040, 05-08-8050, 06-08-8060, 07-08-8070, 08-08-8080, 09-08-8090, 10-18-8101, 01-18-8110, 11-18-8111, 02-18-8120, 12-18-8121, 03-18-8130, 04-18-8140, 05-18-8150, 06-18-8160, 07-18-8170, 08-18-8180, 09-18-8190, 10-28-8201, 01-28-8210, 11-28-8211, 02-28-8220, 12-28-8221, 03-28-8230, 04-28-8240, 05-28-8250, 06-28-8260, 07-28-8270, 08-28-8280, 09-28-8290, 10-09-9001, 01-09-9010, 11-09-9011, 02-09-9020, 12-09-9021, 03-09-9030, 04-09-9040, 05-09-9050, 06-09-9060, 07-09-9070, 08-09-9080, 09-09-9090, 10-19-9101, 01-19-9110, 11-19-9111, 02-19-9120, 12-19-9121, 03-19-9130, 04-19-9140, 05-19-9150, 06-19-9160, 07-19-9170, 08-19-9180, 09-19-9190, 10-29-9201, 01-29-9210, 11-29-9211, 02-29-9220, 12-29-9221, 03-29-9230, 04-29-9240, 05-29-9250, 06-29-9260, 07-29-9270, 08-29-9280, 09-29-9290]

```

All possible date-pairs which are anagrams between one-another are:

```
yyyy-mm-dd: [[0101-10-10,0110-10-01], [0101-10-10,1001-01-10], [0101-10-10,1010-01-01], [0102-10-20,0120-10-02], [0102-10-20,1002-01-20], [0102-10-20,1020-01-02], [0102-10-20,2001-02-10], [0102-10-20,2010-02-01], [0103-10-30,0130-10-03], [0103-10-30,1003-01-30], [0103-10-30,1030-01-03], [0103-10-30,3001-03-10], [0103-10-30,3010-03-01], [0110-10-01,1001-01-10], [0110-10-01,1010-01-01], [0111-10-11,1011-01-11], [0111-10-11,1101-11-10], [0111-10-11,1110-11-01], [0112-10-21,0121-10-12], [0112-10-21,1012-01-21], [0112-10-21,1021-01-12], [0112-10-21,1102-11-20], [0112-10-21,1120-11-02], [0112-10-21,2011-02-11], [0112-10-21,2101-12-10], [0112-10-21,2110-12-01], [0113-10-31,0131-10-13], [0113-10-31,1013-01-31], [0113-10-31,1031-01-13], [0113-10-31,1103-11-30], [0113-10-31,1130-11-03], [0113-10-31,3011-03-11], [0120-10-02,1002-01-20], [0120-10-02,1020-01-02], [0120-10-02,2001-02-10], [0120-10-02,2010-02-01], [0121-10-12,1012-01-21], [0121-10-12,1021-01-12], [0121-10-12,1102-11-20], [0121-10-12,1120-11-02], [0121-10-12,2011-02-11], [0121-10-12,2101-12-10], [0121-10-12,2110-12-01], [0122-10-22,1022-01-22], [0122-10-22,2012-02-21], [0122-10-22,2021-02-12], [0122-10-22,2102-12-20], [0122-10-22,2120-12-02], [0130-10-03,1003-01-30], [0130-10-03,1030-01-03], [0130-10-03,3001-03-10], [0130-10-03,3010-03-01], [0131-10-13,1013-01-31], [0131-10-13,1031-01-13], [0131-10-13,1103-11-30], [0131-10-13,1130-11-03], [0131-10-13,3011-03-11], [0132-10-23,1032-01-23], [0132-10-23,2031-02-13], [0132-10-23,2103-12-30], [0132-10-23,2130-12-03], [0132-10-23,3012-03-21], [0132-10-23,3021-03-12], [0140-10-04,1040-01-04], [0140-10-04,4001-04-10], [0140-10-04,4010-04-01], [0141-10-14,1041-01-14], [0141-10-14,1140-11-04], [0141-10-14,4011-04-11], [0142-10-24,1042-01-24], [0142-10-24,2041-02-14], [0142-10-24,2140-12-04], [0142-10-24,4012-04-21], [0142-10-24,4021-04-12], [0150-10-05,1050-01-05], [0150-10-05,5001-05-10], [0150-10-05,5010-05-01], [0151-10-15,1051-01-15], [0151-10-15,1150-11-05], [0151-10-15,5011-05-11], [0152-10-25,1052-01-25], [0152-10-25,2051-02-15], [0152-10-25,2150-12-05], [0152-10-25,5012-05-21], [0152-10-25,5021-05-12], [0160-10-06,1060-01-06], [0160-10-06,6001-06-10], [0160-10-06,6010-06-01], [0161-10-16,1061-01-16], [0161-10-16,1160-11-06], [0161-10-16,6011-06-11], [0162-10-26,1062-01-26], [0162-10-26,2061-02-16], [0162-10-26,2160-12-06], [0162-10-26,6012-06-21], [0162-10-26,6021-06-12], [0170-10-07,1070-01-07], [0170-10-07,7001-07-10], [0170-10-07,7010-07-01], [0171-10-17,1071-01-17], [0171-10-17,1170-11-07], [0171-10-17,7011-07-11], [0172-10-27,1072-01-27], [0172-10-27,2071-02-17], [0172-10-27,2170-12-07], [0172-10-27,7012-07-21], [0172-10-27,7021-07-12], [0180-10-08,1080-01-08], [0180-10-08,8001-08-10], [0180-10-08,8010-08-01], [0181-10-18,1081-01-18], [0181-10-18,1180-11-08], [0181-10-18,8011-08-11], [0182-10-28,1082-01-28], [0182-10-28,2081-02-18], [0182-10-28,2180-12-08], [0182-10-28,8012-08-21], [0182-10-28,8021-08-12], [0190-10-09,1090-01-09], [0190-10-09,9001-09-10], [0190-10-09,9010-09-01], [0191-10-19,1091-01-19], [0191-10-19,1190-11-09], [0191-10-19,9011-09-11], [0192-10-29,1092-01-29], [0192-10-29,2091-02-19], [0192-10-29,2190-12-09], [0192-10-29,9012-09-21], [0192-10-29,9021-09-12], [1001-01-10,1010-01-01], [1002-01-20,1020-01-02], [1002-01-20,2001-02-10], [1002-01-20,2010-02-01], [1003-01-30,1030-01-03], [1003-01-30,3001-03-10], [1003-01-30,3010-03-01], [1011-01-11,1101-11-10], [1011-01-11,1110-11-01], [1012-01-21,1021-01-12], [1012-01-21,1102-11-20], [1012-01-21,1120-11-02], [1012-01-21,2011-02-11], [1012-01-21,2101-12-10], [1012-01-21,2110-12-01], [1013-01-31,1031-01-13], [1013-01-31,1103-11-30], [1013-01-31,1130-11-03], [1013-01-31,3011-03-11], [1020-01-02,2001-02-10], [1020-01-02,2010-02-01], [1021-01-12,1102-11-20], [1021-01-12,1120-11-02], [1021-01-12,2011-02-11], [1021-01-12,2101-12-10], [1021-01-12,2110-12-01], [1022-01-22,2012-02-21], [1022-01-22,2021-02-12], [1022-01-22,2102-12-20], [1022-01-22,2120-12-02], [1030-01-03,3001-03-10], [1030-01-03,3010-03-01], [1031-01-13,1103-11-30], [1031-01-13,1130-11-03], [1031-01-13,3011-03-11], [1032-01-23,2031-02-13], [1032-01-23,2103-12-30], [1032-01-23,2130-12-03], [1032-01-23,3012-03-21], [1032-01-23,3021-03-12], [1040-01-04,4001-04-10], [1040-01-04,4010-04-01], [1041-01-14,1140-11-04], [1041-01-14,4011-04-11], [1042-01-24,2041-02-14], [1042-01-24,2140-12-04], [1042-01-24,4012-04-21], [1042-01-24,4021-04-12], [1050-01-05,5001-05-10], [1050-01-05,5010-05-01], [1051-01-15,1150-11-05], [1051-01-15,5011-05-11], [1052-01-25,2051-02-15], [1052-01-25,2150-12-05], [1052-01-25,5012-05-21], [1052-01-25,5021-05-12], [1060-01-06,6001-06-10], [1060-01-06,6010-06-01], [1061-01-16,1160-11-06], [1061-01-16,6011-06-11], [1062-01-26,2061-02-16], [1062-01-26,2160-12-06], [1062-01-26,6012-06-21], [1062-01-26,6021-06-12], [1070-01-07,7001-07-10], [1070-01-07,7010-07-01], [1071-01-17,1170-11-07], [1071-01-17,7011-07-11], [1072-01-27,2071-02-17], [1072-01-27,2170-12-07], [1072-01-27,7012-07-21], [1072-01-27,7021-07-12], [1080-01-08,8001-08-10], [1080-01-08,8010-08-01], [1081-01-18,1180-11-08], [1081-01-18,8011-08-11], [1082-01-28,2081-02-18], [1082-01-28,2180-12-08], [1082-01-28,8012-08-21], [1082-01-28,8021-08-12], [1090-01-09,9001-09-10], [1090-01-09,9010-09-01], [1091-01-19,1190-11-09], [1091-01-19,9011-09-11], [1092-01-29,2091-02-19], [1092-01-29,2190-12-09], [1092-01-29,9012-09-21], [1092-01-29,9021-09-12], [1101-11-10,1110-11-01], [1102-11-20,1120-11-02], [1102-11-20,2011-02-11], [1102-11-20,2101-12-10], [1102-11-20,2110-12-01], [1103-11-30,1130-11-03], [1103-11-30,3011-03-11], [1112-11-21,1121-11-12], [1112-11-21,2111-12-11], [1120-11-02,2011-02-11], [1120-11-02,2101-12-10], [1120-11-02,2110-12-01], [1121-11-12,2111-12-11], [1122-11-22,2112-12-21], [1122-11-22,2121-12-12], [1130-11-03,3011-03-11], [1132-11-23,2113-12-31], [1132-11-23,2131-12-13], [1140-11-04,4011-04-11], [1142-11-24,2141-12-14], [1150-11-05,5011-05-11], [1152-11-25,2151-12-15], [1160-11-06,6011-06-11], [1162-11-26,2161-12-16], [1170-11-07,7011-07-11], [1172-11-27,2171-12-17], [1180-11-08,8011-08-11], [1182-11-28,2181-12-18], [1190-11-09,9011-09-11], [1192-11-29,2191-12-19], [2001-02-10,2010-02-01], [2002-02-20,2020-02-02], [2011-02-11,2101-12-10], [2011-02-11,2110-12-01], [2012-02-21,2021-02-12], [2012-02-21,2102-12-20], [2012-02-21,2120-12-02], [2021-02-12,2102-12-20], [2021-02-12,2120-12-02], [2030-02-03,3002-03-20], [2030-02-03,3020-03-02], [2031-02-13,2103-12-30], [2031-02-13,2130-12-03], [2031-02-13,3012-03-21], [2031-02-13,3021-03-12], [2032-02-23,3022-03-22], [2040-02-04,4002-04-20], [2040-02-04,4020-04-02], [2041-02-14,2140-12-04], [2041-02-14,4012-04-21], [2041-02-14,4021-04-12], [2042-02-24,4022-04-22], [2050-02-05,5002-05-20], [2050-02-05,5020-05-02], [2051-02-15,2150-12-05], [2051-02-15,5012-05-21], [2051-02-15,5021-05-12], [2052-02-25,5022-05-22], [2060-02-06,6002-06-20], [2060-02-06,6020-06-02], [2061-02-16,2160-12-06], [2061-02-16,6012-06-21], [2061-02-16,6021-06-12], [2062-02-26,6022-06-22], [2070-02-07,7002-07-20], [2070-02-07,7020-07-02], [2071-02-17,2170-12-07], [2071-02-17,7012-07-21], [2071-02-17,7021-07-12], [2072-02-27,7022-07-22], [2080-02-08,8002-08-20], [2080-02-08,8020-08-02], [2081-02-18,2180-12-08], [2081-02-18,8012-08-21], [2081-02-18,8021-08-12], [2082-02-28,8022-08-22], [2090-02-09,9002-09-20], [2090-02-09,9020-09-02], [2091-02-19,2190-12-09], [2091-02-19,9012-09-21], [2091-02-19,9021-09-12], [2092-02-29,9022-09-22], [2101-12-10,2110-12-01], [2102-12-20,2120-12-02], [2103-12-30,2130-12-03], [2103-12-30,3012-03-21], [2103-12-30,3021-03-12], [2112-12-21,2121-12-12], [2113-12-31,2131-12-13], [2130-12-03,3012-03-21], [2130-12-03,3021-03-12], [2140-12-04,4012-04-21], [2140-12-04,4021-04-12], [2150-12-05,5012-05-21], [2150-12-05,5021-05-12], [2160-12-06,6012-06-21], [2160-12-06,6021-06-12], [2170-12-07,7012-07-21], [2170-12-07,7021-07-12], [2180-12-08,8012-08-21], [2180-12-08,8021-08-12], [2190-12-09,9012-09-21], [2190-12-09,9021-09-12], [3001-03-10,3010-03-01], [3002-03-20,3020-03-02], [3003-03-30,3030-03-03], [3012-03-21,3021-03-12], [3013-03-31,3031-03-13], [3040-03-04,4003-04-30], [3040-03-04,4030-04-03], [3041-03-14,4031-04-13], [3042-03-24,4032-04-23], [3050-03-05,5003-05-30], [3050-03-05,5030-05-03], [3051-03-15,5013-05-31], [3051-03-15,5031-05-13], [3052-03-25,5032-05-23], [3060-03-06,6003-06-30], [3060-03-06,6030-06-03], [3061-03-16,6031-06-13], [3062-03-26,6032-06-23], [3070-03-07,7003-07-30], [3070-03-07,7030-07-03], [3071-03-17,7013-07-31], [3071-03-17,7031-07-13], [3072-03-27,7032-07-23], [3080-03-08,8003-08-30], [3080-03-08,8030-08-03], [3081-03-18,8013-08-31], [3081-03-18,8031-08-13], [3082-03-28,8032-08-23], [3090-03-09,9003-09-30], [3090-03-09,9030-09-03], [3091-03-19,9031-09-13], [3092-03-29,9032-09-23], [4001-04-10,4010-04-01], [4002-04-20,4020-04-02], [4003-04-30,4030-04-03], [4012-04-21,4021-04-12], [4050-04-05,5040-05-04], [4051-04-15,5041-05-14], [4052-04-25,5042-05-24], [4060-04-06,6040-06-04], [4061-04-16,6041-06-14], [4062-04-26,6042-06-24], [4070-04-07,7040-07-04], [4071-04-17,7041-07-14], [4072-04-27,7042-07-24], [4080-04-08,8040-08-04], [4081-04-18,8041-08-14], [4082-04-28,8042-08-24], [4090-04-09,9040-09-04], [4091-04-19,9041-09-14], [4092-04-29,9042-09-24], [5001-05-10,5010-05-01], [5002-05-20,5020-05-02], [5003-05-30,5030-05-03], [5012-05-21,5021-05-12], [5013-05-31,5031-05-13], [5060-05-06,6050-06-05], [5061-05-16,6051-06-15], [5062-05-26,6052-06-25], [5070-05-07,7050-07-05], [5071-05-17,7051-07-15], [5072-05-27,7052-07-25], [5080-05-08,8050-08-05], [5081-05-18,8051-08-15], [5082-05-28,8052-08-25], [5090-05-09,9050-09-05], [5091-05-19,9051-09-15], [5092-05-29,9052-09-25], [6001-06-10,6010-06-01], [6002-06-20,6020-06-02], [6003-06-30,6030-06-03], [6012-06-21,6021-06-12], [6070-06-07,7060-07-06], [6071-06-17,7061-07-16], [6072-06-27,7062-07-26], [6080-06-08,8060-08-06], [6081-06-18,8061-08-16], [6082-06-28,8062-08-26], [6090-06-09,9060-09-06], [6091-06-19,9061-09-16], [6092-06-29,9062-09-26], [7001-07-10,7010-07-01], [7002-07-20,7020-07-02], [7003-07-30,7030-07-03], [7012-07-21,7021-07-12], [7013-07-31,7031-07-13], [7080-07-08,8070-08-07], [7081-07-18,8071-08-17], [7082-07-28,8072-08-27], [7090-07-09,9070-09-07], [7091-07-19,9071-09-17], [7092-07-29,9072-09-27], [8001-08-10,8010-08-01], [8002-08-20,8020-08-02], [8003-08-30,8030-08-03], [8012-08-21,8021-08-12], [8013-08-31,8031-08-13], [8090-08-09,9080-09-08], [8091-08-19,9081-09-18], [8092-08-29,9082-09-28], [9001-09-10,9010-09-01], [9002-09-20,9020-09-02], [9003-09-30,9030-09-03], [9012-09-21,9021-09-12]]
mm-dd-yyyy: [[10-10-0101,01-10-0110], [10-10-0101,10-01-1001], [10-10-0101,01-01-1010], [01-10-0110,10-01-1001], [01-10-0110,01-01-1010], [11-10-0111,11-01-1011], [11-10-0111,10-11-1101], [11-10-0111,01-11-1110], [02-10-0120,10-20-0201], [02-10-0120,01-20-0210], [02-10-0120,02-01-1020], [02-10-0120,10-02-2001], [02-10-0120,01-02-2010], [12-10-0121,11-20-0211], [12-10-0121,12-01-1021], [12-10-0121,02-11-1120], [12-10-0121,10-21-1201], [12-10-0121,01-21-1210], [12-10-0121,11-02-2011], [12-10-0121,10-12-2101], [12-10-0121,01-12-2110], [03-10-0130,10-30-0301], [03-10-0130,01-30-0310], [03-10-0130,03-01-1030], [03-10-0130,10-03-3001], [03-10-0130,01-03-3010], [04-10-0140,04-01-1040], [04-10-0140,10-04-4001], [04-10-0140,01-04-4010], [05-10-0150,05-01-1050], [05-10-0150,10-05-5001], [05-10-0150,01-05-5010], [06-10-0160,06-01-1060], [06-10-0160,10-06-6001], [06-10-0160,01-06-6010], [07-10-0170,07-01-1070], [07-10-0170,10-07-7001], [07-10-0170,01-07-7010], [08-10-0180,08-01-1080], [08-10-0180,10-08-8001], [08-10-0180,01-08-8010], [09-10-0190,09-01-1090], [09-10-0190,10-09-9001], [09-10-0190,01-09-9010], [10-20-0201,01-20-0210], [10-20-0201,02-01-1020], [10-20-0201,10-02-2001], [10-20-0201,01-02-2010], [01-20-0210,02-01-1020], [01-20-0210,10-02-2001], [01-20-0210,01-02-2010], [11-20-0211,12-01-1021], [11-20-0211,02-11-1120], [11-20-0211,10-21-1201], [11-20-0211,01-21-1210], [11-20-0211,11-02-2011], [11-20-0211,10-12-2101], [11-20-0211,01-12-2110], [02-20-0220,02-02-2020], [12-20-0221,02-21-1220], [12-20-0221,12-02-2021], [12-20-0221,02-12-2120], [12-20-0221,10-22-2201], [12-20-0221,01-22-2210], [03-20-0230,03-02-2030], [03-20-0230,02-03-3020], [04-20-0240,04-02-2040], [04-20-0240,02-04-4020], [05-20-0250,05-02-2050], [05-20-0250,02-05-5020], [06-20-0260,06-02-2060], [06-20-0260,02-06-6020], [07-20-0270,07-02-2070], [07-20-0270,02-07-7020], [08-20-0280,08-02-2080], [08-20-0280,02-08-8020], [09-20-0290,09-02-2090], [09-20-0290,02-09-9020], [10-30-0301,01-30-0310], [10-30-0301,03-01-1030], [10-30-0301,10-03-3001], [10-30-0301,01-03-3010], [01-30-0310,03-01-1030], [01-30-0310,10-03-3001], [01-30-0310,01-03-3010], [11-30-0311,03-11-1130], [11-30-0311,10-31-1301], [11-30-0311,01-31-1310], [11-30-0311,11-03-3011], [11-30-0311,10-13-3101], [11-30-0311,01-13-3110], [12-30-0321,03-21-1230], [12-30-0321,03-12-2130], [12-30-0321,12-03-3021], [12-30-0321,02-13-3120], [12-30-0321,10-23-3201], [12-30-0321,01-23-3210], [03-30-0330,03-03-3030], [04-30-0340,04-03-3040], [04-30-0340,03-04-4030], [05-30-0350,05-03-3050], [05-30-0350,03-05-5030], [06-30-0360,06-03-3060], [06-30-0360,03-06-6030], [07-30-0370,07-03-3070], [07-30-0370,03-07-7030], [08-30-0380,08-03-3080], [08-30-0380,03-08-8030], [09-30-0390,09-03-3090], [09-30-0390,03-09-9030], [10-01-1001,01-01-1010], [11-01-1011,10-11-1101], [11-01-1011,01-11-1110], [02-01-1020,10-02-2001], [02-01-1020,01-02-2010], [12-01-1021,02-11-1120], [12-01-1021,10-21-1201], [12-01-1021,01-21-1210], [12-01-1021,11-02-2011], [12-01-1021,10-12-2101], [12-01-1021,01-12-2110], [03-01-1030,10-03-3001], [03-01-1030,01-03-3010], [04-01-1040,10-04-4001], [04-01-1040,01-04-4010], [05-01-1050,10-05-5001], [05-01-1050,01-05-5010], [06-01-1060,10-06-6001], [06-01-1060,01-06-6010], [07-01-1070,10-07-7001], [07-01-1070,01-07-7010], [08-01-1080,10-08-8001], [08-01-1080,01-08-8010], [09-01-1090,10-09-9001], [09-01-1090,01-09-9010], [10-11-1101,01-11-1110], [02-11-1120,10-21-1201], [02-11-1120,01-21-1210], [02-11-1120,11-02-2011], [02-11-1120,10-12-2101], [02-11-1120,01-12-2110], [12-11-1121,11-21-1211], [12-11-1121,11-12-2111], [03-11-1130,10-31-1301], [03-11-1130,01-31-1310], [03-11-1130,11-03-3011], [03-11-1130,10-13-3101], [03-11-1130,01-13-3110], [04-11-1140,11-04-4011], [04-11-1140,10-14-4101], [04-11-1140,01-14-4110], [05-11-1150,11-05-5011], [05-11-1150,10-15-5101], [05-11-1150,01-15-5110], [06-11-1160,11-06-6011], [06-11-1160,10-16-6101], [06-11-1160,01-16-6110], [07-11-1170,11-07-7011], [07-11-1170,10-17-7101], [07-11-1170,01-17-7110], [08-11-1180,11-08-8011], [08-11-1180,10-18-8101], [08-11-1180,01-18-8110], [09-11-1190,11-09-9011], [09-11-1190,10-19-9101], [09-11-1190,01-19-9110], [10-21-1201,01-21-1210], [10-21-1201,11-02-2011], [10-21-1201,10-12-2101], [10-21-1201,01-12-2110], [01-21-1210,11-02-2011], [01-21-1210,10-12-2101], [01-21-1210,01-12-2110], [11-21-1211,11-12-2111], [02-21-1220,12-02-2021], [02-21-1220,02-12-2120], [02-21-1220,10-22-2201], [02-21-1220,01-22-2210], [12-21-1221,12-12-2121], [12-21-1221,11-22-2211], [03-21-1230,03-12-2130], [03-21-1230,12-03-3021], [03-21-1230,02-13-3120], [03-21-1230,10-23-3201], [03-21-1230,01-23-3210], [04-21-1240,04-12-2140], [04-21-1240,12-04-4021], [04-21-1240,02-14-4120], [04-21-1240,10-24-4201], [04-21-1240,01-24-4210], [05-21-1250,05-12-2150], [05-21-1250,12-05-5021], [05-21-1250,02-15-5120], [05-21-1250,10-25-5201], [05-21-1250,01-25-5210], [06-21-1260,06-12-2160], [06-21-1260,12-06-6021], [06-21-1260,02-16-6120], [06-21-1260,10-26-6201], [06-21-1260,01-26-6210], [07-21-1270,07-12-2170], [07-21-1270,12-07-7021], [07-21-1270,02-17-7120], [07-21-1270,10-27-7201], [07-21-1270,01-27-7210], [08-21-1280,08-12-2180], [08-21-1280,12-08-8021], [08-21-1280,02-18-8120], [08-21-1280,10-28-8201], [08-21-1280,01-28-8210], [09-21-1290,09-12-2190], [09-21-1290,12-09-9021], [09-21-1290,02-19-9120], [09-21-1290,10-29-9201], [09-21-1290,01-29-9210], [10-31-1301,01-31-1310], [10-31-1301,11-03-3011], [10-31-1301,10-13-3101], [10-31-1301,01-13-3110], [01-31-1310,11-03-3011], [01-31-1310,10-13-3101], [01-31-1310,01-13-3110], [12-31-1321,12-13-3121], [12-31-1321,11-23-3211], [03-31-1330,03-13-3130], [05-31-1350,05-13-3150], [05-31-1350,03-15-5130], [07-31-1370,07-13-3170], [07-31-1370,03-17-7130], [08-31-1380,08-13-3180], [08-31-1380,03-18-8130], [10-02-2001,01-02-2010], [11-02-2011,10-12-2101], [11-02-2011,01-12-2110], [12-02-2021,02-12-2120], [12-02-2021,10-22-2201], [12-02-2021,01-22-2210], [03-02-2030,02-03-3020], [04-02-2040,02-04-4020], [05-02-2050,02-05-5020], [06-02-2060,02-06-6020], [07-02-2070,02-07-7020], [08-02-2080,02-08-8020], [09-02-2090,02-09-9020], [10-12-2101,01-12-2110], [02-12-2120,10-22-2201], [02-12-2120,01-22-2210], [12-12-2121,11-22-2211], [03-12-2130,12-03-3021], [03-12-2130,02-13-3120], [03-12-2130,10-23-3201], [03-12-2130,01-23-3210], [04-12-2140,12-04-4021], [04-12-2140,02-14-4120], [04-12-2140,10-24-4201], [04-12-2140,01-24-4210], [05-12-2150,12-05-5021], [05-12-2150,02-15-5120], [05-12-2150,10-25-5201], [05-12-2150,01-25-5210], [06-12-2160,12-06-6021], [06-12-2160,02-16-6120], [06-12-2160,10-26-6201], [06-12-2160,01-26-6210], [07-12-2170,12-07-7021], [07-12-2170,02-17-7120], [07-12-2170,10-27-7201], [07-12-2170,01-27-7210], [08-12-2180,12-08-8021], [08-12-2180,02-18-8120], [08-12-2180,10-28-8201], [08-12-2180,01-28-8210], [09-12-2190,12-09-9021], [09-12-2190,02-19-9120], [09-12-2190,10-29-9201], [09-12-2190,01-29-9210], [10-22-2201,01-22-2210], [03-22-2230,02-23-3220], [04-22-2240,02-24-4220], [05-22-2250,02-25-5220], [06-22-2260,02-26-6220], [07-22-2270,02-27-7220], [08-22-2280,02-28-8220], [09-22-2290,02-29-9220], [10-03-3001,01-03-3010], [11-03-3011,10-13-3101], [11-03-3011,01-13-3110], [12-03-3021,02-13-3120], [12-03-3021,10-23-3201], [12-03-3021,01-23-3210], [04-03-3040,03-04-4030], [05-03-3050,03-05-5030], [06-03-3060,03-06-6030], [07-03-3070,03-07-7030], [08-03-3080,03-08-8030], [09-03-3090,03-09-9030], [10-13-3101,01-13-3110], [02-13-3120,10-23-3201], [02-13-3120,01-23-3210], [12-13-3121,11-23-3211], [04-13-3140,03-14-4130], [05-13-3150,03-15-5130], [06-13-3160,03-16-6130], [07-13-3170,03-17-7130], [08-13-3180,03-18-8130], [09-13-3190,03-19-9130], [10-23-3201,01-23-3210], [04-23-3240,03-24-4230], [05-23-3250,03-25-5230], [06-23-3260,03-26-6230], [07-23-3270,03-27-7230], [08-23-3280,03-28-8230], [09-23-3290,03-29-9230], [10-04-4001,01-04-4010], [11-04-4011,10-14-4101], [11-04-4011,01-14-4110], [12-04-4021,02-14-4120], [12-04-4021,10-24-4201], [12-04-4021,01-24-4210], [05-04-4050,04-05-5040], [06-04-4060,04-06-6040], [07-04-4070,04-07-7040], [08-04-4080,04-08-8040], [09-04-4090,04-09-9040], [10-14-4101,01-14-4110], [02-14-4120,10-24-4201], [02-14-4120,01-24-4210], [12-14-4121,11-24-4211], [05-14-4150,04-15-5140], [06-14-4160,04-16-6140], [07-14-4170,04-17-7140], [08-14-4180,04-18-8140], [09-14-4190,04-19-9140], [10-24-4201,01-24-4210], [05-24-4250,04-25-5240], [06-24-4260,04-26-6240], [07-24-4270,04-27-7240], [08-24-4280,04-28-8240], [09-24-4290,04-29-9240], [10-05-5001,01-05-5010], [11-05-5011,10-15-5101], [11-05-5011,01-15-5110], [12-05-5021,02-15-5120], [12-05-5021,10-25-5201], [12-05-5021,01-25-5210], [06-05-5060,05-06-6050], [07-05-5070,05-07-7050], [08-05-5080,05-08-8050], [09-05-5090,05-09-9050], [10-15-5101,01-15-5110], [02-15-5120,10-25-5201], [02-15-5120,01-25-5210], [12-15-5121,11-25-5211], [06-15-5160,05-16-6150], [07-15-5170,05-17-7150], [08-15-5180,05-18-8150], [09-15-5190,05-19-9150], [10-25-5201,01-25-5210], [06-25-5260,05-26-6250], [07-25-5270,05-27-7250], [08-25-5280,05-28-8250], [09-25-5290,05-29-9250], [10-06-6001,01-06-6010], [11-06-6011,10-16-6101], [11-06-6011,01-16-6110], [12-06-6021,02-16-6120], [12-06-6021,10-26-6201], [12-06-6021,01-26-6210], [07-06-6070,06-07-7060], [08-06-6080,06-08-8060], [09-06-6090,06-09-9060], [10-16-6101,01-16-6110], [02-16-6120,10-26-6201], [02-16-6120,01-26-6210], [12-16-6121,11-26-6211], [07-16-6170,06-17-7160], [08-16-6180,06-18-8160], [09-16-6190,06-19-9160], [10-26-6201,01-26-6210], [07-26-6270,06-27-7260], [08-26-6280,06-28-8260], [09-26-6290,06-29-9260], [10-07-7001,01-07-7010], [11-07-7011,10-17-7101], [11-07-7011,01-17-7110], [12-07-7021,02-17-7120], [12-07-7021,10-27-7201], [12-07-7021,01-27-7210], [08-07-7080,07-08-8070], [09-07-7090,07-09-9070], [10-17-7101,01-17-7110], [02-17-7120,10-27-7201], [02-17-7120,01-27-7210], [12-17-7121,11-27-7211], [08-17-7180,07-18-8170], [09-17-7190,07-19-9170], [10-27-7201,01-27-7210], [08-27-7280,07-28-8270], [09-27-7290,07-29-9270], [10-08-8001,01-08-8010], [11-08-8011,10-18-8101], [11-08-8011,01-18-8110], [12-08-8021,02-18-8120], [12-08-8021,10-28-8201], [12-08-8021,01-28-8210], [09-08-8090,08-09-9080], [10-18-8101,01-18-8110], [02-18-8120,10-28-8201], [02-18-8120,01-28-8210], [12-18-8121,11-28-8211], [09-18-8190,08-19-9180], [10-28-8201,01-28-8210], [09-28-8290,08-29-9280], [10-09-9001,01-09-9010], [11-09-9011,10-19-9101], [11-09-9011,01-19-9110], [12-09-9021,02-19-9120], [12-09-9021,10-29-9201], [12-09-9021,01-29-9210], [10-19-9101,01-19-9110], [02-19-9120,10-29-9201], [02-19-9120,01-29-9210], [12-19-9121,11-29-9211], [10-29-9201,01-29-9210]]

```

The differences in days of those pairs are:

```
yyyy-mm-dd: [3278, 328445, 331723, 6557, 328445, 335001, 693344, 696622, 9835, 328445, 338280, 1058239, 1061517, 325167, 328445, 328445, 361620, 364898, 3278, 328444, 331723, 361619, 368176, 693343, 726517, 729795, 6556, 328445, 335001, 361619, 371454, 1058238, 321888, 328444, 686787, 690065, 325166, 328445, 358341, 364898, 690065, 723239, 726517, 328445, 690065, 693344, 723239, 729796, 318610, 328445, 1048404, 1051682, 321889, 328445, 355063, 364898, 1051682, 328444, 693343, 719960, 729795, 1051682, 1054960, 328444, 1410024, 1413302, 328445, 364898, 1413302, 328445, 693344, 729796, 1413303, 1416581, 328445, 1771643, 1774921, 328445, 364898, 1774921, 328444, 693343, 729795, 1774921, 1778199, 328444, 2133263, 2136541, 328445, 364898, 2136541, 328445, 693344, 729796, 2136542, 2139820, 328445, 2494882, 2498160, 328445, 364898, 2498160, 328444, 693343, 729795, 2498160, 2501438, 328444, 2856502, 2859780, 328445, 364898, 2859780, 328445, 693344, 729796, 2859781, 2863059, 328445, 3218122, 3221400, 328445, 364898, 3221400, 328444, 693343, 729795, 3221400, 3224678, 3278, 6556, 364899, 368177, 9835, 729794, 733072, 33175, 36453, 3279, 33175, 39732, 364899, 398073, 401351, 6556, 33174, 43009, 729793, 358343, 361621, 29896, 36453, 361620, 394794, 398072, 361620, 364899, 394794, 401351, 719959, 723237, 26618, 36453, 723237, 364899, 391516, 401351, 723238, 726516, 1081580, 1084858, 36453, 1084857, 364899, 401351, 1084858, 1088136, 1443198, 1446476, 36453, 1446476, 364899, 401351, 1446477, 1449755, 1804819, 1808097, 36453, 1808096, 364899, 401351, 1808097, 1811375, 2166437, 2169715, 36453, 2169715, 364899, 401351, 2169716, 2172994, 2528058, 2531336, 36453, 2531335, 364899, 401351, 2531336, 2534614, 2889677, 2892955, 36453, 2892955, 364899, 401351, 2892956, 2896234, 3278, 6557, 331724, 364898, 368176, 9835, 696619, 3278, 364897, 325167, 358341, 361619, 361619, 361620, 364898, 686784, 358341, 364897, 1048404, 364898, 1410023, 364897, 1771643, 364898, 2133262, 364897, 2494882, 364898, 2856502, 364897, 3278, 6556, 33174, 36452, 3279, 33174, 39731, 29895, 36452, 355060, 361617, 26617, 36452, 358339, 361617, 361617, 716681, 723238, 36452, 719959, 723237, 723237, 1078299, 1084856, 36452, 1081578, 1084856, 1084856, 1439920, 1446477, 36452, 1443198, 1446476, 1446476, 1801538, 1808095, 36452, 1804817, 1808095, 1808095, 2163159, 2169716, 36452, 2166437, 2169715, 2169715, 2524778, 2531335, 36452, 2528057, 2531335, 2531335, 3278, 6557, 9835, 331722, 335000, 3278, 6556, 321887, 325165, 683507, 686785, 1045126, 1048404, 1406746, 1410024, 1768365, 1771643, 2129985, 2133263, 2491605, 2494883, 3278, 6557, 9835, 3278, 6556, 351785, 361620, 361620, 361621, 713404, 723239, 716683, 723239, 723239, 1075024, 1084859, 1084859, 1084860, 1436643, 1446478, 1439922, 1446478, 1446478, 1798263, 1808098, 1801542, 1808098, 1808099, 2159883, 2169718, 2169718, 2169718, 3278, 6557, 9835, 3278, 361619, 361619, 361618, 723239, 723239, 723239, 1084858, 1084858, 1084857, 1446478, 1446478, 1446478, 1808098, 1808098, 1808097, 3278, 6557, 9835, 3278, 6556, 361620, 361620, 361621, 723239, 723239, 723239, 1084859, 1084859, 1084860, 1446479, 1446479, 1446479, 3278, 6557, 9835, 3278, 361619, 361619, 361618, 723239, 723239, 723239, 1084859, 1084859, 1084858, 3278, 6557, 9835, 3278, 6556, 361620, 361620, 361621, 723240, 723240, 723240, 3278, 6557, 9835, 3278, 6556, 361620, 361620, 361619, 3278, 6557, 9835, 3278]
mm-dd-yyyy: [3014, 328709, 331723, 325695, 328709, 328709, 361560, 364574, 29837, 32851, 328709, 687256, 690270, 32851, 328709, 364574, 394412, 397426, 690270, 723121, 726135, 62690, 65704, 328709, 1048818, 1051832, 328709, 1410378, 1413392, 328709, 1771939, 1774953, 328709, 2133499, 2136513, 328709, 2495060, 2498074, 328709, 2856620, 2859634, 328709, 3218180, 3221194, 3014, 298872, 657419, 660433, 295858, 654405, 657419, 295858, 331723, 361561, 364575, 657419, 690270, 693284, 657419, 364575, 657419, 693284, 723121, 726135, 657419, 1018981, 657419, 1380541, 657419, 1742102, 657419, 2103662, 657419, 2465223, 657419, 2826783, 657419, 3188343, 3014, 266019, 986128, 989142, 263005, 983114, 986128, 298870, 361561, 364575, 986128, 1018979, 1021993, 331722, 660431, 986128, 1021993, 1051831, 1054845, 986128, 986128, 1347688, 986128, 1709249, 986128, 2070809, 986128, 2432370, 986128, 2793930, 986128, 3155490, 3014, 32851, 35865, 358547, 361561, 35865, 65703, 68717, 361561, 394412, 397426, 720109, 723123, 1081669, 1084683, 1443230, 1446244, 1804790, 1807804, 2166351, 2169365, 2527911, 2530925, 2889471, 2892485, 3014, 29838, 32852, 325696, 358547, 361561, 32852, 361561, 62691, 65705, 687258, 720109, 723123, 1048818, 1081669, 1084683, 1410379, 1443230, 1446244, 1771939, 1804790, 1807804, 2133500, 2166351, 2169365, 2495060, 2527911, 2530925, 2856620, 2889471, 2892485, 3014, 295858, 328709, 331723, 292844, 325695, 328709, 328709, 292844, 328709, 358546, 361560, 328709, 361560, 328709, 654406, 690271, 720109, 723123, 328709, 1015966, 1051831, 1081668, 1084682, 328709, 1377527, 1413392, 1443230, 1446244, 328709, 1739087, 1774952, 1804789, 1807803, 328709, 2100648, 2136513, 2166351, 2169365, 328709, 2462208, 2498073, 2527910, 2530924, 328709, 2823768, 2859633, 2889471, 2892485, 3014, 624567, 657418, 660432, 621553, 654404, 657418, 657418, 690270, 657418, 657418, 1380539, 657418, 2103660, 657418, 2465220, 3014, 32851, 35865, 35865, 65702, 68716, 361562, 723122, 1084683, 1446243, 1807804, 2169364, 2530924, 3014, 29837, 32851, 32851, 325697, 361562, 391400, 394414, 687257, 723122, 752959, 755973, 1048818, 1084683, 1114521, 1117535, 1410378, 1446243, 1476080, 1479094, 1771939, 1807804, 1837642, 1840656, 2133499, 2169364, 2199201, 2202215, 2495059, 2530924, 2560762, 2563776, 3014, 361563, 723122, 1084684, 1446243, 1807805, 2169364, 2530925, 3014, 32851, 35865, 35865, 65703, 68717, 361560, 723121, 1084681, 1446242, 1807802, 2169362, 3014, 29838, 32852, 32852, 361560, 723121, 1084681, 1446242, 1807802, 2169362, 3014, 361559, 723121, 1084680, 1446242, 1807801, 2169362, 3014, 32851, 35865, 35865, 65702, 68716, 361561, 723121, 1084682, 1446242, 1807802, 3014, 29837, 32851, 32851, 361561, 723121, 1084682, 1446242, 1807802, 3014, 361562, 723121, 1084683, 1446242, 1807803, 3014, 32851, 35865, 35865, 65703, 68717, 361560, 723121, 1084681, 1446241, 3014, 29838, 32852, 32852, 361560, 723121, 1084681, 1446241, 3014, 361559, 723121, 1084680, 1446241, 3014, 32851, 35865, 35865, 65702, 68716, 361561, 723121, 1084681, 3014, 29837, 32851, 32851, 361561, 723121, 1084681, 3014, 361562, 723121, 1084682, 3014, 32851, 35865, 35865, 65703, 68717, 361560, 723120, 3014, 29838, 32852, 32852, 361560, 723120, 3014, 361559, 723120, 3014, 32851, 35865, 35865, 65702, 68716, 361560, 3014, 29837, 32851, 32851, 361560, 3014, 361561, 3014, 32851, 35865, 35865, 65703, 68717, 3014, 29838, 32852, 32852, 3014]

```

And none of those differences are palindromes, so there won't be any output for either of these two formats.

(See my Java answer for an answer using format `dd-mm-yyyy` like the challenge description, which I've also used to generate the lists above.)

# Answer
> 3 votes
# Red, 305 bytes

```
p: func[s n][at to""10 ** n + s 2]s: func[d][rejoin[p d/4 2 p d/3 2 p d/2 4]]
r: func[s][s: to""s s = reverse copy s]a: to-date[1 1 1]b:
collect[until[if r s a[keep a]a: a + 1 a/2 = 1e4]]repeat i l: length? b[repeat
j l[if all[i < j(sort s b/:i)= sort s b/:j
r t: b/:j - b/:i][print[s b/:i s b/:j"::"t]]]]

```

Try it online!

In dd-mm-yyyy format. I'm listing the pairs only once. Currently there is no separator in the dates - I'll fix it if it's necessary.

# Answer
> 3 votes
# JavaScript (ES6),  ~~115 109~~  108 bytes

Date format: `dd-mm-yyyy`.

```
_=>[-1102,-1101,-2,0,2,4,5,7,9].map(y=>([,a,b,c,d]=y+11303+'',[a+b+(m='-'+c+d+'-'+d+c)+b+a,b+a+m+a+b,6556]))

```

Try it online!

# Answer
> 2 votes
Uses format `ddmmyyyy` for the palindrome checks like the challenge description.

## Java 8 (hard-coded), 190 bytes

```
v->"31100113 13100131x20011002 02011020x31011013 13011031x20022002 02022020x31122113 13122131x31033013 13033031x31055013 13055031x31077013 13077031x31088013 13088031x".replace("x"," 6556\n")

```

As expected, a lot shorter than calculating it..
Outputs in the format `ddmmyyyy`.

Try it online.

**Explanation:**

```
v->   // Method with empty unused parameter and String return-type
  "31100113 13100131x20011002 02011020x31011013 13011031x20022002 02022020x31122113 13122131x31033013 13033031x31055013 13055031x31077013 13077031x31088013 13088031x"
      //  Return this String
    .replace("x"," 6556\n")
      //  after we've replaced all "x" with " 6556\n"

```

## Java 10 (calculated), ~~524~~ ~~486~~ 476 bytes

```
import java.time.*;v->{var D=LocalDate.of(1,1,1);java.util.Arrays A=null;var L=D.datesUntil(D.of(10000,1,1)).filter(d->{var s=(d+"").split("-");return p(s[2]+s[1]+s[0]);}).toArray(LocalDate[]::new);for(var a:L)for(var b:L){var x=(a+"").split("");var y=(b+"").split("");A.sort(x);A.sort(y);var d=a.until(b,java.time.temporal.ChronoUnit.DAYS);if(d>0&A.equals(x,y)&p(d+""))System.out.println(a+" "+b+" "+d);}}boolean p(String s){return s.contains(new StringBuffer(s).reverse());}

```

Uses the same format as in the challenge description for the checks `ddmmyyyy`, but outputs as format `yyyy-mm-dd`.

Try it online.

**Explanation:**

```
import java.time.*;       // Import for both LocalDate
v->{                      // Method with empty unused parameter and no return-type
  var D=LocalDate.of(1,1,1);
                          //  LocalDate variable to save bytes, with date 01-01-0001
  java.util.Arrays A=null;//  Static Arrays to save bytes
  var L=D.datesUntil(D.of(10000,1,1))
                          //  Create a stream of dates in the range [01-01-0001,01-01-9999]:
        .filter(d->{      //  Filter it by:
          var s=(d+"")    //   Convert the date to a String in the format "yyyy-mm-dd"
            .split("-");  //   And split it at the "-"
      return p(s[2]+s[1]+s[0]);})
                          //   Return whether "ddmmyyyy" is a palindrome
        .toArray(LocalDate[]::new);
                          //  And convert that filtered stream to an array of LocalDates
for(var a:L)for(var b:L){ //  Nested loop over all these dates a,b:
  var x=(a+"")            //   Convert date `a` to a String,
        .split("");       //   and then into an array of characters
  var y=(b+"").split(""); //   Do the same for date `b`
  A.sort(x);A.sort(y);    //   Sort the characters in both arrays
  var d=a.until(b,java.time.temporal.ChronoUnit.DAYS);
                          //   Get the difference in days between the two dates
  if(d>0                  //   If this difference is larger than 0,
                          //   (which means a is before b, and they are not the same)
     &A.equals(x,y)       //   and the two sorted character-arrays are equal,
                          //   (which means a and b are anagrams)
     &p(d+""))            //   and the difference is a palindrome:
    System.out.println(a+" "+b+" "+d);}}
                          //    Print the pair a,b and difference with trailing newline

// Separated method to check if a String is a palindrome:
boolean p(String s){      // Method with String parameter and boolean return-type
  return s.contains(      //  Return whether the input-string contains:
    new StringBuffer(s).reverse());}
                          //   The reversed input-String(Buffer)

```

# Answer
> 1 votes
\[HARCODED\]

# PHP, 194 bytes

```
<?=str_replace("x"," 6556
","31100113 13100131x20011002 02011020x31011013 13011031x20022002 02022020x31122113 13122131x31033013 13033031x31055013 13055031x31077013 13077031x31088013 13088031x");

```

Try it online!

\[WITH CAUTION\]: shorter version that assumes following Kevin Cruijssen's results (I haven't verified them) that the difference in days will always be 6556:

# PHP, 223 bytes

```
$a=date_create('0000-12-31');for(;($c=($d=clone$a->modify('+1day'))->format('dmY'))!=31129999;)if($c==strrev($c)&($e=$d->modify('+6556day')->format('dmY'))==strrev($e)&count_chars($c,1)==count_chars($e,1))echo"$c $e 6556
";

```

Try it online!

\[FULL VERSION THAT CALCULATES WITH ALL DATES\]:

# PHP, 283 bytes

```
$a=date_create('0000-12-31');for(;($c=($d=clone$a->modify('+1day'))->format('dmY'))!=31129999;){for(;($e=$d->modify('+1day')->format('dmY'))!=31129999;)if($c==strrev($c)&$e==strrev($e)&count_chars($c,1)==count_chars($e,1)&($f=$d->diff($a)->format('%a'))==strrev($f))echo"$c $e $f
";}

```

Try it online!

Dates format is `dd-mm-yyyy`, pairs are displayed in one order only. formats the inputs like `dd-mm-yyyy dd-mm-yyyy n` but doesn't separate them (count 1 bytes more for a new line).

Actually times out pretty quick.. cannot even check the first result in TIO. Note that the date `31-12-9999` is never tested (loops pre-increment), but it doesn't matter because it's not a palindrome anyway..

EDIT: added hardcoded version (port of Kevin Cruijssen's) + switched to format `ddmmyyyy` (without `-`) with a new line for the other versions

# Answer
> 0 votes
# 05AB1E, 39 bytes

```
31 9и20₂S;ǝDí«•1/K†Þ'āD•2×2ôøJº2äøŽP¶δª

```

05AB1E doesn't even have any date buitlins, so hard-coded it is. ;)
Uses and outputs in format `ddmmyyyy`. Outputs as a list of triplets.

Try it online (the `»` in the footer is to pretty-print them, but feel free to remove it to see the actual output).

**Explanation:**

```
31             # Push 31
   9и          # Repeat it 9 times as list: [31,31,31,31,31,31,31,31,31]
     20        # Push 20
       ₂S      # Push builtin 26 as digit list: [2,6]
         ;     # Halve each: [1,3]
          ǝ    # Insert 20 at both those (0-based) indices: [31,20,31,20,31,31,31,31,31]
           D   # Duplicate this list
            í  # Reverse each: [13,"02",13,"02",13,13,13,13,13]
             « # Merge the two lists together:
               #  [31,20,31,20,31,31,31,31,31,13,"02",13,"02",13,13,13,13,13]
•1/K†Þ'āD•    '# Push compressed integer 100101021203050708
          2×   # Double this as string: "100101021203050708100101021203050708"
            2ô # Split it into parts of size 2:
               #  [10,"01","01","02",12,"03","05","07","08",10,"01","01","02",12,"03","05","07","08"]
ø              # Zip the two lists together, creating pairs:
               #  [[31,10],[20,"01"],[31,"01"],[20,"02"],[31,12],[31,"03"],...]
 J             # Join each pair together to a string: [3110,2001,3101,2002,3112,3103,...]
  º            # Mirror each: [31100113,20011002,31011013,20022002,31122113,31033013,...]
   2ä          # Split the list into two equal parts (of size 9)
     ø         # Zip/transpose it, swapping rows/columns:
               #   [[31100113,13100131],[20011002,"02011020"],[31011013,13011031],...]
      ŽP¶      # Push compressed integer 6556
         δª    # And append it to each pair to create triplets
               # (after which that list of triplets is output implicitly as result)

```

See this 05AB1E tip of mine (section *How to compress large integers?*) to understand why `•1/K†Þ'āD•` is `100101021203050708` and `ŽP¶` is `6556`.

---
Tags: code-golf, date, permutations, palindrome
---


title: Build a polyglot for Hello World

text:
# Question
Title: Build a polyglot for Hello World
Produce a text file that prints "Hello World!" in as many programming languages as possible when compiled/interpreted, while also being as short as possible.

The score for your submission is calculated as `C / 2 ^ ((L - 1) / 4)`, where "C" is the length of the text file in characters and "L" is the number of languages that the program is valid in. Lowest score wins, of course.

# Answer
```
print("Hello World!")

```

Works in at least Julia, Perl, PHP, Python2, Python3, Qbasic, R, Ruby ...
> 21 votes

# Answer
# JavaScript ES6, Oration, Vitsy, Minkolang score = 71.94703045766462

`121 / 2^(3/4)`. Fun fact? I'm not trying to win, just to add as many languages as possible.

```
222 //X>"!dlroW olleH"Z
shush=0
alert("Hello World!")
sorry=`
listen
capture Hello World!`
$$$
=` >###      .O$r"!"rXr<`

```

## What Vitsy sees

"Well, I'm a 1D language, so... for now, only the first line counts."

```
222 //X>"!dlroW ,olleH"Z
222                      push three twos
    //                   divide twice
      X>                 drop the result and carry on
        "!dlroW ,olleH"Z standard Hello, World! program

```

Thanks for the cookie, Vitsy :3

## What JavaScript ES6 sees

```
222 //X>"!dlroW ,olleH"Z

```

"Let's see... You put the number `222` and then put something in a comment. Alright, sure, I'll roll with that."

```
shush=0

```

"You made a variable. Noted."

```
alert("Hello, World!")

```

"Ah, I see where you're going with this. I'll display that."

```
sorry=`
listen
capture Hello, World!`

```

"Oo! A multiline string! Now we're talking, ES6 rulez, ES5 drools!"

```
(EOF)

```

"Well, I'm done. Peace out."

## What Oration sees

```
222 //X>"!dlroW ,olleH"Z

```

"This wasn't on my notes...! Best not do anything."

```
shush=0
alert("Hello, World!")
sorry=`

```

"Oh, here's some extra notes."

```
listen

```

"Listen..."

```
capture Hello, World!`

```

"...Hello, World!"

```
(EOF)

```

"*thinks* Nothing more! Great, I'm done here. *breathes deeply*"

## Minkolang explanation

(Too lazy to create narrative. Might do later, the code took a while.) Irrelevant code replaced with `#` or omitted. Also, added comments `C ... C`.

```
222 ###>"!dlroW olleH"#
$$$  C this separates layers C
###>### #####.O$r"!"rXr<`

```

### Layer 1, pt 1

```
222 ###>"!dlroW olleH"#
222                      C push three 2s C
   _                     C space; fall to the next layer C

```

### Layer 2, pt 1

```
###>### #####.O$r"!"rXr<`
   >                       C go this way C
       _                   C fall to the next (first) layer C

```

### Layer 1, pt 2

```
222 ###>"!dlroW olleH"#
       >"!dlroW olleH"   C go right and push those characters in that order C
                       _ C fall to the next layer C

```

### Layer 2, pt 2

```
###>### #####.O$r"!"rXr<`
                       <  C starts here, going left C
                      r   C reverse stack C
                     X    C pop n (n = 2), and pop top n items on stack (2, 2) C
                    r     C reverse stack C
                 "!"      C push exclamation mark (for some reason, it's chopped off C
                r         C reverse stack C
              $O          C output stack as characters C
             .            C terminate program C

```
> 17 votes

# Answer
```
'Hello World!'

```

Runs in several scripting languages, including PHP, GolfScript, APL, ...
> 9 votes

# Answer
**Score of 0.84**

```
H

```

Works in H9+ and HQ9+.

1 / 2 ^ ((2 - 1) / 4) = **0.84**
> 9 votes

# Answer
## CoffeeScript and CJam, 46/2^((2-1)/4)=38.68

```
e###
"Hello, World!"
e###alert "Hello, World!"

```
> 1 votes

# Answer
# ES8, Japt, TeaScript, C#, C++, C, ESMin, score: ~8.8

```
main=_=>"Hello World!"();

```

ES8, TeaScript and Japt see `"Hello World!"`.
> 1 votes

# Answer
# Madbrain and \[insert most BF derivatives here\], ~~272~~ 227 bytes

Just posting for fun, not to win c:

```
956658555658
852224222254
************
c4993c839941
1****1**+**+
01cc70776ccc
g+11+g++*11
 c003 c3c00
 1gg* 1*1gg
 0  c 0c0
 g  1 g1g
    0  0
    g  g[-]+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++.>>.>.<<<.+++.------.<<-.>>>>+.

```

***NOTE:*** *There is no TIO for Madbrain, so you'll have to trust me on this one. I did, however, write an (admittedly not really well-written (but hey, at least it works!)) interpreter for Madbrain, which is on the esolangs wiki.*

## Explanation

Madbrain sees: (I wrote this code c:)

```
956658555658
852224222254
************
c4993c839941
1****1**+**+
01cc70776ccc
g+11+g++*11
 c003 c3c00
 1gg* 1*1gg
 0  c 0c0
 g  1 g1g
    0  0
    g  g

```

I admit, Madbrain reaches the BF code, but it doesn't do anything, so I didn't include it here.

Brainfuck (and a lot of BF derivatives) sees:

```
++++++[-]+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++.>>.>.<<<.+++.------.<<-.>>>>+.

```

BF ignores everything that isn't `><+-.,[]`, so it ignores *most* of the Madbrain code. However, there are some `+`s in the Madbrain code (that's what the `++++++` is), so you need to add `[-]` after that which sets the current cell to 0.

The code after `++++++[-]` is the code for printing `Hello World!`.
> 1 votes

# Answer
# TI-BASIC and Pyth, 13/2^((2-1)/4)=10.93

```
"Hello World!

```
> 0 votes

# Answer
```
puts "Hello world!"

```

Works in Ruby and Tcl
> 0 votes

---
Tags: code-golf, hello-world, polyglot
---


# Question
Title: Shortest, lexicographically smallest generating string
A string `x` *generates* a string `y` if `y` is a substring of an infinite repeat of `x`. For example `abc` generates `bcabcab`.

Write a program to find the shortest, lexicographically smallest string that will generate the input. You are given on standard input a single line of text. You should print the generating string to standard output. For example:

**input**

```
bcabcabca

```

**output**

```
abc

```

Shortest code wins. You may assume the input contains only the characters a-z (and a trailing newline if you want).

# Answer
## Ruby 1.9, 40 characters

```
gets;a=?a;a.next!until(a*~/$/)[$_];$><<a

```

Assumes the input is not terminated by a newline. Also it's probably ridiculously slow for larger results.

```
$ echo -n "bcabcabca" | ruby genlex.rb
abc
$ echo -n "barfoobarfoobarfoo" | ruby1.9 genlex.rb
arfoob

```
> 9 votes

# Answer
**Python ~~88~~ 185 chars**

```
import re
s=raw_input()
m=s.index(min(s))
s=s[m:]+s[:m]
i=0
while s.replace(s[:i],''):i+=1
m=min(s[:i])
s=re.findall('%s[\w]*?(?=%s|$)'%(m,m),s[:i])
m=s.index(min(s))
print ''.join(s[m:]+s[:m])

```

Output:

```
bcabcabca
abc

aaa
a

abc
abc

cccbbcccbbcccbb
bbccc

barfoofoobarfoofoo
arfoofoob

bacabac
abacbac

```
> 2 votes

# Answer
Haskell, 299 128 characters

```
import Data.List
main=interact(\z->minimum$filter(\w->isInfixOf z$concat$replicate(length z)w) $filter((/=)"")$inits=<<tails z)

```

Thanks to jloy! Now the version is both far shorter and I believe correct.
> 2 votes

# Answer
## Python, ~~161 159 166 140 141 134~~ 132 chars

```
y=raw_input();i=n=l=len(y)
while i:
 if (y[:i]*l)[:l]==y:n=i
 i-=1
x=y[:n];y=x*2
while i<n:
 x=min(x,y[i:i+n])
 i+=1
print x

```

**EDIT** : Golfed the code after reading Jules Olléon's comment. Removed a 'bug' that `bcdabcdab` results in `abbc`.

**EDIT2** : Fixed the bug (`abaa` results in `aaa`) spotted by Jules Olléon.

I don't know about Python well, so this code is probably 'not golfed'.

I love this rule:

*You may assume the input contains only the characters a-z...*

## Inputs & Outputs

```
bcdabcd
abcd

bcabcabca
abc

abcdabcd
abcd

bcdabcdab
abcd

barfoofoobarfoofoobar
arfoofoob

cccbbcccbbcccbb
bbccc

aaaaaaaaaaaaaaaa
a

thequickbrownfox
brownfoxthequick

ababa
ab

abaa
aab

```
> 2 votes

# Answer
**Python, 121 137 129 chars**

```
s=raw_input()
n=len(s)
l=[(s+s)[i/n:i/n+i%n+1]for i in range(n*n)]
print min(filter(lambda x:(x*len(s)).find(s)+1,sorted(l)),key=len)

```

EDIT: fixed the bug spotted by JiminP
> 2 votes

# Answer
## Ruby 1.9, 36

```
$><<(?a..gets).find{|s|(s*~/$/)[$_]}

```

Uses the same approach as Ventero's solution.
> 2 votes

# Answer
## Mathematica 124 bytes

```
x = StringLength@(y = "");
For[i = 1, ! (s = y~StringTake~i)~StringRepeat~x~StringContainsQ~y,i++];
First@Sort@StringPartition[s <> s, i, 1]

```

Whitespace and newlines (in the presence of semicolons at the ends of lines) have no meaning in Mathematica and are included here for readability.

Input goes in between the quotation marks in the first line. If recast as a function, that takes string input like so:

```
f=(x=StringLength@(y=#);For[i=1,!(s=y~StringTake~i)~StringRepeat~x~StringContainsQ~y,i++];First@Sort@StringPartition[s<>s,i,1])&

f@"bca"

(* "abc" *)

f@"abaa"

(* "aab" *)

```

then it's 128 bytes.

The `For` loop takes the first `i` characters of the input and repeats them at least up to the length of the input, then checks if the input is a substring of the result. Having found the length of the period of the string, the `StringPartition` command concatenates two copies of that period and takes all substrings of that length from it (basically gets all cyclic permutations), then `First@Sort` finds the first one of them when lexicographically ordered.
> 1 votes

# Answer
# PowerShell, 23 bytes

```
-join($args|group|% N*)

```

Try it online!
> 0 votes

# Answer
javascript 96 Chars.

```
var temp = {},len = str.length;
for(i in str)
temp[str[i]] = true;
Object.keys(temp).join("");

```

Working Plunkr
> -1 votes

---
Tags: code-golf, kolmogorov-complexity, subsequence
---


# Question
Title: Single Digit Representations of Natural Numbers
# Task

Write a program/function that when given a positive integer \\$n\\$ and a digit \\$d\\$ which is not 0 outputs a way to represent \\$n\\$ using only addition, subtraction, multiplication, exponentiation, division, concatenation, parenthesis and the digit \\$d\\$.

# Examples

```
n =  6, d = 1  =>  (1 + 1) * (1 + 1 + 1)
n =  6, d = 1  =>  1 + 1 + 1 + 1 + 1 + 1
n = 10, d = 1  =>  1 || 1 - 1
n = 12, d = 1  =>  1 || (1 + 1)
n = 64, d = 2  =>  2 ^ (2 + 2 + 2)
n =  1, d = 9  =>  9 / 9

```

**Note:** In the examples `||` represents concatenation

# Output Format

* Concatenation must be explicit with a separate operator
* Output can be a string, list of operations and numbers or a list of lists in place of brackets.
* You may choose the precedence of the operators but it must be consistent for all outputs produced by your program/function
* Output may be in polish, reverse polish or infix notation but it must be consistent for all outputs produced by your program/function.
* You can use custom symbols for representing the digits and operations but the symbols used for representing the digits and operations should be distinct.

# Scoring

This is , Your score will be

```
100*B + S

```

Where `B` is the number of bytes in the program/function, and `S` is the sum of the number of times the digit \\$d\\$ appears in the representation of \\$n\\$ with the digit \\$d\\$ as returned by your program/function for all \\$n \le 1000\\$ and all \\$d\\$ from 1 to 9

Lowest score wins

Example: if your program is `abcd` and all representation of \\$n\\$ returned by your program has 5 occurrences of \\$d\\$ then its score will be `(4 * 100) + (5 * 1000 * 9) = 45400`

# Rules

* Your program/function should run deterministically, so that it always returns the same representation for a given \\$n\\$ and \\$d\\$ (and hence always gets the same score).
* Your answer must include not only your submission, but also the code you used to calculate the `S` part of its score. This need not be written in the same language as your submission, and will not be counted towards its byte count. You are encouraged to make it readable.
* Your answer must include the precedence of the operators needed to evaluate the outputs produced by your program/function
* You must actually run your test program and calculate/verify your score before submitting your entry. If your submission runs too slowly for you to verify its score then it is not qualified to compete, even if you know what its score would be in principle.

---

*Inspired by this video*

# Answer
# Python 3, 210 bytes · 100 + 59045 digits = 80045

```
def f(n,d):
 m={d:d},
 while{n}-{*m[0]}:m={z:(p[x],o,q[y])for p,q in zip(m,m[::-1])for x in p for y in q for z,o in zip([x+y,x-y,x*y,y<9and x**y,x%y<1and x//y,int(f"{x}{y}")],"+-*^/|")if z>0},*m
 return m[0][n]

```

Try it online!

### Scoring

Scoring goes much faster using this modified version that solves 1 through 1000 all at once:

```
def f_gen(d):
 m={d:d},
 while 1:yield from m[0].items();m={z:(p[x],o,q[y])for p,q in zip(m,m[::-1])for x in p for y in q for z,o in zip([x+y,x-y,x*y,y<9and x**y,x%y<1and x//y,int(f"{x}{y}")],"+-*^/|")if z>0},*m

def size(expr):
    return 1 if isinstance(expr, int) else size(expr[0]) + size(expr[2])

score = 0
for d in range(1, 10):
    s = set(range(1, 1001))
    for n, expr in f_gen(d):
        if n in s:
            s -= {n}
            score += size(expr)
            print(n, expr)
            if not s:
                break
print(score)

```
> 7 votes

# Answer
# JavaScript (Node.js), Score:  ~~87900 ... 83274~~  82574

## 229 bytes x 100 + 59674 digits

Takes input as `(d)(n)`. Returns a string. Uses `|` for concatenation.

```
d=>n=>[0,v=[d],F={[d]:d},s={[d]:0}].map(_=>v.map(x=>v.map(y=>[x+y,x-y,x*y,x/y,x**y,[x]+y].map((z,o)=>z<0|z>1e4||z%1?0:(!F[z]&&V.push(+z))|(S=s[x]-~s[y])<s[z]?F[s[z]=S,z]=`(${F[x]+'+-*/^|'[o]+F[y]})`:0)),V=[])&&v.push(...V))&&F[n]

```

Try it online!

### Scoring

Because the golfed version is quite slow, the total score was computed with the following ungolfed version which, given \\$d\\$, computes the formulas for all \\$n\in\[1..1000\]\\$ at once.

Although it works on TIO, the output is too long. So the link below is an example for \\$d=9\\$.

Try it online!

```
const OP = ['+', '-', '*', '/', '^', '||'];

function solve(d) {
  let value = [ d ],
      formula = { [d] : d },
      size = { [d] : 0 },
      total = 0;

  for(let i = 0; i < 4; i++) {
    let newValue = [];

    value.forEach(x => {
      value.forEach(y => {
        [0, 1, 2, 3, 4, 5].forEach(o => {
          let v;

          switch(o) {
            case 0: v = x + y; break;
            case 1: v = x < y ? null : x - y; break;
            case 2: v = x * y; break;
            case 3: v = x % y ? null : x / y; break;
            case 4: v = x ** y; break;
            case 5: v = +(x.toString() + y.toString()); break;
          }

          if(v !== null && v <= 10000) {
            let sz = size[x] + size[y] + 1;

            if((formula[v] === undefined && newValue.push(v)) || sz < size[v]) {
              formula[v] = '(' + formula[x] + OP[o] + formula[y] + ')';
              size[v] = sz;
            }
          }
        });
      });
    });
    value.push(...newValue);
  }

  for(let n = 1; n <= 1000; n++) {
    console.log(n, size[n] + 1, formula[n]);
    total += size[n] + 1;
  }
  console.log('-->', total);
  return total;
}

let score = 0;

for(let d = 1; d <= 9; d++) {
  score += solve(d);
}
console.log('Final score:', score);

```
> 6 votes

# Answer
# Wren, 107 bytes, score: 138373

Thanks to @Mukundan for the golfing so far!

(This answer was written before @GammaFunction did so.)

```
Fn.new{|n,d|"%(n)".map{|i|Num.fromString(i)}.map{|i|i<1?[d,-d]:[d]*(i/d).floor+["%(d)/%(d)"]*(i%d)}.join()}

```

Try it online!
> 4 votes

# Answer
# Zsh, ~~89 81~~ 75 bytes, score: 135173

(total digit count is 127673)

```
for c (${(s::)1})(repeat c/$2 s+=($2);repeat c%$2 s+=($2/$2);<<<${s=$2-$2})

```

Try it online!

(This generates the same operations that @a'\_''s method does. I thought of it independently, then saw his score using it, then implemented it.)

> You can use custom symbols for representing the digits and operations \[...\]

We take advantage of that here; concatenation is represented by a newline and addition is represented by space. Concatenation has lower precedence than addition, which has lower precedence than division.

```
for c (${(s::)1})(          # for each digit c in n
                            # repeat $x expands $x in arithmetic mode
    repeat c/$2 s+=($2)     # append d to $s, c/d times
    repeat c%$2 s+=($2/$2)  # append d/d to $s, c%d times
    <<<${s=$2-$2}           # if $s is still unset, set it to d-d
                            # <<< prints $s, implicitly joined on spaces
)                           # exit the subshell, effectively unsetting $s

```
> 4 votes

# Answer
# Brainfuck, 30 bytes * 100 + 9009000 = 9012000

Uses the fact that `n = (d/d)*n`:

```
,>,>+<<->.>.<.<[->>>.<<.>.<.<]

```

In that program, the character representing division is ASCII 1 and the character representing addition is ASCII 0, so the output isn't very readable.

With this TIO link I include a brief header making the output readable. There is still the minor inconvenience that input are ASCII characters (the link has a new line, ASCII 10, in the input, hence the program prints

```
9/9+9/9+9/9+9/9+9/9+9/9+9/9+9/9+9/9+9/9

```

To make 10. If instead you use this interpreter, you can type easier to understand input, using `\` to insert the values of the ascii characters, instead of using the ascii characters. So, using `\10\57` as input in this program gives the same result as the program on TIO.
> 4 votes

# Answer
# Charcoal, 150 bytes × 100 + 81773 digits = 96773

```
⪫Ｅθ§⪪§⪪”}∧⟦NＪgＹＺＧ；|⪫v4⌈-LiςΠg➙∨Ｃ⊕⊙Nψ≧Fδ∨↧↧«3Ｙ!‴2ⅈ⸿⟦⁰J◨(⁴⦄4b¶¤⦄→₂⊞GςＧ⸿≡←ε⭆R？ρq＆Σ<×HJ⁶�⧴Q<"k~3Ｖu⌊+ＬΠ↓1βπt“P³∨Ｒ▶Ａ↓ⅉs▷"«‖κ-σ_←U/Ｖ!Ｕ⊕⁷↙Ｕ3M⁼³ＲＶＶ¤HＱ:”;Ｉη,Ｉι&

```

Try it online! Link is to verbose version of code. Uses `&` (low precedence) as concatenation and `#` to represent the input digit. Explanation: Simply looks up all of the digit patterns in a (compressed) hand-crafted lookup table and concatenates the relevant digits together. Proof of digit count.
> 3 votes

# Answer
# `n`, 22 bytes * 100 + 127673 = 129 873

A blatant rip-off of my Wren answer.

```
☺◘Y╔û çτ◘↑═uon↕I6≡ÿÑ°t

```

Uncompressed:

```
1,             % Split number to chunks of 1
  c}           % Construct the list [input]
    ac/*       %   Repeat that input/current times
  c:{          % The list [input,input]
     '/,       % The string input/input
        }      % The list [input/input]
         acm*  %   Repeat that list input%current times
             + % Join these two lists
      |        % If that's the empty list:
  c:_{         %   Yield the list [input,-input]
       M       % Do that for every thing in the input

```
> 1 votes

# Answer
# Ruby, Score: 127,473 (178 bytes * 100 + 109,673)

```
->n,d{n.to_s.chars.map{|c|g=d.to_s;c<?1?g+?-+g:(i=c.to_i)==d ?d:(d*d==i)?g+?*+g:i%d<1?([d.to_s]*(i/d))*?+:i>d ?g+?++f[i-d,d]:(i+1==d&&i>1)?g+?-+f[d-i,d]:[d==1?d:g+?/+g]*i*?+}*?|}

```

Try it online!

This uses `|` as concatenation. It could also definitely be cleverer. I just kept adding cases to try to minimse the occurences of `d`.
> 1 votes

---
Tags: code-challenge, expression-building
---


title: Print the Stack Exchange favicon

text:
# Question
Title: Print the Stack Exchange favicon
# Challenge

Print or return the Stack Exchange favicon, as provided below:

```
 ___________________
/                   \
---------------------
|                   |
---------------------
|                   |
---------------------
\__________    _____/
           |  /
           | /
           |/

```

This is , so the shortest answer in each language wins.

# Answer
# Operation Flashpoint scripting language, ~~263~~ 195 bytes

```
f={r="                   ";t="---------------------\n";s=" ___________________\n/"+r+"\\n"+t+"|"+r+"|\n"+t+"|"+r+"|\n"+t+"\__________    _____/\n           |  /\n           | /\n           |/";s}

```

Not the right tool for the job.

**Call with:**

```
hint call f;

```

**Output:**

The formatting fails, because the font is not monospaced.
> 43 votes

# Answer
# Charcoal, ~~38~~ ~~37~~ ~~33~~ 30 bytes

```
←×_χ↓Ｆ/||⟦ι¹¹⟧\×_⁹‖Ｂ_×ψ⁴↙↙³↑↑³

```

Try it online! Link is to verbose version of code. Edit: Managed to save a byte with the help of a reflection, although @CarlosAlejo shows that it can in fact be done in 37 bytes without reflecting. Saved a further 4 bytes by drawing the left ¾ and reflecting the final ¼. Edit: Previous 33-byte answer depended on `ReflectButterflyOverlap()` not overprinting the overlap area with the reflection, so in case this behaviour changed, I sought a solution that didn't rely on that, and the result turned out to be shorter anyway, thanks to my creative use of printing an array. Explanation:

```
←×_χ                            Print 10 `_`s leftwards (top row)
    ↓                           Move down to the next row
     Ｆ/||                       For each character in the string `/||`
          ι                     Current character
           ¹¹                   Integer 11, prints as `-----------`
         ⟦   ⟧                  Put both into an array
                                Implicitly print on separate lines
              \                 Implicitly print `\`
               ×_⁹              Implicitly print 9 `_`s
                  ‖Ｂ            Reflect right, overlapping the axis
                    _           Implicitly print `_`
                     ×ψ⁴        Implicitly delete 4 characters
                        ↙↙³     Move down left and print three `/`s
                           ↑↑³  Move up and print three '|'s

```
> 11 votes

# Answer
# ///, 98 bytes

```
/'/  //&/
"""
|!! |//%/\\\/
!'|//#/_____//"/-------//!/'''' / ###____
\/!! \\&&
"""
\\##''#%'% %\/

```

Try it online! Or, see it interactively!
> 9 votes

# Answer
# JavaScript (ES6), ~~113~~ 112 bytes

(Saved a byte thanks to @Craig Ayre.)

```
let f=

_=>` _19
/ 19\\
-21
| 19|
-21
| 19|
-21
\\_10 4_5/
 11| 2/
 11| /
 11|/`.replace(/.(\d+)/g,([a],b)=>a.repeat(b))

 console.log(f());
```
> 8 votes

# Answer
# Python 2, 115 bytes, more creative idea

```
t,u,v,w,x,y,z='\n -/\\_|';k=w+t+11*u+z;i=t+21*v+t
print u+19*y+t+w+19*u+x+(i+z+19*u+z)*2+i+x+10*y+4*u+5*y+k+u,k,k+w

```

Try it online!

# Python 2, 102 bytes, boring idea

```
print'eNrjUojHBFz6CpgghksXG+CqwaK2hgpqYxDuASkDM/S5kDUqKKDxUbn6XADUmClx'.decode('base64').decode('zip')

```

Try it online!
> 8 votes

# Answer
# SOGL V0.12, ~~32~~ 31 bytes

```
^$∙r↑Ψ«2τγæΕž‘╬Æ╬⁷"ƧΡ⅟?0Ξ³‘6«8ž

```

Try it Here!

Explanation:

```
...‘               push a quarter of the icon
    ╬Æ             palindromize vertically
      ╬⁷           palindromize horizontally (these two should be ╬3 together, but spacing doesn't work correctly (though now it does since I fixed it))
        "...‘      push the extention
             6«8ž  at coordinates [12; 8] in the quad-palindromized image put that in

```

The quarter:

```
 __________
/
-----------
|
-----------

```

and the other part:

```

|  /
| /
|/
```
> 7 votes

# Answer
# Python 2, 124 bytes

```
a,b,d,e,f,g,h=' _-|/\\\n';r=d*21+h+e+a*19+e+h;n=f+h+a*11+e;print a+b*19+h+f+a*19+g+h+r*2+r[:22]+g+b*10+a*4+b*5+n+a*2+n+a+n+f

```

Try It Online!
> 6 votes

# Answer
# C (gcc), 187 bytes

Saved 2 bytes thanks to Cody Gray, and 3 bytes thanks to Keyu Gan!

```
#define a"         "
#define s a" "a
#define l"\n---------------------\n"
f(){puts(" ___________________\n/"s"\\"l"|"s"|"l"|"s"|"l"\\__________    _____/\n"a"  |  /\n"a"  | /\n"a"  |/");}

```

Try it online!
> 6 votes

# Answer
# C, 167 bytes

```
i;char*d=" q    /()\\   A   |()|    A   |()|    A   \\h#c/  #&|!/   #&| /   #&|/",c,b;main(j){while(c=d[i++],b=c%5==2||c>123?c:c>95?95:c>45?45:c>=32?32:++c,i<47)for(j=c;j-->=b;)putchar(b);}

```

Try it online!

Note: a lot of apparent spaces above are actually the tab character.

Readable version:

```
i;
char *d = " q   /()\\   A   |()|    A   |()|    A   \\h#c/  #&|!/   #&| /   #&|/", c, b;
main(j) {
    while(
        c = d[i++],
        b = c % 5==2 || c > 123 ? c:
            c > 95 ? 95:
            c > 45 ? 45:
            c >= 32 ? 32:
            ++c,
        i < 47
    )
        for(j = c; j-- >= b;)
            putchar(b);
}

```

Explanation:

The data array, d, encodes the answer in literal single characters and coded repeated characters. Each character, c, in the data array is mapped to a base character, b, and a number of repetitions. It is then printed that many times.

Characters that are used only singly (slashes and the pipe) have ASCII codes 47, 92, and 124. Two of these are divisible by 5 with a remainder of 2 `(c%5=2||c>123)`. I couldn't find a shorter condition to test for all three.

Characters that are repeated (underscore, dash, and space), with ASCII codes 95, 45, and 32 respectively, are coded with a higher ASCII code--increased by one per repetition. So, for example, a single space is just a space, but two spaces can be coded by the next ASCII character, the exclamation point. Where a coded character would be unsuitable because it meets the above modulo condition, it can be split, as with #& to represent eleven spaces. The same technique is used to avoid overlap between the space and dash character ranges.

Finally, the ten newlines are encoded as tabs to save bytes that would have been spent escaping the newlines with a backslash, then incremented for printing (`++c`).
> 5 votes

# Answer
# Rust, 181 bytes

```
||" ___________________
/2\\
1
1
3
\\__________    _____/
4|  /
4| /
4|/".replace("1","3
|2|").replace("2",&" ".repeat(19)).replace("3",&"-".repeat(21)).replace("4",&" ".repeat(11))

```

Try it online!

## Rust, 184 bytes

This version may be more golfable as adding further `replace` cost fewer bytes each. The first `replace` isn't part of the loop because it pulls double duty changing `s` into a `String` instead of a `&'static str`.

```
||{let mut s=" 5__5__5
/2\\
1
1
3
\\55    5/
4|  /
4| /
4|/".replace("1","3
|2|");for p in vec![("2"," ",19),("3","-",21),("4"," ",11),("5","_",5)]{s=s.replace(p.0,&p.1.repeat(p.2))}s}

```

Try it online!
> 4 votes

# Answer
# Charcoal, 49 37 bytes

```
↓⁵\…_χ↓↓³↗↗³…_⁵↑/↑⁵↖\←…_¹⁹↓ /Ｆ³«Ｐ²¹¶¶

```

Try it online!

At last I could golf this a bit. This answer (unlike all other Charcoal answers) does not use reflection, but draws all the contour in one pass, leaving the horizontal bars for the end.

Link to the verbose version.
> 4 votes

# Answer
# Bubblegum, 40 bytes

Saved 1 byte by removing a trailing newline, thanks @ovs!

```
00000000: 5388 c704 5cfa 0a98 2086 4b17 1be0 aac1  S...\... .K.....
00000010: a2b6 860a 6a63 10ee 0129 0333 f4b9 9035  ....jc...).3...5
00000020: 2a28 a0f1 51b9 fa00                      *(..Q...

```

Try it online!
> 3 votes

# Answer
# Charcoal, 38 bytes

```
←…_χＰ↑⁵Ｐ\Ｆ³«↑Ｐ¹¹↑»↗¹…_χ‖ＢＭ²¦⁷Ｐ↓⁴… ⁴↙↙³

```

Try it online!

I used Carlos's answer in its original form as a jumping-off point, but saved a good bit by using a reflection, taking advantage of horizontal symmetry. (Vertical symmetry wasn't worth it because the underscores ended up on the wrong row.) You can see the evolution of the canvas at each step here.

Here's the verbose version.
> 3 votes

# Answer
# Python 2, ~~119~~ ~~117~~ 116 bytes

```
print''.join(' \n-/|\\_'[ord(x)/8-4]*int('1245abjl'[ord(x)%8],36)for x in' V(8&H(7(@&@(7(@&@(7(HT"S8(%@!8(%@ 8(%@8')

```

Try it online!

A bit of tortured run-length encoding...

EDIT: Save 3 bytes by replacing the set of lengths:

`[1,2,4,5,10,11,19,21][ord(x)%8]`

with

`int('1245abjl'[ord(x)%8],36)`
> 3 votes

# Answer
# C++ 11 - ~~162~~ ~~159~~ ~~154~~ ~~152~~ 150 bytes

MSVC:

```
void f(){char*i="b t_b\nb/t b\\b\nv-b\nb|t b|b\nv-b\nb|t b|b\nv-b\nb\\k_e f_b/b\nl b|c b/b\nl b|b b/b\nl b|b/";while(*i)cout<<string(*i++-97,*i),i++;}

```

GCC: (+4 chars)

```
int f(){char*i="b t_b\nb/t b\\b\nv-b\nb|t b|b\nv-b\nb|t b|b\nv-b\nb\\k_e f_b/b\nl b|c b/b\nl b|b b/b\nl b|b/";while(*i){cout<<string(*i-97,*(i+1));i+=2;}}

```

Input string `i` is coded in char pairs:

1. Count of chars to repeat (added to 'a' to be a legible character)
2. Char to print

I think, there's still a lot of room for improvement here.

Edit:

1. Replaced putchar with cout\<\<
2. Remove while, Use string constructor to repeat chars
3. Removed space before pointer and a spurious semi-colon ;;
4. Compounding instructions with comma, removing braces.
> 3 votes

# Answer
## R16K1S60 Assembly, ~~152~~ 144 Bytes

Writes output to screen peripheral the R16K1S60 in ASCII. Runs on The Powder Toy save `2012356`. (See link in header for info)

The byte size of the program is the compiled result (Cells Used * 2), not the assembly.

You know you've done well when the logo takes more space than your bytecode.

```
a:
mov ex, ip
mov ax, .string
mov sp, ip
mov dx, 0x1000
send sp, dx
.loop:
mov bx, [ax]
cmp bx, ip
je .end
cmp bx, ip
je .newline

shr bx, cx, 8
and cx, 0x00FF
.inner:
send sp, cx
sub bx, ex
jnz .inner
.reentry:
add ax, ex
jmp .loop
.newline:
add dx, 0x0020
send sp, dx
jmp .reentry
.string:
dw 0x0120
dw 0x135F
dw 0x000C
dw 0x012F
dw 0x1320
dw 0x015C
dw 0x000C
dw 0x152D
dw 0x000C
dw 0x017C
dw 0x1320
dw 0x017C
dw 0x000C
dw 0x152D
dw 0x000C
dw 0x017C
dw 0x1320
dw 0x017C
dw 0x000C
dw 0x152D
dw 0x000C
dw 0x015C
dw 0x0A5F
dw 0x0420
dw 0x055F
dw 0x012F
dw 0x000C
dw 0x0B20
dw 0x017C
dw 0x0220
dw 0x012F
dw 0x000C
dw 0x0B20
dw 0x017C
dw 0x0120
dw 0x012F
dw 0x000C
dw 0x0B20
dw 0x017C
dw 0x012F
dw 0x0009
.end:
hlt

```

## Explanation

The assembly code above implements a simple compression algorithm, with the words 0x000C being a newline and 0x0009 being the command to stop execution.

The other words are encoded simply, like this: 0xTTCC

* T: Times to repeat the value
* C: The ASCII character to print

The ASM uses every register available to it, including some of the less commonly used ones:

* The Instruction Pointer, to get a few known values into quick recall to save some bytes (A constant value in an instuction that's not just a register uses an extra byte to store it)
* The Stack Pointer is used as 6th general purpose register, because none of the code uses the stack.

Only AX, BX, CX, and DX are actually used for important data. EX and SP are used to store some constants that get frequently used.

It's somewhat simple, and has nil chance of winning, but it was fun to write!

See revision history for the old answer (It's just as large in terms of ASM)

funfact: if this was measured in words (in the case of the R16K1S60,16 bits) it'd be smaller than the pyth answer, at 72 bytes
> 3 votes

# Answer
# Pyth, 74 bytes

```
J*21\-L*db+d*19\_++\/y19\\V2J++\|y19\|;J++++\\*T\_y4*5\_\/V3+++y11\|y-2N\/

```

Try it online!
> 3 votes

# Answer
# Python 2, ~~159~~ ~~153~~ 139 bytes

```
s=" "*19;e="-"*21;a=" "*9;print" %s\n/%s\\\n%s\n|%s|\n%s\n|%s|\n%s\n\%s    %s/\n%s|  /\n%s| /\n%s|/"%("_"*19,s,e,s,e,s,e,"_"*8,"_"*7,a,a,a)

```

Try it online!

EDIT: Saved 6 bytes by using `%` formatting instead of `.format()`.
EDIT: Saved another 14 bytes by fixing the output, thanks to musicman523.
> 2 votes

# Answer
# Jelly, ~~50~~ ~~48~~ 45 bytes

```
21“©&Ẇƥ⁸þ/Ẉoụ’ḃ1pF“CṣʠėHẹỊtṡḤḶ’ṃ“ _/\-|”¤xs¹Y

```

Try it online!
> 2 votes

# Answer
# , 49 bytes

```
i ±¹_
/±¹ \2ÙÒ-jÓÓ/|
3äkGR\±_´ µ_/
±± |  /2ñÙlx

```

Try it online!
> 2 votes

# Answer
# Japt, ~~79~~ ~~72~~ 71 bytes

```
" _p
/ p\\
{"-r
| p|
"²}-r
\\_g a_b/
 h|  /
 h| /
 h|/"r".%l"_g p6nZÅnH

```

Test it

* 7 bytes saved thanks to ETHproductions' excellent suggestion of using base 32 integers for the repetition values.
> 2 votes

# Answer
# Mathematica, 163 bytes

```
Row@Map[Column,Characters/@{" /-|-|-\\   ",r="_ - - -_   ",r,r,r,r,r,r,r,r,r,"_ - - - |||","_ - - -   /","_ - - -  / ","_ - - - /  ",r,r,r,r,r," \\-|-|-/   "},{1}]

```
> 2 votes

# Answer
# PHP, 86 bytes

```
<?=gzinflate(base64_decode("U4jHBFz6CpgghksXG+CqwaK2hgpqYxDuASkDM/S5kDUqKKDxUbn6AA"));

```

Try it online!

# PHP, 118 bytes

```
<?=strtr(' 333____
/00   \
11-
|02
11-
|02
11-
\33    3/
2  /
2 /
2/',['        ','----------',"           |",_____]);

```

Try it online!
> 2 votes

# Answer
## Python 2, 171 bytes

```
p,u,q,v,r,s,F=' ','_','/','|','-'*21,'\\',lambda f,m:f+m*19+f;B=lambda n:p*11+v+p*n+q
print'\n'.join([F(p,u),q+p*19+s,r,F(v,p),r,F(v,p),r,s+u*10+p*4+u*5+q,B(2),B(1),B(0)])

```

Each line is exactly 85 bytes! Hoorah!
> 2 votes

# Answer
# Zsh, 244 bytes

This is specifically written for Zsh, not Bash, as it allows a bit more in terms of weird syntax.

```
alias p=printf
function r { p "$1%.s" {0..$2}}
function l { p $1;r $2 19;p $3;p "\n"}
l " " _ " "
l / " " \\
l - - -
l \| " " \|
l - - -
l \| " " \|
l - - -
p \\
r _ 10
r " " 4
r _ 5
p "/\n"
r " " 11
p "|  /\n"
r " " 11
p "| /\n"
r " " 11
p \|/

```

Note: when I tried to run it on tio.run the output is different than on my terminal. The fix to this is replacing

```
function r { p "$1%.s" {0..$2}}

```

with

```
function r { p "$1%.0s" {0..$2}}

```

which would make it 245 bytes (link).

**Edit** Seems like I was too eager to hit that post button and I missed some spaces, making my solution a bit less efficient. My new output seems off though, but I think I counted correctly (but it wouldn't change the length anyway).
> 2 votes

# Answer
# Retina, 74 bytes

```

 _18¶/ 18\-| 18|-| 18|-\_9 3_4%  % %/
-
¶-20¶
%
/¶ 10|
\d+
$*
+`(.)1
$1$1

```

Try it online!
> 2 votes

# Answer
# ,,,, ~~115~~ ~~101~~ 98 bytes

I am absolutely ashamed that this is the best I can produce. \>.\>

```
"|/
"' 11×:"| /
"⇆:"|  /
"⇆'
'/'_5×' 4×'_10×92c'
'|' 19×'|'
'-21×+++++3×110⇆⊣"\
"' 19×'/'
'_19×' #

```
> 1 votes

# Answer
# JavaScript (ES6), 151 bytes

```
_=>` 2_________
/0\\
1
|0|
1
|0|
1
\\2    _____/
3|  /
3| /
3|/`.replace(/\d/g,a=>a.repeat.call(...[[" ",19],["-",21],["_",10],[" ",11]][a]))

```

## Test Snippet

```
f=
_=>` 2_________
/0\\
1
|0|
1
|0|
1
\\2    _____/
3|  /
3| /
3|/`.replace(/\d/g,a=>a.repeat.call(...[[" ",19],["-",21],["_",10],[" ",11]][a]))

O.innerHTML=f()
```

```
<pre id=O>
```
> 1 votes

# Answer
# Retina, 89 bytes

```

1"""____¶/19\¶##-¶|19|¶##-¶|19|¶##-¶\""4"/¶11|2/¶11|1/¶11|/
#
!!
"
_____
!
-----
\d+
$*

```

Try it online!
> 1 votes

# Answer
# Charcoal, 48 bytes

```
↙¹→Ｐ¹¹↓↓¹Ｐ¹¹‖Ｂ↓¦↘→×¹⁰_Ｍ⁷↑←←×¹⁰_‖ＢＪ¹¹¦⁶→×⁴ ↙↙³↑↑³

```

Try it online!

Somewhat different internals than Carlos's, although not visible at first.
> 1 votes

# Answer
# tcl, 150

```
proc R {s n\ 19} {string repe $s $n}
puts " [R _]
/[R \ ]\\
-[R -]-
[set T |[R \ ]|\n-[R -]- ]
$T
\\[R _ 11]    ____/
[set S [R \  12]|]  /
$S /
$S/"

```

# demo

---

Another version with same number of bytes:

```
proc R {s n\ 19} {string repe $s $n}
puts " [R _]
/[R \ ]\\
[set T -[R -]-\ \n|[R \ ]|]
$T
-[R -]-
\\[R _ 11]    ____/
[set S [R \  12]|]  /
$S /
$S/"

```

# demo
> 1 votes

# Answer
# Python 3.6, ~~132~~ ~~128~~ ~~125~~ 124 bytes

```
x,y="_ "
b=y*19
c='-'*21
e=y*11
f=f"{c}\n|{b}|\n"
print(fr''' {x*19}
/{b}\
{f*2+c}
\{x*10+y*4+x*5}/
{e}|  /
{e}| /
{e}|/''')

```

Try it online!
> 1 votes

# Answer
# Windows batch, 263 bytes

```
@echo off
echo  ___________________
echo /                   \
for /l %%G in (1,1,2)do (
echo ---------------------
echo ^|                   ^|
)
echo ---------------------
echo \__________    _____/
echo            ^|  /
echo            ^| /
echo            ^|/

```
> 1 votes

# Answer
# Braingolf, ~~129~~ 120 bytes

```
9+.# [#_]#
#/[# ]#\#
&@#
.+>[#-]#
!&@V9+#|[# ]#|#
!&@R!&@v&@R&@934#
..#\[#_][# ][#_]#/#
[# ]"|  /
"[# ]"| /
"[# ]"|/"&@

```

Try it online!

As always, braingolf is not good at ASCII art
> 0 votes

# Answer
# Golfscript, 102 bytes

Try it online!

This is less than half the size of the actual output.

```
' ''_'9*.'_
/'' '19*'\
''-'21*n+.'|'.5$\n+++.@.@\'\\'9$'_'' '4*'_'5*'/
'2$.'   |'++.'  /
'@.' /
'@'/'

```
> 0 votes

# Answer
# C (gcc), ~~138~~ 137 bytes

That string still taunts me with its look of compressibility.

```
f(i){for(char*s=" S_:/S \\:U-:|S |:U-:|S |:U-:\\J_D E_/:K |  /:K | /:K |/";*s;s++)for(i=*s>64&*s<91?*s++-64:1;i--;)putchar(*s^58?*s:10);}

```

Try it online!
> 0 votes

# Answer
# PowerShell, ~~116~~ 115 bytes

```
' _19
/ 19\
-21
| 19|
-21
| 19|
-21
\_10 4_5/
 11|  /
 11| /
 11|/'-replace'(.)(\d+)',{$x,$c,$n=$_|% gr*;"$c"*"$n"}

```

Try it online!
> 0 votes

---
Tags: code-golf, string, ascii-art, kolmogorov-complexity
---


title: Square-Cube Digit Usage

text:
# Question
Title: Square-Cube Digit Usage
The point of this challenge is to find the smallest positive integer that uses up *at least* all of the digits supplied in the input after it is squared and cubed.

So, when provided an input such as `0123456789` (i.e. a number that finds the result):

```
69² = 4761
69³ = 328509

```

It means that `69` is the result of such an input. (Fun fact: 69 is the smallest number that uses up all of the decimal digits of 0 to 9 after squaring and cubing.)

## Specification

The input doesn't have to be unique. For example, the input can be `1466` and here's the result:

```
4² = 16
4³ = 64

```

That means we can't just fulfill this input by just doing a number that only uses 1 digit of `6`, it has to have 2 digits of 6 in the output.

## Test cases

Here's an exhaustive list of all numbers from 1 to 10000.

```
1333 (or 3133/3313/3331) -> 111

```

## Input specification

* You may take input as a list of digits.
* Since the test cases (somehow) have a bug in it, here's an extra rule: the `0`'s in the input will be ignored.

# Answer
# Japt , ~~17~~ ~~16~~ ~~15~~ ~~14~~ 11 bytes

~~*Still* very not happy with this!~~ ~~A little happier!~~ *Now* I'm happy!

Takes input as an integer.

```
²+U³s)á dèN

```

Try it

```
²+U³s)á dèN     :Implicit map of each U in the range [0,input)
²               :U squared
 +              :Concatenate
  U³            :  U cubed
    s           :  Converted to a string (preventing the + from adding the 2 numbers)
     )          :End concatenate
      á         :All permutations
        d       :Any truthy (not 0) when
         è      :  Counting the occurrences of
          N     :    The array of inputs, which is implicitly cast to a string
                :Implicit output of first U to return true

```
> 2 votes

# Answer
# 05AB1E, ~~14~~ ~~12~~ 13 bytes

*-2 bytes thanks to @KevinCruijssen*

*+1 byte thanks to @Grimmy*

```
∞.Δ23SmJœIÅ?Z

```

Try it online!

---

### Explanation

```
∞.Δ                  - First number that...
   23Sm              - Power of 2 and 3 [n^2, n^3]
       J             - Concatenated
        œ            - Permutations of this number
         IÅ?Z        - any of these start with the number

```

By the way it's quite slow...
> 5 votes

# Answer
# Python 3, 78 bytes

```
f=lambda s,n=1:n*all(f'{n*n}{n**3}'.count(i)>=s.count(i)for i in s)or f(s,n+1)

```

Try it online!
> 3 votes

# Answer
# Python 2, <sup>~~82~~ \\$\cdots\\$~~78~~</sup> 77 bytes

Added 2 bytes to fix an error kindly pointed out by S.S. Anne.
Switched to Python 2 thanks to Grimmy.
Saved a byte thanks to Arnauld!!!

```
f=lambda s,i=1:i*all((`i*i`+`i**3`).count(c)/s.count(c)for c in s)or f(s,i+1)

```

Try it online!
> 2 votes

# Answer
# Jelly, 14 bytes

```
1*2,3DFœ&Ƒ@ʋ1#

```

Try it online!

A monadic link taking a list of digits and returning an integer in a single element list.

```
1          ʋ1# | Start with 1 and find the first integer where the following is true, using the input digit list as the right argument:
 *2,3          | - To the power of 2 and 3
     D         | - Convert to lists of decimal digits
      F        | - Flatten
       œ&Ƒ@    | - Check whether the inout digit list is invariant when intersected with this list of digits

```
> 2 votes

# Answer
# JavaScript (ES7),  ~~77~~  72 bytes

Takes input as a list of digits.

```
f=(a,k)=>([...[k*k]+k**3].sort()+'').match(a.sort().join`.*`)?k:f(a,-~k)

```

Try it online!

### Commented

```
f = (                     // f is a recursive function taking:
  a,                      //   a[] = input
  k                       //   k   = counter, initially undefined
) =>                      //
  ( [...[k * k] + k ** 3] // concatenate k² and k³ and split the resulting string
    .sort()               // sort from lowest to highest digit
    + ''                  // coerce back to a string (this puts commas between the
                          // digits, but they are harmless)
  ).match(                // test whether it matches:
    a.sort()              //   the input list sorted the same way
    .join`.*`             //   joined with .* patterns, so that unused digits and
                          //   commas are ignored
  ) ?                     // if it does:
    k                     //   stop recursion and return k
  :                       // else:
    f(a, -~k)             //   try again with k + 1

```
> 1 votes

# Answer
# Wolfram Language (Mathematica), 89 bytes

```
1//.t_/;ContainsNone[Subsets[Join@@IntegerDigits[t^{2,3}],Length@#],Permutations@#]:>t+1&

```

Try it online!
> 1 votes

# Answer
# , ~~142~~ ~~134~~ 121 bytes

```
i=1;x=table(scan());l=function(t)x>table(strsplit(paste0(t^2,t^3),"")[[1]])[names(x)];while(any(l(i),is.na(l(i))))i=i+1;i

```

Try it online!

# , ~~152~~ ~~146~~ ~~144~~ 130 bytes

(This is only if we have to be wrong like your test cases)

```
i=1;x=scan();x=table(x[x>0]);l=function(t)x>table(strsplit(paste0(t^2,t^3),"")[[1]])[names(x)];while(any(l(i),is.na(l(i))))i=i+1;i

```

Try it online!
> 1 votes

# Answer
# Ruby, 67 bytes

Uses Arnauld's regex. Takes a list of digits. If that isn't allowed, add 6 bytes to change `d.sort` to `d.chars.sort`.

```
->d,i=0{i+=1until"#{i*i}#{i**3}".chars.sort*''=~/#{d.sort*'.*'}/;i}

```

Try it online!
> 0 votes

# Answer
# Burlesque, 28 bytes

```
r0{{2 3}?^im}]mj{j\\z?}j+]fi

```

Try it online!

```
r0       # Range from [0,inf]
{
 {2 3}?^ # {squared, cubed}
 im      # Concatenate
}]m      # Map over each and parse to string
j        # Swap stack
{
 j       # Swap
 \\      # List difference
 z?      # Is null
}
j+]      # Prepend input to make {input j \\ z?}
fi       # Find index s.t.

```
> 0 votes

# Answer
# Perl 5 `-pF`, 70 bytes

```
$p=join'.*',sort@F;1while(join'',sort((++$\**2 .$\**3)=~/./g))!~/$p/}{

```

Try it online!
> 0 votes

# Answer
# Charcoal, 27 bytes

```
≔⁰ηＷΦχ›№θＩκ№⁺ＩＸη³×ηηＩκ≦⊕ηＩη

```

Try it online! Link is to verbose version of code. Explanation:

```
≔⁰η

```

Start at zero.

```
ＷΦχ

```

Repeat until none of the 10 digits satisfies...

```
›№θＩκ№⁺ＩＸη³×ηηＩκ

```

... the count of that digit in the input is greater than the count in the cube and the square...

```
≦⊕η

```

... increment the result.

```
Ｉη

```

Output the result.
> 0 votes

# Answer
# C (gcc), 134 bytes

```
s,c,i,m;f(n){for(c=s=i=m=1;m;c=(s=++i*i)*i){int a[10]={};for(;c;s/=10)a[c%10]++,s&&a[s%10]++,c/=10;for(m=n;m*a[m%10]--;m/=10);}n=--i;}

```

Try it online!

Ungolfed and with better variable names:

```
int square, cube, result, input_copy;

int f(int input)
{
    for(cube = square = result = input_copy = 1;
        input_copy;
        cube = (square = ++result * result) * result)
    {
        int digits[10] = { };
        for(; cube; square /= 10)
        {
            digits[cube % 10]++;

            if(square)
                digits[square % 10]++;

            cube /= 10;
        }
        for(input_copy = input;
            input_copy && digits[input_copy % 10]--;
            input_copy /= 10);
    }
    return result-1;
}

```
> 0 votes

# Answer
# Haskell, 62 bytes

```
import Data.List
f l=[n|n<-[0..],[]==l\\(show=<<[n^2,n^3])]!!0

```

Try it online!

Even with the import, Haskell's list difference function `\\` is quite powerful.
> 0 votes

# Answer
# C (gcc),  ~~93~~  92 bytes

-1 Byte thanks to ceilingcat

```
D;I;C(N){N=N?C(N/10)+(N%10==D):0;}F(N){for(D=I=0;D<10;C(N)>C(I*I)+C(I*I*I)?D=!++I:++D);I=I;}

```

Try it online!

ungolfed:

```
int D;
int I;

int CNT(N)  // count occurrences of digit D in number N
{
    if (N)
        return CNT(N / 10) + (N % 10 == D);
    return 0;
}

int F(N)
{
    for (D = I = 0; D < 10; ++I)
    {
        for (D = 0; D < 10; ++D)
            if (CNT(N) > CNT(I * I) + CNT(I * I * I))
                break;
    }

    return I-1;
}

```
> 0 votes

---
Tags: code-golf, math
---