[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: 43
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>53885491

What are you working on, /g/?
>>
>>53890674

Dick Cheney profited from the iraq war
>>
>>53890685
cool
>>
>>53890685
>>>/out/
>>
File: comfy.png (167 KB, 376x328) Image search: [Google]
comfy.png
167 KB, 376x328
DAILY PROGRAMMING CHALLENGE!
In your preferred programming language, write a function that converts a numeric string into an integer value.
>>
>>53890685
Bush did 1911
>>
>Tfw you and Ruby will never rub butts together
>>
>>53890759

Maximum integer size?

>>53890796

Anon, if you are wanting to see a lewd Ruby, you are posting in the wrong thread on the wrong board. I try to keep things strictly programming related here, except maybe when the subject of politics comes up.
>>
>>53890857
I see so I should see your posts on /fit/ then?
>>
>>53890759
read
>>
>>53890857
haha what the fuck do you post nudes on /soc/ or something?
>>
>>53890759
what bases are valid, and for radix greater than 10 is it lower-case alphabetic first, then upper-case, then ??? or like
>>
p- python?
def strToInt(strigy):
return int(float(strigy))
>>
>>53890882
>>53890905

Should also mention it's on another *chan.
>>
>>53890930
LEWDDD Ruby is all I want now where you post babe
>>
>>53890759

do i win?
int atoi(const char *nptr)
{
long len = strlen(nptr);
int result = 0;
long exp = 0;
long i;
for (i = len - 1; i >= 0; i--)
{
if (nptr[i] >= '0' && nptr[i] <= '9')
result += (nptr[i] - '0') * pow(10, exp++);
else if (nptr[i] == '-')
{
result = -result;
break;
}
else
break;
}
return result;
}
>>
>>53890954
nice ctrl+c ctrl+v
>>
File: image.png (19 KB, 905x898) Image search: [Google]
image.png
19 KB, 905x898
help please.

I don't understand how the statement and function differ. Don't they both return 1 in the end?
>>
>>53890930

Lord have mercy, Ruby.
>>
I have a word counting program
res = Hash.new(0)
ARGF.each_line do |line|
line.downcase.gsub(/[(),.?!`;:"]/, ' ').split.each { |word| res[word] += 1 }
end

res.to_a.sort_by { |pair| pair[1] }.reverse.each { |p| puts "#{p[1]}\t#{p[0]}" }

that I am translating to Java. It's suffering.
>>
>>53890674
Stop this programming fag meme.
>>
>>53890972
try running it
>>
>>53890985

Tell me, GTP, should I be a total cock tease for all of these thirsty traps?

Maybe I'll make them solve classical ciphers to get a link to my secret club...
>>
>>53890759
uintmax_t str_to_i(const char *str)
{
uintmax_t n = 0;

for (; *str && isdigit(*str); ++str) {
int v = *str - '0';

if (n > UINTMAX_MAX / 10)
return 0;

n *= 10;

if (n > UINTMAX_MAX - v)
return 0;

n += v;
}

return n;
}
>>
>>53891163
what about negative numbers?
>>
>>53891111

I think you should do nothing of the sort. What happens when your beautiful christian waifu finds out what you did?
>>
>>53891230

Fair enough. I guess they'll just have to hunt me down themselves.
>>
File: SS2217.png (45 KB, 1033x739) Image search: [Google]
SS2217.png
45 KB, 1033x739
okay, whatever. here's the naive way
thx for the link
>>
>>53891416
you could move the r==INF into the for loop if you really want to be a jerk

for (;i<j&&r!=INF;i++) {
>>
>>53890986
final Map<String, Integer> count = new HashMap(); 
for(String word : myString.split("[\\W]")) {
int c = count.get(word);
if (count.get(word) == null) c = 0;
count.put(word, c + 1);
}
>>
why is fizzbuzz usually stated as 3 : fizz :: 5 : buzz :: 3&5 : fizzbuzz rather than 3 : fizz :: 5 : buzz :: 15 : fizzbuzz? am I missing something? is it a deliberate obfuscation or are there somehow integers divisible by 3, and also 5, but not 15?
>>
>>53891570
an excellent question. I wonder if its possible to prove or disprove this idea though rational thought.
>>
>>53891582
>is it a deliberate obfuscation
is actually the crux of the question, smartass.
>>
>>53891570
The problem never says to print "fizzbuzz"
>>
>>53891612
>http://c2.com/cgi/wiki?FizzBuzzTest
>"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."
if your intent was to piss me off by being a pedant about the casing of the string when the problem logic is the same regardless, congrats, here's your (You)
>>
>>53891539
The easy part was getting things into the Map. The hard part is getting pairs back out.
>>
>>53891674

You can get an iterator for the keyset.
>>
>>53890986
>>53891163
int word_ct(const char *input)
{
size_t len = strlen(input);
char *tmp = (char *) malloc(sizeof(char) * len + 1);
strcpy(tmp, input);

int count = 0;
char *tok = strtok(tmp, " ");
while (tok != NULL)
{
count++;
tok = strtok(NULL, " ");
}
free(tmp);
return count;
}


:3
>>
File: vomit.jpg (90 KB, 650x650) Image search: [Google]
vomit.jpg
90 KB, 650x650
>>53891699
>>
>>53884118
this

also known as Csharts

C# is actually in third place (which is not bad at all) after C++ and java imo
>>
File: 1.png (42 KB, 959x735) Image search: [Google]
1.png
42 KB, 959x735
I'm struggling to create a program with a main menu and submenus

Simply:
Main menu with a selection list
Select one of the items from the list
New submenu with selection list appears

I don't need/want anything fancy. Picture related is what I currently have.

I just need some youtube tutorials or something to get further on this, because I think I've hit a brick wall with my method trying to get it to work, (it does work... but I can't create submenus) and am probably going the wrong way with it.

Google so far hasn't been very helpful for this at all; the few tutorials I've managed to find involve creating more typical program menus like you see in a normal windows application (file, edit, view, on the top bar, etc), which isn't what I'm going for. (It's probably too complicated for what I'm doing/my skill level anyways)

(fwiw, the program itself is a basic address book with name, lastname, ID#, address all stored in a vector with functions for different types of sorting and editing/adding/removing entries)
>>
The Universe is not a sphere.

The Universe is not a torus.

The Universe is a crescent. A sliver across the border of Heaven.
>>
>>53891928
for every submenu, you're building a stack. so you push the main menu at the start, then when they select a submenu you push that. When they pick exit in a menu, you pop one of the menus and display the menu at the top of the stack
>>
>>53891845
what's wrong senpai?
too concise for you?
>>
>>53891674
List<Map.Entry<String, Integer>> entries = new ArrayList(count.entrySet());
Collections.sort(entries, (o1, o2) -> o2.getValue().compareTo(o1.getValue()));

for(Map.Entry<String, Integer> entry : entries) {
System.out.println(String.format("%s:%s", entry.getKey() , entry.getValue()));
}
>>
>>53891928

Are you trying to create some kind dynamic thing, or are you just manually going to display and handle menus?

int main(void)
{
bool quit = false;
while (!quit)
{
ShowMainMenu();
char input = getch();

switch (input)
{
case : 'A' : AddName(); break;
....
}
}
}

void AddName()
{
ShowNameMenu();
char input = getch();
switch (input)
{
....
}
}
>>
>>53891163
>if (n > UINTMAX_MAX / 10)
> return 0;

That's... Weird.
>>
>>53891539
>final
thank goodness, i almost started to think i'm the only one who uses final and const
>>
test
>>
>>53892076
don't worry anon you're not alone
>>
>>53891570
>am I missing something? is it a deliberate obfuscation or are there somehow integers divisible by 3, and also 5, but not 15?

Most people don't notice this and, frankly, it doesn't matter. If you're using FizzBuzz to test whether or not someone sees the mathematical 'optimization' then you're doing it wrong.

It's just a test to see whether you can write a loop, do some logic, and follow instructions correctly. Look how often people on /g/ start from zero, for example.

It's not a deep programming challenge, it's just a "is this person capable of very basic reading comprehension, logic, and structure before I interview them more thoroughly" test.
>>
>>53892005
I'm on Java 7, so lambdas are out. What I did was
Object[] entries = results.entrySet().toArray();
and wrote a sort using the getValue(). It took a shameful amount of casting but it works.
>>
File: 1458961372911.jpg (752 KB, 1920x1080) Image search: [Google]
1458961372911.jpg
752 KB, 1920x1080
Does anyone have that old programming challenge list that had the easy, normal, hard rankings.

Looked kinda like pic related.
>>
>>53892120
this. it's just a quick test to see if a job interview candidate is bullshitting or delusional

>>53891570
you could change the numbers to like 6 and 10 and then there would be numbers that would be divisible by both 6 and 10 but not 60. and you could have a version of fizzbuzz that takes any numbers, not just 3 and 5. also if you check for divisibility by 15, that's 3 divmod (3, 5, 15) but if you check for divisibility by 3 and 5 it's only 2 divmod (3 and 5) because the results can be reused
>>
>>53892120
>frankly, it doesn't matter
minor protest- this
>http://c2.com/cgi/wiki?FizzBuzzTest
suggests that part of why it's "hard" to write is that the if statements are unintuitively structured if you treat divisibility by 15 as the composition of divisiblity by 3 and divisibility by 5. (Apparently. Nesting decision trees is something I have to STOP myself from doing because at a certain point it impacts readability, but it seems that most programmers aren't comfortable with the structure.) that whole pothole goes away if the problem is stated as involving the number 15. and, as stupid as it is that human brains aren't directly wired for prime factorization, it is a fact that that's a layer of complexity to the problem that wouldn't exist if not for deliberately poor communication. (Or, worse- parroting someone ELSE'S poor communication, having failed to notice that the problem can be stated more intuitively.)

>>53892198
valid points, I just don't like communicational problem complexity. the 6/10 problem seems like a more honest way to make the problem difficult, I dunno.
>>
File: programming challenges 2.0.png (378 KB, 1450x1080) Image search: [Google]
programming challenges 2.0.png
378 KB, 1450x1080
>>53892190
>>
>>53892256
Thank you!
>>
I was asked to write an algorithm in pseudocode that should tell which day of the week is in a month if you enter a number from 1 to 31, when 1 is monday. I took the long route and wrote something like this

 
Process weekday
define day as integer;
day=0;

display "Type day number from 1 to 31 :";
read day ;

if day =1 || day =8 || day = 15 || day =22 || day = 29 then;
read "Monday";
else
if day =2 || day =9 || day = 16 || day =23 || day = 30 then;
read "Tuesday";
else etc...
etc



And so on, it works and everything, it was just tedious to make, is there an easier way of writing these kind of codes?
>>
>>53892245
>suggests that part of why it's "hard" to write

I don't know what that is, and I'm not going to read it, but FIZZBUZZ IS NOT HARD.

"FizzBuzz" as more-or-less coined (in programming interview terms) by Jeff Atwood, is a CLASS of problems. Simple problems that just test basic reading comprehension, and rudimentary programming skill.

As for the statements...

if ( (i % 3 == 0) && (i % 5 == 0) )
{
}
else if (i % 3 == 0)
{
}
else if (i % 5 == 0)
{
}


Easy peasy.
>>
>>53890759
def toInt(n="123456"):
return int(n)
>>
>>53892324
fill a list with days of the week, mod the given day by 7, index the list, print
>>
>>53892342
what language?
>>
>>53892348
Could you give me a short example? I barely understood what you told me, sorry.
>>
>>53892324

void PrintDayOfWeek(int day)
{
char **DaysOfWeek = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

printf("Day is %s.\n", DaysOfWeek[day % 7]);
}
>>
File: grad.png (24 KB, 261x223) Image search: [Google]
grad.png
24 KB, 261x223
>>53890759
Mark II
StringtoInteger<-function(x){
if (x=="0"){
x<-0;x
}else if (x=="1"){
x<-1;x
}else if (x=="2"){
x<-2;x
}else if (x=="3"){
x<-3;x
}else if (x=="4"){
x<-4;x
}else if (x=="5"){
x<-5;x
}else if (x=="6"){
x<-6;x
}else if (x=="7"){
x<-7;x
}else if (x=="8"){
x<-8;x
}else if (x=="9"){
x<-9;x
}else if (x=="10"){
x<-10;x
}else{
stop('Number in string is not an integer in 0-10')
}
}
>>
>>53892392
days = ["mon","tue","wed","thr","fri","sat","sun"];
currentDay = days[date %7];
>>
>>53892392
String[] daysOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int currentDay = 7;

String day = daysOfWeek[(currentDay % 7)];
System.out.println(day);
>>
>>53892377
Python
>>
>>53892392

daysOfWeek = ["mon", "tues, ..., "sun"]
today = 5
print daysOfWeek[today % 7]
>>
my latest project:
op is a faggot
>>
>>53892435
ignore mine, I missed that mon is 1.
>>
>>53892420
Why isn't this meme more popular! It's hilarious, I guess it must be a bitch to write all of that redundant code.
>>
>>53892245
>>53892337
The purpose of FizzBuzz is to weed out the ignorant.

You both failed.
>>
>>53892438
put in 3.2 and see what happens. pretty sure that will raise an invalid literal
thus
>>53890929
unless it doesn't need to handle them. the question is pretty vague.
>>
>>53892337
>I'm not going to read what you're talking about, but I AM going to make assumptions about the argument you're making anyway
fizzbuzz is simple logic, yes. it is not a problem I consider hard, no. it is also logic that large numbers of people are bad at. it's reasonable to operationally define problem difficulty in a posteriori/empirical terms, that is, what percentage of the problem solvers experience what degree of difficulty. fizzbuzz is "inexplicably" high on both counts, taking only logical complexity into account.

SO, since these problem solvers are all human, maybe... we should take human factors into account??

humans, especially coders, are taught early on to avoid repeating themselves. sure, this is not as important as we tend to treat it as if it is, but present enough coders with a simple problem whose simple solution involves repeating even something as trivial as an equality test and they will inevitably bend over backwards, statistically, to avoid the repetition. communicate the problem in unnecessarily general terms (divisible by both 3 and 5, as opposed to divisible by 15), and they will treat the specific problem as if it was a general case. fail to accustom coders to nesting decision trees, and they will fail problems that are "simple" but require the unfamiliar structure.

you seem to have gotten the wrong end of the stick here. I'm not complaining that the statement of the problem caused ME issues; I'm trying to think of how the problem could be made less difficult (the a posteriori definition, where we simply observe how hard people seem to think it is) without reducing the logical complexity. Mostly as an academic/aesthetic thing, really.

also:
if i%15 == 0:
fizzbuzz
elif i % 3 == 0:
fizz
elif i % 5 == 0:
buzz
else:
str(i)

avoids some unnecessary typing, and is logically equivalent to the thing you just said, so I don't know why you thought I needed it explained to me?
>>
>>53892497
similarly, if people aren't comfortable with how boolean operators work, they're going to avoid one-line statements like (i % x == 0 and i % y == 0). thus, nested if statements, which are also (apparently) an unfamiliar structure.
>>
'nigger'
>>
How hard would it be to make an alarm that presses the mouse leftclick once when it goes off?

I was thinking it would be really useful as a universal turning playlists into wakeup alarms, itunes, spotify, flash playlists, almost anything that starts when you hit play once.
>>
>>53892464

>The purpose of FizzBuzz is to weed out the ignorant.

Nope.

http://blog.codinghorror.com/why-cant-programmers-program/

Incidentally, you'd be amazed at how many "experienced" software engineers literally have no idea how to program. One experienced "consultant" I interviewed didn't understand how for loops work.
>>
>>53892522
as an exercise or do you really need it?
If you need it, I believe its been done already in AHK:
https://autohotkey.com/board/topic/11143-alarm-clock/
>>
>>53892324
def weekday(day):
return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][day%7]
>>
>>53892497
>you seem to have gotten the wrong end of the stick here. I'm not complaining that the statement of the problem caused ME issues; I'm trying to think of how the problem could be made less difficult

You're wasting time on shit that doesn't matter. You remind me of the jerkoff coworker I had who wrote a "spec" half of which was page after page of ranting about how important coding style was to reducing bug count.
>>
>>53892076
Got code cleanup profiles that enforce it.

Const everything possible. Deny pull requests if they cast it away without reason.
>>
>>53892556
>You're wasting time on shit that doesn't matter.
we are literally both posting in a general thread on 4chan right now, so maybe you should give me a little slack on what kinds of problems I find interesting to consider? also your coworker could probably use an editor, but they're not WRONG.
>>
>>53892543
It was more a cry for help, I'm just beginning to learn to code, and I cannot decypher this page or how to actually run the code.

I just didn't want to start a new thread and couldn't find the question thread anywhere

[spoiler]help[/spoiler]
>>
me: *ponders thing*
you: you're wrong about thing
me: actually I'm right about thing
you: you're overthinking thing
me: I'm having fun doing it, are you having fun yelling at me about it
>>
Oh, and

>>53892497
>avoids some unnecessary typing, and is logically equivalent to the thing you just said,

If you wrote that, I would begin looking for signs that you don't value expressiveness and maintainability.

When some other employee comes along to maintain YOUR CODE after three years, he's going to look at it and not immediately grasp the meaning of "if (i % 15 == 0)" in relation to the other two statements.

There is absolutely no reason whatsoever to do what you've done. It only harms readability for absolutely no gain. If you're going to dick around with % 15 bullshit, then just turn it into a switch statement:

for (int i = 1; i < 100; i++)
{
switch (i % 15)
{
case 0 : ...
}
}


> so I don't know why you thought I needed it explained to me?

Idiot, I wasn't explaining it to you, I was showing the logic that is typical and correct.
>>
guys, why are patterns such a pile of shit?

so i'm writing event system. and first i went with visitors for events. and it's so much spaghetti. just simply checking if i have duplicate event requires me to write additional class that has stored state, setter and getter. what the fuck?

this is so much simpler with unions. where do these "patterns" even apply? because i can't find an application for them.
>>
>>53892596
>me
>you

Anon, what are you doing.
>>
>>53892584
>also your coworker could probably use an editor, but they're not WRONG.

Yeah, actually, he was wrong. Why? Because a spec isn't the place to wedge in your personal, subjective, political beliefs about programming.

He was wasting everyone's time. He was an idiot who was really, really impressed with himself. He wrote a plugin architecture that quite literally reinvented COM. He had in his code, I shit you not, the following comments:

// deep magic

// deeper magic


All he was doing was dumb vtable pointer arithmetic. The EXACT same thing done in COM, except proprietary and full of useless jerk-off comments like above.

A key trait of a good software engineer is knowing where to spend time. The guy who writes manifestos on style in a specification is wasting his own time and that of his coworkers.
>>
>>53892601
>When some other employee comes along to maintain YOUR CODE after three years, he's going to look at it and not immediately grasp the meaning of "if (i % 15 == 0)" in relation to the other two statements
and FUCK him. i believe you should actively sabotage enterprise code whenever you can. it creates more jobs for us programmers.
>>
>>53892610
What are unions for?
I've never found a use for them.
>>
>>53892593
well if you're looking for a place to start, I wouldn't recommend that quite yet. Its messy because depending on your system, the system time will be stored/behave differently etc. I'd recommend programs with purely functional behavior requirements (procedurally does something, without requirements on how fast/when). How about writing a function that checks if parentheses in a string are balanced?
>>
>>53892601
why ARE you so mad about this? the problem is easier to solve if you know that (i % 3 == 0 and i % 5 == 0) will always be the same as (i % 15 == 0), whether you write it that way in the final code or not. maybe you have a point! perhaps, for clarity, the problem should be stated both ways, pointing up the logical identity. perhaps the code should be commented, either way. (i % 3 == 0 and i % 5 == 0) is just as incomplete a statement of the logic as i % 15 == 0, since one fails to capture the commonality between the three tests and one obscures the math.

>>53892626
can... you... chill... please...
>>
>>53892610
>where do these "patterns" even apply?

Mostly in really predictable applications written primarily by low-quality engineers who can't create elegant architecture and code on their own.

Design patterns are effectively "interchangeable parts" for programming. They're an attempt to standardize codebases to reduce the spin up time it takes for a new hire to pick up your project, or for a team to adopt new code and members.
>>
>>53892497
>human factors
it's easier for a human to check divisibility by 3 and 5 than divisibility by 3, 5 AND 15
>>
>>53892601
prompted interview question != production code. I suppose you'd want to enforce company coding standards to all whiteboard work, too?
>>
File: miku.gif (43 KB, 493x522) Image search: [Google]
miku.gif
43 KB, 493x522
Friendly reminder that verbose and well commented code makes you easier to replace so pajeet can take your job maintaining what you wrote.
Always write cute and consise unmaintainable shit if you want to have a job 2 years from now.
>>
File: 6822137aa9f084be836206215b6a148d.jpg (146 KB, 1000x1453) Image search: [Google]
6822137aa9f084be836206215b6a148d.jpg
146 KB, 1000x1453
>>53892644
say you have input events. they have obviously various parameters- like mouse coordinates, pressed key, etc. you can put them all in a union and add enum that specifies what exactly you are using.

now you can pass your events uniformly.
>>
>>53892654
>why ARE you so mad about this?

I'm not mad about anything. Why are you such a precious, sensitive faggot?

> the problem is easier to solve if you know that

Again, you're the kind of person I avoid hiring. Maintainability is more important than conciseness.

> since one fails to capture the commonality between the three tests and one obscures the math.

THAT IS NOT MEANINGFUL INFORMATION. You're trying to "capture" irrelevant shit. Again, you are exactly the kind of person I avoid hiring.

>can... you... chill... please...

Quit projecting, you immense vagina.
>>
>>53892615
Me: xD
You: :P
Jesus:

            .======.
| INRI |
| |
| |
.========' '========.
| _ xxxx _ |
| /_;-.__ / _\ _.-;_\ |
| `-._`'`_/'`.-' |
'========.`\ /`========'
| | / |
|/-.( |
|\_._\ |
| \ \`;|
| > |/|
| / // |
| |// |
| \(\ |
| `` |
| |
| |
| |
| |
__ _ _\\| \// |//_ _ \// _
^ `^`^ ^`` `^ ^` ``^^` `^^` `^ `^
>>
>>53892677
>prompted interview question != production code.

What, exactly, do you think the employer is evaluating you for? "Well, let's see, I hated the style of all his code, but I'm sure he'll be a completely different guy once we hire him!"

Nope.

>I suppose you'd want to enforce company coding standards to all whiteboard work, too?

No, because the interviewee could not reasonably be expected to be familiar with an internal document, obviously.
>>
>>53892679
maybe if you already have a job and have no aspirations to get promoted

if you're a NEET it's inexcusable
>>
What's a good platform for practice making a kernel for?
I've read a lot of OSDev and made a hello world x86 kernel and I've come to the conclusion that I'm not masochistic enough to write a proper kernel for x86/PC platform.
It should at least have support for virtual memory, memory mapped IO, and interrupts. Bonus points for raster graphics.
And I'm going to be emulating it.
Thanks.
>>
>>53892666
the human's not doing the math. the human is telling a computer to do the math. please follow here. compound boolean statements, nested if structures, and repetition are all things I hypothesize naive programmers may avoid. the 15 vs 3 vs 5 test avoids all three, but is unintuitive if the problem is communicated as 3&5 vs 3 vs 5. I'm literally just fuckin' chucking the pigskin around as to "how could we make the problem easier to solve without changing the logic," it is not this serious

>>53892691
>conciseness
???
you're literally not reading anything I'm saying! "intuiting the solution" and "writing the code" are different processes! you have to understand the problem logic before you write code that works, much less maintainable OR concise code!
>THAT IS NOT MEANINGFUL INFORMATION
it is if you care about maintainability! redundancy in documentation improves the likelihood other people will understand your code!
>>
>>53892679

While I find everything you say offensive, I begrudgingly agree.

>>53892713
>maybe if you already have a job and have no aspirations to get promoted

As if there's any actual career path for programmers. The only "promotion" that matters is the one into management.
>>
>>53892712
protip: the guy interviewing you doesn't know how to program or even what "good coding style" looks like

if your solution doesn't match the scribbles in the HR's notebook, you're not getting the job.
>>
>>53892610
>>53892640
I want to hug Satorin.
>>
>>53892737

I've never known HR to ask any sort of coding question. At all.
>>
>>53892712
look up how its actually used. I'm not saying I agree with it, but historically its not used how you claim it is.
>>
>>53892726
it's not even supposed to be as easy as possible to solve. the "divisible by both 3 and 5" adds some complexity so that even a cs grad who is insecure about his programming ability can struggle with how to write it elegantly. % 15 is an acceptable solution but the question shouldn't ask for it explicitly especially since % 3 && % 5 is also a perfectly fine solution
>>
>>53892726
>you're literally not reading anything I'm saying!

Learn what literally means, then get back to me.

You're a blowhard and your point is idiotic. I've explained why several times. I'm done with you. No hire.

>it is if you care about maintainability!

What the fuck are you talking about? No, "capturing" completely irrelevant information does NOT aid maintainability.

> redundancy in documentation improves the likelihood other people will understand your code!

What. The. Fuck. Redundancy in *documentation* only improves the likelihood of said documentation becoming inaccurate over time as it is edited.
>>
>>53892712
real businessmen have potential applicants solve production problems and coding issues in job applications.

Don't even need actual programmers, you can just farm that shit out for free senpai
>>
>>53892747
>look up how its actually used. I'm not saying I agree with it, but historically its not used how you claim it is.

What "it" are you talking about?

I've been interviewing for a long time, on both sides of the table. I can assure you that you are judged by your attention to detail in your whiteboard code. I *will* take your choices as a sign of what damage you'll do to my codebase.
>>
>>53892779
no it would be a huge waste of time, you're supposed to look for actual job candidates, so you can test them on real problems but you should already have a solution to compare against their solution
>>
>>53892779

Heh. I went to an interview once where I was an excellent fit for the job description, got along well enough with the employees, and had a ton of recent experience that was directly relevant to what they were trying to get done.

One lady kept scribbling down every tool and technique suggestion I made. She mined the hell out of me. Not that I cared, it was fairly minor stuff in my opinion. But sure enough, no call back from them.
>>
>>53892779
This is actually a real thing.
I was once brought in to a 5 hour coding interview where i literally had to fix one of their bugs.
They didn't even buy me lunch.
I left 2 hours in when I realized this was they were making do actual work for free.
>>
also, for the record, a comment like "deep magic" is meaningfully communicative. it is programmer talk for "be fucking careful before monkeying around with this"

>>53892754
let me point you up here to where I explain why I'm talking about this:
>>53892497
>Mostly as an academic/aesthetic thing, really.
>>53892245
>I just don't like communicational problem complexity

now can we please stop throwing a hissy fit like I care about the utility of fizzbuzz? I have chosen a problem to examine for the hell of it. I'm sorry no one else finds this problem interesting, I guess?

>>53892774
>Learn what literally means, then get back to me
Learn about semantic drift and the history of words like "very" and "truly", then get back to me.
Putting the SAME explanation in different places is a terrible idea; putting two explanations of the same problem in one place is a great idea. If the logic changes, you still only have to change one comment block, and if someone doesn't get why 3&5 works but DOES get why 15 works, wow, your code makes more sense to them.
>>
>>53892822
top kek
>>
>>53892823
shiggy
>>
>>53892720
VAX
>>
>>53892822
>>53892829
but to be fair, if you actually fixed the bug, who knows you might have gotten hired
>>
>>53892846
>paying for programming work when desperate CS grads are willing to do it for free if you pretend to dangle a job offer
>>
>>53892841
I don't think my vacuum cleaner has any of the things I listed.
>>
>>53892823
>also, for the record, a comment like "deep magic" is meaningfully communicative. it is programmer talk for "be fucking careful before monkeying around with this"

No, it isn't. It was pointer arithmetic. The comment provided zero explanation of what he was doing or (more importantly) why. It was purely masturbatory.

>Learn about semantic drift and the history of words like "very" and "truly", then get back to me.

Blow me, faggot. You're talking about programming, you're posting on /g/, and now you want to get imprecise? Fuck off.

>putting two explanations of the same problem in one place is a great idea.

Yeah, it will be awesome when Billy Bob comes along next year, changes the behavior, and updates the documentation. Except he didn't notice the separate section addressing the same code. So now you have a clusterfuck.

Again, no hire.
>>
>>53892870
>having such an incompetent shop that you can't fix your bugs yourself and get bugs in the first place so that you think it's worth your time to teach random shitters your code base in hope that they will find the solution
>>
Hey there /dpt/. I'm trying something stupid for fun. In Hyper Light Drifter, to unlock a certain costume you need to dash 800 times in succession. It's relatively simple to do, the only catch is maintaining the rhythm of your keypresses. Well I have a mechanical keyboard and it causes an enormous racket to press my spacebar 800 times in rapid succession, plus I value the tendons in my wrist. So I decided to try automating it in C#. The catch is I'm extremely new at C#.

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;

namespace Spacebar
{
static class Program
{
const UInt32 WM_KEYDOWN = 0x0100;
const UInt32 WM_KEYUP = 0x0101;
const int VK_SPACE = 0x20;

[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);

[STAThread]
static void Main()
{
Thread.Sleep(5000); // move the mouse cursor back
Process[] processes = Process.GetProcessesByName("HyperLightDrifter.exe");
int x;
for (x = 0; x < 800; x++)
{
foreach (Process proc in processes)
{
PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_SPACE, 0);
PostMessage(proc.MainWindowHandle, WM_KEYUP, VK_SPACE, 0);
}
Thread.Sleep(200);
}


}
}
}


I bashed a few stackoverflow threads together until this came out. It runs but it doesn't do anything to the active program. A previous iteration of it would make the character jump once but never move again - before I realized you have to specify the KEYUP state as well, rather than just KEYDOWN and assuming it resets every loop. After adding that, though, it doesn't do anything at all. Can any of you guys see where I'm going wrong? Apologies in advance for the silliness of this question.
>>
I just noticed that when I slammed my fist into the table my pinky split open a centimeter long, so I'm done talking about this. I'm gonna close the tab and put a bandaid on and think about something else. thanks for the shitfit, I loved it.
>>
>>53892822

I've heard of the same thing.

Heh. I'm also randomly reminded of the time that Bittorrent had a job listing where you had to complete a programming test and send the answer in the subject line in order to be considered.

Except that they had a logical error in their problem description making it technically unspecified behavior.
>>
File: anime question girl.jpg (50 KB, 736x724) Image search: [Google]
anime question girl.jpg
50 KB, 736x724
Winforms or WPF? pls respond
>>
>>53892888
autohotkey would be easier
>>
>>53892888

I don't think WM_KEYDOWN can be sent to a different process. I mean, if you could do that it would kind of create a lot of potential security issues.

Look into keybd_event(). There's SendInput(), but I always found it to be a ridiculously complicated way to do something fairly simple.
>>
>>53892703
>messes up the top of the cross
have fun sleeping tonight with tammuz tormenting you in your dreams faggot
>>
>>53892906
It would be, but I'd rather do this myself. It's fun, and I feel like it couldn't hurt to get a little more familiar with C#.

>>53892926
But it did earlier. I mean, I have no objection to changing, I'm just puzzled. I'll try keybd_event though, SendInput is what I was looking at first and I avoided it for the reason you stated. It looked pointlessly annoying. I'll give it a shot in any case.
>>
>>53892644

Dynamic typing
Abstract Syntax Trees...

Really, anything where you're representing a generic object that could take multiple forms.
>>
>>53892905

Do you want to target more than just Windows? Windows Forms or GTK#.

Do you want to do everything in XAML and are okay with your application not really running outside of a Microsoft ecosystem (WPF is not a part of the .NET core)? WPF then.
>>
>>53890759
in R
MyVeryOwnFunction<- as.integer

Am I pro yet?

Assuming we're not allowed to use existing functions that coerce objects, here's my shot at it. It's wordy and over-explicit because I assume some others in the thread are as green as me.

StringtoInteger<-function(x){
### Create vectors for comparison, a logical for negation,
### and set to answer start at zero, to be later added to.
chars <- c("0","1","2","3","4","5","6","7","8","9")
values <- c(0:9)
negate <- F
number <- 0

### cut string into a vector of its individual chanracters
split <- strsplit(x, split="")[[1]]

### condition for negation also chops off negative sign
### because it's not in the comparison vector
if (split[1]=="-"){
negate <- T
split <- split[2:length(split)]
}

### For each character "digit", find it in the values
### vector, then add that times place value to the answer.
### Spit error if not found.
for (i in 1:length(split)){
if (!(split[i] %in% chars)){
stop('Object x must be integer as string')
}
digit <- values[chars==split[i]]
number <- number + digit*10^(length(split)-i)
}

### negate answer if condition was met
if(negate){
number <- number*(-1)
}

###state answer
number
}
>>
Thank you Ruby for the Lewddd images and putting stuff up my butt
>>
>>53893194
i don't think i can go back to R from Haskell, the <- really fucking throws me off trying to read that
>>
>>53893196
did ruby start trapping it up or something?
>>
>>53892888
IIRC, you can use System.Windows.Forms.SendKeys.Send() to send keystokes to an active program, though it may cause timing issues in keeping rhythm.
>>
>>53893196
Winners don't do drugs, Anon.

>>53893229
No. I have a legitimate neckbeard. I mentioned to an Anon that I have done lewd things in another thread on another board on another *chan. I never mentioned what those lewd things were, but I can assure you, they do not involve crossdressing.

>>53893194
When I took a statistics class, they had us using R for all of the assignments. But we were pretty much just calling R functions, rather than writing any of our own (math majors aren't programmers). One of these days I should take the time to learn the language proper.
>>
>>53893223
You can use = if you want to.
>>
>>53893352
winners apply drugs.

there's a time and a place...
>>
https://www.youtube.com/watch?v=RCXGpEmFbOw

is it the real linus torvalds at 6:46 or a lookalike
>>
>>53893426
Nah, mate. Use drugs, lose in the long run. Only drugs you should use are antibiotics as prescribed by a doctor.

Well.. that and your regular daily dosage of caffeine.
>>
>>53890759
ITT retards make anon introduction to programming homework.
>>
>>53893473
pretty much this
>>
>>53890930
kek i'd like to see this just for the novelty of it
>>
File: Screenshot_20160406_160507.png (15 KB, 129x129) Image search: [Google]
Screenshot_20160406_160507.png
15 KB, 129x129
>>53893442
unless he got 100% more jewish all of a sudden, no
>>
>>53893473
the Big Four drugs God has given us and have been known to man for quite some time arranged by toxicity:

marijuana to find God

tobacco to focus on your problems

coca to become unrestrained

poppy to forget what is real

times and places, moderation, etc. in the modern world coca and poppy are no longer necessary, tobacco is on its way out. we never know what the future may hold or what we may be required to do however.
>>
>>53893352
>they do not involve crossdressing.
But you're the one that's spamming hime OPs every day, right?
It all makes sense now.
You're not cute enough to crossdress, so you live vicariously through hime arikawa and post cute edits of hime programming.
>>
I'm thinking about giving up on college, /dpt/. There are only 2 semesters left, but i can't see what i would gain by finishing college, and it's expensive as fuck. They haven't had anything to teach me for a long, long time.

I'm Brazilian so maybe having a degree will help if/when i decide to get out of the country. But otherwise, i can't see any advantage to it..
>>
File: 1448832701166.png (236 KB, 540x540) Image search: [Google]
1448832701166.png
236 KB, 540x540
What anime should I watch to improve my coding skills?
>>
>>53893533
he looks more like linus in the video and it could be the lighting that makes your pic look wrong but yeah i was thinking it could be someone else
>>
>>53893567
Code geass
>>
>>53893567
none

>>53893565
i don't think a brazilian degree will be worth much in a first world country Tbh
>>
>>53893572
not his glasses either I don't think
>>
>>53893585
For me to work in the US i need either 12 years of working experience or a 4 year degree.
>>
>>53893587
ah ok then, thanks
>>
>>53893565
brazil's fucked m8 if you stay there it doesn't matter what you do.

move to canada and bleed their welfare while you can
>>
>>53893223
Is haskell nice? Does it have much in common with R? I want to learn Python and SQL purely for their market value, but if I find something R-like with broader applications I might go for that instead.

>>53893352
The R base package is fairly straight forward. I really like that functions just have a simple function(object, arguments) structure and it has 1-based indexing. Just so intuitive. However, it really is just a functional language specializing in statistics. Making executable or something like that is something an expert might do with an obscure package as an experiment. It's not a tool for that. Also if you want to be effective with R it's advised to learn a bunch of other packages which tend to have wildly different syntax from the base and each other. It's a headache. Do other languages do that? Because if so i might just have to give up.

>>53893366
I think you can in most cases, but it's considered good practice not to. I was told you reserve = for setting arguments in functions, and that it can cause class issues when you use it to create an object.
>>
>>53893638
don't think i can get a job in canada yet, i had a job that basically took 10 to 14 hours of my day for the last year.
I'm just now building online presence on github, stack overflow etc..
"A year of experience doing java web" isn't exactly something you'd hire someone from another country for
>>
>>53893549

Actually, the person who posts hime OPs is an Anon. Generally, I tend to prefer the picture of Yuki with an SICP, since it's more traditional. Although at one point in time, on /tech/ (on 8ch), I decided to troll everyone by using a similarly themed image with a pony doing the backflip and holding a programming book.

>>53893642

>Do other languages do that?
What, have inconsistent libraries? Depends on the language. Many communities encourage a consistent style for developing libraries.

>>53893664

They hire Indians for it all the time. I see no reason why a Brazilian would be less competent.
>>
>>53893734
Is there anywhere specially good to look for jobs in canada? Or just the usual (stack careers, etc)
>>
>>53890759
~Ultra compact~ edition.
int atoi(char str[])
{
int n, sign;
char *c;

sign = *(c = str) == '-' && ++c;
for (n = 0; isdigit(*c); ++c)
n = n * 10 + (*c - '0');

return sign ? -n : n;
}
>>
>>53893751

I would not know, I do not live in Canada.
>>
>>53893772
>sign = *(c = str) == '-' && ++c;
positive numbers have to be written as "+x" for this to work then, no?
>>
>>53893855
No. `++c` only gets evaluated if the left part is true, because of lazy evaluation.

Although this way `+x` doesn't work and it really should.
>>
File: 1412888142440.jpg (90 KB, 930x1316) Image search: [Google]
1412888142440.jpg
90 KB, 930x1316
Experimenting with stochastic processes. Making my computer read war and peace to learn english. What should I make it read next? It needs to be long so it has plenty of data
>>
>>53893960
Make it read Lovecraft.

Care to post some of its output?
>>
>>53893952
>lazy evaluation
short circuiting

>Although this way `+x` doesn't work and it really should.
this is part of why shorter code isn't always better, you should cover all special cases
>>
>>53893995
Short circuiting. Thanks.
>>
>>53893960
Infinite Jest.
>>
File: 1412887981424.jpg (426 KB, 850x1111) Image search: [Google]
1412887981424.jpg
426 KB, 850x1111
>>53893980
When I can. It's in the learning phase right now. I'm having it analyze 3, 2, and 1 dimensions of a markov matrix to produce english sentences.

It favors a trigram matrix matrix but if a monogram matrix is overwhelmingly more common than a trigram (e.g: "great wall of china" appears once, but "of course" appears 150 times, then it will most likely (it's weight random) choose "of course"). This way it doesn't just copy and past the source material word for word. It prefers trigrams because they create better sentences.

If you're interested, I suggest you read "A Mathematical Theory of Communication" by Shannon, the section of discrete sources of information and stochastic processes.

It will be online at stochatta.com as soon as it's ready.
>>
File: 1412888553192.jpg (1 MB, 1241x884) Image search: [Google]
1412888553192.jpg
1 MB, 1241x884
>>53893960
>>53894017
I think I'll have it read "I have no mouth and I must scream" next haha
>>
For a server which clients stay connected to for long periods of time (think days), which is the better server architecture:

A: accept loop -> spawn thread -> serve client
B: spawn worker thread(s) -> accept loop -> in worker thread(s) -> select on all clients -> serve client(s)

And by "better" I mean better in two ways: performance, and easier to work with. With the latter being more important.
>>
>>53892409
>every 1st of month is a Monday
>>
>>53894084
did you even read the spec?
>>
>>53892462
but anon it's optimized code
>>
I'm thinking about starting programming, and I'm considering buying a book (preferably about C).


Is it a good idea to start with C instead of Python or Java like most people do?
>>
>>53894639
You'll be able to make "cool things" sooner with Python than you will with C. What motivates you?
>>
>>53894639
>python
please don't

C is fine if you're interested in it, otherwise i'd recommend java
>>
>>53894700
Programming just has a certain appeal to me. It may be hard to start, but creating things from thin air sounds fucking amazing.

>>53894738
Thank you mate. I'll check them both out, even though Java has a bad reputation.
>>
>>53894769
C++ is also an option if you want something more in between, but it can be a bit much for a beginner, i'd suggest you get a decent understanding of java and then learn C++ or C
>>
I work as a java programmer. How do I become a better programmer and less of a googling code monkey?
>>
>>53894639
Python makes it easy to immediately get into programming and playing with programming logic / prototyping which is useful for learning
>>
>>53894873
It also teaches you bad programming habits when it comes down to programming beyond prototyping.
>>
in java how do I go about checking a 2D array for certain objects to see if the player is standing on them? I can't manually type in all the coordinates since there are multiple levels...
>>
>>53894902
and it doesn't even teach you the most basic things like floats and arrays. and the OOP in python is horrific, most people just ignore it
>>
>>53894950
use a nested for loop to check each coordinate or only look at the coordinate where the player is standing
>>
>>53894963
>the OOP in python is horrific, most people just ignore it
>everything is a object
>standard library is build on classes
lel, k tard.
>>
>>53895011
most python shitters just do trivial scripts, they don't make classes and objects of their own
>>
>>53895034
they still use objects, tard.
>>
>>53890759
fn to_int(num_str: &str) -> u64 {
u64::from_str_radix(num_str.trim(), 10).expect("Not a valid integer, fag.")
}


What do i get?
>>
>>53895057
mostly just built in implicit objects like dictionaries/maps
>>
>>53895060
rust is so fucking ugly
>expect
why is even called expect when it should be except and it shouldn't just be tacked on to the end like a method call, clutters up the main part of the code
>>
>>53894902
What would you say are the good habits that are picked up whilst learning with C?
>>
>>53894984
preferably I would want to avoid hardcoding the coordinates
>>
>>53895122
not sure what you're talking about, do you have a code example? like you could have map[playerY][playerX].getStandables() or something
>>
How do i optimize my code?
defmodule Fizzbuzz2 do
Enum.each(Enum.map(1..100, fn(n) -> n end),
fn(x) -> cond do
rem(x, 15) == 0 -> IO.puts "Fizzbuzz"
rem(x, 3) == 0 -> IO.puts "Fizz"
rem(x, 5) == 0 -> IO.puts "Buzz"
true -> IO.puts "#{x}"
end
end)
end
>>
File: lOwcJMs.webm (627 KB, 720x404) Image search: [Google]
lOwcJMs.webm
627 KB, 720x404
Ask your much beloved programming literate anything (IAMA)

>>53890674
>What are you working on, /g/?
/r/dailyprogrammer. Made a solution for #260 Easy in Racket that shows why Lambda is the ultimate goto

>>53892679
Chris Sawyer programmed the RollerCoaster Tycoon games in x86 assembly. Because of that he was unavoidable and earned
~$30 millions making him one of the most well paid programmer ever.

>>53892841
>>53892720
VAX actually had one of the most interesting instruction set (memory to memory, fast Fourier transform, ...) but it's now dead technology.

>>53893567
not anime but manga; System Engineer.
http://kissmanga.com/Manga/SE

>>53894639
Avoid C at any cost. Python is fine.

>>53894902
>bad programming habits
Which ones ?
>>
>>53895144
well to avoid walking into walls I use this:

switch (key) {
case KeyEvent.VK_UP:

if (speel.level1[this.xPosition][this.yPosition-1] == 3) {

System.out.println("solid");
speel.objectarray[this.xPosition][this.yPosition] = speel.returnPlayer();
speel.repaint();


3 is the value I use for walls and 20 for keys, problem is it doesn't actually see if you're standing on the key:

switch (key) {
case KeyEvent.VK_UP:

if (speel.level1[this.xPosition][this.yPosition-1] == 3) {
System.out.println("solid object");
speel.placeableobject[this.xPosition][this.yPosition] = speel.returnPlayer();
speel.repaint();

if (speel.level1[this.xPosition][this.yPosition-1] == 20)
System.out.println("you have the key");
speel.placeableobject[this.xPosition][this.yPosition] = speel.returnPlayer();
speel.repaint();

} else {

speel.placeableobject[this.xPosition][this.yPosition] = l;
yPosition -= 1;
speel.placeableobject[this.xPosition][this.yPosition] = speel.returnPlayer();
speel.repaint();
System.out.println("y= " + yPosition);
System.out.println("x= " + xPosition);
System.out.println(speel.placeableobject[xPosition][yPosition]);
System.out.println("you don't have a key");
}
break;
>>
Scanner sc = new Scanner(System.in);
String k = sc.nextLine();
while(k != "exit")
{
k = sc.nextLine();
System.out.println(k);
}

The while loop doesn't end when I enter exit and I have no idea why. I know this is pretty basic shit but I really don't know why it's doing this
>>
>>53895297
My hunch is that line is "exit\n".
>>
>>53895297
while(!k.equals("exit")) {


what happens is that when you enter exit, a new string object is created, so the object that represents the string literal is a different object, so you have to use the equals() method to see if the contents of the two objects are the same

or if that fails, try >>53895338, depending on what the documentation says for Scanner#nextLine()
>>
>>53895338
>>53895347
Thanks. Turns out using the equals function worked it out.
>>
>>53895107
Not arguing for C. I would use it for emb systems but nothing else. C++ is the best for teaching. Best blend of entry level syntax, program structure, pseudo memory management, and even OOP.
>>
File: 1452403462016.png (79 KB, 307x400) Image search: [Google]
1452403462016.png
79 KB, 307x400
>>53895230
>Avoid C at any cost. Python is fine.
>""programming literate""
>>
THE NEXT FUCKER TO POST SOME GODDAMN FIZZBUZZ GETS HIS SHIT KICKED IN
>>
>>53894051
It depends on how many clients you're expecting to have and whether you're planning on doing any computationally expensive logic within those threads.
Light load? A
Otherwise go with B
>>
>>53895587
if i==15 print fizzbuzz elif i == 3 print fizz elif if i == 5 print buzz else print i exit
>>
>>53890759
(define rep->number
(lambda (b x)
(if (= (string-length x) 0)
""
(let ((f (string-ref x 0)))
(cond ((char=? f #\-)
(* (rep->number b (substring x 1)) -1))
((char=? f #\+)
(rep->number b (substring x 1)))
(else
(convert b x)))
))
))

(define convert
(lambda (b x)
(if (= (string-length x) 0)
0
(let ((f (substring x 0 1))
(b-len (string-length b))
(esp (- (int-length x) 1)))
(if (string=? f ".")
(decimal b (substring x 1))
(+ (* (digit-weight b f 0) (expt b-len esp))
(convert b (substring x 1)))
)))
))

(define decimal
(lambda (b x)
(if (= (string-length x) 0)
0
(let ((l (substring x (- (string-length x) 1)))
(b-len (string-length b))
(esp (string-length x)))
(+ (* (digit-weight b l 0) (expt b-len (- esp)))
(decimal b (substring x 0 (- (string-length x) 1))))
))
))

(define int-length
(lambda (x)
(if (= (string-length x) 0)
0
(let ((f (string-ref x 0)))
(if (char=? f #\.)
0
(+ 1 (int-length (substring x 1)))
)))
))

(define digit-weight
(lambda (b x c)
(if (= (string-length b) 1)
c
(if (string=? x (substring b 0 1))
c
(digit-weight (substring b 1) x (+ c 1))
))
))
>>
>>53895587
fizzbuzz :: Int -> String
fizzbuzz 0 = []
fizzbuzz n = fizzbuzz (n - 1) ++
case (n `mod` 3, n `mod` 5) of
(0, 0) -> "FizzBuzz\n"
(0, _) -> "Fizz\n"
(_, 0) -> "Buzz\n"
(_, _) -> show n ++ "\n"

main :: IO()
main = putStr (fizzbuzz 100)
>>
>first year course at uni
>software engineering course
>literally just java 101
>get assignment
>"You should not use arrays"

Literally using switch statements instead of arrays now and it's disgusting and killing me inside. 200 lines instead of 30. They are trying to teach good OOP skills but they haven't even taught arrays yet? This is going to be so messy.
>>
>>53895623
just use it like this:
(rep->number <base> <number>)
example:
(rep->number "0123456789" "-123.8")
(rep->number "0123456789ABCDEF" "A3.C5")
>>
>>53895678
Arrays and switch statements have nothing to do with OOP. However, if you're discouraging the use of arrays as a lookup table, they should not be teaching programming.
>>
File: wallpaper.png (736 KB, 1920x1080) Image search: [Google]
wallpaper.png
736 KB, 1920x1080
>>53895587
defmodule Fizzbuzz2 do
Enum.each 1..100,
fn(x) -> cond do
rem(x, 15) == 0 -> IO.puts "Fizzbuzz"
rem(x, 3) == 0 -> IO.puts "Fizz"
rem(x, 5) == 0 -> IO.puts "Buzz"
true -> IO.puts "#{x}"
end
end
end
>>
File: jpg.png (33 KB, 1234x85) Image search: [Google]
jpg.png
33 KB, 1234x85
>>53895685
It's kind of a general java course. It starts from the very start, but I have to use like 20 switch statements just because I can't use an array for 3 objects. I don't even know if they've taught arrays because I don't go to the lectures, but they I don't see why they would explicitly say not to use them either way. It's really annoying
>>
>>53890759
I hope there are more posts like this in the future. Daily Programming Challenge is a good reason to come to /g/. I think we should take it a step further to Hourly Programming Challenge.
>>
File: lolwtf.png (407 KB, 3556x1929) Image search: [Google]
lolwtf.png
407 KB, 3556x1929
lol i dont even know what to make of this
>>
>>53895714
it doesn't say anything about using a switch. try using object polymorphism
>>
>>53895737
we need our own board god dammit
>>
>>53895752
Where'd you find this
>>
>>53895752
it's from a profiler and it's telling you how much CPU time each function is using isn't it
>>
File: Capture.png (18 KB, 385x613) Image search: [Google]
Capture.png
18 KB, 385x613
>we should outsource, it's really cheap
What are strings? We should just store our shit in textbox text fields.
Extra lines make us productive.
>>
>>53895768

see

>>53895770

I understand that. Just not sure what I want to do with this information. Kinda lame that 99% of the cpu time is spent on stuff I have limited control over. Cool to look at though.
>>
>>53892841
>>53895230
But what about Alpha?
>>
>>53895714
what country? our shit school uses blackboard too
though 6 months in and were already doing OOP
still a shit school tho
>>
File: jpg.png (13 KB, 501x430) Image search: [Google]
jpg.png
13 KB, 501x430
>>53895844
I'm in Australia. I'm only 6 weeks in and it looks like they've just covered classes and methods. Also looks like they're doing arrays just after this assignment. It's really dumb, I'm gonna go ask the lecturer or something when break is over
>>
>>53895844
A lot of schools use blackboard, even big ones. It's maintainers are retarded but it can be useful at times.
>>
>>53895836
alpha is far from vax, it's a classical RISC ISA.
>>
File: tumblr_o0g3tqIbrU1tqzrm7o1_1280.jpg (279 KB, 1272x544) Image search: [Google]
tumblr_o0g3tqIbrU1tqzrm7o1_1280.jpg
279 KB, 1272x544
>>53895919
>risc
>good
lel
>>
>>53895935
>cisc
>better than risc
>>
>>53895865
what exactly is the assignment? you might be doing it wrong
>>
>>53895974
Essentially they want 3 classes
>one to handle interface (so basically terminal input and output)
>a product class which just holds information about a product
>a store class, which contains 3 product objects and this class does calculations on the products
Need to be able to add products, remove them and edit them and stuff through the interface class. They want getters and setters for everything too
>>
Real talk, if I presented this FizzBuzz solution to an interview, would it be okay? I assume it's just a task for weeding out the utterly incompetent.

main() 
{
for (int i = 1; i <= 100; i++) {
if (i % 15 == 0) {
printf("Fizzbuzz\n");
} else if (i % 3 == 0) {
printf("Fizz\n");
} else if (i % 3 == 0) {
printf("Buzz\n");
} else {
printf("%d", i);
printf("\n");
}
}
}
>>
>>53896007
Do they even do fizzbuzz in interviews anymore?
>>
File: 1450150353589.jpg (33 KB, 600x476) Image search: [Google]
1450150353589.jpg
33 KB, 600x476
>>53895230
>http://kissmanga.com/Manga/SE

tfw no qt girl to pair code with
>>
>>53896004
seems like your school is just shit then
>>
>>53896004
Also the interface class contains the main method and a store object. So I need to be able to mess with the products through the interface class using the store object I guess, which is why having all the products in an array would be easier
It's not really a difficult task, it's just they're throwing obstacles randomly which is stopping me from doing things how I want to
>>
>>53896016
yes, I failed my interview because I wasnt able to accomplish it fast enough in Go
>>
>>53896016
No idea. I'm still in uni so I've never had a job interview for a programming role. Supposedly a majority of applicants can't even implement it, which is bizarre to me.
>>
>>53896061
Fast enough? Lel how long did it take?
>>
>>53896007
>main()
Implicit int is fucking shit.
>printf("\n");
That should be a part of the last printf statement.

Otherwise, that is fine.
>>
File: 1423034303128.jpg (60 KB, 700x500) Image search: [Google]
1423034303128.jpg
60 KB, 700x500
HOW DO I GET A PROGRAMMING JOB

I SENT OUT SO MANY RESUMES ON JOB WEBSITES. CANT EVEN GET AN INTERNSHIP
>>
>>53896075
I don't think int is even implicit in c++
>>
>>53896104
The code posted was C.
>>
>>53896103
Sent out one resume, got an interview but not the internship. Kinda same boat.
>>
>>53896007

>i % 3 == 0 twice

ya dun goof'd
>>
File: 1443935252165.jpg (22 KB, 408x352) Image search: [Google]
1443935252165.jpg
22 KB, 408x352
>>53896113
I've only gotten to meet in person for an interview once or twice, and a couple other times were phone interviews. The rest are ignores or automated rejection emails. I feel like I'm on a dating website.

Guess thats what I get for living in a non-tech state.
>>
File: 1458309617415.jpg (45 KB, 447x653) Image search: [Google]
1458309617415.jpg
45 KB, 447x653
>>53896103
> mfw people literally cold call me to offer me programming jobs

git gud
>>
>>53896157
yeah I'm not sure what to do if I don't get an internship. I guess freelance or design something idk.
>>
>>53896148
Yeah, whoopsy dasies. Obviously meant to be 5.

>>53896075
Just to be clear, do you mean that I should be using 'int main' rather than just 'main'?
>>
>>53892905
WinForms is considered deprecated, although some people prefer it.

If it's just for you to work on, do what suits. If you expect other people to use and contribute, use WPF.
>>
>>53896173
You already passed college that's why
Thread replies: 255
Thread images: 43

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.