• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 22:00
CET 04:00
KST 12:00
  • 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
TL.net Map Contest #21: Winners10Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
StarCraft, SC2, HotS, WC3, Returning to Blizzcon!41$5,000+ WardiTV 2025 Championship6[BSL21] RO32 Group Stage4Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win10
StarCraft 2
General
StarCraft, SC2, HotS, WC3, Returning to Blizzcon! Mech is the composition that needs teleportation t TL.net Map Contest #21: Winners Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win RotterdaM "Serral is the GOAT, and it's not close"
Tourneys
Constellation Cup - Main Event - Stellar Fest $5,000+ WardiTV 2025 Championship Sparkling Tuna Cup - Weekly Open Tournament Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
BW General Discussion [ASL20] Ask the mapmakers — Drop your questions [BSL21] RO32 Group Stage BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review
Tourneys
[BSL21] RO32 Group A - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues [BSL21] RO32 Group B - Sunday 21:00 CET
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Should offensive tower rushing be viable in RTS games? Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Learning my new SC2 hotkey…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 992 users

The Big Programming Thread - Page 604

Forum Index > General Forum
Post a Reply
Prev 1 602 603 604 605 606 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.
SpiZe
Profile Joined December 2010
Canada3640 Posts
March 11 2015 23:09 GMT
#12061
Hi guys, I have a time period (lets call it A), that goes from say February 1st to April 1st. I also have multiple others smaller time periods (lets call them B) and I have to make sure that my A is always covered by a B period. So at any given time, there is an overlap between A and a B period. Thing is, I have absolutely no idea how one should proceed to do this. Anyone has ideas ?
Acrofales
Profile Joined August 2010
Spain18111 Posts
March 11 2015 23:25 GMT
#12062
On March 12 2015 07:05 enigmaticcam wrote:
Ok, so I have a programming problem I'm trying to solve. Any help would be appreciated.

I'm scheduling users to daily jobs for a given month. I have a specific set of users and a specific set of jobs. However, one day might not have the same set of jobs as another. There are various hard rules, such as not allowing one user to be scheduled more than twice in a day - hard rules can't be broken. There are various soft rules, such as scheduling the same user to the same job two days in a row - soft rules can be broken. I want to write a program that will give me the best combination for a given month - one combination is better than another if it breaks less soft rules (no combination is good if it breaks any hard rule). I also want to be able to add or remove rules easily, so there's no dependency on the rules themselves, only that they are either hard or soft.

The difficulty I'm having is that you can't really put a score on a user to a job unless you've accounted for all other jobs due to the nature of the rules. For example, I can't say that adding John to job 2 on day3 is good or bad unless I know if he was already added on that same day. So it seems to me then that dynamic programming is out because you can't break the problem down into smaller components to solve. Also, I don't think brute forcing will work if you have a large amount of job types, users, and jobs per day. Too many variations.

Any help you can offer would be appreciated!

It sounds like a Constraint Optimization problem, as opposed to Constraint Satisfaction.

Branch and bound is probably your best bet. It's not a simple algorithm, and seeing as the problem is NP complete, there are plenty of problem-specific heuristics that may or may not help you. Most good books on advanced algorithms have a chapter on branch and bound. Alternatively, start with the wiki page, which has a boatload of references.
Acrofales
Profile Joined August 2010
Spain18111 Posts
March 11 2015 23:28 GMT
#12063
On March 12 2015 08:09 SpiZe wrote:
Hi guys, I have a time period (lets call it A), that goes from say February 1st to April 1st. I also have multiple others smaller time periods (lets call them B) and I have to make sure that my A is always covered by a B period. So at any given time, there is an overlap between A and a B period. Thing is, I have absolutely no idea how one should proceed to do this. Anyone has ideas ?

Just some overlap? Or completely covered?

Completely covered is pretty simple: just loop over your B periods and find any with a starting datetime earlier or equal to A's starting datetime and ending datetime later or equal to A's ending datetime. If you find one, break out of the loop and return it. If you don't, return false, throw an exception or whatever your solution calls for. Partial overlap requires 2 extra checks, but can be done with a similar approach.
Manit0u
Profile Blog Joined August 2004
Poland17421 Posts
March 12 2015 12:32 GMT
#12064

