7 kyu

Product Array (Array Series #5)

795 of 10,242MrZizoScream

Description:

Introduction and Warm-up (Highly recommended)

Playing With Lists/Arrays Series


Task

Given an array/list [] of integers , Construct a product array Of same size Such That prod[i] is equal to The Product of all the elements of Arr[] except Arr[i].


Notes

  • Array/list size is at least 2 .

  • Array/list's numbers Will be only Positives

  • Repetition of numbers in the array/list could occur.


Input >> Output Examples

productArray ({12,20}) ==>  return {20,12}

Explanation:

  • The first element in prod [] array 20 is the product of all array's elements except the first element

  • The second element 12 is the product of all array's elements except the second element .


productArray ({1,5,2}) ==> return {10,2,5}

Explanation:

  • The first element 10 is the product of all array's elements except the first element 1

  • The second element 2 is the product of all array's elements except the second element 5

  • The Third element 5 is the product of all array's elements except the Third element 2.


productArray ({10,3,5,6,2}) return ==> {180,600,360,300,900}

Explanation:

  • The first element 180 is the product of all array's elements except the first element 10

  • The second element 600 is the product of all array's elements except the second element 3

  • The Third element 360 is the product of all array's elements except the third element 5

  • The Fourth element 300 is the product of all array's elements except the fourth element 6

  • Finally ,The Fifth element 900 is the product of all array's elements except the fifth element 2


A more challenging version of this kata by Firefly2002



Playing with Numbers Series

Playing With Lists/Arrays Series

For More Enjoyable Katas


ALL translations are welcomed

Enjoy Learning !!

Zizou

Fundamentals
Arrays

Stats:

CreatedFeb 23, 2018
PublishedFeb 23, 2018
Warriors Trained18314
Total Skips939
Total Code Submissions24106
Total Times Completed10242
C++ Completions795
Ruby Completions246
JavaScript Completions3745
Crystal Completions23
Python Completions2795
NASM Completions15
Fortran Completions20
C Completions265
Java Completions1094
C# Completions524
Haskell Completions114
PHP Completions286
Dart Completions283
Julia Completions22
CoffeeScript Completions14
TypeScript Completions277
Reason Completions5
Elixir Completions54
Prolog Completions28
Clojure Completions36
Rust Completions217
COBOL Completions15
R Completions33
D Completions11
Total Stars185
% of votes with a positive feedback rating92% of 1319
Total "Very Satisfied" Votes1142
Total "Somewhat Satisfied" Votes145
Total "Not Satisfied" Votes32
Total Rank Assessments9
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • MrZizoScream Avatar
  • GiacomoSorbi Avatar
  • donaldsebleung Avatar
  • Chrono79 Avatar
  • imjasonmiller Avatar
  • JohanWiltink Avatar
  • B1ts Avatar
  • Voile Avatar
  • realfg Avatar
  • rsa Avatar
  • clcraig Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • cliffstamp Avatar
  • stellartux Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Wei-Ting Yang Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad