[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]
4chanarchives logo

/dpt/ - Daily Programming Thread


Thread replies: 356
Thread images: 34

File: 1403745661717.jpg (113KB, 800x535px) Image search: [Google] [Yandex] [Bing]
1403745661717.jpg
113KB, 800x535px
Old thread: >>53687586

What are you working on, /g/?
>>
>>53697617
First for D
>>
Second for java being shittiest language
>>
File: Type Iteration.png (10KB, 568x217px) Image search: [Google] [Yandex] [Bing]
Type Iteration.png
10KB, 568x217px
I wish I was a girl so I could properly enjoy D
>>
File: Pattern Matching.png (12KB, 596x233px) Image search: [Google] [Yandex] [Bing]
Pattern Matching.png
12KB, 596x233px
>>53697655
>>53697677

D stands for dubs
>>
>>53697694
>tell a girl that I want to bring her back to apartment so that I can give her the D
>we get back and she starts taking her clothes off
>wtf is she doing
>all I wanted to do was was write one-line fizzbuzzes in D
>>
>>53697675
That's not how you spell python you silly.
>>
File: ;D.png (57KB, 800x334px) Image search: [Google] [Yandex] [Bing]
;D.png
57KB, 800x334px
>>53697755
did you show her your D?
>>
>>53697617
Where can I find good self-learning sources?
I am already studying CS at uni, but I want to learn more and something more practical. Probably want to learn WebDev (javascript and SQL?) stuff as I want to make a database website for my student organization.
Any tips on where to start and where I can find good sources to learn from?
>>
Currently working on Python class that reads in an HTML text file and count the word frequency for each article in the text file (there are 3 articles).

Is there any way to create a dictionary so that I can count the word frequencies for each article separately?

For example:
[Word] -> [1, 15], [2, 20], [3, 56]
[Word2] -> [1, 22], [3, 6]
>>
>>53697773
python is at least a good language for writing tools. java is literally shit and only attracts flies
>>
>>53697798
>studying CS at uni
>want to learn something more practical
>webdev
>javascript
>sql
>database website

you're retarded
literally the best decision in that entire sentence was you falling down the stairs meme
>>
>>53697787
No, she ranted about how this is why she doesn't date men while she was putting her clothes back on. Then she left and called me a nerd on her way out.

I didn't even get a chance to show her my mixins ;_;
>>
>>53697803
Like any good Python coder, you should use libraries written in C and C++ and talk about how great that makes python

std::multiset, or a decorated trie
>>
File: nothing.gif (39KB, 356x200px) Image search: [Google] [Yandex] [Bing]
nothing.gif
39KB, 356x200px
>>53697617
Fuck that guy, he tried to sell me TurboTax.
https://www.youtube.com/watch?v=3WNlWyFgLCg
>>
working on a android game using libgdx. Gonna publish it soon to the play store
>>
>>53697854
post it so we can laugh how bad it is
>>
>>53697820
Ok, thanks for the input, but nor really helpfull.
So can you recommend some place I can learn more?
>>
>>53697617
Event dispatcher subscription management for a websocket server in Go. Eventful multithreaded consistency can be a pain, when you also have to take into account database consistency.
>>
>>53697798
Ruby on Rails
You'll thank me later
>>
>>53697880
Yeah, your fucking university
>>
>>53697908
But where is a good place to start to learn it?
Where can I find some good courses, books webpages to learn it? Dont want to waste my time by learning from poor learning materials.
>>
>>53697872
you can laugh all day neet faggot but this is the second shit game im gonna publish and the first one got me 1500$ and counting in a month and a half.
>>
>>53697960

Code academy
>>
>>53697960
https://www.railstutorial.org/book
>>
>>53697976
>1500$
wow, you can almost move out of your mom's basement. congrats
>>
>>53697960
Your fucking computer. Make something and you'll have learned something.

If you want web stuff go to w3.
>>
Can anyone recommend any books that discuss design of large software projects? I'm reading "The Architecture of Open Source Applications" but I'd like something that talks about it in a more general sense. How to approach designing a large software system from the ground up.
>>
>>53697990
Sure... Did it once, not again.
>>53697992
>>53698016
Ok cool.
Also why Ruby over JS or other?
>>
>>53697803

In other words, how do you make a hash table with a linked list?
>>
>>53697655
the D*
>>
Rust vs D.

Which meme language should I learn? Leaning towards Rust at the moment.
>>
>>53698028
How about Software Engineering by Sommerville?
Maybe way to basic for you, I dont really know it to well myself.
>>
>>53698013
Its not bad faggot considering its the first one i made and it took me a 12 days to finish it. But still its more than you made in your lifetime neet faggot
>>
>>53697803
Search "python dictionary" - it's what you need.
>>
MessageDigest hasher = MessageDigest.getInstance("SHA-1");


>string lookup
>to get a hasher object
>raises a _CHECKED_ exception NoSuchAlgorithmException

Who the fuck designs something this retarded?
>>
>>53698042
That I can't tell you. I work with ruby and really like it, don't know if it's really better than what is out there
>>
>>53698065
D
>>
>>53698072
yes, I am so jealous of your shitty game that is designed on one of the shittiest game library ever made
>>
>>53698118
Have you every produced software for profit? You have no right to whine if you haven't.
>>
>>53697903
Isn't the whole purpose of Go's concurrency model to avoid shit like this?
>>
>>53698118
ofc you are neeto. Now go write console apps all day
>>
>>53698072
>getting this mad when someone refuses to stroke your e-peen

hahaha holy shit, back to tumblr kiddo
>>
File: 2016-03-26_18-26-19.png (13KB, 774x258px) Image search: [Google] [Yandex] [Bing]
2016-03-26_18-26-19.png
13KB, 774x258px
>>53697787
Is it that time again?
>>
File: download.png (11KB, 194x259px) Image search: [Google] [Yandex] [Bing]
download.png
11KB, 194x259px
> Taking a Java programming class.
> Prof doesn't care about source code, just checks that the .class files pass his tests.
> mfw I write all my assignments in Scala.

Actually none of the above is true, but goddamn do I wish it were, I hate Java so fucking much.
>>
>>53698116
Why? I need reasons.
>>
>>53697976
>>53698072
>>53698156

Are you really so pathetic and insecure that you must think about everyone who disagrees with you as a neet to feel better about youself?

You aren't as clever as you think, and nobody is forcing you to post here, so feel free to head back any time.
>>
>>53698083

I have a dictionary with the word frequencies of all articles combined.
Am now trying to split them up so I get the frequencies per article
>>
>>53698163
>no active patterns

for shame
>>
>>53698195
>I have a dictionary with the word frequencies of all articles combined.

You might find
collections.Counter
useful.
>>
>>53697617
i have an array list of linked lists of city objects in java. the linked lists of cities store what cities can be flown to directly from that city and i'm trying to make my addAdjacent method. does
map[        map.indexOf(aCity)].add(adjCity); 
work or would i have to use toArray? if it doesn't work how do i do it?
>>
Do we agree that Javascript can be a pretty good language?

It's in the closures and ES6 lambdas. Those provide you with light syntax for lambda calculus, add a functional library like underscore or ramda on top of that and you're left with a simple untyped functional language.
>>
>>53698195
If you know about dictionaries and lists then you have enough information to solve your problem. Think about ways that you can combine those data structures to achieve what you want. I can tell you how to do it, or you can figure it out yourself.
>>
>>53698246
no support for decent performance
>>
>>53698148
Yes, and that works perfectly fine, if you have no database you want to write to concurrently or a lot of state. But something here is probably bad design. Need to rethink
>>
On Linux, say I had 1 socket and 2 threads, is it safe for thread A to read from socket and thread B write to socket at the same time?
>>
File: fizzbuzz.png (30KB, 722x480px) Image search: [Google] [Yandex] [Bing]
fizzbuzz.png
30KB, 722x480px
>>53698163
>>
>>53698194
>>53698162

