There are 87 square numbers with all the digits 0 to 9 exactly once.(1026753849, 1042385796, 1098524736, 1237069584, 1248703569, 1278563049, 1285437609, 1382054976, 1436789025, 1503267984, 1532487609, 1547320896, 1643897025, 1827049536, 1927385604, 1937408256, 2076351489, 2081549376, 2170348569, 2386517904, 2431870596, 2435718609, 2571098436, 2913408576, 3015986724, 3074258916, 3082914576, 3089247561, 3094251876, 3195867024, 3285697041, 3412078569, 3416987025, 3428570916, 3528716409, 3719048256, 3791480625, 3827401956, 3928657041, 3964087521, 3975428601, 3985270641, 4307821956, 4308215769, 4369871025, 4392508176, 4580176329, 4728350169, 4730825961, 4832057169, 5102673489, 5273809641, 5739426081, 5783146209, 5803697124, 5982403716, 6095237184, 6154873209, 6457890321, 6471398025, 6597013284, 6714983025, 7042398561, 7165283904, 7285134609, 7351862049, 7362154809, 7408561329, 7680594321, 7854036129, 7935068241, 7946831025, 7984316025, 8014367529, 8125940736, 8127563409, 8135679204, 8326197504, 8391476025, 8503421796, 8967143025, 9054283716, 9351276804, 9560732841, 9614783025, 9761835204, and 9814072356)Step-by-step solutionThe square numbers we seek must have exactly ten digits, so they are between 1000000000 and 9999999999 (in scientific notation, 1e10 and 1e11). This means their square roots must be between 31623 and 100000. So we have approximately 68400 numbers to test. This a simple task for a computer like a Raspberry Pi.The square numbers with all digits can be found with just one line of Python:`[i**2 for i in range(31623, 100000) if len(set(list(str(i**2)))) == 10]`This is achieved by combining together several different language elements. (In general, it is not a good idea to write complicated one-line programs, especially if you are new to programming. It can make it difficult for people to work out what the program does. Also, if you make a typo, it is difficult to spot where it has been made.)What does this code do?  It forms a list of squares made from the numbers in the range 31623 and 100000, including only those which satisfy a key condition: that the square has all ten digits once only. But how is this condition implemented? Let's consider the steps in the one-line program, using an (small) example number` i=66 `to illustrate what's going on:First, the square number (`i**2`) is converted into a string, with the `str` function. So (e.g.) `56**2 = 3136` is converted to a string `'3136'`.The string is converted into a list of digits, using the `list` function. So `'3136'` becomes `['3','1','3','6']`The list is converted into a set, using `set`.  This has the effect of removing the duplicate elements. So `['3','1','3','6']` is converted to `{'3','1','6'}`.The function `len` tells us the number of elements in the set, i.e., 3 in this example.Finally, we test the length of the set (i.e. the number of distinct digits), to see whether it is equal to 10. If so, it is included in the list, if not it is excluded.
{"ft_lang_label":"__label__en","ft_lang_prob":0.71859664,"math_prob":0.9380363,"size":2298,"snap":"2023-40-2023-50","text_gpt3_token_len":822,"char_repetition_ratio":0.08326068,"word_repetition_ratio":0.0,"special_character_ratio":0.60530895,"punctuation_ratio":0.25821596,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9776391,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-29T07:43:33Z\",\"WARC-Record-ID\":\"<urn:uuid:eb52d34c-bb23-4948-b06b-0763f413ddc8>\",\"Content-Length\":\"21663\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4a50c318-9928-4b04-998e-309b567eacea>\",\"WARC-Concurrent-To\":\"<urn:uuid:fc668b54-b667-461f-ba12-678b1656632f>\",\"WARC-IP-Address\":\"172.253.115.121\",\"WARC-Target-URI\":\"http://pi3.sites.sheffield.ac.uk/mini-challenges/chal2/ans\",\"WARC-Payload-Digest\":\"sha1:KZRNFU5FTELF7LLXMMTSWGN24Y32JEYJ\",\"WARC-Block-Digest\":\"sha1:XZ22RIMOH7ASHNX4CHX7QET663ATLN57\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510498.88_warc_CC-MAIN-20230929054611-20230929084611-00690.warc.gz\"}"}