I wrote a simple algorithm and it keeps getting stuck in a loop. I
guess I'm just to tired to figure it out:
compcount=[5,4,2,2]
suitrank=[0,0,0,0]
trump=2
l,lt=0,0
while l<4:
while lt<4:
if l==trump:
l+=1
if l>3:
break
if lt==trump:
lt+=1
if compcount[l]<compcount[lt]:
suitrank[l]+=1
lt+=1
l+=1
In case you're wondering, the point is to rank suits from highest to
lowest based on how few cards each suit has. I hope that's enough
information. 2 1676
On Mar 31, 8:22 pm, hexusne...@gmai l.com wrote:
I wrote a simple algorithm and it keeps getting stuck in a loop. I
guess I'm just to tired to figure it out:
compcount=[5,4,2,2]
suitrank=[0,0,0,0]
trump=2
l,lt=0,0
while l<4:
while lt<4:
if l==trump:
l+=1
if l>3:
break
if lt==trump:
lt+=1
if compcount[l]<compcount[lt]:
suitrank[l]+=1
lt+=1
l+=1
In case you're wondering, the point is to rank suits from highest to
lowest based on how few cards each suit has. I hope that's enough
information.
Inside the inner loop, lt never changes if lt != trump, so you get an
infinite loop the first time when lt == 0.
I think you may have misindented the last two lines.
<he********@gma il.comwrote in message
news:e1******** *************** ***********@c26 g2000prf.google groups.com...
|I wrote a simple algorithm and it keeps getting stuck in a loop. I
| guess I'm just to tired to figure it out:
The easiest way to figure out somethinglike this is to print your variables
from inside the loop to see things stick, or if there is a cycle.
| compcount=[5,4,2,2]
| suitrank=[0,0,0,0]
|
| trump=2
| l,lt=0,0
| while l<4:
| while lt<4:
print l, lt
| if l==trump:
| l+=1
| if l>3:
| break
| if lt==trump:
| lt+=1
| if compcount[l]<compcount[lt]:
| suitrank[l]+=1
| lt+=1
| l+=1 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ron |
last post by:
have been stuck on this for several days now.
I am trying to create a reverse polish calculator and I'm stuck at an
intermediate stage.
This is what I know I have to do (just not sure how to do it to much of a
newbie :( )
I'm trying to call method, isOp, in the int method, evaluate. While in INT
evaluate method and in a while(hasNextToken) loop. Calling isOp on each
token, nextToken.
If it returns False, convert to (Integer) and push...
|
by: reynoldscraigr |
last post by:
Hi All,
hope someone can see what wrong here I have the following function
function RemoveMenuFromHoldArray(menuName) {
var i = 0;
for (i=0;i<=MenusToHoldOpen.length-1;i++) {
if (MenusToHoldOpen == menuName) {
MenusToHoldOpen.splice(i,1);
return;
|
by: GeorgeAtkins |
last post by:
VS 2003 using VB.NET
I'm writing a program that reads text entries from a one file and matches
them against values in an XML document. However, the code seems to just sit
in the loop and never get anywhere, yet no errors occur. I tried this
hard-coding a title known to be in the XML file and it worked ok. It seems to
"hang" when the title is not found, but that's just a guess. Here is the code:
Imports System.Xml
Imports System.Text...
|
by: Mark Phillips |
last post by:
Hello,
I am having a problem in which a file can get stuck open when a thread
that is attempting to write to it gets aborted (ThreadAbortedException
occurs). The log file gets stuck open until the process is shut down
(cannot delete file from Windows Explorer, for example). My test
application stops execution with:
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process...
|
by: Rene |
last post by:
I got stuck on an infinite loop on the "Paint" event of my custom control
and I was not able to "ctrl-break" my way out of it.
After trying everything, I had to ctrs-alt-delete to shut down the
application and delete the bin and obj folders of the control so that the
application could start without locking.
I don't understand? I am pretty sure I was able to press ctrl-break before
and it would stop on the offending line. Could this be...
| |
by: Mike D |
last post by:
Attached is my code. Which I know there is a better way of writing however
this is what I came up with and it works until the value is null or not = to
the <> value.
'Do While rdrSQL.Read()
'While rdrSQL.Read()
' Dim result As String
' result = Trim(rdrSQL.GetString(0))
|
by: steve marchant |
last post by:
trying to learn VB6. Simple counting loop which counts to 8 in 1 sec
intervals, then starts from 1 again and repeats.
Have two Command buttons on the form. Cmd1 starts the counting, and I need
to know how to stop it with Cmd2. Here's my code so far:
Private Sub Command1_Click()
Dim x, y, m
m = 1
Do
Print m
|
by: Tom C |
last post by:
We have a window named FormApplication which just happens to be our
mid parent window. When I open it in the designer, it is stuck in a
loop redisplaying a c1flexgrid. maxing out our cpu's. By attaching to
the process from another visual studio, I can get it to break on some
user code with this huge callstack, most of which is native. So are we
instantiating something in design mode that we should not be? Does
this mean anything to anyone?...
|
by: Cainnech |
last post by:
Hi guys,
I'm a bit stuck in an infinite loop. What I'm trying to do in the code below is to compare two arrays and if there's an item in array ALGEMEEN that is not in array ITEMS, I want to add it to ITEMS.
Now the ITEMS-array looks like this:
items=;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |