[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: 322
Thread images: 40

File: Chizuru smile.png (363KB, 500x544px) Image search: [Google]
Chizuru smile.png
363KB, 500x544px
Previous: >>57311298

What are you trying hard to be working on, /g/?
>>
1st for F#
>>
>>57325190
To get my motivation back.
>>
File: 1477587841385.jpg (147KB, 600x534px) Image search: [Google]
1477587841385.jpg
147KB, 600x534px
can anyone explain the filesystem/ filehandling in java to me?
>>
>>57325190
I'm trying hard to be working on learning how to write an mp3 decoder.
>>
>>57325286
German, by any chance?
>>
>>57325190
Refactoring an erlang project.
>>
>>57325190
if (op.image.isAnime() == true)
reply("Fuck you for using anime weeaboo scum\n>>>/a/");
>>
>>57325365
I love how this samefag is triggered each and every time.
>>
>>57325365
>== true
>>
>>57325356
Nope.
>>
>>57325365
if you're lonely just say so
>>
>>57325412
Doesn't MISRA require that?
>>
File: gd.png (343KB, 494x596px) Image search: [Google]
gd.png
343KB, 494x596px
/dpt/ can't make a JS script that sorts comments by the number of replies they have.
>>
>>57325453

oh, that would be interesting to look at
>>
File: 1432259490310.jpg (68KB, 700x700px) Image search: [Google]
1432259490310.jpg
68KB, 700x700px
getting a gf
>>
YOU HAVE 10 SECONDS TO WRITE A FUNCTION THAT TAKES IN A FOUR DIGIT NUMBER AND RETURNS THE HIGHEST DIGIT
>>
>>57325481
no u
>>
>>57325481
max(raw_input())
>>
>>57325481
('div' 1000)
>>
>>57325493
I don't wanna......
>>
File: Hidden feels.jpg (74KB, 900x900px) Image search: [Google]
Hidden feels.jpg
74KB, 900x900px
>>57325472

Haha.
Well, but we can program one, dont we?
>>
>>57325453
I always wanted that feature. I'll look into it
>>
>>57325481
Oh wait did you not mean the first one?

maximum . map read . show
>>
>>57325509
hopefully intro to AI that I'm taking this semester will teach me that
>>
>>57325481
No.
>>
>>57325521
Yeah I worded it poorly, sorry
>>
>>57325523
post results
>>
>>57325496
oh sorry, I thought program not function

lambda x: max(str(x))
>>
>>57325531
I'll share my gf on /g/ if I ever write one
>>
>>57325552
thanks famalam
I await eagerly
>>
File: Taylor.jpg (146KB, 500x558px) Image search: [Google]
Taylor.jpg
146KB, 500x558px
>>57325552

do so, please
its my only chance
>>
>>57325521
Whoops

maximum . map (read @ Integer) . pure . show
>>
>>57325552
The slut.
>>
File: wojak_rope.jpg (32KB, 300x360px) Image search: [Google]
wojak_rope.jpg
32KB, 300x360px
>>57325567
So far we are teaching a machine on paper how to recognize if papaya is good or not, that's pretty close right? ...right?
>>
>>57325453
Made a shitty script that does that a while back.

var replies = document.querySelectorAll('.replyContainer');
var replyCount, n = 0;
var chanX = document.querySelector("[title='4chan X Settings']") !== null;

function getReplyLength(node) {
if(chanX) {
return node.querySelectorAll('.desktop .container a').length;
}
return node.querySelectorAll('.desktop .backlink > span').length;
}

for(var i = 0; i < replies.length; i++) {
replyCount = getReplyLength(replies[i]);

if(replyCount > n) {
n = replyCount;
}
}

while(n !== -1) {
for(var i = 0; i < replies.length; i++) {
replyCount = getReplyLength(replies[i]);

if(replyCount === n) {
document.querySelector('.thread').appendChild(replies[i]);
}
}

n--;
}


Could be cleaner and looking at it now, I don't really know what's going on, but meh, it works.
>>
>>57325552

>open source GNU/Girlfriend
>>
>>57325523
you have to have a lot of data
how will... how will we get data
>>
>tfw you write a girlfriend and she rejects you
>>
>tfw you write a girlfriend and she deletes herself rather than sleeping with you
>>
File: anal beads.png (72KB, 1897x971px) Image search: [Google]
anal beads.png
72KB, 1897x971px
Fuck off, nip moot, you just destroyed my userstyle.
>>
>>57325481
>YOU HAVE 10 SECONDS
Nah, I took my time.

#include <iostream>

int main(){
int num;
int dig = 0;
std::cin >> num;

for(int oom=1; oom<num; oom*=10){
if((num/oom)%10>dig) dig=(num/oom)%10;
}
std::cout << dig;
}
>>
>>57325656
>>57325674

with proper training set she won't know what rejection is

>>57325645
but how are we going to get said training set...
>>
File: 1461654953369.png (55KB, 217x190px) Image search: [Google]
1461654953369.png
55KB, 217x190px
>>57325627
>>
>>57325698
>with proper training set she won't know what rejection is
l-lewd
>>
>ftw fucking your AI girlfriend until her stack overflows
>>
File: 1464692145407.png (81KB, 994x617px) Image search: [Google]
1464692145407.png
81KB, 994x617px
>>57325681
Works fine with OneeChan
>>
what purpose does the java.util.Scanner serve?
>>
File: 1477568367259.png (72KB, 1080x715px) Image search: [Google]
1477568367259.png
72KB, 1080x715px
>>57325729
What font is that?
>>
>>57325768
Doing everything with objects is obviously always better, duh
>>
>>57325775
Roboto
>>
>>57325768
https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
>A simple text scanner which can parse primitive types and strings using regular expressions.
>>
fugg
>>
what is the best language to write your girlfriend in?

i guess java, since i can run easily port her to my smartphone then.
>>
>>57325850
arexx
>>
>>57325850
They taught us Prolog and Python to start Intro to AI so I would say these, we are using them in that course
>>
>>57325881
>>57325863

okay.
if i make my girlfriend too smart, she might come to the conclusion she can date someone else (as every other woman I knew did), so i have to be careful.
>>
>>57325190
Box packing algorithm. My workplace has put me on a long term project to develop ways to make our warehouse packing more efficient. I've currently got a stack and slice method going, but I'm considering a 2D pack and slice method instead.

That or, considering we have hundreds of thousands of records of how items ought to be packed, finally taking the plunge and learning muh mashin lurnin
>>
>>57325949

sounds interesting.
>>
>>57325949
Could you give a rundown of the algorithm?
>>
>>57325949
Sounds coolio.

What shape are the boxes?
>>
>>57325972
Fucking square you retard
>>
>>57325984
I mean the things you're packing them inside. If they're all square boxes, than the algorithm can be made in less than a few lines.
>>
http://v8project.blogspot.com/2016/10/webassembly-browser-preview.html

what's going to happen when you give web devs c/c++?
>>
File: spoon-feeding.jpg (82KB, 584x389px) Image search: [Google]
spoon-feeding.jpg
82KB, 584x389px
Is there anywhere I could find a condensed English or pseudo code outline of the typical structure of video games?
>>
>>57326008
I was just mucking around :)
>>
>>57325961
Sort items by largest side area. Reduce problem space by checking bounds of the containing boxes and a rudimentary stack of items, considering the majority of our items are stackable tile shapes.

Grab largest item, fit in smallest necessary box for all potential items, run reducer each time you fit an item, opening and closing boxes as needed until the smallest item is fit. It runs in shitty n^3 time because it's dependent on the number of possible containers.

>>57325972
Boxes are all six sided, quadrilaterals of unknown dimensions for sides.

I originally went with a method that takes the space above and space beside the box because I thought splitting into three spaces might negatively impact performance but it seems that the system I'm running on and the overall size of the packs can handle it.

I don't know machine learning. But I know how to learn it.
>>
>>57326013
>make_share <life_prtnr>
>>
>>57326020
Look up the doom source code on github if you're feeling real daring
>>
trying to figure out how to send a keystroke over a network in java. The key values I know are an integer, but how will the server handle it to control the program its running
>>
>>57326038
>It runs in shitty n^3 time because it's dependent on the number of possible containers
I mean, if you're only going to be running it every so often, that's okay.
I just looked up the problem. Apparently it's NP complete
https://en.wikipedia.org/wiki/Bin_packing_problem
>>
Thinking about writing a program that can give me a random anime from my plan to watch list on MAL in C. You think that would be a doable project for someone who have pretty much started out with C?

I guess I would first read the source code from the plan to watch list, then extract the ID of each anime into an array. After that randomize an array position for one of the anime IDs, and open that one in a web browser.

How would be a good way to sort out every thing other than the IDs from the source code and get them into separate positions in the array? That feels like it would be the hardest part. Can you open stuff into a browser from C?
>>
I wrote a script so you can SELECT YOUR SPOOKY SKELETON
var s = document.getElementById("skellington");
window.change = function(n){window.skeleton+=n;if(window.skeleton < 1){window.skeleton = 23;}if(window.skeleton > 23){window.skeleton = 1}document.getElementById("skellington").src = "//s.4cdn.org/image/skeletons/"+window.skeleton+".gif";};
var a = document.createElement("a");
a.innerText = "next";
a.style.position = "fixed";
a.style.right = "150px";
a.style.bottom = "0px";
a.style.cursor = "pointer";
var b = document.createElement("a");
b.innerText = "previous";
b.style.position = "fixed";
b.style.right = "200px";
b.style.bottom = "0px";
b.style.cursor = "pointer";
document.body.appendChild(a);
document.body.appendChild(b);
window.skeleton = 1;
window.change(0);
a.onclick = function(){window.change(1)};
b.onclick = function(){window.change(-1)};
>>
>>57326330
>implying I'll download your botnet
>>
>>57326330
>not webassembly
>>
File: UxTmJlQ.jpg (57KB, 564x854px) Image search: [Google]
UxTmJlQ.jpg
57KB, 564x854px
>program something for a deadline that was much tighter than it should have been
>no peer review
>only other person on the project was in process of leaving

>months later, customer finds five robustness faults

Feels so bad, man. My pride has really taken a hit. I'm not even sure how to make up for it (to myself).
>>
What should I read if I want to learn C#? Know C++ and OOP, I just want to learn the language.
>>
>>57326455
Probably a textbook or something
>>
>>57326455
>>57326463
dont listen to this anon, there are many pdf documents and powerpoint presentations that you could learn from just as well, if not better,
>>
>>57326310
You may want to start simpler, referring to HTML as "the source code" and questions like "Can you open stuff into a browser from C?" indicate you have a lot to learn about these various technologies, let alone how to interact with them in C.

If you would like to make a try of it, I would recommend using their API instead of scraping HTML (if you don't know what an "API" or "scraping" is, these are other concepts you will need to learn)

https://myanimelist.net/modules.php?go=api

This returns data in XML, so you will need to learn the basics of XML, and then how to use it in C
http://www.xmlsoft.org/
>>
>>57325190
Sauce, please, OP. Please.
>>
>>57326510
ReLIFE
>>
>>57326455
https://learnxinyminutes.com/docs/csharp/

If you just need syntax, read this and then scrounge MSDN for definitions.
>>
http://www.strawpoll.me/11545470
>>
>>57326038
Don't know how much machine learning is going to help you. Your problem isn't a learning problem, it's an optimization problem. Yes most machine learning is optimization, but they are different.

For this type of problem you have your naive packing solution (similar to the naive solution to the knapsack problem), some kind of first fit linear algorithm, or the combinatorial solution.
>>
>>57326548
whats an xkdc?
>>
>>57326548
>no ritchie
>>
What's a paladin?
>>
>>57326585
a word that's the same forwards and backwards
>>
>>57326601
that would be a palindrone
>>
File: 1464321557138.jpg (102KB, 508x600px) Image search: [Google]
1464321557138.jpg
102KB, 508x600px
Is upgrading to code academy pro a worthwhile investment for learning how to program? I'm asking mainly because of the access to projects and I personally feel I'm learning a few things with the introduction courses.
>>
File: BanspioCQAAaDak.png (277KB, 599x400px) Image search: [Google]
BanspioCQAAaDak.png
277KB, 599x400px
>>57326611
>>
>>57326613
i just want to breed all anime posters

it's a reflex
>>
>>57326613
I hope this is a joke.
Codecademy doesn't teach anything, it just has you copy and paste some contrived examples and CONGRATULATIONS YOU'RE A CODER NOW :)
>>
>>57326623
a scary picture
>>
>>57326613
don't know what codeacademy pro is like, but I don't think u need it since u can download books and watch tutorials on youtube. If u prefer courses take presencial ones
>>
>>57326548
wtf. Since when does strawpoll does IP checking?
curl -d 'options=116316442' http://www.strawpoll.me/11545470 didn't work
>>
>>57325768
There is a built-in class called Scanner in Java to easily get the user input. What it does is it acquires information from the input stream, either from the keyboard or a file, and stores it in a variable. However, the Scanner class is not part of the core Java language so you need to tell the compiler where to find it.

import java.util.Scanner;
>>
>>57326661
Yep, I'm going through books and youtube videos myself along with using the CA's introductory courses. I was wanting more hands on with projects, I'm under the impression there will be enough to get me fluent in Java.

Not sure where else I can look
>>
>>57326494
>referring to HTML as "the source code"
Yeah, that was a blunder. Wrote that since "View page source" in Firefox is written as "Show source code" in the Swedish version.
Will look up those things though.
>>
>>57325211
how is it? Ive used C# and Haskell for uni so far and theyre not bad to work with, so that should fair well with F# rite?
>>
>>57325432
It makes sense in C.
But it doesn't in languages with proper boo-leans and no "truthy" and "falsey" BS.
>>
File: The_Keeper.jpg (52KB, 782x722px) Image search: [Google]
The_Keeper.jpg
52KB, 782x722px
I just understood quaternions by calculating the formulas in my head.

When I don't understand something, I just close my eyes and think about it really hard.

my face rn
>>
>>57326834
yeah unity sure requires a lot of thinkwork :^)
>>
>>57326834
Quaternions are neat.
Calculating them by hand is a pain in the butt, tough.
implementing them is fairly trivial.

IIRC the is something like a quaternion, but with 8 components.
But their multiplication is not even associative anymore.
They're even in boost.
I don't know of any practical applications though.
>>
>>57326552
It's more like we aren't looking for optimization, but accuracy. We know NOW after a first iteration that performance won't be an issue with the scale of individual calls, so that gives us more leeway for a data-driven approach -- or so a member of my team suggests, anyway. For now, the improvements I'm working on will help us be marginally more accurate for the holiday season.

>>57326109
Sure is. I have five years of experience in the field but I still struggled to get a good implementation for it on a ten day sprint. Doesn't feel good, but this is a revisit.
>>
>>57326927
octonions. that's the end of the road unless you relax the axioms even further
>>
>>57326981
>axioms even further
What would that look like?
>>
medium was a mistake
>>
I whipped up a working prototype in like a day, but all the code is so messy and hacked together that it's un-maintinable and un-reusable, so it's all going to garbage during restructuring and clean up.

How to into foresight?
>>
>>57327180
Why don't you try writing it correctly the first time?
It takes longer, but you'll actually be able to reuse the code and expand it as your needs grow.

Usually, I do this by writing structs and function declarations in advance before actually writing anything.
>>
File: e.e.jpg (30KB, 619x720px) Image search: [Google]
e.e.jpg
30KB, 619x720px
I'm working on an AI that has the capability of forming phrases. I'll make a database where each word will have "friendliness_level", "happiness_level", words that might be related to it, etc.

Any tips?
>>
>>57327242
Yes.

Don't
>>
If you code your waifu, wouldn't that make her your daughter?
>>
>>57327249
I have a lot of free time and I need to hone my programming skills, so I will do it
>>
File: Usagi_drop.jpg (97KB, 411x433px) Image search: [Google]
Usagi_drop.jpg
97KB, 411x433px
>>57327265
kinda

it's not like there's anything wrong with that
>>
File: ksr.jpg (129KB, 750x750px) Image search: [Google]
ksr.jpg
129KB, 750x750px
>>57327265
there is no difference
>>
>>57327277
There are better AI training that you can do. Like code me a waifu
>>
Fuck.
The ISO 11172-3 document file if found, containing the mp3 standard, is only half the document.

I need someplace to pirate the complete ISO document.
>>
File: q86u.jpg (92KB, 800x600px) Image search: [Google]
q86u.jpg
92KB, 800x600px
>>57327265
I wouldn't mind having a qt3.14 AI daughteru
>>
>>57327302
>code me a waifu
What?

Couldn't find anything on Google
>>
>>57327290
Kinda glad the anime ended before this.
>>
>>57327370
Why do people hate the ending so much?
They're NOT RELATED.
>>
>>57327396
it turned it from a cute story into smut
>>
>>57327396
Anon, I'm pretty sure that's not OreImo.
>>
>>57327360

He wants to program an AI that will serve as his waifu.
>>
>>57327411
This is so dumb, imagine ripping out the last chapter of a book because you don't like the ending.

It's how the author intended it to end, regardless of whether you think it was the result of her inserting her fetishes into her work.
>>
>>57327396
I haven't actually read it but heard about it. I don't care about if they are related or not, it's was nice with an anime that was just a cute story about raising a child and turning that into a love story about said child and the guy raising her just seems shitty to me. Just because it's not illegal doesn't mean it's morally correct.
>>
Rate my email DNC/Podesta email downloader

Just replace "dnc-emails" on the website with "podesta-emails" for podesta emails. Although you'd probably want it in another folder

#!/bin/bash

x=1
folder="emails"
website='https://wikileaks.org/dnc-emails/get'

if [ ! -f "error.html" ]
then
curl "$website/error" -o 'error.html'
fi
if [ ! -d "emails" ]
then
mkdir emails
fi

while
if [ ! -f "emails/$x.eml" ]
then
echo "-----------------DOWNLOADING $x------------------"
curl "$website/$x" -o "$folder/$x.eml"

if [ "$(cat error.html)" == "$(cat $folder/$x.eml)" ]
then
rm $folder/$x.eml
break
fi
sleep 1.5
fi

(( x += 1 ))

do
:
done
>>
Doing a uni assignment, the night before it's due, as per usual.
I need to list 3 games that were made in Unreal Engine, then say whether or not that was a correct decision, to develop on Unreal, compared to other engines.
I've only used Unreal for a very small amount of time in this unit. Last year I taught myself Unity (did a shitty sidescroller).

The only thing I can say about Unreal, is that it seems to be more accessible to people who can't code for shit (with the Blueprints thing).
Though it is, according to some random guys online, more optimized that Unity.

But it feels weird to take a game, and then say, "this was a horrible choice". If I used Unreal AND a different engine for a few years, I might be able to make that call. But all I've done is import models, play around with input, and do some lighting. Fuck all really.

Opinions /g/?
Feel free to point me to a thread focused on Game Engines, if they exist.
I normally just talk in /dpt/ is all
>>
>>57327593

Why do you sleep between downloads?
>>
>>57327640
As to not spam the server with requests?
>>
>>57327630
Just point a 2D game made in Unreal, say it's shit because Unreal it's for 3D, then pick 2 realistical 3D games and say they made the right choice because Unreal is a pretty 3D engine
>>
trying to make a menu in python that can either loop back to the very beginning, or exit the program if the user specifies. this is what I have so far.
c = (input("Would you like to scrape a board, or a specific thread?\nPlease enter 1 for thread, or 3 to scrape every thread on a board:\n"))

while c is "1":
board = input("What board would you like to search?: \n")
max_p = int(input("How many pages would you like to search?:\n"))

if len(nchan_spider(1)) > 1:
while True:
try:
for i in threads_list(threads_get(nchan_spider(max_p))):
print(i + "\n")
print("The above is a list of threads available to select from.")
thread = input("Please enter the thread ID: \n")
search_thread((thread_spider(board, thread)))
break
except ValueError:
print("Not a valid input. Please enter a number (e.g. 1, 2, 3, 150, etc.)")
continue
else:
print("Not a valid board abbreviation, try again.\n\n")
continue

while c is "3":
board = input("What board do you want to scrape from?\nPlease enter just the letter for the board: ")
if len(nchan_spider(1)) > 1:
while True:
try:
deepsearch_thread(deepthread_spider(threads_get(
nchan_spider(int(input("How many pages would you like to scrape from?\n: "))))))
break
except ValueError:
print("Not a valid input. Please enter a number (e.g. 1, 2, 3, 150, etc.)")
continue
elif len(nchan_spider(1)) <1:
print("Not a valid board abbreviation, try again.\n")
else:
print("Please enter 1, 2, or 3\n")
>>
>>57327630
Seems like a shitty assignment.
>>
>>57327665
Thanks yeah this seems like a good idea

>>57327724
Yeah it's awful
Makes sense if I knew what I was doing
But I'm essentially judging developers which are 500 times more experienced than me
It's only meant to be ~1 page though
>>
>parse xml for an android app
Should I learn how its done with xml parsers or just implement one myself.
>>
What do I spend the next few days/week programming a script to encrypt text using my own "algorithm" or a text based adventure game? if the game what should it be about?
>>
>>57327630
All unity games i've played choke pretty hard on resources.

Some overheat my other toaster while UE4 games don't.

IMO unity is pretty shit.
>>
>>57327669
I believe you want
c == "1"
, etc, its the equivalent of Java's == vs .equals(), while all
 a is b 
implies
 a == b 
,
 a == b 
does not imply
 a is b 
>>
File: Untitled.png (381KB, 1328x1024px) Image search: [Google]
Untitled.png
381KB, 1328x1024px
I just started recently and I'm going through the book The C Programming Language.

I'm at Exercise 1-9: "Write a program to copy its input to its output, replacing each string of one or more blanks with a single blank."
This is my solution:
#include <stdio.h>

main()
{
int c;
int blankcount = 0;

while ((c = getchar()) != EOF) {
if (c == ' ') {
if (blankcount < 1) {
putchar(c);
++blankcount;
}
}

if (c != ' ') {
putchar (c);
blankcount = 0;
}
}
}


Does anyone have a more concise way of doing this? I know about && and the else-statement, but the book hasn't introduced them yet, so I think you're supposed to do this without them.
>>
>>57327902
they probably want you to take in input until EOF and then spit it back out with the spaces collapsed, no?
>>
Currently trying to automate my every day Amazon Sales Business.

And HOLY FUCK WHAT IS WITH THIS API?

It offers all available data except everything that I actually need. They literally beg me to scrape their site.
>>
>>57327902
int c, b = 0;

while ((c = getchar()) != EOF)
{
if (b != c || c != ' ')
{
putchar(c);
}
b = c;
}
>>
>>57326330
Doesn't work on the superior browser, Firefox.
>>
>>57327902
Use an else famalam.
>>
File: explosive diarrhea.gif (2MB, 700x394px) Image search: [Google]
explosive diarrhea.gif
2MB, 700x394px
>>57327950
I think it's until you hit enter. Earlier the book gives you this code:
#include <stdio.h>

/* copy input to output, 2nd version */
main()
{
int c;

while ((c = getchar()) != EOF)
putchar(c);
}

And this outputs when you hit enter.

>>57328001
>>57328005
Else and || are only introduced in the chapter after this one.
>>
>>57327776
come on, someone make the choice for me because I'm not capable of making decisions
>>
>>57328098
just watch anime and play vidya
you're not gonna learn anything anyway
>>
>>57325190
I just made my first implementation of a genetic algorithm work. Shit's way more simple than the name implies.
Now I'll either reimplement it in Lua for the luajit keks or port it to cython so I can see how fast that thing goes.
>>
>>57328071
>Else and || are only introduced in the chapter after this one.
Stop being autistic about this, faglord.

int c, b = 0;

while ((c = getchar()) != EOF)
{
if (b != c) {
if (c >= '!' /* or != ' ', depending on what "blank" means */) {
putchar(c);
}
}
b = c;
}
>>
File: thumbs up.jpg (39KB, 301x267px) Image search: [Google]
thumbs up.jpg
39KB, 301x267px
>>57328118
This works.
>>
>>57328104
I don't play vidya though also not looking to learn I'm looking for something to kill time
>>
Writing a library for genetic algorithms. Breeds, mutates, selects, evaluates

Want to use it to find solutions for nurse scheduling problem.

Would calling it libgen (link with -lgen) conflict with any major pre-existing packages?
>>
>>57328146
Actually, I just realised that it doesn't.

Try inputting repeating characters, for example two letters.
>>
>>57328194
i dunno but why not libgene
>>
>>57328194
It would conflict with the world's largest online library.
>>
>>57328194
Yes

http://pubs.opengroup.org/onlinepubs/7908799/xsh/libgen.h.html
>>
>>57328199
Yeah I just realized it after I posted that.
>>
>>57328219
#include <stdio.h>

int main(){
int c, b = 0;
while( (c = getchar()) != EOF){
if(b == c){
if(c == ' '){
b = c;
continue;
}
}
putchar(c);
b = c;
}
}
>>
>>57327776
>>57328098
The encryption thing.
But you better implement decryption as well.
>>
>>57325365
I don't know what's worse. Watching cartoons as an adult, or getting good triggered by cartoons as an adult.
>>
Alright, doing some of the /dpt/ rolls (https://better-dpt-roll.github.io/), and I've made an attempt at "Iteratively estimate pi to 1000 digits"

Here's the python code:

import math
x = 0
y = 0
r = input("Enter radius: ")
r2 = r**2
while x < (r+1):
y = y + math.sqrt((r2)-(x**2))
x = x+1
print (y*4)/r2
input("")


It uses x^2+y^2=r^2 (cartesian equtaion of circle) and measures y value of each integer x in the first quadrant. Multiplies the result by 4 to estimate area of the whole circle (pi*r^2). Divides it by r^2 to estimate pi.

Unfortunatly, if I run a billion (literally) iterations, it takes about twenty minutes and will only give me pi to 9 places (which is still an accomplishment, but not success). This makes getting even 20 digits inconceivable within my lifetime, with this algorithm on this computer (Core2 Duo E7400 lol, replacing it this month).

Is my problem due to some horrible inefficiency? Have I used a bad technique to estimate pi? Or is it just because it's running on an interpreter?
>>
>>57328256
yeah I should be able to do decryption too
>>
>>57325684
>function
Let me waste a post and correct myself.
int rhd(int num){
int dig = 0;

for(int oom=1; oom<num; oom*=10){
if((num/oom)%10>dig) dig=(num/oom)%10;
}
return dig;
}


Also, laugh at my post in the last thread: >>57325258
>>
>>57328240
That first b=c is pointless, but this actually works.
>>
>>57328258
>watching moving pictures as an adult
If you want to qualify as an adult, all your pictures better be stationary.
>>
File: last.png (91KB, 1918x829px) Image search: [Google]
last.png
91KB, 1918x829px
Working on my terminal emulator, did a bunch of refactoring and performance improvements, now the performance of insertion heavy programs like yes is on par (if not faster) than with st and rxvt-unicode.

Have a nice terminal render of a picture.
>>
>>57328258
I'd just like to interject for a moment. What you're referring to as cartoons, is in fact, anime, or as I've recently taken to calling it, animation.

Yeah. I got bored really quickly.
>>
File: the term.png (41KB, 237x222px) Image search: [Google]
the term.png
41KB, 237x222px
>>57328328
>>
File: 1476315408830.jpg (65KB, 960x695px) Image search: [Google]
1476315408830.jpg
65KB, 960x695px
How do I check whether a point is in a rotatable rectangle
>>
>>57328419
all rectangles are rotatable
>>
>>57328419
You shouldn't have skipped trig, anon.
>>
If this:
for(int i = 0; i < 10; i++) {
do_something();
}

is a loop then what's an antiloop?
>>
>>57328449
Not this one
>unzips dick

>>57328451
What does this have to do with trig?
My idea is to model the vectors between the rectanges points as function and check whether the Point is on the right side of them.
>>
>>57328456
A kind of african deer
>>
>>57328468
Oh now that I typed that out maybe it would be better to temporarily unrotate the rectangle and the point with it.
Checking for collision would be trivial then
>>
what are some useful miscellaneous macros that make c less of a pain
>>
>>57328456
Just count down to zero

>>57328544
#define static_arrlen(p) (sizeof(p) / sizeof(*p))
>>
>>57328516
>Checking for collision
2bh this always seemed like an impossible task

How is this generally done?
>>
File: 1477184224876.jpg (9KB, 261x192px) Image search: [Google]
1477184224876.jpg
9KB, 261x192px
>taking comp Sci AP in my senior year of hs rn
>get an A the first cycle
>now I have a low B
>failed one test
>got a C on the other
>mfw choking
>mfw it's java

I bought a text book on Java to help with the labs we get. It helped a little but how do I get good at this ? There's people in my class that are a lot better than me at this. I wanna do good when the AP test comes at the end. This is basically my first year at this.
>>
>>57328544
http://research.swtch.com/shmacro
>>
>>57328516
This is how it's done. Checking if a point is inside an axis aligned box is easy. So you rotate your coordinate system to make the box axis aligned.
>>
>>57328656
What exactly is it that you don't understand, or are bad at?

Is it the OOP mindset, the syntax, the type system? Define your problem, then you or maybe other anons can come up with a solution for you.
>>
>>57328661
I puked a little in my mouth
>>
How would one hash 30000~80000 words with min collisions. The number is large enough to where a bad hash would dramatically slow down the code.
>>
>>57328882
If performance really matters, something simple like crc32 or whatever. If not, something like sha1.
>>
>>57328759
recursion for 500
>>
>>57328759

I've been making stupid mistakes on little things. I need a way to practice , like I need more projects or something to better my understanding.
I've been making stupid mistakes on little things. I need a way to practice , like I need more projects or something to better my understanding.
>>
>>57328981
Ignore the double I fucked up.
>>
>>57328981
i think a better idea would be to study the answers you got wrong on the past test and pay attention in class
>>
File: g v1.4.png (302KB, 1920x1080px) Image search: [Google]
g v1.4.png
302KB, 1920x1080px
>>57328981
Make random things like these in Java.
>>
Just wondering. I'm trying to write a program that checks for balanced parentheses e.g. (), {}. []
and the requirements is that I can't use a character array or a string type.
I'm thinking about a stack to implement this, but isn't a char array or string type necessary just for taking in the expression and counting the length? pls respond
>>
>>57329117
>checks
checks what? whoever gives you this task should specify
>>
I've heard lately that Ogg Vorbis is a meme. What did Anon mean by that?

Since i can't find the mp3 specs without paying iso lots of monies, i'm thinking of switching focus to implementing a vorbis decoder instead of an mp3 one. Bad idea?
>>
>>57329117
Stack. Push when you have the left version, pop when you get the right. If everything's even, they'll match. Otherwise, they won't.
>>
>>57329166
Yeah, I was thinking of that, but how would I put in enter the characters of the expression into the stack? I was thinking about either making a char array or putting it into a string variable, counting the length and going on from there; but my assignment says that I can't use a string type and char arrays. I'm just wondering how would I put in the expression into my stack with out a char array or string type.
>>
>>57329193
It's just a stack of characters. Iterate through the input stream. No need to save anything.
>>
>>57329158
>Ogg Vorbis
You may as well use Opus at this point. It's a superior codec and is royalty free, like Vorbis.
>>
>>57329158

It's not really a meme, but it's not something that is as ubiquitous as .mp3 files.

However, I would suggest you don't do decoding implementations by yourself and use third party libraries unless you are doing it for learning purposes. And Opus is the new hotness, if you were thinking about implementing decoding for some application or something, so seriously consider to use that instead.
>>
>>57329228
I see, thanks mate
>>
i can't remember the last time i saw a .ogg file
>>
>>57329252
>>57329245
I am doing it for learning purposes. It would be to have been able to play my mp3 collection with my own decoder, though.

I glanced at Opus today, but i got the impression that it's more intended for network streaming, which doesn't really interest me right now.
>>
>>57329375
would be nice*
>>
I want to master c++ or java, and i cant decide which one should i pick. Can you help me anons?
>>
>>57329393
C++, just in case you really ARE a noob here, and this is not bait.
>>
Fittest: 'It's not really a meme, but it's not something that is as ubiquitous as .mp3 files.' (83/83) from generation 8065
Target reached
./evolve 25.46s user 0.01s system 99% cpu 25.497 total


Evolving strings.
Next up, evolving neural networks.
>>
>>57329427
I am at same level with c++ and java
Design patterns is last thing i learned
But i have never done anything that works with db, something like restful and shit
>>
>>57329375
>i got the impression that it's more intended for network streaming
Yes, it was originally intended for that, but it turned out to better that pretty much every lossy codec in most situations.
>>
Older guy going back to school, half way through the first semester. This school is really, really bad. The only CS teacher is 4 foot tall 300+ LB woman, who pretty much only knows Unreal Engine. They try to push all the students into game development. I'm just trying to get my credits before hopefully transferring to stony brook.

How woefully unprepared will I be? I'm trying to educate myself as much as I can I supplement my "education".
>>
>>57329576
Why are you even going to class if you have to self-teach yourself anyway?
>>
>>57329618
A lot of reasons, no point to break them all down but it's by far my best option right now.
>>
>>57329558
Just dont use ;p3. It's shit. OGG has a much more better quality/size ratio.
>>
>>57329576
hm
my 1st semester:

>Programming in c
>Mathematical analysis 1
>Discrete mathematics 1
>Digital Logic Circuits

2nd semester
>Object oriented programming
>Mathematical analysis 2
>Discrete mathematics 2
>Web programming [basic, html,css js]

3rd semester
>Linear algebra
>Computers architecture
>English [basic]
>Android development


4th semester
>Symbolic calculations [Wolfram mathematica]
>IT projects management
>Data Structure and Algorithms
>Algorithms: Design and Analysis

5,6th
>software engineering (c++, java)
>probability
>networking [cisco]

and i forgot others, it was 2 years ago :D
there were lots of good things to learn desu
>>
>>57329558
Wikipedia seems to agree with you. Maybe i'll take a closer look at Opus then. Thanks.
>>
File: amada.jpg (268KB, 1410x1406px) Image search: [Google]
amada.jpg
268KB, 1410x1406px
>>57329727
In comparison to my only one math class - that is horrifying. There is seriously only one math class in my entire track.

It's simple math too - just algebra. It's been 6 years since high school and even in high school I never took pre-calc so I need to start where I am.

You also got to start with C compared to my bullshit "logic" class that consists of psuedocode with rules that are more strict than a real language and visual logic.

Makes me wish I could afford to go to a 4 year school right off the bat but this is my only option for the next 2 years. Doing anything other than getting this associates degree is not an option.
>>
>>57329807
btw, in 5th and 6th semester there is:
>statistics
>english [advanced]
>arithmetic geometry
>web dev, databases [access,mysql,php]

7,8,9,10th semesters are good, that is when real shits starts
That is when you start machine learning, machine learning is like first 6 semesters combined.
>>
>>57329032
Yeah I need to do that but we don't get our test back
>>
File: 1477605588520.jpg (66KB, 720x960px) Image search: [Google]
1477605588520.jpg
66KB, 720x960px
>>57329873
>>57329727
I'm so excited to get into the "meat" of the education. Bit of a blog inc just stop reading;

Every time I question anything we do in class the teacher seems to take it personally and starts talking about "M-MUH PEDAGOGY" and coming from a legitimate walking spicy meatball it's aggravating. I'm also hyper-competitive so I can't take class lightly, I always try too hard.
So I was really upset with the quality of education but today I tried to apply what I learned so far in python and wrote a modularized number averaging program and it only took like 40 minutes.
Plus I felt like I understood what everything was in the syntax quick references, so I think I'm progressing at least.
>>
>>57330006
>I tried to apply what I learned so far in python
Only thing i dont like about my faculty is that you can only learn c,c++,c# and java. There is nothing else.
>>
>>57328262
I'd say try a different method.
Cheating a bit, SICP has pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 ...
Having noodled about with this before, I've got pi equal to the sum of 4(1/(4x+1) - 1/(4x+3)) from x=0 to x=INF (alternatively, the sum of 8/((4x+1)(4x+3)) from x=0 to x=INF).
I even had a go at it myself:

from time import time

x=0
pi=0
pi1=-1
r1=0
r2=0
currentTime = time()

while(pi-pi1>10**-1000):
pi1 = pi
r1=4*x+1
r2=r1+2
pi = r1*r2
pi = 1/pi
pi = 8*pi
pi = pi + pi1
x = x+1
print(str.format('{0:.1000f}', pi1))
print("Time taken:", time()-currentTime)

Whole thing takes me two minutes to compute.
Sadly, you'll discover that Python only keeps fifty significant figures and not the thousand you want: we'll both need to find a different method to go about this.
>>
Why didn't any lisp varient with m-expressions every become popular?

It's clear from looking at s-expressions they're not supposed to directly be used by the programmer.
>>
Okay, guys. I'm stuck. Here is my code so far.
I'm trying to have my program take in an arithmetic expression into my stack, but I keep getting an error where i is being used without being initialized. How would I take in an equation into a stack correctly?

int main(){
// Stack that will hold expression
stackType<char> stackExp;
string exp;
cout << "Please enter an arithmetic expression ending with ;" << endl;
cin >> exp;

for(int i; i<sizeof(exp); i++){
if ((exp[i] == '(') || (exp[i] == '{') || exp[i] == '['){
stackExp.push(exp[i]);
cout << exp[i];
}// end if
}// end for loop

system("pause");
return 0;
}

>>
>>57330417
You should probably initialize i, presumably as 0
>>
>>57330417
i thought you said you couldn't use anything resembling a string
>>
>>57330425
OKay that works, and that actually cout's the exp[i] at the end. Thanks, i may need help later on.
>>
>>57330417
>I keep getting an error where i is being used without being initialized
What a hard riddle anon.
>>
>>57330417
>I keep getting an error where i is being used without being initialized
>>57330425
>You should probably initialize i
>>57330447
>OKay that works

Jesus fucking christ
>>
>>57330439
Well, i'm not sure how I would take in the equation.
>>57330450
lel, rubber ducky
>>
>Gender Bias in Open Source: Pull Request Acceptance of Women Versus Men
my sides
>>
//include stdio
#include <stdio.h>

//define function called main, returns an int
int main(void) {
//begin for loop going from 1 to 100
for (int i = 1; i <= 100; i++)
//begin for loop
{
//check if i is divisible by 3
if ((i / 3) == (i / 3.0) && (i / 5) != (i / 5.0))
printf("fizz\n"); //print fizz
//check if i is divisible by 5
if ((i / 3) != (i / 3.0) && (i / 5) == (i / 5.0))
printf("buzz\n"); //print buzz
//check if i is divisible by 3 and 5
if ((i / 3) == (i / 3.0) && (i / 5) == (i / 5.0))
printf("fizzbuzz\n"); //print fizzbuzz
//check if i isnt divisible by 3 or 5
if ((i / 3) != (i / 3.0) && (i / 5) != (i / 5.0))
printf("%d\n", i); //print i
} //end for loop
}

Why isn't my code working
>>
>>57330558
I hope that is satire.
>>
So I'm learning python and want to make a script to crack common codes and ciphers here's what I plan on having binary, hex, decimal, ceaser shift, base64

anything else I should add, just looking for ones that're commonly used
>>
>>57330558

Because you have 4 different if statements that work seperately instead of an if if else chain of those 4 statements.

Also, learn what % means in C.
>>
>>57330558
are you barred from using %?

>Why isn't my code working
this is not a good bug report
>>
why the fuck is everyone using C++ for SDL

it's really hard to find C examples
>>
>>57330653
SDL is a C library, you use it the same way you would as in C++.
What resources are you looking at?
>>
>>57330725
not really using anything in particular, i'm just googling around

i'm only a beginner and all i know is basic C
>>
>>57330767
Well try to ignore the C++ specific stuff because that has nothing to do with how SDL is utilized in your program.
>>
http://pastebin.com/1M0h2vBU
Anyone like my shitty csv implementation?

I had to do a quick/messy job, it's for an assignment for school. Also meaning I had to comment the hell out of it
>>
>>57330898
>it's for an assignment for school. Also meaning I had to comment the hell out of it
Do better.
http://www.stack.nl/~dimitri/doxygen/
>>
>>57330898
Doesn't handle strings that contain commas properly
>>
File: DeepinScreenshot20161101011617.png (64KB, 1084x308px) Image search: [Google]
DeepinScreenshot20161101011617.png
64KB, 1084x308px
What do you guys think about my program?
>>
>>57331019
It doesn't need to be that complex. It just needs to werk for simple alphanumeric strings. No punctuation/newlines necessary

>>57331018
I have to print it out and give it to him. Doxygen is unnecessary
>>
>>57331056

It's a program.
>>
>>57331056
when can you start
>>
>>57331056
It's the best possible program. You should just stop programming forever since nothing you ever do in the future will top that one
>>
>>57331068
>It doesn't need to be that complex
It does to be a compliant CSV parser

If you don't have to do that, you aren't writing a CSV parser
>>
>>57331056
r u poo in loo
>>
>>57331095
>It does to be a compliant CSV parser
No it doesn't actually. I'm only writing this to help out with the task. Just need good inputs
>>
>>57331056
I'll tell you what I think when the patent office gets back in touch. Thanks for the algorithm, sucker :^)
>>
>>57331095
>It does to be a compliant CSV parser

You act like there's some sort of standard.
>>
>>57331056
What is that asterisk for before the for loop?
>>
>>57331108
>No it doesn't actually
Yes it does actually. RFC 4180, section 2.5

You're welcome to implement it without quotation parsing, and your assignment probably doesn't require it of you, but you aren't writing a compliant CSV parser. You're just parsing text in some unnamed way.

>>57331177
There is
>>
>>57330406

S-expressions are nice. Nothing wrong with them.

>>57331095

Even a fully compliant CSV parser isn't... too complex, I think. As long as you remember how to deal with quoted strings, it's still pretty straightforward.

That said, it's still too much work if you can at all use a library.
>>
File: DeepinScreenshot20161101013103.png (98KB, 1088x293px) Image search: [Google]
DeepinScreenshot20161101013103.png
98KB, 1088x293px
>>57331070
>>57331072
>>57331076
>>57331102
>>57331109
Am I doing it rite?
>>
>>57331188
>It does

"It does not specify an Internet standard of any kind."

- RFC 4180
>>
>>57331185
That's not actually a for loop. It's a list comprehension.
And the asterisk unpacks the list.
Here it calls the print function with the arguments being the elements of the list.
>>
>>57331249
Thank you for breaking that down, I was wondering why I couldn't find any info on one line for loops.
>>
>>57331056
>no functional purity
>code isn't point-free
>>
I'm having a problem with a assignment in my intro class where we are supposed to implement matrix multiplication. The issue is something with the way I'm doing the columns in the multiplication function. This weird column appendage in the middle of the multiply function serves as my last ditch attempt by me to make it work by making a list of columns instead of triple nested for loops? It works for inputs like this
m1 = [[-1,3], [2,-2]]
m2 = [[-1],[2]]

but it doesn't work for any other legal size of m2??

 #!/usr/bin/python3

import math
import unittest
#import matrixplot as mp

def column(matrix, c):
columnList = []
for index in range(0, len(matrix)):
columnList.append(matrix[index][c])
col = columnList
return col

def rowcol_product(row, col):
if len(row) != len(col):
raise MatrixAlignmentException
total = 0
for index in range(0, len(row)):
total = total + (row[index]*col[index])
return total

def product_defined(m1,m2):
r2 = len(m2)
for row in m1:
if len(row) != r2: return False
return True

def multiply(m1, m2):
if (product_defined(m1, m2) == False):
raise MatrixAlignmentException
newMatrix = []
for i in range(0, len(m2[0])):
newM2 = []
col = column(m2, i)
newM2.append(col)
for element in range(0, len(m1)):
row = m1[element]
newRow = []
for index in range(0, len(newM2)):
col = newM2[index]
#for index in range(0, len(row)):
newElement = rowcol_product(row, col)
newRow.append(newElement)
newMatrix.append(newRow)
return newMatrix
>>
File: cuknjivodrvo.png (10KB, 441x380px) Image search: [Google]
cuknjivodrvo.png
10KB, 441x380px
the hundreds should be odd numbers, the tens should be even, and the ones should be able to be divided by 4.
>>
File: woo.jpg (2MB, 1200x1800px) Image search: [Google]
woo.jpg
2MB, 1200x1800px
>>57331290
>triple nested for loops
as a first pass this is what you should be doing. there is no way you need 45 lines to do this job

>but it doesn't work
be more specific
>>
>>57331319
>needing more than one loop
>needing more than one variable
#include <stdio.h>
int main(void) {
for (int i = 100; i < 1000; i+= 4) {
if (0 != (i / 10) % 2)
i = ((i / 10) + 1) * 10 - 4;
else if (0 == (i / 100) % 2)
i = (i / 100 + 1) * 100 - 4;
else
printf("%d\n", i);
}
}
>>
>>57331394

It is a specific assignment, and all the useless helper functions are part of it, not my personal design choice.

It always returns a multiplied matrix in the form [[integer],[integer]], regardless of what two matrices I multiply, as long as they are legally multipliable. Doesn't give any errors, just spits out incorrect answers(although it gets the first two numbers that it returns to the matrix list correct)?
>>
>>57331284
How can i port this to windows? :^)
>>
How different is CS to SE in burgerland?
>>
>>57331691
CS drops out because wanted to program gaymex xD
SE is pajeet
>>
>>57331705
What about CE?
>>
>>57331691
It depends. As it is the meaning of CS varies dramatically based on the college. In some places (mostly smaller schools) it may as well be an IT major, and in others it's more theoretical. So you really need to compare based on the specific college you're looking at.

FWIW where I went CS and SE were essentially the same thing for the first 2 years, then CS majors took a few more theory classes (things like linear algebra, AI, and compilers) and SE majors took shit like project management. From what I hear the SE classes are a little easier toward the end, but it's basically a liberal arts major and SE majors can go suck a dick fags
>>
// This program will read for matching group symbols from arithmetic equations


#include "myStack.h"
#include "stackADT.h"

// The string library will only be used to take in the expression and measure it
#include <string>
#include <iostream>
using namespace std;

int main(){
// String variable that holds the equation
string exp;

// User i/o
cout << "Please enter an arithmetic expression ending with ;" << endl;
cin >> exp;

// Initialize char stack as a size of the equation
stackType<char> stackExp(sizeof(exp));

// For loop that scans the stack
for(int i=0; i<sizeof(exp); i++){

// If char is an opening symbol, push into stack
if ((exp[i] == '(') || (exp[i] == '{') || exp[i] == '['){

// Initialize stack so stack top = 0
stackExp.initializeStack();

// Then push in the opening symbol as stack top
stackExp.push(exp[i]);

} // end if

// If above condition is successful, then move on to this, or if the equation starts
// with a closing bracket, then this will be triggered
else
{
switch(exp[i])
{
case ')':
// Pop the opening symbol from the stack
stackExp.pop();
break;

case '}':
stackExp.pop();
break;

case ']':
stackExp.pop();
break;
} // end switch
} // end else

}// end for

// If stacktop contains only a ';' then that means the grouping symbols have been pushed and then poped
// confirming that the equation contains matching group symbols
if(exp[0] == ';'){
cout << "Expressing contains matching group symbols." << endl;
} // end if


This isn't final, but I am having a problem. My for loop crashes because int i would eventually become a huge number; I'm not sure what to use to make it only scan the stack, and not overflow. Other than that, the program runs.
>>
>>57331797
I'm not a filthy sepplesfag, but does "sizeof(exp)" really do what you think it does?
>>
>>57331797
You're initializing you're stack multiple times because ...?
>>
>>57331503
fine, i read it. i see the problem but i don't see a great way to hint at it. my suggestion would be to open a new file, write down the 4-5 lines that do the job, and then start shitting it up with the given requirements
>>
>>57331797
What if the brace symbols are mismatched (e.g., "(2 + 4]")
>>
These were my College classes.
Am i fucked if i move to another country?

>1st Semester
Computer Fundamentals
Intro to programming
Math I
Communications techniques
General Administration
English I

>2nd Semester
Math II
OS Fundamentals
Programming workshop I
Databases
IT essentials
English II

>3rd Semester
Data Structure
Networking I
Information Systems I
Programming workshop II
Accounting
English III

>4th Semester
Information Systems II
Web Dev
OS workshop I
Programming workshop III
Database workshop
English IV

>5th Semester
Investigation Methodology
Software Engineering
Use Case Tools
OS workshop II
Informatic Projects I
English V

>6th Semester
Finances
Calculus I, II, III
Informatic Projects II
HRM
English VI

>7th Semester
Statistics and probablility
Strategic Planning
Algorith Analisis
Informatic Projects III
Information Technologies I
Project Evaluation

>8th Semester
Organizational Behavior
Computational Auditing
Economics
Integral Informatic Projects
Information Technologies II
>>
>>57331921
>Calculus I, II, III
>taking calculus I in your third year
Nigger what are you doing with your life
>>
>>57331912
I'm going to add conditions to prevent that under my cases.

>>57331882
I'll remove the initialize function...

>>57331849
Probably not...
>>
>>57331933
That's was the college plan, math I and II should had been calculus I and II IMO.

Can't do anything about it.
>>
>>57331933
Reminds me of the statistics masters that took calc together with us my first year.
>>
>>57329071
>in Java
Please,
>>
>>57331921
This is about what I'd expect from an IT major. I'd trust you to plug in my mom's internet modem
>>
>>57331921

This was an IT degree I'm assuming? Not CS right?

I would be curious to hear what any of these fundamentals and workshops classes even are? I can't imagine what you would do in them when you don't do data structures til semester 3, and no algorithms classes until 7!? What kind of degree is this?
>>
>>57331746
They confuse employers, most of the time employers will go for straight up EE instead when CE knows more shit.
>>
>>57331756
>mfw had to work with SE once in a team at uni
>his only contribution was:
import static org.junit.Asser.*;
import junit.framework.JUnit4TestAdapter;
import org.junit.Test;
import java.io.*
import java.util.Vector;
public class TransactionIOTest{

// test method to get the account id
@Test
public void TransactionIOTest(){
String copyOver;
assertEquals("Must be the same", "transactions.trf", copyOver.TransactionIO("transactions.trf"));
}

@Test
public void readFileTest(){
String readTest;
Vector<Transaction> real = new Vector<Transaction>();
Transaction trans1 = new Transaction(10, "Billy-Bob Thorton", 00000, 00000.00, "S");
Transaction trans2 = new Transaction(02, "Billy-Bob Thorton", 10001, 00275.10, "");
Transaction trans3 = new Transaction(02, "Billy-Bob Thorton", 00000, 00275.00, "");
Transaction trans4 = new Transaction(00, "Billy-Bob Thorton", 00000, 00000.00, "S");
real.add(trans1);
real.add(trans2);
real.add(trans3);
real.add(trans4);
readTest.TransactionIO("transactions.trf");
assertEquals(real, transTest.readFile());
}

public static junit.framework.Test suite(){
return new JUnit4TestAdapter(TransactionTest.class);
}
}

I don't know how they let him get to third year
>>
>>57332160
Here is called "Informatics Engineering"

Fundamentals were like a rush in several subjects in a course.

Like in computer F. we did bash,excel,basic crypt conversions

And in OS F we learned Linux, how to setup a server on linux, IP addresses, Windows server, we also learned hardware for some reason.

In workshops they bumrushed us with certain languages and we had to make a final project each semester. first it was c,c++ then java and visual basic. in databases were SQL then oracle.

I guess it's really more aimed to the country environment since it's pretty much mandatory to have a degree to get a job. Also now it's changed, this was the old mandatory plan.
>>
>>57332360
Yep that sounds about right.
>>
Please help /g/
freshman here.

How do I turn a string with a newlines into a nested list in python? For example I would want to make

"4,2,5,1\n, 3,2,1\n, 6,1\n, 5,1,0,4" into [[4,2,5,1],[3,2,1],[6,1], [5,1,0,4]]

I've tried stackoverflow.
>>
>>57332428
You need to know:
- s.split('\n') splits a string s into substrings delimited by '\n'.
- s.split(',') splits a string s into substrings delimited by ','.
- for loops
- creating/appending to a list
- as an alternative to the last two, list comprehensions.

I'm not going to spell it out for you any further because fuck you but i hope this helps
>>
>>57332428
Slowly break the problem down. Use new lines as to split the string. If you don't need to convert the actual numbers, that's it. Google how to split strings using a delimeter in python. Pretty sure there is a method for that.
>>
Or just have >>57332507 tell you the answer. That works.
>>
>>57332360
But i thought SEs were the ones who were supposed to know how to get things done, while CSs choke when faced with real programming tasks.
>>
>>57332507
It has helped. Thanks anon.
>>
>>57332549
Don't fall for those memes, mate.
>>
>>57332549
did a software engineer tell you that?
>>
>>57332579
Mmaaaybe...
It's just the general impression of the stereotypes, i've accumulated.
>>
File: mac.jpg (28KB, 650x400px) Image search: [Google]
mac.jpg
28KB, 650x400px
C++ question: if I have a class that mallocs a chunk of data and keeps the pointer as a private variable, and then I pass a COPY of the class to a method that then does some operation on the malloc'd data and then free's said data, will that free the original malloc'd data?

Ie If i want to copy classes and fiddle with a copy of that malloc'd chunk, I'd have to instead put that data on the stack vs the heap, yes?
>>
>>57332794
You want to learn what "call-by-reference" and "copy constructor" mean. That should answer your question.
>>
>>57332824
How is call-by-reference relevant?
>>
>>57332794
If you class keeps a pointer, then what's going to be copied is the pointer. If you want a deep copy you need to write your copy constructor to allocate a new chunk of memory and copy the data in your old chunk to your new chunk.

Also
>C++
>malloc
>>
Simple windows calculator for a college assignment

This is what I have so far: https://github.com/cylon56/Windows-Calculator/blob/master/src/MyCalcFrame.java
>>
>>57332839
Because call-by-value actually triggers that problem.

>create object
>pass object by value
>no copy constructor
>new object with the same pointer is created
>function does something
>returns again
>object is destructed
>if you, by any change, delete the pointer in your object, it gets invalid
>but your original function does not know that
>and so it might keep using a pointer that was already deleted
>boom

>call-by-reference
>no copy is created
>no copy is destructed
>everything's fine

>call-by-value
>but we have a copy constructor
>makes sure new object has its own memory allocated
>can be destructed without placing the original object in danger
>everything's fine
>>
>>57332824
>>57332911
Reading on copy constructors now
>C++ and malloc
I'm building on an example that used malloc and forgot to do update it.
>>
>>57332947
Oh alright that makes sense. Another way to obtain a copy (other than pass-by-value invoking a copy constructor) would be copy assignment followed by pass-by-reference, for some reason I was envisioning that.
>>
>>57325481
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(int argc __attribute__ ((unused)), char* argv[] __attribute__ ((unused))) {
int n = -1;
int tmp;

while(isdigit(tmp = fgetc(stdin))) {
if((tmp = strtol((char *)&tmp, NULL, 10)) > n) {
n = tmp;
}
}

printf("%d\n", n);

return EXIT_SUCCESS;
}
>>
>>57333184
>__attribute__ ((unused))
Come on, mate. If you're not going to use main's arguments, just do "int main(void)".
Also, "(void)argc;" is the standard way to do that.
>>
>>57333198
I don't know who to believe. Purists say that main *always* has arguments (int argc, char *argv[]) and returns an int no matter what. Purists also say to squash all warnings no matter what. This is the only way that satisfies everyone, and using extensions makes you more neckbeardly.
>>
File: spook.gif (126KB, 300x273px) Image search: [Google]
spook.gif
126KB, 300x273px
I'm very spooked by the fact that most (popular) software is written in C++.

Internet Explorer, Google Chrome, Mozilla Firefox, Safari, Opera, Microsoft Office, VLC Media Player, Steam, and Visual Studio to name a few. It's used for everything.

Even Microsoft uses it instead of C#. Why don't they use C# exclusively? Is it not their language? I thought software for Windows was supposed to be programmed in C#? Why do people still use C++? They use it for everything except macOS where they use Objective-C and Android where they use Java because they have to.

Can anyone explain to me why C++ is this popular? Would it be beneficial to create software in C++ or go with C#?
>>
>>57333232
>Purists say that main *always* has arguments
The standard says otherwise.
>returns an int no matter what
That's true.
>>
>>57325481
firstDigit = last . takeWhile (> 0) . iterate (`div` 10)
main = getLine >>= putStrLn . show . firstDigit . read

>>57333232
Purists? Never heard of them. If you want to write strictly conforming programs, then you shouldn't, obviously, use compiler extensions like attributes.
The current standard mentions two ways to define main: int main(void) {...} and int main(int a, char *b[]) { ... } (plus all possible variations due to parameter type adjustments and typedef synonyms.)
Also, return statement at the end of the main function isn't required anymore.
>>
>>57333258
>Can anyone explain to me why C++ is this popular?
It is very performant and has many features that make it work well in an enterprise environment and in large teams
>>
>>57333232

The standard allows for two definitions of main:
int main(void)

and
int main(int argc, char *argv[])


Any other definition is wrong.

>>57333258

Imagine all of those programs you just listed, except running a little bit slower, and using more memory, due to running in a managed environment.

Also, what language would you use to write the CLR (the runtime that C# code is run on) in, and why?
>>
>>57333374
No, that was bad! Here is a good one.
firstDigit = head . dropWhile (> 10) . iterate (`div` 10)
main = readLn >>= print . firstDigit

>>57333435
Implementation defined, not wrong.
What about int main(int a, char **b) { ... }?
>>
>>57333452
>What about int main(int a, char **b) { ... }?
That is equivalent to "int main(int argc, char *argv[])"
>>
>>57333452

Wrong in the "purist" sense.
But yes, it is implementation defined.
>>
new bred when
>>
New thread:
>>57333561
>>57333561
>>57333561
>>
>>57325481
#include <stdint.h>

int8_t largest(uint16_t n) {
uint16_t copy = n;
uint8_t length = 1, highest = n % 10;

while ((copy /= 10) > 0) {
++length;
if (copy % 10 > highest) highest = copy % 10;
}

if (length != 4) return -1;
return highest;
}
>>
>>57333258
C++ pros:
- Software needs to be fast. C++ gives you the control you need to make fast code.
- Software needs to be easy to distribute. With C++ you can hand the user a relatively self contained executable. With C# you have to hand the user your executable plus a 200MB+ runtime.
- Software needs to be cross platform. C#'s cross platform support is getting better every day but it's still scary to depend on massive platform-dependent frameworks written by someone else.

C++ cons:
- Software needs to be easy to develop. It's much easier to hack together C# code than C++ code.
- Software needs to be correct. C# code avoids entire classes of bugs by handling memory management for the programmer.

if performance is a requirement then C++ may be a good choice.
Otherwise C#, Java, or Python are probably better bets.

There's also a newfangled language Rust that's trying to address some of C++'s shortcomings, but it hasn't picked up much steam in the real world yet.
>>
college pajeet in training here, learning java for CS-101

this project involves taking in an expression from the user using Scanner in the format
> 2 + 5
>% 14 3
>13 ^ 2
That sort of thing. The problem is that I need to catch and reject inputs that have too many or too few tokens in the input. I've hamfisted it to where it rejects inputs of too few tokens, but I cannot for the life of my retarded self come up with a way to catch an input with too many tokens.

Can I get some suggestions on this, please?
>>
>>57333984
if (yourstring.length() > 9000) {
system.out.println("i'm a pajeet");
}
>>
>>57334007
I'm catching small inputs with a string.length() < 5 because the smallest possible string in that format is 5 characters. I can't catch large inputs because the numbers could be any size integer, and length can't tell the difference between "5000 + 1" and "1 + 1 56"

Technically the program just calculates that as 1 + 1 which makes sense, but my professor's wishes take precedence over pragmatism
Thread posts: 322
Thread images: 40


[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.