Skip to content

Instantly share code, notes, and snippets.

View madhoshyagnik's full-sized avatar

Madhosh Yagnik madhoshyagnik

View GitHub Profile
class Stack:
def __init__(self):
self.items = []
def is_empty(self):
# return len(self.items)==0
return not self.items
def push(self, item):
self.items.append(item)
"""
Python Data Structures - A Game-Based Approach
Stack challenge
Robin Andrews - https://compucademy.net/
"""
import stack
string = "gninraeL nIdekniL htiw tol a nraeL"
reversed_string = ""
@madhoshyagnik
madhoshyagnik / read_maze.py
Created October 22, 2020 11:06
Stripping endlines from mazes
"""
Python Data Structures - A Game-Based Approach
Reading a maze from a text file
Robin Andrews - https://compucademy.net/
"""
def read_maze(file_name):
"""
Reads a maze stored in a text file and returns a 2d list containing the maze representation.
"""
Python Data Structures - A Game-Based Approach
Reading a maze from a text file
Robin Andrews - https://compucademy.net/
"""
def read_maze(file_name):
"""
Reads a maze stored in a text file and returns a 2d list containing the maze representation.
@madhoshyagnik
madhoshyagnik / challange.py
Created October 23, 2020 06:57
challange problem
"""
Python Data Structures - A Game-Based Approach
Reading a maze from a text file
Robin Andrews - https://compucademy.net/
"""
def read_maze(file_name):
"""
Reads a maze stored in a text file and returns a 2d list containing the maze representation.
let user = {
name: 'crystel',
age: 30,
email: '[email protected]',
location: 'berlin',
blogs: ['why mac and cheese rules', ['10 things to make with marmite']],
login: function(){
console.log('user logged in');
},
logout: function(){
//arrow functions DO NOT WORK inside an object, if arrow function is user the window context is set for that method
let user = {
name: 'crystel',
age: 30,
email: '[email protected]',
location: 'berlin',
blogs: ['why mac and cheese rules', ['10 things to make with marmite']],
login: function(){
console.log('user logged in');
//arrow functions DO NOT WORK inside an object, if arrow function is user the window context is set for that method
let user = {
name: 'crystel',
age: 30,
email: '[email protected]',
location: 'berlin',
blogs: ['why mac and cheese rules', ['10 things to make with marmite']],
login: function(){
console.log('user logged in');
let user = {
name: 'crystel',
age: 30,
email: '[email protected]',
location: 'berlin',
blogs: [
{ title: 'why mac and cheese rules', likes: 30},
{ title: '10 things to make with marmite', likes: 40},
],
//primitive data types are store in a stack, reference data types are stored in a heap
//explanation - the data type created is a list, key pair data type
//for both the variables, a single value is stored in the heap, changing any one variable
// would change the value for both variables, unlike primitive data types, number, string,
// booolean