Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Java
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 01-31-2008, 05:52 PM   #1 (permalink)
ace12364
Recruit
 
Join Date: Oct 2007
Posts: 3
ace12364 is on a distinguished road
Unhappy algorithm from java code

Does anyone know how to recognize the steps used/algorithm used within java code.
I dont much a bout java but i need to know the algorithm used in the java code so i can reproduce it in Haskell.

The program is about generating 6 random numbers and a target number, then using the 6 numbers with arithmetic to produce an arithmetic expression that when calculated is the target number.

can anyone help

thanks
__________________
ace12364 is offline   Reply With Quote
Old 01-31-2008, 08:42 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
If you're having trouble with algorithms, Haskell might be a pretty tough introduction to programming. What you've described sounds like it could be done a number of ways. Have you done anything with list comprehensions?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 02-01-2008, 04:29 AM   #3 (permalink)
ace12364
Recruit
 
Join Date: Oct 2007
Posts: 3
ace12364 is on a distinguished road
are you talking about the higher functions map and filter, and the ability to concatenate lists of lists.

Do you understand java, would you be able to recognise what is going on?
__________________
ace12364 is offline   Reply With Quote
Old 02-01-2008, 05:53 AM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
What steps, what algorithm, what part of code ????
You aren't displaying anything, it could be any lines of code found anywhere..

Your described problem can be achieved in many ways, but if you need to follow a predefined algorithm, we need to know that aswell or we might not be able to guide you in the right direction.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-01-2008, 06:37 AM   #5 (permalink)
ace12364
Recruit
 
Join Date: Oct 2007
Posts: 3
ace12364 is on a distinguished road
Do you understand this? I have added some comments of my own iunderstanding, but i would be grateful someone could justify it?
Code:
public int levelbottom(int v) //0->0, 1->6, 2->11, 3->15, 4->18, 5->20, 6->21 {return (21 - ((6-v)*(7-v))/2); } public boolean better(int a, int b, int c) //Is c closer to a than b is to a? {return (((b<c) && (b-a<a-c)) || ((c<b) && (a-c<b-a))); } public int calc(int h, int l, int f) //doing the calculation? {switch (f) {case 0: return h+l; // addition case 1: return h-l; // subtraction case 2: return h*l; // multiplication case 3: return h/l; // division default: } return 0; // should not arrive here?
__________________
ace12364 is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need c++ code for streamtokenizer function of java muralikrishna Standard C, C++ 2 11-06-2005 06:00 PM
how the servlet will integrate the LDAP code j.gohel Java 19 04-16-2005 12:55 AM
Java Resources Belisarius Java 0 03-28-2005 02:03 PM
What is OOP and Java? srt42 Java 0 04-07-2003 01:21 AM
An Introduction to XHTML/CSS Rie HTML / CSS 0 03-07-2003 06:50 PM


All times are GMT -8. The time now is 06:20 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle