Giriş ve Kredi
Bir numaranın 11 ya da 3'e bölünebilir olup olmadığını test etmek için harika kurallarımızı hepimiz biliyoruz ve seviyoruz, bu rakamın basamağı üzerinde zekice bir miktar. Şimdi bu zorluk, rakamların toplamını hesaplamanızı isteyerek ve ardından sonucun mükemmel bir tamsayı karesi olup olmadığını kontrol ederek, ne işlemlerin genellikle çok kısa sürede yapılamayacağını kontrol ederek bunu yeni bir düzeye çıkarır. Bu özelliğin bir sayıya bakarken de görülmesi çok zor olduğu için, bunun tüm sayı listeleri için yapılmasını istiyoruz, böylece insan işini kurtarabiliriz. Öyleyse bu şimdi senin meydanın!
Bu üniversitedeki fonksiyonel programlama kursunda bir ödevdi. Bu ödev şimdi kapandı ve sınıfta tartışıldı ve profesörümün burada yayınlama iznine sahibim (açıkça sordum).
Şartname
Giriş
Girişiniz, herhangi bir standart G / Ç biçiminde, negatif olmayan tam sayıların bir listesidir.
Dilin gerektirdiği şekilde liste biçimini seçebilirsiniz
Çıktı
Çıktı, herhangi bir standart G / Ç formatında tam sayıların bir listesidir.
Ne yapalım?
Sayıların toplamının bir kare olmadığı bir girdi listesinden her tam sayıyı filtreleyin (bir tam sayı).
Eğer alırsanız öğelerin sırası, örneğin değiştirilemez [1,5,9]
sen olabilir değil dönmek[9,1]
Potansiyel köşe kılıfları
0 olan negatif olmayan bir tamsayı ve böylece geçerli bir giriş ve 0 bir tamsayı kare olarak 0 sayımları örneğin, aynı zamanda geçerli bir tamsayı köküdür.
Boş liste de geçerli bir girdi ve çıktıdır.
Kim kazanır?
Bu kod-golf yani bayt cinsinden en kısa cevap kazanır!
Standart kurallar elbette geçerlidir.
Test Kılıfları
[1,4,9,16,25,1111] -> [1,4,9,1111]
[1431,2,0,22,999999999] -> [1431,0,22,999999999]
[22228,4,113125,22345] -> [22228,4,22345]
[] -> []
[421337,99,123456789,1133557799] -> []
Adım Adım Örnek
Example input: [1337,4444]
Handling first number:
Sum of the digits of 1337: 1+3+3+7=14
14 is not an integer square, thus will be dropped!
Handling second number:
Sum of the digits of 4444: 4+4+4+4=16
16 is an integer square because 4*4=16, can get into the output list!
Example output: [4444]