• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:01
CEST 14:01
KST 21:01
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
ZeroSpace Early Access is Now Live!19Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters2Balance hotfix patch 5.0.16b (July 16)88Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!18
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) How would you feel about frequent/monthly balance patches for SC2? Clem: "I don't have that much hope in Blizzard" Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters [D] Wireframe Casting Removed
Tourneys
IntoTheTV X SOOP SC2 League : Weekly & Monthly INu's Battles#18 - Cure, herO, Rogue & ByuN RSL Revival: Season 6 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026
Strategy
[G] Having the right mentality to improve
Custom Maps
[M] (2) Industrial Park New Map Maker - Looking for Advice - Love or Hate
External Content
Mutation # 535 Assembly of Vengeance The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Animated Gateway BW General Discussion HORROR STARCRAFT MOVIE How Famous was FlaSh before his Debut?
Tourneys
Escore Tournament - Season 3 [Megathread] Daily Proleagues [IPSL] Spring 2026 Grand Finals - This Weekend! Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers PvT advise for noobs Fighting Spirit mining rates Creating a full chart of Zerg builds
Other Games
General Games
Path of Exile ZeroSpace Early Access is Now Live! Nintendo Switch Thread General RTS Discussion Thread Diablo IV
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Artificial Intelligence Thread US Politics Mega-thread Russo-Ukrainian War Thread How to buy a book - shipping from Korea to Europe The Games Industry And ATVI
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Anime Discussion Thread Series you have seen recently... Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
How Games can Help with Majo…
TrAiDoS
Hello guys!
LIN1s
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
An Exploration of th…
waywardstrategy
Customize Sidebar...

Website Feedback

Closed Threads



Active: 4119 users

The Big Programming Thread - Page 471

Forum Index > General Forum
Post a Reply
Prev 1 469 470 471 472 473 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
berated-
Profile Blog Joined February 2007
United States1134 Posts
April 26 2014 18:53 GMT
#9401
On April 26 2014 17:22 norlock wrote:
Show nested quote +
On April 25 2014 17:49 SilverSkyLark wrote:
Hi guys Android/Java question here. I managed to set onClickListeners for my AutocompleteTextViews (ACTV) by setting it in my Java code instead of my XML one. However, my issue now is that whenever I click on any of my ACTVs, I have to click it again before the onClickFunction fires successfully.

In my onCreate, I initialize my ACTVs as such:


brandACTV = (AutoCompleteTextView) findViewById(R.id.actvBrand);
itemACTV = (AutoCompleteTextView) findViewById(R.id.actvItemName);
partACTV = (AutoCompleteTextView) findViewById(R.id.actvPart);
barcodeACTV = (AutoCompleteTextView) findViewById(R.id.actvBarcode);

brandACTV.setOnClickListener(actvClicked);
itemACTV.setOnClickListener(actvClicked);
partACTV.setOnClickListener(actvClicked);
barcodeACTV.setOnClickListener(actvClicked);


and I create my onClickListener function as such:


OnClickListener actvClicked = new OnClickListener(){
@Override
public void onClick(View view){
switch (view.getId()) {
case R.id.actvBrand:
Log.d("Hi", "Brand pressed");
break;

case R.id.actvItemName:
Log.d("Hi", "Item name pressed");
break;

case R.id.actvPart:
Log.d("Hi", "Part pressed");
break;

case R.id.actvBarcode:
Log.d("Hi", "Barcode pressed");
break;
}
}
};


Any ideas anyone?


your code is wrong. You can't use it on a anonymous class, you need to create a private class. example from internet.

package com.example.android.accelerometerplay;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import android.content.Context;

public class StudentFormsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// To specify the actions of the Buttons
Button accept = (Button) findViewById(R.id.myButton1);
Button reject = (Button) findViewById(R.id.myButton2);

accept.setOnClickListener(clickFunction);
reject.setOnClickListener(clickFunction);
}

private OnClickListener clickFunction = new OnClickClass();

private class OnClickClass implements OnClickListener{
public void onClick(View v){
Context context = getApplicationContext();
CharSequence text;

switch(v.getId()){
case R.id.myButton1: text="accept was pushed";
break;
case R.id.myButton2: text="reject was pushed";
break;
default: text="We didn't know what was pressed :(";
}

int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context,text,duration);
toast.show();

}
}
}



