[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
>go to job interview >"alright, for this next part,
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: 35
File: WAAAAAAAAAAH.jpg (297 KB, 1280x720) Image search: [Google]
WAAAAAAAAAAH.jpg
297 KB, 1280x720
>go to job interview
>"alright, for this next part, i want you to go up to the whiteboard, and write a function that returns an array of cartesian coordinate points that plot a circle"
>"you can use any language you like, but you only have 10 minutes"
>my face internally

needless to say, i didn't get the job
>>
File: 1439689650563.jpg (363 KB, 1280x720) Image search: [Google]
1439689650563.jpg
363 KB, 1280x720
>>53893686
Did you write any of it?
>>
File: 1336867899114.jpg (179 KB, 589x564) Image search: [Google]
1336867899114.jpg
179 KB, 589x564
>>53893686
>>
Did they state what the input would be?
>>
>>53893686
Assuming it was a programming job, if you couldn't solve this exercise, you don't belong in that job and the decision was entirely just.
>>
>>53893686
from math import sin, cos, pi

steps = 1000
print [(cos(a), sin(a)) for a in [2 * pi * s / steps for s in range(0, steps)]]

took like 1 minute
>>
>>53893700
>>53893708
>>53893786
>>53893813
This is just a reposting of >>53817856
>>
what's
0 <= a < 2π
x, y = cos(a), sin(a)
>>
I work as a software engineer and I don't know what those words mean
>>
>>53893813
nuh uh REAL programming is spending 2 hours googling, reading stackoverflow, and skimming unofficial documentation (official documentation is hard and not the first result on google, and has weird brackets and colons everywhere wtf does that shit mean)

t. webdev
>>
>>53893686
Jesus christ this is so easy. Since they didn't specify how fast your program has to be, couldn't you write some retarded shit like this? [pseudocode]

let increment = 0.001
let x = -1
let points = []
while x < 1, x += increment {
let y = -1
while y < 1, y += increment {
if x * x + y * y = 1 then add (x, y) to points
}
}
points now contains the points that graph a circle.
>>
>>53893686
i remember you

typedef struct {
float x;
float y;
} point_t;

typedef struct {
point_t *arr;
unsigned size;
} plot_t;

plot_t *plot_circle(float radius, float resolution)
{
plot_t *out = (plot_t *) malloc(sizeof(plot_t));
out->size = 0;

float angle;
for (angle = 0.0; angle <= (2.0 * M_PI); angle += (M_PI / resolution))
out->size++;
out->arr = (point_t *) malloc(sizeof(point_t) * out->size);
unsigned index = 0;
for (angle = 0.0; angle <= (2.0 * M_PI); angle += (M_PI / resolution))
{
out->arr[index].x = sin(angle) * radius;
out->arr[index].y = cos(angle) * radius;
index++;
}
return out;
}


can i have job now?
>>
real talk: You can skip geometry class and still be able to program if you're not working in graphics or physics simulations.
>>
>>53893686
you had more than 10 minutes don't be a liar anon.
>>
>>53893686
public class Point
{
public float x;
public float y;
}

public List<Point> MapCircle(Point origin, float radius, int precision = 100)
{
List<Point> points = new List<Point>();
for(int i = 0; i < precision; i++)
{
float theta = (i/precision) * 2 * Math.PI;
points.Add(new Point() { origin.x + (radius * Math.Cos(theta)), origin.y + (radius * Math.Sin(theta)) })
}

return points;
}

I did this in 4 minutes. No idea if it's correct/works
>>
File: not_bad.png (46 KB, 1365x545) Image search: [Google]
not_bad.png
46 KB, 1365x545
>>53893938
pretty close I was just missing casts
>>
y+=(x-=y*p)*p;
>>
File: Shaggers.png (51 KB, 261x162) Image search: [Google]
Shaggers.png
51 KB, 261x162
>>53893686
>Know what this guys asking for from my 3D printing hobby and could shit out something like that in gcode.

Have no clue how to program it though.
>>
>>53893938
>>53894075
Interesting, so this would take less than 10 mins for you guys on a whiteboard.
>>
File: 1433514083507.png (57 KB, 708x480) Image search: [Google]
1433514083507.png
57 KB, 708x480
t=0:0.1:2*pi;
x=cos(t);
y=sin(t);
plot(x,y)
>first 'language' learnt was matlab
>mfw trying to learn literally any other language
>>
>>53894169
I don't know if I'd be able to write fast enough to be honest, but conceptually it's a pretty easy problem.

It really just comes down to whether or not you know how to convert from polar to cartesian coordinates.
>>
>>53894213
I know I am slow on the coding part, but if I were asked to do some math problems of it on paper or whiteboard would done it instantly, but I often space out when I get these questions, I guess I need more practice.
>>
>>53894199
he asked to return the points to an array, not plot the points
>>
>>53893875
like you can plop this entire shit in a job interview with a 10 minute limit
>>
>>53894242
i literally wrote it in 4 minutes
>>
>>53893686
Could anyone explain step by step how to tackle this thing?
>>
>>53894285
Nvm, I think I am getting it now.
>>
>>53893686
should have wrote "a function that returns an array of cartesian coordinate points that plot a circle"

in english.

they were looking for folks who can think on their feet outside the box
>>
>>53893686
That isn't even hard. They weren't looking for something that compiles they just wanted to evaluate your problem solving skills i.e. how you break down the problem into steps, identifying inputs, outputs and logic
>>
>>53893869
you're halfway there, just need to add a ton of npm packages that do everything for you
>>
File: 12936487.jpg (57 KB, 832x690) Image search: [Google]
12936487.jpg
57 KB, 832x690
>>53893686
What the fuck?
There will be countless points.
int r = 5 //arbitrary radius; feed into the function
float circlePoints[];
int x = -r;
while (x<=r)
{
double y1 = + sqrt(pow(r,2) - pow(x,2));
double y2 = - y1;
//circlePoints.append (x,y1) and (x,y2)
}


I don't really program, so I forgot everything; but this should be easy?
>>
>>53893686
the problem i give junior devs is to find the middle of a hash table without looping twice or flatten/build a sorted tree without recursion.
>>
>>53894374
This is one of the rarest pepes I ever saw. Saved that!
>>
I really want to improve myself with such problems, some say it's easy some just meme around(maybe having trouble) but I want to learn and understand. So where can I find same problems and improve myself?
>>
function P = Circle(x0,y0,r,N)
T = linspace(0,2*pi,N)';
P = [x0 + r*cos(T), y0 + r*sin(T)];
end
>>
>>53893686
>redditor
>umaru cancer
and you wonder why you didn't get the job. seek asylum on reddit you cancerous shit.
>>
>>53893875
float angle;
for (angle = 0.0; angle <= (2.0 * M_PI); angle += (M_PI / resolution))
out->size++;


out -> size = 2 * resolution;
>>
>>53893686
x = x0 + R*cos(t)
y = y0 + R*sin(t)
for t from 0 to 2*pi

OR

x = x0 ± R*cos(t)
y = y0 ± R*sin(t)
for t from 0 to pi/2 (4 times less work)

Now, the thing is to determine the optimal step so as to not do unnecessary work. But this shit is too complicated for 10 minutes so it doesn't matter.
>>
>>53894630
What should t be incremented by?
>>
>>53893686
>modern programmers
I think you need to go back to school and learn some basic fucking math.
>>
>>53894374
Ah disregard the y2
I just realised my algorithm doesn't need defining negative y's
>>
>>53893871
This is retarded in more ways than one. First, the fact that they did not explicitly require efficiency doesn't mean you can just shit some absolutely unrealistic code that is quadratically slower than even the most simple alternatives. Second, it would produce points in messed up order (you couldn't plot a circle with them). Third, your solution wouldn't even work at all. More or less the only points this would produce are (-1, 0), (0, 1), (0, -1), (1, 0).

