pseudocode

Python - Writing pseudocode?

How would you write pseudocode for drawing an 8-by-8 checkerboard of squares, where none of the squares have to be full? (Can all be empty) I don't quite get the pseudocode concept. ...

Understanding an example

def solve(numLegs, numHeads): for numChicks in range(0, numHeads + 1): numPigs = numHeads - numChicks totLegs = 4*numPigs + 2*numChicks if totLegs == numLegs: return [numPigs, numChicks] return [None, None] def barnYard(heads, legs): pigs, chickens = solve(legs, heads) if pigs == None: print "Th...

Pseudo Code for converting infix to postfix.

I'm struggling getting the pseudo code for this. Scan string left to right for each char If operand add it to string Else if operator add to stack .... i'm struggling on how to handle ( )s ...

2D World design question

I'm facing a problem which is probably extremely common in game-design. Let's assume that we've got a 2D world The world's size is M x N rect The world may contain some items in it The items have (x,y) coords The world can be browsed via a window that is physically (m x n) large. The browser window can be zoomed in / out The browser wi...

Implement a listbox

I need to implement a listbox for a mobile. The only relevant controls are up and down arrow keys. The listbox should display as many rows of items from a list as will fit on the screen (screen_rows), one row should be highighted (sel_row) and the display should wrap if the user hits up arrow when the first item is highlighted or down ...

Convert Array of Decimal Digits to an Array of Binary Digits

This is probably a quite exotic question. My Problem is as follows: The TI 83+ graphing calculator allows you to program on it using either Assembly and a link cable to a computer or its built-in TI-BASIC programming language. According to what I've found, it supports only 16-Bit Integers and some emulated floats. I want to work with...

What is the correct way to convert from a for loop to a while loop?

I have a for loop of the form: for (int i = from; i < to; i++) { // do some code (I don't know exactly what, it is subject to change) } And I want to convert it to a while loop (mostly because I want to play with the value of i inside the loop to go backwards and forwards and my co-worker thinks that doing this in a for loop is pron...

transitive reduction algorithm: pseudocode?

I have been looking for an algorithm to perform a transitive reduction on a graph, but without success. There's nothing in my algorithms bible (Introduction To Algorithms by Cormen et al) and whilst I've seen plenty of transitive closure pseudocode, I haven't been able to track down anything for a reduction. The closest I've got is that ...

Pseudocode for getting order based on Dependency

Ok, my situation is this I have a list of items and I need to get the order of these items based on the references they have. For example lets say we have these items: A,B,C,D,E,F C and D have no dependencies so their order can be 0. B is the one that has the most with C, D and A. A has C and F has A and B C D | \ / A / ...

Getting a list of all churches in a certain state using Python.

Hi, I am pretty good with Python, so pseudo-code will suffice when details are trivial. Please get me started on the task - how do go about crawling the net for the snail mail addresses of churches in my state. Once I have a one liner such as "123 Old West Road #3 Old Lyme City MD 01234", I can probably parse it into City, State, Street,...

Explain this DSP notation

I'm trying to implement this extenstion of the Karplus-Strong plucked string algorithm, but I don't understand the notation there used. Maybe it will take years of study, but maybe it won't - maybe you can tell me. I think the equations below are in the frequency domain or something. Just starting with the first equation, Hp(z), the pi...

Job scheduling problem

I'm working on an application where I need to automatically schedule jobs for members on a rotating schedule. I'm not very good at explaining rules, so here's some data to help out: Positions: A job title, with rules such as Mondays and Wednesdays weekly. Categories: A set of positions Groups: Another set of positions. Positions in the ...

Assembler Language Programming

I am trying to write a program that inputs a positive number less than 10 and outputs the sum of the first numbers. For example 5 would be 5+4+3+2+1. The commands are Stop, Load, Store, Add, Sum, Multiply, Divide, Input, Output, Branch, Branch if 0, and branch if not 0. Can anyone help me out here. I am kind of stuck. well what I have wr...

Pseudo codestructure to Mysql?

Can somebody help get the following pseudocode in mysql? The resulting selects in the IF statement all return the same columns (4) and multiple rows (unknown) so that's not really the problem i'm facing.. How can I get the following structure in Mysql? //parameters @p1; @p2; @v1; @v2; //vars @t1= 15000; @t2 = 15000; //calculated vars...

Does anyone design api or library code in this way?

I was reading up some things about how to design a library or API well, and stumbled across Joshua Bloch's great talk at Google Tech Talks. Now although I am nowhere near a professional API developer, I think programming a bunch of classes/functions is a similar, although much scaled-down version of the same thing - clear-cut separation ...

Randomly Generate Letters According to their Frequency of Use?

How can I randomly generate letters according to their frequency of use in common speech? Any pseudo-code appreciated, but an implementation in Java would be fantastic. Otherwise just a poke in the right direction would be helpful. Note: I don't need to generate the frequencies of usage - I'm sure I can look that up easily enough. ...

Representing code algebraically

Dear all; I have a number of small algorithms that I would like to write up in a paper. They are relatively short, and concise. However, instead of writing them in pseudo-code (à la Cormen or even Knuth), I would like to write an algebraic representation of them (more linear and better LaTeX rendering) . However, I cannot find resources...

In a triangulated isometric grid, what triangle is a given point in?

I have a triangulated isometric grid, like this: In my code, triangles are grouped by columns. As I hover the mouse, I want to calculate what triangle the mouse coordinates are in. Is there a simple algorithm to do that? ...

Standards for pseudo code?

I need to translate some python and java routines into pseudo code for my master thesis but have trouble coming up with a syntax/style that is: consistent easy to understand not too verbose not too close to natural language not too close to some concrete programming language. How do you write pseudo code? Are there any standard re...

How to generate n different colors for any natural number n?

Say n = 100; How do I generate 100 visually distinct colors? Is this mathematically possible? ...