protected function getIndexRedirectParams($date)
{
return "?make_sale_filter%5Btype%5D="
. "&make_sale_filter%5BdocumentNumber%5D="
. "&make_sale_filter%5Bcustomer%5D="
. "&make_sale_filter%5BcustomerName%5D="
. "&make_sale_filter%5BcustomerCity%5D="
. "&make_sale_filter%5BissuedAt%5D%5Bleft_month%5D={$date}"
. "&make_sale_filter%5BissuedAt%5D%5Bright_month%5D={$date}"
. "&filter_action=apply"
. "&make_sale_filter%5BvalueGross%5D%5Bleft_number%5D="
. "&make_sale_filter%5BvalueGross%5D%5Bright_number%5D="
. "&make_sale_filter%5BremainingValue%5D%5Bleft_number%5D="
. "&make_sale_filter%5BremainingValue%5D%5Bright_number%5D="
. "&make_sale_filter%5BshouldBePaidAt%5D%5Bleft_month%5D="
. "&make_sale_filter%5BshouldBePaidAt%5D%5Bright_month%5D="
. "&make_sale_filter%5BdaysAfterPayDate%5D="
. "&make_sale_filter%5BisPaid%5D="
. "&make_sale_filter%5BcustomerIsIndividual%5D=";
}


T_T

And that's after I've refactored it a bit to see what's going on, previously it was just this uber-long string being appended to the path. Funny thing is, if you remove the empty filters all the others stop working too...

So much for pretty urls...
Time is precious. Waste it wisely.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
March 12 2015 15:23 GMT
#12065
On March 12 2015 08:02 Zocat wrote:
Do you need to find the best solution (global optima) or a "good enough" solution (local optima)?

What is the rough user/job size? Hundreds, thousands, millions, unlimited?

