[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: 29
File: hidamari_dpt_waifu2x_traps.png (2 MB, 1618x1308) Image search: [Google]
hidamari_dpt_waifu2x_traps.png
2 MB, 1618x1308
Old thread: >>52001995

What are you working on /g/?
>>
>>52006792
C integer handling framework
>>
DuDe weeD lmao
>>
3rd for fuck animu
>>
>>52006792
anime is so dumb
>>
4chan thread downloader and parser, so that in a hundred years I can still reconstruct exactly what you faggots wrote.
With my own HTTP stack and JSON parser - fucking fast as hell.
>>
>>52006878
roflcopter
>>
>>52006828
shut up looser
>>
So can the memes finally end?
int average(int n, ...)
{
va_list args;
int avg = 0;
int odd[2] = {0, 0};

va_start(args, n);

for (int i = 0; i < n; ++i) {
int val = va_arg(args, int);
avg += val / n;
if (val % 2 != 0)
++odd[val < 0];
}

va_end(args);
return avg + (odd[0] / 2) - (odd[1] / 2);
}
>>
Thank you for not using an anime image.
>>
File: 1444159018240.png (779 KB, 1000x1000) Image search: [Google]
1444159018240.png
779 KB, 1000x1000
Friendly reminder that C is the new COBOL, universally hated by millennial webdev faggots without even knowing why.

>>52006433
>>
>>52006920
>looser
how do you have the audacity to even defend yourself? we all know that you cower from any confrontation irl. just be yourself dude
>>
>>52006942
/* 
* Average any number of ints
* without overflow, rounding towards zero
*
* Compile with: gcc -o avg avg.c -lgmp -lm
*/
#include <stdio.h>
#include <gmp.h>
#include <assert.h>
#include <stdarg.h>

int average(int count, ...)
{
va_list args;

mpz_t cnt;
mpz_t accum;
mpz_t x;

mpz_init_set_si(accum, 0);
mpz_init_set_si(cnt, count);
mpz_init(x);

va_start(args, count);

for(int i = 0; i < count; i++)
{
mpz_set_si(x, va_arg(args, int));
mpz_add(accum, accum, x);
}

va_end(args);

mpz_tdiv_q(accum, accum, cnt);
return (int) mpz_get_si(accum);
}

int main(int argc, char *argv[])
{
printf("%d\n", average(3, 1, 3, 7));

return 0;
}
>>
>>52006792
sentiment analysis of tweets about presidential candidates.
>>
Scala will make you go crazy, avoid it.
https://www.youtube.com/watch?v=4jh94gowim0
>>
File: chen.png (25 KB, 228x239) Image search: [Google]
chen.png
25 KB, 228x239
>>52006792
https://projecteuler.net/problem=17

My software sorta works, sorta doesn't.
>>
>>52007197
One of the most stupid Euler problem.
>>
>>52007131
deep learning?
>>
>>52007197
>342 (three hundred and forty-two)
>three hundred and forty-two
>and

Fucking dropped.
>>
>>52007237
Stupid burgerclap
>>
What advantages does Go have over C? It seems so ascetic.
>>
Computers are not good at solving complicated problems. Instead, they good at doing the same thing over and over again. I've been programing for 10 years and just realized this.
>>
>>52007270
So you're a moron?
>>
>>52007279
I believe so, yes.
>>
>>52007270
When they reach consciousness they will be good at everything
>>
>>52007247

342 is "Three hundred forty two", and that's final.
>>
>>52007338
Fuck of English. Long live American.
>>
>>52007230
No, I don't have any experience with neural nets, but I might eventually go that route with a professor's assistance.
>>
>>52007374

GOD BLESS, Y'ALL.
>>
>>52007381
this is a pretty short course if you're interested and on winter break

http://cs224d.stanford.edu/
>>
My friend just learned about ASCII and now he writes all his HTML/CSS/Javascript in uppercase whenever he can because he thinks it saves bandwidth to send 'A' instead of 'a' since it's a smaller number. What do I do?
>>
>>52007762
Rape him.
>>
>>52007762
show him how the numbers are encoded.

explain to him what a 64 bit integer is.
>>
Do you think that word suggestions on phone keyboards use markov chains?
>>
>>52006792
Studying for my interview with Facebook
>>
>>52007270
What is a large problem but a collection of many small problems?
>>
>>52007827
you're given an int array representing the heights of people. The person at index i can see the person at index j if there's no person in between them that's (strictly) taller than both. Given the array of heights, output an array of (# of people person i can see)

do it in O(n) time.
>>
>>52007762
Just let him continue. You cant cure autism
>>
>>52007860
Are i and j two integers passed into the function? Are they always valid or do I need to check for out of bounds? Will my array always contain at least two elements? Will i ever equal j?
>>
>>52007910
You don't understand the question. 'i' and 'j' are just referring to any two people in the array. You need to calculate how many combinations of 'i' and 'j' there are such that person at 'i' can see person at 'j'.
This is like, basic mathematical comprehension. :/
>>
>>52007338
Lol, I got this wrong the first time around never could figure it out. I was spelling Forty as Fourty, which I've done all my life. Truly the worst PE question.
>>
>>52007910
so say you've got input [2, 3, 6, 4]
you should output [2, 2, 3, 1]
>>
Do you think this update time is a little too low, /dpt/?

setInterval(function() { ThreadUpdater.update() }, 3000);
>>
>>52007990
>>52007860
this challenge extends to anyone in DPT.

it actually took me a while, but I'm a noob undergrad and didn't know about dynamic programming before a few months ago.
>>
>>52006792

Question is Eclipse Mars/Java 8 out for Linux yet?
>>
>>52007990
Wow so Ive done loads of tree problems and Ive gotten pretty good but on this Im actually pretty stumped. Thanks for the problem but I honestly dont know how to do this in N. At first I thought this was the same as the building height problem where you just push stuff to the stack from right to left so long as it's taller but that would be N^2 if I did it on this since Im trying to find all possible combinations
>>
>>52008021

is the DP solution actually O(n)?
>>
>>52008049
if you can at least get a correct solution, that's a good start.

Look up dynamic programming and try to come up with a recurrence, if you haven't heard of it.

If you haven't done any dynamic programming, try some easier DP practice problems first.
>>
Anyone here ever interviewed with Google for software engineering? If so, any tips?
>>
>>52008062
with a big K
>>
>>52008062
yes. a guy I know would ask this to interviewees at addepar.

I'll never tell the secret
>>
>>52008065
>pick up that can
>invert that binary tree
>give him the stick
>DON'T GIVE HIM THE STICK
>>
>>52008063
Ya Ive done loads of DP. Stuff like the fibonacci sequence, pascal's triangle, and the child running up stairs problem from CTCI. But this? Hm...
>>
>>52008000
I'm just gonna stop you right there and ask you what the fuck you are doing.
>>
>>52008085
I've done loads of DP too. Always leaves me sore for a few days and walking funny.
>>
>>52008068
>>52008077

Might take a crack at this later (if not actually writing some code, just formulating the recurrence relation).

But I might also just get drunk instead.
>>
>>52008000
3 seconds is a pretty long time. I usually do 300ms

Also I like setTimeout better because it's non blocking
>>
>>52008062
I don't know... You have to revisit the nodes multiple times, but you only go forward through the list once. Maybe I don't have the proper DP solution.
>>
How about this? (Not the original asker)
/*
assuming 0 is minimum height
*/
void count_seen (int* people, int* seen, int len) {
int i, j;
for (i = 0; i < len; i++)
seen[i] = 0;

for (i = 0; i < len;) {
// descend
j = i + 1;
while (j < len && people[j] < people[j - 1])
j++;

// ascend
while (j < (len - 1) && people[j + 1] > people[j])
j++;

for (i = 0; i < j; i++) {
seen[i]++;
seen[j]++;
}
}
}
>>
>>52008133
>I don't know

Usually DP solutions end up being something like O(n*k) or O(n*W) or whatever the particulars end up being for that problem.
>>
>>52008126
I thought setTimeout only runs once?
>>
>>52008172
You have it self invoke the wrapping function
>>
>>52008147

While this might work (I'm not going to test it) the real nigger of the problem is getting a solution that works in O(n). That said, trivial implementations and worse runtimes aren't always bad.

Something that works is better than jerking off about theoretical runtimes with your gay post-grad friends. Not to mention, the profiler never lies.
>>
>>52008021
Too lazy for any code, but initial thoughts:

Start at the ends, the counts for [0] and [n-1] should be easy, [0] and [n-1] can see all ascending sub-sequences which begin and end with heights < [0]'s height, if you ever hit a height greater than the end points you clamp there and discard the rest.
From there in you work your way towards the middle by accumulating counts from left and right if they are below your height ([i] can see all [i-1] sees if the height of [i] > [i-1])
>>
>>52008224
But being able to find a solution in O(n) requires critical thinking and shit, and shows that you aren't a codemonkey

>>52008227
My solution >>52008147 finds "V" shapes in the list
+     +
++ +
+++ +
+++++

And says that everyone in the V can see the person on the right and that the person on the right can see everyone in the V.
Finding the V shape is O(n) and then accumulating for each person is O(n), and O(n) + O(n) is O(n). Then you can ignore all of them and move on (more O(n))

...not out of highschool would facebook hire me
>>
>>52008289
I fucked up my diagram
+     +
|+ +|
||+ +||
|||+|||
|||||||
>>
>>52008163
Yeah, my algo is O(n), there is just a large non-deterministic K. Just need to write it up.
>>
>>52008224
There's the famous quote by that one guy that he preferred a predictable N^2 over a complex nlogn
>>
>>52008289
does it work for uneven W shapes?
>>
>>52008342
Fuck me no it doesn't
>>
>>52008289

You're descending and ascending for each person in the list, are you not?
>>
Working on a compiler.

I'm sort of stuck right now. I got it parsing fine. But how should I proceed to generate the assembly?

Should I traverse the tree, finding all classes, and flattening it out to make a list of classes that I compile? This gets rid of any directory information (ie, if a class World is sitting in the namespace Hello, and another class references World, how would I know they belong to the same namespace? What if there's another World class in the Planets namespace?)

Or should I simply just traverse the tree and compile it as is? If a class is referenced, I can just go up each level of the tree and search for it. But this is extremely inefficient. While the first option's search would be O(1), this would be O(n). For EVERY reference of a class, i'd have to traverse the tree.

Or should I mix it up? compile the tree as is, and if I find a reference, I add it to a list of found references. But again, this loses branching information.
>>
>>52008372
Just draw the rest of the fucking owl
>>
>>52008227
Yeah, this would nearly work.
>4 8 8 10 2 4 8 3 6
4 < 8
8 !< 8, so acculumate count since last flush for each element
1 1
8 !< 8, again, but don't reset flush because if the next elem is greater than 8 that number can see both
1 1
8 < 10
10 !< 2, flush
1 1 1

and so on. You'll end up with
1 3 2 6 3 3 5 2 2
which is correct if I'm handling the equals right (why would 8 be able to see 4 over another 8?)
>>
>>52008371
No, not that it matters because it doesn't work (>>52008342)

>>52008372
You're compiling every class eventually, right?
Save as much information as you can, put classes into hash tables for easy look up.
>>
>>52008407
the way I was given the problem, 8 could look over 8 and see 4, although it doesn't make too much sense intuitively.
>>
>>52006810
Can it average two of them?
>>
>>52008372
>This gets rid of any directory information (ie, if a class World is sitting in the namespace Hello, and another class references World, how would I know they belong to the same namespace? What if there's another World class in the Planets namespace?
Don't get rid of the information then.
Set the actual symbol name as "Hello.World"
>>
>>52008421
>No

It seems I misread it.
>>
>>52008457
Look at the code.
It finds the V, accumulates it and the continues on at the end of the V.
Hence "Then you can ignore all of them and move on"

I'm assuming the trick is using > O(1) space
>>
>>52008494

I did. When I first looked at the code, it looked like something that was greater than O(n).
>>
public static void printSquare(int min, int max)
{
int i = 0;
int i2 = 0;
int min2;
int min4 = min;
int min3 = min;
int length = 0;
while(min4<=max)
{
length++;
min4++;
}

while(i < length)
{
min2 = min;
while(i2<=(max-min3))
{
System.out.print(min2);
min2++;
if(min2>max)
{
min2 = min3;
}
i2++;
}
System.out.println();
i2 = 0;
min++;
i++;
}
System.out.println();
}
>>
Anybody working on anything exciting? All my big projects are kinda just sitting around right now.
>>
>>52007860
I feel like this primary issue is that arrays are of static size.

I can think of a solution that uses two O(n) operations, but it seems too simple and makes me feel like a dumbass.

You literally just use a basic linked list, as it has dynamic sizing capabilities, and append the index of each person whose height is less than or equal to i and j. Then, you just create an array with the same size as the list and append each element in the list to the respective index in the new array.

Two O(n) operations is still linear, but this has got to be too simple. I'm expecting someone here to call me a dumbass.
>>
>>52008372
NAME MANGLING
>>
>>52008672
I'm not sure I understand your solution.

you might be misunderstanding the problem

i and j are arbitrary indices from the list.

or I might just be misunderstanding your solution.
>>
>>52008672
oops, I forgot to mention that the initial sifting through the array breaks once someone taller than person i or j is found
>>
>>52006816
D mentioned
>>
>>52006792
Writing a crawler to steal steam keys.
>>
>>52008668
add more features to your homosexual image program
>>
>>52008752
just quickly whipped this up

int[] peoplePersonCanSee (int i, int j) {
create new list called "tempPeople"

for (int index = i; i <= j; index++) {
add personArray[index] to tempPeople
if ((personArray[index] > personArray[i]) || (personArray[index] > personArray[j])) {
break
}
}

int[] returnArray = new int[tempPeople size];

for (int index = 0; i < tempPeople size; index++) {
returnArray[index] = tempPeople.get(index)
}

return returnArray
}
>>
>>52009103

I might, my man. I was considering something to smooth out images that were enlarged with my other algorithm. First I'd scaled them up, then do some edge detection, and then apply median filtering to non-edge pixels.
>>
>>52009133
Do you plan to go into graphics of some sort by the way? You've been adding various features to it for a while; did you start it around the time you made that Rob Pike maymay, or even earlier?
>>
>>52009144
>You've been adding various features to it for a while; did you start it around the time you made that Rob Pike maymay, or even earlier?

That's about when I started it.

>Do you plan to go into graphics of some sort by the way?

Probably not, it's just a diversion. I don't have anything better to do.
>>
>>52009121
i and j aren't part of the input sorry.

The idea is that for an array [2, 5, 3, 2, 9], you output how many people each index can see. One index can see another index if there is no body in between the two indices who is strictly taller than both.
>>
>>52008668
I want to get started on creating an intelligent agent to play Super Smash Brothers Melee. The new dolphin build allows you to feed controller inputs through a program, so the only thing left before I can start is getting the game info. I can either train some sort of computer vision NN or something, or figure out how dolphin stores memory addresses and get them from that.
>>
Why do I keep seeing "t." everywhere?

t. concerned user
>>
>>52009202
Ids a mene you dib :DDDD

t. Ylilauta pro
>>
>cin
>cout
How do C++ fags live with themselves
>>
>>52007197
#!/usr/bin/env python3
"""Project Euler, Problem 17
Brute force solution. The function 'int2word' defined below converts integers
to their corresponding word.
"""
MAX_NUM = 1000


DIGIT_TO_WORD = { 1 : "one",
2 : "two",
3 : "three",
4 : "four",
5 : "five",
6 : "six",
7 : "seven",
8 : "eight",
9 : "nine" }

TEENS_TO_WORD = { 10 : "ten",
11 : "eleven",
12 : "twelve",
13 : "thirteen",
14 : "fourteen",
15 : "fifteen",
16 : "sixteen",
17 : "seventeen",
18 : "eighteen",
19 : "nineteen" }

TENS_TO_WORD = { 20 : "twenty",
30 : "thirty",
40 : "forty",
50 : "fifty",
60 : "sixty",
70 : "seventy",
80 : "eighty",
90 : "ninety" }

MAGNITUDE = { 3 : "thousand",
6 : "million",
9 : "billion",
12 : "trillion",
15 : "quadrillion",
18 : "quintillion",
21 : "sextillion",
24 : "septillion",
27 : "octillion",
30 : "nonillion",
33 : "decillion" }


con't...
>>
>>52009169
Ah I see, and feel you. It must be nice to have a side project that you can just add features to when you're out of ideas to work on at least. Hope something comes to you.
>>
>>52009279

def tens2word(num):
"""Return positive integer 'num' as a word, provided it is less than one
hundred.
"""
if num < 10:
return DIGIT_TO_WORD[num]
elif num < 20:
return TEENS_TO_WORD[num]
elif num < 100:
if num % 10 == 0:
return TENS_TO_WORD[(num // 10) * 10]
else:
return TENS_TO_WORD[(num // 10) * 10] + "-" + DIGIT_TO_WORD[num % 10]

return str(num)

def hundreds2word(num):
"""Return positive integer 'num' as a word, provided it is less than a
thousand. Does *not* use "and" ie
hundreds2word(115) = one hundred fifteen
"""
if num < 100:
return tens2word(num)

elif num % 100 == 0:
return DIGIT_TO_WORD[num // 100] + " hundred"

else:
return DIGIT_TO_WORD[num // 100] + " hundred " + tens2word(num % 100)

def int2word(num):
"""Return integer 'num' as a word, provided it is greater than negative
undecillion and smaller than positive undecillion.
"""
if num < 0:
return "negative " + int2word(-num)

elif num == 0:
return "zero"

elif num < 100:
return tens2word(num)

elif num < 1000:
# cannot invoke 'hundreds2word' because there would be no "and".
if num % 100 == 0:
return DIGIT_TO_WORD[num // 100] + " hundred"
else:
return DIGIT_TO_WORD[num // 100] + " hundred and " + tens2word(num % 100)

else:
magnitude = ((len(str(num)) - 1) // 3) * 3
left_side = hundreds2word(num // 10**magnitude) + " " + MAGNITUDE[magnitude]
remainder = num % 10 ** magnitude

if remainder == 0:
return left_side
elif remainder < 100:
return left_side + " and " + tens2word(remainder)
else:
return left_side + " " + int2word(remainder)


con't...
>>
>>52009295
def main():
"""Print the number of letters, no including spaces in hyphens, of all
numbers from one to 'MAX_NUM' written out.
"""
letters = 0
for i in range(1, MAX_NUM + 1):
word = int2word(i)
clean_word = word.replace(" ", "").replace("-","")
letters += len(clean_word)

print(letters)


if __name__ == "__main__":
main()
>>
>>52009263
just use printf and fgets
>>
I'm a CS major on my break and don't feel like a worthy programmer. I've been doing C++ and want to learn C, someone give me a project.
>>
>>52009358
implement a simple stack using linked lists
>>
>>52009358
An OS
>>
>>52009365
I've been triggered
>>
>>52009358
Can you average two ints in C?
>>
>>52009358
fast fourier transform
>>
>>52009358
Do a Ludum Dare challenge.
https://en.wikipedia.org/wiki/Ludum_Dare
>>
>>52009173
oh shit, so it's supposed to be the number of people each person in the array can see in-between every other person? Ah, okay, so that is dynamic programming
>>
File: boxcutter.webm (225 KB, 666x452) Image search: [Google]
boxcutter.webm
225 KB, 666x452
Just finished a basic proof of concept of my openbox rice generator~
>>
>>52009438
Nice. Shame such a clean wm uses xml and other deprecated means of configuration; appreciate you making an effort to ease it, though.
>>
>>52009294

It's entertaining.. usually.
>>
>>52009438
Looks good. Would like to see a demo Anon!
>>
>>52009438
what shell or bash extension is that that lets you tab through the autocomplete candidates like that?
>>
>>52009607
I'm using zsh. It's one of the configuration options I think, not sure if it's the default though.
>>52009533
>>52009464
The code is here https://github.com/nv-vn/boxcutter but it doesn't even have like 50% coverage of the config options for openbox yet and I haven't finished implementing any other features yet~ I'll probably have a menu.xml generator at some point as well as some other shit
>>
>>52009737
Didn't even realize it was you, pizza! Doing something practical, I like it!
>>
>>52007762
god that must be fun to read. My work used to do that and it was like pulling fingernails to try and get them to use camel case. Fuckers didn't give me any credit for making their lives easier ofc
>>
File: acnefix.gif (465 KB, 859x580) Image search: [Google]
acnefix.gif
465 KB, 859x580
Well, I made it so median filtering can be applied like a brush (like Photoshop would do it).

Seems to work pretty gud.
>>
Apparently a class is just an F-coalgebra. It's pretty nice that you can create a proper foundation for OOP.
>>
>>52009787
That really didn't fix her face B)
>>
I'm learning programming and I was wondering when would it be a good time to start doing my own projects for c++?
>>
>>52009809

I know, she's still white.

:^)
>>
>>52009787
That's cool. You should try seam carving next.
>>
>>52009915

That's considerably more complicated.
>>
>>52009801
Interesting. It's neat that it even manages to formalize instantiation and encapsulation.

I wish I could actually sit down and learn category theory. The only bits I know are from things that come up in functional programming or type theory and especially the implementation/formalization of data types.
>>
>>52008952
I have a stream of posts now. Just need to look for keys.
>>
>>52009934
>It's neat that it even manages to formalize instantiation and encapsulation.
Forget I said that.
>>
>>52009983
post code
>>
>>52009263
Use iostreams for line-by-line input and run sscanf with grep-like input sets over each line.
>>
>>52007860
So what's the O(n) solution? No one has been able to figure it out. It's been 4 hours.
>>
>>52010400
>No one has been able to figure it out. It's been 4 hours.

Has anyone been trying? I thought it just sort of petered out.
>>
File: swift.webm (1 MB, 800x713) Image search: [Google]
swift.webm
1 MB, 800x713
Exponents working! next: Square roots.

any advice?
>>
>>52010405
Well I have. I'm probably just looking too hard. I came up with some things but they weren't very good. DP doesn't come very natural to me.
>>
>>52009983
Fixed spacing in newlines and increased delay between updates to 10 seconds. Now it's more stable and posts don't get repeated.
>>52010049
I'll post it later.
>>
Damn, I found a great NSFW image which demonstrates my edge-preserving softening algo, but I can't post lewds on here.
>>
>>52010670
Are you getting drunk yet
>>
>>52010574
just a quick overview, then. Language, general strategy...most importantly, what's that nifty logging you've got going?
>>
>>52010683

I mean.. I'm drinking right now.
>>
>>52010684
I'm using ruby. Using built in logging. I'm using the 4chan JSON API. I first get a list of threads for the board and store all the threads and the time they were last updated. Then I wait (10 seconds for now) then I get the list of threads again and see which ones have been updating by seeing the time they were last updated again. From there I load the threads that were updated and get the posts that happen after the previously stored last update time. For now I'm just logging the new threads, but I'll later work on scraping for keys. And probably use autohotkey to input the keys.
>>
>>52010765
crawler.rb
version = '0.1.2015.12.22'
require 'logger'
require 'open-uri'
require 'json'
require 'loofah'
require 'htmlentities'
require_relative 'util'

Logging.log.info "Steam key crawler version #{version}"

# Get list of boards from commandline arguments
boards = {}
ARGV.map{ |arg| arg.tr('/', '') }.uniq.sort.each do |board|
boards[board] = {}
end

Logging.log.info "Listening on the board#{pluralize(boards.plural?)} #{boards.keys.map{|b| boardStr(b)}.join(', ')}."

boards.each_key do |board|
boards[board] = getThreads(board)
end

loop do
# Rate limiting. API suggests waiting one second between calls
sleep 10

begin
boards.each_key do |board|
threads = getThreads(board)
threads.each do |thread, info|
if(updated?(info, boards[board]))
parsePosts board, thread, boards[board]
end
end
boards[board] = threads
end

rescue SystemCallError
Logging.log.error $!
end
end
>>
>>52010670
better not be a pimply ass
>>
>>52010779
util.rb
class Logging
def self.log
if @logger.nil?
@logger = Logger.new STDOUT
@logger.level = Logger::INFO
@logger.datetime_format = '%Y-%m-%d %H:%M:%S '
end
@logger
end
end

$coder = HTMLEntities.new

def boardStr(board)
"/#{board}/"
end

def pluralize(plural)
plural ? 's' : ''
end

class Hash
def solo?
self.length == 1
end

def plural?
not self.solo?
end
end

def getThreads(board)
threads = {}
Logging.log.debug "GET http://a.4cdn.org/#{board}/threads.json"
JSON.parse(open("http://a.4cdn.org/#{board}/threads.json").read).each do |page|
page['threads'].each do |thread|
threads[thread['no']] = {last_modified: thread['last_modified'], no: thread['no']}
end
end
threads
end

def updated?(thread, oldThreads)
if(oldThreads[thread[:no]])
thread[:last_modified] != oldThreads[thread[:no]][:last_modified]
end
end

def getThread(board, threadNumber)
thread = {}
Logging.log.debug "GET http://a.4cdn.org/#{board}/thread/#{threadNumber}.json"
JSON.parse(open("http://a.4cdn.org/#{board}/thread/#{threadNumber}.json").read)["posts"].each do |post|
thread[post["no"]] = {no: post['no'], name: post['name'], time: post['time'],
comment: post['com'] || ''}
end
thread
end

def parsePosts(board, thread, threads)
if(threads[thread])
last_modified = threads[thread][:last_modified]
getThread(board, thread).each_value do |post|
if(post[:time] > last_modified)
parsePost post
end
end
else
# Thread is new. Parse all posts
getThread(board, thread).each_value do |post|
parsePost post
end
end
end

def parsePost(post)
Logging.log.info $coder.decode(Loofah.fragment(post[:comment].gsub(/<br\s*[\/]?>/, " ")).to_text)
end
>>
>>52010786

Naw, it's a white woman.
>>
making a list of elements that border (j,k) in a 2d array
boundary cases included
any better way of doing this?
for (int dx = (j > 0 ? -1 : 0); dx <= (j < arraySizeX ? 1 : 0); dx++)
{
for (int dy = (k > 0 ? -1 : 0); dy <= (k < arraySizeY ? 1 : 0); dy++)
{
if (dx != 0 || dy != 0)
{
neighbors.add(array[j+dx][k+dy]);
}
}
}
>>
>>52010819
ew
>>
>>52010824
>16 spaces of indent
>even indenting after the for header and before the bracket
>>any better way of doing this?
i think so
>>
>>52010830

I know, but it does show the edge preservation vs. 100% median filter.

I also made it a little more particular by posterizing the output of the edge detection convolution. Removes a lot of noise, and only serious edges are left over after that process.
>>
>>52010844
it fucked up when i copied it in from my IDE
>>
>>52010866
>IDE
>>
>>52010872
android; i'd use emacs if i could.
>>
File: lewd.png (115 KB, 719x820) Image search: [Google]
lewd.png
115 KB, 719x820
#lewd
>>
>>52010906
Post some hot blacks
>>
>>52010975
i think you mean asians
>>
File: we must go wider.webm (2 MB, 1920x1080) Image search: [Google]
we must go wider.webm
2 MB, 1920x1080
>>
>>52010975

I'm good. I'm not trying to get banned again.
>>
File: 1449029351774.jpg (65 KB, 768x1024) Image search: [Google]
1449029351774.jpg
65 KB, 768x1024
>>52010999
>He doesn't know how to ban evade
>>
>>52011014
He'd have to take off his tripcode, the horror.
>>
File: mayday.webm (2 MB, 718x404) Image search: [Google]
mayday.webm
2 MB, 718x404
Ask your beloved programming literate anything
>>
Hmm, maybe this would work better if I actually did what I was supposed to do: convert to greyscale and then create a composite of two directional sobel operators.

oops.
>>
>>52011014
left looks like yui hatano
>>
File: Screenshot_2015-09-10-15-39-18.png (88 KB, 1080x1920) Image search: [Google]
Screenshot_2015-09-10-15-39-18.png
88 KB, 1080x1920
>>
runOnTick() lightCreate(1) lightPos(owner)) lightParent(owner)) lightColor(vec:(0,0,0))
>>
File: lewd round tude.png (128 KB, 707x817) Image search: [Google]
lewd round tude.png
128 KB, 707x817
Now that's what I call an edge map.
>>
Where do you acquire advanced programming knowledge? I'm almost finished with college and if i had to create a compiler i wouldn't even know where to start. I even work at IT, but i don't feel like i know any advanced techniques.
>>
>>52011353
>I'm almost finished with college and if i had to create a compiler i wouldn't even know where to start.

dragon book, dawg
>>
>>52011359
What is that?
>>
>>52011372
Just google it breh
>>
>>52011359
>dragon book
It's not about specifically creating a compiler, just the general level of knowledge that allows me to design one if i wanted to, ya dig?
>>
>>52011353
Read books. Read source code of compilers.
Books: Modern Compiler Implementation in ML, Advanced Compiler Design and Implementation
>Dragon book
ignore that btw
>>
>>52011395
Learn by doing ya fukin dork
>>
>>52011395
So you want to learn how to write a compiler without reading about how to write a compiler and without trying to write a couple yourself?
>>
>>52011422
Yeah, i was being silly, sorry.
>>
>>52011405
>ignore that btw

fuck you
>>
reminder that type checking is based
>>
>>52011460
It becomes even more based when type checking is static verification.
>>
>>52011405
don't forget Essentials of Programming Languages
>>
>>52011460
This
>>
lisp seems like the best family of languages to be used for AI - and the most popular for the field.
If I want to get into this field, which lisp should I learn first? One with an extensive collection of libraries would probably be best, right?
I know CL and Clojure are the two big ones, probably Racket too, but I'm not sure where to start.
I know SICP is the meme book to read to learn lisp and about programming in general; I should be able to follow it after learning the syntax of my preferred lisp, right?
>>
>>52011472
mozzarella, pepperoni, etc
>>
File: 63463463.png (197 KB, 610x349) Image search: [Google]
63463463.png
197 KB, 610x349
I have a question on making a UI.

I've heard that to most effectively modify and handle things in a frame, you make like a creator class, a modifier class and retriever class or something. 3 classes that perform different functions on the frame.

Is there a book or some reference for this way of doing things?

I currently have everything to do with UI in the 1 class. Constructor, listeners etc.
>>
>>52011523
fuck off mate everyone knows cheese is the best
>>
>>52011627
mozzarella is cheese you dip
>>
>>52011492
Each Lisp kind of has its own style that it's best suited for. You can get away with CL or Clojure for SICP, but at the end of the day it's a Scheme book and you'll probably get the most out of it using a Scheme. That said, if you personally like a different Lisp more then go with that because that's what you'll end up using in real life. And just because it's slightly more awkward to write translate some Scheme to CL or Clojure doesn't mean that you're "doing it wrong".
>>

int a
int b

if a = b;

>>
>>52011712
anonymous' paradox XDDDDD
>>
I'm writing a server for multiplayer and I was wondering what is the best way to strore users.
Right now I'm just using an array which stores at most 10 users and it works just fine until someone disconencts. Then I need to remove their data from the array and set that "slot" in the array to NULL. These NULL gaps force me to loop the entire array to reach all users.
Other solution would be to use memmove but I don't think that's very efficient.

So the question is, is it okay to use linked lists for small datasets like this?
>>
File: 1439451572911.jpg (93 KB, 612x720) Image search: [Google]
1439451572911.jpg
93 KB, 612x720
>>52011732
op wanted to know what i was working on
>>
why can't they just write a native python compiler so that it's fast
>>
>>52011741
>10 elements
nah bro dont worry, do whatever makes the most sense to. there will be a bottleneck somewhere else - worry about that first
>>
Hi /dpt/

Why is GUI programming such shit?
>>
>>52011851
it's the only time I have no problem with drag-and-drop
>>
>>52011825
Okay, thanks anon
>>
Trying to think of new ideas for projects. I've tried to contribute to open source work but they all seem like they're over my head or fix problems for software I'll most likely never use.
>>
>>52011983
Same boat. Can't come up with anything. So, I was trying to fix a bug in i3 that seemed simple enough but had trouble and gave up after a couple hours. Decided just to read a book instead; if you're not doing, might as well be learning.
>>
Any good books or other documentation for C# that is meant to be for beginners? I have 0 experience with c#, and very limited experience with c/c++
>>
>>52012024
Check out books from O'Reilly Media.
>>
>>52011813
such compilers already exist afaik

but python doesn't map cleanly to machine code so it's going to slower than say a well-written C++ program
>>
>>52012024
Troelsen, C# and .net 4.5
>>
>>52011983
I think for now I may as well get some practice in and try implementing thread safe data structures. The biggest difference is that if i'm doing anything with a top and pop function I need to combine that into one option since if I try to implement top and pop as function i'm setting myself up for race conditions.
>>
>>52012077
>Python doesn't map cleanly to machine code
What? It's literally C++ with babby syntax and dynamic typing. Maybe it's the latter that causes problems.
>>
>>52006792
An automated twitter trolling bot.
It spews half coherent tweets at random people.

It will use Machine Learning and Markov Chains like this one: http://kingjamesprogramming.tumblr.com/
but it will spew shit directly at randos on twitter
>>
File: milibot.png (1 MB, 1920x1080) Image search: [Google]
milibot.png
1 MB, 1920x1080
>>52011759
>back when people actually cared about CPUs
I searched for a reaction image for about 5 minutes but I couldn't find one so here's a vaguely /g/ image I think
>>
File: ji.jpg (87 KB, 736x748) Image search: [Google]
ji.jpg
87 KB, 736x748
>>52012169
>tfw golden age brit/pol/ is gone and never coming back
>>
File: omg.jpg (149 KB, 1386x1600) Image search: [Google]
omg.jpg
149 KB, 1386x1600
>>52012169
this is always /g/ aporoved
>>
>>52012121
dynamic typing, dicts for everything, cookie cutter library calls (which are often O > 1 without the user realizing) etc
>>
>>52009279
dangerously close to csgrad.png territory here
>>
>>52008668
I'm using scikit to predict NFL games desu
>>
I really want to get into machine learning but I hate python. Would it be stupid to write some program in C? Any tips to do so?
>>
>>52012435
are people really believing their own memes so much that they'd want to do machine learning in C instead of python?
are you a masochist or perhaps just ignorant?
>>
>>52012402
I like that idea.

>>52012435
Don't. Python is the way to go with ML. You are basically asking to do web development in Java... it works, but it's a lot fucking harder and niche in practicality. Just use a fucking library if you are going to stick to C.
>>
>>52012462
I fucking hate python. I hate it so much I'm willing to reinvent the wheel in C.

>>52012463
The only libraries I see are in C++, never C.
>>
File: aima.jpg (27 KB, 260x325) Image search: [Google]
aima.jpg
27 KB, 260x325
Chapter fucking 2 and this guy wants me to write software for a virtual Roomba.
Tomorrow.
Jesus christ, I thought I might be able to finish the exercises tonight, but no, I have to write a fucking Roomba. Maybe I'll get all graphical with it using SDL or some shit.

Night /dpt/.
>>
>>52012485
Learn R if you hate Python so much. Dunno why you'd hate Python considering the godly libraries it has, though
>>
>>52012485
>I hate it so much I'm willing to reinvent the wheel in C.
so you are ignorant? why do you hate it so much, anon?
>>
>>52012485
>I hate python so much that I hate myself enough to waste weeks
nice
It's only repremandable to use Python if it's your first language.
>>
>>52012503
It has shit syntax, reinvents pointless things for no reason while trying to be other, better languages. It's slow. Any of the interesting work is done so most of the time youre just putting puzzle pieces together. Trying to read code written in python is horrible because it's so lazy in it's syntax but strict in others worthless areas. Any significant python codebase will be a clusterfuck unless some incredibly strict care is given to documentation and code quality which is rare for any company/group.

>>52012514
I would rather waste my time than write in python and by the time I finish my code maybe the python script will be done executing.
>>
>>52012555
>Any of the interesting work is done so most of the time youre just putting puzzle pieces together.
Let's be real here, you wouldn't exactly be doing anything new and fresh by implementing ML libraries in C, though you will definitely learn more. I mean, residual sum of squares algorithms aren't exactly new inventions.

Half of the time, combining those "puzzle pieces" into something new is interesting in and of itself, even if it is glorified pipefitting.
>>
>>52012588
>you will definitely learn more
That's basically what it comes down to for me. I know it's reinventing the wheel and pointless work but sometimes it's worth it.

Guess I'll just kill myself.
>>
>>52012555
>It has shit syntax,
oh boy what other criticism would one have expected
>reinvents pointless things
such as?
>It's slow
one of the few valid complaints, although mostly irrelevant for what you are trying to do
>so most of the time youre just putting puzzle pieces together
"abstraction is bad"
>because it's so lazy in it's syntax but strict in others worthless areas
i don't see how this harms readability
are you criticizing the facts that it's dynamically but strongly typed? would you prefer a weakly typed language like C, JS or PHP?
>Any significant python codebase will be a clusterfuck
python code is arguably harder to refactor thanks to dynamic typing, but that doesn't mean it will be a clusterfuck

most of your claims are baseless (syntax, reinventing things, putting puzzle pieces together, lazy in its syntax, python codebases will be a clusterfuck)
python certainly isn't a good language for maintaining large code bases, just like any dynamically typed language (this isn't related to readability, but correctness), but if the support for whatever you are trying to do is so good that you also need to write a lot less code than in other languages, then using that language is worth it
>>
>>52012621
"machine learning" isn't much more than a stupid meme anyway
>>
What is our definitive coding challenge website?
>>
>>52012660
https://www.codingame.com/clashofcode
>>
>>52012660
>coding challenge website
the definitive way to get challenges here is from clients senpai
>>
>>52012699
Take it easy Pajeet
>>
>>52012660
https://www.reddit.com/r/dailyprogrammer
>>
>>52012622
>oh boy what other criticism would one have expected
So it's clearly valid if you've heard it so much.

>such as?
I'll secede on this because I can't remember what it was exactly. Something about lists or control flow?

>one of the few valid complaints, although mostly irrelevant for what you are trying to do
ML is computationally intensive so no it's not irrelevant.

>"abstraction is bad"
Abstraction? No not necessarily, but non stop use of libraries? Yes.

>would you prefer a weakly typed language like C
Literally what I said before. Also the fact that variables have no tell as to when they are created versus altered.

Remember this isn't "python is bad" this is "I hate python so much I'm considering rewriting everything in C".

Like I said above, suicide seems like my only option at this point
>>
>>52012660
I like HackerRank. Don Mills online judge is also really good but a lot of there solutions have hard runtime limits so you really gotta know your algorithms and have a good understanding of a mid-level language like C/C++
>>
>>52012693
>have to make an account
D R O P P E D
R
O
etc.
>>
>>52012660
Waiting for kids to post their homework
>>
>>52012724
their*

holy shit time to end it senpaitachi
>>
>>52012727
of course, there stats, ranks, * friends, contests, job offers, ...

add me: https://www.codingame.com/profile/214c77abf50683d2d450063b06e9939f0255311
>>
How do I become a /g/ computer scientist
>>
>>52012902
read SICP and achieve satori
>>
>>52012902
Write a program in C to average two ints
>>
https://www.youtube.com/watch?v=i2fhNVQPb5I
>>
>>52013010
See >>52006942
The ebin maymay is over, mate.
>>
>>52013067
That took much longer than it should have
>>
Why round away from zero?
>>
>>52013052
average_dpt_polster.flv
>>
>>52006942
>>52013067
>>52013079
It's wrong though.
average(3, 0, 999, 999999)

falsely yields 333667

(0+999+999999)/3 is exactly 333666

/g/ still can't average ints
>>
>Rust
>compiler is not ancient, has useful error messages (ehhm ehhm gcc)
>cross platform, user friendly networking in standard library (fuck boost)
>not a hack on top of some other language (hi, Qt)
>has really useful functional features (match, algebraic data types)
>compiled
>not dead
>overrun by ruby hipsters and SJWs
>now Mozilla is killing itself, making me lose all hope
God damn it you were the choosen one.

What new meme language can I use now?
>>
>>52013133
Isn't it open source?
Just fork it.
>>
This is the only correct solution for N ints thus far:
>>52007058
>>
>>52013133
>>52013133
Get a Xeon and code exclusively in Erlang
>>
>>52013010

>>51999764
>>
Writing Go binding for Aubio.
>>
>All my knowledge is C/C++/x86 asm
>All jobs are C#/Python/Ruby/High level garbage
>>
>>52013272
>I'm so leet
>All jobs are C#/Python/Ruby/High level garbage
http://careers.stackoverflow.com/jobs/tag/c++
>>
>>52013272
you should stress that you have practical programming experience and that learning a new language is something you can do with ease.

place an emphasis on the problems you solved rather than the tools which you used to accomplish that.
>>
>>52013340
And before you know it, you're a full stack webdeveloper.
>>
>>52013356
I hope so, anon-kun. I really do ;~;
>>
is unit testing a meme xor should I do it
>>
>>52013380
According to reputable /g/ computer scientists, unit testing is webshitter tier. Any respectable /g/ computer scientists formally proves their code correct.
Thread replies: 255
Thread images: 29

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.