[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
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 36
File: 1460066248490.png (260 KB, 600x800) Image search: [Google]
1460066248490.png
260 KB, 600x800
Old bread: >>53941429
what ya working on /g/?
>>
>>53947631
No functional, no future anon.
>>
D is literally perfect
>>
>when you come up with a mini project idea at 1am and mostly finish it at 8am
>>
>>53948578
go to fucking bed anon
>>
>>53948588
I've been in bed the whole time actually

but goodnight dpt
>>
>>53947631
I've never been to hackernews before so is it just a meme that they shill FP all the time?
>>
>>53947631
Currently writing some integration tests for my company's web application.
After that I'll probably go back to working on my own web application.
>>
File: bglisp.jpg (42 KB, 500x225) Image search: [Google]
bglisp.jpg
42 KB, 500x225
>>53947631
>>
I want to write a website. I know it's basically html and css right? But html tutorials are all garbage and give you the extremely fundamental bear-bones kind of idea/design/layout.

So yeah where do I REALLY start? What keeps me from reusing source from other websites exactly?
>>
To learn myself programming, should I start with OOP or functional programming?
>>
>>53948747
Ruby on rails, or Wordpress.
>>53948756
OOP, don't fall for these new memes.
>>
>>53948825
It's for my own company I'll be doing this. Wordpress wouldn't really be an option would it? I mean it's not so professional.

I have good knowledge of C to a point where I've programmed my mouse driver a couple of years ago/some rootkits. Would that at ALL be helpful when it comes to Ruby or is it completely different?
>>
>>53948756
You should start with imperative or functional.
OOP is usually combined with either one of those as an extra layer and it will only make it harder for you to learn since you suddenly have to learn double the concepts.
>>
>>53948918
If it's for your own company then try doing it in javascript, and write the business logic in whatever backend controller you guys already use.

If this is an enterprise company using legacy web frameworks, then sorry, you're kinda stuck doing what they're already doing to pull data from the database. You can have fun with the presentation layer in Javascript though.

But if your company is more modern, you could write ruby 'gems' <packages> as standalone <packages> and import then into your framework. But I don't know your arch so I can't help out that much, sorry if this aint helpful
>>
>>53948548
>systems programming language
>has a garbage collector
>>
>>53949149
It is not garbage collected by default, it's only GC'd if you use standard library functions which use the GC and I think at this point there's like one module that uses the GC and the rest is all non-GC
>>
>>53948578
>proving that people who post here are neets with no industry experience.

Thanks anon
>>
File: oop.png (313 KB, 1680x740) Image search: [Google]
oop.png
313 KB, 1680x740
>>53948756
Learn a modern, powerful, multi-paradigm programming language like Javascript.
>>
Why do startup hipsters use Ruby the whole time above anything else?

I get data scientists using python or R, but whats with engineers and Ruby?
>>
File: js.png (3 KB, 403x95) Image search: [Google]
js.png
3 KB, 403x95
who thought javascript was a good idea?
>>
File: carmack.jpg (2 MB, 1819x1866) Image search: [Google]
carmack.jpg
2 MB, 1819x1866
>>53949340
We all know the real masterminds use C
>>
>>53949367
But Carmack uses Racket now ;) functional programming wins again!
>>
>>53949367
Actually Carmack uses C++ mainly.
>>
>>53948756
just learn how to program before stepping into ridiculous cults
>>
>>53949390
He made his own Racket bindings for the Oculus Rift and his rockets.
>>
>>53949349
I do.
>>
>>53949418
Ok, he uses more than one language. But C++ is his main one.
>>
>>53949367
Going through Quake3 networking code.
>We all know the real masterminds use C
Fucking why is this so true?
>>
>>53949418
he should just use haskell
>>
>>53949445
He has shat on C++ on his twitter more than once. He obviously acknowledges Racket is superior.
>>
>>53949340
Because ruby on rails is a quick way to build a minimum-viable-product and get funding, the tradeoff is that it doesn't scale so you'll have to rewrite it using something else.
>>
>>53949485
Fuck off.
>>
>>53949488
Racket is a cute toy language for toy projects. He uses C++ for his serious projects.
>>
File: javascript.jpg (71 KB, 700x500) Image search: [Google]
javascript.jpg
71 KB, 700x500
>>53949441
I also unironically like Javascript, and write it for a living, using node.
>>
>>53949485
Hey Haskell is nice but I think he has some reason to choose a Lisp over it since he definitely knows how to program Haskell too.

Haskell shouldn't just be used because it can.
You have to look at what the right tool for the job is.
>>
>>53949390
you can 'use' c++ and only use some of the syntactic sugar c++ adds, while writing 'c' code

no reason to use a C compiler in this day and age imo
>>
Carmack's Racket shit is only meant to make basic VR apps like 3D photo viewers
>>
>>53949540
Pretty sure he uses C++ and not C in C++. He has talked in his twitter about C++ techniques like RAII for better memory management.
>>
>>53949540
For embedded systems, realtime systems and operating systems a C compiler makes sense since it can produce more predictable code compared to a C++ compiler.

Compile times might also be a factor.

But yeah other than that it doesn't really matter if you use the C compiler.
>>
>>53949349
What is the problem?
>>
>>53949565
He has also used racket to build other things, only going to C++ when performance is needed
>>
>>53949524
I use JS to write cool prototypes. Right now I'm doing >>53948648
>>
Hey, I'm wondering if this would be the right forum for my question.

I would like to learn a technology that'd very likely to serve me for the next 10 years when looking for sidejobs. It should be something quite stable and in-demand. Nothing like the web 6.0 hipster scene where I have to sweat every time I update the production environment, which I am doing now and it's soul-sucking shit. I want to concentrate on my studies and get a PhD before I turn 35.

I was thinking of Swift / iOS or C# / ASP.NET. The latter would also offer the chance to work with desktop applications if needed.
>>
>>53949610
Such as...?
>>
>>53949629
Swift or HTML5/Javascript. Web won't go anywhere.
>>
>>53949629
If you learn how to make web applications in C# then you should be set.
There are created new services with it right now and a lot of legacy applications.
>>
>>53949632
He mentioned he used it for some server needed by oculus.
>>
>>53947631
#ifndef vector_H
#define vector_H

#include <windef.h>

typedef struct {
unsigned num_entries;
void* data;
} vector;

void* vector_find(vector *self, void* value, size_t value_size);
void vector_insert(vector *self, void* value, unsigned idx, size_t value_size);
void vector_delete(vector *self, unsigned idx, size_t value_size);
void vector_push(vector *self, void* value, size_t value_size);
void vector_pop(vector *self, size_t value_size);
void vector_free(vector *self);
void* vector_index(vector *self, unsigned idx, size_t value_size);

#define vector_INIT { 0, NULL }
#define vector_INDEX_NOTFOUND 0xFFFFFFFF

#define vector_TEMPLATE(name, prefix, type) \
typedef vector name##_vector; \
static inline unsigned prefix##_vector_find(name##_vector *self, type *value) \
{ return vector_find(self, value, sizeof(type)); } \
static inline void prefix##_vector_insert(name##_vector *self, type* value, unsigned idx) \
{ vector_insert(self, value, idx, sizeof(type)); } \
static inline void prefix##_vector_delete(name##_vector *self, unsigned idx) \
{ vector_delete(self, idx, sizeof(type)); } \
static inline void prefix##_vector_push(name##_vector *self, type* value) \
{ vector_push(self, value, sizeof(type)); } \
static inline void prefix##_vector_pop(name##_vector *self) \
{ vector_pop(self, sizeof(type)); } \
static inline void prefix##_vector_free(name##_vector *self) \
{ vector_free(self); } \
static inline type* prefix##_vector_index(name##_vector *self, unsigned idx) \
{ return vector_index(self, idx, sizeof(type)); }

#endif
>>
>>53949677
He also mentioned networking was easier in racket, something about global singletons being needed in his c++ code.
>>
So, using FIFOs to communicate between processes, isn't it prone to a lot of rewriting if i have to do stuff like doing a splitted mergesort (as exercise)? I have to give the half of data to 2 new processes, and write it back from those 2 when it's over. Seems like it would be a lot more efficient to just have shared memory and pass pointers or some shit.
>>
>>53949696
>windef.h
>>
>>53949635
Front-end is not going anywhere but it's changing fast. One year ago it was all Angular 1.x but now everyone's flocking to React, CycleJS, Elm and whatever. It's also a domain where the clients want constant this and that, because if the logo is not 1px to the right by yesterday, the whole world is going to burn. I'm not keen on answering to my phone 24/7 just because of silly demands. It would be nice to do something very well the first time, then forget about it and get paid.

I suppose Swift would be good since people consider mobile apps to be "ready" once they implement all the required features. It's also something most idiot ass execs are not constantly looking and finding "terrible bugs" aka "wrong colours" or "ugly fonts".
>>
>>53949615
>I'm thinking about moving the heaviest part (fitness function) into standalone C++ binary and interacting with it via standard IO / JSON. That can wait though.

You know that Node itself is C++, and you can write native modules for it to do things in C++ land instead of Javascript land.
>>
Quick question /dpt/:

My program reads several numbers from stdin representing lengths in metres. Each number has one decimal place. I want to avoid using floats, so I will work in millimetres instead.

How can I use scanf to read a float, multiply by a 1000, and store in an int without truncating the value?
>>
>>53949782
>without truncating the value
No idea why you want to do this. I guess you can use floor() but that returns a double that you need to truncate to an int.
>>
>>53949725
i actually used DWORDs and PVOIDs but was ashamed of it, so i replaced everything but forgot about windef
>>
>>53949756
Yeah, I can write a node extension. I have studied this feature, looked at NAN etc. I think it will be much easier to hook a separate C++ process via stdio/JSON than make a NAN module.

Also I'll move all code to C++ when the system stabilizes.
>>
>>53949837
To make it clearer, I want an input of 14.1 to be stored in an int as 14100. By "without truncating the value" I meant that the precision wasn't lost, so I wouldn't get something like 14000.
>>
>>53949782
Read two ints separeted by a decimal point
>>
>>53949904
Simple, thanks.
>>
>>53949875
>By "without truncating the value" I meant that the precision wasn't lost, so I wouldn't get something like 14000
What the fuck?
Just do "int m = 14.1 * 1000;"
>>
File: Dilbert-280x300.jpg (16 KB, 280x300) Image search: [Google]
Dilbert-280x300.jpg
16 KB, 280x300
>mw /dpt/ can't even average two ints in C
>>
>making a UDP server
>UDP has no connect()/accept()
>need to recvfrom 30*64 packets
>need to have a pre defined worker thread pool to wait for and handle packets asynchronously
>need to somehow signal thread to start reading from a list of datagrams
>most likely have to call mutex to all worker threads when one thread starts

This is fucking disgusting, what's the "pure" way to handle this in C?
>>
>>53950067
Use select() instead of threads
>>
>>53949963
int res = a - b/2;
>>
>>53950105
But I gotta go fast. recv 1920 packets per second fast. I did a select test and it just wasn't worth it, I still had to spawn worker threads otherwise I got packet loss
>>
File: 1458936497688.png (45 KB, 547x233) Image search: [Google]
1458936497688.png
45 KB, 547x233
Is there any programming language that supports multiple constructors with the same parameters?
>>
>>53950120
>a-b/2
>>
>>53950157
I'm sure you can make some sort of bastardization like that in c++ with templates.
>>
>>53950157
why
>>
>>53949629
c# basically
>>
>>53950157
>>53950157
keep one constructor, make different init functions, match them against whatever you need
>>
File: 1458944751478.jpg (62 KB, 735x320) Image search: [Google]
1458944751478.jpg
62 KB, 735x320
>>53950234
I have a Race class. Sometimes I need to initiate it with a list of all waypoint, other times with a list of tagged waypoints by the current user. But I figured out just now that when I need one I don't need the other, so I just got to make two new classes that extend Race.
>>
Learnpythonthehardway.org says to use Python 2 instead of 3. Will there be any problems if I just ignore that and use 3 with the tutorial instead?
>>
>>53950448
>reading anything written by Zed "the cuck" Shaw that isn't Rails is a Ghetto

baka senpai
>>
>>53950448
there is momentum for python3 nowadays
>>
>>53950067
I'm thinking all worker threads calling recvfrom since recvfrom blocks until it receives a packet so no mutexes, no thread signals, no pending threads taking up performance and it sounds clean and effective.

Shit, yeah, this might work.
>>
File: color-head.png (94 KB, 259x259) Image search: [Google]
color-head.png
94 KB, 259x259
>>53949701
Over GNU/Linux, right? There's this zero copy IO functionality in recent versions of the main kernel... look into the GNU/Manpage for fcntl.

Maybe the receiving process can't write into the sender's memory this way tho...
>>
>>53950157
Vala I think. Because of GObject basically, since there's no overloading in C so you're already obliged to come up with constructor names.
>>
File: hqdefault (1).jpg (12 KB, 480x360) Image search: [Google]
hqdefault (1).jpg
12 KB, 480x360
Have you ever made a serious use of setjmp/longjmp, /g/? What about call/cc? And Racket's call/comp?

Personally, I tried to write coroutines using jmp, but then I realised that you still have only one stack, so it failed and it doesn't count. As for call/cc, I've only done it for early returns, no usage that would be incompatible with Racket's call/ec. And call/comp: never. Maybe I should read the papers the docs link to?
>>
How long would it take a programming newbie to learn the following Java concepts (assuming they were a NEET):

>Java overview and the basic language elements: Introduction to Java. Elements of Java programming. Review of programming constructs of the C family languages (Language structure, conventions. Variable and data types. Arrays. Operators. Expressions. For, if, while, do). Main method.
>Objects in Java: Objects, Classes, Packages, Generics, Inheritance, Interfaces.
>Classes/packages.
>String classes, System classes, Collections.
>Error handling: Exceptions (unchecked exceptions, throw).
>>
>>53948667
shots fired
>>
You guys are really bad at programming I bet I could out program all of you easily
>>
>>53951066
fite me

print "Hello, world!"

wew lad
>>
File: 1451316939583.png (98 KB, 810x1195) Image search: [Google]
1451316939583.png
98 KB, 810x1195
>>53951066
How does "out programming" someone work?
>>
>>53951074

printf("Hello, world!");


Checkmate.
>>
>>53951074
>>53951079
>>53951093
Simple you both are given a programming challenge and are judged based on how good your code is
>>
>>53951124
Let me guess, it's going to be "who can write fizzbuzz as short as possible" or some other babby ass shit.
>>
>>53951145
import fizzbuzz
fizzbuzz.do()
>>
>>53951145
roblem

In A.D. 2100, aliens came to Earth. They wrote a message in a cryptic language, and next to it they wrote a series of symbols. We've come to the conclusion that the symbols indicate a number: the number of seconds before war begins!

Unfortunately we have no idea what each symbol means. We've decided that each symbol indicates one digit, but we aren't sure what each digit means or what base the aliens are using. For example, if they wrote "ab2ac999", they could have meant "31536000" in base 10 -- exactly one year -- or they could have meant "12314555" in base 6 -- 398951 seconds, or about four and a half days. We are sure of three things: the number is positive; like us, the aliens will never start a number with a zero; and they aren't using unary (base 1).

Your job is to determine the minimum possible number of seconds before war begins.

Input

The first line of input contains a single integer, T. T test cases follow. Each test case is a string on a line by itself. The line will contain only characters in the 'a' to 'z' and '0' to '9' ranges (with no spaces and no punctuation), representing the message the aliens left us. The test cases are independent, and can be in different bases with the symbols meaning different things.

Output

For each test case, output a line in the following format:

Case #X: V

Where X is the case number (starting from 1) and V is the minimum number of seconds before war begins.

Limits

1 ≤ T ≤ 100
The answer will never exceed 1018

Small dataset

1 ≤ the length of each line < 10

Large dataset

1 ≤ the length of each line < 61

Sample

Input

Output

3
11001001
cats
zig
Case #1: 201
Case #2: 75
Case #3: 11
>>
>>53951171

This looks like your HW.
>>
>>53951171
This is really simple
-Find the number of different characters in the string (n) - this is the base
-Assign the following numbers, in order: 1,0,2,3,4,5,6,7,8,9,A,B... Therefore ab2ac999 -> 10213444
-Convert the number in base n to base 10
-Print result

