LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 July 3 2010

Georges
Member

Quizz of the Day

Hello everyone... In this topic we'll be asking each other questions to test our skills.
Here are the rules:

1 - I ask the first question.
2 - The person who answers this question correctly will post another question and so on.
3 - Time will end every night at midnight.
4 - If no one answered correctly, the person who asked the question will select a person from those who answered to ask another question the next day.

- To make posts and Replies prettier, please use the "Quote" tag.
- Enumerate your questions and answers (example: Q1 - A1, Q1 - A2, Q2 - A5, ...)
- You may use hints and external links to help solve your question.

Okay, let's get started now...

Question 1:
What is the simple difference between the Bugatti Veyron and Jad Berro's Car?

Hints - The Veyron has a Top Speed of 401 Km/h, 1001 HP, and an 8.0 litre W16 engine with sixteen cylinders in two banks of eight, equivalent to two narrow-angle V8 engines mated in a "W" configuration.

Last edited by Yorgi (July 3 2010)

Offline

#2 July 3 2010

babum
Member

Re: Quizz of the Day

Question 1:

What is the simple difference between the Bugatti Veyron and Jad Berro's Car?

Hints - The Veyron has a Top Speed of 401 Km/h, 1001 HP, and an 8.0 litre W16 engine with sixteen cylinders in two banks of eight, equivalent to two narrow-angle V8 engines mated in a "W" configuration.

Answer 1:

Jad Berros car its quite slower, and its engine is not like the veyrons

Last edited by babum (July 3 2010)

Offline

#3 July 3 2010

Georges
Member

Re: Quizz of the Day

babum wrote:

Question 1:

What is the simple difference between the Bugatti Veyron and Jad Berro's Car?

Hints - The Veyron has a Top Speed of 401 Km/h, 1001 HP, and an 8.0 litre W16 engine with sixteen cylinders in two banks of eight, equivalent to two narrow-angle V8 engines mated in a "W" configuration.

Answer 1: Jad Berros car its quite slower, and its engine is not like the veyrons

No... Think Smarter, as a geek.

Last edited by Yorgi (July 3 2010)

Offline

#4 July 3 2010

crazy
Member

Re: Quizz of the Day

The color

Offline

#5 July 3 2010

Georges
Member

Re: Quizz of the Day

crazy wrote:

The color

No... It has nothing to do with the color, the shape, the power...
It's the Speed...

Offline

#6 July 3 2010

J4D
Member

Re: Quizz of the Day

A1

the Bugatti obviously lacks the geek  , on a more serious manner , a Bugatti drives you , while you drive the sirion , its a matter of soul over body

Offline

#7 July 3 2010

Georges
Member

Re: Quizz of the Day

------- Time is Up... --------

Here's the solution:
The Bugatti's top speed is 401 KM/h while Jad's car reached 140 KM/h. so, what makes the daihatsu a Bugatti ?

It's a Shift Register... (Shifting the top speed once to the right)

Jad's Turn.

Last edited by Yorgi (July 3 2010)

Offline

#8 July 3 2010

J4D
Member

Re: Quizz of the Day

Q2

lets learn some digital logic .

simple one

i have 3 rooms with 3 doors . one light bulb .

design a circuit that would light the bulb only if the three doors are closed . you can use switches or the minimal number of logic gates .

you can draw it and post it here , use normal logic , ill be giving the shortest answer later .

Offline

#9 July 4 2010

Ayman
Member

Re: Quizz of the Day

There you go :)
logick.png

Offline

#10 July 4 2010

arithma
Member

Re: Quizz of the Day

Or you can just connect the doors to close the circuit when they are themselves closed and avoid using transistor ICs altogether.

Offline

#11 July 4 2010

J4D
Member

Re: Quizz of the Day

arithma, i said digital logic :) and ayman's solution is correct :)

lets make this a bit tough .

I have 3 water tanks each with a sensor that goes high if the tank is empty .
design a circuit that would light an led on the left if any one of the tanks goes empty , the left and the middle LEDs if any two tanks are empty and the 3 LEDs if all tanks are empty . use the minimal number of logic gates possible or any decoder or multiplexer you might think of . you can research decoders and multiplexers.
happy solving !

Offline

#12 July 4 2010

arithma
Member

Re: Quizz of the Day

you can use switches or the minimal number of logic gates .

Fuck no, you ain't barring my simple door solution!

I put 6 switches. Three of them close in the existence of water, and the others in it's absence.
Call them A, B, C, D, E, F respectively.
Connect A, D, F in series, B, D, F in series, and C, E, F in series. Combine them all in parallel and complete the circuit with the one-filled-indicator LED.
You can another similar D, E, F switches and connect them in series and connect it to the All three are empty.
The two tank case requires something similar to the one LED thing, only using the reverse instead.

As for a digital circuit: Call the inputs: A, B, C. On if the tanks are empty.
LED1 = OR(A, B, C)
LED2 = [A AND OR(B, C)] OR AND(B, C)
LED3 = AND(A, B, C)

Offline

#13 July 4 2010

J4D
Member

Re: Quizz of the Day

arithma , gr8 logic ! :) but i will have to take a deeper look on what you wrote later  .

anyhow the best way to make this is using a 3 to 8 decoder with its output ORed .
gerorges2.jpg

Offline

#14 July 4 2010

Georges
Member

Re: Quizz of the Day

Jad... It's Ayman's Turn Now. Go ahead Ayman.

Another simpler solution for Q2...

26131779.png

Offline

#15 July 4 2010

Ayman
Member

Re: Quizz of the Day

Question 4:

Here is a little programming challenge, imagine you are working for the car registration authority. The new trend in license plates these days is that car numbers now are formed of 3 digits followed by 3 upper case letters for example: 007CAR. The assignment of License plates numbers is based ona first come first serve basis.

For example: The first customer will be assigned 000AAA, the second 000AAB and so on. Obviously, 000ABA comes after 000AAZ and 001AAA comes after 000ZZZ.

You are assigned to write a program, that gets the customers sequence (positive integer) number N and then prints out the respective plate number. When the sequence number exceeds the number of possible plates it should print: "Impossible".

For example: For N = 1 : 000AAA  (First customer)
                    For N = 65 : 000ACM
                    For N = 1000000 : Impossible

For now it is not that hard, but to make it challenging, you have to solve it in the most efficient way possible i.e. pure arithmetics with reliance on modding(%), division(/), addition, subtraction, and multiplication. No loops, if statements, recursive functions or any conditions.

All you can use is arithmetic operators to make out formulas that will lead to the correct output. To be able to work with incrementing the letters you need to rely on their ASCII value, so type casting from int to char and char to int is allowed. Only one if statement is allowed to be used, this is the condition in which you have to print "Impossible".

I hope you find this question fun, and I hope we can get to a solution. In case no one solves it after some time, I will post the solution. Have a good day :)

Last edited by Ayman (July 4 2010)

Offline

#16 July 4 2010

arithma
Member

Re: Quizz of the Day

Nice one ayman:
Solution written in pseudocode..

x: int input
s: string output

set s to ""
repeat three times{
 append ((char) (x % 26 + int('A'))) to s
 x /= 26
}
repeat three times{
 append ((char) (x % 10 + int('0'))) to s
 x /= 10
}
if x > 0 error "Impossible"

Offline

#17 July 4 2010

duckster
Member

Re: Quizz of the Day

ayman are you sure N=1mil is impossible?
it should be anything above 10*10*10*26*26*26 = 17,576,000

Offline

#18 July 4 2010

duckster
Member

Re: Quizz of the Day

In any case, I'm writing here a PHP code that would do what you asked.
I'm only missing echoing 'impossible' for values larger than 17576000 without a conditional

<?php

$customer_number = 65;
showplate($customer_number);

function showplate($customer_number) {
	$number = $customer_number-1;
	$plate=array();
	$plate[1]= floor(($number/(26*26*26*10*10))%10);
	$plate[2]= floor(($number/(26*26*26*10))%10);
	$plate[3]= floor(($number/(26*26*10))%10);
	$plate[4]= toletters(floor(($number/(26*26))%26));
	$plate[5]= toletters(floor(($number/26)%26));
	$plate[6]= toletters($number%26);
	$plate_number = implode($plate,"");
	echo $plate_number;
}

// this function prints the ascii value of the letters
function toletters($num) {
	return "&#".($num+65).";";
}

?>

Try changing $customer_number.
65 returns 000ACM
17576000 returns 999ZZZ

Last edited by duckster (July 4 2010)

Offline

#19 July 5 2010

Ayman
Member

Re: Quizz of the Day

Correct answer for both arithma and duckster although ducster you should have added one condition so that in case the number is above 17,576,000 it would print impossible just as arithma did but thats okay.

Good job guys, now it is your turn arithma or duckster :)

ayman are you sure N=1mil is impossible?
it should be anything above 10*10*10*26*26*26 = 17,576,000

Actually in the example I meant  1000,000,000 instead of 1000,000 it was a typo :)

Last edited by Ayman (July 5 2010)

Offline

#20 July 5 2010

arithma
Member

Re: Quizz of the Day

Reverse a single connected linked list. Best optimized algo (performance first, then memory usage) wins.

Offline

#21 July 5 2010

duckster
Member

Re: Quizz of the Day

airthma made use of recursive calls and conditionals, which you noted was prohibited :)
and the no-conditionals rule was behind the reason I didn't check for 'impossible' numbers

Offline

#22 July 5 2010

Ayman
Member

Re: Quizz of the Day

airthma made use of recursive calls and conditionals, which you noted was prohibited :)
and the no-conditionals rule was behind the reason I didn't check for 'impossible' numbers

The concept is correct though, I liked his idea 

If you look into my post, this is what I said:

Only one if statement is allowed to be used, this is the condition in which you have to print "Impossible".

Anyways, yours is correct, thanks for participating :)

Last edited by Ayman (July 5 2010)

Offline

#23 July 5 2010

MrClass
Member

Re: Quizz of the Day

yo ayman, guess we need to show the guys the correct answer (no loops, and pure algorithming (which excludes PHP built-in functions). So here it goes:

            int N = 0;
            int n1=0;
            int n2=0;
            int n3=0;
            int c1=65;
            int c2=65;
            int c3=65;
           
                N = "user entry" //may vary from language to language
               //assume we are using java:
                N=JOptionPane.showMessageInput("Enter a user number");
               
                    N=N-1;
                    c3=c3+N%26;
                    N=N/26;
                    c2=c2+N%26;
                    N=N/26;
                    c1=c1+N%26;
                    N=N/26;
                    n3=n3+N%10;
                    N=N/10;
                    n2=n2+N%10;
                    N=N/10;
                    n1=n1+N%10;
                    N=N/10;
                   
                    if(N>0)
                    {
                        System.out.println("IMPOSSIBLE");
                    }
                    else
                    {
                        System.out.println(n1+""+n2+""+n3+""+(char)c1+""+(char)c2+""+(char)c3);
                    }

Offline

#24 July 5 2010

Joe
Member

Re: Quizz of the Day

Wrong!!

What is the value of c3 if N = 10000 ?

Look at duckster's solution, you'll see what is wrong with yours . ;)

Offline

#25 July 5 2010

arithma
Member

Re: Quizz of the Day

OK, back to reversing a single linked list already?

Here's a naive implementation that you should not put in:

define node as {int data; ref node next;} // contains a data member and a reference to the next node

void reverse_list(ref node n){
  ref node current = break_last(n); // declaration
  while( (ref node last = break_last(n)) != null ){
    current.next = last;
    current = last;
  }
}

ref node break_last(ref node n){
  while(n.next != null && n.next.next != null) n = n.next;

  if(n.next == null) return n;
  
  ref node result = n.next;
  n.next = null;
  return result;
}

Last edited by arithma (July 5 2010)

Offline

Board footer