Home | Community | Message Board


This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Shop: Unfolding Nature Unfolding Nature: Being in the Implicate Order   Myyco.com Golden Teacher Liquid Culture For Sale

Jump to first unread post Pages: 1
This Java code is driving me crazy. What is wrong with it??
    #15486771 -

I've been working on this for a while now, and I'm not sure what the issue is. The program takes a series of scrambled words from standard in, and checks them against a wordlist. What I'm doing is first sorting the wordlist so that each word is sorted by character. For example, "string" becomes "ginrst". Those sorted words are then placed into an array, which is passed to a 'match' method along with an array that contains the scrambled words.
The match method checks each scrambled word against every sorted word in the array, and if they match, the word from the original list is placed into another array of strings.

My code is here -> http://pastebin.com/VeqVGpYe

This is the problem I am trying to solve:
Find the original (unscrambled) words, which were randomly taken from a wordlist.
Send a comma separated list of the original words, in the same order as in the list below.



EDIT: I suppose I should tell you what's going wrong :facepalm: Instead of getting the correct words, I am getting a series of nulls. It seems as though the array I am trying to return never has anything put into it.


--------------------


Use these substances wisely, they have the ability to cause life altering realizations.

Edited by bholzer (12/08/11 04:20 PM)

Extras: Filter Print Post Top
Re: This Java code is driving me crazy. What is wrong with it?? [Re: bholzer]
    #15486896 -

I'm not sure I understand what the program is supposed to be doing in the first few steps. I need clarification before I can respond properly. I'm mostly confused about the "scrambled" part.

Do you mean they are just arbitrarily placed in the list or that the letters are scrambled before the letter sorting starts?
Then once they are sorted by character they are sent to check if the original word was already composed of characters in alphabetical order?

Extras: Filter Print Post Top
Re: This Java code is driving me crazy. What is wrong with it?? [Re: pickeroo]
    #15486921 -

pickeroo said:
I'm not sure I understand what the program is supposed to be doing in the first few steps. I need clarification before I can respond properly. I'm mostly confused about the "scrambled" part.

Do you mean they are just arbitrarily placed in the list or that the letters are scrambled before the letter sorting starts?
Then once they are sorted by character they are sent to check if the original word was already composed of characters in alphabetical order?



Shit, I really need to start commenting my code better, let me do that really quick, and I'll repost the commented code


--------------------


Use these substances wisely, they have the ability to cause life altering realizations.

Extras: Filter Print Post Top
Re: This Java code is driving me crazy. What is wrong with it?? [Re: bholzer]
    #15486972 -

What is that line?
Quote:
In list = new In("wordlist.txt");



I have never seen anyone read a file like that. In fact, I cannot even compile it.

I would use an  instance of Scanner to read your file. It is super useful, because you can tell it what delimiter you want to use, so you could skip the split() command as well :wink:

Extras: Filter Print Post Top
Re: This Java code is driving me crazy. What is wrong with it?? [Re: bholzer]
    #15487021 -

http://pastebin.com/8cHCyVyj

It's slightly better, hopefully understandable


--------------------


Use these substances wisely, they have the ability to cause life altering realizations.

Extras: Filter Print Post Top
Re: This Java code is driving me crazy. What is wrong with it?? [Re: Arugula-375]
    #15487035 -

Arugula-375 said:
What is that line?
Quote:
In list = new In("wordlist.txt");



I have never seen anyone read a file like that. In fact, I cannot even compile it.

I would use an  instance of Scanner to read your file. It is super useful, because you can tell it what delimiter you want to use, so you could skip the split() command as well :wink:



It's a custom library for reading input, however scanner or buffered input would work as well.


--------------------


Use these substances wisely, they have the ability to cause life altering realizations.

Extras: Filter Print Post Top
Re: This Java code is driving me crazy. What is wrong with it?? [Re: bholzer]
    #15487173 -

Quote:
Code:
if(scrambled[i].equals(sortedList[j])) solved[i] = list[j];





Should that not be
Code:
solved[i] = sortedList[j]

?

Extras: Filter Print Post Top
Re: This Java code is driving me crazy. What is wrong with it?? [Re: pickeroo]
    #15487236 -

pickeroo said:
Quote:
Code:
if(scrambled[i].equals(sortedList[j])) solved[i] = list[j];





Should that not be
Code:
solved[i] = sortedList[j]

?



No, because I want the solution to be the unscrambled and unsorted words.
I did however find my issue, the words from the wordlist had newline characters that was throwing the if statement off, thanks for your help though!


--------------------


Use these substances wisely, they have the ability to cause life altering realizations.

Extras: Filter Print Post Top
Jump to top Pages: 1

Shop: Unfolding Nature Unfolding Nature: Being in the Implicate Order   Myyco.com Golden Teacher Liquid Culture For Sale


Similar ThreadsPosterViewsRepliesLast post
* A home-built ram drive? HagbardCeline 1,357 1 07/08/04 05:23 PM
by HagbardCeline
* Java applet designer question_for_joo 848 4 07/28/04 04:53 PM
by Scarfmeister
* Java Virtual Engine? ImOver18 998 6 04/13/04 06:35 PM
by MAIA
* Go to the store and name your price! with re-code.com
( 1 2 all )
Lana 4,516 39 06/03/03 10:22 AM
by Raadt
* Electromagnetic Hard Drive Erasing?
( 1 2 all )
EffedS 5,836 35 08/01/03 07:52 PM
by Effed
* Software Developer Deciphers Shredded Paper's Code wingnutx 1,911 9 10/16/03 09:08 PM
by Joshua
* removing Java Runtime Environment, SE v1.4.2_05 felix 948 6 08/31/05 11:16 PM
by Vvellum
* new to html/java etc... funkymonk 617 4 08/13/03 11:27 PM
by funkymonk

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
381 topic views. 0 members, 3 guests and 0 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2026 Mind Media. Some rights reserved.

Generated in 0.026 seconds spending 0.004 seconds on 14 queries.