Click here to Skip to main content
15,889,462 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: How to check if a tree is AVL tree? Pin
Dimitri Witkowski8-Jan-10 22:06
Dimitri Witkowski8-Jan-10 22:06 
AnswerRe: How to check if a tree is AVL tree? Pin
ProtoBytes26-Jan-10 13:48
ProtoBytes26-Jan-10 13:48 
QuestionComplexity help please! Pin
password9996-Jan-10 7:25
password9996-Jan-10 7:25 
AnswerRe: Complexity help please! Pin
ProtoBytes27-Jan-10 7:24
ProtoBytes27-Jan-10 7:24 
QuestionRomanization of Japanese using the Hepburn (or related - like ISO_3602) algorithm Pin
Tom Clement30-Dec-09 14:40
professionalTom Clement30-Dec-09 14:40 
AnswerRe: Romanization of Japanese using the Hepburn (or related - like ISO_3602) algorithm Pin
ProtoBytes27-Jan-10 7:20
ProtoBytes27-Jan-10 7:20 
QuestionSnake game problem Pin
venomation28-Dec-09 11:03
venomation28-Dec-09 11:03 
AnswerRe: Snake game problem [modified] Pin
Luc Pattyn28-Dec-09 11:33
sitebuilderLuc Pattyn28-Dec-09 11:33 
Hi,

1.
when you use PRE tags, you get a non-proportional font, and spaces work as you would expect.

2.
you need to hold the playground in memory, maybe as a 2-dimensional array of integers.
you could initialize it at all zero (=empty cells); then set one or a few cells to consecutive numbers (1,2,3,..N) where the highest number is the head and the lowest non-zero is the tail of the snake.

Moving it means adding the next number to the right/left/top/down position of the head, depending on current direction; and probably also removing the lowest non-zero, unless you want the snake to grow.

[CLARIFICATION ADDED]: in one dimension the snake could move
from 0 0 1 2 3 4 0 0 0
  to 0 0 0 2 3 4 5 0 0

, so the head was 4 and now moved to 5, while the tail was 1 and moved to 2. You keep a pointer to the head and adjust it in the right direction; and you keep a pointer to the tail, search the neighbour that is one higher, and that becomes the tail.[/ADDED]

3.
and then you should visualize all this in the Paint handler, as I explained here[^].

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Merry Christmas and a Happy New Year to all.


modified on Wednesday, January 13, 2010 8:41 PM

AnswerRe: Snake game problem Pin
Skippums13-Jan-10 10:58
Skippums13-Jan-10 10:58 
GeneralRe: Snake game problem Pin
Luc Pattyn13-Jan-10 11:30
sitebuilderLuc Pattyn13-Jan-10 11:30 
GeneralRe: Snake game problem Pin
Skippums13-Jan-10 13:36
Skippums13-Jan-10 13:36 
GeneralRe: Snake game problem Pin
Luc Pattyn13-Jan-10 13:56
sitebuilderLuc Pattyn13-Jan-10 13:56 
GeneralRe: Snake game problem Pin
Skippums13-Jan-10 14:22
Skippums13-Jan-10 14:22 
GeneralRe: Snake game problem Pin
Luc Pattyn13-Jan-10 14:40
sitebuilderLuc Pattyn13-Jan-10 14:40 
AnswerRe: Snake game problem Pin
pewtas23-Feb-10 20:16
pewtas23-Feb-10 20:16 
GeneralRe: Snake game problem Pin
venomation4-Mar-10 1:25
venomation4-Mar-10 1:25 
QuestionGeometry problem Pin
Daniel.Sturza27-Dec-09 3:03
Daniel.Sturza27-Dec-09 3:03 
AnswerRe: Geometry problem Pin
Luc Pattyn27-Dec-09 3:10
sitebuilderLuc Pattyn27-Dec-09 3:10 
GeneralRe: Geometry problem [modified] Pin
Daniel.Sturza27-Dec-09 3:45
Daniel.Sturza27-Dec-09 3:45 
AnswerRe: Geometry problem Pin
harold aptroot27-Dec-09 4:33
harold aptroot27-Dec-09 4:33 
GeneralRe: Geometry problem Pin
Daniel.Sturza27-Dec-09 5:31
Daniel.Sturza27-Dec-09 5:31 
AnswerRe: Geometry problem Pin
Luc Pattyn27-Dec-09 5:28
sitebuilderLuc Pattyn27-Dec-09 5:28 
GeneralRe: Geometry problem Pin
Daniel.Sturza27-Dec-09 5:52
Daniel.Sturza27-Dec-09 5:52 
GeneralRe: Geometry problem Pin
Luc Pattyn27-Dec-09 6:10
sitebuilderLuc Pattyn27-Dec-09 6:10 
GeneralRe: Geometry problem Pin
Daniel.Sturza27-Dec-09 7:13
Daniel.Sturza27-Dec-09 7:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.