All of the neet faggots got triggered hahahahahahahahahahahahahhaha
>>
>>53698281
>dae le triggered xD so fannay

nobody is forcing you to keep making inane posts, bud
>>
>>53698257
True, but honestly everything web-related is allowed to be slow as all fuck these days. You'd be better off avoiding JS altogether if performance is important.
>>
>>53698273
Also, thread A can also write to the socket.
>>
File: 2016-03-26_18-36-31.png (16KB, 628x353px) Image search: [Google] [Yandex] [Bing]
2016-03-26_18-36-31.png
16KB, 628x353px
>>53698200
Happy?
>>
>>53698318
>>53698200
Ignore the wrong string though.
>>
>>53698251

Thanks for your encouraging words. Just learned about dictionaries, so I'm not that familiar with them, however I will think about it for a moment. Although I'm a bit frustrated, been working on this for a couple of hours now.
>>
>>53698273
>>53698308
It's safe, but if you're using a SOCK_STREAM your messages might get mixed up.
>>
>>53698246
>Indeed, Waldemar Horwat once told me that he viewed JavaScript as essentially Common Lisp with a C-like syntax. In fact Waldemar defined a metalanguage, wrote an interprepter for his metalanguage in Common Lisp, and then wrote the JavaScript spec in his metalanguage, thereby enabling him to actually run the specification. It was a clever technique.
>>
>>53698375
What if in my socket abstraction layer, I just include a simple mutex lock in the write call, to make sure that only 1 thread is writing at a time.
Since my program doesn't split single protocol messages into multiple write calls, this should do, right?
>>
>>53698341
Take a break, go for a walk or play some vidya or something. Frustrating problems get easier to solve when you step away from them for a while.

As I said before
>combine those data structures to achieve what you want

It'll come to you.
>>
>>53698384
>-- Eric Lippert
Sheeet
>>
>>53698318
upvoted
>>
Anybody here making money from ads in android apps?

How much user is needed to make it worth?
>>
>>53698091
>string lookup
>to get a hasher object
it's what you could call a 'universal solution' (or something), so that all future implementations (of algorithms that may not even exist at the same this was made) can still use this interface

>raises a _CHECKED_ exception NoSuchAlgorithmException
yeah I agree this is pretty silly, should be unchecked
>>
>>53698431
I guess.

Why not just have a third thread waiting on a queue of messages to send?
>>
>>53698491
That would probably complicate things more than I need to.
>>
>>53698486
I guess it's nice to have this when you read the hash method that you want to use out of something like a config file
the checkedness of the exception makes sense, too
but it would be a lot better to actually have constructors for SHAHasher().. etc exposed to the user as well
>>
>>53698586
>but it would be a lot better to actually have constructors for SHAHasher()
yeah that's just the retarded Factory design pattern that was so popular in Java

i'm glad it's mostly over
>>
Can someone help me?
Also OpenCV is shit.It has the shittiest documentation I have ever encountered.
main.cpp:3:28: fatal error: opencv/ml/ml.hpp: No such file or directory
compilation terminated.
>>
>>53698486
why not have an enum of supported algorithms?
>>
>>53698436
Thank you
>>
>>53698811
did you even read my post?

because that would limit the amount of supported algorithms, which is not what that interface is trying to accomplish
>>
>>53698915
the method is static so its not part of an interface
>>
>>53698915
why not use static constant ints
>>
>>53698811
What if I have two different crypto implementations supporting different sets of algorithms, and I want to use the same API for both implementations?

>>53698944
Never mind, you're an idiot.
>>
Can someone recoomend me a good face parts recognition tutorial in OpenCV whose tutorial is not shit?
>>
>>53699013
>tutorial
>facial recognition
Google for academic papers instead
>>
>>53698992
you are the idiot
>>
File: 2016-03-26_19-21-41.png (19KB, 720x807px) Image search: [Google] [Yandex] [Bing]
2016-03-26_19-21-41.png
19KB, 720x807px
>>53698277
>>53698163
Continuing.
>>
public void insertAdjacent(City aCity, City adjCity) {        
map.set(map.indexOf(aCity), map.get(map.indexOf(aCity))).add(adjCity);
}

>2016
>not using beautiful, elegant 1 line methods
>>
>>53699096
kek

this is why you will never have a job or be a good programmer whatsoever
>>
>>53699096
>map.indexOf(aCity) repeated twice
>map repeated four times
>explicit parameters
>>
>In-process database like sqlite
>Actual key/datatype constraints
>Not OS/Platform specific (i.e. no SQL CE)
Does such a thing exist?
>>
>>53699049
Academic Papers are outdated
I tried an the example code and the code is compile
>>
>>53698979
you usually create your hasher object once
doubt a string lookup really matters at all
>>
>>53699149
>>In-process database
but why?
>>
How/where can I find some Abandonware stuff that I can try and expand/modify to gain some experience?
>>
>>53699124
>>53699141
webdevs detected
>>
>>53699155
wont compile
(Swipe is annoying)
>>
>>53699165
retarded code monkey producing unreadable shitcode detected
>>
>>53699179
>>
>>53697880
Youtube, and work on a project. When you don't know how to do something specific look it up on youtube or stack exchange etc.
>>
>>53699160
Hash(algorithms.SHA1);
Hash(algorithms.SHA0);
// compile time error, squiggly line, intellisense

Hash("SHA-1");
// run time error, (typically) no ide detection
>>
>>53699196
okay but keep your facebook conversations to yourself, spicenigger
>>
>>53699161
Because I can't have an application installing Postgres on every desktop just to store config settings.
>>
I'm making a simple program to calculate the candidate keys for a given set of attributes and functional dependencies. It ain't hard but it's mostly to practice writing stuff in c++.

Now I'm trying to do something obviously wrong and I can't remember what's the correct approach, or solution

 typedef struct _attribute{
char atr;
std::set<attribute> closure;
} attribute;


I can't just put the attribute in itself before it is even fully defined. Do I put
std::set<struct _attribute> atr;

or
std::set<attribute*> atr;

or
std::set<attribute>* atr;


I get a feeling this is a most basic thing, but I haven't dealt with this kind of things in a while.
>>
>>53699233
>just to store config settings
why would you need a database of any kind for this?
>>
>>53699165
>i've never heard of combinatorics
>>
>>53699247
>typedef struct
typedef not necessary for a struct in C++

std::set<attribute*> is a set of attribute*
std::set<attribute>* is a pointer to a set of attributes

I believe you'd want the second but I don't know that it's valid (for the same reason you can't have attribute in attribute), the first is definitely valid but won't do what you want (it'll just be a set of pointers - i.e. a set of integers)

in the worst case you might need reference_wrapper or something
>>
>>53699247
Think about what you're actually saying with this.

>std::set<attribute*> closure;
Each attribute contains a set of pointers. Each pointer in the set refers to another attribute which is contained in the closure.

>std::set<attribute>* closure;
Each attribute contains a pointer to a set of attributes which are in the closer of this attribute. This won't work though, since each of the attributes in the set will then need to have their own set, with their own attributes.

>std::set<struct _attribute> closure
>just fuck my shit up
>>
File: 1458789349674.png (316KB, 504x486px) Image search: [Google] [Yandex] [Bing]
1458789349674.png
316KB, 504x486px
>>53698231
I haven't worked with java in a long time, but I can tell you how you should be thinking about it (assuming I understood your problem correctly). You want to essentially get the appropriate linked list head from the map, and then add adjCity to that city's list.

