Jump to content
CaddyInfo Cadillac Forum

programming challenges


Recommended Posts

As a challenge to my beginner programming ability I thought it would be fun to see if I could code a simple brute force password thing. So I've started writing an application which generates, given a value for the length of the string, every alphanumeric permutation it could take. However, as I am a complete programming newbie I am having troubles.

Firstly, despite having imported java.lang.Math, I'm getting errors saying cannot find symbol: pow. I managed to fix this by writing out in full java.lang.Math.pow(); when I use the function instead, but why that works but import does not is beyond me.

Secondly, regardless of the length input, after inputting I get the runtime error:

aaException in thread "main" java.lang.ArrayIndexOutOfBoundsException: 98

at combination.main(combination.java:53)

Which suggests that in line 53:

current[j] = alphanum[((int)current[j])+1];

I'm apparently trying to access index 98 in either current[] or alphanum[]? Which as far as I can see shouldn't be happening...

Link to comment
Share on other sites


Exception 98 is the error number. Look for it in the Java manual for the interpreter or compiler that you are using. That will tell you where the error is in the expression, and probably what the error is. Most likely it is in the use of alphanum[*] or the compatibility with the output of alphanum[*] with current[*]. In fact, I would suspect that the output of alphanum[*] is text, not a number, and you may eliminate the error by simply not calling alphanum[*] at all.

I'm not a Java person, but the pow(*,*) function usually computes the power of one variable with another. For example, pow(2.,3.) is two to the third power, or eight. Generally,

pow( a, b ) = exp(b*ln(a))

although there are better numerical methods to use when, for example, a is an integer. The function fails if a is negative unless complex numbers are allowed. One big thing that will cause an error if you try to call pow(*,*) is that it has two arguments, and your dummy function has only one argument.

CTS-V_LateralGs_6-2018_tiny.jpg
-- Click Here for CaddyInfo page on "How To" Read Your OBD Codes
-- Click Here for my personal page to download my OBD code list as an Excel file, plus other Cadillac data
-- See my CaddyInfo car blogs: 2011 CTS-V, 1997 ETC
Yes, I was Jims_97_ETC before I changed cars.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...