Skip to content

Commit 6dcf0b9

Browse files
committed
Visualizations for Bubble sort added
1 parent 2cacafd commit 6dcf0b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+15433
-6
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ include
66

77
# .pyc files
88
*.pyc
9+
10+
# Buffered files
11+
*~
12+
13+
# Database
14+
db.sqlite3
15+
16+
# Environment files
17+
.env

Code-ologists/README.md

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,48 @@
22
PyDSA Visualization Examples
33

44
**Team**: Code-ologists
5-
<br>
6-
**Team Members**: Kanika Murarka ( _@kanikaa1234 )
7-
Anika Murarka (_@anikamurarka )
8-
<br>
9-
**Algorithm Implemented**: Bubble Sort
10-
5+
6+
**Team Members**: Kanika Murarka [kanikaa1234](https://github.com/kanikaa1234)
7+
Anika Murarka [anikamurarka](https://github.com/anikamurarka)
8+
9+
**Set up environment**
10+
11+
Create and activate virtual environment.
12+
```bash
13+
$ pip install -r requirements.txt
14+
```
15+
16+
**Set-up environment variables**
17+
After activating your virtual environment export the following variables:
18+
19+
```bash
20+
export SECRET_KEY="alskj2mn34m@$%asd#45ASD"
21+
export DATABASE_URL="sqlite:///db.sqlite3"
22+
export DEBUG=True
23+
```
24+
25+
26+
**Algorithm Implemented**:
27+
28+
1. Bubble Sort implementation using `python` and `matplotlib`
29+
30+
```bash
31+
$ cd Code-ologists
32+
$ python bubble_sort.py
33+
```
34+
35+
2. Visualization of Bubble Sort as a web app using `Django` and `JavaScript`
36+
37+
```bash
38+
$ cd Code-ologists
39+
$ ./startserver.sh
40+
```
41+
42+
The server is up and running at [localhost:8000](http://0.0.0.0:8000)
43+
44+
Some features :-
45+
+ Whenever you RELOAD the page, you will see distinct colors.
46+
+ Every iteration is played as an animation.
47+
+ Hover on the bars to see the number that is sorted.
48+
+ You can make different sorting objects and visualize Bubble Sort on it.
49+

Code-ologists/bubble_sort.py

56 Bytes
Binary file not shown.

Code-ologists/pydsa/manage.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydsa.settings")
7+
8+
from django.core.management import execute_from_command_line
9+
10+
execute_from_command_line(sys.argv)

Code-ologists/pydsa/pydsa/__init__.py

Whitespace-only changes.

Code-ologists/pydsa/pydsa/settings.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
"""
2+
Django settings for pydsa project.
3+
4+
Generated by 'django-admin startproject' using Django 1.8.2.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.8/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/1.8/ref/settings/
11+
"""
12+
13+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
14+
import os
15+
import environ
16+
17+
18+
root = environ.Path(__file__) - 3 # three folder back (/a/b/c/ - 3 = /)
19+
env = environ.Env(DEBUG=(bool, False),) # set default values and casting
20+
environ.Env.read_env() # reading .env file
21+
22+
SITE_ROOT = root()
23+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
24+
25+
# Quick-start development settings - unsuitable for production
26+
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
27+
28+
# SECURITY WARNING: keep the secret key used in production secret!
29+
SECRET_KEY = env('SECRET_KEY')
30+
31+
# SECURITY WARNING: don't run with debug turned on in production!
32+
DEBUG = env('DEBUG') # False if not in os.environ
33+
34+
ALLOWED_HOSTS = []
35+
36+
37+
# Application definition
38+
39+
INSTALLED_APPS = (
40+
'django.contrib.admin',
41+
'django.contrib.auth',
42+
'django.contrib.contenttypes',
43+
'django.contrib.sessions',
44+
'django.contrib.messages',
45+
'django.contrib.staticfiles',
46+
'sort',
47+
)
48+
49+
MIDDLEWARE_CLASSES = (
50+
'django.contrib.sessions.middleware.SessionMiddleware',
51+
'django.middleware.common.CommonMiddleware',
52+
'django.middleware.csrf.CsrfViewMiddleware',
53+
'django.contrib.auth.middleware.AuthenticationMiddleware',
54+
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
55+
'django.contrib.messages.middleware.MessageMiddleware',
56+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
57+
'django.middleware.security.SecurityMiddleware',
58+
)
59+
60+
ROOT_URLCONF = 'pydsa.urls'
61+
62+
TEMPLATES = [
63+
{
64+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
65+
'DIRS': [os.path.join(BASE_DIR, 'templates')],
66+
'APP_DIRS': True,
67+
'OPTIONS': {
68+
'context_processors': [
69+
'django.template.context_processors.debug',
70+
'django.template.context_processors.request',
71+
'django.contrib.auth.context_processors.auth',
72+
'django.contrib.messages.context_processors.messages',
73+
],
74+
},
75+
},
76+
]
77+
78+
WSGI_APPLICATION = 'pydsa.wsgi.application'
79+
80+
81+
# Database
82+
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
83+
DATABASES = {
84+
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
85+
'default': env.db(),
86+
'extra': env.db('SQLITE_URL', default='sqlite:////tmp/my-tmp-sqlite.db')
87+
}
88+
89+
90+
# Internationalization
91+
# https://docs.djangoproject.com/en/1.8/topics/i18n/
92+
93+
LANGUAGE_CODE = 'en-us'
94+
95+
TIME_ZONE = 'UTC'
96+
97+
USE_I18N = True
98+
99+
USE_L10N = True
100+
101+
USE_TZ = True
102+
103+
104+
# Static files (CSS, JavaScript, Images)
105+
# https://docs.djangoproject.com/en/1.8/howto/static-files/
106+
107+
STATIC_ROOT = os.path.join(BASE_DIR, 'sort/static')
108+
STATIC_URL = '/static/'
109+
STATICFILES_DIRS = (
110+
os.path.join(BASE_DIR, 'staticfiles'),
111+
)
112+
STATICFILES_FINDERS = (
113+
'django.contrib.staticfiles.finders.FileSystemFinder',
114+
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
115+
)

Code-ologists/pydsa/pydsa/urls.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""pydsa URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/1.8/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Add an import: from blog import urls as blog_urls
14+
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
15+
"""
16+
from django.conf.urls import include, url
17+
from django.contrib import admin
18+
admin.autodiscover()
19+
20+
urlpatterns = [
21+
url(r'^admin/', include(admin.site.urls)),
22+
url(r'^', include('sort.urls')),
23+
]

Code-ologists/pydsa/pydsa/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for pydsa project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydsa.settings")
15+
16+
application = get_wsgi_application()

Code-ologists/pydsa/sort/__init__.py

Whitespace-only changes.

Code-ologists/pydsa/sort/admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.contrib import admin
2+
from sort.models import Sorting
3+
4+
5+
# Register your models here.
6+
class SortAdmin(admin.ModelAdmin):
7+
fields = ['Name', 'List']
8+
list_display = ('Name', 'List')
9+
10+
11+
admin.site.register(Sorting, SortAdmin)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9.5 on 2016-04-14 11:13
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='Sorting',
18+
fields=[
19+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('Name', models.CharField(max_length=50)),
21+
('List', models.CharField(max_length=50)),
22+
],
23+
),
24+
]

Code-ologists/pydsa/sort/migrations/__init__.py

Whitespace-only changes.

Code-ologists/pydsa/sort/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
5+
6+
class Sorting(models.Model):
7+
Name = models.CharField(max_length=50)
8+
List = models.CharField(max_length=50)
9+
10+
def __str__(self):
11+
return self.Name

0 commit comments

Comments
 (0)