I think he stated already that the problem was something else, but even if not, this advice is wrong. The only difference between the anonymous inner class and a named innerclass is that you can construct a named inner class more than once.
Epishade
Profile Blog Joined November 2011
United States2267 Posts
April 27 2014 02:55 GMT
#9402
Hey guys, got a small question here in search of a better way of coding something.

What I'm doing here in this code is I'm checking whether the codedPinArray value at slot k matches the value for the code array at the slot of pinArray at value k. I got it all synced up and stuff, which took me a while to wrap my head around nesting an array inside an array, so that's not a problem.

Here be code:

+ Show Spoiler +
for (int k = 0; k < 5; k++)
{
if (codedPinArray[k] == code[pinArray[k]])
{
isMatch = true;
}
}


What I want to do is have this code go through each number and, if each number matches, set (bool) isMatch equal to true. The problem is, if any of the 5 numbers match, even if the other 4 or so don't, it will still set isMatch = true. I want it so that only is all the numbers match, isMatch = true.

I know I can do this if I did this instead:

+ Show Spoiler +
if (codedPinArray[0] == code[pinArray[0]] &&
codedPinArray[1] == code[pinArray[1]] &&
codedPinArray[2] == code[pinArray[2]] &&
codedPinArray[3] == code[pinArray[3]] &&
codedPinArray[4] == code[pinArray[4]])
{
isgood = true;
}


That'll work fine for my purposes on this assignment I've got. There's nothing saying I can't do that, but I was just wondering if there was a better way. Like, what if I had to check matches for a thousand values in the array or something? How might I use that in the for loop above? Thanks.
Pinhead Larry in the streets, Dirty Dan in the sheets.
Ben...
Profile Joined January 2011
Canada3485 Posts
Last Edited: 2014-04-27 03:23:03
April 27 2014 03:03 GMT
#9403
One idea would be to create to create a boolean array in which each index lines up with your code/codedPinArray indices. If the two array items match, the matching boolean array index is set to true. Then to solve your issue of if they all match, just have a loop of some type that checks if all entries in the boolean array are true. If one is false, set a separate boolean variable to false and return that instead. It's also handy because if a set doesn't match, you can always output the results of the boolean array to find which don't match.

Like so (I'm attempting to do this in C++, but my C++ is super rusty so it is kinda pseudocody. You should get what I mean though):


bool isMatched[5];

for (int k = 0; k < 5; k++)
{
if (codedPinArray[k] == code[pinArray[k]])
{
isMatched[k] = true;
}

}
bool allMatch = true;

for (int i = 0; i < 5; i++)
{
if (!isMatched[i]) allMatch = false; // can also use isMatched[i] == false in the if statement
}
"Cliiiiiiiiiiiiiiiiide" -Tastosis
Epishade
Profile Blog Joined November 2011
United States2267 Posts
Last Edited: 2014-04-27 03:29:40
April 27 2014 03:10 GMT
#9404
Great idea! Thanks. Never had to use a bool array before but I think this should work just fine.

Edit: Actually I just thought of an easier way without using bool arrays.

I can increase the count of something each time that number matches. Then if that count is == 5, I will know that the numbers match.

Something like this

+ Show Spoiler +

int amount = 0;
for (int k = 0; k < 5; k++)
{
if (codedPinArray[k] == code[pinArray[k]])
{
amount++;
}
}

if (amount == 5)
{
//do this
}
Pinhead Larry in the streets, Dirty Dan in the sheets.
Mstring
Profile Joined September 2011
Australia510 Posts
April 27 2014 04:53 GMT
#9405
Since your success condition is all matching elements, you only need to find a single mismatch to know the condition cannot be met. If you have a million pairs and the first doesn't match then you can stop right away.


bool allMatch = true;
for (int k = 0; k < CODE_SIZE; k++)
{
if (codedPinArray[k] != code[pinArray[k]])
{
allMatch = false;
break;
}
}

if (allMatch)
{
takeAction();
}
Ben...
Profile Joined January 2011
Canada3485 Posts
April 27 2014 06:01 GMT
#9406
On April 27 2014 13:53 Mstring wrote:
Since your success condition is all matching elements, you only need to find a single mismatch to know the condition cannot be met. If you have a million pairs and the first doesn't match then you can stop right away.


bool allMatch = true;
for (int k = 0; k < CODE_SIZE; k++)
{
if (codedPinArray[k] != code[pinArray[k]])
{
allMatch = false;
break;
}
}

if (allMatch)
{
takeAction();
}

That's even easier. Good idea. I've had my head stuck in data structures for too long and have a tendency to complicate things a bit too much. Stupid shortest path algorithms and things like that can use boolean arrays.

I guess my solution is more useful for finding pairs that don't match.
"Cliiiiiiiiiiiiiiiiide" -Tastosis
shem
Profile Joined March 2010
United States7 Posts
April 27 2014 06:03 GMT
#9407

bool isMatch = true;
for (int k = 0; k < 5; k++) {
isMatch = isMatch && (codedPinArray[k] == code[pinArray[k]]);
}


These things always turn into code golf
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2014-04-27 06:45:39
April 27 2014 06:41 GMT
#9408
Extract a function from Mstring's solution and you have a very clear piece of code:
bool PinArraysMatch(int[] codedPinArray, int[] pinArray, int[] code, int length)
{
for(int k = 0; k < length; ++k)
{
if(codedPinArray[k] != code[pinArray[k]])
{
return false;
}
}
return true;
}


This actually closely resembles functions like Linq's All() or Any() (based on an enumeration of ints from 0 to length). So if your language supports lambdas, chances are there already is a function that does exactly what you want if you give it the right input.
In short: Any() and All() check whether a condtion holds true for any or all elements in a list of elements, and that's exactly what you want to know: Are there any elements that don't match. You just have to create the list properly.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17799 Posts
April 27 2014 07:26 GMT
#9409
On April 27 2014 15:41 spinesheath wrote:
Extract a function from Mstring's solution and you have a very clear piece of code:
bool PinArraysMatch(int[] codedPinArray, int[] pinArray, int[] code, int length)
{
for(int k = 0; k < length; ++k)
{
if(codedPinArray[k] != code[pinArray[k]])
{
return false;
}
}
return true;
}


This actually closely resembles functions like Linq's All() or Any() (based on an enumeration of ints from 0 to length). So if your language supports lambdas, chances are there already is a function that does exactly what you want if you give it the right input.
In short: Any() and All() check whether a condtion holds true for any or all elements in a list of elements, and that's exactly what you want to know: Are there any elements that don't match. You just have to create the list properly.


Any() and All() won't do. I think that the order here is important, if it wasn't he would use foreach instead of for.
Time is precious. Waste it wisely.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 27 2014 08:16 GMT
#9410
var hasMismatch = Enumerable.Range(0, length).Any(k => codedPinArray[k] != code[pinArray[k]]);

You can't enumerate directly on the arrays, but you can enumerate on the index.

You could also create a sequence of pairs at first and then call Any() on that, like this:
IEnumerable<Tuple<int, int>> GetPairSequence(int[] codedPinArray, int[] pinArray, int[] code)
{
for(int k = 0; k < codedPinArray.Length; ++k)
{
yield return Tuple.Create(codedPinArray[k], code[pinArray[k]]);
}
}
...
var hasMismatch = GetPairSequence.Any(pair => pair.Item1 != pair.Item2);

But I would only really do that if there were other places that could make use of the sequence of pairs. Also C#'s Tuple class is really awkward, I'd prefer not to use it at all. "Item1" and "Item2" isn't exacly self-documenting code.
If you have a good reason to disagree with the above, please tell me. Thank you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-04-27 14:10:26
April 27 2014 13:05 GMT
#9411
code golf! using mismatch and a lambda. hoping i understood the problem.


typedef array<int,5> array_t;

//dummy variables
array_t pin{0,1,2,3,4};
array_t code{4,3,2,1,0};
array_t coded_pin{4,3,2,1,0};

bool match=mismatch(
begin(coded_pin),
end(coded_pin),
begin(pin),
[&code](int const& coded_pin_digit,int const& code_idx){
return coded_pin_digit==code[code_idx];
}
).first==end(coded_pin);

conspired against by a confederacy of dunces.
novaballistix
Profile Joined December 2006
Australia113 Posts
April 27 2014 17:53 GMT
#9412
Hi all,

I've got some coding homework to design an acoustic sensor. When it detects noise level changes, it sends notifications to all devices listening to it. There are 2 other devices listening, which include a warning light and a self destruct, which both due their own thing depending on the noise level. I'm trying to approach this problem in OOP, but have trouble thinking in abstract. I have narrowed down the "classes" as nouns, which are the sensor, warning light and self destruct device, and can list their responsibilities. Any hints on what I can do next, or even design patterns that I can follow would be greatly appreciated.

I am coding in C#.net.

Thanks!
norlock
Profile Joined March 2010
Netherlands918 Posts
April 27 2014 18:11 GMT
#9413
On April 27 2014 03:53 berated- wrote:
Show nested quote +
On April 26 2014 17:22 norlock wrote:
On April 25 2014 17:49 SilverSkyLark wrote:
Hi guys Android/Java question here. I managed to set onClickListeners for my AutocompleteTextViews (ACTV) by setting it in my Java code instead of my XML one. However, my issue now is that whenever I click on any of my ACTVs, I have to click it again before the onClickFunction fires successfully.

In my onCreate, I initialize my ACTVs as such:


brandACTV = (AutoCompleteTextView) findViewById(R.id.actvBrand);
itemACTV = (AutoCompleteTextView) findViewById(R.id.actvItemName);
partACTV = (AutoCompleteTextView) findViewById(R.id.actvPart);
barcodeACTV = (AutoCompleteTextView) findViewById(R.id.actvBarcode);

brandACTV.setOnClickListener(actvClicked);
itemACTV.setOnClickListener(actvClicked);
partACTV.setOnClickListener(actvClicked);
barcodeACTV.setOnClickListener(actvClicked);


and I create my onClickListener function as such:


OnClickListener actvClicked = new OnClickListener(){
@Override
public void onClick(View view){
switch (view.getId()) {
case R.id.actvBrand:
Log.d("Hi", "Brand pressed");
break;

case R.id.actvItemName:
Log.d("Hi", "Item name pressed");
break;

case R.id.actvPart:
Log.d("Hi", "Part pressed");
break;

case R.id.actvBarcode:
Log.d("Hi", "Barcode pressed");
break;
}
}
};


Any ideas anyone?


your code is wrong. You can't use it on a anonymous class, you need to create a private class. example from internet.

package com.example.android.accelerometerplay;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import android.content.Context;

public class StudentFormsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// To specify the actions of the Buttons
Button accept = (Button) findViewById(R.id.myButton1);
Button reject = (Button) findViewById(R.id.myButton2);

accept.setOnClickListener(clickFunction);
reject.setOnClickListener(clickFunction);
}

