Tamsayıları kare sayı toplamıyla döndür


31

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]

11
Güzel ilk meydan okuma ve siteye hoş geldiniz!
DJMcMayhem

Gelecekteki zorluklar için sanal alanı not edin . Onları ana siteye koymadan önce meydan okuduğumuz bir yer bu yüzden hey gözden geçirilebilir ve içerikleri sorgulandı, böylece (umarız) ana bilgisayardan daha iyi bir şekilde haberdar olun. Bu kötü bir soru olsa da değil (aslında oldukça hoşuma gidiyor)
Mavi

@muddyfish, bu konuyu okudum ve göndermeyi düşündüm ama yapmamaya karar verdim, çünkü kendimi çok özlüyorum, burada çok özleyebileceğim / yanlış şeyler yapabileceğim bir şey yoktu :) Tabii ki bir şüphe olsa bile Özledim oraya gönderirim.
SEJPM

12
Sanal alandan kaçınmak tamamen iyi olsa da, oraya göndermiş olsaydınız, yalnızca bireysel bir tamsayı test etme konusunda zorluk çekmenizi öneririm. İşin ilginç yanı, test, bu görevin bir filtre ile kaydırılması özellikle ilginç değil. Yaptığı tek şey, türler gibi dizileri olmayan ezoterik dillerde mücadeleyi büyük ölçüde zorlaştırıyor. Bu biraz sert gelebilir, ama bu hala mükemmel bir ilk yazıdır. Sadece kum havuzunun orada olduğunu söylüyorum çünkü hiçbir şeyi kaçırmadığınızdan emin değilsiniz, bir şeyi kaçırdınız.
FryAmTheEggman 10:16

1
@FryAmTheEggman Mathematica için söyleyebilirim ki, bu işlevi daha iyi kılabilir hale getirmek işleri önemsiz bir şekilde karmaşıklaştırıyor, bu yüzden tam olarak sıkıcı değil.
LLIAMnYP

Yanıtlar:


10

Pyke, 6 bayt

#s,DBq

Burada dene!

#      - Filter list on truthiness:
 s     -    digital_root(^)
  ,    -   sqrt(^)
    Bq -  int(^) == ^

5

Mathematica, 39 36 bayt

Anonim bir işlev:

Select[AtomQ@√Tr@IntegerDigits@#&]

LLIAMNYP byte kaydetti. Teşekkür ederim!

Martin Ender IntegerQile değiştirerek üç tasarruf daha AtomQ. Zeki! (Bunun sonucu kesin olacaktır, bu nedenle Sqrt[5]argümanı kare değilse bir bileşik ifade döndürür .)


Bir bayt tarafından kurtarılmak için ...Digits@#&yerine...Digits[#]&
LLlAMnYP

4

Jöle, 8 7 bayt

@ Sp3000 sayesinde 1 bayt .

DSƲðÐf

Test odası.

açıklama

DSƲðÐf  Main monadic chain. Argument: z

     Ðf  Filter for truthiness:
D            convert to base 10
 S           sum
  Ʋ         is perfect square

4

Brachylog v2, 8 bayt

{ẹ+√ℤ&}ˢ

Çevrimiçi deneyin!

açıklama

{ẹ+√ℤ&}ˢ
{     }ˢ  Map the following operation over {the input}, discarding elements that error:
 ẹ         Split into a list of digits
  +        Sum that list
   √       Take its square root
    ℤ      Assert that the result is an integer
     &     Return to the original value

&Aracının elemanları çıkış giriş listesinde aynıdır, ama bloğun giriş kare sayı değilse biz atılan kare olmayan basamaklı toplamları elemanları ile giriş listesine böylece, üzerinden hata olacaktır.

İlk başta burada kayan nokta yanlışlığı sorunu gibi görünebileceğini unutmayın (bazı çok büyük kare olmayan tam sayıların yuvarlama nedeniyle tamsayı kare kökleri vardır). Bununla birlikte, Brachylog bignum aritmetiğini destekler ve aslında bu davranışı uygulamasına dahil eder : mükemmel bir kare olan bir sayı, kare kökünün tamsayı olarak rapor edilmesini sağlarken, mükemmel bir kare olmayan bir sayı (ancak karekök integraldir) karekökünün integral değeri olan bir şamandıra olarak bildirilmesi gerekir. Uygun şekilde, yalnızca eski türden bir geri dönüş değerine izin verir, ikincisi için bir iddia hatası verir.


3

Pyth, 10 bayt

fsI@sjT;2Q

Test odası.

açıklama

fsI@sjT;2Q

f        Q  Filter for the following in Q(input):
     jT;        convert to base 10
    s           sum
   @    2       square-root
 sI             is integer (is invariant under flooring)

3

CJam, 14 bayt

Bir bayt tasarrufu için @FryAmTheEggman teşekkürler!

{{Ab:+mq_i=},}

Çevrimiçi deneyin!

Bu, yığında giriş listesini bekleyen ve filtrelenmiş listeyi üzerinde bırakan adsız bir bloktur.

açıklama

{e # yeni bir blok başlat
 Ab # # üsse dönüştürmek 10 -> sayıyı rakamlara böler
 : + e # toplam inci basamak
 mq e # karekök olsun
 _ e # sonucu çoğalt
 yani # tamsayıya dönüştür
 = e # Dönüştürülen karekök ile orjinalinin eşit olup olmadığını kontrol edin
e # end bloğu
, e # giriş listesini filtrele

3

Haskell - 70 60 59 bayt

f=filter(\x->elem(sum.map(read.pure).show$x)$map(^2)[0..x])

Kullanımı:

> f [0..100]
[0,1,4,9,10,13,18,22,27,31,36,40,45,54,63,72,79,81,88,90,97,100]

Oldukça açık; basamakların toplamını hesaplar ve taban olup olmadığını kontrol eder (sqrt (y)) ^ 2 == y

Düzenleme: C. Quilley'den kareler listesini kontrol etme fikrini çaldı


2
İlginç yaklaşım f=Bu cevap için gerekli olduğundan emin değilim .
Michael Klein

3

05AB1E, 19 10 bayt

vySOtDï->—

açıklama

vy                     # for each int in list
  SO                   # digit sum
    tDï-               # difference between sqrt() and int(sqrt())
        >              # increase by 1 giving 1 (true) when equal
         —             # print current int in list if truthy

Çevrimiçi deneyin

Düzenleme: @Adnan sayesinde 9 bayt kaydedildi


Her biri için rakamların toplamını almak için, vySOkare olup olmadığını anında kontrol edebilirsiniz . Ben 5'e bu var: tDï->. Aynı zamanda ( ) ydeğerine eşit olan basılan özel bir yerleşik de vardır . Yani, bu olurdu . 1vySOtDï->—
Adnan

@Adnan: S'yi unuttuğuma inanamıyorum bile bakmadım - görev bir liste olarak çıktığını söyledi, ancak diğer cevapların da aynı şeyi yaptığını görüyorum, bu yüzden tamam olduğunu sanıyorum.
Emigna

Evet, yeni satırlarla ayrılan öğeler, varsayılan olarak kabul edilmez, çünkü zorluk açıkça belirtilmediği sürece.
Adnan

3

R , 57 55 bayt

Vektörde kullanın Filter. 32 bit tamsayı varsayar, böylece 10 basamak maks.

Köşe durumlarda: NULLboş vektör ve numeric(0)geçerli sayıları olmayan bir vektör için döndürür . Bu ikisinin de uzunluğu sıfırdır, bu nedenle kabul edilebilir olmalıdır.

-2, @Giuseppe'e teşekkürler

Filter(function(n)!sum(n%/%10^(0:10)%%10)^.5%%1,scan())

Çevrimiçi deneyin!


3

PowerShell , 64 54 bayt

$args|?{!([math]::Sqrt(([char[]]"$_"-join'+'|iex))%1)}

Çevrimiçi deneyin!

Mazzy sayesinde -10 bayt

Girdiyi, PowerShell'de diziye işlenen komut satırı argümanları (aşağıdaki örneklere bakın) olarak alır $args. ?Çıktımızı seçmek için bunu bir diğer ada Where-Object( boruya benzer işlevler filter) yönlendiriyoruz. Seçimimiz [math]::Sqrt(), sayının rakam toplamının .NET çağrısına dayanarak bir tamsayı olduğunu gösterir !(...%1). Tamsayılar, 0 olduğunda, noted olduğunda Truetamsayı olmayan kökler olurken olur False.

Başka bir yerde belirtildiği gibi , boş bir diziyi "geri döndürmek" anlamsızdır, $nullkapsamı bıraktıktan hemen sonra dönüştürülür , bu nedenle boş bir girişin çıktısı hiçbir şey değildir.

Örnekler

PS C:\Tools\Scripts\golfing> .\return-integers-with-square-digit-sums.ps1 1 4 9 16 25 1111
1
4
9
1111

PS C:\Tools\Scripts\golfing> .\return-integers-with-square-digit-sums.ps1 1431 2 0 22 999999999
1431
0
22
999999999

PS C:\Tools\Scripts\golfing> .\return-integers-with-square-digit-sums.ps1 22228 4 113125 22345
22228
4
22345

PS C:\Tools\Scripts\golfing> .\return-integers-with-square-digit-sums.ps1 

PS C:\Tools\Scripts\golfing> .\return-integers-with-square-digit-sums.ps1 1337 4444
4444

1
$n%1sadece int olup olmadığını kontrol eder$args|?{!([math]::Sqrt(([char[]]"$_"-join'+'|iex))%1)}
mazzy

2

Python 2,76 bayt

lambda l:filter(lambda n:eval(("sum(map(int,`n`))**.5==int("*2)[:-6]+")"),l)

Burada dene!

Bazı değerlendirmede kare sayının kötüye kullanılması, istirahat oldukça belirsizdir.
İçin eval deyimi değerlendirir sum(map(int,n ))**.5==int(sum(map(int,n))**.5)


2

Oracle SQL 11.2, 213 bayt

WITH v AS(SELECT a,SQRT(XMLQUERY(REGEXP_REPLACE(a,'(\d)','+\1')RETURNING CONTENT).GETNUMBERVAL())s FROM(SELECT TRIM(COLUMN_VALUE)a FROM XMLTABLE(('"'||REPLACE(:1,',','","')||'"'))))SELECT a FROM v WHERE s=CEIL(s);

Un-golfed

WITH v AS
(  
  SELECT a,SQRT(XMLQUERY( 
                   REGEXP_REPLACE(a,'(\d)','+\1')  -- Add a + in front of each digit 
                   RETURNING CONTENT
               ).GETNUMBERVAL())s                  -- Evaluate the expression generated by the added +
  FROM 
  (SELECT TRIM(COLUMN_VALUE)a FROM XMLTABLE(('"'||REPLACE(:1,',','","')||'"'))) -- Split string on ','
)
SELECT a FROM v WHERE s=CEIL(s) -- Is a square if square has no decimal part

2

Brachylog , 26 bayt

:1f.
e.(:ef+~^[X:2]h>0;.0)

Örnek:

?- run_from_file('code.brachylog',[1431:2:0:22:999999999],Z).
Z = [1431, 0, 22, 999999999]

açıklama

Bu, bir şeylerin çok iyi çalıştığı bir durumdur ... ~^[X:2]kısım hem pozitif hem de negatif için doğrudur X, bu yüzden yinelemeleri önlemek için bunu belirtmek zorundayım X > 0.

;.0Bölüm (numaralandırmak tamsayı 0 çalışmaz) nedeni teknik bir hata burada.

  • Ana tahmin

    :1f.                Find all values of Input which satisfy predicate 1
    
  • 1 tahmin et

    e.                  Unify output with an element of the input
    (
      :ef               Find all elements of Output (i.e. all digits)
         +              Sum the digits
          ~^[X:2]       True if that sum is the result of X², whatever X is
                 h>0    Impose that X > 0
    ;                   OR
      .0                True if Output is 0
    )
    

2

Python 2, 53 bayt

lambda x:[n for n in x if sum(map(int,`n`))**.5%1==0]

İdeone üzerinde test et .


1
For f([1111111111111111]), it looks like repr(n) contains an 'L' and int('L') throws a ValueError. I feel like you need str(n) here?
Lynn

2
Right, it won't work for long ints. I don't think that's different from a solution in a language with fixed-width integers though.
Dennis

2

J, 33 27 bytes

6 bytes thanks to @miles.

#~[:(=<.)@%:+/"1@(10&#.inv)

In online interpreters, inv is not instored. Change that to ^:_1 instead.

Usage

>> f =: #~[:(=<.)@%:+/"1@(10&#.inv)
>> f 1 4 9 16 25 1111 0
<< 1 4 9 1111 0

Where >> is STDIN and << is STDOUT.

Slightly ungolfed

to_base_10 =: 10&#.^:_1
sum        =: +/"1
sqrt       =: %:
floor      =: <.
itself     =: ]
equals     =: =
of         =: @
is_integer =: equals floor
test       =: is_integer of sqrt
copies_of  =: #
f =: copies_of~ [: test (sum of to_base_10)

Previous 33-byte version

(]=*:@<.@%:)@(+/"1@(10#.^:_1]))#]

Usage

>> f =: (]=*:@<.@%:)@(+/"1@(10#.^:_1]))#]
>> f 1 4 9 16 25 1111 0
<< 1 4 9 1111 0

Where >> is STDIN and << is STDOUT.

Slightly ungolfed

to_base_10 =: 10#.^:_1]
sum        =: +/"1
sqrt       =: %:
floor      =: <.
square     =: *:
itself     =: ]
equals     =: =
of         =: @
test       =: itself equals square of floor of sqrt
copies_of  =: #
f =: (test of (sum of to_base_10)) copies_of itself

1
You can use f&.g to apply g, then f, and then the inverse of g to shorten *:@<.@%: to <.&.%: saving 2 bytes. You can rearrange it and use only floor to get #~[:(=<.)@%:+/"1@(10&#.inv) for 27 bytes where inv is ^:_1, and is already defined.
miles

2

Javascript 66 bytes

a=>a.filter(b=>(e=Math.sqrt((b+"").split``.reduce((c,d)=>c-+-d)))==(e|0))

Thanks for SergioFC for saving 7 bytes


Can't you just use c+d instead of c-+-d? In addition you can use n%1==0 to test if the result is an int, so maybe you can save some bytes using b=>!(Math.sqrt((b+"").split``.reduce((c,d)=>c-+-d))%1) to filter
sergioFC

@sergioFC I can't change -+- to +, because they're strings
Bálint

2

Perl 5, 42 bytes

41, plus 1 for -pe instead of -e

my$s;map$s+=$_,/./g;$_ x=sqrt$s==~~sqrt$s

Explanation:

  • -p gets each input integer on a new line and assigns $_ to that string.
  • my$s initializes the variable $s to nothing, anew for each input integer.
  • map$s+=$_,/./g grabs each numeric character and numerically adds it to $s. (The newline becomes 0 when numified.)
  • sqrt$s==~~sqrt$s tests whether $s has a nonintegral square root, and $_ x= makes $_ into itself or the empty string depending on that test.
  • -p prints $_

Thanks to Brad Gilbert b2gills for saving three bytes.

Also 41 plus 1:

my$s;s/./$s+=$&/ger;$_ x=sqrt$s==~~sqrt$s
  • s/./$s+=$&/ger adds each numeric character to $s (and the newline is 0 as above)

2

JavaScript (Node.js), 48 bytes

a=>a.filter(b=>eval([...b+""].join`+`)**.5%1==0)

Try it online!

Explanation

a =>                                  // lambda function taking one argument
    a.filter(                         // filter the list
        eval(                         // begin eval
            [...b+""]                 // convert number to array of digits 
                .join`+`              // join them with + sign
            )                         // close eval. we achieved sum of all digits of number
        **.5                          // square root of number
        %1==0                         // check for perfect square
    )                                 // end filter and return value

1

MATL, 16 14 13 bytes

"@tV!UsX^1\?x

Try it Online!

Explanation

        % Implicitly grab input
"       % For each number in the input
  @t    % Get this element and duplicate
  V     % Convert to it's string representation
  !     % Transpose the string so each digit is on it's own row
  U     % Convert each row to a number (separates the digits)
  s     % Compute the sum of the digits
  X^    % Compute the square root
  1\    % mod with 1 to determine if the square root is an integer
  ?x    % If there is a remainder, then remove this element from the stack
        % Implicitly display the stack contents

1

Julia - 38 bytes

!X=filter(i->√sum(digits(i))%1==0,X)

It's pretty easy to see what this does. digits converts a number into a list of its digits, sum thus calculates the digit-sum, will then produce a whole number if the number is a square, otherwise there will be a fractional part. %1 will return only the fractional part, and if it's zero (==0), filter will keep it on the list, otherwise it gets filtered out.

Used as ![22228,4,113125,22345]


1

Jolf, 8 bytes

Try it here!

ψxd!iUuH

Explanation

ψxd!iUuH
ψxd       filter the input according to the input
      uH  digit sum of H (element)
     U    sqrt of
   !i     is an integer?

1

MATLAB, 52 43 42 bytes

@(x)x(~mod(sum(dec2base(x,10)'-48).^.5,1))

Creates an anonymous function named ans that can be called with an array as input: ans([22228,4,113125,22345]).

Online Demo. The online demo is in Octave which doesn't work for the empty input, but MATLAB does.

Explanation

We convert each element in the input array to base 10 which will yield a 2D character array where each row contains the digits of a number in the array. To convert these characters to numbers, we subtract 48 (ASCII for '0'). We then sum across the rows, take the square root, and determine whether each value is a perfect square ~mod 1. We then use this boolean to filter the input array.


1

Clojure, 110 bytes

(fn[t](filter(fn[x](let[a(reduce +(*(count(str x))-48)(map int(str x)))](some #(=(* % %)a)(range(inc a)))))t))

Calculates the sum of number digits and then filters out those for which there doesn't exist a number which squared is equal to the sum.

You can see the result here – https://ideone.com/ciKOje


1

Perl 6,  38  35 bytes

{.grep: {($/=sqrt [+] .comb)==$/.Int}}
{.grep: {($/=.comb.sum.sqrt)==$/.Int}}
{.grep: {($/=sqrt [+] .comb)==^$/}}
{.grep: {($/=.comb.sum.sqrt)==^$/}}

Test:

#! /usr/bin/env perl6

use v6.c;
use Test;

my @tests = (
  [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] => [],
);

plan +@tests;

my &sq-digit-sum = {.grep: {($/=sqrt [+] .comb)==^$/}}

for @tests -> $_ ( :key($input), :value($expected) ) {
  is sq-digit-sum($input), $expected, .gist
}
1..5
ok 1 - [1 4 9 16 25 1111] => [1 4 9 1111]
ok 2 - [1431 2 0 22 999999999] => [1431 0 22 999999999]
ok 3 - [22228 4 113125 22345] => [22228 4 22345]
ok 4 - [] => []
ok 5 - [421337 99 123456789 1133557799] => []

1

C, 143 141 bytes

  • saved 2 bytes, @user6188402
i;q(char*n){double m=0;while(*n)m+=*n++-48;m=sqrt(m)-(int)sqrt(m);return !m;}s(n,s)char**n;{i=-1;while(++i<s)if(q(n[i]))printf("%s\n",n[i]);}

Ungolfed try online

int q(char*n)
{
    double m=0;

    while(*n) // sum digits
        m+=*n++-48;

    // get the decimal part of its square root
    m=sqrt(m)-(int)sqrt(m);

    // true if decimal part is zero
    return !m;
}

// input is text, can be a file
void s(char**n, int s)
{
    int i=-1;

    while(++i<s) // for each number in input
        if(q(n[i])) // if is square
            printf("%s\n",n[i]); // output is terminal
}

1

Retina, 69

Because testing for perfect squares in retina. This can be modified for generalised integer square root calculation.

.+
$&a$&
+`\b\d
$*b 


\bb
$&:
+`(\bb+):(bb\1)
$1 $2:
G`(:a|0$)
.*a

Input is a newline-separated list.

Try it online.

  • Stage 1 - repeat the number on each line, and separate with a
  • Stage 2 - convert each digit before the a to unary expressed as bs, separated with spaces
  • Stage 3 - remove spaces - each unary now represents the digit sum
  • Stage 4 and 5 - Use the fact that perfect squares may be expressed 1 + 3 + 5 + 7 + ... . Split each unary up accordingly
  • Stage 6 - grep filter just the ones that exactly split into the above form
  • Stage 7 - discard all but the original number

I had a few ideas how to improve this, but ended up rewriting most of it. Nevertheless, this is still exactly your idea: duplicate input, expand digits in first half, filter squares in the form of sums of odd numbers, discard first half of remaining lines. The way I golfed the steps is via %-configuration, \G and forward references. Feel free to take it: retina.tryitonline.net/… :)
Martin Ender

1

Python, 50 bytes

filter(lambda x:sum(map(int,str(x)))**0.5%1==0,in)

If n is input list of numbers


1
Hello, and welcome to the site! Since this is a code-golf competition, e.g. who can write the shortest code, we require all submissions to be at at least somewhat golfed. We have a list of python golfing tips here. Just off the top of my head, one obvious improvement you could do is to remove all the extra whitespace, and rename your variables to one letter each. You could also take input as function arguments or STDIN instead of command line arguments.
DJMcMayhem

You should also specify the language and the byte count, which could be counted, for example, there.
nicael

1
Welcome to PPCG! In addition to what the others said, please note that all solutions must be either full programs or callable functions. So far, all of your answers have been snippets which assume that the input is stored in some variable and just evaluate to the result, which unfortunately makes them invalid. For acceptable I/O methods, see this meta post.
Martin Ender


1

K (oK), 19 17 13 bytes

Solution:

(~1!%+/.:'$)#

Try it online!

Explanation:

(~1!%+/.:'$)# / the solution
(          )# / apply function to list
          $   / convert to string
       .:'    / value (.:) each (')
     +/       / sum
    %         / square-root
  1!          / modulo 1
 ~            / not

Notes:

  • -2 bytes with smarter way of identifying squares
  • -4 bytes thanks to ngn

1
you know about filter (func#list)?
ngn

I did not, very nice!
streetster

1

MathGolf, 5 4 bytes

gÅΣ°

Try it online!

Explanation:

gÅ    Filter by the next two instructions
  Σ   The digit sum
   °  Is a perfect square?

MathGolf is still in development, so I assume implicit input is coming soon to shave off that first byte. Yay!


Congratulations on the first MathGolf answer not by me! I've discussed implicit input with Emigna, and he gave me some great ideas. It's coming, hopefully soon.
maxb
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.