The logical thing is this:
For any number, the lower the base, the lower the value. 1010 in base 2 is 10 and in base 4 is 68. You also can't have a base lower than the number of digits, as that becomes nonsensical.
>>
>>53950919
>Have you ever made a serious use of setjmp/longjmp, /g/?
Yeah. Good for implementing exceptions or for jumping out of deep non tail trivial recursive calls.

I've also tried implementing coroutines with setjmp/longjmp. It's not sufficient, you can't longjmp down the stack. However I'm attempting to implement segmented stacks and use a modified setjmp/longjmp for coroutine semantics. All functions become coroutines in that case. The implementation is quite the challenge. You either need a runtime to detect stack overlap and fix everything up (inconceivable) or just mmap every stack, which is not only costly, but the kernel tries to mmap regions close to the break, so any further sbrk will collide and so malloc must use mmap exclusively past that point. Also, the coroutines have to be stackless, otherwise when you run out of space after a function call or allocing on the stack (you can't really tell without additional runtime), you would have to mmap a new region and copy the entire stack. Yuck. And there is a lot of asm.

I wonder how the Go guys did it.
>>
you're all fucking cancer, not just the OP for posting the thread extremely early, but the rest of you too because you went to his thread with no one posting a link to the new one
>>
The number 64 is cute.
CUTE!
>>
>>53951348
this was my first thought too,

>assign digits using [1,0,2,3..] in the order you encounter them
>convert to base 10

but why are you helping with homework?
>>
>>53951372
Actually reading about it on cloudflare's blog right now. They do exactly what I said. Fuck me.
>>
>>53951171
you got this off some currynigger site didn't you, with the annoying poorly written backstory and overly verbose problem statement
>>
File: 1460064094673.jpg (102 KB, 942x1080) Image search: [Google]
1460064094673.jpg
102 KB, 942x1080
Does anyone know anything about yEnc?

I've spent the last 4 hours banging my head against the wall. These fucking python libraries do not work
>>
>>53951466
Never mind I'm a dumb fucking weeb. Any time I ask a question here I find the answer myself in literally minutes.
>>
>>53951372
>Good for implementing exceptions
longjmp is terrible for that because it's inefficient as shit.
>>
>>53951424
Not homework. Google Code Jam.
>>
>>53951554
It's as efficient as it possibly can be. Just want to reset the ip and sp, damned be the other registers?
>>
>>53951372
https://blog.cloudflare.com/how-stacks-are-handled-in-go/
>>
File: 1459300814132.gif (498 KB, 320x240) Image search: [Google]
1459300814132.gif
498 KB, 320x240
anyone here use exercism.io? pretty cool for picking up new languages, and forces TDD. relatively small community and when you submit an exercise you can see what other people who solved it did. since its small now people actually comment on your stuff and suggest things. its especially fun in go because the test files they give normally have benchmarks.
>>
>>53947631

I just fizzbuzzed in python now what?
>>
>>53943382
what if you use a typedef'd pointer type
>>
>>53952032
fizzbuzz in ruby
>>
>>53951686
Just read that. Seems super inefficient, but that is the only way I've been able to see it being set up. Might be simpler and more efficient if I make the programmer manually keep track of the current stack usage and grow when needed.
>>
>>53948747
HTML and CSS are good but you should really learn Javascript + jQuery if you want to do anything without using wordpress etc
>>
File: browser.png (731 KB, 1500x665) Image search: [Google]
browser.png
731 KB, 1500x665
just added proper text sizing options to browser #112. feels good.
>>
>>53952041
http://stackoverflow.com/a/750237

IT'S ALL OGRE NOW
>>
>>53952184
will it ever not look like an unreadable sack of shit
>>
Anyone here ever wrote anything to do with exhentai?

Any idea why curl exhentai.org doesn't even give me the sadpanda image.
>>
>>53951298
>>53951348
>>53951464
Thank you for doing my homework it works every time
>>
>>53952194
what's "unreadable" about it?

everything's perfectly legible.
>>
>>53952219
>everything's perfectly legible
anon...
>>
File: 400k.png (167 KB, 256x384) Image search: [Google]
400k.png
167 KB, 256x384
>>53952219
>everything's perfectly legible
>>
>>53952184
You should make everything more closer together there is too much white space
>>
File: Untitled.png (2 MB, 1680x1050) Image search: [Google]
Untitled.png
2 MB, 1680x1050
>>53952230
>>53952242
>>53952254
the idea is to cram in as much info as possible, while also remaining usable. It's a tough balance to strike, which is why there's so many options that can be adjusted.

show me another catalog type of app that's capable of displaying ALLof a board's threads on ONE SCREEN, without needing to scroll around to see them. that's the entire point of browser. It's why I made it in the first place.
>>
>>53952332
it's disgusting, you're still going to have to mouse over most threads, so you should just have scrolling anyway. and make the post backgrounds solid
>>
Best commits?

f6c6070 Go fuck yourself hippies. Remove 'potentially offensive word blocking'.
>>
File: 1422248533014.jpg (51 KB, 500x681) Image search: [Google]
1422248533014.jpg
51 KB, 500x681
>>53952332

awful.
>>
>>53949166
Unfortunately most GCs have stop the world pauses (Erlang is an exception). This means only one thread that uses the GC can mess up the rest of your program.
>>
>>53952359
>f6c6070
Where is that
>>
>>53948667
Lmfao
>>
Anyone know an easy curses like library for Java? I tried lanterna and charva but lanterna has basically no documentation and charva requires you to get ANT and other shit, and I just want a small contained curses like library for java for doing some simple gui shit in the console.
>>
File: Untitled.png (633 KB, 840x1010) Image search: [Google]
Untitled.png
633 KB, 840x1010
>>53952345
>you're still going to have to mouse over most threads

no, you have to mouse over EVERYTHING, which is a feature. lazily moving the mouse around and using the scroll wheel to read replies is the simplest possible way of browsing.

and a solid bg covers up too much of the grid, and has too much whitespace. I prefer the look of aero glass.
>>
>>53948747
Depends what type of website. If it's a simple static website, you could get away with minimal HTML/CSS/JS, but if you want to make full blown web apps, you'll probably want to learn a framework like React or Angular. I was new to web dev a year ago, but now I'm working on a fairly complex web app. I use React on the front end with MongoDB, Node and Express on the backend.
>>
>>53952332
>while also remaining useable
>>
What is the best language to start with?
>>
>>53952551
java
>>
>>53952564
NO NO NO
>>
>>53952551
C was, for my generation
>>
>>53952574
epic meme shit fag
>>
>>53952431
where can i download the source code for this
>>
>>53952551
python

>>53952564
I had Java in my CS101
Literally only 30% people passed kek
>>
>>53952622
because you're literally retarded and python isn't any good for actually learning programming, it's just easier to pass a class with python because the bar is set so incredibly low
>>
>>53952622
Java and C# are horrible introduction languages.
I'm teaching C# to others right now and I regret not choosing Python or Ruby instead.
>>
>>53952551
whatever you do, don't learn fucking python or ruby, they're FUCKING SHIT AS HELL
>>
>>53952647
So, should I stick to Python as my 1st language? Why is this better than others?
>>
>>53952675
Why is this worst?
>>
>>53951162
#!/bin/zsh
fizzbuzz
>>
>>53947631

It seems every legitimate program has already been created

I find myself drawn to doing dubious projects easily
>>
>>53952700
python is shit for many reasons. you don't really learn types and arrays. it prefers to silently fail instead of giving clear errors (java has great errors so it tells you what you're doing wrong in real time as you write the code). python is just overall dumbed down, it doesn't even have a proper for loop. it's made by an idiot, for idiots. with python you probably won't learn OOP because the OOP in python is ridiculously disgusting, most people just pretend it isn't there, all you'll really learn is the most basic control flow which you learn literally in the first day of learning java.
>>
Why are Programming Java introduction courses have such a low passing rate? Most people fail in Java courses and they never want to program ever again
>>
>>53952777
because of shit teachers and retarded disinterested students

if you're interested in programming just learn it yourself

https://docs.oracle.com/javase/tutorial/
>>
>>53952681
Java/C# will generally confuse new folk because everything is a class. new programmers might call this "boilerplate code"
public class HelloWorld { 

public static void main (String[] args) {
// write your code here
}

}

which has lots of distracting parts for a new learner. plus you need to compile, so half-working programs will literally get rejected by the compiler. whereas python is sort of a soft padded box that'll run your shit even if it contains errors. Python's version of the above:
//write your code here

modern professional python code starts looking like Java/C# (and honestly you should be using a compiled language for professional programing) but it takes a few years to realize why those languages are structured that way so python is a perfectly acceptable beginners' language.
>>
HOW DO YOU CHECK IF TWO MOTHERFUCKING 2D LINE SEGMENTS INTERSECT

THIS THING IS FOR 3D, CROSS PRODUCTS AREN'T FUCKING DEFINED IN 2D SPACE

https://www.quora.com/Given-four-Cartesian-coordinates-how-do-I-check-whether-these-two-segments-intersect-or-not-using-C-C++

HOW DO YOU FUCKING DO IT IN 2D
>>
>>53952826
ok it's in a footnote
>[2]: Here, the "cross product" of two 2D vectors U, V = U × V = U.x * V.y - V.x * U.y, which gives a signed scalar. Actually AB × BC = 2 * Signed area of triangle ABC. Strictly speaking (told by a friend with math background), cross product is only defined in 3D and 7D space, but here we sort of pretend that these two 2D vector are 3D vectors lying on a plane in the 3D space. "Wedge product" seems to be a more appropriate term, but I have been seeing people use this term and "cross product" interchangeably. (See also: Is the vector cross product only defined for 3D?)

fuck you
>>
>>53952803
But Python is used pretty much for the entire Machine Learning/ Deep Learning/ Neural Networks thing.
Python is literally the #1 thing in academia and data science now.
>>
>>53952867
it's only used for scripting with libraries that do everything for you. it's shit for actually learning programming
>>
>>53952826
Write the equations segments as lines. Solve for their intersection. Reject the solution if it is outside of either segment. All are trivial operations.
>>
>>53952675
>don't learn fucking python or ruby

ur retarted m8
>>
>>53952879
Agreed Java is the number one language to learn programming
>>
>>53952880
it needs to be super efficient for shader code. the quora solutions seems more efficient

>>53952895
8/8
>>
>>53947631
Haskell people always talk about "no side effects", but autism seems to be a pretty obvious side effect of using Haskell.
>>
>>53952903
we're talking about a few additions and multiplications. how optimized does it need to be?
>>
>>53952611
nowhere. maybe someday when I'm done with it, but doubtful.
>>
>>53953022
burn the closed source witch
>>
Working on K&R Exercises since I'm somewhat of a beginner to all of this. I'm on 1-20 and 1-21 and recently finished them.

How'd I do?

http://pastebin.com/AFSFChqT
http://pastebin.com/7Zp7WGgp
>>
>>53953036
it only runs on Windows anyway (which is also closed-source).
>>
https://www.youtube.com/watch?v=bIjeJaMPH60

>cd..
>cd..
>cd ..
>ls
>python helloworld.py
>print('hello world\')
>SyntaxError: EOL while scanning string literal

oh
>>
>>53952953
I laughed
>>
>>53953051
What are they supposed to do?
>>
>>53953127
Oh, sorry. I forgot to post the descriptions.

Exercise 1-20.
>Write a program detab that replaces tabs in the input with the proper number
of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns.
Should n be a variable or a symbolic parameter?

Exercise 1-21.
>Write a program entab that replaces strings of blanks by the minimum
number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab.
When either a tab or a single blank would suffice to reach a tab stop, which should be given
preference?
>>
>>53953018
the quora solution to check for a proper intersection is

AB × BC) * (AB × BD) < 0 && (CD × DA) * (CD × DB) < 0


with

U × V = U.x * V.y - V.x * U.y


doing it with linear equations might be more efficient, idk, i can't be bothered to type out the solution right now, but with linear equations you'd have a minimum of 3 comparisons (check the slope and check range) or 1 division and 2 comparisons (calculate the slope and check range)
>>
>>53952551
Pascal desu.
>>
>>53953153
If they work you are golden. Code looks like you know what you're doing.
>>
>>53952551
Scheme
Oz
Python
>>
>>53953061
this shit pisses me off so much it's incredible really
>>
>>53952551
Basil
>>
>>53948667
would have been so nice if that was an actual quote
>>
>>53952551
I would say python or javascript
>>
>>53953322
Aside from edge cases I can't really bring up to mind, they are working like they should.

Hearing that really makes me relieved. They were sloppy and confusing messes before I got around to simplifying them.
>>
what ide should I use for android? should I use the google one?
>>
How bad is the overhead with using floating point arithmetic?
I'm reading data from sensors using a microcontroller, and I could either use 2 bytes for the whole number and 2 bytes for the decimal, or just use a 4 byte float.
I wouldn't get any data loss from a float because of the sensor's precision, so it just comes down to speed and readability.
>>
I need help. I'm not very good at programming yet and I can only really dev productively when using visual studios and C#.

I like being on my linux machine much more than my windows machine. I'm running a very slim arch linux set-up right now,
>Firefox
>Hexchat
>Kate
>mplayer
>lxde with openbox

I want to be able to develop games cross platform, right now I'm just making text based games, what language works well for development on linux. My gut instinct tells me c++.

I don't know how to live without intellisense.
>>
Want to program, have a headache.
>>
>>53953541
>got around to simplifying them.
That's important. If you are capable and willing to do it you'll go far. And don't get distraught when you get to pointers. They are hell the first time around.
>>
>>53950963
>hackernews
4-6 months
>>
>>53951410
lets fuck anon
>>
>>53953565

For text based games, you should use a scripting language like Perl or Python. They have great support for string manipulation with flexible and easy to use data structures built in.
>>
>>53950963
a month or two
>>
>>53953170
shit doesn't even work, it almost works but only intermittently, i have it set the vertex color to red and it flashes when it should just be a consistent red
>>
File: 1454485929649.png (738 KB, 1280x720) Image search: [Google]
1454485929649.png
738 KB, 1280x720
>>53949963
function average(a,b:integer):integer;
result:=(a+b) shr 1;
end.
>>
>>53949254
I'm a college student with an incoming internship, nice try though :')
>>
>>53952681
USE C++ for fawk sake. It's versatile enough to where you can write anywhere from a simple program to a hardcore OOP program.
>>
>>53952681
sure.
>>
I have a file like this:
1010101 101101
1101101 101101
0110101 101101
1111010 101110
1110110 101110
1101111 101110
... etc


How can I turn it into this in Python?

in = [
[1,0,1,0,1,0,1],
[1,1,0,1,1,0,1],
[0,1,1,0,1,0,1]
]

[
[1,0,1,1,0,1],
[1,0,1,1,0,1],
[1,0,1,1,0,1]
]


? This is what I've tried:
        inputData = [[[[int(digit) for digit in inputValues], [int(output)], ] for [inputValues, output, ] in line.split()] for line in f]

but that didn't work too well (at all, actually)

I'm pretty darn rusty on python, so excuse that.
>>
>>53954244
"forgot" to add the last 3 lines from the text file, imagine they're in the lists like the first 3 lines from the text file are
>>
>>53954244
it's in a text file like that or...?
>>
>>53947631
Hello I'm working on some homework for my C class and I'm kinda stuck. I working on this function that where i pass two values in as a pointer and then have to set them based on user input. my problem is that i get a segmentation fault when i set it. you guys got any ideas why this is happening?

void setParameters(int * length, int * difficulty) {

int q = 1;
int len;
int diff;
while(q){
printf("\nChoose a length for the code (5-10 numbers).\n");
scanf("%d", len);
*length = (int)len;
if (*length >= 5 && *length <= 10){

break;
}

}
while (q){
printf("\nChoose a difficulty (1, 2, or 3).\n");
scanf("%d", diff);
*difficulty = (int)diff;
if( *difficulty >= 1 && *difficulty <= 3)
{
break;
}
}
//return(*length,*difficulty);
}
>>
>>53954266
side not i was just throwing things at the wall with this version so it might be a bit bungled and over complicated in the current state.
>>
Is there a logging framework that automatically indent logging statements? For example if I wrote
print "Starting Task A"
print "Doing one part of Task A"
print "Doing the second part of Task A"
print "Done with Task A"

it would print
Starting Task A
Doing one part of Task A
Doing the second part of Task A
Done with Task A

automatically? Obviously I could insert tabs manually but that doesnt work when moving blocks of code around of calling functions recursively.
>>
>>53954266
Firstly, for scanf you have to use the address operator (&) when passing things in for input. You've got to give the memory address of the variable for scanf to put something into it, not just the value of the variable (which is what you're currently giving the function)

You should be compiling with -Wall and -Wextra in order to avoid this, btw

Further more, // comments aren't technically aloud in C. Encase 'em in /* comment */ instead.

Also,
while(q)

is equal to
while(1)

which is always a sign you're doing something wrong. You should never be leaving a loop with a break (in theory anyway, there are some cases you might want to but they are rare).
See that if statement with the break? Put the expression of that if statement in your while loop instead of 1

jesus christ actually, this code is a fucking mess. You haven't even taken into account
>>
>>53954422
>// comments aren't technically aloud in C

Lad...
>>
>>53954266
scanf expects you to give it a pointer; when you pass it len or diff, you're handing it garbage data.

try again without the extra variables.
>>
I have the following snippet of code:

input.getline(&a[0], 50, ',')


How do I make it so it reads either for a ',' or another character?
>>
>>53954422
>Further more, // comments aren't technically aloud in C. Encase 'em in /* comment */ instead.

That's only if you want to stick to the C89 standard though.
>>
>>53954488
>That's only if you want to stick to the C89 standard though.

Which nobody should be doing. You should be using the newest possible standard.
>>
>>53954488
>>53954505
C89 is the only C standard.
>>
>>53954422
>>53954437
trying this but still getting a segmentation fault.
 
void setParameters(int * length, int * difficulty) {
while(*length < 5 && *length > 10){
printf("\nChoose a length for the code (5-10 numbers).\n");
scanf("%p", &length);
}
while (*difficulty < 1 && *difficulty > 3){
printf("\nChoose a difficulty (1, 2, or 3).\n");
scanf("%p", &difficulty);
}
>>
File: umarusee.jpg (113 KB, 1280x720) Image search: [Google]
umarusee.jpg
113 KB, 1280x720
>>53954244
http://ideone.com/f4WMKt
>>
>>53954558

gommit suidide
>>
If I have a MySQL database table assigned to $Recipes that has food recipe titles, and recipe descriptions in different columns, how can I call upon that with a foreach loop drop down so that when I choose one and press a button, it prints out the description of the item selected?
>>
>>53954600
We're not on the same level.
>>
>>53954567
Just `length` and `difficulty` this time. They're pointers, so when you use their names you are automatically referring to their addresses.
>>
>>53954622

Right, you're a moron.
>>
>>53954558
k tard
>>
File: ayyyyyyy.gif (2 MB, 540x285) Image search: [Google]
ayyyyyyy.gif
2 MB, 540x285
What will give me more money through freelancing, web dev or software dev?

Thanks fellas.
>>
>>53954628

do you mean like this i tried as a %i and %p and they both give me a segmentation fault.


void setParameters(int * length, int * difficulty) {
while(*length < 5 && *length > 10){
printf("\nChoose a length for the code (5-10 numbers).\n");
scanf("%i", length);
}
while (*difficulty < 1 && *difficulty > 3){
printf("\nChoose a difficulty (1, 2, or 3).\n");
scanf("%i", difficulty);
}
>>
>>53954264
...yes

>>53954568
Marvelous!
>>
File: stoolworth.jpg (144 KB, 1395x1395) Image search: [Google]
stoolworth.jpg
144 KB, 1395x1395
>daily reminder that the Son will not restore us to Heaven until we program away the evils of this world.
>>
>>53954600
gtp you're gr8
>>
>>53954674
web dev because you're probably a fuccboi
>>
>>53954702
Look, learn to set compiler flags. Then it will bitch at you in all the right ways.

-Werror -Wextra -Wall


By the way, your loop logic is wrong.
>>
>>53951171
>posting Google code jam problems
Shoo shoo pajeet
>>
>>53954266
>>53954567

This might help. I hope it's formatted correctly.

 Access type |      Create new      |       Copy existing      | Reference existing | Value | Address 
-------------|----------------------|--------------------------|--------------------|-------|---------
Value | int x = 1; | int x = other; | N/A | x | &x
Pointer | int* x = new int(1); | int* x = new int(other); | int* x = &other; | *x | x
Reference | N/A | N/A | int& x = otherInt; | x | &x
>>
>>53954849
I have my compiler flags just like this. and its no longer throwing any warnings on that function. and is it its supposed to be a number 5-10 and a number 1-3. if its less than 5 or more than 10 it asks you again.
>>
>>53954840
hmm so what?
>>
File: umarusummer.jpg (56 KB, 848x480) Image search: [Google]
umarusummer.jpg
56 KB, 848x480
>>53954802
same but with numbers converted to integers
http://ideone.com/aVh1zM
>>
>>53954889
so are you saying i should try somthing along the liens of.

scanf("%i", int* length);
>>
reminder that this happens when you let women in the industry

https://www.youtube.com/watch?v=_dkeD3OZ218
>>
>>53954952
web dev takes less skill so go with that
>>
>>53954986
>desktop apps with web languages
obviously fucking retarded
>>
>>53954674
If u want them checks just go web and make sure u learn more than just html/css.
>>
>>53954567
I think the problem may be what you're passing.
form your call like this
 int length=6, difficulty=6;
setParameters(&length,&difficulty)


The implementation I see doesn't seem problematic aside from that length has to be greater than 10 and smaller than 5. So you shouldn't enter the loop.
Same for the difficulty, 3 and 1.
>>
>>53955050
>cobol missing
>>
File: enviados2975.jpg (7 KB, 100x100) Image search: [Google]
enviados2975.jpg
7 KB, 100x100
>>53955082
>thinking were still in the mesozoic era
>>
>>53955120
>thinking banks don't pay money to people
>>
File: mr4.jpg (547 KB, 2404x1198) Image search: [Google]
mr4.jpg
547 KB, 2404x1198
>>53955130
no they just rob you
>>
>>53952551
Just learn C first, like a real man.
>>
>>53955157
>durr capitalism is bad

Retardation.
>>
>>53955225
>stockholm syndrome
>>
>>53952551
THE SNAKE ONE
>>
>>53955243

Not even. There is nothing in history that has genuinely helped people as much as capitalism has.

It has ended so much suffering, it's incredible.
>>
>>53955225
>he supports capitalism
good goy, now, how about you give us more shekels?
>>
>>53955290

This is capitalism, so I have the freedom to say no.
>>
File: PAPAWONTALLOWIT.png (793 KB, 642x650) Image search: [Google]
PAPAWONTALLOWIT.png
793 KB, 642x650
God damn this is shitting me off.

Whenever I decode a yEnc file there is always extra bytes being added, and I have no idea where the fuck they are coming from.
What the fuck am I doing wrong? This stupid NNTP shit adds random rules everywhere, I've tried removing double dots.

8 hours and I'm fucking nowhere.
>>
>>53955060
>>53954889
>>53954849
>>53954628
>>53954422
>>53954422
>>53954422
>>53954437

Thanks for all the help i got it to work and i feel like i have a better understanding of how pointers work :^)


it was the loop at the end there not segmentation fault. when you guys where saying the loop was wrong i thought you meant the less than and grater than not the $$ -> ||
void setParameters(int * length, int * difficulty) {
while(*length < 5 || *length > 10 ){
printf("\nChoose a length for the code (5-10 numbers).\n");
scanf("%d", length);
}
while (*difficulty < 1 || *difficulty > 3){
printf("\nChoose a difficulty (1, 2, or 3).\n");
scanf("%i", difficulty);
}
}


>>
Haskell
>>
I just started learning C, and this project is to double the size of a picture with a .ppm format, so I made a struct called Pixels that holds the three int values, R-G-B for each pixel, and I'm making a matrix of this Pixel struct, is this a way I could go about it? It's within a nested for loop that traverses the matrix and increments i and j by 2 each time.

new is the struct that holds the new (larger) matrix and original is the one it's copying from.

    new->pixels[i][j]  = original->pixels[i][j];        //the pixel that is being duplicated
new->pixels[i][j+1] = new->pixels[i][j]; //pixel copied to the left
new->pixels[i+1][j] = new->pixels[i][j]; //pixel copied to the one below
new->pixels[i+1][j+1] = new->pixels[i][j]; //pixel copied to the one bottom-left diagonally
>>
>>53955436
It really annoys me that Haskell is called a bad language because there are som zealot retards out there who say you should use Haskell for everything.
>>
>>53955448
the last line is bottom-right diagonally*
>>
>>53955333
Why are you even doing any of that bullshit? Usenet is dead.
>>
File: filthy degenerates.gif (93 KB, 500x447) Image search: [Google]
filthy degenerates.gif
93 KB, 500x447
>>53955452
It annoys me that people judge languages by the (cherry-picked) people that use them.
>>
>>53955489
I think it sucks for a lot, but for anime it's pretty good. Most of the time it's faster to get something through usenet than to wait for torrents.
>>
>>53955157
feel the bern xd

https://www.youtube.com/watch?v=UOQb7Y5QVO8
>>
>>53955452
haskell is shit no matter the use case
>>
>>53955050
any idea on what the most future-proof jobs are? I don't want to work for five years only to be out of a job because everyone from the upcoming generation can do what I do
>>
>>53955634
All languages are shit no matter the use case.
We just use what works best.
>>
using UnityEngine; 
using System.Collections;

public class player : MonoBehaviour {
// Offset
private Vector2 pos;

// Offset Direction
private int x,
y;

// Offset Speed
public float speed = 1.5f;

// Use this for initialization
void Start () {
// set the position
pos.x = this.transform.position.x;
pos.y = this.transform.position.y;
}

// Update is called once per frame
void FixedUpdate () {
// reset position
pos = this.transform.position;

// reset offset direction
x = 0;
y = 0;

// set offset direction
if (Input.GetKey (KeyCode.UpArrow)) {
y = 1;
}
if (Input.GetKey (KeyCode.DownArrow)) {
y = -1;
}
if (Input.GetKey (KeyCode.RightArrow)) {
x = 1;
}
if (Input.GetKey (KeyCode.LeftArrow)) {
x = -1;
}

pos.x += x * speed * Time.fixedDeltaTime;
pos.y += y * speed * Time.fixedDeltaTime;

this.GetComponent<BoxCollider2D>().transform.position = pos;
}

void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.name == "solid") {

}
}

void OnTriggerStay2D(Collider2D other) {
if (other.gameObject.name == "solid") {

}
}

void OnTriggerExit2D(Collider2D other) {
if (other.gameObject.name == "solid") {

}
}
}


Going to post this in AGDG as well, but the code tag is here.

Been trying to figure out how to push an object with a BoxCollider2D back against another object with a BoxCollider2D; things definitely trigger, but what i've tried that would work on an "engine" i'd make myself don't work in this. I'll post what I normalyl use in the next post
>>
>>53955772
haskell is never what works best for people who aren't fedora-tipping faglords
>>
>>53955050
>javascript
fuck capitalism
Thread replies: 255
Thread images: 36

banner
banner
[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.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.