private OnClickListener clickFunction = new OnClickClass();

private class OnClickClass implements OnClickListener{
public void onClick(View v){
Context context = getApplicationContext();
CharSequence text;

switch(v.getId()){
case R.id.myButton1: text="accept was pushed";
break;
case R.id.myButton2: text="reject was pushed";
break;
default: text="We didn't know what was pressed :(";
}

int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context,text,duration);
toast.show();

}
}
}



I think he stated already that the problem was something else, but even if not, this advice is wrong. The only difference between the anonymous inner class and a named innerclass is that you can construct a named inner class more than once.


http://stackoverflow.com/questions/9017374/private-onclicklistener-clickfunction-new-onclicklistenerstmt <-- This is why you do it. you put multiple objects, on a class so STILL USE A PRIVATE CLASS! And you don't construct a class more than once but objects.
Are you human?
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 27 2014 18:12 GMT
#9414
On April 28 2014 02:53 novaballistix wrote:
Hi all,

I've got some coding homework to design an acoustic sensor. When it detects noise level changes, it sends notifications to all devices listening to it. There are 2 other devices listening, which include a warning light and a self destruct, which both due their own thing depending on the noise level. I'm trying to approach this problem in OOP, but have trouble thinking in abstract. I have narrowed down the "classes" as nouns, which are the sensor, warning light and self destruct device, and can list their responsibilities. Any hints on what I can do next, or even design patterns that I can follow would be greatly appreciated.

I am coding in C#.net.

Thanks!

I suggest you look up C# events and/or the INotifyPropertyChanged interface.
If you have a good reason to disagree with the above, please tell me. Thank you.
novaballistix
Profile Joined December 2006
Australia113 Posts
April 27 2014 18:31 GMT
#9415
On April 28 2014 03:12 spinesheath wrote:
Show nested quote +
On April 28 2014 02:53 novaballistix wrote:
Hi all,

I've got some coding homework to design an acoustic sensor. When it detects noise level changes, it sends notifications to all devices listening to it. There are 2 other devices listening, which include a warning light and a self destruct, which both due their own thing depending on the noise level. I'm trying to approach this problem in OOP, but have trouble thinking in abstract. I have narrowed down the "classes" as nouns, which are the sensor, warning light and self destruct device, and can list their responsibilities. Any hints on what I can do next, or even design patterns that I can follow would be greatly appreciated.

I am coding in C#.net.

Thanks!

I suggest you look up C# events and/or the INotifyPropertyChanged interface.


I forgot to mention that I am unable to use the event keyword. I dont think I can use INotigyPropertyChanged as it uses the PropertyChanged Event. Correct me if i'm wrong, thanks
supereddie
Profile Joined March 2011
Netherlands151 Posts
April 27 2014 18:59 GMT
#9416
On April 28 2014 03:31 novaballistix wrote:
Show nested quote +
On April 28 2014 03:12 spinesheath wrote:
On April 28 2014 02:53 novaballistix wrote:
Hi all,

I've got some coding homework to design an acoustic sensor. When it detects noise level changes, it sends notifications to all devices listening to it. There are 2 other devices listening, which include a warning light and a self destruct, which both due their own thing depending on the noise level. I'm trying to approach this problem in OOP, but have trouble thinking in abstract. I have narrowed down the "classes" as nouns, which are the sensor, warning light and self destruct device, and can list their responsibilities. Any hints on what I can do next, or even design patterns that I can follow would be greatly appreciated.

I am coding in C#.net.

Thanks!

I suggest you look up C# events and/or the INotifyPropertyChanged interface.


I forgot to mention that I am unable to use the event keyword. I dont think I can use INotigyPropertyChanged as it uses the PropertyChanged Event. Correct me if i'm wrong, thanks

In that case you can take a look at Action<> and Func<>
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
April 27 2014 19:36 GMT
#9417
On April 28 2014 03:31 novaballistix wrote:
Show nested quote +
On April 28 2014 03:12 spinesheath wrote:
On April 28 2014 02:53 novaballistix wrote:
Hi all,

I've got some coding homework to design an acoustic sensor. When it detects noise level changes, it sends notifications to all devices listening to it. There are 2 other devices listening, which include a warning light and a self destruct, which both due their own thing depending on the noise level. I'm trying to approach this problem in OOP, but have trouble thinking in abstract. I have narrowed down the "classes" as nouns, which are the sensor, warning light and self destruct device, and can list their responsibilities. Any hints on what I can do next, or even design patterns that I can follow would be greatly appreciated.

I am coding in C#.net.

Thanks!

I suggest you look up C# events and/or the INotifyPropertyChanged interface.


I forgot to mention that I am unable to use the event keyword. I dont think I can use INotigyPropertyChanged as it uses the PropertyChanged Event. Correct me if i'm wrong, thanks

Well, in that case you just code that behaviour yourself. Seems like that's the goal of the exercise...
Check out the Observer and Publish/Subscribe patterns.
If you have a good reason to disagree with the above, please tell me. Thank you.
cilinder007
Profile Joined August 2010
Slovenia7251 Posts
April 27 2014 23:34 GMT
#9418
I have a programming challenge I can't quite seem to get the right awnser to, it goes like this

You were hired by a director of a small company with N employees to set up the network between the employees who have to send a weekly report to each of the other employees as a different part or their report is important for each employee, depending on the importance of their work they have to send a report Ki number of times per week
You have measured the time it takes for a message to be delivered between each 2 employees
Due to budget cuts the network will only have N-1 connections between they employees and because of the simplicity of the technology you are using when one message is sent the entire network has to wait for it to be delivered (only 1 message at a time)
What you get is N -the number of employees, you get Ki which is the muber of times a report from worker i is to be sent per week, Tij which indicates the time a message traveles from employee i to employee j
1<=N<=13
0<=Ki<=10^3
0<=Tij<=10^3
Tij = Tji, Tii = 0

At first I assumed the most optimal network would be a star (tree) and all it would take is to determine which node to be in the center and since we were limited to an N at most 13 I decided to just brute force it and try them all, but that attempt failed as apparently this was not the most optimal network configuration (or so the test cases showed me)
Then I thought maybe this would be solved by finding a minimum spanning tree or each full graph made from the employees, but since there are multiple minimum spanning trees and not all of them are equaly good for this problem that failed on paper already

I am currently a bit out of ideas, so a hint as to what direction I should be looking towards would be great
supereddie
Profile Joined March 2011
Netherlands151 Posts
April 28 2014 15:31 GMT
#9419
Maybe I'm stupid, but I don't understand the programming challenge here.
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2014-04-29 17:33:55
April 28 2014 17:33 GMT
#9420
If my resulting graph has no edge from employee a to employee b, but edges from a to c and from c to b, is the time from a to b defined as Tab or as Tac + Tcb?

Our graph is always a tree. It has to be connected or else one employee couldn't message everyone else. It has N nodes and N-1 edges. Therefore it is a tree, and we are most likely looking for a Minimum Spanning Tree by some weight function we don't know yet.

We know that in our resulting tree, every edge is used Sum Ki = K times to send all messages since each employee a recieves Kb messages from each other emplyee b and sends Ka messages himself.That's wrong, explanation in another post.

It seems fairly obvious that we need to weigh the edges by a combination of Tij and Ki. But since each edge is used K times, maybe Ki actually isn't relevant at all.
If you have a good reason to disagree with the above, please tell me. Thank you.
Prev 1 469 470 471 472 473 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Summer Champion…
12:00
Summer Cup Group C
LiquipediaDiscussion
CrankTV Team League
11:00
Crank Gathers S4: Playoffs
LiquipediaDiscussion
KCM Race Survival
10:00
2026 Season 3 Week 3
Kim Chul Min (afreeca) 1594
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko448
RotterdaM 223
Rex 37
StarCraft: Brood War
Rain 5634
Calm 4415
910 2285
BeSt 2188
Bisu 1264
Zeus 1014
Jaedong 753
firebathero 610
Horang2 590
Mini 413
[ Show more ]
EffOrt 315
Soma 255
Soulkey 223
Snow 213
Light 204
Stork 174
actioN 159
Last 119
Hyun 111
Rush 110
Dewaltoss 99
Mong 99
Mind 90
Larva 87
Pusan 82
ggaemo 63
ToSsGirL 54
sorry 36
Bale 34
Shine 30
hero 30
Movie 26
yabsab 26
[sc1f]eonzerg 25
Terrorterran 22
JYJ 22
Sexy 21
Sacsri 20
Barracks 19
Sharp 19
HiyA 18
ajuk12(nOOB) 15
JulyZerg 15
zelot 15
Yoon 13
IntoTheRainbow 12
Noble 8
Dota 2
Dendi526
XcaliburYe134
Counter-Strike
fl0m1030
shoxiejesuss942
markeloff256
edward76
Other Games
gofns10783
FrodaN2243
singsing1886
B2W.Neo478
crisheroes287
uThermal176
OGKoka 163
Sick154
Liquid`LucifroN118
CosmosSc2 25
Trikslyr14
Organizations
StarCraft 2
WardiTV146
StarCraft: Brood War
UltimateBattle 36
StarCraft 2
angryscii 19
StarCraft: Brood War
lovetv 10
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2195
• WagamamaTV325
League of Legends
• Jankos1984
• TFBlade672
Upcoming Events
Replay Cast
11h 59m
Escore
21h 59m
CrankTV Team League
22h 59m
Big Brain Bouts
1d 3h
Soulspirit vs goblin
TriGGeR vs Bunny
Korean StarCraft League
1d 14h
Afreeca Starleague
1d 15h
RSL Revival
1d 20h
Serral vs SHIN
herO vs Solar
Online Event
2 days
Replay Cast
2 days
RSL Revival
2 days
Clem vs ByuN
Rogue vs Lambo
[ Show More ]
OSC
2 days
WardiTV Weekly
3 days
Sparkling Tuna Cup
4 days
INu's Battles
4 days
Cure vs herO
ByuN vs Rogue
PiGosaur Cup
5 days
The PondCast
5 days
Kung Fu Cup
5 days
Patches Events
6 days
Replay Cast
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Proleague 2026-07-22
HSC XXIX
Eternal Conflict S2 E3

Ongoing

CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
ASL Season 22: Qualifier #1
ASL Season 22: Qualifier #2
CSLAN 4
ASL Season 22
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
ESL Pro League Season 24
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.