Fuck, I only now realised that you are baiting. Fuck me.
>>
Isn't a circle defined as x2+y2=r2? For a circle who's centre is (0,0)
That shouldn't be hard to do I think
Gonna try in a couple of minutes
>>
File: qwe.png (3 KB, 348x282) Image search: [Google]
qwe.png
3 KB, 348x282
>>53894788
You made me remember stuff I learned years ago and thought to have completely forgotten.
All the measurements are in pixels to make calculations easier.

Let θ be our change of angle. Picrelated is the first step of our algorithm.
sin(θ) = Δz/R, as shown in the picture.
Basically, we want Δz to be 1. That is, to get exactly to the pixel above us. If we make Δz any smaller, we will land on the same pixel next step, which is an unnecesarry work for our computer.
A careful reader will notice that this step has biggest change in ordinate of the point, so a result that satisifies this step will suffice for all the others.
θ ≈ Δz/R, because θ is small enough.
θ ≈ 1/R
Therefore, θ should be incremented by 1/R.
One may see that this can be applied to basically any curve with a curvature of R.

And yet this shit is really slow and just use https://en.wikipedia.org/wiki/Midpoint_circle_algorithm if you want any efficiency. But I don't think people in the interview wanted an optimal step or a goddamn Bresenham for a circle.
>>
File: 1444551454395.gif (2 MB, 480x270) Image search: [Google]
1444551454395.gif
2 MB, 480x270
>>53893686
>programming job
>test is a math problem that has very little to do with programming
>>
>>53895130
>have a degree in cs
>without doing math
Its to weed out the shitty self learners while giving the good ones a chance
>>
>>53895130
>math problem
>little to do with programming
>>
>>53895142
>>53895143
>programming is math
Programming is logic. It may contain math, but not all programming is about math.
Also do not confuse computer science with computer engineering. Software engineers are not the same as computer scientists.
>>
>>53895142
>>53895143
The "math" average programs doesn't go beyond power functions. What on earth are you talking about?
>>
>>53895182
Exactly, and a computer scientist might not make as good a program as a software engineer, and vice versa.
>>
>>53893686

{ [1,0] , [0,1] , [-1,0] , [0,-1] }

it's still a circle, however with only 4 points plotted
>>
>>53895399
You'll get the smartass of the year award, not the job.
>>
Here's my idea in pseudocode, the webdev-way

import 2DGraphicsLib

canvas = new 2DGraphicsLib.createCanvas(100, 100)
2DGraphicsLib.drawCircle(1, 1, 1, RGB(0, 0, 0))

points = []

for pixel in canvas.pixels:
if pixel.color = RGB(0, 0, 0):
points += [(pixel.x, pixel.y)]

>>
>>53897285
>import
You didn't get the job.
>>
File: draw-a-circle.gif (17 KB, 346x311) Image search: [Google]
draw-a-circle.gif
17 KB, 346x311
>"you can use any language you like, but you only have 10 minutes"
>you can use any language you like
>not doing it in Scratch
>>
>>53893824
This isn't a function and it doesn't return the array, just prints it.
Sorry, you're not qualified.
>>
>>53893686
couldn't you just use fucking cosine between 0 2pi
>>
>>53894820
hey, i just want to make games
>>53894075
>Java
>>
>>53893869
>mfw this is literally what I did as a webdev
They hired me because of my sysadmin background lmao
>>
File: 1459465679510.png (66 KB, 200x200) Image search: [Google]
1459465679510.png
66 KB, 200x200
>>53894242
>this guy
>>
Literally an exam exercise. CompEngfag here.
>>
File: 1459116586427.png (889 KB, 756x715) Image search: [Google]
1459116586427.png
889 KB, 756x715
>>53899915
That's c# you retard.
>>
Okay, so first for the function, we'll need to know where the circle is and how big it is. We'll assume that a point is defined as a struct with just an x element and a y element:
struct point *circle_as_array(struct point center, int radius)
{

Now what we want to do is go around the circle and add a point every so often to the array. Can we assume that we've already included math.h?
>interviewer probably allows it
So, to go around the circle, we'll use a for loop:
 struct point *circle_as_array(struct point center, int radius)
{
for (int ii = 0; ii <

Uh, actually we should also take in a value for resolution, to define how precise we want our circle to be:
struct point *circle_as_array(struct point center, int radius, int resolution)
{
int ii;
for (ii = 0; ii < resolution; ++ii) {

Now, to find each point on the circle we start at 0 degrees, or does sin(), etc. take radians, I can't remember?
>interviewer probably either tells me or lets me look it up
Okay, so we start at 0 radians and go around the circle until we reach 2pi radians, uh, but first we need a return array, obviously:
struct point *circle_as_array(struct point center, int radius, int resolution)
{
struct point *to_return = malloc(sizeof(struct point) * resolution);
int ii;
for (ii = 0; ii < resolution; ++ii) {

And can we also assume stdlib.h was included?
>probably
Okay, now we step around the circle:
struct point *circle_as_array(struct point center, int radius, int resolution)
{
struct point *to_return = malloc(sizeof(struct point) * resolution);
int ii;
for (ii = 0; ii < resolution; ++ii) {
to_return[ii].x = cos(PI * (ii / resolution) );
to_return[ii].y = sin(PI * (ii / resolution) );
}

return to_return;
}

And we're done. How was that?

^ how I played it out in my mind, it's more than just
>walk up to board
>maek coed
>get money
>>
>>53900197
both are so shit that i didn't notice
>>
>>53900234
Don't flatter yourself, you're just retarded.
>>
>>53894242
>sour_grapes.jpg
>>
>>53900228
1. You didn't even incorporate the radius - which should be float imo
2. ( -r * sin(theta) , r * cos(theta) )
>>
i can do that in polar as well as cartesiean as well as any arbitrary number system

: /
>>
>>53900228
Aaand of course I messed up a bit by completely disregarding the center point and radius, but in my defense I was running out of space in the post.

>>53900278
Yes, I could fix that up, but it should still show the interviewer I know my stuff decently and can be articulate about it. Everyone occasionally forgets an important part which is caught by a simple test run, though, so it shouldn't hurt too bad.
>>
>>53900288
Then do it
>>
>parametrize circle in polar coordinates
>choose amount of points
>put in array
why is this hard?
>>
File: 1348598499498.jpg (29 KB, 400x500) Image search: [Google]
1348598499498.jpg
29 KB, 400x500
>>53900228
No check for malloc return value. Segfault/10

Also, the task was to return an array. You are returning a pointer. I think it's pretty obvious C too toy a language to be used for this task.
>>
>>53900390
arrays don't exist in C
array[32] is syntactic sugar for *(array+32)
&array[32] is the same as array+32
>>
>>53893686
I'm pretty sure you can solve this with the bullshit I have to learn about complex numbers right now.

it probably involves
x = r * cos(phi)
y = r * sin(phi)
or something.

Inserting all numbers between 0 and 2π (radians) for phi might give you all cartesian coordinates of a circle with the radius r.
>>
>>53900462
Arrays do exist. Returning an array is a whole different matter.

But what matters is that you were given a task, a task to return an array in the language of your choice. You chose a language that cannot do that. Understand? No solution made in C can satisfy the requirements. You failed the task.
>>
File: 1459808660136.jpg (115 KB, 499x499) Image search: [Google]
1459808660136.jpg
115 KB, 499x499
>>53893686
>watching chinese cartoons
>/gee/ I didn't get the job
>>
>>53900580
>bullshit i have to learn about complex numbers
>polar coordinates
>bullshit
anon for fuck sake
>>
>>53893686
circle divisions xpos ypos radius = 
[ (radius * (cos i) + xpos, radius * (sin i) + ypos) | i <- (map (\x -> x/divisions * 2 * pi) [0..divisions-1]) ]


Took two minutes to write, two minutes to debug, and three minutes to plot the output manually as a quick test.
>>
>>53900600
>ok anon, please write a function that returns a string
>return a null terminated char array
>sorry anon you failed i wanted a string

:^)
>>
>>53900669
If you are given the choice over the language, maybe you shouldn't choose a language that doesn't have a string type?


[spoiler]i hope you too are saging[/spoiler]
[spoiler]no spoilers on /gee/ ;_;[/spoiler]
>>
>>53899826
A function can't output a circle
>>
File: akari eats chippus.png (131 KB, 256x256) Image search: [Google]
akari eats chippus.png
131 KB, 256x256
>>53900730
>>53900600
>>53900390
>bikeshedding
>>
>>53893871

This is actually my favorite version in the whole thread because it's the only one that doesn't rely on Sin and Cos library functions. The whole thing is self-contained. The returned matrix size actually scales with the size of the problem and doesn't rely on the user input. It can also be broken up into quadrants and then the whole solution found by symmetry. x^2 is invariant on every column so it comes outside the inner loop. y^2 can be found by an induction variable.
>>
>>53893824
Putting this in my memory banks in case I get asked this.
Thanks
>>
>>53900769
>all that whileing
>>
function getPointsAlongCircleAsArray(radius, originX, originY, steps)
points = {}
for i=1, steps do
points[i] = {}
points[i]['x'] = originX + radius * math.cos(((i-1)/steps) * (2*math.pi))
points[i]['y'] = originY + radius * math.sin(((i-1)/steps) * (2*math.pi))
end
return points
end

steps = 18 --the number of steps around the circle

pts = getPointsAlongCircleAsArray(8, 0, 0, steps) --get the array of data

for i=1, steps do
print("(" .. pts[i]['y'] .. ", " .. pts[i]['x'] .. ")") --print the array:
end


glorious lua
>>
>y = ±sqrt(-x^+r^2)
>increment x from -r to r
simplest desu
>>
File: 1348763945930.jpg (161 KB, 720x951) Image search: [Google]
1348763945930.jpg
161 KB, 720x951
>>53900754
>i post code on /g/ but don't want to accept constructive criticism

(For some values of constructive)
>>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>

std::vector< std::vector<double> >
circle (const double& radius, const std::vector<double>& center, const int& N)
{
std::vector< std::vector<double> > c = std::vector< std::vector<double> > (N, std::vector<double> (2, 0.0));
for (int i = 0; i < N; ++i)
{
c[i][0] = radius * cos(2 * double(i) * M_PI / double(N)) + center[0];
c[i][1] = radius * sin(2 * double(i) * M_PI / double(N)) + center[1];
}
return c;
}

Literally how I'd do it. But then again I'm a physicist and not a programmer or whatever.
>>
>>53900889
Why is C++ so ugly and bloated
>>
>>53900889
Dude. You know std::pair exists, right?
>>
File: 1459231257762.gif (2 MB, 400x209) Image search: [Google]
1459231257762.gif
2 MB, 400x209
>>53893869
>this is what I actually do
>>
>>53900992
Yes, but it's not appropriate here. It's doing stuff I don't need (i.e. having two different filetypes, which is useless here) and if I wanted to implement the same code in n dimensions std::pair is useless.
>>
>>53900889
did you try making it look as shit as possible.
>>
>>53901184
How about std::array? You'd save a fuckton of small allocations.

>>53901204
It's not using templates for variable arity or types and it's not even an iterator and there's no constexpr overload or traits anywhere. So I'd say there's a lot of potential to make it follow the true C++ way (tm) even more.
>>
>>53895130
> Programming job
> Don't know what a unit circle is
c'mon guys, it's basic maths
>>
>>53900654
Fail: that's a cons list, not an array.
>>
https://jsfiddle.net/vcx6gsak/1/
>>
>>53901244
>How about std::array? You'd save a fuckton of small allocations.
That sound like a good idea. Thanks.
>>
>>53901244
using const& for int/double is retarded.
the initialization for c is retarded.
>>
>>53900750
>write a function that returns an array of cartesian coordinate points that plot a circle
You're not meant to output a circle, you're meant to output an array of points that plot a circle.
>>
>>53901344
I honestly don't know -- why is it retarded?
>>
>>53901377
don't initialize it, reserve and emplace_back
>>
>>53901377
small types should be passed by value.
type x = type(args); is better written as type x{args};
also this >>53901444
>>
>>53901444
>>53901481
Thanks.

>small types should be passed by value
Why? Doesn't this unnecessarily copy the variable?
>>
for (I=0;I<=2*math.pi;I++){
print(math.cos(I));
print(",");
print(math.sin(I));
print("/n");
}

And that's the lazy inefficient way OP. If you can't do that, you really should reconsider any form of programming or anything that requires more than 7th grade algebra as a career.
>>
>>53901549
copying is cheaper for small values
>>
>>53901549
There's nothing wrong in copying small values, especially if the alternative is to copy a pointer (reference) to it.

But this is insignificant in practice. Just write whatever you like and let the compiler optimize.

>>53901655
It depends. Copying requires a copy to stack. For example, if a single value is external, and calling convention uses some SSE, the load to register is just wasted time.
>>
>>53901710
compiler can't optimize out wasteful array copying
>>
>>53894382
Lag pointer for first one, what for second?
>>
>>53901549
>>53901655
though desu the compiler takes care of that shit, but it looks dumb to anyone who knows c++ well
>>
>>53901733
Yes, of course. My comment was only in the context of small values.
>>
File: 1457966788918.png (60 KB, 592x492) Image search: [Google]
1457966788918.png
60 KB, 592x492
>>53893686
Are you me?
>>
All you really need to know to solve this problem is x = rcos@ and y = rsin@

Then get r and set @ from 0 to 360.
>>
>>53893686
I couldn't even do that optimally in an hour, fuck that shit
>>
>>53893686
>>53901944
They should have asked you to make a sphere. Same concept except with the second angle, but definitely scarier.
>>
OMG MATH
>>
>>53893869
>official documentation is hard and not the first result on google, and has weird brackets and colons everywhere wtf does that shit mean
More like official documentation is practically non-existant. Webdev, not even once.
>>
File: 1436551550961.png (884 KB, 1184x1080) Image search: [Google]
1436551550961.png
884 KB, 1184x1080
>tfw u dont know what a cartesian is
>>
>>53902905
as expected of a dumb anime poster
>>
>>53902928
Don't insult my friend thank you
>>
>>53894169
underrated post
>>
>people in CS are bad enough at math that this is anything but trivial
wat this is hs shit
>>
>>53902991
I'll just bully you instead then.
>>
>>53894199
Those aren't even Cartesian coordinates
>>
>>53900750
A vector function can though

You didn't get the job.
>>
>>53903245
..yes they are
>>
File: 1448326499811.jpg (166 KB, 1024x576) Image search: [Google]
1448326499811.jpg
166 KB, 1024x576
import math
def circle(r,x):
try:
y = math.sqrt(r**2 - x**2)
return [(x,y),(x,-y)]
except:
return [None]

def gen(r,steps):
ds = r/float(steps)
L = []
i = 0
while i <= steps:
L.extend(circle(r,i))
L.extend(circle(r,-i))
i = i + ds
return [x for x in L if x]

xy = gen(5,100)
>>
File: 1447022928829.gif (73 KB, 250x253) Image search: [Google]
1447022928829.gif
73 KB, 250x253
>>53893686
This image ought to help you.
>>
>>53903623
how does density of sample points work out? seems like the curve have an uneven distribution of points with a constant term added to the parameter variable each time
>>
>>53903707
If you want the sample points to be evenly distribution on the circle line, then you use the parametrization [r cos(t), r sin(t)] with t in [0, 2π].

If you want the sample points to be evenly distributed on the x axis then you choose the parametrization [x, √(r^2 - x^2)] with x in [-r, r].
>>
>>53893686
You shouldn't get the job if you didn't even know how to do that.

Learning a language doesn't make you a good programmer, you CS monkey.

Fucking hell, you're almost as bad as engineers, when it comes to math.
>>
>>53903103
CS students at my school can't even handle fucking linear algebra, and this is supposed to be a top ten. i'll bet even the bio students have them beat
>>
>>53903838
yes thinking of the application of say knitting a (flat) circle, and determining the amount of stitches in each row - I have problems imagining how one would use the trigonometric parametrization.

Each row more or less coincides with a point on [-r, r].
>>
>>53893869
/thread
>>
respects to those who try to learn.
shame on the rest, too busy trashtalking to realize, that here's a programmer among scripters.
>>
I failed calculus.
>>
>>53900462
I'd just like to interject for a moment.
array[32] is actually syntactic sugar for *(array + (sizeof(array[0]) * 32) )
&array[32] is the same as array + (sizeof(array[0]) * 32)
>>
>>53904586
A lot of people do.

Calculus is a Weeder Course for Computer Science Majors just like Organic Chemistry is a Weeder Course for Premed Majors

It is pretty funny how a Computer Science Degree is essentially a Math Degree, minus just a few classes.
>>
>>53902928
He didn't post anything m8.

>>53893824
Is that python? Cause it looks comfy as fuck. Definitely I have to learn a scripting language properly.
>>
>>53893686
HAHAHAHAHAHAH FUCKING DUMB WEEB POSTER BTFOOOOOOOOOOO


AHAHAHAHAHHAHAHAHAHAHAHAHAHAHHAHAHAHAHAHAHAHAHAHAHAHAH
>>
>>53904767
N-no bully pls...
>>
File: 1410785254343.png (13 KB, 500x500) Image search: [Google]
1410785254343.png
13 KB, 500x500
>>53893869
yep, that's me
>>
>>53904731
Not the guy, but that's python, yes. It's nice to do stuff like that really quickly.
import numpy as np

def circle(r, n):
return np.cos(np.linspace(0, 2 * np.pi, n)), np.sin(np.linspace(0, 2 * np.pi, n))
>>
>>53893686
>>53893865
What the fuck, you guys never learned algebra ii or pre Calc?
>>
>>53893686
function circle_array = circle_points(interval) 
if isscalar(interval)
i=0:interval:2*pi;
circle_array=[cos(i'), sin(i')];
elseif isvector(interval)
circle_array=[cos(interval(:)), sin(interval(:))];
else
error('Input must be a vector or scalar')
end
end
>>
>failing the autism test
My condolences, anon
>>
>>53904836
Slightly wrong format, should be

return zip(np.cos(np.linspace(0, 2 * np.pi, n)), np.sin(np.linspace(0, 2 * np.pi, n)))


Otherwise, very nice answer though
>>
>>53894199
almost just use a for loop
>>
>>53905662
>for loop
>matlab

son,
>>
File: circle.png (3 KB, 349x518) Image search: [Google]
circle.png
3 KB, 349x518
Am I doing it right?
>>
>>53906033
>write a function that returns an array of cartesian coordinate points that plot a circle
>>
>>53906075
>>53906085
What's wrong? That's my beautifully drawn circle with radius 21.
>>
>>53893686
[(x,y) | x <- [-10..10], y <- [-10..10], x*x + y*y < 10*10]


Took me 3 seconds to write. Not even gonna bother testing it.
>>
Damn, I wish I was smart enough for this shit. Or maybe I am and my education was just shitty. I don't even know what a Cartesian Coordinate is.
>>
>>53906122
It's a disc, anon.
>>
>>53906211
I'm an IT student and flunked hard on math. so at least you're less unfortunate than me
>>
>>53906120
not him, but you're supposed to return an array of cartesian coordinate points. those points are supposed to plot a circle.

this isn't a complicated math problem or something. it's a simple function to determine if you can articulate fairly straightforward logic that i throw your way and return the kind of value i need (and that the value is correct).

i've interviewed more people than i can remember and a handful will do this stupid "above and beyond" thing and it's annoying. i can't imagine any reason for showing off except to ingratiate yourself to the interviewer. just compliment me on my shoes or something if you're going to be this obnoxious.
>>
>>53906294
Yeah but your shoes stink.
>>
>>53906211
That's... 7th grade stuff. 9th if you use trigonometry.
>>
>>53904871
I know I didn't.

Honestly, I've never run into a situation where that level of math was required anyway. The most I ever see regularly is just basic algorithm efficiency. (Which IS important to know.)

I don't write graphics code or cryptographic functions--I just architect things to limit the complexity of a system while making sure that it performs all of the things it needs to. I keep things maintainable, and I write new pieces in ways that won't make the next guy™ pull his hair out if I decide to move.

This does not require math, just judgement and logic. I wish interviews paid more attention to that aspect, because I've seen a lot of very bad code from people who were fantastic at math.
>>
>>53906294
I can never picture a boss of a company who interviews guys daily to spend some of his time on an Azerbaijani carpet-knitting imageboard
>>
>>53906316
obviously. but it's a more worthwhile lie than pretending you give a fuck about this assignment enough to implement an ascii plotter (to say nothing of having plotted the area of the circle, when all the prompt called for was the line).
>>
>>53906376
i'm not a boss (let alone of a company) and i never said i was. you must have inferred that to justify your own stupid misunderstanding of what i was saying.
>>
>>53893686
If it makes u feel better I'm a project manager and also serve as lead programmer making big bucks and I can't even remember what Cartesian coordinate are
>>
>>53906376
bosses don't interview developers. someone in HR might interview for "culture fit", but the tech interviews are almost always internally managed. maybe a PM will do the interview but often he'll just ask someone in the team to run it.

it's both an exercise for the employee and more practically relevant - neither the manager nor HR nor even the PM really has a good sense of the sort of work that a developer would need to be competently prepared for. having people working on the codebase running the interview at least gives you some intuitive assurance that the whiteboard coding prompt won't be totally unrelated to the work.
>>
The name "Cartesian coordinates" made me think they were something more fancy than just coordinates on a graph until I looked them up.

Yep, I would have failed that question.
>>
>>53906527
You didn't know they were called Cartesian? I'd blame your education system, it's pretty bad. Where I'm from, we learnt that in Junior High along with other coordinate systems like polar or cylindrical.
>>
>>53906527
you had never heard of the formal term before?

did you not go to college or something? i mean i was a bad student in high school and even then i got far enough in math to hear the term for it.

how would you handle something like the greek value for sum? or the various things that might go around it?

i feel like if you don't understand the "vocabulary", you'll basically be outed as a fraud at some point. like i agree that the concept behind pic related isn't that complicated (just 1+2+3+...100), if you saw that shit (or heard something like "Cartesian Coordinates") and looked at them like a deer in the headlights, you'll immediately shake their confidence. Like who the fuck knows what else you don't know? You sure don't.
>>
>>53906612
>bikeshedding this hard

Booksmarts don't mean shit in the real world.
>>
>>53906689
>using a term he just learned in this thread
>incorrectly
>>
>>53901623
Ironic because that isn't even fucking correct. You didn't multiply by the radius.
>>
>>53906689
what i'm talking about isn't bikeshedding. you should read up on what bikeshedding is.

you can accuse me of being pedantic, and that's fine, but the whole point is that if you're not *a little* pedantic then people will wonder how rigorous you could possibly have been if you didn't go through the formal, pedantic process of university. because we all (well, everyone that went to university) know that class or that concept that was hard for us to grok and we know we never would have learned it if it had been up to us. but that's what makes us better; the struggle of trying to understand something unfamiliar.
>>
>>53906837
>i'm better than you because i have a degree
>>
>>53906877
again, not what i'm saying. if you're reading that from my post then that's your own baggage.
>>
>>53906877
Wat
t. Bystander anon
>>
>>53906805
>hurr you didn't include every possible modifier
Yeah no shit you could modify it to specify a radius or offset or whatever. Doing it like I wrote prints the Cartesian coordinates of a circle of radius 1. Don't be a nigger.
>>
>>53906572
We used them all the time from the time, but aside from some history I can't remember now, I never heard them called anything more than "coordinates".

>>53906612
I likely had heard it at some time, but it was mentioned so rarely that I had no idea what it was when I saw this thread.

And yes, I do have post-secondary, though it was from a Polytechnic, so it taught about algorithms, efficiency, operating system internals, system analysis and design, database use and administration, etc... There was no math aside from the obvious Big O Notation.

>how would you handle something like the greek value for sum? or the various things that might go around it?
If I need something I don't know, I'd read the Wikipedia article on it, start a literate programming document, and in it, write code snippets until I am confident enough to use it for reals.

Literate programming is amazing for learning anything that has logic very quickly.
>>
>>53906940
>from the time
*from the time we learned about graphs

Dammit phone.
>>
>>53906877
as an example of why it would be important to know the formal terms, and taking from this specific case, what if the interviewer didn't want Cartesian coordinates but polar coordinates?

You can demand that the interviewer explain these things until you figure out intuitively what they mean - because you almost certainly use both in "everyday" life - but the whole point of formal language describing this stuff is to make this process easier by assuming that everyone dealing with coordinate systems has learned the same names for these things.

You could be an autodidact or a self-directed learner or whatever else you call yourself where you learn all this stuff without having gone to university, but if your argument is that you're just as good as a university graduate, then don't ask us to explain what we mean by "cartesian coordinates".
>>
File: 1000px-Polar_graph_paper.svg.png (87 KB, 1000x1000) Image search: [Google]
1000px-Polar_graph_paper.svg.png
87 KB, 1000x1000
>>53907033
meant to post this to illustrate polar coordinates. god damn it.
>>
>>53901348

> that's impossible sir, there are an infinite amount of points in a circle

> I like the way you think, son. Welcome aboard the Google team.
>>
>>53893686
w/ MATLAB & complex plane

function z = circle(r)
z = r*exp(1j*linspace(0,2*pi));
plot(real(z),imag(z));
end
>>
>>53906940
>start a literate programming document
this whole response makes me think you didn't understand what i was asking. i'm asking what you would do if you encountered symbols or terms that referred to ideas you understood, but had never learned the formal term for.

An example of something slightly more complex than "sum" is "kurtosis". The intuition for kurtosis isn't totally crazy and if you know basic stats you probably encountered it. it's basically describing the qualities of the tail of a distribution (or thinking of it differently, the peaking of the distribution).

this shouldn't require a lot of "literate programming" or anything. let's pretend you know it right now, even if you don't. the issue is that if you have some intuition about kurtosis but you'd never heard the term itself, or the terms and ideas surrounding it, and if that comes up in an interview, it will rattle the interviewer. it makes it *extremely* salient that you have blind spots in your education that are wildly unpredictable. you don't know the term for "kurtosis", but you know the idea. What ideas & terms are you in the dark about?
>>
>>53907119
>studying a NN design book right now
>all examples in MATLAB
>I'm punishing myself doing it in C++ for CUDA gains
MATLAB
C O Z Y
O
Z
Y
>>
>>53901348
>>53907103
He obviously means some subset that you can visually imagine to be forming a circle if you connect the dots.

On that note, just return some arbitrary point. It's a subset of the circle, right? :^)
>>
>>53907226
return a triangle and say that if you filled in more points it would be clear that it plots a circle but that he's connecting the 3 visible dots with straight lines which is obviously wrong.
>>
>>53907033
Ah, if this was during an interview, honestly, I would probably be done for. (And probably a little frustrated, since I doubt I would use it in my day-to-day work)

I'd ask for them to elaborate. But, if they didn't, I would be stuck until they said something that gave away what they were talking about.

On the fipside, if I was already working somewhere and the term came up, I would Google it and realize "Oh hey! I actually know this.". If I didn't, then I would do my literate document thingy.
>>
import math

def circle(r,steps):
if (steps < 1) or (steps % 1 != 0) or (r < 0):
return
array = []
j = 0
while j < (2 * math.pi):
points = []
if abs(math.cos(j)) < 0.000000001: # accounting for the fact that math.pi isn't really pi; can be omitted
points.append(0)
else:
points.append(r * math.cos(j))
if abs(math.sin(j)) < 0.000000001:
points.append(0)
else:
points.append(r * math.sin(j))
array.append(points)
j += (math.pi / (steps / 2))
return array


Did I fuck up?
>>
shortest i could make it
d=s=>[for(a of Array(s).fill(0).map((_,i)=>i*2*Math.PI/s))[Math.cos(a),Math.sin(a)]]
d(10)
>>
>>53900288
>polar
>difficult
Sure is amateur hour here
>>
>>53906033
>floor
>not rounding
top pleb
>>
>>53907460
3.1415 is shorter than Math.PI if you're lazy
>>
>>53900234
Nice recovery there
>>
File: 00.jpg (2 KB, 224x250) Image search: [Google]
00.jpg
2 KB, 224x250
>>53903944
>you're almost as bad as engineers, when it comes to math

plz
>>
>>53906336
this nigga knows what's up
>>
>>53908317
Studying anything than mathematics is a waste of time
>>
>>53906336
Fucking hell I wish you were my employer
>>
>>53893686
>what does plot means?
>can you give an example or test case?
>>
>>53908475
I think they meant locus
>>
File: 1362473171492.gif (617 KB, 211x199) Image search: [Google]
1362473171492.gif
617 KB, 211x199
>>53893875
what meme language is that? disgusting
>>
>>53908564
C
>>
>>53904586
This is high school trig, not calculus.
>>
>>53893875
>plot_t *out = (plot_t *) malloc(sizeof(plot_t));

why the fuck are you dynamically allocating that?
>>
>>53908721
the op asks for a function that returns an array.
you can't pass arrays in C, only pointers to arrays, so you need to dynamically allocate it and return the pointer.
the rest is just fluff
>>
>>53908770
You're only allocating one of the plot struct, the point array is inside of it.
>>
>>53908831
plot_circle() returns a pointer of type plot_t
>>
Can someone write a lua that pops all burnphase cds with one go?
>>
>>53893869
I modify like 10+ year old proprietary shit that has zero documentation

I also work with cache and it's awful, this is pretty much my day
>>
>>53908858
>plot_circle() returns a pointer of type plot_t

You don't need to return a pointer
>>
>>53906033
that's a disc, not a circle
>>
>>53909003
how would you write it then?
>>
>>53906877
he is, though
>>
>>53900888
>you are allowed to use any language
>>
>had job interview the other day
>company that does websites for contractors or something
>they only want HTML/CSS experience
>at the interview they ask me of I'd mind "writing some code"
>displaying a hyperlinked image
>easy as shit
>on the way home realized I fucked it up by combining the two together like

<IMG a href="link" src="image" />

I don't even know why I did it like that. I don't think I meant to. I know how it's supposed to be done. It just suddenly hit me on the drive home. I even emailed them afterward explaining it, though I doubt it helped any.
Honestly it was probably a pretty shitty interview all around anyway. I was unprepared and found myself stammering out a lot of my answers. A lot of the shit like
>What is your biggest flaw?
>Where do you see yourself in five years?
Would've been nice since there's like no tech companies actually in my town and this one was, but whatever.
>>
>>53907418
Mmm python goodness
>>
>>53908317
that's why EECS is masterrace
>>
>>53909089
>What is your biggest flaw?
How do people answer this? Are you supposed to blatantly lie and humblebrag?
I get the feeling telling the truth would lose me the job for sure. "Sometimes I'm very lazy and I'm prone to depression."
>>
>>53893686
>cartesian coordinate points that plot a circle
what the fuck bro. this is some middle school geometry shit
>>
>>53909175
I'm not even sure. I think I said that I'm naturally reserved, but through schooling and some customer service experience I feel I've improved. At the same time that might look like shit.
>>
>>53909175
It doesn't matter.
It's a formality.
By the time they're asking you that question, they've already made up their mind about whether they'll call you back.
>>
>>53894967
>Second, it would produce points in messed up order (you couldn't plot a circle with them).
Yeah you could, just put pixels on each of those points it'll definitely make a circle.

>Third, your solution wouldn't even work at all. More or less the only points this would produce are (-1, 0), (0, 1), (0, -1), (1, 0).

If this is a jab at floating point arithmetic, just measure whether thay are within tolerance, it's not that hard at all:

if abs(x * x + y * y - 1) < epsilon
>>
circle = concatMap (\(a,b) -> zipWith (,) a b) [fq,sq,tq,ftq]
where fq = (fst sq, map negate (snd sq))
sq = (map sin [0,0.01..pi/2], map cos [0,0.01..pi/2])
tq = (map negate (fst sq), map negate (snd sq))
ftq = (map negate (fst sq), snd sq)
-- all the quadrants
>>
>>53902905
>posts anime
>this post
Are all of you like this?
>>
File: f9FW2.gif (2 MB, 240x180) Image search: [Google]
f9FW2.gif
2 MB, 240x180
>apply for non-IT job at a bank
>"please answer these 20 statistics questions in 20 minutes"
>run out of time and have to guess on three questions
>>
>>53909175

No shit. I hardly think an employer would call me back if I was honest and said that I'm manic depressive and may miss up to ten days of work at a stretch as I languish in bed contemplating suicide.
>>
>>53909175
You're supposed to answer with a flaw that isn't really a flaw and that you can turn into an advantage. Yeah it's a pointless bullshit question. I'm glad they didn't ask me at my current job.
>>
>>53909175
you're supposed to answer with a genuine but minor flaw AND what you're doing to improve upon it.
>>
>>53909175
I tell the truth, but not the extent.

I say that I am really hard on myself sometimes.
I don't say that I am actually more nasty to myself when I make mistakes than I am to my worst enemies when I am absolutely livid.
>>
>>53893686
>import circle_maker()

print(circle_maker(20).


Fucking ez
>>
>>53899515

http://plt-scheme.org/software/drscheme/

you can use DR SCHEME!!!

or fucking RACKET i guess they renamed it since i got assfucked and forced to take a "programming" class that used this fucking bullshit fake useless language that we might as well have been using java or c++for instead
>>
>>53909521
Racket is actually really awesome. It's just not that fun if it's your first language.
>>
I would have walked out of the interview

Unless this job involved graphics programming of any sort, why would I need to know this?
>>
>>53909553
I mean, doing the standard basic school assignments in it is boring.
However when you learn how to use high-order programming techniques, it becomes absolutely fantastic.

You should try it again later when you get familiar with functional pipelines. You might see it in a much different light.
>>
>>53909591
>implying anyone on /g/ has the balls to walk out of an interview
>>
>>53909591
https://css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
>>
>>53909607
I've done this before when one of the interviewers made fun of me for wearing a suit.
>>
>>53909634
What kind of job was it? I always wear at least a nice shirt and tie.
>>
>>53909634
I thought the general rule was to dress as well as the employees?
If you're expected to wear a suit everyday, you'd better wear a suit to the interview.
>>
>>53909634
https://www.youtube.com/watch?v=x_9hYMVVv_Q
>>
>>53909620
That entire thing pissed me off, thanks mate
>>
>>53909620
I think circle geometry is a step up from fizzbuzz and converting time to seconds.
>>
>>53909516
>unclosed parenthesis
>doesn't even do what was asked
>>
>>53893871
>if x * x + y * y = 1 then add (x, y) to points
>if x * x + y * y = 1
>if ... y * y = 1 ...
not ==?
>>
>>53909607
I'm sure a lot of us have done it. I have.

Interviews are a two-way street. I am interviewing the company to see if I would want to work for them as much as they are interviewing me.

If they seem too serious, if they don't seem to value their developers, or if they have some policy I disagree with. I am out. I don't need to put up with them.

Working at a place where I hate myself is just not worth it.
>>
>>53909788
>If they seem too serious, if they don't seem to value their developers, or if they have some policy I disagree with. I am out. I don't need to put up with them.

That's nice, but most people who are applying to jobs don't have the luxury of choice.
Especially not on this board, which is full of NEETs and other unfortunate cases who have zero experience.

The way it works is you suck up to anyone who was gracious enough to give you a skype call.
>>
>>53909810
It doesn't have to be that way though... Contributing even the tiniest of patches to a reasonably sized project looks really impressive to the right kind of people.

Also, networking, even if it is just on GitHub and Stack Exchange websites give you a pretty huge boost when it comes to getting hired by non white-collar companies.

If you get your name out there and have a good reputation, recruiters literally hound you all the time.

It sounds impressive, but really, it's not.
>>
File: 1438716337451.png (750 KB, 854x853) Image search: [Google]
1438716337451.png
750 KB, 854x853
>>53909620
>>
fn lol(max: u32) -> Vec<f64> {
(0..max).map(|r| 2. * f64::consts::PI * r as f64 / max as f64).collect()
}
>>
>>53910022
That is beautifully high-order.
>>
>>53910022
>using a shit language like rust
You forgot the actual coordinates anon.

fn lol(max: u32) -> Vec<(f64, f64)> {
(0..max).map(|r| 2. * f64::consts::PI * r as f64 / max as f64)
.map(|x| (x.cos(), x.sin())).collect()
}
>>
>>53910022
Is this rust?
>>
>>53910179
yeah
>>
>>53907256
>You need to write out a program that plots a series of alt-cides for the three triangles, perfectly centered, and perfectly stacked, one atop two
>>
>>53910179
>>53910210
That looks awesome, now I'm inspired to learn rust... well, maybe after I shitpost a bit more.
>>
>>53893875
Enjoy your leaks cuck
Thread replies: 255
Thread images: 35

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.