A map (to my understanding) is a key value pair, where the key is not necessarily an int. Therefore, wouldn't the key that corresponds to the linked list you want just be aCity? I think your code should look something like this, assuming the LinkedList.add(str) function does what it looks like:

map[aCity].add(adjCity)


To reiterate, map[aCity] is gonna grab the linked list, so add will be called on that linked list. Some things to think about are, is map[aCity] gonna return the pointer to the head of the linked list, or a copy of the linked list? Will calling .add update the value within the map too?

Hope this helps.
>>
>>53699297
You can just say
struct {something something} thing
in c++? I didn't know that.
>>
>>53699371
struct cuck {
int timeInCuckShed;
std::string countryOfOrigin = "Sweden";
};
cuck olaf;
std::cout << olaf.countryOfOrigin << std::endl; // Sweden
>>
>>53699371
it works like this

struct/class X {
};

X some_instance;
X some_instance, some_other_instance;

struct/class X {
} some_instance;

you can have anonymous structs

struct { } some_instance;

you can do static, const, pointer, etc

static const struct {
char attr;
} *some_instance;


btw, in your case, I think std::set<attribute> might actually work
>>
>>53699417
oh, and std::set elements need a < operator

in this case you can do
bool operator<(const attribute& other) { return atr < other.atr; }
you put this in as a member function, and then whenever anything does

some_attribute < some_other_attribute
it's replaced with a call to this function

std::set uses it to sort elements
>>
>>53699417
>btw, in your case, I think std::set<attribute> might actually work
It'll work if you want the wrong data model.

Consider the 2 element case, where each element is in the same closure.

A's closure set: <B>
But that <B> there is a copy of the actual attribute B. This is a wasted copy, and you're going to have to leave the closure set empty.

Just use std::set<attribute*>. Anything else you're going to make data modelling errors.
>>
File: poly.png (7KB, 640x480px) Image search: [Google] [Yandex] [Bing]
poly.png
7KB, 640x480px
I need an algorithm to find the nearest polygon to a point. Someone suggested using a R-Tree, is that a good idea or is overkill?
>>
>>53699477
why not just use a set of chars in the first place
>>
>>53699350
I have no problem understanding that all three are fundamentally different. I'm just wondering which ones will compile. If there were no std::set in question, then I'd have known that I can't just place an atribute inside itself, I'd have to resort to a pointer.

But now I'm wondering if a pointer to a set is valid, even if whatever is contained in the set is still not defined, because all pointers are just ints.
>>
>>53699514
all three (third being std::set<attribute>) will (effectively) compile

in reality you'd get an error because attribute doesn't have an operator<
but std::set<attribute*> does have an operator< - pointer A < pointer B
>>
>>53699509
Depends what you're using the data for. If you need to:
* Access a given attribute's closure
* Examine the elements in THAT elements closure
Then you'll need to look up the actual referring element at some point anyway, so just use a pointer. But since chars and attribute* are isomorphic here it's just a matter of how you're going to use the data -- both will work.
>>
>>53699514
std::set is a red black tree.
RB trees store values via pointers
you're really just storing an attribute* at the end of the day (plus other book keeping)
>>
>>53699506
https://en.wikipedia.org/wiki/Gilbert%E2%80%93Johnson%E2%80%93Keerthi_distance_algorithm

i believe support and nearestsimplex are what you want
>>
I made a dependently-typed language and all is fine, but I still can't decide whether I want monads or first-class effects to handle side effects.

In the meantime, working on a small Idris to LLVM bitcode compiler.
>>
>>53699466
Thank you for this. I've read that the set is a sorted container, but I didn't see anything about overloading an operator to make it work. So I include that in the strucure, or just put it somewhere in the main function?

>>53699559
The guy who originally asked about the whole set thing here.

I'm still pondering how to model the whole thing. I think I might switch over to a set of chars, since you raised a good question if I'm ever going to examine the elements in the closure themselves. In the end the only reason I'm using these containers is because I wanna get a bit more accustomed to c++ and because I want someone else to deal with potential adding and deleting of elements.
>>
>>53699662
Post source
>>
>>53699718
>I'm still pondering how to model the whole thing.
That's one of the hardest part of designing the program IMO. The exact types you use have significant implications for how you'll want to code your algorithm.

If you want more data modelling questions think about union-find structures. It might be the case that they're useful for you here:
https://en.wikipedia.org/wiki/Disjoint-set_data_structure
>>
File: 1458226840689.jpg (40KB, 420x401px) Image search: [Google] [Yandex] [Bing]
1458226840689.jpg
40KB, 420x401px
Need help real quick with some PHP for my class /g/entoomen.

I have an array (called $food_prices) where the array keys are food names and their respective values are the prices. I assigned the array keys to a value called $foodnames and the array values to $prices. Then I made a dropdown with

<select name="foodname"></p>
<?php foreach($foodnames as $value): ?>
<option <?php if ($params->foodname == $value) echo "selected" ?>
><?php echo $value ?></option>
<?php endforeach ?>
</select>


But I need to compute the total cost of this food. How do I get the values of the food I chose?
>>
>>53699371
structs are just classes with members set to public as a default.

regular classes set their members to private.
>>
>>53699718

Put it inside the struct as a member function

bool operator<(attribute other) const { return atr < other.atr; }

it's literally the same as any other member function - the only change is that now when you call some_attribute < some_other_attribute, it calls this function

you can overload for different types, e.g.
bool operator<(char other) const { return atr < other; }
or
bool operator<(const attribute& other) const { return atr < other.atr; }
>>
>>53699604
Would that algorithm be usefull for 2D bezier curves of order n?
>>
>>53699405
you need to assign to countryOfOrigin in the constructor
>>
>>53700011
If you rasterise them to triangles

There's probably a simpler way.
>>
>>53700044
Actually it should work if you just rasterise it to straight lines, it's supposed to work with arbitrary convex shapes
>>
>>53700025
>inferior c++03 cuck
get that weak shit out of here
>>
>>53699992
When I try that it tells me that attribute does not name a type, probably because it still isn't defined inside itself.

I can overload the operator outside the structure just fine, only I have to tweak it to say bool operator<(att first, att second) {return first.atr < second.atr}
Is there a way to do the overloading inside the structure itself?
>>
>>53700132
No, that should be fine. Are you actually calling the type attribute?
Might want __attribute if you named it differently
>>
>>53697617
What are the benefits of using Ruby over Python if I'm not a webdev (muh rails)?
Python seems much saner to right in for me, has some decent libraries, and has the benefit of a larger "community," so there's more information available.
>>
>>53699091
That some Erlang?
>>
>>53700223
Correct.
>>
>>53698318
FAIL
>>
>>53700190
Here's my code
struct atribut{
char atr;
std::set<char> zatvorenje;
bool operator<(const atribut& other) { return atr < other.atr; }
};

Excuse the jibberish, I'm to lazy to translate these things right now. So this breaks, but doing this
bool operator<(const atribut& prvi, const atribut& drugi) { return prvi.atr < drugi.atr; }

is fine for some reason.
>>
>>53700132
>>53700190
ah you called the type _attribute rather than attribute, you made an instance of it called attribute
>>
>>53700272
>>53698339
I'll write unit tests next time, promise.
>>
>>53697880
You're a CS student and you don't know how to use google smfh.
>>
>>53700313
first, reference members are perfectly fine - they're basically pointers that can't be null

second, your std::set<char> will use char's operator<, I meant if you had a
std::set<attribute>
it'd call operator< on attribute

third, you can use the type in function definitions within the class, you just can't define members of the class (but you can define pointers and references, and templates of the class that don't directly hold it as a member, e.g. set/vector)
>>
>>53699906
$_POST['foodname']
>>
I have nothing to work on :|
>>
>>53700360
the only thing you really need to avoid is doing this:

struct X {
X mem;
}

or anything that would be "like that"

you CAN do this
struct X {
X& mem;
X *mem2;
}

struct X {
std::set<X> mem; // because std::set uses pointers and references
}
>>
File: honking intensifies.gif (57KB, 205x190px) Image search: [Google] [Yandex] [Bing]
honking intensifies.gif
57KB, 205x190px
>>53697903
>if err != nil
>if err != nil
>if err != nil
>if err != nil
Just kill this fucking meme language already.
>>
>>53700429
it's the same for C, newfriend
>>
>>53700360
>>53700397
I'll keep this in mind. But still, why does placing the overloading of the operator inside the structure not work ass opposed to placing it outside? I mean I know crap all so I just copied your or that other guy's code intomy structure and it doesn't pass compilation.
>>
>>53700313
That looks fine -- what's the compiler error? The only thing I would change is marking the member function operator overload as const:
    bool operator<(const atribut& other) const { return atr < other.atr; }


But if you're going to use std::set<char> then you don't need to define operator<, since it'll use operator< for char which is already defined.
>>
>>53700313
>>53700447

Oh I see the issue
operator< has to be a const member function (for std::set) - i.e.
params ...) const { ... body

Basically, your member function is equivalent to this:
bool operator<(attribut* this, const atribut& other) { return this->atr < other.atr; }
notice how the first isn't const?
>>
>>53700429
Yes, because try-catch spam is much more flexible and elegant.
>>
Probably not the right place to be asking this. But has anyone here gone to a SUNY for a CS degree? I got into Penn State but my parents make too much to receive any financial aid. I'm considering Buffalo or Stony Brook.
>>
>>53700445
C was created in the 1970s, when people didn't know any better. Go was designed to be stupid in the 2000s.
>>
>>53700487
>when people didn't know any better
lol bud. we know DPT is beginner's general so if you have any questions, spit 'em out
>>
>>53700453
>>53700466

error: no match for ‘operator<’ (operand types are ‘const atribut’ and ‘const atribut’)
{ return __x < __y; }

And you guys were correct, it has to be a constant function. Thank you all for the help, and thank you
>>53699795
for reminding me of this thing. I think I saw this back in a data structure course.
>>
>>53700478
Exceptions and monadic composition are objectively superior to this awful hodgepodge.
>>
Im pretty new to this programming thing, can anyone nicely explain to me and my friend why you do it?
do u think the future actually needs programmers later?
have u thought about robots?

thanks in advance
im asking for my newspaper you see :)
>>
>>53700567

struct attribute {
char atr;
std::set<attribute> rest;

bool operator<(const attribute& other) const { return atr < other.atr; }
};
>>
>>53700589
GET
THE
FUCK
OUT

And we are not programmers, we are computer scientists.
>>
>>53700630
>daily programming thread
>programming
uh-oh friendo, looks like you were wrong :^)
>>
>>53700684
Doesn't makes us programmers, faggot.
>>
>>53700569
Nice opinions, m8.
>>
>>53700025
That's not true.
>>
>>53700704
>Doesn't makes me programmers, faggot.
FTFY
>>
File: ntPBqHb.jpg (481KB, 2322x4128px) Image search: [Google] [Yandex] [Bing]
ntPBqHb.jpg
481KB, 2322x4128px
>>53700704
I dont think you shuold be using "fagot" as an insult, beacues it emplies that gay people are bad, and they get enough of that in real life, its pretty sick to get hate even on online websites
when i thought i woudl be safe from insults because of my position on sexuality.
no thanks have a good day homophobic c .uck.
>>
>>53700751

>>>/reddit/
>>>/tumblr/
>>>/github/
>>>/mozilla/
>>
>>53700743
>me programmers
This is not English.
>>
File: bebi.png (485KB, 521x449px) Image search: [Google] [Yandex] [Bing]
bebi.png
485KB, 521x449px
>>53700773
no thanks those sights are homophobic aswell, i came here because i heard there were alot of "fagots" here aswell so i thought i woudl be in good company.
clearly i was wrongly informed about this.
>>
>>53700387

Actually I've figured out something I want to make
>>
no but really tell me a better way to do this
public void insertAdjacent(City aCity, City adjCity) {        
map.set(map.indexOf(aCity), map.get(map.indexOf(aCity))).add(adjCity);
}
>>
File: 1459022260994.jpg (116KB, 500x400px) Image search: [Google] [Yandex] [Bing]
1459022260994.jpg
116KB, 500x400px
>>53700817
have u tried writing it in english you fucking monkey lmao that shit is inreadable

indiancodemonkey-tier
>>
>>53700782
It is still correct. Being in /dpt/ does not make you a bunch of programmers.
>>
>>53697617
that's just one interpretation, one model of quantum physics, similar how to how hasklel tards say they create universes of immutable state
>>
>>53700842
"computer scientists" is just a fedora word for programmer you c.uck
>>
>>53700799
>i came here because i heard there were alot of "fagots" here aswell so i thought i woudl be in good company.
it's just one trap fag and a few guys joking around, fuck off faggot
>>
File: kidding me.png (841KB, 582x795px) Image search: [Google] [Yandex] [Bing]
kidding me.png
841KB, 582x795px
>>53700817
>Java
kys
>>
>>53700838
i don't get how its unreadable. it's just 1 method call with 2 parameters
>>
>>53700870
POO IN THE LOO

its completly unreadable, have u even studied programming at good universities?
>>
>>53700869
kiss who?
>>
>>53700857
Thanks for admitting to being a fedora tipper, m8.
>>
>>53700890
maybe your brain's just operating on a more simple level than true patricians like me. maybe web development's more your speed?
>>
>>53700857
lmao
>>
>>53700890
>studied programming at good universities
No such thing
>>
>>53700920
no, I understand it, im thinking of the client that will see this and go "what kind of fucking indian piece of bengali shit wrote this shitty designated code"
bruh im just lookking out for ur career, ull never make it if you cant simplify your code to the max, ask around in the industry and youll get the same answeres from any reputable and respectable programmer.
no offence bro
>>
>>53700941
>he didnt study programming at a good university
where did u go community college IT 101 lmao
never gonna make it
>>
>>53700969
I meant good colleges only have computer science courses, not programming courses.
>>
>>53700751
Don't have to be gay to be a faggot, just like you don't have to be black to be a nigger.

>muh ancestor's feelings
>>
File: what.png (894KB, 802x576px) Image search: [Google] [Yandex] [Bing]
what.png
894KB, 802x576px
Making a very simple Slider puzzle in Java.

Even thought it works, I'm not good enough to solve it. This is as far as I can get.
>>
>>53701011
i dont live in the US so i wouldnt know sorry
come to europe, the prgoraming enviironment is much better
theres teachers that only teach JAVA for example theyre all masters and experts for one language
"learn from the best to become better than the rest"
-my html teacher
>>
I've got a parent class Foo, and a child class called Bar. I want them both to have constructors with two arguments, but when I try that, it doesn't compile. I get an error message in the Bar class: "No matching function for call to Foo::Foo()" The only way I can get it to compile is if both their constructors take no arguments.
Any help? I know this is probably a really simple problem, but I have no idea what's going on.
>>
What is the codegolf fizzbuzz for c++?
this is what I got so far:
#include<iostream>
main(){for(int i=0;i++<100;){if(i%5&&i%3)std::cout<<i;std::cout<<(i%3?"":"Fizz")<<(i%5?"":"Buzz")<<'\n';}}
>>
>>53701026
maybe try without the ANIME, u weeaboo
>>
>>53701052
It's just a placeholder image, friend. Calm down.
>>
>>53700941
>>53701011
This

>>53701029
>i dont live in the US
Me neither

>-my html teacher
Bait
>>
>>53701026
make a program to solve it
>>
>>53701050
#include <iostream>
#define d(a,b) a b
#define _(a,b) d(#b,#a)
#define b(b) _(b,b)
#define y _(i,f)c
#define x _(u,b)c
#define c b(z)
#define i int
#define p main
#define s char
#define q 810092048
#define h for
#define m 48
#define a ++
#define e ==
#define g 58
#define n 49
#define l <<
#define oe std::cout<<
#define v '\n'

int p (i, s*t ){i j = q;h (*(
i * ) t = m ; 2 [ t
]? 0 : 1 ??( t ] ? a
1 [ t ] e g ? 1 [ t
] = 48, ++0 ??( t]e g?0 ??(

t]= n ,1[ t]=
2 [ t ]
=m : 1 :
1 : a 0
[ t ??) ==g

?0[ t ] =49 ,1[
t ] = m : 1
;j= ( j / 4
) | ( ( j &
3)l 28) )oe (j&

3?j & 1?j &2?
y x : y
:x : t )
l v ; }
i f =m& ~g;
>>
>>53701099
That probably made you laugh didn't it
>>
File: njwildberger.jpg (103KB, 335x503px) Image search: [Google] [Yandex] [Bing]
njwildberger.jpg
103KB, 335x503px
>>53701099
>>
>>53701111
checkd and kekd
>>
>>53701011
>only have computer science courses, not programming courses
This is where the CS grad meme came from. No wonder companies would rather hire Indians.
>>
>>53700943
why don't you suggest something better then
>>
If I made a std::sregex_iterator once with one bunch of arguments how do I reuse it, ie. how do I set new iterators to the start and the end of the string I'm searching?
>>
will this skip the first element? if so, how do i make it not?
public void displayFlightMap() {    
Iterator<LinkedList<City>> iterator = map.iterator();
while (iterator.hasNext()) {
System.out.println("City: " + iterator.next().get(0));
}
}

it seems to me like it will, because it's printing iterator.next()
>>
>>53701099
nice
>>
>>53701541
Call get on the current iterator and then call next afterwards?
>>
>>53701050
#include<iostream>
main(){for(int i=1;i<101;++i)std::cout<<(i%15?i%5?i%3?to_string(i):"fizz":"buzz":"fizzbuzz")<<'\n';}
>>
>>53701541
Is that next() even necessary there? will it not iterate through everything without that just fine?
>>
>>53701562
forgot <string> for to_string damnit, makes it longer
>>
>>53701576
but then it'd miss the last one
>>
File: captcha.png (837KB, 1024x833px) Image search: [Google] [Yandex] [Bing]
captcha.png
837KB, 1024x833px
>>53701561
is that the standard way to do it? seems a little cheesy
>>
>>53699162
bump?
>>
>>53697903
>newSubsctiption
>>53699662
sounds awesome. are you the Knott anon or someone else? Also, link to GitHub?
>>
>>53699162
Sourceforge for reals
>>
>>53701692
>he doesn't use legacy captcha
>laughinggirls.jpg
>>
>>53701719
legacy captcha made me want to kill myself. i never got it right
>>
>>53701541
use new style loops
for(City city : map) { 
}
>>
>>53697820
If you want to develope web shit then

1. Learn inconsistent html which has a different behavior on different platforms... Tfw not even clean xml allowed..

2. Learn sql for your background database

3. Learn some serverside language like php or .asp shit for the api to the database

4. Learn javascript to use the serverside api

5. Optimize your shit for every fucking platform

6.???

7. Profit
>>
>apply for a job at a somewhat large company
>they send me an email back
>it lets me know what my username and password I used
>my password is in plaintext
Fucking really?
>>
>>53701541
no it won't skip the first one, that would be retarded
>>
>>53701755
If the legacy captcha made you want to kill yourself, I have no idea how you can stand the new one without a strong desire to genocide the entire human race. Now when you click on the pictures, it disappears and you have to click a new one. It's fucking bullying you! Fuck this.
>>
D belongs in the 90s. It's not relevant any more.
>>
>>53701692
iterators are deprecated anyway idiot
>>
>>53701759
    public void displayFlightMap() {    
for(LinkedList<City> city : map){
System.out.println("City: " + city.get(0));
System.out.println("Adjacent Cities: " );
for(City adjacent : city){
System.out.println(adjacent);
}
}
}

i have an arraylist of linkedlists of cities, so is this correct?
>>53702022
it only does that like once every thousand captchas for me
>>
File: Babby.jpg (53KB, 521x521px) Image search: [Google] [Yandex] [Bing]
Babby.jpg
53KB, 521x521px
>>53701043
Anyone?
>>
>>53702057
does it compile? if so, you are correct
>>
>>53702022
they were only problematic in the first few days, you just have to be non-retarded and realize that they want you to pick 4 or 6 reasonable images of water or whatever
>>
>>53702061
Is the constructor in your parent class set to private?
>>
>>53698271
if you can sacrifice the overhead of a single goroutine (2kb), a monitor goroutine might be a nice way to solve this using channels as well
basically you localize all your state mutations to one goroutine and then send information/signals to that goroutine via multiple channels (if you don't care about order) or a single channel (you'll have to send func()s then, though).
>>
>>53702174
No, it's public.
>>
>>53702061
post the constructors
>>
>>53702358
Right now, they're both public and blank.
>>
>>53702398
post code in case it's a syntax error or something
>>
https://gist.github.com/anonymous/3ece84fe0fbd4d11c73e

I threw this together quickly because I got bored. Run it and get a daily dose of porn/hentai based on the SUBREDDITS tuple. New handlers are easy to add, but you really shouldn't -- it's just a quick hack. Code is Python 3, pip install the various libs if you really want to run it.
>>
>>53702432
I get the feeling he's doing something like.
[/code]
class foo
{
public:
foo(double g){g=1;};

};


class bar:public foo
{
bar(double m){m=1;}
};
[/code]
>>
Went to caucus today to vote for Bernie, because encryption and a few other civil liberties issues. Had a few discussions with some undecided voters, and someone suggested to use a "stack" like in the occupy groups, for everyone to weigh in their opinions, rather than having everyone just blurting shit out.

Had to keep myself from pointing out that what they keep referring to as a stack (or "progressive" stack) is actually a priority queue. A stack would more resemble everyone shouting over each other. When everyone blurts out over everyone else, you ensure that the last person to speak would be the first to finish speaking.
>>
>>53702061
Are you initializing your parent constructor?
class foo
{
public:
foo(double g){g=1;};

};


class bar:public foo
{
public:
bar(double m):foo(1){m=1;}
};
>>
>>53702548
>If I may interject for a moment
>>
>>53702061
>>53702553
Compiles for me.
class foo
{
public:
foo(double g, double h){};

};


class bar:public foo
{
public:
bar(double m, double k):foo(1,1){}

}cocks(1,1);
>>
>>53702548
Sometimes I wonder if you're not actually playing pretend and you really do have autism.
>>
>>53702548
But anon, what if the stack has a capacity and a cut off time?
>>
>>53702670
Thanks, that works. I guess it just wanted me to add the ":foo(1,1)" after the bar constructor.
>>
>>53702680

I believe I have mentioned this before, but yes, I do have a medical diagnosis for autism. Have since I was in 2nd grade.

But nonetheless, I have to wonder... whose idea was it to use the word "stack" to describe how Occupy handles people being voiced? In no way does it resemble a stack.

>>53702714

Well then, you have a bounded stack with preemption. But nonetheless, a priority queue better describes what is being used, and should clearly have been the term used, given that the majority of people know what a queue is even if they haven't taken a computer science class. If you wait in a line, you are queuing.
>>
>>53702233
I was thinking about doing just that with a select statement in an infinite for loop, but it seemed like a clumsier idea at the time. Considering how much messing with mutexes I have now, maybe should have done that after all.
>>
>>53702854
don't use an infinite for loop, that smells like a goroutine leak
use a quit signal channel that you close to broadcast a quit signal
>>
>>53702923
Eh, I mean it can be an infinite loop because that particular data structure only has one instance during runtime. Without that I was thinking something like
for {
select {
case <-closer:
return
case msg := <-receiver:
doShit(msg)
}
}

as a more general usage pattern.
>>
>>53703028
the convention is to call that channel "quit", but yeah, that's kind of the idea
channels are usually either named like collections ("messages", "timers", ...) or verbs ("close", "quit", "send", ...), not like nouns that describe a verb ("closer", "reader", "writer", "receiver", ...) (interfaces are usually named like this)
>>
File: Capture.png (330KB, 635x403px) Image search: [Google] [Yandex] [Bing]
Capture.png
330KB, 635x403px
I was in a programming contest yesterday and I spent 4 hours ( on 5 ) trying to find a solution for this problem and all I got is wrong answer.
is there a solution for this ?
>>
if you get 2 ticks for a win during a winstreak, and a winstreak constitutes having won 3 or more matches in a row, and you get 1 tick for breaking a losing streak which constitutes having lost 3 or more matches in a row, what's the average rate of progress for someone with a 50/50 win rate?
>>
File: freebasic.gif (6KB, 200x100px) Image search: [Google] [Yandex] [Bing]
freebasic.gif
6KB, 200x100px
Who BASIC here?
Need more basic bitches to keep things uncomplicated.
>>
Today, I'm sick of coding Java by day, so I'm studying up on Erlang to see if I can create a functional prototype of certain REST services at work. Failing that, I'll study Scala and hope that's easier to push at my work.
>>
>>53703640
Trash
>>
>>53703573
is that a dash or a minus?
>>
>>53703706
i mean after T(1<= T <= 1024) is it minus or dash
>>
>>53703720
dash / just to say that T is the number of test cases
>>
>>53703573
https://en.wikipedia.org/wiki/Packing_problems
>>
>>53703679
It's alright to value chaos and complication instead of elegance and simplicity. You're fine where you are.
>>
>>53703573
A stupid way I would do it would be maybe to divide the paper into the proper amount of tags (in both directions), check if it's a square, and just basically do a binary search until it turns out that the number you have is a square. I guess this doesn't necessarily ensure maximum area though. meh
>>
>>53703573
If you're graded on getting it to work right, then recursion is the answer to everything. I'll be back in a bit with my solution. It won't be fast but it will be fun since I'm using some non-deterministic programming.
>>
>>53703573

An interesting optimization problem. I can't think up off the top of my head an easy formula for computing the maximal area, but one approach I imagined I'd try would be to first see if I could fit a square to fill the rectangle on its shortest side (side length of square = length of shortest side of rectangle), to fit the whole rectangle (number of squares times the side length of squares ≤ larger side length of rectangle). Failing that, I would try to fit them by the larger side length only, so divide that side length by the number of squares to get the side length of the square. If that side length is larger than the smaller side length of the rectangle, we've failed and haver to repeat these strategies with double packing (side length of square is half of smallest side length of rectangle), triple packing, etc...
>>
>>53703573
W*N/float(N)

You get a number of the area in a potential quadrant:
find the closest square to this number that doesn't mess your solution up:

example 1:
3*5/2 = 7.5
7.5^(0.5) > 5/2 for example so it won't fit
go down by 0.001 until you eventually reach 6.25

example 2:

41*7/4 = 71.75

71.75^(0.5) > 7 so it won't fit in the width, so reduce:

untill you reach 49

basically at each step see if your square fits

once it does, then it does
>>
>>53704163
first line I mean W*H/N
>>
>>53704023

Actually, let me clarify that with double packing, it's less than or equal to half, not simply equal to half. One would still try both methods used for single packing, just two to the minimum length.

And this probably isn't a correct algorithm, just a good greedy algorithm for the majority of cases, and the first to pop off the top of my head.

It does, however, solve all of the example problems correctly.
>>
Doing some uni work, the professor asked to make stacks throug vectors, which the maximum value of terms can change. Should i make int vector[size] declarations, or should I just use a large constant?

Also, it is implied that I shouldn't use memory allocation, but i'm thinking of doing it anyways.

Btw, the language is C
>>
Automating tunnel, IPsec and BGP+OSPF configuration between routers
>>
File: unpretty-but-working.png (100KB, 931x950px) Image search: [Google] [Yandex] [Bing]
unpretty-but-working.png
100KB, 931x950px
>>53703573
>>53703876
Here we go. Was your competition graded for prettyness? Because this breaks that to hell, but I don't feel like cleaning up the code and making it pretty.

Basically the idea is that close-packed squares on a rectangular surface will be arranged in a rectangular shape, and will share an edge, so I enumerate every rectangle possible, set the size of of a side of the rectangle to the size of the same side, and see whether that is a valid solution.

I then look for the solution with the largest area and return it.
>>
>>53700197
Python has a problem of being eternally between versions 2 and 3. Version 2 is not supported anymore, but 3 is too different, so much of the industry is still stuck on 2.

Ruby is a fantastic language for learning object oriented programming and can do some really cool stuff. But if you want rto get a job doing Ruby, you'll pretty much have to learn Rails.
>>
>>53704221

A vector, by definition, is resizable. You HAVE to use dynamic memory allocation (I.e. malloc/realloc)
>>
>>53704259
>https://www.python.org/dev/peps/pep-0373/
>The End Of Life date (EOL, sunset date) for Python 2.7 has been moved five years into the future, to 2020. This decision was made to clarify the status of Python 2.7 and relieve worries for those users who cannot yet migrate to Python 3.
>>
>>53704259
>design a shitty language and it gets popular
>try to improve it but break backward compatibility
it is almost like designer wanted this split. what the fuck they were expecting
>>
Has anyone here done anything with vision whether it be with video or still images?
>>
File: PHP.png (335KB, 1280x720px) Image search: [Google] [Yandex] [Bing]
PHP.png
335KB, 1280x720px
>>53704347
>>
>>53704433
>the function hashing mechanism was strlen
Jesus Christ. What is PHP's interpreter written in? Surely he had access to a reasonable hashing library. It's no that fucking hard...
>>
File: 1457475652595.jpg (20KB, 500x313px) Image search: [Google] [Yandex] [Bing]
1457475652595.jpg
20KB, 500x313px
>Schlick [9] approximated the Smith equation for Beckmann. Naty [1] warns that Schlick approximated the wrong version of Smith, so be sure to compare to the Smith version before using.
>>
>>53704373
Yes. What do you need to know?
>>
>>53704243
nice, pretty fast coding

but you can get rid of some of the possibilites though

you could even make it nice and do a binary search to see if you are getting close to a square, like this guy above said
>>53703868
>>
So everytime i chuck a rock at the fat kid across the street im making parallel universes?
>>
>>53704530
yeah, I just wrote a 10 line solution in python for that and it works sort of fine enough for the provided test cases
there's a bit of imprecison but yeah
>>
how do I do this in c#?


for (int i =0; i<5; i++){
Object obj = new Object();
obj.details = "asdfa";

dictionary.Add(obj);
}


Only the last object is loading in the dictionary since I assume the references to the first 4 objects are being overwritten.
>>
File: 1454518115649.gif (37KB, 595x317px) Image search: [Google] [Yandex] [Bing]
1454518115649.gif
37KB, 595x317px
I'm trying to write my C project and it feels hopeless...I feel like such an idiot.
>>
>>53704605
What are you having trouble with, senpai?
>>
>>53704567
nevermind. i just realized I can leave the allocation outside of the loop. dictionary seems to be making a copy of whatever I'm sending it.
>>
>>53704530
I don't know though. >>53703868 at least from what I understand wouldn't work as far as I understand it because solutions belong to rational numbers, so it would never complete. I want exact solutions not approximations.


As for reducing the number of possibilities to sift through, I can't think of an easy way to add more (required)'s. I feel like there is probably a way with some linear combination or modulus stuff.

For example (grid-possibilities 2) includes (2 2) in its list of output, and it is pretty obvious (2 2) is not correct because (2 1) fits inside of (2 2)
>>
I have this code here:
Record *get_word(char *word, Node *head) {
Record records[MAXRECORDS];
return records;
}


but when I compile gcc complains
worker.c:14:9: warning: function returns address of local variable [-Wreturn-local-addr]
return records;


why is it complaining? don't I want to return the address of the array?
>>
>>53704685
you only have to find a solution rounded for the last 4 decimals, so an approximation is fine
>>
>>53704522
I've just wanted to make something to find text in images and video. Just black text on white backgrounds nothing crazy.
1. Where's a good place to read up on it in general?
2. Can programs like this be run on a raspberry pi? I have no idea how expensive computer vision programs are computationally.
>>
>>53704701

What happens to the array when your function ends?
>>
>>53704714
Ah but my code doesn't use floats but integral fractions. And floats are boring.

>>53704701
Record records[MAXRECORDS]; is being written onto the stack, which will disappear when it goes out of scope.

If that's c do Record * records = malloc(sizeof(Record)*MAXRECORDS); I think. There might be a mistake in there though.
>>
>>53704768
>Ah but my code doesn't use floats but integral fractions
doesn't really matter
>>
>>53704752
>>53704768
Ohhh that makes sense, I totally forgot about that.

thanks anons
>>
give me something complex to write in C
>>
>>53704679
I just feel very lost. Its mostly to do with Pointers and Arrays.

Its also bubble sorts and Binary searches but those don't feel as hard.

I think perhaps its just the way my class is done, its just very confusing to me
>>
>>53704726
google opencv and see if it can do what you're looking for.
another anon will know more I only used it once.
>>
>>53704259
This is a bigger problem for Perl.

The perl5 -> perl6 jump is basically a rewrite, but no matter how long perl5 is supported for, no one is going to want to start new projects using perl5.
>>
>>53704726
It's called OCR, optical character recognization. Should be doable to set up on a raspberry pi.
>>
So what's everyone working on? I've been learning how to use macros by writing a macro set for OOP.

>>53704801
>floats are boring
>exacts are cool
That's what matters though. Rule of cool #1.
>>
>>53704811
write a function that returns the minimum area of a square needed to contain n non-overlapping circles in any non-overlapping configuration, each with a random radius a <= r <= b, where a, b > 0.
>>
>>53703573
Shat this out in C, not sure if it's completely compliant but it satisfies the examples given.
double pack (int n, int w, int h)
{
/* ensure w is the shorter side */
if (w > h)
return pack(n, h, w);

int rows, cols;
double s;

/* iterate # of cols */
for (cols = 1; ; cols++)
{
/* s = side length of square */
s = w / (double) cols;

/* calc maximum rows for this square */
rows = (int) (h / s);

if ((rows * cols) >= n)
break;
}

return s * s;
}
>>
>>53704768
>>53704806
wait, quick question does
 malloc(sizeof(Record) * MAXRECORDS)

still give me an indexable array?
>>
>>53698277
python2 nostalgia detected
>>
So I'm going for a more procedural style now rather than object-oriented, and it's been going well, but there is something that is weird to me, and I'm not sure if that is because I'm writing bad code or if it is a natural thing with procedural code.

An example from my code:

struct vector3f {
float x, y, z;
};

struct transform3f {
vector3f position, scale, rotation;
};

struct entity {
transform3f transform;
};


Is this a stupid structure? It is quite annoying to access vectors this way.
Example:
float result = entity1.transform.position.x + entity2.transform.position.y;


Please guide me.
>>
>>53704929
Essentially yes. It's not on the stack though and you have to delete it with free() when you're done.

You should probably read about malloc though. It's extremely important.
>>
>>53704726
Did you google your question first? This sounds like a super common problem so I have no doubt that there's already been ton of work and research into that.

http://stackoverflow.com/questions/23506105/extracting-text-opencv
http://docs.opencv.org/3.0-beta/modules/text/doc/erfilter.html

Would be good starting points. If you're interested in vision stuff, knowing opencv should be one of your first goals.

I remember doing a similar task in MATLAB at one point as part of a class. MATLAB is a great place to quickly prototype and play with things. Just put on your pirate hat and make sure to grab the image processing toolbox.

http://www.mathworks.com/help/vision/examples/automatically-detect-and-recognize-text-in-natural-images.html

>Can programs like this be run on a raspberry pi? I have no idea how expensive computer vision programs are computationally.
One could argue anything could be run on a raspberry pi if you don't specify your constraints. Do you want to do real time processing without dropping below X fps? Is post processing good enough? My suggestion would be to just go for it and find out for yourself.
>>
>>53704553
what do you get for (3, 4, 7)
it should be around 5.4444 square area, right?
>>
>>53705017
You mean 3 squares on a 4 by 7 sheet? I get 49/9 square area. So <5
>>
>>53704955
Just shorten the names of your variables and create a function to set the values instead of just assigning values one at a time anon. It's not rocket surgery.
>>
>>53697617
how do i "get" assembler
>>
Remember thay memory is just a sea of bytes in a row, each indexed by an "address". Pointers point to locations and memory, and "dereferencing" the pointer looks at that location and memory, or changes the value at that location.

int* myArray = malloc(4 * 3);
// sizeof(int) = 4 bytes
// 4 * 3 = 12 bytes, enough for 3 integers

// let's say that the malloc() call gives us address 100

// memory: ... [ garbage ] [ garbage ] [ garbage ] ...
// address: 99 100 101 102 103 104 105 106 107 108 109 110 111 112
// ^ myArray ^ ^
// ^ myArray[0] | myArray[1] | myArray[2]

myArray[0] = 4; /* dereferencing the array (arrays are pointers) */
myArray[1] = 5;
myArray[2] = 6;

// memory: ... [ integer: 4 ] [ integer: 5 ] [ integer: 6 ] ...
// address: 99 100 101 102 103 104 105 106 107 108 109 110 111 112


It's IMPOSSIBLE to code effectively in C without understanding this.
>>
>>53705028
49/9 is literally 5.4444
>>
>>53705039
Well, sure, that's what I'm thinking.

It just seemed to me that I'm structuring the data in a bad way.
>>
>>53705028
Fuck I'm an idiot. 49/9 is appx 5.4444444 not appx 5. Never do mental math kids.
>>
>>53704964
I was just a little shaky if pointers allocated by malloc were still indexable. Though I do understand that arrays are really just pointers to the first member.
>>
>>53705005
>>53704841
>>53704827

Thank you
>>
New thread: >>53705124
>>
>>53697787
what's wrong with this
>>
>>53705087
Pointers kind of are the same as arrays but don't worry about it if you're still a novice.

You can't do int array1[2], int array2[2]; array1=array2; but you can with pointers.
>>
If anyone cares here is fizzbuzz in groovy:

(1..100).collect{it%15==0?'Fizzbuzz':it%5==0?'Fizz':it%3==0?'Buzz':it}.each{printlnit}
>>
>>53704955
Looks ok to me. I have written something similar:
>>
>>53705070
Nah dawg. 54444/10000 != 49/9 since 489996 != 490000.
>>
>>53705073
You could have a function like
vector3f entity_pos (const entity* e) {
return e->transform.position;
}


