vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Community Lounge (https://vborg.vbsupport.ru/forumdisplay.php?f=13)
-   -   This see who the smart ones are (https://vborg.vbsupport.ru/showthread.php?t=285492)

ForceHSS 07-13-2012 04:01 AM

This see who the smart ones are
 
Question: Given an unsorted array of integers, find any 3 numbers that will add up to 100. For example, if the array has -77, 55, 22, 0, 2, and 155, one answer would be -77, 22, and 155.

ForceHSS 07-15-2012 04:23 PM

Looks like no smart people here

Paul M 07-15-2012 04:43 PM

The smart ones avoided wasting their time on something they have no need of. ;)

BirdOPrey5 07-15-2012 05:12 PM

Step 1: Randomly pick 3 numbers from the array
Step 2: Do they add to 100?
If Yes, DONE.
If No, go to step 1.

What do I win?

ForceHSS 07-16-2012 03:36 AM

Quote:

Originally Posted by BirdOPrey5 (Post 2348380)
Step 1: Randomly pick 3 numbers from the array
Step 2: Do they add to 100?
If Yes, DONE.
If No, go to step 1.

What do I win?

I still don't see your answer. You have just given a question and answered yourself

BirdOPrey5 07-16-2012 09:38 AM

I gave the answer is pseudo-code. You didn't specify it needed to be in particular language. An algorithm is generally acceptable in computer science as anyone with a basic understanding of a language can easily convert it.

Azhrialilu 07-16-2012 10:27 AM

It involves numbers... I generally avoid anything involving numbers. Words are my thing. I can barely add up using a calculator :D

ForumsMods 07-17-2012 01:38 AM

It reminds me of college exercises and Facebook Hacker Cup.
PHP Code:

<?php

$array 
= array(-77552202155);
sort($array);

$i $j $k 0;
$number 100;
$found false;

foreach(
$array AS $i => $value)
{
    
$j $i 1;
    
$k count($array) - 1;

    while (
$j $k)
    {
        
$sum $array[$i] + $array[$j] + $array[$k];

        if (
$sum $number)
        {
            
$k--;
        }
        else if (
$sum $number)
        {
            
$j++;
        }
        else
        {
            
$found true;
            break 
2;
        }
    }
}

if (
$found)
{
    echo 
"It is possible. The numbers are: " $array[$i] . ", " $array[$j] . ", " $array[$k];
}
else
{
    echo 
"It is not possible.";
}


Shazz 07-17-2012 02:01 AM

Is it a homework question? :p

ForceHSS 07-18-2012 12:40 AM

Quote:

Originally Posted by Shazz (Post 2348824)
Is it a homework question? :p

It is for a job with very good pay. Was just seeing if anyone could work it out but have already been pmed with the correct answer and am now it talks with the member

Ziki 07-18-2012 11:14 AM

Quote:

Originally Posted by ForceHSS (Post 2349113)
It is for a job with very good pay. Was just seeing if anyone could work it out but have already been pmed with the correct answer and am now it talks with the member

Your post made me LOL

ForceHSS 07-18-2012 02:28 PM

Quote:

Originally Posted by Ziki (Post 2349228)
Your post made me LOL

If you found out the pay it would stop

socialteenz 07-18-2012 06:17 PM

Quote:

Originally Posted by ForceHSS (Post 2349264)
If you found out the pay it would stop

How much are people paying for this kind of tasks? :o

Ziki 07-18-2012 07:16 PM

Quote:

Originally Posted by socialteenz (Post 2349322)
How much are people paying for this kind of tasks? :o

I don't know how much a bit of logical thinking and common sense is worth these days, but it would surely make me stop laughing ;)







or not...:D

kh99 07-18-2012 07:49 PM

When I google the question, I find that it's a question that Facebook has asked while interviewing potential engineers. There are also lot of potential solutions, including the one ForumsMods posted above (which is an algorithm called 3SUM, http://en.wikipedia.org/wiki/3SUM). I think the point of the question is recognizing that the obvious solution (adding together every combination of 3 numbers) is not an efficient algorithm compared to other ways of doing it. I think if I wanted to hire a good software engineer I might ask some similar questions, but I'd probably wait until the interview or at least pick one that couldn't be solved so easily using a search engine.

Sarteck 07-25-2012 10:10 AM

What ALSO floats in water?

08-01-2012 06:40 PM

Have anyone give the right answer yet? I will be honest, it is even hard for me too but Im not sure about the 155...


All times are GMT. The time now is 04:45 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01202 seconds
  • Memory Usage 1,760KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (17)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete