Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Java Homework

Name: Anonymous 2007-04-09 13:17 ID:HpLdMw06

Ok /prog/, this is very simple.

You're going to do my programming homework. Because want you to.

This is very simple... Work + No Spare Time = No Homework Done

So here's the deal: I supply to you my Java Homeworks and you'll do it.
If you're unable to do it, feel free to post whatever you like.
If you're a fucking coding god, you will post your ultimate solution, and face the criticism from other coding gods, including moot.

Cruel Leonidas demanded that you stand. I require only that you kneel.

Name: Anonymous 2007-04-09 13:27 ID:nDUlYiO3

This is madness. (Or Java, whichever word you prefer)

Besides, my dick is so long, I have a cramp in my upper leg. I can't kneel for you.

Name: Anonymous 2007-04-09 13:53 ID:fXVbnq6z

We will do your Java homework IN HASKELL.

Name: Anonymous 2007-04-09 14:47 ID:NUcXnUpj

And Python!

Name: Anonymous 2007-04-09 16:16 ID:HpLdMw06

>>3
>>4

It has something to do with outputs in the console.
I'll translate the shit after my dinner at Chez Enfer, with 300 hot chicks.

Name: Anonymous 2007-04-09 16:51 ID:Heaven

>>5
System.out.print(shit);

Name: Anonymous 2007-04-09 17:47 ID:8q50gCgB

>>5

If you're eating dinner out, and not ordering pizza in, you'll never be a programmer.  Sacrifice your social life now, or be condemned to a career filled with VB6 and legacy code.

Name: Anonymous 2007-04-09 18:47 ID:/1w4xrfa

I will do your programming homework.

I am a coding god.

It will be done.

Name: Anonymous 2007-04-09 19:41 ID:HpLdMw06

>>7
We have a programming class here that is mandatory to every course. I'm not going to be a programmer.

Name: Anonymous 2007-04-09 19:53 ID:N/BlYyRO

>>1
he didnt even post any homework
I was going to do it to troll people

Name: Anonymous 2007-04-09 20:08 ID:HpLdMw06

>>8

Here it is, then, mister god:

-- You have to write a Java program that draws numbers in the computer screen, old calculator LED style. Counsider a screen with infinite lines and a max of 80 columns.

-- Input data:
The input file of this program contains several lines, one for each number being shown in the screen.
Each line has 2 integer numbers: S (where S is (1 <= S <= 10)) and N (where N is (0 <= N)). N is the number that will be written in the screen. S is the size of the characters.

-- Output data:
The screen prints (LED style ) the numbers in the file, using S symbols "-" for the horizontal segments and S "|" for the vertical segments. Each numerical digit ocupies exactly S+2 columns and 2S+3 lines.

The program must assure that all whitespaces of each numerical digit (the spaces that don't have "|" or "-"“, have the proper " " (space).

Between do consecutive numerical digits of a same number should exist a column of spaces. If there's 2 numbers in a row that are the same, they must be separeted with a space.

EXAMPLE:

2 12345
3 67890
4 0012345678901234
A saída será:
      --   --        --
   |    |    | |  | |  
   |    |    | |  | |  
      --   --   --   --
   | |       |    |    |
   | |       |    |    |
      --   --        --

 ---   ---   ---   ---   ---
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---      
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   ---

 ----   ----          ----   ----          ----   ----   ----   ----   ----    
|    | |    |      |      |      | |    | |      |           | |    | |    |   
|    | |    |      |      |      | |    | |      |           | |    | |    |   
|    | |    |      |      |      | |    | |      |           | |    | |    |   
|    | |    |      |      |      | |    | |      |           | |    | |    |   
                      ----   ----   ----   ----   ----          ----   ----    
|    | |    |      | |           |      |      | |    |      | |    |      |   
|    | |    |      | |           |      |      | |    |      | |    |      |   
|    | |    |      | |           |      |      | |    |      | |    |      |   
|    | |    |      | |           |      |      | |    |      | |    |      |   
 ----   ----          ----   ----          ----   ----          ----   ----    

 ----          ----   ----                                                     
|    |      |      |      | |    |                                             
|    |      |      |      | |    |                                             
|    |      |      |      | |    |                                             
|    |      |      |      | |    |                                             
               ----   ----   ----                                              
|    |      | |           |      |                                             
|    |      | |           |      |                                             
|    |      | |           |      |                                             
|    |      | |           |      |                                             
 ----          ----   ----        



Welcome to India!

Name: Anonymous 2007-04-09 21:03 ID:kH/CbOmx

>>3

Or Prolog, or Scheme.  Just not a worthless mindfuck like Java.

4chan /prog/.  Helpful as ever.

Name: Anonymous 2007-04-09 21:21 ID:ehFLAFbU

$120/hr for programming training.

Name: Anonymous 2007-04-09 21:27 ID:HpLdMw06

>>11

That's what happens when you don't eat beef. Morons.

Name: Anonymous 2007-04-09 22:00 ID:QxMUFpnv

>>11
Your homework is from that shitty codegolf.com page?

Name: Anonymous 2007-04-10 3:09 ID:oF3ehT5j

>>12
Fuck Scheme. 

No seriously, I fucking hate Scheme.

Name: Anonymous 2007-04-10 3:44 ID:bQtu3QZF

As promised, here's your homework:

module Main where

import Char (digitToInt)
import Data.List (intersperse, transpose)
import System.IO

import Prelude hiding (Left, Right)

data Position = Left | Right | Both
data Digit = Digit Bool Position Bool Position Bool

digit :: Int -> Digit
digit 0 = Digit True  Both  False Both  True
digit 1 = Digit False Right False Right False
digit 2 = Digit True  Right True  Left  True
digit 3 = Digit True  Right True  Right True
digit 4 = Digit False Both  True  Right False
digit 5 = Digit True  Left  True  Right True
digit 6 = Digit True  Left  True  Both  True
digit 7 = Digit True  Right False Right False
digit 8 = Digit True  Both  True  Both  True
digit 9 = Digit True  Both  True  Right True

horiz :: Int -> Bool -> [String]
horiz n False = [replicate n ' ']
horiz n True  = [replicate n '-']

vert :: Int -> Position -> [String]
vert n pos = replicate n $ vert' n pos

vert' n Left  = "|" ++ replicate (n-1) ' '
vert' n Right =        replicate (n-1) ' ' ++ "|"
vert' n Both  = "|" ++ replicate (n-2) ' ' ++ "|"

showDigit :: Int -> Digit -> [String]
showDigit n (Digit t u m l b) =
    hor t ++ ver u ++ hor m ++ ver l ++ hor b
    where hor = horiz n
          ver = vert n

showDigits :: Int -> [Int] -> String
showDigits n = concat .
               map ((++ "\n") . concat . intersperse " ") .
               transpose . map (showDigit n . digit)

mongleLine :: String -> String
mongleLine (n:' ':digits) = showDigits
                            (digitToInt n)
                            (map digitToInt digits)
mongleLine x = ""

main :: IO ()
main = getContents >>= mapM_ (putStr . mongleLine) . lines


>>16
What does this have to do with the topic? Or is this just your way to say "I've read SICP"?

Name: Anonymous 2007-04-10 5:27 ID:Hy49oqDy

>>17
Needs more $.

Name: Anonymous 2007-04-10 5:41 ID:bQtu3QZF

>>18
Sorry, I'm broke. I could barely afford the one $.

Name: Anonymous 2007-04-10 6:00 ID:V9G9BCuJ

>>14 kuttiya

>>15
Nope. My teacher often steals these from european universities or he makes them, when he's in a good mood.
There's no Java coding gods in here?

Name: Anonymous 2007-04-10 6:36 ID:qIQdBsAH

>>20
coding gods does not do Java

Name: Anonymous 2007-04-10 6:51 ID:d1pXCURF

I would do this but I have a shitload of homework.

I'll give you a hint: Queues.

Name: Anonymous 2007-04-10 7:21 ID:dMc4lajH

>>17
Coding god

>>21
Truth

Name: Anonymous 2007-04-10 8:33 ID:V9G9BCuJ

Name: Anonymous 2007-04-10 11:30 ID:bQtu3QZF

HOW DOES CODING GODS KNOW WHAT JAVA IS?

Name: Anonymous 2007-04-10 12:22 ID:dMc4lajH

Because god knows the devil

Name: Anonymous 2007-04-10 14:06 ID:RIw09X2R

WWWHHHHYYYYYYYYYY ARENTT YOU GUUUUUUUYS DDDDOOOOOING MY HOOOOOOMEWOOOOOOORDKK!~!@~~~

Name: Anonymous 2007-04-10 15:14 ID:zFywYjEm

DO IT IN C, CODE GODS! ENLIGHT OUR SOULS WITH THE FIRST LANGUAGE!

Name: Anonymous 2007-04-10 15:42 ID:AXCZaZK3

>>17
What kind of asshole using the dot operator with a space on each side?

You . Dumb

Name: Anonymous 2007-04-10 15:45 ID:1t3kJ6mu

>>29
If you don't put spaces it looks similar to using a function from an external module using its fully qualified name.

Name: Anonymous 2007-04-10 16:00 ID:Heaven

>>29
What kind of asshole using the pipe operator with a space on each side?

You | Dumb


What kind of asshole using the concatenation operator with a space on each side?

You ++ Dumb

What kind of asshole using the dollar sign operator with a space on each side?

You $ Dumb



What kind of asshole using the equals operator with a space on each side?

You = Dumb

Name: Anonymous 2007-04-10 16:29 ID:kbihfNmm

>>28
I did something similar to the OP's homework for a micro processor a few years back. How do I found old project?

Name: Anonymous 2007-04-10 16:46 ID:AXCZaZK3

wow..... I just realized the code posted is in Haskell.

I'm slow.

Name: Anonymous 2007-04-10 16:56 ID:Heaven

>>33
The most epic failure in the history of /prog/.

Name: Anonymous 2007-04-10 16:58 ID:AXCZaZK3

>>34
Sad part is I know Haskell.

It's been awhile.

Name: Anonymous 2007-04-10 18:17 ID:SVF9Hm6x

>>31
What kind of fucking idiot posts shit like this on /prog/ ?

Name: Anonymous 2007-04-10 18:21 ID:Heaven

>>17
What kind of fucking idiot posts shit like this on /prog/ ?

Name: Anonymous 2007-04-10 21:57 ID:Heaven

>>33
sup slowpoke

Name: Anonymous 2007-04-11 7:57 ID:vvxwPClh

NEEDS MORE ANSWERS

Name: Anonymous 2007-04-11 9:59 ID:iVmnI21Z

Run it with a filename as the command line argument.
import java.io.*;
import java.util.*;
public class YourHomework {
    private static final boolean flags[][]={
        {true,true,true,false,true,true,true},
        {false,false,true,false,false,true,false},
        {true,false,true,true,true,false,true},
        {true,false,true,true,false,true,true},
        {false,true,true,true,false,true,false},
        {true,true,false,true,false,true,true},
        {true,true,false,true,true,true,true},
        {true,false,true,false,false,true,false},
        {true,true,true,true,true,true,true},
        {true,true,true,true,false,true,true}
    };
    private static void printDigitLine(int n,int size,int line) {
        char l=' ',c=' ',r=' ';
        if (line==0) {
            if (flags[n][0]) c='-';
        } else if (line<=size) {
            if (flags[n][1]) l='|';
            if (flags[n][2]) r='|';
        } else if (line==size+1) {
            if (flags[n][3]) c='-';
        } else if (line<=2*size+1) {
            if (flags[n][4]) l='|';
            if (flags[n][5]) r='|';
        } else if (flags[n][6]) c='-';
        System.out.print(l);
        for (int i=0;i<size;i++) System.out.print(c);
        System.out.print(r);
    }
    public static void main(String args[]) {
        if (args.length==0) {
            System.out.println("must be run with a filename argument");
            return;
        }
        try {
            BufferedReader in=new BufferedReader(new FileReader(args[0]));
            String l;
            StringTokenizer t;
            int size;
            String digits;
            int maxperline;
            int lines;
            int bound;
            while ((l=in.readLine())!=null) {
                t=new StringTokenizer(l);
                size=Integer.parseInt(t.nextToken());
                digits=t.nextToken();
                maxperline=81/(size+3);
                lines=digits.length()/maxperline+1;
                for (int i=0;i<lines;i++) {
                    for (int j=0;j<2*size+3;j++) {
                        bound=Math.min(digits.length(),(i+1)*maxperline);
                        for (int k=i*maxperline;k<bound;k++) {
                            printDigitLine(digits.charAt(k)-'0',size,j);
                            if (k<bound-1) System.out.print(' ');
                        }
                        System.out.print('\n');
                    }
                    System.out.print('\n');
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}

Name: Anonymous 2007-04-11 10:10 ID:l4kB/YDN

>>40
Close, but I need it in Java 1.0

Thanks in advance!

Name: Anonymous 2007-04-11 10:24 ID:Heaven

>>40
Wow, that sucked.

Name: Anonymous 2007-04-11 13:13 ID:vvxwPClh

>>40

Fucking fail!

I'm just saying this because I can't read what the fuck you just did.
This is more illegible than my children's "essays"...

Name: Anonymous 2007-04-11 13:22 ID:Jd8hd+qd

>>40
You use too much whitespace. You can eliminate all whitespace after the control keywords to save space. Also, I recommend dropping all indentation. You remember Java doesn't have forced indentation, thread over?

Name: Anonymous 2007-04-11 14:13 ID:vvxwPClh

>>40

It doesn't respect the requests.

Name: Anonymous 2007-04-11 14:17 ID:Jd8hd+qd

>>45
No one does! NO ONE!

Name: Anonymous 2007-04-12 5:27 ID:h+JL7/nV

>>45
It's not fun if you do

Name: Anonymous 2007-04-12 10:52 ID:d3aWDEt+

>>40

I AM AN EXPERT PROGRAMMER, AND THIS IS A FINE SOLUTION.

Name: Anonymous 2007-04-12 12:42 ID:Us5SDvzA

IF U WERE KILLED TOMORROW IN BATTLE, I WOULDNT DINE IN HELL CUZ ID B IN JAIL 4 KILLIN DA PERSIAN WHO KILLED U!

    ======================[ >

    WE TRUE SPARTANS
    WE FIGHT TOGETHER
    WE DINE TOGETHER

    send this SPEAR to everyone you care about including me if you care. Count how many times you get this, if you get to 300, then you're A TRUE SPARTAN!

Name: Anonymous 2007-04-12 17:46 ID:fPKYZPA2

Oh and I forgot to mention that it has to be recursive.

Name: Anonymous 2007-04-12 17:51 ID:sQab9Y/f

>>50
Very well. The Haskell version is recursive.

Name: Anonymous 2007-04-12 19:51 ID:fPKYZPA2

>>51
Okay thank you. Now how do I run Haskell programs in Java?

Name: Anonymous 2007-04-12 20:00 ID:sQab9Y/f

>>52
Write a JVM bytecode compiler for Haskell.

Name: sage 2007-04-13 17:31 ID:Heaven

>>53
>>52
http://www.cs.rit.edu/~bja8464/lambdavm/

LambdaVM - The Haskell to Java Translator

Tell us how to install this.

Name: Anonymous 2010-11-19 18:13

>>3
SCHWEIG STILL SCHWEINHUND

Name: Anonymous 2011-02-03 0:13

Name: Anonymous 2012-03-25 10:16

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

Name: Sgt.Kabu埃ᘪkiman煏맡 2012-05-29 0:05

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List