Adding / removing rules depends on your rule complexity. Changing a rule can be easy (not working 3 days in a row), but adding a completely new rule might be complicated (user X doesn't like to do job Y, but he can do it if necessary).

If you don't need the global optima I would look into genetic algorithms. The fitness function sounds easy enough to implement with your set of rules and hard-rule breaking offspring can die off immediately.

"Good enough" is certainly good enough. In fact, if a solution is found that doesn't break any rules, it can stop there. For a given month, there are 40 possible jobs to fill on average, with 8 users on average to fill each job. So the number of possibilities is about 8^40.

I had forgotten about genetic algorithms! I've got some experience with those, I might go that route. Thank you!

On March 12 2015 08:25 Acrofales wrote:Branch and bound is probably your best bet. It's not a simple algorithm, and seeing as the problem is NP complete, there are plenty of problem-specific heuristics that may or may not help you. Most good books on advanced algorithms have a chapter on branch and bound. Alternatively, start with the wiki page, which has a boatload of references.

I looked this up. The description on wiki is practically exactly the solution I'm looking for. But as you say, it doesn't look easy to implement. I'll try the genetic algorithm first, but if for some reason that doesn't work, I'll give this a try. Thanks!
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 13 2015 01:24 GMT
#12066
What is the difference between an empty array and a null array? How do you have an empty array that is not null?
Acrofales
Profile Joined August 2010
Spain18111 Posts
Last Edited: 2015-03-13 01:36:32
March 13 2015 01:33 GMT
#12067
On March 13 2015 10:24 travis wrote:
What is the difference between an empty array and a null array? How do you have an empty array that is not null?

Depends on the language, but generally, a null array will be a variable that has been declared, but not instantiated, whereas an empty array is an array of length 0 that has been instantiated.

To put it in java terms, lets say you have declared an int[] foo without instantiating it. Calling foo[0] will throw a NullPointerException, because java does not know where to even start looking for foo (memory has not been allocated). On the other hand, if you have declared int[] foo = new int[0], and then you call foo[0], it will throw an ArrayIndexOutOfBoundsException, because foo has been allocated, but there is no 0th element in the array.

PS. I didn't actually try this code, and it is entirely possible that the Java compiler catches these situations and does not even allow you to do this stuff, but it is meant more as an illustration than a coding example.

PS2. I said it depends on the language, because in some languages it's possible there is no difference.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-03-13 01:54:50
March 13 2015 01:35 GMT
#12068
On March 13 2015 10:24 travis wrote:
What is the difference between an empty array and a null array? How do you have an empty array that is not null?


A null array would mean you declared a reference to an array, but didn't initialize an array to place in that reference. An empty array would be what you get when you initialize it.

int[] numbers;

versus
int[] numbers = new int[];


It makes more sense if it's a collection like an arraylist rather than an array I imagine.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-13 01:45:25
March 13 2015 01:44 GMT
#12069
gah i have to work in a file where people don't unlock the synclock before calling eventhandler and firing async events... 1 day debugging a deadlock...sad i can't just refactor stuff without a care
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17421 Posts
Last Edited: 2015-03-13 22:28:49
March 13 2015 22:27 GMT
#12070
On March 13 2015 10:44 Blisse wrote:
gah i have to work in a file where people don't unlock the synclock before calling eventhandler and firing async events... 1 day debugging a deadlock...sad i can't just refactor stuff without a care


I feel your pain. Right now I'm doing some refactoring on the legacy code... Entities in the model don't match the database, relations that are declared aren't there (there are no columns like that in the database for example) etc. etc.

2 days debugging and fixing it, just to do something that shouldn't take more than 15 minutes. For the first 3 hours me and other developers were wondering why the hell stuff doesn't work when it clearly should. Scouring the 400 tables of the db revealed our issues. To our horror though, this 400 tables are just for the system skeleton to work, it's using 5 different databases, each on a different server and some of them are really huge. Now we have to somehow fix this mess without breaking it (since the system is being used by several companies). The worst part of it is that each new registered user in any of those companies gets his own DB instance, which is being populated with entries that don't match the model.
Time is precious. Waste it wisely.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2015-03-14 01:05:29
March 14 2015 00:50 GMT
#12071
On March 13 2015 10:24 travis wrote:
What is the difference between an empty array and a null array? How do you have an empty array that is not null?


Google is very useful. Why don't you search for simple questions there? http://stackoverflow.com/questions/27476845/difference-between-a-null-array-and-empty-array-in-java

On March 10 2015 03:01 Ropid wrote:
Show nested quote +
On March 10 2015 01:01 sabas123 wrote:
Currently im writing alot of structs and giving them an unique id to identify them later.

constantly looking up the latest id I putted in/looking up the id of the struct is a bit of an pain. any way I can do this automatically with something like an enum?

The OOP way is using "virtual" functions. Behind the scenes, those are basically a pointer to a function getting added to the data structure. When you then have a base class and derive a bunch of specialized classes from it, and you then have a collection of elements of that base class, you can call that virtual function on any element of your collection, and what will run is the function from the specialized class without any type casting needed.

No idea if that's better or worse than doing things manually like what you're doing right now with your IDs.


If I have to be picky, there's no "virtual function". Function is not part of a class. Function which belongs to a class is called a method. Anyway, virtual methods are resolved at runtime and that is their difference compared to "regular" methods. If you have derived classes in C++ and want to have different behaviour from base class, then you should better declare them virtual. I'm not sure if C# works in the same way although it has 'virtual', but I guess it should. I've just not tested it.

Edit: I know Java has no virtual methods but are they all virtual by default/implicitly? I remember overriding a method is done by the @Override attribute.

Edit2: I should follow my own advice. Yes, methods are virtual by default.
Lascero
Profile Joined July 2010
United States59 Posts
March 15 2015 20:07 GMT
#12072
Career optimization questions!

1. My first job has me in the deep end. Some people enjoy this, but code reviews stopped for all new hires after the first two months and we have no automated testing or any real coding standards besides "don't break prod". I feel like I'm only learning how to code for this particular job and product and platform. Would this affect me negatively if I explained this situation to other employers? Would I be a dick for leaving a job for the same reason? (phrased along the lines of "I didn't feel like I could grow" or "I wanted a new challenge")

2. Coding after work seems to suck. I'm mentally drained and don't really feel excited about starting anything, although it's still fun to read about things and do hand-holding tutorials. Is this a mental block that I can overcome by just brute forcing or will it go away on its own once my day job feels more routine and is easier? It feels routine now, but there is still some struggling to fix/build things. This is how I would fix the skill gaps that my job won't directly teach me but I don't want to completely burn out and just hate everything.

3. Is there a grunt-like position for security? Maybe a bit underpaid but still rewarding? I know that's aiming a bit low, but I'm trying a few different areas and I'm trying to get a feel for the time investment of being good at it and when you can first start being useful to someone. Does anyone really care if you start at the bottom, or is it better to just acquire more than the minimum skills, say 1 or 2 years of practice and learning, and first enter the industry at a higher level?

Thanks
LaNague
Profile Blog Joined April 2010
Germany9118 Posts
March 15 2015 23:29 GMT
#12073
1. you can never be a dick for changing workplaces, in my oppinion. Employer and employee all know what ttheir professional relationship is.

2. I have the same problem, i rather play games than be productive when im at my home PC, no idea how to "fix".
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 16 2015 17:38 GMT
#12074
I have phases where I can be productive at home, and then phases where I just don't have enough motivation. These phases last anywhere from a week to several months...
If you have a good reason to disagree with the above, please tell me. Thank you.
r3dox
Profile Blog Joined May 2003
Germany261 Posts
March 16 2015 18:49 GMT
#12075
1) if you were to apply at my company and say that, I would ask you what you tried to improve your situation...
did you ask for continued code reviews to improve quality?
did you look into areas that could be tested automatically?
did you suggest deciding coding standards?

