[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: 34
File: 1430326831779.png (368 KB, 800x507) Image search: [Google]
1430326831779.png
368 KB, 800x507
No weebs edition

Old thread >>51894993
>>
File: 1429275627954.jpg (40 KB, 405x451) Image search: [Google]
1429275627954.jpg
40 KB, 405x451
>Shell scripting
>Spawning a process for EVERY COMMAND.
>>
How do I find the average of two strings in c?
>>
>>51898583
>>
>>51898581
(a + b ) / 2;
>>
>>51898550
Spawning processes is very efficient on most GNU systems
>>
>>51898611
Why would GNU coreutils change anything about how processes are spawned?
That's a kernel thing.
>>
posting again...

I would like to learn to program but I am getting
a little annoyed with myself as I am not too sure which language I should start with.

I have no interest in web programming. I would like to know how to make desktop programs so I am thinking C++ however I think that might be a bit too much for a total beginner so I thought maybe Java as that can be used for desktop programs and seem to be a little easier in general from what I have read. Is that true?

Also Java seems to give me some good options for looking at a programming job one day.

Or should I start with C like so many suggest? I find the whole reverse engineering thing really interesting and that all seems to be done in C (and assembly). Also most libraries seem to be written in C so some understanding would be good to have yes?

Some have suggested Python but I don't really like the look and feel of it, plus it seems to be kind of sucky for doing desktop programs with a GUI which is what I am interested in obviously.

Opinions and suggestions?
>>
>>51898581
Explain what do you mean by it. Avg length? Avg character for every charqcter?
>>
>>51898599
gay
>>
File: photoNormal.jpg (28 KB, 400x300) Image search: [Google]
photoNormal.jpg
28 KB, 400x300
>>51898581
Arguably you could calculate the Levenshtein distance and stop halfway through.

https://en.wikipedia.org/wiki/Levenshtein_distance


kitten → sitten (substitution of "s" for "k")
sitten → sittin (substitution of "i" for "e")
sittin → sitting (insertion of "g" at the end).

So the average of kitten and sitting would be either sitten or sittin.

Most premade Levenhstein algorithms just give you a number for the similarity of two words.

Neat challenge.

So /g/, average two strings with a modified Levenshtein algorithm. It doesn't need to be C.
>>
>>51898636
>C++ -> C -> assembly
Learn it in this order
>>
>>51898667
lol idiot
>>
>>51898631
GNU systems usually ship with a kernel that's good at spawning processes, such as Linux or FreeBSD.

Debian GNU/kFreeBSD for instance.
>>
the values in each box should be the # of neighbors each box has (5 along edges, 8 in center, 3 at each corner)

Anyone know why this isn't working?
>>
>>51898447
How do I find my own IP address using python? I don't mean localhost or the local addresses like 192.168.etc.etc
>>
>>51898685
I have no idea about python but how about tracerouting until first public ip
>>
>>51898685
google.com
>>
>>51898447
I'm writing a NES emulator for the Arduino Due. Games playing around with PPU registers suck.
>>
>>51898685
import socket
print([l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0])

not my code but works well
>>
>>51898709
That seems a bit too complex.

>>51898710
I assume you meant opening a connection to google and then trying to get my IP address from that with socket.gethostname. That gave me 192 etc.

>>51898735
That looks really terrible. Is there no better way of doing it?
>>
>>51898735
Nevermind, this is local, not public

If you want your public IP, try
urllib.request.urlopen('http://ipinfo.io/ip').read()[:-1].decode('ASCII')
>>
>>51898681
your y in neighborCount iterates all over the place, init it with max(0, col-1) I suppose
>>
>>51898760
I think its either using some service that tells you your ip or tracerouting some random public ip
>>
File: catfight.webm (2 MB, 720x404) Image search: [Google]
catfight.webm
2 MB, 720x404
Ask your beloved programming literate anything.
>>
>>51898807
I love you.
>>
File: sds.png (210 KB, 640x360) Image search: [Google]
sds.png
210 KB, 640x360
Why is /g/ so slow nowadays?
>>
>>51898822

what's the latest program youve written?
>>
>>51898807
>>51898834
Darn, I just realized that the top-right and bottom-right corners are still wrong
>>
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
>>51898838
Because there isn't a qt gril in the OP pic.
Also, it's 11am on the west coast, and finals week in most places.
Congrats on outing yourself as a neet.
>>
File: we_are_shiba.png (667 KB, 640x640) Image search: [Google]
we_are_shiba.png
667 KB, 640x640
>>51898842
Thank your for your question.

>what's the latest program youve written?
Averaging two integers in C.
>>
>>51898447
Next time, use an anime image. That shit is disgusting.
>>
>>51898861
>finals week in most places.
Not here it ain't. We've got exams in January.
>>
File: sad.png (486 KB, 1280x794) Image search: [Google]
sad.png
486 KB, 1280x794
>>51898861
But anon, /g/ has been slowly dying for awhile now.

Why?
>>
>>51898861
>finals week

Glad I graduated tbqh
>>
>>51898848
idk man, just from looking at it, <=min({rows,columns},... check goes outside the limits, try replacing with rows-1, columns-1. I don't know if it will fix the corners or fuck the right and bottom lines instead though.
>>
>>51898447
I'm looking to make a deep level Android application/service that has to be hidden and can't be disabled/uninstalled.

i know there were big security changes post 3.0 but would that be still doable on like 4.3+ Android versions?

So far the only answer I have is a hidden service that starts up on phone boot, but I wan't it completely hidden from processes list.
>>
>>51898848
Post your code. Also, why are you using loops to calculate it, you already know what the values should be, just check if you're at an edge or corner.
>>
>>51898838
sauce ?
>>
>>51898973
Why tho?
>>
>>51898667
this. it wouldn't hurt to reverse the order of asm and C, but do C++ first regardless.
>>
>>51898957
already tried that, screws up the bottom lines unfortunately
>>
double avg(int a, int b)
{
return a / 2 + b / 2 + a & 0x1 ? 0.5 : 0 + b & 0x1 ? 0.5 : 0;
}
>>
>>51898838
Don't know about /g/ in general, but as far as the /dpt/ one trap faggot has driven off many regulars by trying to force-feed his gay shit to everyone.

But meh, he'll get the message eventually.
>>
>>51898861
I've been done for a week
>>
>>51898861
stfu & gtfo nigger faggot
>>
>>51899022
>But meh, he'll get the message eventually.
Will he, though? Some shitposters aren't human anymore, they're just balls of concentrated autism. Like that faggot who posts that Sakura fish image on /a/ every fucking day.
>>
>>51898981

World.initializeGrid(11, columns: 10)

func drawGrid() {
visibleGrid = Array(count:World.rows, repeatedValue: Array(count: World.columns, repeatedValue: UIButton(type: UIButtonType.System)))

for rowPosition in 0..<World.rows { // starting with rowPosition traverses cells from left to right
for columnPosition in 0..<World.columns {
visibleGrid[rowPosition][columnPosition].setTitle("\(World.neighborCount(rowPosition, col: columnPosition))", forState: .Normal)
}
}
}


func neighborCount(row: Int, col: Int) -> Int {
var neighborCount = 0

for var y = max(0, col-1); y <= min(rows, col+1); ++y {
for var x = max(0, row-1); x <= min(columns, row+1); ++x {
if x == row && y == col {
//skip myself (cell being checked)
continue
}
neighborCount++
}
}
return neighborCount
}


the relevant parts
>>
>>51898883
Fuck off idiot
>>
>>51899043
maybe, but idk or care. i simply don't post in the trap threads, or make a counter one.

/dpt/ isn't that important to me that i feel obsessed to post in a gay thread some cock-mongler wants to flaunt.
>>
>>51898667
>>51898989
What about Java?
>>
>>51898984
Plastic Memories.
>>
>>51899076
>Java
meh, C++ and C hide less from you
>>
File: t-thanks microsoft.png (404 KB, 640x582) Image search: [Google]
t-thanks microsoft.png
404 KB, 640x582
How do I get into embedded C programming?
I bought an arduino clone but I think I broke it.

What's a good usb ISP programmer that comes with a few microcontrollers to play with?
>>
>>51899048
You can do it anon, I saw you first posting this like 20h ago and still posting midday on agdg and here.

I wish you best luck.
>>
>>51899087
isnt it easier to get started with programming with java over C or C+ though?

what about things like java's built in GUI stuff. I dont think C or C++ has that?
>>
>>51899076
Java and C# are basically in the same category (and probably Python, et al)...you'll be taught to believe in 'magic'. If that's as far as the demands of you're career lead, then fine. If on the other hand you ever move into systems or high-perf work, then you'll have to relearn a few things from the ground up so you understand the actual underpinnings irl of the 'magic forces' at work anon.
>>
>>51899048
        for var y = max(0, col-1); y <= min(rows, col+1); ++y {
for var x = max(0, row-1); x <= min(columns, row+1); ++x {

I take it "rows" and "columns" are the size of your grid? Why do you compare row to columns and col to rows? And you didn't answer my question, why are you calculating this with loops?
>>
>>51899048
Your rows and cols is all over the place anon.

The for line for x should only talk about columns. The for line for y should only talk about rows.
>>
>>51899094
send help ;_;
>>
someone explain this new average of two ints maymay.
>>
>>51899076
C++ is faster and widely used in clients because the dumb users dont need to install java to get your program working. C++ also gives you less-useless errors than C, so you may know what happened, you just have to find out where. If you wanna write servers w/o much computing then feel free to go Java
>>
>>51899122
ok cool i get that. so what if i just want to make normal desktop apps? is java a good place for that?
>>
>>51899118
C++ has a TS in the work to add GUI. It's still a couple of years out though. However, as it's basically THE library creation language in existence there are a metric shitton of GUI libs/frameworks available for it anon. QT is the most popular one atm.
>>
>>51899130
He actually also has a boolean associated with each tile, or at least he had that in a prior version.

So I guess the end code would actually not yield such a constant output dependent only being in a corner, edge or inside.
>>
>>51898985
A security app with database connection on an external. It just needs to transmit 2 lines of text but the user can't know
>>
>>51899118
It is, but if you need to know how everything works underneath, then at the very least one should learn something like C or C++ or even both.
From what I heard, Java's GUI library isn't actually that great. QT is where it's at.
>>
>>51899149
It's just some dumb niggers going 'hurr that isn't the most effective method let me show you one don't mind if it doesn't compile or doesn't work properly every time'
>>
>>51899168
Sure. Java is probably the best portable language to use for that. If you're primary focus is Wangblows, then it's definitely C# instead.
>>
>>51899149
it's a forced meme don't bother
>>
>>51898636
>>51898667

I humbly beg to differ but I think this order is better:
>C -> C++ -> Assembly

also no language is too hard to a beginner if that beginner really wants to learn it bad enough. even Carmack was a beginner the first time he saw a PC. Then he made Doom. So go learn Haskell or LISP for all anyone cares, JUST DO IT OP
>>
>>51899170
>>51899188
ok cool. im not sure about the whole knowing the workings underneath or not. i like the idea of knowing the low level stuff but i dont have a CS or EE education so wouldnt it be all beyond me?
>>
>>51899149
Its a meme trying to deal with ints possible overflowing during the average computation.
>>
>>51899137
you're right but that only breaks more corners (pic related)

>>51899130
I don't understand what you're saying or why you are asking about the loop. Is there some other way to do this?

    func neighborCount(row: Int, col: Int) -> Int {
var neighborCount = 0
//var columnLimit = col+1
//var rowLimit = row+1

for var y = max(0, col-1); y <= min(columns, col+1); y++ {
for var x = max(0, row-1); x <= min(rows, row+1); x++ {
if x != row || y != col {
neighborCount++
}
}
}
return neighborCount
}
>>
>>51899201
> C -> C++

Newp. Guys who learn C first never get to the point where they write decent Sepples code. The reverse isn't the case however.
>>
>>51899203
Face it, you will need to know how this stuff works, sooner or later. Thats why i suggested c++ first, because its easier to learn, then C.
>>
File: couragewolf.jpg (66 KB, 576x576) Image search: [Google]
couragewolf.jpg
66 KB, 576x576
>>51899201
forgot motivational img
>>
>>51899203
Meh, depends on how much you apply you'reself really anon. PPP2 will take from zero to near-hero in about 3 months of focused effort on you're part. If you can do that, then that's a good path.

Otherwise, just start with C# if you're going to do GUIs on Windows(tm)(R)($). Hurry up, cause Rajeesh will be gunning for that exact spot though.
>>
File: 1443576772136.png (835 KB, 1200x1080) Image search: [Google]
1443576772136.png
835 KB, 1200x1080
>>51899022
Enjoy ;)
>>
>>51899168
I'd suggest C# and Windows Forms for learning.
Once you're comfortable, a good goal is "I want to be cross platform". I'd then suggest diving into C++ /D to learn about pointers and memory management.

If you want to be a good programmer though, always go out and learn new things.
When you hear about a new language, like hearing LISP for the first time, GO OUT AND LEARN ABOUT IT!
Try it, play with it. There's always the right tool for the job.
probably-just-responded-to-bait|spoon-feeding / 10
>>
>>51899251
fuck off nigger faggot. you'll never be accepted here.

you sucking dicks has nothing to do with being a good coder. keep it to you'reself, and you might be able to pick up some help from old hands. flaunt that bullshit, and you'll rightfully get nothing but the bumrush.
>>
>>51899251
>Zed A. Shaw
dropped
>>
>>51898665
just read through it and it's pretty magnificent

I guess a suitable or an alternative challenge with this algorithm is to find the nearest dictionary word to the middle step in the algorithm, returning 0 if none (so kitten and sitting would return 0 assuming sitten and sittin aren't english dictionary words)

then you can safely say you've found the average of 2 words in c
>>
>>51899192
>can't average 2 ints in c
>>
>>51899201
>>51899239

yeah i really want too do it. i keep thinking i am not intelligent enough though. i have done some of the basics in C, C++, Python, Java, JS, VBScript, etc. I can do FizzBuzz in them all. Loops, if/else, switch, etc. isnt that hard but I always feel I cant move past that.

>>51899250
I downloaded the PDF of that but never started it. Is it the best for C++ for a total newb then?

>>51899277
Thanks. I will look at C# also. Not baiting. just need to stop being a NEET/find some self-belief that I can actually do it
>>
>>51899209
You're counting an extra row and column, change to this:
        for var y = max(0, col-1); y <= min(columns-1, col+1); y++ {
for var x = max(0, row-1); x <= min(rows-1, row+1); x++ {


>I don't understand what you're saying or why you are asking about the loop. Is there some other way to do this?
Yes, just check if it is an edge or corner, then you don't need the loops in the neighborCount function. Unless you're planning to add functionality like >>51899178 said.
>>
File: 153.png (156 KB, 451x387) Image search: [Google]
153.png
156 KB, 451x387
>>51899251
Reminder that it's only cute in anime, 3D traps are generally pig disgusting.
>>
>>51899251
>I don't learn programming languages to use them. I don't learn programming languages at all! I don't understand why everyone keeps emailing me saying my books are terrible for learning languages when I've never even written a book before.
-Zed Shaw
>>
>>51899328
If you're already cute as a guy, you can make it as a cute girl.

Just letting you know.
>>
>>51899343
Im ugly as a guy, yet people keep thinking Im a girl. Dont even have long hair. wat do
>>
>>51899220
but if he wants to make PC games, he doesn't really need to get all Seppl-y. what he needs is a good foundation in pointers and basic procedural/modular programming paradigm before moving on to a object-oriented approach. it's simply more fun doing all that pointer/heap/stack stuff in C if just for the keks, man.

also use notepad and none of those based IDEs.
>>
>>51899178
>>51899325
yes ultimately I'm tallying the bools around the cell being checked

>>51899325
This worked for me, thank you very much
>>
>>51899306
>best for total newb
Yes. PPP2 (be sure it's the second edition) is THE best beginners programming textbook for any language period.

It's primarily a long-ass tutorial designed to teach you to THINK like a programmer. The fact it's in C++ is literally secondary.

I couldn't recommend that book highly enough to a serious beginner. But--stress on the word serious. You'll only learn to code by actually coding. Reading only won't do it. So, you have to work through the exercises, etc. (and there are many) to get the benefit from it.

However, if you do so, you'll be far, far ahead of the average amateur coder, and well on you're way to becoming an actual professional.
>>
http://www.strawpoll.me/6285195/
>>
File: 1374823915625.jpg (147 KB, 1280x720) Image search: [Google]
1374823915625.jpg
147 KB, 1280x720
>>51899287
Don't worry anon, if you want to come out of the closet I won't judge you.
>>
>>51899306
You're looking in a rough place for that, as it's a common concept here that if you're not hardcore, you're not worth the score. C# will be very useful in industry and teaching, then...
pick the tool for the job!
I wouldn't suggest C# for intensive vidya games, but it works perfect for desktop app development. ( +with it being crossplatform /opensource soon.. )
I'd always suggest looking into Lisp for a new view on programming structures, and giving the SICP a read.
When you're moving to lower level languages, try D for safety +development power, or C++ for the huge library. Try writing some basic apps in Rust, to learn more about thread safety.
I wouldn't suggest writing anything large in ASM, but you WILL want to know how a computer works. A lot of languages I've noted above allow for inline ASM.
-- and you should learn C just because it's everywhere. Same with Java, though it's waning thank god.
>>
>>51899377
sounds like just what i need! thanks anon. :)
>>
#include <iostream>
#include <string>
using namespace std;
int main()
{
struct database
{
string login;
string password;
bool is_admin;
};

database jarek;
jarek.login ="jarek0990"; jarek.password="pass1234"; jarek.is_admin==false;
database damian;
damian.login="damian999"; damian.password="damek99"; damian.is_admin==true;

cout << jarek.login << ":" << jarek.password << " " << jarek.is_admin << endl;
cout << damian.login << ":" << damian.password << " " << damian.is_admin << endl;

return 0;
}

why does while printing is_admin==false this code print out 157 instead of 0?
>>
File: ok.png (359 KB, 860x1040) Image search: [Google]
ok.png
359 KB, 860x1040
>>51899412
Seriously, anon. No more gay shit, ok? /g/ is a Conservative board, please respect our culture.

You might fight Reddit more to your liking.
>>
>>51899431
You are trying to compare with ==, you want just one = for assignment.
>>
>>51899431
admin==false is either true or false
admin is not changed
>>
How come the further you get from real programming and the closer you get to web dev, the word 'library' starts to become 'framework'?

I just read 'Python has a framework for unit testing, the unittest module.'

Wouldn't 'library' be more appropriate?
Or is the word 'library' only for use with compiled languages that use a linker?
>>
>>51899449
ok i forgot about this. i'm faggot
>>
I need to write a program using python to where the user enters initials and depending on what the user inputs it will read it from a namelist.txt and display all the names from it with those certain initials. However, some names have a middle initial like John S. Doe.


for line in open("namelist.txt"): # This is where you open the .txt file
user = input("Please enter one pair of initals: ")
parts = line.split(", ")
new =



This is all I have so far, advice on how to at least get started?
>>
>>51899440
We're all Bernie supporters you liar.
>>
File: 1374346251600.gif (496 KB, 500x455) Image search: [Google]
1374346251600.gif
496 KB, 500x455
>>51899440
Don't worry, I've posted borderline gay shit here for far longer than you anon.
>>
>>51899454
>python
>web dev

stay NEET, anon
>>
>>51899356
follow your dreams

also i'm gonna stop off topicing now, this is /g/
>>
>>51899364
>This worked for me, thank you very much
No problem. Do you understand what was wrong?

>yes ultimately I'm tallying the bools around the cell being checked
That's fine then, I was confused because it wasn't in the code you posted. If you weren't doing that then you could do it quite easily without loops:
bool vEdge = (col == 0) || (col == columns-1); // left or right edge
bool hEdge = (row == 0) || (row == rows-1); // top or bottom edge

if (vEdge && hEdge) { // two edges, i.e. a corner
return 3;
}
if (vEdge || hEdge) { // one edge
return 5;
}
return 8; // no edges
>>
>>51899454
You control when to use a library function, while the framework uses you.
>>
>>51899454
Frameworks contain key distinguishing features that separate them from normal libraries:

inversion of control: In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework.[1]
default behavior: A framework has a default behavior. This default behavior must be some useful behavior and not a series of no-ops.[citation needed]
extensibility: A framework can be extended by the user usually by selective overriding or specialized by user code to provide specific functionality.
non-modifiable framework code: The framework code, in general, is not supposed to be modified, while accepting user-implemented extensions. In other words, users can extend the framework, but should not modify its code.
>>
>>51899362
I have no problem if C is the final goal. It's an admirable language that has changed human history. I personally love it. However, after more than two decades of watching the progression of developers moving from C to C++, I stand firmly convinced of my statement: Guys who learn C (essentially) never learn to code in C++ well.

I'm not sure what it is about it, but I know of only one exception to this observation. I think it's probably the roughly two-year time frame it takes to move the mindset over to the more abstract approach when it's a better choice.

Or something. Regardless, this is my experienced observation on the topic. Again, I love C, but if you're going choose to work in both worlds, and you're still a beginner, then C++ -> C is always the best planned course.

>>51899416
nprb anon.
>>
File: 1391447434048.png (343 KB, 494x596) Image search: [Google]
1391447434048.png
343 KB, 494x596
>>51899487
>I'm an oldfag

That's nice, anon.
>>
Ok anons, I'm in the mood to learn one of these new hipster programming languages. Anyone got any good ideas of what I should go for?
>>
>>51899479
First off, I'd make that first line into two seperate ones. arr = open('namelist.txt','r').readlines() and for line in arr: so you don't end up opening it again and again.
The rest depends on how you've formatted namelist.txt.
>>
>>51899488
On the spectrum of metal <-> webdev, python is closer to webdev than metal, and js is pretty much just webdev
stfu homo

>>51899498
Gotcha

>>51899504
Makes some sense, thanks.
>>
>>51899540
typescript
>>
hey guys
im 19, currently at tech uni but its shit and we dont study programming

i already know html, css, js and php with mysql
i know im a cuckold but i was 12 when i started learning these by myself...

now i want to level up and be a real programmer
what languages should i study and why? (inb4 java)
i already know a little c++ but im unsure what the fuck can i do with it
>>
>>51899540
Haskell is a great deal of fun if that's what you're looking for.
>>
>>51899540
OCaml
>>
>>51899559
Don't learn languages; learn math
>>
>>51899571
why?
>>
>>51899541
Thanks I did that :)

It's just a very long list of names.

http://pastebin.com/dwPjyXy4
>>
>>51899559
Math and Java

Hating Java is a pre-undergrad meme.
>>
>>51899582
>>51899571
also what kind of math are you specifically talking about?
>>
>>51899559
python and django

helps that you have your current skills too
>>
Write a c program that can determine if an arbitrary program will halt on an arbitrary input.
You should be able to do this
>>
>>51899579
Teaches you to think

Focus on discrete math. It's easier to apply to CS.
>>
>>51899559
>i already know a little c++ but im unsure what the fuck can i do with it
here's a short list of a few things that have been done with it anon, just to give a little perspective

http://www.stroustrup.com/applications.html
>>
>>51899547
js is pretty much just webdev, but there's where your meme ends. higher levels of abstraction do not mean webdev. python is used for the majority of scientific research.
>>
>>51899606
I'm not doing your homework
>>
File: ojjh.png (969 KB, 1050x913) Image search: [Google]
ojjh.png
969 KB, 1050x913
niichan, why do you watch cuckold porn?
>>
How does one get into coding?
>>
>>51899598
Logic, graph theory, combinatorics, linear algebra
>>
>>51899619
I know that, but python is closer to web dev
>>
>>51899598
Abstract Algebra
Linear Algebra
Calculus

From most important to least important for computer science. You really want to know abstract algebra.
>>
>>51899606
lol
>>
File: shot-20151206-1874-1jbezwi.jpg (144 KB, 1280x1466) Image search: [Google]
shot-20151206-1874-1jbezwi.jpg
144 KB, 1280x1466
>>51899540
valutron or lfe (pic)
>>
>>51899606
>hey guise today I learned about the halting problem in my CS101 class
>I'm so smart
>>
>>51899615
>http://www.stroustrup.com/applications.html
thank you fellow anon

>>51899611
ill take a look at it

btw i forgot to tell i already know a lot about processor architecture (i have made basic cpus in simulating softwares) thus i know assembly too
>>
>>51899606
1. Take an idealised Hyper-Turing machine that can solve the halting problem.
2. Use it as oracle in my program.
3. ???
>>
>>51899581
Alright, so readlines makes it so every line in the text file is treated as a seperate string.
What you should do now is reduce these seperate strings to initials. One way of doing that is taking the first letter and then every letter that comes after a space. Another is just taking every capital letter in the string.
>>
>>51899413
>wouldn't suggest C# for intensive vidya games,
C# is perfect for whatever intensity your standard indie dev is gonna need. Especially with unity(inb4 >unity). It's very rarely that someone programming of their own vocation NEEDs anything faster than java or c#. Hell most won't need more than python I'd wager
>>
>>51899638
Abstract algebra is mainly useful for coding theory

I think I've seen it pop up elsewhere but not very much
>>
>>51899559
If you know a little bit of C++ I think you should learn that. You could do a HFT simulator (a real one too but that's not really the point) in it, for example. From what I know about technical universities, you will be using C++ a lot so there is that as well.

Oh and what technical uni?
>>
>>51899620
>>51899649
>taking everything on 4chan seriously
You must be the life of every event
>>
>>51899681
budapest university of technology
>>
Is Java actually shit or is that just a meme? Sure I know the JVM coming with the Ask toolbar is shit but other than that what is so bad about Java?

Is it used for much outside of Android and in businesses for their mission critical, multi-platform backend systems? I don't see many (I can't think of anything other than Minecraft desu) applications written in it.
>>
>>51899650
nprb. study hard anon.
>>
>>51899582
or somebody that actually programs at a lower hardware level and dislikes the inefficiencies...
>>
>>51899398
>scheme: 1 vote
jesus read your sicp already
>>
>>51899703
>>51899703
>JVM coming with the Ask toolbar
That's only and that one terrible operating system that nobody should use
>>
>>51899677
Its also essential for many cool algorithms that can solve very hard problems like checking for graph ismomorphisms.
Also highly relevant for cryptography and many other aspects ranging even into quantum computer computations like Shors factorization algorithm.
>>
>>51899711
thank you, i will
>>
>>51899703
Verbose af and annoying af handholding like checked exceptions
>>
>>51899733
>crypto
yeah included that under coding theory
>>
File: advent tree.jpg (115 KB, 701x649) Image search: [Google]
advent tree.jpg
115 KB, 701x649
anyone else keeping up?
>tfw 6 minutes too late for leaderboards
hope I get into one before christmas
>>
>>51899692
Fuck off. I'm in a shit mood as I can't average two ints in C.
>>
How can I learn about low-level programming in C and assembly as a 30-something who hasn't done any programming outside of VB back in the early 2000s in Excel and Windows Scripting?

I have always been interested in reverse engineering and how people read things like the output of IDA and OllyDbg. I would love to finally learn about it now I have the time in my life.

I come from a finance background so zero computer science (or related maths) knowledge.
>>
>>51899681
also what kind of "study" programs should i write? i'm done with these shitty console programs like palindrome and stuff
>>
>>51899654
Sorry, I'm very new so I'm still learning.


name = open('namelist.txt','r').readlines()
for line in name: # This is where you open the .txt file
user = input("Please enter one pair of initals: ")
parts = line.split(", ")
if user == ####?:
name2 = open('namelist2.txt','w')
print(name)



Am I on the right track?
Or am I retarded
>>
>>51899648
>valutron
fuck off anon
>>
>>51899790
Start with learning C. You can then move on to computer architecture, assembly, operating systems, embedded programming whatever.
>>
File: ibp3dxZy2Vys4F.png (770 KB, 848x900) Image search: [Google]
ibp3dxZy2Vys4F.png
770 KB, 848x900
>Learning programming
>Instructor sends us an assignment in which we are to write a program in an unnecessarily convoluted way just "for practice"
>Can't do it the much simpler way
Kill me already. In every way to look at this, I need to lower my IQ to finish this crap. What the fuck.
>>
>>51899571
Come to think of it I do need to brush up on my math. Thanks for the suggestion! ;)
>>
"a. a function called reduce that takes a fraction list and reduces that fraction to lowest terms, returning the appropriate fraction list. For example, reduce([4,6]) would return [2,3]. "

im very new to python can anyone tell me how to at least get started besides a def statement?
>>
>>51899850
What was the assignment?
>>
>>51899774
Mate, you are probably in a bad mood because you aren't able to bait any one anymore with this meme for the last three times. If you aren't, move on. The recommended formula (that still doesn't work for all cases) is simply (a/2)+(b/2)+(a&b&1)
>>
>>51899850
post the question
>>
>>51899496
>No problem. Do you understand what was wrong?
I think so. My rows and columns variables aren't local to the method (global? I don't know...) and they're the raw number of rows/columns without respect to the fact that arrays start with index zero, while the row: and col: parameters are just indices. Is that correct?

Thanks for the help
>>
>>51899866
def halve(li):
return [x/2 for x in li]
>>
>>51899703
>what is so bad about Java
You can go in a few directions with this. One direction is that Java does not do well in zero-cost abstraction. The other is that Java is elegant, i.e. it cannot represent many powerful abstractions which would make life a lot easier (though the language developers seem to be working on this). Basically the whole deal is that Java is pretty average as a language.

>>51899791
Anything big. You could try writing a parser generator, for example. Would take you a lot of time but you would learn a lot, and it would look good on a CV as well.
>>
>>51899866
there's an algorithm for finding the greatest common factor between 2 numbers using modulo

forgot what it was exactly, but it's something like

a,b=b%a, a


or

a,b=b%a,b


and then repeating that until b is 0
>>
>>51899866
Top of the head stupid solution for reduce(x, y):
For each natural n number up to min(x, y) check if n divides x and y and if so divide x and y by n.

I am assuming you can define a function, write a for loop and an if statement. If not, look up these things and then come back.
>>
>>51899932
*is not elegant.
>>
>>51899922
That's not what he asked for.
>>51899866
You need to calculate the Greatest Common Divisor (GCD). A standard way is Euclid's algorithm.
>>
>>51899866
from fractions import Fraction


there you go anon the rest is ez
>>
>>51899866
Look through the array, loop from 0 to half the number in the array, put in the first number that has no remainder when divided into the number (i.e 4%2 == 0, so 2 is the first factor if you start from 0)
>>
>>51899866
Divide both by their GCD.

Look up Euclid's algorithm.
>>
>>51899932
>Basically the whole deal is that Java is pretty average as a language.
This. It's not horrible, but it's nothing special either. It doesn't do anything well except appeal to people who have never programmed before, for some reason or another.
>>
>>51899945
if (x % n == 0 && y % n == 0) {
x /= n;
y /= n;
}
/* bla bla bla */
>>
>>51899819
>Sorry, I'm very new so I'm still learning.
We all were at first. No one's born knowing how to program. I think.

I could solve this for you easily, but I won't, since you won't be learning as much that way.
What I would do is:
user = input() # since you only want to ask the initials once, right?
for line in name:
#line is, for example, "Martin Van Buren". So do one of the things I suggested in the previous post to change it to initials.
initials = #the initials, however you decide to do it. Don't change the variable line while you're "calculating" the initials.
if user == initials:
print line
#then it goes on to check the next line.


Other things to look out for is that python can print out arrays, but most languages can't (meaning they need you to define some kind of function for that yourself). So don't use "print(name)", especially since you're printing out the whole array every time.
Another thing you're doing wrong is opening the second file. You're opening the same file many times, but the parameter 'w' means that it's effectively wiped clean and then writes.This means you'll only get the last thing. So either change 'w' to 'a' (for append) or put it outside of the for-loop.
Lastly, you're not writing to the file. You're just printing to the console. To write to a file, you'll have to do name2.write(what you want to write). Just use print for now, though, it's easier.
>>
>>51899978
.. or yay for GCD too. it's the less stupid way
>>
>>51899964
>for some reason or another.
It has more tutorials than most I suspect, especially to the query "programming tutorial". Nowadays with the advent of hip coders though that paradigm is shifting (to javascript of all things)
>>
ayy>>51899987
>>
>>51899998
Off by one, mate.
>>
>>51899958
lmao thanks python
>>
>>51899606
>You should be able to do this
Heh, you should be able to win the Turing Award (and, possibly, the Fields Medal) as well.
>>
File: mthis.png (80 KB, 1216x770) Image search: [Google]
mthis.png
80 KB, 1216x770
u.pomf.io/haddjc.tar

could someone please take a look at this, cant figure out why im getting this message, think it's something to do with memory but im not sure
>>
>>51899866
https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-14.html#%_sec_2.1.1
>>
>>51900026
You're trying to use NULL as if it were a valid pointer. Don't do that.
>>
Write an operating system that has an interface usable by normies in Assembly and C.
You should be able to do this.
>>
>>51899540
Smalltalk
>>
>>51900026
>viewing window of 22 lines
>still uses allman
jesus
>>
>>51900031
I seriously hope
>>
>>51899874
>>51899914
It's basic stuff: I need to write code for a program in which one of its options is for the user to enter numerical values and the program stores them in an array.

The thing is, each value needs to be immediately stored into the array ascendantly, so we are not allowed to just receive all the input and later use an algorithm to sort the entire array. To my knowledge, this involves having to compare each value in the array to the input until the input is higher, then store that input in the next position, and if there is data already there, needing to move every value in front of it one position to the right to ensure it stays sorted.

Unless I am retarded and I can't think of there being a use for doing it this way when there actually is, it's pissing me off that I have to write more code to do this when a simple sorting algorithm at the end would lend itself to less likelihood of errors and it would be easier to follow, and accomplishes the same result in the end.
>>
>>51900052
>operating system
>interface
wew
linux is written in C and has the gnome shell :^)
>>
>>51900052
Look up Windows, it's a small project I did a few months ago
>>
>>51900026
come on peter leatherbarrow, you're better than that disgustingly verbose ide
>>
>>51900045
im not sure whereabouts i used null, could you point out the line or something please?

>>51900061
im minimized the window so it wasnt this massive screenshot for no reason

>>51900098
forced to use it for my degree
>>
>>51900103
>forced to use it for my degree
Change the school immediately.
No one should be forced to use proprietary software.
>>
>>51900086
>/g/tards can't create an operating system
You aren't Torvalds and Linux is not usable by normies. Try again.
>>
>>51900085
>a simple sorting algorithm
But that's basically what you are supposed to do
>>
>>51900085
>To my knowledge, this involves having to compare each value in the array to the input until the input is higher
No, you divide and conquer, faggot

Your teacher is just giving you a test, not a real world implementation of that particular algorithm. Like in my uni where we had to use bresenham's algorithm to draw a circle rather than just calling up a library that has smoothened down the algorithm as efficiently as possible
>>
Rate my character scrubber.
char *strip_characters(const char *string, const char *remove)
{
unsigned r_len = strlen(remove);
unsigned len = strlen(string);
char *out = (char *) malloc(sizeof(char) * len);
unsigned i, j;
unsigned k = 0; /* output index */
for (i = 0; i < len; i++)
{
unsigned found = 0;
for (j = 0; j < r_len; j++)
{
if (remove[j] == string[i])
found = 1;
}
if (!found)
{
*(out+k) = string[i];
k++;
}
}
*(out+k) = '\0'; /* null terminate */
return out;
}
>>
>>51900103
input_data is null for gods sake
look at the autos window at least
>>
>>51900109
true, its just so they can mark them quicker if they have just vb projects, but yes i agree with you its very retarded
>>
>>51900085
What language are you using? Some have some neat features for things like this(if you're allowed to use those)
>>
>>51900135
>*(out+k)
Why
>>
>>51900085
>take input
>expand array size by 1
>insert new value at the end
>sort array
>go to step 1
>>
>>51900135
Is that C? May i use it? I'll put the GLPv3.0 thing before
>>
Currently studying this amazing maths library

http://www.cgal.org/
>>
>>51900135
Remember thet you nedd to free(out) when you have finished so you'll avoid memory leaking
>>
>>51900135
for(j = 0; j < r_len; ++j)
{
if(remove[j] != string[i])
out[k++] = string[i];
}
>>
>>51900135
also why unsigned and not int?
>>
>>51900198
I'm pretty sure you don't want to be returning malloc'd char array pointers.

also
>(C) 2015 - Anonymous
you're a funny guy
>>
>>51900135
Ignore this >>51900243, I goofed
>>
>>51900266
int* shortArray(int v[], int vi) {
int *p;
int i;
p = (int*)malloc((vi)*sizeof(int));
for (i = 0; i<vi; i++) {
p[i] = v[i];
}
return p;
}

you can have my array shortener!
>>
>>51900291
If it shortens arrays and returns malloc'd memory, why don't you just count the number of elements and realloc?
>>
>>51899073
>>51899041
samefags
>>
>>51900347
realloc is not a good thing... if you want to make an array longer it could just go NULL and fuck your function up
>>
>>51900376
yea but thats array shortener not expander so no worries
>>
>>51900135
>C faggots take 50 lines to do what python can do in 1 line

you people are really no different from cobol dinosaurs at this point
>>
>>51900410
>import stringShortener
>it just werks
>>
>>51900354
why repeat myself anon? i made my point well enough the first time.
>>
>>51900410
A program is written once and run a million times. Guess which efficiency is more important?
>>
>>51900410
Enjoy your shitty bogged down language.
>>
>>51900410
yea because python is great for embedded systems.
>>
>>51900427
Not him, but why do people like you post these kinds of screenshots when editing html on various browsers is piss easy?
>>
>>51900427
Nice photoshop
>>
>>51900436
Embedded systems are outdated
>>
>>51900438
because I've been doing screencaps for years for circlejerks?

>>51900440
heh, k. w/e.
>>
>>51900193
Alternatively, use a linked list or some datastructure that automatically/makes it easy to keep the content ordered
>>
>>51900476
>because I've been doing screencaps for years for circlejerks?
can't argue with that
>>
>>51900461
oh yeah, everything's node.js-powered web 3.0 now
>>
File: 2015-12-16_21-50-45.png (17 KB, 475x88) Image search: [Google]
2015-12-16_21-50-45.png
17 KB, 475x88
I'm trying to do some uni shit here with Java pls help

The program (roulette) is supposed to recieve input like this "EVEN 15", then add 15 credits to the even field

How can I split that up?

I'm not supposed to use any shit from pic related
>>
>>51900533
I'm thinking of creating a reserve String, then looping through that one, adding characters as it goes along, then stopping once it hits the space
>>
>>51900429
Depends on the context of the tradeoff.

A senior developer spending hours to increase performance on a small internal application by 2% is a waste of resources.

In that case, and many others, abstraction is more cost-effective.
>>
Is using a generator where possible in python a good idea?

like:

def encrypt(message,shift):
return ''.join([chr(shift + ord(i)) for i in str(message)])


instead of:
def encrypt(message,shift):
string = ''
for i in message:
ordinal = ord(i)
string = string + str(chr(ordinal + shift)
return string
>>
>>51900533
if index is like that you can always get just last 2 index-es on the fly like .charAt(length() -2) end go from there, its simple and stupid solution
>>
>>51900626
yes
>>
>>51900656
Well, that was a short example, the user can for example do shit like

"EVEN 15 BLACK 5 17 10"

To bet 15 credits on even, 5 credits on black and 10 credits on 17
>>
File: 7seg.png (16 KB, 720x474) Image search: [Google]
7seg.png
16 KB, 720x474
Playing around with a digital IC for driving a 7-segment LED display.
With this, one could drive a single 7-seg display with just four microcontroller I/O pins.
>>
>>51900673
yes i know what i meant was if it is guaranteed that input will be exactly of format EVEN 15 one per line that he can just do that. Much better solution would be to parse till you get an int...
>>
>>51900695
No, "EVEN 15 BLACK 5 17 10" is going to be all on one line.

One horribly inefficent method might be to set up a String array, then in a loop append to array[i] the characters until a space
>>
#include <stdio.h>
#include <string.h>

void rot (char *string, size_t len) {
int limit = 0;
int rot = 0;
for (size_t i=0; i<len; i++) {
if (string[i] >= 'a' && string[i] <= 'f') {
limit = 20;
while (rot < limit) {
if (string[i] == 'z') {
string[i] = 'a';
rot++;
} else {
string[i]++;
rot++;
}
}
} else if (string[i] >= 'g' && string[i] <= 'm') {
limit = 7;
while (rot < limit) {
if (string[i] == 'z') {
string[i] = 'a';
rot++;
} else {
string[i]++;
rot++;
}
}
} else if (string[i] >= 'n' && string[i] <= 's') {
limit = 7;
while (rot < limit) {
if (string[i] == 'a') {
string[i] = 'z';
rot++;
} else {
string[i]--;
rot++;
}
}
} else if (string[i] >= 't' && string[i] <= 'z') {
limit = 20;
while (rot < limit) {
if (string[i] == 'a') {
string[i] = 'z';
rot++;
} else {
string[i]--;
rot++;
}
}
}
rot = 0;
}
string[len] = '\0';
printf("%s\n", string);
}

int main (int argc, char **argv) {
FILE *fp = fopen(argv[1], "r");
char line[1024];

while (fgets(line, sizeof(line), fp)) {
rot(line, strlen(line)-1);
}

fclose(fp);
return 0;
}

Anyone know why this isn't getting accepted? I'm getting partial score ~60%
Challenge is: https://www.codeeval.com/open_challenges/226/
It's a 20-7-7-20 rotation encrption.
>>
i am interested in picking up a cheap android phone to learn android development. what is the "best" budget android phone to be used for development? something around £100 would be awesome
>>
>>51900748
Moto E
>>
>>51900748
iphone 24s
>>
Would someone mind helping with some databinding in WPF/C#?

I'm a complete novice working on my first project, up to this point I've done fairly decently, but I've reached a complete standstill, not a single clue do I have about binding the data I've currently got onto a form I've made.

I could ask here but it seems a bit long winded and I clearly need a dialogue about this because it's lost me entirely.

steamcommunity.com/id/sirdoombox if you're willing to give me 10 minutes.
>>
File: 1437506731525.jpg (19 KB, 319x316) Image search: [Google]
1437506731525.jpg
19 KB, 319x316
>>51900770
>C#
mfw
>>
>>51900770
>windows problems
lol
>>
>>51900786
>implying C# isn't GOAT
>>
>>51899606

>replace arbitrary program with gibberish
>print("arbitrary program will halt")
ez pz
>>
>>51900786
It's a competent language that seems to suit someone with no experience. Other than the utter clusterfuck of features that makes up WPF, I don't really have any issues so far. Binding data however seems to entirely elude me.

>>51900788
>Implying
>>
>>51900739
try adding return; in the void rot
also if you use C you shouldn't declear the size_t in the for and if it's C++ there's abetter solution than printf
Thread replies: 255
Thread images: 34

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.