The array-manipulation tag has no wiki summary.
1
vote
10answers
483 views
Convert JSON string to Key / Value Arrays
Convert JSON (key/value pairs) to a native arrays of keys & values, in your language.
var X = '{"a":"a","b":"b","c":"c","d":"d","e":"e","f":"f9","g":"g2","h":"h1"}';
The value array could be ...
11
votes
12answers
1k views
Javascript: Create a 10x10 array of 1s
Obviously this challenge would be trivial with separate functions and libraries, so they aren't allowed.
Your code must conform to an ECMAscript specification (any spec will do), so no ...
-1
votes
1answer
181 views
Merge working time periods
You have an array of working time period pairs (from, till) received from user input and written according 24-hour clock format convention.
You have to merge these periods if the intersect each ...
5
votes
8answers
533 views
Array Sandwiches
(Adapted from Problem C of the first qualifier of the ACM Programming Contest of 2012/2013)
You have several arrays, named A1, A2, ... , An, each sorted in ascending order. Every item in the array ...
1
vote
12answers
347 views
Create a hash from an array of arrays of key|value pairs
Starting from an array of sub-arrays, each sub-array is a 2 elements key|value pair. Example
input = [["A", 5], ["B", 2], ["A", 12], ["B", -2], ["C", 7]]
Convert this into a hash that has distinct ...
3
votes
5answers
221 views
Operations with Lists
Inspired by this question.
Given a list containing numbers, print:
The sum and product of the numbers in the list
The average and median
The differences between each term in the list (e.x. [1,2,3] ...
0
votes
1answer
156 views
Reduce the amount of loops when finding if an element is stored only once in the array? [closed]
I was amazed to find that there is a way to reduce the times you loop on an array to find if a element is contained once.
One would think that the only way would be to loop through the whole array, ...
2
votes
3answers
307 views
Polynomial extrapolation
Task
Given a list of integers a1, a2, …, ak (k ≥ 2) and a positive integer m, write a function or a complete program that calculates the next m numbers of the list. Assume that ai = P(i) ...