2) basically the same for me, i rather Play games or read about stuff than code as a Hobby. It would be different if i had a Project to work on with others... anyone wanna hack on some 2d game code together?
BisuDagger
Profile Blog Joined October 2009
Bisutopia19298 Posts
Last Edited: 2015-03-16 19:36:38
March 16 2015 19:36 GMT
#12076
Anyone know how to change the wallpaper to color black from the terminal/a makefile in KDE4? Additionally, how would I apply it to more then one screen?

Thanks in advance!
edit: this is on RHEL7 if that makes any differences.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
nunez
Profile Blog Joined February 2011
Norway4003 Posts
March 16 2015 20:33 GMT
#12077
On March 17 2015 02:38 spinesheath wrote:
I have phases where I can be productive at home, and then phases where I just don't have enough motivation. These phases last anywhere from a week to several months...

producing what?
pet projects or work?
conspired against by a confederacy of dunces.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 16 2015 21:25 GMT
#12078
On March 17 2015 05:33 nunez wrote:
Show nested quote +
On March 17 2015 02:38 spinesheath wrote:
I have phases where I can be productive at home, and then phases where I just don't have enough motivation. These phases last anywhere from a week to several months...

producing what?
pet projects or work?

Pet projects. I have a regular full time job which usually exhausts my desire to write code for one day. Well, unless I have one of my productive phases.
If you have a good reason to disagree with the above, please tell me. Thank you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
March 16 2015 21:35 GMT
#12079
ah, i have found that my job not only exhaust, but also perverts my desires.
i find it difficult to decouple from whatever problem i am facing at work,
and my pet projects end up being solving the same problems, except
phrased more comfortably.
conspired against by a confederacy of dunces.
Acrofales
Profile Joined August 2010
Spain18111 Posts
March 16 2015 22:21 GMT
#12080
I have to say that that is a pretty normal reaction in my experience. When studying, I had fun with some pet projects. Nowadays unless it serves a serious purpose (work or a course), I don't program anything at home.
Prev 1 602 603 604 605 606 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
23:00
PiGosaur Cup #55
Liquipedia
BSL 21
20:00
ProLeague - RO32 Group A
Gosudark vs Kyrie
Gypsy vs OyAji
UltrA vs Radley
Dandy vs Ptak
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 129
StarCraft: Brood War
Britney 20637
Sea 1806
NaDa 68
Noble 45
Dota 2
monkeys_forever460
NeuroSwarm96
League of Legends
JimRising 604
Heroes of the Storm
Khaldor141
Other Games
tarik_tv10367
summit1g9517
ViBE44
goatrope34
Models1
Organizations
Other Games
gamesdonequick617
Counter-Strike
PGL119
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Hupsaiya 171
• davetesta9
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota21604
Upcoming Events
Sparkling Tuna Cup
7h
WardiTV Korean Royale
9h
LAN Event
12h
ByuN vs Zoun
TBD vs TriGGeR
Clem vs TBD
IPSL
15h
JDConan vs WIZARD
WolFix vs Cross
BSL 21
17h
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
1d 6h
Wardi Open
1d 9h
WardiTV Korean Royale
2 days
Replay Cast
3 days
Kung Fu Cup
3 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
[ Show More ]
Tenacious Turtle Tussle
3 days
The PondCast
4 days
RSL Revival
4 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
4 days
WardiTV Korean Royale
4 days
RSL Revival
5 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
5 days
CranKy Ducklings
6 days
RSL Revival
6 days
herO vs Gerald
ByuN vs SHIN
Kung Fu Cup
6 days
BSL 21
6 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
Stellar Fest: Constellation Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
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 © 2025 TLnet. All Rights Reserved.