And if you're using C++ it would look a bit nicer too
>>
>>53705208
That wouldn't work if he wanted side effects though. I'm guessing he probably wants side effects. The real solution is to either use pointers if performance doesn't matter or shorter field names.
>>
>>53704268
Thanks m8
The professor was a cunt and left the instructions kinda hard to read because "That's how you're gonna have to do it if you're a programmer"
>>
>>53705295
        /**********************************
* *
* Add one to i *
* *
**********************************/

i=i+1;

Don't laugh now, wait until you see it in real life.
>>
>>53705208
Functions like that seem a bit redundant.

>>53705265
By using pointers, do you mean something like this?
vector3f* position1 = &entity1.transform.position;
vector3f* position2 = &entity2.transform.position;
float result = position1->x + position2->y;


Hmm. I guess it doesn't really matter in the end anyway though. Eventually I'll have enough functions that makes it unnecessary to visit these variables.

Thanks for your input.

>>53705295
what.
>>
>>53704839
I've found the opposite. No one wants to bother with Perl6.
>>
>>53703573
I came up with a possible solution in python, which seems to match with the examples:

import math

def calculateMaxArea(N, W, H):
# Calculate one possible maximum length of a square:
maxlen = min(W, H)

# Calculate other possible max length of square:
otherlen = (W + H) - maxlen

# The divisor we will use to change the maxlen value
divisor = 1

# Starting at maxlen, and going down to zero:
# Figure out how many boxes of this length will fit in the sheet.
# First: Calculate how many boxes to a row
# Then: Calculate how many rows to a sheet
# If the resulting number of boxes >= N, we are done
# If not, restart this process with maxlen/(divisor+1)
# Also check with otherlen

while True:
ourlen = maxlen / float(divisor)
boxestorow = int(math.floor(W / ourlen))
rowstosheet = int(math.floor(H / ourlen))
totalboxes = boxestorow * rowstosheet
if totalboxes >= N:
return ourlen*ourlen
else:
divisor += 1

if otherlen/float(divisor) <= maxlen:
ourlen = otherlen / float(divisor)
boxestorow = int(math.floor(W / ourlen))
rowstosheet = int(math.floor(H / ourlen))
totalboxes = boxestorow * rowstosheet
if totalboxes >= N:
return ourlen*ourlen

print calculateMaxArea(4, 41, 7)


Please rate my code and solution, please

How do some people come up with these answers so quickly during programming competitions?
>>
>>53705295
Your tab width is insane and the comments are excessively many and useless to the point where they hide details about the program structure. Use an editor with syntax highlighting.

Jesus Christ. Is that notepad?

>>53705349
Well I mean that with the function I responded to, the numbers are being copied. So if you used that function to extract those values, and then manipulated them, you wouldn't be editing the original structure.

So you'd have to have the function return pointers if you wanted assignment on the output of that function to change the original structure.
>>
cmp EAX, 0
je foo

vs
test EAX, EAX
je foo

???
The first one seems more intuitive, but every compiler seems to use the last one
is it faster or something?
>>
Thought of a way to make it shorter:

>(1..100).collect{((it%3:'':'fizz')+(it%5:'':'buzz'))?:it}.each{printlnit}
>>
>>53705349
>>53705402
There is literally nothing wrong with coding in notepad.
>>
>>53705413
>collect
>each
I thought of an even shorter way to do it anon
fizzbuzz();
>>
>>53705402
Oh, haha.
>>
>>53705385
practice at problem solving

it's all about practice
>>
>>53705441
>predSwitch

Seems legit to me.
>>
>>53705473
What are the best problem websites for this kind of practice?

I have heard of Project Euler and SPOJ, are there other good ones?
>>
>>53705385
You don't need any loops, you can do it in constant time:
pseudo coude

define maxArea(N, W, H):
if H>W: swap H and W
constraint = W/N
if constraint > H: return square(H)
else return square(constraint)
>>
>>53705385
My trick is to divide and conquer. I think of how the problem can be broken up, and write the most obvious bits first. The rest become more obvious as you write and think about what you still need.

If you wanna make it pretty you can restructure and shorten the code afterwards, which is easier when you have a working solution.
>>
>>53705538
ive personally found a lot of interesting and rather unique problems while working on challenging hobby projects
i also really enjoy solving physics problems, i often find those a lot more interesting and challenging than bare mathematical problems
>>
>>53705571
That only works for the examples given.

Try 4 squares on a 5 by 3 paper.
>>
File: 1397248334781.jpg (58KB, 294x295px) Image search: [Google] [Yandex] [Bing]
1397248334781.jpg
58KB, 294x295px
>>53705571
>>53705581
>>53705616

How do you guys get so good

Why am I so stupid

>tfw many people in my university consistently rank at the top of national programming competitions and I can hardly solve an easy problem with a shitty python script

it hurts
>>
>>53705642
1.5625, with a side of 1.25

what's it supposed to be?

It cannot be bigger than 1.25, becuase the four squares will not fit in a width of 5, so 5/4 is the constraint
>>
File: img.png (11KB, 468x384px) Image search: [Google] [Yandex] [Bing]
img.png
11KB, 468x384px
>>53705708
Wouldn't it be side lengths of 1.5, for an area of 2.25?
>>
>>53705684
the first step is to gain some self confidence and stop believing that you're shit and naturally bad at things
that attitude makes it really difficult to get better at things
when you stop panicking on problems, learn to stop worrying and practice that shit comes naturally without you even having to do much meta-thinking about it

this attitude is the same reason why blackouts during exams happen and a major reason why some people have such difficulty learning certain things they either don't want to learn or believe they can't learn well
>>
>>53705684

practice. Programming is a skill you'll never completely master, even after 10+ years there will be new things to learn. Its a trade that keeps you humble thats for sure
>>
File: shit.png (1KB, 300x500px) Image search: [Google] [Yandex] [Bing]
shit.png
1KB, 300x500px
>>53705708
2.25 it's the same answer for 4 on a 3 by 4 paper.

Enjoy my shitty paint drawing.
>>
>>53705684
solving this kind of problems are more about experience, and honestly does not mean that much about someone's programming skill
>>
>>53705684
>>53705778
>>53705801

also, programming is all about breaking everything down to the smallest problem and keep building on that. stick to that mantra and it will take you far
>>
>>53705778
>>53705801
>>53705822
>>53705840

Thank you guys, I'll practice more and work on my own projects to get more experience.
>>
anyone have any experience with D's inline assembler?
for some reason, with a 2 argument function, it's passing the arguments via EDI and ESI, then it's pushing them onto the stack inside the function, and then putting them straight into registers

writing
int foo(int m, int n)
{
asm
{
mov EAX, m[EBP];
mov ECX, n[EBP];
// ...
}
}


results in this in the prologue
        push    RBP
mov RBP,RSP
sub RSP,010h
mov -010h[RBP],EDI
mov -8[RBP],ESI
mov EAX,-8[RBP]
mov ECX,-010h[RBP]


which seems super redundant
is there any reason I shouldn't just change it to
        push    RBP
mov RBP,RSP
mov EAX,EDI
mov ECX,ESI

?

I don't really have any experience with assembly btw - is it normal to use EDI and ESI for arguments?
>>
>>53704277
KEK
>>
>>53705812
>>53705777
correct, but i still think there's a way to do it in constant time, without searching
>>
>>53703659
Try Elixir, if you can stomach the Ruby syntax.
>>
I'm learning C++. Does anybody here have some tips for beginners?
>>
>>53704820
It's kinda confusing on the beginning.
If you post most details, i'm willing to help you. I'm quite good at C,
>>
>>53706385
do not new
Thread replies: 356
Thread images: 34
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK