[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 318
Thread images: 23

File: 1489268910463.jpg (475KB, 852x973px) Image search: [Google]
1489268910463.jpg
475KB, 852x973px
Old one's at bump limit

Previous Thread:
>>59354282

What are you working on, /g/?

Quick question, are there any C++ libraries that will quickly get me the result of "n C r" (from n items, choose r)
>>
first for emaKKKKs
>>
>>59361335
It isn't a part of POSIX. Vi in the vast majority of cases will be installed in a unix-like system.
>>
>>59361370
fuck POSIX

UNIX set back computing by half a century.

We need to do away with this trash and build modern-day Lisp Machines.

That's the ONLY way to reliably get over the von neumann bottleneck.
>>
>>59361391
Well, tell it to Intel or whoever, I'd better stick with the old good vim, C and a unix-like system until that.
>>
>>59361391
LOOOOOOOOOOOOOOOOOOOL
>>
>>59361420
>>59361423
Lisp made breakthroughs that are still missing from popular languages, and those machines were truly ahead of that time. Imagine how far we would be if the Lisp Machine won the race. UNIX only became popular because it was enterprise-friendly and adopted by lots of business, not because of technical merits.

I use Linux and OpenBSD and like them both because they are the best contemporary systems available, but that just tells you how far this field has fallen.
>>
File: 1431432030106.jpg (13KB, 228x238px) Image search: [Google]
1431432030106.jpg
13KB, 228x238px
>>59361308
Please follow the established OP format. Don't go posting your shit in it.
>>
>>59361522
>automated site access
That's against the global rules, fucko
Reported, enjoy your permaban
>>
Any recommendations for resources explaining methods of determining the prime factors of a large integer in a way a crappy programmer like me can understand?

My first thought was to use something like the sieve of eratosthenes and check different combinations until I find the right one but that seems wildly inefficient.
>>
>>59361522
>Scraping HTML
>Not just using the JSON API
Also, your entire script can be replaced with
#!/bin/bash

curl -s "https://a.4cdn.org/$1/thread/$2.json" | jq -r ".posts[] | select(.tim) | \"-O https://i.4cdn.org/$1/\" + (.tim | tostring) + .ext" | xargs curl
>>
>>59361308
Here you go, buddy.
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

int choose(const int n, const int r) {
return static_cast<int>(tgamma(n + 1)/(tgamma(r + 1)*(tgamma(n - r + 1))));
}

int main(void) {
cout << choose(5, 2) << endl;
return EXIT_SUCCESS;
}
>>
File: 1455583175374.jpg (43KB, 319x310px) Image search: [Google]
1455583175374.jpg
43KB, 319x310px
>>59361647
Thats the thing since I'm so inexperienced.
There's so much stuff to learn about programming, that it becomes really overwhelming. I had no idea JSON even existed. I was writing that script in an effort to more familiarize myself with urllib, beautifulsoup, and regular exressions.
>>
How does Google Captcha work?

I'm fucking tired of these new captchas, is there any way to "force" my browser to use the old text-based ones?
>>
How do I properly abstract out Graphics from a video game with c++?

Like, I'm using pointers to abstract classes of enemies, which get created by a factory that makes the correct enemy based on the visualisation used.
Afterwards you just call the visualisation function, and the correct function automatically gets called, so far I can follow.

But then:
How do the classes know to which window/surface to draw?
Am I supposed to make an abstract window class, which creates the correct window type through a factory, and then send that pointer to the class that needs it in the constructor?
That seems like the wrong way, but I know too little of it to be sure.
>>
>>59361308
Currently implementing a look up table
>>
I don't know jack shit about build tools. I'm competent enough to write simple algorithms and use different APIs, but as soon as my system grows larger than a file or two, I lose it. Best I can do is produce a very shitty makefile, and only for super small projects.
Any helpful links or books on this?
>>
>>59361308
>What are you working on, /g/?

I am supposed to work on a JavaEE project, that is to make a simple mini "forum" like thing.
Have 2 days left and not started, don't even understand why there is so much shit with JavaEE to even get it going.
>>
>>59362109
because lol java and poo in loo and boilerplate and everything is an object, and POO
>>
what exactly does POSIX_ME_HARDER do
>>
>>59362139
>POSIX_ME_HARDER
I don't think that actually exists; it was just joked about.
>>
>>59362075
It really depends what the conditions of being drawn in a certain window are? Like, is it based on position? Are the two windows different views or are they entirely different sets of Actors? I mean most games only ever use one window and even when they use multiple it's usually just a single virtual window that's been stretched out over two display screens.

But in general, the Actors really shouldn't be the ones keeping track of where/if they need to be drawn, but rather the window areas should be the ones keeping track of which actors they need to draw and the various camera states (and then they pass the graphical context to all Actors that need to be drawn in them).
>>
>>59362150
I see what you mean, and I didn't explain properly.
I'm supposed to make a 2D game where we should be able to replace the graphics library easily.
There'll indeed always be one window, and the camera will be in a fixed position (Space Invaders).

My question was more on how to properly separate the graphics from the game for easy replacement.
If I understand correctly, you basically recommend making screens where the actors are linked to, and let the screen handle the drawing?

I thought of that as well, but then I thought it shouldn't be the responsibility of the screen.
Although I have to admit, I didn't think of making multiple screens, just a single one, which is significantly worse.
>>
>>59362197
Oh, that's easy. You just wrap it in an abstract class and pass this wrapper (often called the graphical context) to the Actor in its draw function (the game engine object, whatever you call it, should have access to both the list of Actors and the GraphicalContext object, so it does the passing). Each different graphics engine (say, one written in DirectX, one written in OpenGL) will implement the virtual methods that abstract class defines (methods will be things like "startDraw", "drawPolygon", "setColor", "endDraw", things like that). It can be a bit tricky to try and figure out before hand exactly what methods the graphical context can need in order to provide all the interactions that will be necessary, but it's not like you're releasing it into an environment where the API needs to be strictly define beforehand. You can look up SDL and see what kind of methods it provides since that is essentially what it is: a wrapper for all the various internal graphical libraries.
>>
File: 1489272073156.jpg (169KB, 1366x768px) Image search: [Google]
1489272073156.jpg
169KB, 1366x768px
>>59361741
Thank you!!
>>
>>59362241
Thanks man, I get the basic idea.
I knew this wasn't that hard of a question but stuff like proper design can keep me up all night.
>>
>>59361923
>buy 4chan gold to bypass the site's captcha
>dynamically add the old version of captcha to 4chan when you visit
>>
Why do you program /g/? I've attempted to learn stuff like python, C, and ruby before but I never stick with any of it. I mainly use linux for my casual usage but I never need to really do anything that would require me to learn stuff. The thing is there aren't any 'problems' I want to solve even if I learned a language or two. There's no applications that I want to make that isn't already being developed if it doesn't already exist. So it might not just be for me. Doing it to get a job wouldn't make me any happy and I have trouble believing companies would hire this NEET who wasted his life doing nothing for two years. So why do you do it? I'm just curious.
>>
>>59362282
Yeah, the words are scarier than the concepts. Everyone already intuitively knows what an abstraction is, they just never thought to call it a virtualized abstract polymorphic class.
>>
>>59362310
Literally the most exciting things happening in the world right now are computational/computer science related. I want to be a part of it. Whether you agree with that, though, is subjective.
>>
>>59362310
Creating something from nothing. Turning analytical thought into tangible, useful tools. We are living in the second Renaissance only this time alchemy is real.
>>
Working on computing 2D Navier Stokes on SciLab (Uni too poor for MatLab) before doing it again in C++
>>
>>59362310
It's fun to make tools / programs that "niche" communities enjoy using.
>>
I want to find a pair of elements in an array that give a given sum.

public bool hasPairOf(int[] a, int sum)
{
for(int i=0; i < a.length-1; i++)
{
if(a[i]+a[i+1] == sum)
return true;
}
return false;
}


How could I make this faster? I'm an amateur programmer, so I wan't to use simple tools that I understand.
>>
>>59362365
You don't.
>>
>>59362332
The equation can be solved with FFT.
>>
>>59362365
If the array is over a certain size you could start allocating new threads for going over it in chunks.

I would calculate how long it takes to setup the multi-threading and calculate what size of array goes over the multi-threading time on a moderate speed PC.
>>
>>59362365
Is the data sorted?
>>
>>59362378
I'm trying to do it the "normal" way, with Poisson, Jacobi iteration etc.
But thanks, I'll take a look at FFT.
>>
>>59362365
They have to be consecutive? That really looks too simple to optimize without digging into the assembly and the compiler might already optimize it anyway.
>>
>>59362412
If it's unsorted then it's O(n).
If it's sorted then it's O(lg(n)).
>>
>>59361308
I have two functions. I expected function1 to be slower than function2 but it turns out that function2 is almost a hundred times slower than function1. I suspect cache misses to be the reason for function2's slowness but I'd like to be sure. What tools can I use in order to find out why function2 is slow?
My project is written in C, I'm using linux with gcc (though I could use clang if need be).
>>
>>59362424
(K)CacheGrind
>>
>>59362414
Fourier Transform is a method to solve the Poisson problem.
>>
>>59362418

They don't have to be consecutive, so I guess mine is wrong?
>>
>>59362427
Thanks anon. I think I'm going to go with cachegrind, KCacheGrind has too many dependencies.
>>
22 years old NEET here.

Am I too old to learn how to program?
>>
>>59362439
I didn't know.
Thanks.
Is it more effective than Jacobi ?
>>
>>59362502
No, no one is too old to learn anything. If you have time and a will you can learn anything.
>>
>>59362502
Nope.
>>
File: 1450763534148.png (398KB, 508x685px) Image search: [Google]
1450763534148.png
398KB, 508x685px
>>59362502
>22 is too late to do anything
Are you think only literal autists who stated when they were 7 years old can be programmers or something?
>>
>>59362502
Also, there are people 30-50 years old from pooland who manages to "program", so if they can do it. You surely can do it even better, unless you're a poolander too.
>>
>>59362484
You're looking at a knapsack problem, then.
>>
>>59362519
>Are you think
Do you think*
I was originally going to ask that differently.
>>
Pattern recognition in log files with python.. where do you start?
>>
>>59362545
With the library that wrote the log files.
>>
>>59362502
Do you have a pair of programming socks?
>>
>>59362502
Not at all.
>>
>>59362502
Not just not too old, you have everything to become super competent. But you must get obsessed and learn learn learn and work your ass off.
>>
>>59362484
Is the array sorted or not?
>>
>>59362503
I don't know the actual equation you two are talking about but the FFT is REALLY fast.
>>
>>59362614

It's not sorted.
>>
>>59362661
dt u + u.∇u = -∇P + ν∇u
I have to solve a Poisson equation for P.
>>
>>59362503
Jacobi is a simple iterative method, FFT solves the problem in a transformed space. It depends, I guess, abilities to be scaled and parallelised, computed on GPUs, speed, accuracy, particular conditions of the fluid environment and so on.

I'm not investigated that much, it's just educational exercises of the numerical methods for PDE for me.
>>
>>59362310
I'm still a newbie programmer but part of the reason I'm learning it is because I get a lot of ideas, or small hunches about how I can make certain improvements, and make programs that are somewhat useful to my situation.

for instance: Recently i made a small python script to make an alert signal whenever there's an empty slot on a game server i like to play on, so I no longer have to compete for that slot with other players trying to join.

Then there are some bigger programs im working on like 2d games and stuff. Not super passionate about them but it's something to do.

dont rush it by trying to learn several languages at once. I only know python now and i think it's very good for beginners. Take your time, and try to pursue small projects that you think you can accomplish.
>>
>>59362661
FFT is a divide and conquer algorithm, it's n log n, the earlier DFT implementations were n^2.
>>
>>59361308
What's wrong with Pascal?
>>
>>59362755
For me too it's an exercice for numerical methods.
We code what we learnt in finite differences/elements/volumes.
>>
Anyone got some good advice to brush up on calculus? I left university and started working a few years back and now I'm going back to finish a degree for reasons. I haven't done anything with calc or formal math in years and feel I've probably forgotten it all.

The only calculus I have to take is the very last one, but I've totally forgotten the contents of the previous courses. Does meme-shit like khan-academy work for prepping for (non-shit) university math?
>>
File: glenda.jpg (4KB, 200x217px) Image search: [Google]
glenda.jpg
4KB, 200x217px
>>59361461
Plan 9 made breakthroughs that are still missing from popular operating systems, and the operating system was truly ahead of its time. Imagine how far we would be if Plan 9 won the race. UNIX only became popular because it was enterprise friendly and adopted by lots of business, not because of technical merits.
>>
>>59362779
What are plan9's breaktrhoughs? I can only vaguely remember that it did some cool shit with the way it networked filesystems and devices.
>>
I have a question regarding txt files.
I have a program for data in files, but I have a problem.
I want it to make it delete all data in a line, move all of the data one line up, then change the ids of the file after the deleted line by -1.
For example.I have ids 1-7, I delete line 4, I then want to have ids 1-6, not 1,2,3,5,6,7. I'm generating ids by the file length
>>
>>59362777
What is the "very last one?" Differential equations?
>>
hey, why do you guys hate OOP?
>>
>>59362815
Because hating on popular things is what the cool kids do.
>>
I've been up to learning lisp, but Emacs makes my whole arm hurt with RSI. Is there any sort of way to create a Lisp enviroment with Vim?
>>
>>59362832
Just switch caps lock and ctrl like it was meant to be.
>>
>>59362832
slimv
Or you could keep using emacs and use evil-mode for vim like bindings.
>>
>>59362763
Yeah I know, and on real world datasets its quick. Whats your point?
>>
>>59362851
My point is that 'quick' is a relative term. We discussed the methods to solve a PDE.
>>
>>59362815
Because it's shit.
I don't think I need to justify hatred for something that is shit.
>>
>>59362815
It's unneeded 99.9% of the time. It's a completely worthless abstraction.
It's great for producing programmers that don't actually understand how computers work.
>>
>>59362891
I dunno. It just seems so useful. You know, it makes it easier to re-use code and all. Plus It seems a little more organized. But I've not looked big time into it tho
>>
>>59362815
Same reason /g/ does anything: it's a tradition which they inherited and they have no idea why, but they will parrot it to no end because that's what they latched onto when learning. Like Thinkpads and foobar.

But pretty old and I've been around. The animosity originated from Universities switching their curriculum over from C[++] to Java. Now granted there is some legitimate design issues with Java that were raised about forcing OOP even for the program entry point and about excessively verbose default libraries, but that wasn't the real meat of the issue (C++, after all, was even then considered to be a stylistic travesty of feature bloat, but everyone accepted it). No, the real hatred was over the Java Virtual Machine. Not its concept, no, that was quite sound and quite well implemented, but its closedness. You see, at the time "Free Software" was not some niche gathering of neckbeards and conspiracy nutters, but it was actually a principal that was firmly rooted in the Mathematical origins of Computer Science and which the old guard of Academia tried and failed to preserve. To put it simply, Java marks the point in which Computer Science was ripped out of the hands of Mathematicians and into the hands of corporations, or at the very least that it became no longer a field of study, but rather a trade. And even though the concept of OOP was championed more by C++ and the concept of machine-independence was really what Java brought to the table, because it forced OOP and made porting sequential code redundant and awkward, that's what people latched onto.

And maybe everything I just typed was pure bullshit and just one man's misguided understanding of the situation, but that's my experience.
>>
Anyone got a link to some good collection of free PDF books?

Kinda like this one
>https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md
>>
>>59362900
>it makes it easier to re-use code and all
No it doesn't. OOP encourages so much damn mutable shared state. If you want to "reuse" an object, you need to drag with whole environment and other mess of objects with it.
An example of true reusable code would be a pure function.
>>
>>59362900
It's not really an issue when it is correctly used.

It's almost never correctly used however, and universities keep throwing it on new programmers.
>>
Okay, here's a thought...

What is the smallest n such that an individual could reasonably argue that there is at least one string of n bytes that has never existed at any time in any computer's memory? Obviously, it's bigger than 4. I can imagine someone has at one point built a program to count from 0 to 4 billion, just to see how fast it could be done. I'd even be willing to argue that it's bigger than 8. But with each byte you add, you multiply the size of the set by 256, and the chance that there is a unique bytestring increases.
>>
>>59361308
Lua or python?
I want to make a website.Will use one language for both front and backend.
>>
>>59362567
It's cruel to give someone false hope. It is a well known fact that at 20, your brain starts to decline. It becomes harder for you to grasp those technical concepts that are commonly found in programming. Even if you think you're becoming good, there'll always be someone who's younger and much much smarter than you.
>>
>>59362957
Nice pseudo-science you have there.
>>
>>59362949
You ever tried r9k? Not the hot mess it turned into but the actual algorithm. Needless to say, even under the extremely small subset of "things people actually say", all strings are cosmically unlikely. I would hazard to guess that the length of n is in the low four-digits
>>
>>59362957
>It is a well known fact that at 20, your brain starts to decline. It becomes harder for you to grasp those technical concepts that are commonly found in programming. Even if you think you're becoming good, there'll
Nonsense.
>>
>>59362310
I'm in it for the money, and because any other career path that I would choose doesn't offer the the flexibility I'm after.
With programming I could go with any career style I want: big corporations, freelancing, entrepreneurship, hacking 13 year olds with viruses and obtaining their mom's credit card info. I doubt any other parth offers that much freedom.

The downside is that it's pretty damn stressful work. I'm a freshman and I've already parted ways with sleep and 3 meals a day just to do some fucking compressed sparse column implementation.
>>
>>59362957
I assume you were documenting your own retardation as a part of this research?
>>
#define FREAD_OR_FAIL(dest, size, num, file) if (fread(dest, size, num, file) != num) return false;

this is a good solution and nobody can convince me otherwise
>>
is there a way to create a table in sql so that
TableA has foreign key to TableB
TableB has foreign key to TableA
without using ALTER? (as in just having two CREATE TABLE statements)
>>
>>59363038
To this shitposter's credit, it's actually a pretty big cliche in Mathematics that analytical intelligence deteriorates at an alarmingly young age, citing a number of historical Mathematical geniuses who did all their best work in their early 20s. But this "phenomenon" is widely apocryphal and completely contradicted by pretty much all work done in this modern era of hyper-specialization.
>>
File: 1381228285622.jpg (27KB, 260x384px) Image search: [Google]
1381228285622.jpg
27KB, 260x384px
>>59363074
>Flow control inside macros
>>
>>59363146
(defmacro foo ()
(if bar
`(baz)
`(qux)))
>>
 #include <stdio.h>
#include <cs50.h>

int coins = 0;

int main(void){

printf("O hai! How much change is owed? ");
float change = get_float();

while (change != 0){
if(change > 0.25){
change = change - 0.25;
coins++;
} else if(change > 0.10 ){
change = change - 0.10;
coins++;
} else if(change > 0.05 ){
change = change - 0.05;
coins++;
} else {
change = change - 0.01;
coins++;
}
}
printf("%i\n", coins);
}


Hi /dpt/, I'm doing the cs50x course on edx, and I can't get this assignment right. The code above compiles just fine, it prompts the question, but then nothing else happens, the cursor just stays there. Any ideas for this noob? thx
>>
>>59363100
Yeah, nowadays you need a lot more time to even get to the forefront of a subfield of a subfield. Cauchy, Lagrange, Galois, Gauss, etc. could become experts in several fields at a very young age.

There are other factors, too. A person in their early 20s usually doesn't have a family or old parents to take care of, and isn't advanced enough in their career that their time is eaten up by non-research things (day job, teaching/committee work, etc).
>>
>>59363236
Did you try to enter the value of owed change?
>>
>>59363236
Don't test for equality on floats.
>>
>>59363077
How do you think it would work without an alter command? Chicken and egg problem, man.
>>
>>59363253
I did that, yeah, enter the value, and then the cursor just sits there.

>>59363260
so what else can I do?
>>
>>59363236
>the cursor just stays here
it awaits your input senpai
>>
>>59363267
Just change it to an inequality:
while (change > 0) {
>>
>>59363267
#define EPS 0.001

while (fabs(change) > EPS)
{
...
}
>>
>>59363270
nope, I'm talking about after I input the value
>>
>>59363274
>>59363277
>>59363267
>>59363260
>>59363253
Nevermind, I got it. I was working with the floats themselves, but that won't work because of the float imprecision. The task instructions state at the very fucking end to convert all floats to int. That should fix it...
>>
>>59363292
Yup, that's the reason why you don't test them for equality. Have fun!
>>
>>59363244
Also, most people don't really work on difficult problems past college. Most work is pretty easy compared to a reasonably challenging major (STEM) at a good school (say... top 25). How many times does a typical programmer use group theory or advanced AI/ML in their day to day routine?
>>
File: 1456731652670_20170313_010151.jpg (24KB, 200x234px) Image search: [Google]
1456731652670_20170313_010151.jpg
24KB, 200x234px
>>59361308
A webextension. Currently trying to figure out how to wait for a programatical refresh before I inject a content script into the tab and modify its document. Since the refresh promise returns once it confirms the refresh can start, not when it has started, Im mutating the document a second before the refresh.
>>
>>59363277
#define (x)===(y) (abs(x - y) < 0.001)
>>
>"hey anon, could you make a program to regularly collect info about our competitors"
>"hey I need a program to automatically collect news from a few websites"
>"write me a bot to aggregate this shit"
>make a dumb jsoup html collector bot
>make a cronjob every week
>convince everyone to pay me monthly for my """service"""
>they gladly oblige and praise me
wtf I started a business
>>
>>59363378
What language do you use?
>>
>>59362502
Your quick learning list:
SICP - teaches you the basics and is a great intro to CS
Starting Forth - prepares you for thinking
Thinking Forth - teaches you program design and covers a bit of history you need to understand
Jonesforth - [optional] teaches you how to build a compiler from x86 to high level forth (can also be a guide to x86)
K&R C or Learn C the hard way - because it's everywhere
Learn you a haskell for great good - Forces you to relearn most as you learn to design without side effects making your programs easier to build and later modify

After this you will have pretty much passed most here as many are stuck on C thinking it's the language of god or what their uni gave them.
Each book/tutorial teaches you different parts in small steps with SICP preparing you for Thinking Forth which prepares you for C and finally Haskell where you cover theory of computation and how to ensure your program will run first time.

You'll also be able to learn any language quickly as you'll understand how they work. Scheme and Forth cover how objects can be implemented using closures so OOP will be easy.
>>
>>59362310
I am developing things other applications don't suit my needs for atm. More importantly, cs is very important for applying future research. And somebody has to program like rockets and shit my man. Money is in it.
>>
>>59362989

n > 1000? I would imagine it is a bit smaller than that. I can imagine that there is at least one sequence of 999 bytes that has not once existed in any computer's memory. I argue this based on the fact that 256 to the power of 999 is a number literally too large for me to put into a 4chan post (it's 2406 digits). I am not certain if any modern machine could count to that number from 0 if it was allowed to start at the time the first computer came into existence, and even if we assumed an infinitely wide register size, allowing addition of big numbers in the same amount of time it takes to add a 64-bit integer. I want to imagine that n is probably 2 digits, but I am not certain how high.
>>
>>59362806
pls respond
>>
What's the difference between SICP and HtDP?
>>
How do I remove the longest strings in a list?
>>
>>59363418
need to load the file into memory and rebuild the table form it. then write it out again...
>>
>>59363431
Take the length of each string, keeping track of the minimum length. Then remove each string with length more than that. Pretty inefficient though.
>>
>>59363396
java
never used it before actually, seems fun so far
>>
>>59363431
sort then drop the top. if it was only the largest you could just store the length and index of the last largest
>>
>>59363418
Just post your code. I have no idea what kind of data structures you're using.

>>59363431
>>> a = ["4444", "333", "22", "1", "4444"]
>>> filter(lambda x: len(x) < reduce(max, map(len, a)), a)
['333', '22', '1']
>>
>>59363456
Java for everything?
>>
>>59363453
how so? it's pretty much the only way even if they are sorted
>>
File: change.jpg (33KB, 1305x142px) Image search: [Google]
change.jpg
33KB, 1305x142px
#include <stdio.h>
#include <cs50.h>
#include <math.h>

int coins = 0;

int main(void){

printf("O hai! How much change is owed? ");
float change = get_float();
int cents = round(change * 100);
printf("%i cents require ", cents);

while (cents > 0){

if(cents > 25){
cents = cents - 25;
coins++;
} else if(cents > 10 ){
cents = cents - 10;
coins++;
} else if(cents > 5 ){
cents = cents - 5;
coins++;
} else {
cents = cents - 1;
coins++;
}
}
printf("%i coins in change\n", coins);
}


me again. Now the thing compiles and executes every line down to the very end, but the math I'm getting is fucked up, it doesn't give me the right change. Where have I fucked up now?
>>
>>59363479
Why don't you learn to use a debugger? Or at least print statements. Isn't that part of the course?
>>
>>59363479
>=
retard
>>
>>59362365
you iterate over the list and put each element's complement in an unordered set. while doing this you check if one of the complements is in your list. I can show you the code if y ou like
>>
>>59363478
Yeah, I figured. Doesn't mean it isn't inefficient. But that tends to be the case when you're dealing with strings.
>>
>>59363475
I use Java only for Android.
>>
>>59363487
not yet, probably later

>>59363490
yeah, I know, but hey, I'm learning. thx!
>>
>>59363475
ye, I just dump everything into basic txt/html files. their backend devs made php scripts to add everything into their databases properly from my files after a cronjob

I use c/c++ on my main job tho
>>
can we build something together so i can add it later to my portfolio
let do something faggots
>>
>>59363443
>>59363474
How exactly do I exclude that one index from the table? I have a table reading all the user data in separate elements (id, name, password,.. in one elemenent), say user inputs 2, how do I create a new table without that index?
>>
File: difference.png (83KB, 556x424px) Image search: [Google]
difference.png
83KB, 556x424px
>>59363428
http://www.ccs.neu.edu/racket/pubs/jfp2004-fffk.pdf
>>
>>59363537
no
do it yourself
>>
>>59363474

public static void Main()...
public static string LongestString(List<string> longest)...
public static bool RemoveLongestString(List<string> strings, string longeststring)
{

return true;
}


I've already found the longest strings in the list, but I just can't figure out how to remove them.
>>
>>59363487
>Or at least print statements
For debugging logic errors, that's all you need most of the time.
>>
>>59363567
>string LongestString(List<string> longest)
Returning that index of that string would be much more useful than returning the string itself.
>>
>>59362812
multivariable.
so partial differentials.
>>
File: 1461264646286.png (215KB, 1700x940px) Image search: [Google]
1461264646286.png
215KB, 1700x940px
Fucking hell. It took me about 8 hours to build a web spider with mysql support.

First project using mysql. It just kept throwing curve balls at me out of nowhere. I didn't even know you need a commit save changes, and that took 3 hours to troubleshoot.
>>
>>59363510
>>59363510
Ok, I'd suggest reading ahead when you get stuck and coming back later. >= was pretty obvious as `i > 25` will be false if 25 which is a problem.

Also start with SICP, C is better as a second or third language (after Forth).
>>59363538
read lines, remove line N, recount lines, write
>>
>>59363543
I take that as HTDP being easier, but lacks depth.
>>
>>59362930
This is what I never understood about oop.
What is it's actual purpose or benefit over just linking headers?
I mean isn't that essentially the exact same thing?
>>
>>59363537
ok but I want to use Forth and x86 with a FP dictionary I'm working on
>>
>>59363596
No, read up on closures VS OOP and you'll understand it a bit better
>>
>>59363590
Yeah, I get what I have to do, I don't know what the code is supposed to look like. I already have all the lines in an array, each one in separate elements. How do I make a new array, or replace this one with one line missing, where the line missing will be the one that the user inputs.
I have user input, the file in an array, all I need now is to create a new array without n index.
>>
>>59363537
Okay let's build strong AI and solve the halting problem.
>>
>>59363643
just create a buffer for the input (an array)
then all you need to do is print each line back and when the index == line to be removed you print the buffer instead to file.

length 0 do i file + dup N <> if print then loop
>>
>>59363586
That is shitty table anon
>>
>>59363577

It probably would, but this is the way I want to do it.

Any suggestions on how to solve? I've tried my best but can't get it to work.
>>
>>59363690
>>59363710

There's the correct, efficient way and then there's yours... index > pointer > string

list longest constant longstr
length 0 do i table + strlen longstr = if i remove then loop
>>
File: 1469556460819.png (1MB, 1273x922px) Image search: [Google]
1469556460819.png
1MB, 1273x922px
>>59363146
>Macros for anything that a static function can do

>>59363567
>>59363474
how can you think posting functions without any code in them is posting code when the reference is to data structures

        public static List<string> RemoveLongestString(List<string> input)
{
input.Remove(input.OrderByDescending(r => r.Length).First());
return input;
}
>>
>>59363578
Then you should study:
-vector math
-the definition of a limit
-the difference quotient (remember slope of a linear function)
-finding the limit of the difference quotient as the denominator approaches zero
-conceptually what is differentiation
-differentiation rules
-implicit differentiation
-differentials
-conceptually what is integration
-riemann sums
-basic integration rules
-integrals involving trig
-u-substitution
-trig substitution
-integration by parts
-integration by partial fractions
I'm sure there is more.
>>
>>59363709
Well ain't exactly a pro at this. First time programming with MySQL. Everything else just simple authentication for ftp and shit
>>
>>59363753
Why not just have a database you serialize data straight out of a class from and back into memory at startup? Can even flush out to disk if needed with a timer
>>
>>59363753
Study database normalization. It will help you keep your sanity when your tables get more complicated. https://en.wikipedia.org/wiki/Database_normalization
>>
I'm looking for a language to replace Python.
Is Ruby good?
>>
>>59363783
Lisp.
>>
>>59363725

But do you know how to make it work my way?
>>
>>59363789
No Lisp.
>>
>>59363783
What sold you on python to begin with?
>>
>>59363793
Racket.
>>
>>59363802
>>59363793
>>
>>59363799
I'm looking for personal use only.
>>
Is there anyone here who used Telerik Visual Studio extensions?

I installed the thing and can't find RadGridView, the reason i installed the whole package.
>>
>>59363803
Scheme.
>>
>>59363813
If mac and linux arent a concern to you go with c#
>>
>>59363793
Suit yourself. It's pretty easy to pick up though.
>>
>>59363818
>>59363793
>>
>>59363824
Clojure.
>>
>>59363821
Well, I'm looking for a scripting language, and I need it for Linux.
>>
>>59363729

I know it's a terrible way to do it, but I need to do it that way.

LongestString finds the longest string in the list already. How do I use that and loops to remove the longest string from the list in my RemoveLongestString method?
>>
>>59363413
I am intrigued, but could you please expand on how you are using the n as 2 digits ??
what your saying is theoretically what is the largest computation that has ever been done ? where the result has existed in memory ?

I know my Fibonacci code grinds to a halt a lot sooner than I had hoped, but this sort of thing interests me.
>>
>>59363839
>by learning the language and writing something yourself
that function contains all of the code required.
>>
>>59363835
Why not just use bash then?
>>
>>59363856
I'm going to do some web scraping.
>>
>>59363813
Forth, it's the ultimate scripting language
>>
>>59363839
Why do you NEED to do it that way? Do you have a gun pointed at you?
>>59363861
curl is all you need with a bit of ksh or Haskell, Forth, ect...
>>
>>59363861
bash + grep + curl
>>
>>59363729
        final int longestLen = strs.stream().map(s -> s.length()).max(Comparator.naturalOrder()).get();

strs = strs.stream().filter(s -> s.length() < longestLen).collect(Collectors.toList());

or:
        int longestLen = 0;
final List<Integer> longestIndices = new ArrayList<>();
for (int i = 0; i < strs.size(); i++) {
final int curLen = strs.get(i).length();
if (curLen > longestLen) {
longestLen = curLen;
longestIndices.clear();
longestIndices.add(i);
} else if (curLen == longestLen) {
longestIndices.add(i);
}
}

for (int i = longestIndices.size() - 1; i >= 0; i--) {
strs.remove(longestIndices.get(i).intValue());
}
>>
>>59363898
First one by far. Second one for job interviews.
>>
>>59363920
Do you think I can succeed at a coding interview, fampai?
>>
>>59363879
>Do you have a gun pointed at you?

Because I want to learn how to use methods.
>>
>>59363947
Certainly. Just keep practicing.
>>
I have a question. Building my CV, I have seen that I have only done manual labour before.
I do have some knowledge about some IT and Computer usage.
Like, I wouldn't need any help in installing drivers, OS, flashing phones, encrypting HDDs,using any Office Software, using Linux and so on.
I also have some basic, as in bloody beginner basic knowledge of Haskell, Java and Python.
I would need more experience and time to fully gain the professional experience that is more or less looked for I believe.
Are they special enough to put on my CV?
>>
>>59364002
I guess. I would probably do these, though:
1. Sign up for Github and start contributing.
2. Take some programming classes at a CC. Try to get an AS.
3. Look into certs (Cisco, etc).
4. Volunteer at local businesses for free (making websites, writing small applications, etc) until you get good enough to make money.
5. Go to programming gettogethers in your city. Tell people that you are willing to work for little/no money and want to improve.
>>
>>59364002
Java and Python probably. Better than nothing.
>>
>>59363791
yes and it's by using pointers instead
>>59363971
Then do something that requires them and not something better done without them.
>>
So, I have a class, A, which has an abstract function. B derives of A, but still shouldn't implement the function. C derives from B and should define the function.

How do I implement this in C++?
>>
>>59364089
You don't. NEXT!
>>
>>59364089
>How do I implement this in C++?
Pay attention in class.
>>
>>59364089
you dont need to write it at all in B
>>
>>59364089
struct A
{
virtual void foo() = 0;
virtual ~A() = default;
};

struct B : public A {};

struct C : public B
{
void foo() override {}
};
>>
>>59364107
They don't teach us shit about C++, they assume that after they taught us Java we can learn C++ perfectly on our own.

>>59364112
>>59364127
Thanks man

I'll have to go back to /sqt/ it seems
>>
I'm Teaching my self to program, and I am running into a problem with a section that checks for a user input directory and the switches:
#get path from user. and change directory
print ("Please input the path to folder:")
pathin = input();
if not os.path.exists(pathin):
print("Directory not found! Create Directory? Yes(1) or No(2):")
nopath = input()
checker = bool(nopath)
if nopath == (1):
checker = True
elif nopath == (2):
checker = False
while False:
quit()
while True:
os.mkdir(pathin)
if os.path.exists(pathin):
os.chdir(pathin)
print("Changed to path:", pathin)
else:
quit()


I get this error:
Please input the path to folder:
/home/anon/test
Directory not found! Create Directory? Yes(1) or No(2):
1
Traceback (most recent call last):
File "makedir.py", line 23, in <module>
os.mkdir(pathin)
FileExistsError: [Errno 17] File exists: '/home/anon/test'


I think I'm running into a data race, but I'm not sure.
>>
/dpt/ functional programmers use the technology called "lazy programming", analogous to lazy evaluation.
The program is never written, but it's claimed to be written. Program code forming must happen on the first direct reference to it, but because no one references to it, code is never formed.
Thanks to this, functional programmers have much spare time, which is spent for efficient trolling.
>>
>>59364160
Love uni, apparently using malloc was too advanced in their class where they wanted a TUI (used a scratch pad the same size as the terminal) so said I would fail for writing the program properly. Can't even use unions as "we haven't covered them yet so it's unfair"
>>
>>59361308
How can I print text in c which make it feels like someone is typing. Like characters would print one after another pausing for a brief 1 to 2 secs?
>>
File: Screenshot_2017-03-13-00-26-23.jpg (1MB, 1440x2560px) Image search: [Google]
Screenshot_2017-03-13-00-26-23.jpg
1MB, 1440x2560px
>>59362075
Dunno how much you'll get out of it, but "SFML Game Development by Example" and pic really helped.
>>
>>59364180
bool(1) and bool(2) are both True. Also, you don't need the if statements. Nor the while loops. Those could be if statements, testing checker.
>>
>>59364207
putchar, fflush(stdout), sleep
>>
>>59364180
>if nopath == (1):
drop the parens
>while False:
whywouldanyonedothis.jpg
>while True:
you are entering a loop of create path
it's BEGIN path mkdir AGAIN... it never ends which is where your error is...

Learn how loops work and when to use them
>>
>>59362075
Enjoy your cache misses.
>>
>>59364265
>>59364250
Thanks, these point me in a direction. I'll fuck around some more.
>>
>>59362075
>How do I properly abstract out Graphics from a video game with c++?
In my experience it's really not worth the hassle. Just go with straight DirectX/OpenGL. In practice there's so much shit to manage with graphics libraries that writing a clean abstraction is a real pain in the ass
>>
PYTHON HELP

so I'm trying to make a script load a website then return back to the start of the script it loads the website fine but the script doesn't return to the start


def youtube():

import webbrowser
webbrowser.open("https://www.youtube.com/feed/subscriptions")
start()



the terminal I use the script in just gets GTK errors then doesn't return
>>
>>59362075
Easy, just implement an AbstractFactoryBeanBeanBeanBeanBeanBeanBeanFizzBuzzSingleton
>>
>>59364337
Learn how to use loops.
>>
>>59363688
This is the code I'm trying to use, gives me an out of range exception though.
File is the original array read from the file, up is user input and delete is an array the same length as File array.

for(int i = 0; i<file.Length;i++)
{
if (i == up)
{
delete[i] = file[i + 1];
Array.Resize(ref delete, delete.Length-1);
}
else
delete[i] = file[i];
}


Am I thinking wrong here? I'm printing new values in the array and making it smaller as I go.
>>
>>59361644
Yeah this is an old ass post. But yeah, prime generation using a sieve (for small numbers) is necessary. The basic algo goes start with the lowest prime number, 2, and attempt to divide the number by it. If the division succeeds insert a two into the prime factor list. Continue dividing by that prime until it is no longer divisible. Then get the next prime number and repeat. Do that until the remaining number is 1.

If your language has support for coroutines or generators you can reformat the typical sieve as a generator instead of a massive table. The table method is slower, consumes more memory, and has an artificial limit on the primes found based off how large you make the table. A generator does not.
>>
>>59364391
>file[i + 1];
>>
KRC 5.2
#include<stdio.h>
#include<ctype.h>
#include<string.h>

#define SIZE 100
int getInt(int* p);
int main(){
int array[SIZE];

int i;
for(i = 0; i < SIZE && getInt(&array[i]) != EOF; ++i)
;

int x = 0;
printf("I is %d \n", i);
for( x = 0; x < i; ++x){
printf("%d \n", array[x]);
}
return 0;
}
int getCh(void);
void ungetCh(int c);

int getInt(int* p){
int c;
/* 4432 32 11 2 11 32 \n12 331 3 4 1 */
while( isspace(c = getCh()) || !isdigit(c))
;//sink
if( !isdigit(c) && c != EOF && c != '+' && c != '-'){
ungetCh(c);
return 0;
}
int sign;

/* Can i say c is either '+' , '-' or digit at this point
* May be yes */
sign = (c == '-') ? -1: 1;

if( c == '+' || c == '-')
c = getCh();

/*if( !isdigit(c) ){
ungetch(c)
return 0;
}*/

for(*p = 0;isdigit(c); (c = getCh()))
*p = *p * 10 + (c - '0');

*p *= sign;
if( c != EOF)
ungetCh(c);
//printf("Returning %d \n", c);
return c;
}
#define BUFFERSIZE 100
int buffer[BUFFERSIZE];
int top = 0;
int getCh(void){
return (top > 0) ? buffer[--top]:getchar();
}
void ungetCh(int c){
if( top < BUFFERSIZE)
buffer[top++] = c;
else
printf("error: buffer overflow");
}




How to do below:
getInt treat '-' or '+' not followed by a digit as the valid representation of 0. Fix this to push such a characted back into input.
>>
>>59364377
ok I googled loops and tried changing it to
def youtube():
for i in range(1):
webbrowser.open("https://www.youtube.com/feed/subscriptions")
start()



can you give more spoonfeeding please?
>>
>>59364429
I'm trying to make the user decide which index to "delete". I don't know how else to do it so that it prints the next index into the array. Example, array a and b, I want to delete index 2, then change the values in the array by -1 after that index.
a:0,1,2,3,4,5
b:0,1,2,3,4,5
After the code it should be
a:0,1,2,3,4,5
b:0,1,2,3,4
Where 2 was 3, 3 was 4, 4 was 5 and 2 doesn't exist in the new array.
>>
>>59364446
Why do you want to return to the start anyway?
>>
>>59364491
start is the main menu of my shitty virtual assistant
>>
How do I average two ints in a language without I/O?
>>
>>59364503
>a language without I/O?
nani?
>>
>>59364496
Oh, well then you probably just need to call the function of the main menu. Forget about the loops.
>>
>>59364446
>for i in range(1):
>>
>>59364488
Well the way you have it currently overflows, since file[i + 1] would reference a location outside the array. You'll just have to check if you're already at the end.
>>
>>59364446
import math
for i in range(-int(math.cos(math.pi))):
>>
>>59364528
can you tell me why I'm an idiot please I fail to see the mistake
>>
Best variable size poolallocator for C that supports freeing?
>>
>>59364548
Err, technically no overflow, but goes out of bounds.
>>
>>59361308
q = "How does Trump remove his fucking condom ?"
print (q)
print (q[O],q[6],q[3],q[25],"a",q[10],q[9],q[7])
print("If you don't reply to this, your mom will die in her sleep tonight")
>>
>>59364559
Explain what
for i in range(1)
does.
>>
>>59364559
It's as good as having nothing there.
>>
>>59364584
Trash.
>>
>>59364598
I thought it would execute webbrowser.open once then move on to start() hopefully suppressing the console output of webbrowser.open
>>
>>59364584
Dumbest post ITT.
> ?
Stop with your crimes against typography.
>>
>>59364584
Needs work
>>
>>59364624
Why would you loop just once?
>>
>>59364624
See >>59364526
>>
>>59364637
I hoped it would execute once then move on to start() rather than hogging up the console stopping start() from executing
>>
>>59364668
You literally retarded.
>>
>>59364668
Disregard >>59364659
I see now that it's blocking and that's what you tried to do originally anyway. You'll probably need another thread for the menu.
>>
>>59364439
Done that
 
void ungetch(int c){
if( top < BUFFERSIZE){
if( !isspace(c) ) /* I don't want non space */
return;
else
buffer[top++] = c;
}
else
printf("error: buffer overfow\n");
}

>>
>>59364548
>>59364582
I edited it a bit, but now I get an out of bounds exception on the last else.
for (int i = 0; i < file.Length; i++)
{
if (up == file.Length-1)
{
Array.Resize(ref delete, delete.Length - 1);
}
if (i == up)
{
delete[i] = file[i + 1];
Array.Resize(ref delete, delete.Length - 1);
}
else
delete[i] = file[i];
}

I have no idea why. Basically if up is the last index of the array, it should just make it smaller by 1, which means the last index is deleted. Nothing else should happen, but when I run it through, at the end I get an array of size 0. Also, if I put in any other index, like 1, it gives me an out of bounds on the last else.
>>
File: qtchan.png (274KB, 1920x1080px) Image search: [Google]
qtchan.png
274KB, 1920x1080px
4chan browser: it's pretty chill; still needs a lot of work, though. fuck, general web browsers need to die.
>>
>>59364766
it's trash.
>>
>>59364725
threads seem too complex, I'll give up for now and come back to it in a week and try learning threads, thanks anon
>>
>>59364786
so is this site
>>
>>59364766
Please tell me I can use a light color scheme.
>>
>>59364080
>Then do something that requires them and not something better done without them.

Not that guy, but it's good to do everything with methods when you're starting, because if you're going to program anything larger you will use methods for EVERYTHING.
>>
>>59364747
Okay, first, I'm a bit slow, instead of the "up" in the first if, there should be an "i".
However, it still doesn't work properly:
a: 0,1,2
b: 0,1,2
If I want to delete 1, it goes through without errors, however it doesn't print the next element if of the array.
Instead of
b:0,2
I get
b:0
pls help.
>>
File: qtchan light.png (172KB, 1920x1080px) Image search: [Google]
qtchan light.png
172KB, 1920x1080px
>>59364808
ofc; it's just a few lines to change colors
>>
>>59364747
You're still going to go out of bounds on your second if statement.

If file has a length 10 (0,1,2,3,...,9), and i = 9, file[9 + 1] == file[10]. Bad.
>>
>>59364863
>>59364839
Nevermind, I honestly have no idea how to fix this.
>>
>>59364850
Cool.
How do you handle captcha?
>>
>>59364794
Here's a start for you. It's not as hard as it seems if you read the docs.
import threading

def start():
#menu stuff
#if youtube is picked
mythread = threading.Thread(target=youtube)
mythread.run()

def youtube():
webbrowser.open("https://www.youtube.com/feed/subscriptions")
>>
File: ccc.webm (240KB, 640x350px) Image search: [Google]
ccc.webm
240KB, 640x350px
>>59364207
void fillOffsets( int **offsets, char *str )
{
int n = strlen(str), base = 50, spaces = 0,
b = rand() % 4 + 3, stutters = rand() % 4 + 1;

*offsets = calloc(sizeof(int), n);

for (int i = 0; i < n; i++)
{
switch (str[i])
{
case ' ':

spaces++;

if (spaces == b)
{
(*offsets)[i] = base * 5 + 10 * (5 + rand() % 5);
spaces = 0;
b = rand() % 3 + 2;
}
else
(*offsets)[i] = base;
break;
default:
(*offsets)[i] = base + 10 + rand() % 10;
break;
}
}

for (int j = 0; j < stutters; j++)
(*offsets)[rand() % n] = -1;
}


int main( void )
{
int i, *offsets = 0;
char Buf[1000] = "How can I print text in c which make it feels like someone is typing?\nLike characters would print one after another pausing for a brief 1 to 2 secs?";
int n = strlen(Buf);

getchar();

srand((int)time(NULL));

fillOffsets(&offsets, Buf);

for (int i = 0; i < n; i++)
{
printf("%c", Buf[i]);

if (offsets[i] == -1)
{
offsets[i] = 50;
for (int k = 0; k < 4; k++, i--)
{
printf("\b \b");
muhSleep(50);
}

if (i < 0)
i = 0;

muhSleep(500);
}
else
muhSleep(offsets[i]);
}

getchar();

free(offsets);

return 0;
}
>>
>>59364954
so excuse potentially wrong terms here but that'll kinda run headless as in def youtube will just be set off to run the left without any output?

the code seems understandable I'm going to try implementing it now
>>
>>59364900
You'll need an extra if statement that tests if i == file.Length() - 1. If you're deleting from the end, you just don't copy to the other array.
>>
for now just using 4chan pass cookie. it's pretty simple though: load and solve captcha then put the response in the multipart form data as g-recaptcha-response when sending thread reply.
>>
>>59365006 meant for >>59364942
>>
>>59364954
>>59364970
ok this exits the script after it launches the web browser which will work for now, thanks again
>>
>>59364863
Okay, nevermind again; it works now, edited the code a bit. Also, does anyone know why does 4chan fuck up my code formatting so bad. Code related.

if (up == file.Length - 1)
{
delete = file;
Array.Resize(ref delete, delete.Length - 1);
}
else
{
for (int i = 0; i < file.Length; i++)
{
if (i == up)
{
delete[i] = file[i + 1];
}
else
delete[i] = file[i];
}
Array.Resize(ref delete, delete.Length - 1);
}
>>
>>59364970
Yeah, you're probably right, and you might have to play around with the code to get your desired functionality.
>>
>>59364956
muhSleep is undefined
>>
>>59365059
#ifdef _WIN32
#include <Windows.h>
#define muhSleep(x) Sleep((x))
#else
#include <unistd.h>
#define muhSleep(x) sleep((x))
#endif
>>
File: 1433442045366.png (602KB, 963x720px) Image search: [Google]
1433442045366.png
602KB, 963x720px
If monads are so good how come they live in tents?
>>
File: mz0iM[1].gif (1MB, 578x399px) Image search: [Google]
mz0iM[1].gif
1MB, 578x399px
/dpt/ should have more codegolfs and less shitposting
>>
>>59365152
Monads aren't anything special. Only garbage languages can't implement them.
>>
>>59365152
Because they're too busy banging your mom :^)
>>
>>59365219
There's a difference between implementing particular monads and implementing operations that work for all monads. Most if not all languages can do the former whereas the latter is a challenge.
>>
>>59365213
Is that a clock made in Conway's game?
>>
>>59365213
Yep, and it's glorious
http://codegolf.stackexchange.com/questions/88783/build-a-digital-clock-in-conways-game-of-life/
>>
Reminder to learn at least one new language every year.
>>
>>59365235
https://copy.sh/life/?gist=f3413564b1fa9c69f2bad4b0400b8090&step=512
>>
>>59365234
If that's a "challenge" then your language is fucking deficient.
>>
>>59365284
I agree. You should just fix your wording.
>>
q = "How does Trump remove his fucking condom ?"

print (q)
print (q[O],q[6],q[3],q[25],"a",q[10],q[9],q[7])

print("If you don't reply to this, your mom will die in her sleep tonight")
>>
>>59365288
I don't think you realize where you're posting right now.
>>
>>59365274
Only a retard would learn at such a slow speed.
>>
How do I make a dictionary console application program interactive?

Meaning that if the user writes: "Ass"
the application will instantly show the words with "Ass" in them.
>>
>>59365298
NameError: name 'O' is not defined
>>
>>59365327
Use grep.
>>
>>59365299
What does that have to do with >>59365234?
>>
Retard time: how important are neural networks going to be in 5+ years? Is it the sort of tech that would be handy to learn and have an example project on your portfolio for future job applications?
>>
>>59365327
https://en.wikipedia.org/wiki/Trie
>>
>>59365338
It's a post I replied to in >>59365284.
And what you replied to is itself related to that post.
>>
>>59365342
Any complex project is good for your portfolio, so they're relevant now.
>>
>>59365298
what?
>>
>>59365342
it's hottest new meme on the block so having experience with it is going to make you look very employable.
However, the real-world applications are severely overhyped, and mostly rest on wishful thinking caused by a misunderstanding of the complexity of human brains.

If you're planning to work in data analysis (also called BIG DATA), image recognition, automated translation or god forbid algorithmic trading, it's probably a good skill to have. Otherwise, I wouldn't buy into the hype if you could be doing more useful things instead.
>>
Why isn't there a decent C# <-> postgresql ORM? Why can't I find a single minimal example for any of the alternatives that comes up when I google? Has anyone actually managed to use any these without pulling their hair out? Supposedly Entity Framework is what I'm looking for, but you need to read a 300 page book to begin using it. Just give me a fucking code example before I kill myself.
>>
>>59365350
>>59365337

not really helpful...
>>
>>59365298
shitposter.destroy();
>>
>>59365499

>C#

just kill yourself.
>>
>>59365327
what exactly are you trying to do?
If it's just getting input, enter, and then displaying output, shit a la scanf should work.
If you want an immediate ever-changing response as the user types, you'll want to use something to make it easier for you to redraw your console interface (e.g. ncurses), and then as you read the user input character by character, have the dictionary lookup be performed in a separate thread so the user can still enter letters while your lookups are still on-going, cancelling the previous lookup if a new letter is entered.
>>
>>59365499
GET
>>
File: 1451844939638.gif (1001KB, 280x203px) Image search: [Google]
1451844939638.gif
1001KB, 280x203px
Please spoonfeed me on Pascal
>>
>>59365505
There is plenty of pseudocode in that article. What more do you need?
>>
>>59365607

It predated C and was better designed. Use FPC or Ada these days.
>>
>>59365641
I don't think his question was about the dictionary search operation, but the interactivity of a console program (i.e., non-blocking input)
>>
>>59365327
char **strings, *input;

for (int i = 0; i < n; i++)
{
char *res = strstr(strings[i], input);

if (res != 0)
puts(strings[i]);
}
?
>>
File: 1458285738712.png (143KB, 800x1000px) Image search: [Google]
1458285738712.png
143KB, 800x1000px
>>59365662
>linear search
>>
>>59365661
Are you a girl or something?
>>
>>59361818
To be honest the 4chan json api returns so much nested shit that all the image bots I've made just scrape image links from the HTML, so don't feel bad.
>>
File: 1461566119420.gif (994KB, 245x245px) Image search: [Google]
1461566119420.gif
994KB, 245x245px
>>59365564
C# is great
>>
I have a question again, regarding text files.
I want to split them by a certain character on a certain index, let's say index 2 and the character |.
Can I rewrite the text in file just after the index, or do I need to rewrite the whole file?
>>
>>59365850
>>>/r/abbit
>>
File: HaunterHaunter.jpg (93KB, 1920x1080px) Image search: [Google]
HaunterHaunter.jpg
93KB, 1920x1080px
What the best resource for a C#/Ruby/Go developer to use to learn frontend webdev?
>>
>>59365861
Depends on your api. Most let you specify if you want to append or if you're rewriting everything.
I say you should test it if you don't understand your documentation.
>>
File: images (3).jpg (22KB, 513x287px) Image search: [Google]
images (3).jpg
22KB, 513x287px
Kinda stuck. At what point do we program silicon to understand binary, and how do we do it?
>>
New thread:

>>59365904
>>59365904
>>59365904
>>
>>59365896
>C#/Ruby/Go
>webdev
>>>/r/ibbit
>>
hey /dpt/

It is an undisputed fact that Structure and Interpretation of Computer Programs is the greatest introductory text to Computer Science that has ever been written. It is also a fact that The Art of Computer Programming is the greatest expert-level Computer Science text.

I was wondering - what text(s) join the two? What is the greatest intermediary Computer Science text? Is there one? I don't feel like someone could jump straight from SICP to TAOCP - but that doesn't necessarily mean there's a text that can bridge that gap. Do you just need real world experience to get to the level required for Knuth's works?
>>
>>59365972
>python
dropped.
>>
>>59366052
Feel free to do this in any language of your choice. The 4chan JSON API is dead-simple, is the point I was making. Note that getting the actual image links is only 3 lines, because the thread json is a dictionary with a "posts" key that is just a list of all the posts in said thread.
Thread posts: 318
Thread images: 23


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.