8 kyu

To square(root) or not to square(root)

9,083 of 34,561user5036852

Description:

Write a method, that will get an integer array as parameter and will process every number from this array.

Return a new array with processing every number of the input-array like this:

If the number has an integer square root, take this, otherwise square the number.

Example

[4,3,9,7,2,1] -> [2,9,3,49,4,1]

Notes

The input array will always contain only positive numbers, and will never be empty or null.

Mathematics
Arrays
Algorithms

Similar Kata:

Stats:

CreatedOct 6, 2016
PublishedOct 6, 2016
Warriors Trained51847
Total Skips1232
Total Code Submissions91014
Total Times Completed34561
C# Completions1593
Java Completions3982
JavaScript Completions14335
F# Completions120
Python Completions9083
TypeScript Completions631
Ruby Completions830
CoffeeScript Completions25
C Completions1125
Crystal Completions26
Go Completions1347
Swift Completions1282
PHP Completions823
Haskell Completions83
COBOL Completions10
λ Calculus Completions8
Julia Completions22
Rust Completions245
D Completions12
C++ Completions582
Total Stars465
% of votes with a positive feedback rating93% of 4323
Total "Very Satisfied" Votes3777
Total "Somewhat Satisfied" Votes482
Total "Not Satisfied" Votes64
Total Rank Assessments12
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • user5036852 Avatar
  • GiacomoSorbi Avatar
  • SithFire Avatar
  • suic Avatar
  • Chrono79 Avatar
  • naithar Avatar
  • Dentzil Avatar
  • JohanWiltink Avatar
  • leometzger Avatar
  • Voile Avatar
  • hobovsky Avatar
  • MikChan Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • o2001 Avatar
Ad