Skip to content

Instantly share code, notes, and snippets.

nested_list_exercise

Creator: Bryce Egley

Run

python nested_lists.py

Test

python nested_lists_tests.py

NOTE

The flatten fuction in nested_lists.py is the function that satisfies the requirements of the exercise. I wrote tests for the flatten function as well in nested_lists_tests.py. I wrote the other functions in nested_lists.py just to see time performance with large lists and test cases like 0 or 1 sized lists. I developed the flatten list function in jupyter_nootbooks and included my notebook in the repo

import random
import time
# Parameters: input(list)
# Return: flatten_array(list)
# Description: flatten a nested list of integers
# Creator: Bryce Egley
def flatten(input):
flatten_array = []
for i in input:
@bdegley4789
bdegley4789 / nested_lists_tests.py
Created September 12, 2019 06:00
Tests for nested_lists
import random
import time
import unittest
import nested_lists
class nested_lists_tests(unittest.TestCase):
# Description: Test flatten list if the size of the list is 0
# Creator: Bryce Egley
def test_flatten_list_size_0(self):
@bdegley4789
bdegley4789 / exampleD3.html
Created November 5, 2018 17:28
exampleD3
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<script type = "text/javascript">
// Set the dimensions and margins of the graph
let margin = {
top: 30,
right: 225,
[
{
"values":[
{
"ele":3,
"type":"c1"
},
{
"ele":12,
"type":"c2"
@bdegley4789
bdegley4789 / file1.txt
Created July 7, 2017 11:24
edited description for this gist
Edited String file contents
@bdegley4789
bdegley4789 / file1.txt
Last active July 8, 2017 01:13
check edited description for this gist
Edited String file contents
@bdegley4789
bdegley4789 / file1.txt
Created July 7, 2017 08:31
the description for this gist
String file contents
@bdegley4789
bdegley4789 / file1.txt
Created July 7, 2017 08:27
the description for this gist
String file contents
@bdegley4789
bdegley4789 / file1.txt
Created July 7, 2017 08:26
the description for this gist
String file contents