₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,273 members, 8,421,090 topics. Date: Friday, 05 June 2026 at 06:43 PM

Toggle theme

Javanian's Posts

Nairaland ForumJavanian's ProfileJavanian's Posts

1 2 3 4 5 6 7 8 ... 41 42 43 44 45 46 47 48 49 (of 57 pages)

ProgrammingRe: Another Programming Challenge by Javanian: 8:36am On Sep 28, 2012
^ i suggest you remove this one until some one comes up with a solution to the former...so that we dont derail the thread...

For the former can i read it in parts, lets say 100kb until the file is exhausted?
ProgrammingRe: Another Programming Challenge by Javanian: 8:13pm On Sep 27, 2012

import java.util.*;
import java.io.*;
public class ReadFile
{
static List list;

public static void main(String[] args)
{
Scanner read = new Scanner(System.in);
System.out.println("Enter the number of lines (k) you want to print"wink;
int k = read.nextInt();

list = new ArrayList();
File file = new File(args[0]);

try
{
FileReader fr = new FileReader(file);
BufferedReader in = new BufferedReader(fr);
String s;

//read each line from the file
s = in.readLine();

while(s!=null)
{

list.add(s);
s = in.readLine();
}
in.close();

}
catch(Exception ex)
{
ex.printStackTrace();
}
printRandom(k);
}

public static void printRandom(int k)
{
long i = Math.round(Math.random()*list.size());

if(k<=list.size())
{
for(int m =0; m<k; m++)
{
System.out.println("Read:" + list.get((int)(i)));
i = Math.round(Math.random()*list.size());
}
}
else
{
System.out.println("No of Lines too much..."wink;
System.exit(0);
}

}

}
ProgrammingRe: Another Programming Challenge by Javanian: 12:32pm On Sep 27, 2012
If k =3 and the file contains 100 lines...should the printed lines follow each other e.g line 50,51 and 52 or it can be any 3 random lines e.g. 3,45, 82 ??
ProgrammingRe: Programming Challenge by Javanian: 11:01am On Sep 27, 2012
Can some start a thread with a new challenge...i learnt alot from this one...
ProgrammingRe: Programming Challenge by Javanian: 7:37am On Sep 26, 2012
mkwayisi: Well this is getting interesting. I have my code too in C on a single line. Now don't tell me about readability, you asked for it wink Perhaps you can write a shorter one with no lines at all wink
int main(int i,char**v){if(i>1){int c[26];char *p=v[1];for(i=0;i<26winkc[i++]=0;while(*p!='\0'){if(*p>=97&&*p<=122)*p-=32;if(*p>=65&&*p<=90)c[*p-65]++;p++;}for(i=0;i<26;i++)if(c[i]>0)printf("%cs=%d\n",i+65,c[i]);}return 0;}

After compiling, launch the exe passing the sentence as an argument. A screenshot is shown below.
u don high?
PoliticsRe: Anti-Islam Movie Demonstration In Kaduna by Javanian: 5:22pm On Sep 24, 2012
hmmm
EducationRe: World's Smallest Girl Starts School by Javanian: 10:53am On Sep 24, 2012
See how she is loved by her parents despite her deficiency. She is lucky she is not a Nigerian, they would have killed her after birth and say it is the work of witches and wizards or she is an ogbanje (evil child)
ProgrammingRe: Programming Challenge by Javanian: 11:28pm On Sep 22, 2012
http://pastebin.ca/2206823

15 lines...this is the best i can go...
ProgrammingRe: Programming Challenge by Javanian: 9:10pm On Sep 22, 2012
^ I will like to see it...so you still dey this forum?
ProgrammingRe: Programming Challenge by Javanian: 7:37pm On Sep 22, 2012
₱®ÌИСΞ:
. i had implemented this in python before asking and it occupied far less lines...
doing this in a language like python or PHP will take far more less lines..
ProgrammingRe: A Problem In Class by Javanian: 6:19pm On Sep 22, 2012
^ With due respect sir, whether he is new to java or not, am sure he was taught something similar before he was given that assingment...he souned more like he wanted to see the code than a guide...
ProgrammingRe: Programming Challenge by Javanian: 6:09pm On Sep 22, 2012
naija_swag: The number of lines of your code does not determine how efficient it is.I will rather code for shorter running time than for shorter lines of code.
i know that but he was more interested in the number of lines so i wanted to prove to him that i can get it done in fewer lines...tongue
ProgrammingRe: Programming Challenge by Javanian: 6:01pm On Sep 22, 2012
@otuabaroku I used a char array to compare it with the letter of the alphabets...

By the way, i will sue you for plagiarism grin...you wrote another version of my code grin...dont you know that code has a patent grin...we will see in court!...lol...just kidding...You did a great job...
ProgrammingRe: A Problem In Class by Javanian: 4:04pm On Sep 22, 2012
No! angry try it no matter how stupid...
ProgrammingRe: Programming Challenge by Javanian: 4:02pm On Sep 22, 2012
http://pastebin.ca/2206725

The same code in 66 lines grin
ProgrammingRe: A Problem In Class by Javanian:
Na Lie!... angry...Nobody will help you do your assignment...Attempt it and if you have any error post your code...
ProgrammingRe: Programming Challenge by Javanian: 3:35pm On Sep 22, 2012
and don't count it like that, i can easily remove 30 lines without actually adding or subtracting any code... grin
ProgrammingRe: Programming Challenge by Javanian: 3:33pm On Sep 22, 2012
Thanks but its actually 135 lines grin dont count the space..
ProgrammingRe: Programming Challenge by Javanian: 2:45pm On Sep 22, 2012
I did this in a hurry its quite lengthy but it works

http://pastebin.ca/2206694

I'll see if i can write a shorter version...
ProgrammingRe: Anonymous Functions/ Lambda Functions by Javanian: 9:19am On Sep 21, 2012
^ Thanks a million
ProgrammingRe: Anonymous Functions/ Lambda Functions by Javanian: 9:12am On Sep 21, 2012
Thanks, but can i see a java version of the g function?
ProgrammingRe: Anonymous Functions/ Lambda Functions by Javanian: 8:33am On Sep 21, 2012
Could you throw more light
WebmastersRe: Broke Professional Webmaster: Should I Change Career? by Javanian: 10:09am On Sep 19, 2012
Revealedtv: I share you pain brother. See some sites I've created and a brother is still dry. This freelance thing no dey work:
http://www.pressoncampus.com
http://www.docmission.com
http://www.versadesignstudio.com
http://www.qlnggroup.com
http://www.movingtrainent.com
http://www.nedcomoaks.com
Again..None of your sites have a mobile version...Be professional in what you do...
WebmastersRe: Broke Professional Webmaster: Should I Change Career? by Javanian: 9:56am On Sep 19, 2012
None of your sites have a mobile version...
Art, Graphics & VideoRe: Web Banner Design Contest (154x95 Pixel Format) by Javanian: 8:35pm On Sep 18, 2012
Yes o!...i am one of the judges grin...and so far only one person on this thread knows what he is doing...may be seun should translate it to pidgin...
Art, Graphics & VideoRe: Web Banner Design Contest (154x95 Pixel Format) by Javanian: 8:21pm On Sep 18, 2012
Nawa o!...It seems most people on this thread dont understand simple english...
CultureRe: What People Think About Certain Reflex Behaviours. by Javanian: 9:53pm On Sep 16, 2012
smh...if you lie on your back problem, lie on your left problem, lie on your right problem, lie on your front problem, make we float for air? grin
ProgrammingRe: Is Something Wrong With This Code by Javanian: 8:28pm On Sep 14, 2012
lol grin

1 2 3 4 5 6 7 8 ... 41 42 43 44 45 46 47 48 49 (of 57 pages)