Skip to content

Commit

Permalink
Merge pull request #11 from AmodhShenoy/master
Browse files Browse the repository at this point in the history
Cryptober code
  • Loading branch information
AmodhShenoy authored Oct 11, 2019
2 parents 35d4cbd + b7b03fe commit a52241d
Show file tree
Hide file tree
Showing 31 changed files with 1,371 additions and 7 deletions.
14 changes: 14 additions & 0 deletions blogs/migrations/0049_merge_20191010_1911.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2.6 on 2019-10-10 19:11

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blogs', '0048_auto_20190905_0552'),
('blogs', '0048_auto_20190905_1751'),
]

operations = [
]
19 changes: 19 additions & 0 deletions blogs/migrations/0050_auto_20191010_1914.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.6 on 2019-10-10 19:14

import datetime
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blogs', '0049_merge_20191010_1911'),
]

operations = [
migrations.AlterField(
model_name='bloghits',
name='created',
field=models.DateTimeField(default=datetime.datetime(2019, 10, 10, 19, 14, 12, 3807)),
),
]
19 changes: 19 additions & 0 deletions blogs/migrations/0051_auto_20191010_1939.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.6 on 2019-10-10 19:39

import datetime
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blogs', '0050_auto_20191010_1914'),
]

operations = [
migrations.AlterField(
model_name='bloghits',
name='created',
field=models.DateTimeField(default=datetime.datetime(2019, 10, 10, 19, 39, 15, 794434)),
),
]
32 changes: 32 additions & 0 deletions cryptober/Functions/LIS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Dynamic programming Python implementation of LIS problem

# lis returns length of the longest increasing subsequence
# in arr of size n
def lis(arr):
n = len(arr)

# Declare the list (array) for LIS and initialize LIS
# values for all indexes
lis = [1]*n

# Compute optimized LIS values in bottom up manner
for i in range (1 , n):
for j in range(0 , i):
if arr[i] > arr[j] and lis[i]< lis[j] + 1 :
lis[i] = lis[j]+1

# Initialize maximum to 0 to get the maximum of all
# LIS
maximum = 0

# Pick maximum of all LIS values
for i in range(n):
maximum = max(maximum , lis[i])

return maximum
# end of lis function

# Driver program to test above function
arr =[3, 10, 2, 1, 20]
print(lis(arr))
# This code is contributed by Nikhil Kumar Singh
16 changes: 16 additions & 0 deletions cryptober/Functions/cube_difference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#Logic: This program prints the diffrence of cube
#of number having maximum abslute value and minimum absolute value.

def solve(a):
minv=1000000000
maxv=0
for i in a:
minv=min(minv,abs(i))
maxv=max(maxv,abs(i))

# print(maxv,minv)
return (maxv*maxv*maxv-minv*minv*minv)


a = [1,2,-1,2,-1]
print(solve(a))
18 changes: 18 additions & 0 deletions cryptober/Functions/duplicate_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#Logic: Print no. of charaters that are repeated passed string

def printDups(string):
count = [0] * 256
for i in string:
count[ord(i)] += 1
k = 0
cnt=0;
for i in count:
if int(i) > 1:
cnt=cnt+1;
return cnt;



# Driver program to test the above function
string = ['a','a']
print(printDups(string))
45 changes: 45 additions & 0 deletions cryptober/Functions/edit_distance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# A Dynamic Programming based Python program for edit
# distance problem :
# minimum number of edits (operations) required to convert ‘str1’ into ‘str2’.
#allowed operations:
#Insert
#Remove
#Replace
def editDistDP(str1, str2, m, n):
# Create a table to store results of subproblems
dp = [[0 for x in range(n+1)] for x in range(m+1)]

# Fill d[][] in bottom up manner
for i in range(m+1):
for j in range(n+1):

# If first string is empty, only option is to
# insert all characters of second string
if i == 0:
dp[i][j] = j # Min. operations = j

# If second string is empty, only option is to
# remove all characters of second string
elif j == 0:
dp[i][j] = i # minimumn. operations = i

# If last characters are same, ignore last char
# and recur for remaining string
elif str1[i-1] == str2[j-1]:
dp[i][j] = dp[i-1][j-1]

# If last character are different, consider all
# possibilities and find minimum
else:
dp[i][j] = 1 + min(dp[i][j-1], # Insert
dp[i-1][j], # Remove
dp[i-1][j-1]) # Replace

return dp[m][n]

# Driver program
str1 = "iste"
str2 = "nitk"

print(editDistDP(str1, str2, len(str1), len(str2)))
# This code is contributed by Bhavya Jain
16 changes: 16 additions & 0 deletions cryptober/Functions/sum_difference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# LOGIC:Python program to print diffrence between sum of even array indices and
#sum of odd array indices

def solve(a):
sumodd=0
sumeven=0;
for i in range(0,len(a)):
if(i%2==0):
sumeven+=a[i];
else:
sumodd+=a[i];

return sumeven-sumodd

a = [200,100,1000,150,250]
print(solve(a))
Empty file added cryptober/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions cryptober/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.contrib import admin
from .models import Response
# Register your models here.
admin.register(Response)
5 changes: 5 additions & 0 deletions cryptober/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CryptoberConfig(AppConfig):
name = 'cryptober'
27 changes: 27 additions & 0 deletions cryptober/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 2.2.6 on 2019-10-10 19:14

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Response',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(default='', max_length=200)),
('email', models.EmailField(max_length=254)),
('input1', models.CharField(default='', max_length=100)),
('input2', models.CharField(default='', max_length=100)),
('input3', models.CharField(default='', max_length=100)),
('input4', models.CharField(default='', max_length=100)),
('input5', models.CharField(default='', max_length=100)),
],
),
]
38 changes: 38 additions & 0 deletions cryptober/migrations/0002_auto_20191010_1939.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 2.2.6 on 2019-10-10 19:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cryptober', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='response',
name='input1',
field=models.CharField(default='[]', max_length=100),
),
migrations.AlterField(
model_name='response',
name='input2',
field=models.CharField(default='[]', max_length=100),
),
migrations.AlterField(
model_name='response',
name='input3',
field=models.CharField(default='[]', max_length=100),
),
migrations.AlterField(
model_name='response',
name='input4',
field=models.CharField(default='[]', max_length=100),
),
migrations.AlterField(
model_name='response',
name='input5',
field=models.CharField(default='[]', max_length=100),
),
]
Empty file.
14 changes: 14 additions & 0 deletions cryptober/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField
import uuid
import datetime


class Response(models.Model):
name = models.CharField(default="",max_length=200)
email = models.EmailField()
input1 = models.CharField(default="[]",max_length=100)
input2 = models.CharField(default="[]",max_length=100)
input3 = models.CharField(default="[]",max_length=100)
input4 = models.CharField(default="[]",max_length=100)
input5 = models.CharField(default="[]",max_length=100)
117 changes: 117 additions & 0 deletions cryptober/templates/cryptober/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">

<style>
body {
text-align:center;
font-family: "Arial";
}
li{
display: inline;
}
a{
text-decoration: None;
}
.simple-input {
display: inline-block;
padding: 5px;
border: 4px solid #F1B720;
border-radius: 5px;
color: #333;
transition: all 0.3s ease-out;
}
.simple-input:hover{
border-radius: 8px;
}
.simple-input:focus {
outline: none;
border-radius: 8px;
border-color: #EBD292;
}

.bordered{
width:98%;
display: inline-block;
padding: 8px;
border: 3px solid #FCB326;
border-radius: 6px;
box-shadow:
0 2px 1px rgba(0, 0, 0, 0.2),
inset 0 2px 1px rgba(0, 0, 0, 0.2);

/* Font styles */
text-decoration: none;
font-size: 14px;
text-transform: uppercase;
color: #222;
}

.metro {
display: inline-block;
padding: 10px;
margin: 10px;
background: #08C;

/* Font styles */
color: white;
font-weight: bold;
text-decoration: none;
}

.metro.three-d {
position: relative;
box-shadow:
1px 1px #53A7EA,
2px 2px #53A7EA,
3px 3px #53A7EA;
transition: all 0.1s ease-in;
}
.metro {
display: inline-block;
padding: 10px;
margin: 10px;
background: #08C;

/* Font styles */
color: white;
font-weight: bold;
text-decoration: none;
}

.metro.three-d:active {
box-shadow: none;
top: 3px;
left: 3px;
}

.inline-link-2 {
display: inline-block;
border-bottom: 1px dashed rgba(0,0,0,0.4);

/* Font styles */
text-decoration: none;
color: #777;
}

.inline-link-2:hover { border-bottom-style: dotted; }
.inline-link-2:active { border-bottom-style: solid; }
.inline-link-2:visited { border-bottom: 1px solid #97CAF2; }
</style>


<link rel="stylesheet" href="styles.css">
<title>ERROR!</title>
</head>
<body class="bordered">
<h1 text-align"center">ERROR! Your input is invalid! Try again!</h1>
<ul>
<li class="inline-link-2"><a href="1">1</a></li>
<li class="inline-link-2"><a href="2">2</a></li>
<li class="inline-link-2"><a href="3">3</a></li>
<li class="inline-link-2"><a href="4">4</a></li>
<li class="inline-link-2"><a href="5">5</a></li>
</ul>
</body>
</html>
Loading

0 comments on commit a52241d

Please sign in to comment.