Coder Social home page Coder Social logo

nwea_technical_challenge's Introduction

nwea_technical_challenge

NWEA Technical Challenge

This should take anywhere between 15mins – 1 hour to complete and would give us a better understanding on their logical thinking.

Exercise

Problem Statement

Given a nested list of integers, implement a function to flatten it. Each element is either an integer, or a list -- whose elements may also be integers or other lists. Provide a github gist link to your code and tests,. You may use whatever language you are comfortable with but do not use any built-in flattening functions that provide this functionality like Ruby’s Array.flatten.

Examples

flattened_list = [5,6,7,8,9] nested_list = [5,6, [7,8], [9]]

if flatten(nested_list) == flattened_list p "Pass" else p "Fail"

Solution

Algorithm

  1. Initialize empty result list
  2. Validate the input is a list a. Else throw validation error
  3. For each element of the list a. validate the element is an integer or list Else throw validation error if the element is an integer add element to the result list else run the list through step 3 of this algorithm
  4. Return result list

Testing

To run test cases

ruby flatten_test.rb

nwea_technical_challenge's People

Contributors

galxy25 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.