5 kyu

Coding 3min : Excel Puzzle #3

Description:

Introduction

In Excel, suppose you set up a column of data, data's type contains: string, integer, decimal, Date. If you set the column width is large enough, they will be displayed in their original way. If the column width is too small, there are different types of data show different results(you can try it in Excel or look at the following).

When data type is string, no matter how much is the width of a column, it will displayed all of the text.

When data type is integer or Date, If the width of the column is smaller than the width of the data, the data will be displayed as some "#".

For example, data a=12345 data b=2016-4-25, if column width=8, data a displayed "12345", data b displayed "########"; if column width=4, data a and data b both displayed "####"

When data type is decimal, If the width of the column is smaller than the width of the data, the data will be round to shorter decimal, until rounded to an integer.

For example, data a=1.2345, if column width=6, displayed "1.2345", if column=5, displayed "1.235", column=4, displayed "1.23",etc..

If the width of the column is smaller than the width of the data, when data rounded to an integer, the data will be displayed as some "#".

For example, data a=9.9, if column width=3, displayed "9.9"; if column=2, displayed "10"; If column=1, displayed "#".

If column width < 1, All data except string will be displayed as an empty string.

Task:

Give you two parameters: excel (an array), like this:[1 ,"2" ,3.3 ,new Date("2004-1-1")] (Although it is a row, but imagine it is a column), and width (the width of column)

Return the actual display effect of excel by an array(all of elements be string format).

Some example to help you understand the rules:


solveIt([12345 ,"12345" , 1.2345, new Date("1234-5-5")],8)
      =["12345","12345" ,"1.2345",         "1234-5-5"]
    
solveIt([12345 ,"12345" , 1.2345, new Date("1234-5-5")],6)
      =["12345","12345" ,"1.2345",         "######"]
solveIt([12345 ,"12345" , 1.2345, new Date("1234-5-5")],5)
      =["12345","12345" ,"1.235",          "#####"]
solveIt([12345 ,"12345" , 1.2345, new Date("1234-5-5")],4)
      =["####", "12345" ,"1.23",           "####"]
          
solveIt([12345 ,"12345" , 1.2345, new Date("1234-5-5")],2)
      =["##",   "12345" ,"1",              "##"]

solveIt([12345 ,"12345" , 1.2345, new Date("1234-5-5")],0.5)
      =["", "12345" ,"",           ""]

Please use the sort function carefully, because the original array should not be changed.

Series:

Puzzles
Games

Stats:

CreatedApr 25, 2016
PublishedApr 25, 2016
Warriors Trained101
Total Skips1
Total Code Submissions350
Total Times Completed29
JavaScript Completions29
Total Stars1
% of votes with a positive feedback rating84% of 16
Total "Very Satisfied" Votes11
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes0
Total Rank Assessments3
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • Voile Avatar
  • ejini战神 Avatar
Ad