Hello! I am looking for some help, and have provided the code. I'm just trying to do some simple stuff. I'm trying to create a simple game without using classes (but using lists). What I'm trying to do is create collision detection among list objects ("bullets" and "baddies"), as you'll be able to see in the code. I'm also trying to fire 10 bullets at once from an "ammoCrate". My problem is that I have to stay on the "ammoCrate" in order for the bullets to do their thing, otherwise they stop in place and disappear, but continue if the …

Member Avatar
Member Avatar
+0 forum 2

I'm attempting to write a simple search engine (which you might know if you read my previous question) that runs off of tags combined in a list. Currently it's just in a basic ASCII output, with things like print functions and the like. def main(): active = True done = False results = [] OTags = ['Hi', 'hi', ... #Continues onward] OResult = ["Type 'Hello' to access this page!"] BTags = ['Bye', 'see ya', ...] BResult = ["Type 'Goodbye' to access this page!"] while active: searchPrompt = raw_input('Https://') if searchPrompt in Otags: results.append(OResult) if searchPrompt in BTags: results.append(BResult) done = …

Member Avatar
Member Avatar
+0 forum 1

import pymongo uri = "mongodb://127.0.0.1:27017" client = pymongo.MongoClient(uri) database = client['fullstack'] collection = database['students'] students = [student['mark'] for student in collection.find({}) if student['mark'] == 99.0] print(students) In the program above how does this work? Why is the `if` statement after the execution code? I would expect the `if` to be before the `for`. And if `student['mark']` contains a value other than the string mark then it looks to me like student behaving like a dictionary with a key/value pair and not a python list. It probobly doesn't help that I've been playing in php and looks exactly like a php …

Member Avatar
Member Avatar
+0 forum 3

Im trying to implement queue with a linked list i think i have the enqueue function correct but im having problems with the dequeue. I can get it to delete the first number but then the rest of the list is empty can someone point me in the right direction? #include <stdio.h> #include <string.h> #include <stdlib.h> //Structure node struct _node { int num; struct _node * next; }; //type definitions typedef struct _node node; typedef node * link; //Structure list struct _list { link top;//points to node structure link bottom; }; //type definition typedef struct _list list; typedef list * …

Member Avatar
Member Avatar
+0 forum 4

Hi all, I'm trying to access a list in a class made in another class and display it in a listbox but its not working. I most probably have to make a small change to be able to get it to work. So please check in the code if you can see where the problem is. I have two classes - Race and Runner. **The Race class** Where I created the list and added the runners into it using a method that I call in the main form. namespace HW2 { class Race { public List<Runner> myList = new List<Runner>(); …

Member Avatar
Member Avatar
+0 forum 5

Hello below is my code for a program that reads in integers rom keyboard input and creates two polynomials from that input and then does some maths functions on them. I've got the addition working, having trouble with the multiplication though. Any help would be appreciated. thanks import java.util.*; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.text.*; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.Scanner; public class Polynomial { private Monomial head; private int TOLERANCE = 0; /****************** the Monomial (inner) class ********************************/ private class Monomial { private DecimalFormat precision = new DecimalFormat("#.####"); private int deg; // degree of polynomial …

Member Avatar
Member Avatar
+0 forum 7

I know that the main difference between an array and a list is that a list size changes dynamically as items are added or removed. Because of this, if we copy an array to a list does that mean that the list must have a static size of the array's capacity?

Member Avatar
Member Avatar
+0 forum 3

Both lists and arrays store data in one object(array or list). 1. In C# what is the difference between arrays and lists? 2. Can we store the same type in a list as an array? 3. Can an list store objects and references to other objects? 4. Where would we use a list instead of an array or vise versa? 5. What benefits does each have over the other?

Member Avatar
Member Avatar
+0 forum 4

I'm working with a LIST that am getting from a soup which after the clean up gives me: lists of variable length ['7.0', '7.5', '6.8', '6.9'] or ['7.0', '7.5'] so my problem is when I try formating the output: code snippet: if grades: print '\r\n["' + str(student[0]), if len(grades) == 1: print print ('%s'*len(grades)) % tuple(grades) the output of this is: >> ["John Doe 7.0 7.5 6.8 6.9 however what I need is: ["John Doe, ["7.0","7.5"],["6.8","6.9"]] or ["John Doe, ["7.0","7.5"]] I've tried with Formatter and Template and seems can't be done with those. thank you

Member Avatar
Member Avatar
+0 forum 5

Alright, so I found a tutorial on how to use lists to make a "TreeList" type thing, basically a list, ordered or unordered, that has a nested list that is collapsible. However, it doesn't seem to be working for me. Here's some code that I'm sure you will figure out. JavaScript: window.onload = function() { addEvents(); } function addEvents() { activateTree(document.getElementById("navigation")); } function activateTree(oList) { for(var i = 0; i < oList.getElementsByTagName("ul").length; i++) { oList.getElementsByTagName("ul")[i].style.display="none"; } oList.addEventListener("click", toggleBranch, false); } function toggleBranch(event) { var oBranch, cSubBranches; oBranch = event.target, cSubBranches = oBranch.getElementsByTagName("ul"); if(cSubBranches.length > 0) { if(cSubBranches[0].style.display == "block") { …

Member Avatar
+0 forum 0

# I want to eliminate a list from a bigger list, only by typing something # tasks = [] task = [task1,year,month,day, hour, minute, second, microsecond,str(cuando),cuando]# this is a list that is filed into another list named tasks# # If I type a position, I want to eliminate a complete list that is filed in tasks # tasks = [["math",year,month,day, hour, minute, second, microsecond]["biology",year,month,day, hour, minute, second, microsecond,str(cuando),cuando]] # the program asks if you finished any tasks# k = 0 while k < CantTareas : ans = raw_input ("Did you finished any task? (yes or no) ") if ans == …

Member Avatar
Member Avatar
+0 forum 1

We were given a task to use lists and iterators. We were supposed to make them from scratch. I'm done with that. The problems that I'm having are as following: 1. I'm not able to access the list made of Course datatype which is present in each Student instance. Does this mean I need to make an iterator for that course list inside the student class? 2. Similarly since I don't have direct access to The course list so I added the course into the Student list through the student objects not through the iterator. How can I do it …

Member Avatar
Member Avatar
+0 forum 1

I'm looking for some help with an issue I am having. I have multiple text files in a folder. The folder can have an "unlimited" amount of text files in it, although typically 2-150 files. http://gyazo.com/5f314d1ca374abf9f813914609dd931d (images for this + below) Each file then contains an "unlimited" (although typically 0-20 lines) amount of data inside it. Line 1 being the "test number" and line 2 being the "test result" - as seen in the image above My Data Grid View has 3 columns in it [Username, Test Number and Test Result] named (Column_Username, Column_TestNumber, Column_TestResult) - as seen in the …

Member Avatar
Member Avatar
+0 forum 1

Do you know if I can change of line in a list of lists? tareas = [] > otraTarea = [tarea,year,month,day, hour, minute, second, microsecond,str(cuando),cuando] `+'\n'+ []`(this is what i have tried) #I have tried to concatenate two lists, but the program returns a message, in which it's explained that I have to convert my list into a string format, and I don´t want that. #I want something like: [tarea,year,month,day, hour, minute, second, microsecond,str(cuando),cuando] [tarea,year,month,day, hour, minute, second, microsecond,str(cuando),cuando] [tarea,year,month,day, hour, minute, second, microsecond,str(cuando),cuando] # normally it is shown like: # [[tarea,year,month,day, hour, minute, second, microsecond,str(cuando),cuando],[tarea,year,month,day, hour, minute, second, microsecond,str(cuando),cuando],[tarea,year,month,day, …

Member Avatar
Member Avatar
+0 forum 1

odd mountain is a list of odd numbers going up from 1 and then back to 1. e.g. odd_mountain of size 5 is [1,3,5,3,1] odd_mountain of size 4 is [1,3,3,1] Hint: use the list functions and a builtin function. Can anyone help me in this? all my tries are going waste. I thought of doing it using range but getting trouble with even sizes! Please help!

Member Avatar
Member Avatar
+0 forum 6

Hi, Below is the code I am having difficulty making work: public function showLoginOut() { if (session==null) { return '<li><a href="login.php">Login</a></li>'; } else { return '<li><a href"logout.php">Logout</a></li>'; } } *^ Above is a PHP page, which holds functions I can use in a phtml document* <ul> <li><a href="index.php">Home</a></li> <?php function showLoginOut() { }; ?> <li><a href="allstock.php">All Our Stock</a></li> ..... * ^ Above is part of the phtml page.* When I run the page there are no errors shown, but in the list there's no Login or Logout. I don't know why. I've tried echo instead of return, but the same …

Member Avatar
Member Avatar
+0 forum 3

Ok, so I am trying to write a code that will find the attributes in a html tag using lists and splitting them up. Unfortunately its giving me a hard time with the added quotation marks. [CODE] def find_attribute_value(html_tag, att): '''Return the value of attribute att (a str) in the str html_tag. Return None if att doesn't occur in html_tag. ''' words = html_tag.split(" ") #this is me trying to split up the initial html tag. omgs= str (words) # then trying to convert it into a string because it wouldn't let me split it up further otherwise :( list2 …

Member Avatar
Member Avatar
+0 forum 9

Hello! I've been busy passing exams, but now I'm free to code around again. So, in my usual style! **The goal:** I've been playing some Battlefield 3 during study breaks, and I've often been pissed off by BF3's autobalance mechanism. It's bad. Horrible. It makes me sad. I usually have to watch cat videos for an hour to recover from being autobalanced. But, it gave me the idea to code my own autobalancer! :D **The problem:** To me, my logic seems fine, but the code breaks when I try to call the methods and objects in my main class. **The …

Member Avatar
Member Avatar
+0 forum 16

Okay so I have couple of questions about lists in vb.. Please be aware that it's all related to integers only no strings or others 1. How to sum values of a list? 2. How to sort values of list from highest to lowest? Also how would I display list values in a message box vertically? Example: ...........Message Box............ .1 .2 .3 .4 .5 .6 .................................. I appreciate any answers.. And please let me know if you need further information.

Member Avatar
Member Avatar
+0 forum 1

I need to write an algorithm for finding the maximum weighted independent set of a graph, G. Any idea of where I should start?

Member Avatar
Member Avatar
+0 forum 1

I've been looking around for an answer to this but have had no luck. I need to take two files and print the top most frequent words they have in common as well as their combined(sum) frequencies. This might be simple but I'm pretty new to programming. Any help? def mostFrequent(word,frequency,n): my_list = zip(word,frequency) #combine the two lists my_list.sort(key=lambda x:x[1],reverse=True) #sort by freq words,freqs = zip(*my_list[:n]) #take the top n entries and split back to seperate lists return words, freqs #return our most frequent words in order from wordFrequencies import * #gives both the word and its frequency in a …

Member Avatar
Member Avatar
+0 forum 3

class BTNode(object): """A node in a binary tree.""" def __init__(self, item, left=None, right=None): """(BTNode, object, BTNode, BTNode) -> NoneType Initialize this node to store item and have children left and right, as well as depth 0. """ self.item = item self.left = left self.right = right self.depth = 0 # the depth of this node in a tree def __str__(self): """(BTNode) -> str Return a "sideways" representation of the subtree rooted at this node, with right subtrees above parents above left subtrees and each node on its own line, preceded by as many TAB characters as the node's depth. """ …

Member Avatar
Member Avatar
+0 forum 1

Hello. I'm attempting to create a program in C# that reads lines of text from a text file and stores them in a list. Then I have to compare each line to another equally large (50 lines) text file, and display the differences to the screen? Could anyone help? It would be appreciated. So far i've only been able to read the files. TextReader tr = new StreamReader("file1.txt"); for (var i = 0; i < 1; i++) { tr.ReadLine(); } TextReader tra = new StreamReader("file2.txt"); for (var f = 0; f < 1; f++) { tra.ReadLine(); }

Member Avatar
Member Avatar
+0 forum 2

hi ! how can i do a one-way-circular linked list function that gives to me** merge 3 lists** such as struct node{ int data; node *flink; node *blink; }; void concatenate(node *&L1,node *L2,node *L3) { ??? }

Member Avatar
Member Avatar
+0 forum 2

Hello my fellow Daniwebers! I am having some problems wrapping my head around the task sorting a List(Of CustomType) I have a list containing a custom class. The class contains Two DateTime objects, Start and End. I am trying to sort the list descending so that the shortest timespan will be on the bottom of the list. I am unsure how to write the function that returns the value to sort. I have read Microsoft's documentation [here](http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx) and, as all ways, I am more confused after reading it than I was before I began. This is what I have deducted …

Member Avatar
Member Avatar
+0 forum 2

Hello All!! I have an assignement that I am working on and for some reason I cannot for the life of me recall how to do something so simple lol. The directions are too "Write a function named Exam, which takes one argument n where n>2. Your function creates a list (list1) of n random integers in range (1,5) and print all elements of list1 on one line. So far what I have is : def Exam(n): import random random.randrange(1,5) I am not sure where to insert the n>2 and even really what it means. If anyone can assist or …

Member Avatar
Member Avatar
+0 forum 1

Write a Python program which will read data for several students from a text file and create a list of lists to store that data. The data must be read from a text file named “Lab11.txt”. Each line in the text file contains the first name, last name, techid, number of credits earned, and number of quality points earned for a single student. The individual items of data on a line are separated by one or more spaces. You can see sample data in the D2L file “Lab11.txt”. Lab11.txt looks like: Max Medium 12345678 58 152 Jane Johnson 87654321 78 …

Member Avatar
Member Avatar
+0 forum 3

[L-Lists](http://l-lists.com/) is a website for creating lists of links, and contributing new links to existing lists. The directory of lists on [L-Lists](http://l-lists.com/), is called the [List of Lists](http://l-lists.com/en/lists.php). Currently there are lists of: [Open Access Computer Science Journals ](http://l-lists.com/en/lists/sumdhc.html)[Search Engines](http://l-lists.com/en/lists/qukoen.html) [Image Search Engines ](http://l-lists.com/en/lists/ov9lqv.html)[Political Spectrum Tests](http://l-lists.com/en/lists/0isll4.html) (like [Political Compass](http://politicalcompass.org/)) [Free Statistical Software](http://l-lists.com/en/lists/dz3a5t.html)

Member Avatar
Member Avatar
+0 forum 2

The goal of the program is to make a sparse matrix using circularly linked lists. basically its a matix what only has values at the locations entered, and the rest of the lactions are not defined. the question i have is the logic for the code. how would i go about traversing and adding elements to the list with out defining the elements i dont want to define, as well as linking it to the other horizontal/vertical components

Member Avatar
Member Avatar
+0 forum 6

Hello, I am writing a program that reads in data from a text file and puts it into a linked list. Certain variables are read in only if the "officeHeld" number is a particular number, otherwise the variable is set to 0. When I run this through Visual Studio, I get a blank black screen with nothing on it. When I run it through our university's unix, I get "segmentation fault". I am not sure where the error is here and I'm at a loss. Any help or suggestion would be overwhelmingly appreciated. I'm attaching the code as well as …

Member Avatar
Member Avatar
+0 forum 4

The End.