[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 484 KB, 1366x768, Untitled.jpg [View same] [iqdb] [saucenao] [google]
3027562 No.3027562 [Reply] [Original]

>have no programming experience at all
>look up stuff about python for a few minutes
>make program that calculates fibonacci sequence
>call myself expert programmer
>trollface.jpg

anyone else have experiences with python being embarrassingly simple?

>> No.3027586

>never had any experience in python
>looks at your pic
>holy fuck, is that pseudocode?

>> No.3027622
File: 114 KB, 214x270, 1261850630347.png [View same] [iqdb] [saucenao] [google]
3027622

mon visage quand in python, hello world is hardest program to write

>> No.3027627

>>3027586
might as well be. it's hilariously easy to learn.

>> No.3027645

>>3027622
print "hello world"
and done!!

>> No.3027666
File: 60 KB, 970x878, ruby_masterrace.png [View same] [iqdb] [saucenao] [google]
3027666

It looks almost the same in ruby, only that input is gets instead, print works but p is shorter, the loop doesn't need ":" or forced indentation but you finish it with "end", there's also while for looping if that's to your liking.

>> No.3027693

actually programming is shit-simple, algorithms are what separate the men from the boys.

>> No.3027713

>>3027693
This is true. And there's a better algorithm for the fib sequence. Several actually.

>> No.3027717

>>3027562
Wait until you get to multithreading.

God. Buckets. Everywhere.

Also
>Make infinite loop in python
> Make a break in it
>Java fag sees it.
>Thinks python is magic
>mfw people use java over python
>

>> No.3027718

>>3027693
programming is shit-simple when the entirety of your program fits on one page.

>> No.3027726
File: 131 KB, 1366x768, Untitled1.jpg [View same] [iqdb] [saucenao] [google]
3027726

a simple number-guessing game written in python
10 lines
it's like they dont even want me to try

>> No.3027748

>girlfriend has Assembler class
>can't figure out Fib sequence
>have never even seen the language before
>glance at her screen
>girlfriend's homework now done

>> No.3027756

>write huge, complicated, algorithm solver in python
>takes 10 minute to calculate
>write it in c
>takes 10 seconds to calculate

>> No.3027771

>computer programming
>difficult

anything that can be done by comic con-frequenters is probably not difficult

>> No.3027773
File: 4 KB, 126x103, trollface.jpg [View same] [iqdb] [saucenao] [google]
3027773

>>3027756

>>interpreters

>> No.3027784

>>3027645
thatshtejoke.bmp

>> No.3027786

>>3027771
programming is not difficult, applying programming is difficult.

>> No.3027790

>>3027718
fuck you people are bad at even simple codes. that many lines for a stupid fibonacci sequence? "Hit enter"?

Matlab:
a(1)=0;
a(2)=1;
for i = 3:10
a(i)=a(i-1)+a(i-2)
end

>> No.3027805
File: 41 KB, 1110x623, rub masterrace2.png [View same] [iqdb] [saucenao] [google]
3027805

>>3027726
I like my version better

>> No.3027808

>>3027748
so your girlfriend is stupid enough to be confused by something so simple, yet she's in some kind of CS/CE program... and you do her easy work for her guaranteeing she'll forever be worthless and live up to the stereotypes of women being awful?

>> No.3027836

Quicker algorithm for fib sequence. lim n-> infinity of a(n+1)/an in the fib sequnce is the golden ratio. Write out the first couple of terms

1, 1, 2, 3, 5, 8, 13, 21, 34, 55
For everthing after that use floor[13*phi^(n-9)]

I saw that trick written on project Euler.

>> No.3027842

>>3027836
its 55*phi not 13*phi.

>> No.3027848

>>3027836

wtf is floor[] and what does it do

>> No.3027852
File: 79 KB, 1110x655, rub masterrace2.png [View same] [iqdb] [saucenao] [google]
3027852

How about a program that reads the title of the active window once a second?

>> No.3027855

Floor is greatest integer function. It returns the greatest integer less than a number. In other words it chops of decimals.

eg: 3.14159265359 becomes 3

>> No.3027859
File: 57 KB, 474x604, 1265976462150.jpg [View same] [iqdb] [saucenao] [google]
3027859

>>3027562
>fibonacci
>no memoization
>no dynamic programming
>expert programmer

>> No.3027860

>>3027805

a=floor(rand(1)*10)+1;
while( a ~= input('Guess\n') )
disp('fail\n');
end

>> No.3027867

>>3027852
full of epic fail if you have to refer to a textbook for something so trivial

>> No.3027879
File: 63 KB, 433x559, 1266162979518.jpg [View same] [iqdb] [saucenao] [google]
3027879

>>3027562
>fibonacci sequence
>he doesn't know how to find closed forms for recurrences using linear algebra!

>> No.3027896

>>3027867
I used it to look up the random function for the previous example as I was unsure if it could be used to randomize numbers within a range(which it apparently could not).

Also, given that you have half a trillion built in methods for everything I'd be retarded if I tried to memorize all of them.
See string for example: http://ruby-doc.org/docs/ProgrammingRuby/html/ref_c_string.html

>> No.3027903

>>3027879
note the utter lack of programming experience, and only a basic understanding of how the fibonacci sequence works

>> No.3027924

>>3027808

You gettin' mad that a woman is being a woman? No wonder you're a virgin.

>> No.3027960

i like this thread

>> No.3027967
File: 18 KB, 1097x579, inkjet.png [View same] [iqdb] [saucenao] [google]
3027967

I also have a program that hijacks your mouse to draw pictures like an inkjet printer but unfortunately it's too big to fit all on one screen(81 lines). It's also devoid of comments and 1.5 years old so I have no clue how it really works.

>> No.3028022

Given that someone in here seems to be real CS guys. How do you call win32API/dlls from matlab?

Also, why is entry level documentation for a lot of things so incredibly sparse? Things that turn out to be relatively simple once you know them was driving me crazy when I first tried them out and i found zero documentation anywhere.

>> No.3028035
File: 13 KB, 672x244, fib.png [View same] [iqdb] [saucenao] [google]
3028035

look at all the little boys playing with their pythons

>> No.3028063
File: 381 KB, 1366x768, retard001.png [View same] [iqdb] [saucenao] [google]
3028063

>>3027726
Holy shit your control structures fail so fucking much

oh my god seriously it's sooooo bad

>> No.3028072

>>3028035
That, sir, is a lot of parentheses.

>> No.3028076

>>3028022
>Also, why is entry level documentation for a lot of things so incredibly sparse?
It ain't.
>"help rand"
kinda a huge attribute of matlab.

>How do you call win32API/dlls from matlab?
with "loadlibrary". not something i ever do though. not really the point of matlab, unlike ruby.

>> No.3028085

>LOL THIS LANGUAGE IS SO EASY CHECK MY SKILLS LOL IT SUCKS SO MUCH I SO GOOD

you chucklefucks...an intuitive high-level programing language is a good thing. that's why python is so popular.

>> No.3028091

>>3028063
>two comparison statements when only one is needed
>rants enough to paint up a hate-img

>> No.3028099

>>3028072
the defining characteristic of all things lisp... i mean, i don't like the whitespace/column shit of python, but sweet fuck lisp is a bitch to look at

>> No.3028102

>>3027903
note the
>EXPERT PROGROMMAR

>> No.3028104

>>3028063
i never claimed to be a good programmer. i just wanted to make a program that worked. and guess what? mission fucking accomplished. i had a goal in mind, and i accomplished that goal.

>> No.3028114

>>3028104
>expert programmer

>> No.3028127

do it in machine code, and i'll be impressed.

Just kidding,I wont be impressed. If you take the time to learn machine code, the fib sequence is easy.

>> No.3028147

>>3028114
not the clear sarcasm. as referenced by the ">trollface" line

>> No.3028168
File: 40 KB, 499x573, 128680525020167060[1].jpg [View same] [iqdb] [saucenao] [google]
3028168

>mfw i saw OP's code

five lines op:

a, c, b = 1, 1, 0
while 1:
print str(b) + " \n"; b = a + c
print str(a) + " \n"; a = b + c
print str(c) + " \n"; c = b + a

>> No.3028203

>>3028168
>uses three variables to compute
>laughinggirls.png

>> No.3028218

>python
>expert programmer
hahahahahahahaha

>> No.3028235

>>3028076
>with "loadlibrary". not something i ever do though. not really the point of matlab, unlike ruby.

Matlab have some neat libraries for fetching video streams and processing them, if I want to use my hand as an airmouse or similar alternate input via gestures i'd say it's perfectly reasonable and for that limited application it would be the point of matlab to be able to do so. The point of anything you can program in is to have a turing complete enviroment you can do everything in is it not?

Point of ruby is to have easy syntax and great flexibility for those code projects you have that do not require industrial grade precision and speed.

>> No.3028245

>>3028218
>make program that calculates fibonacci sequence
>call myself expert programmer
>trollface.jpg

I guess you're too ignorant or socially retarded to get that when the OP says "TROLLFACE.jpg" it's to make the "expert programmer" remark look sarcastic and silly.
God, you must have horrible social etiquette.

>> No.3028249

>>3028091
wow that was some overreaction... the program here isn't terrible, but if you ever have to write REAL programs, unnecessarily calling more comparisons than you actually need could severely slow down the performance of your program especially since functions and comparison methods grow to be quite complex when dealing with objects. developing good style is a good habit to get into early on before it becomes a big deal

>> No.3028250

>>3028235
>The point of anything you can program in is to have a turing complete enviroment you can do everything in is it not?
not so much... for example, C++ is not actually turing complete

>> No.3028268

>>3028250

So, all the languages with C++ interpreters aren't Turing complete either?

>wtfamireading.jpg

>> No.3028281

>>3028235
>Matlab have some neat libraries for fetching video streams and processing them, if I want to use my hand as an airmouse or similar alternate input via gestures i'd say it's perfectly reasonable and for that limited application it would be the point of matlab to be able to do so.
true. not my area though so i forgot about the various toolboxes.

>The point of anything you can program in is to have a turing complete enviroment you can do everything in is it not?
no, the point is to get a real task done as efficiently as possible. different languages can be drastically better at different tasks. i use matlab for basic math, simple numerical solutions to differential equations, plotting, and numerical algorithm development; C++ and MPI for large scale, long-term numerical software projects; and python for occasional automation of the big codes for producing a lot of data. i only recently got into python though, and have never written anything longer than a handful of unit tests for compiled code.

>> No.3028284

>>3028268
No, the languages interpreted by C++ interpreters are Turing-complete, but the language of C++ is not.

>> No.3028295

>>3028250
>C++ not Turing complete
Detected either a complete dumbass, or a dumbass that thinks that's some kind of troll.

Either way, my Turing machine points to dumbass.

>> No.3028300

>>3028284

you dip-shit, any language that can interpret a turing complete language is turing complete. Its almost the fucking definition.

I'm not even the guy you were talking to and im raging at that

>> No.3028306

I fucking loved impressing the shit out of people in high school with my

>omfg1337 python skiilllzzz

It honestly got me laid at least once.

>> No.3028314

>>3028295
No, C++ is not capable of simulating a universal Turing machine given infinite memory.

>>3028300
>any language that can interpret a turing complete language is turing complete
Not true. The C++ language is flawed, but it can still interpret other languages that are not flawed for any practical purpose.

>> No.3028325

>>3028314
Can't tell if troll or retarded. Damn you, natural flaw in text-based communication!

>> No.3028333

Even the fucking TEMPLATES in C++ are turing complete.

>> No.3028342

>>3028314
>>3028314

you're a fucking retard. your wrongness is like a 4 dimensional fractal, you are wrong in dimensions that are inaccessible to us and you are also infinitely and recursively WRONG.

well go on, show us how c++ isn't Turing complete

>> No.3028346

>>3028333
C++ templates are turing complete, but C++ itself is not.

>> No.3028352

>>3028325
>/sci/ forever etching out the fractal boundary of Poe's law

>> No.3028355

>>3028346
now certain is troll.

and still a fucking dumbass that isn't funny.

>> No.3028358

>>3028295
>>3028333

I'm assuming you're the same person.
want to write up a quick Turing machine program in C++ so we can be done with this.

be sure to append "QED MUTHAFUCKA to the end"

>> No.3028362

bitches don't know about my QBASIC skillz

>> No.3028371

http://lmgtfy.com/?q=turing+machine+source+c%2B%2B

>> No.3028372

>>3028352
>/sci/ forever etching out the fractal boundary of Poe's law

That's like, the most beautiful and accurate description of /sci/ I've ever contemplated. It's like some kind of infinite variation on the same theme. Anti-Turing guy is like an "engineers are gay" thread.

Kudos

>> No.3028382

>>3028342
C++ isn't Turing complete because you can't make a pointer to any address in infinite memory. It has to be within a particular range. No infinite tape, no universal turing machine.

>>3028358
That won't prove anything.

>> No.3028394

>>3028382

Turing machines can't go directly to any address in memory either; they can only go one step to the left or to the right.

>> No.3028396

>>3028382

In computability theory, a collection of data-manipulation rules (an instruction set, programming language, or cellular automaton) is said to be Turing complete if and only if such system can simulate any single-taped Turing machine.

http://en.wikipedia.org/wiki/Turing_completeness

QED bitch

>> No.3028414

http://www.youtube.com/watch?v=E3keLeMwfHY

you will never do any so cool and utterly useless in your entire life.

>> No.3028417

>>3028396
>if and only if such system can simulate any single-taped Turing machine.
You know that all Turing machines have infinite tape, right?

>>3028394
I don't see why it matters whether the Turing machine has to walk to a point outside of the boundary or teleport to it. The fact of the matter is that C++ can do neither.

>> No.3028435

>>3028414
>http://www.youtube.com/watch?v=E3keLeMwfHY
more Turing-complete than C++

>> No.3028436

>>3028417


huh, so tape==RAM
lol no.
just put the parts of the tape that you aren't even close to on the hard drive.

>> No.3028443

>>3028417

What boundary?

>> No.3028471

>>3028443
The size of the pointers is a specified number of bytes. C++ cannot create pointers for any address that does not fit in that number of bytes. You must give pointers a size. Thus, you cannot make a program that would be able to access infinite memory.

>> No.3028475

>>3028435
> Shows digital devices likely programmed in C/C++ used to physically simulate a Turing machine
> Thinks the machine is Turing complete but the program running it is not
> Does not understand induction

>> No.3028482

i started this thread in hopes that people would share experiences in their own poor programming ability in python.

does anyone else have neat little programs made in python that they're proud of despite not being efficient or even "good" programs?

please stay on topic.

>> No.3028494

>>3028475
No, the language of the machine is Turing-complete. The program running on it is not a language. It is a program. Programs are not Turing-complete. It doesn't even make sense for a program to be Turing-complete.

>> No.3028508

>>3028482

ok OP I got you. taught my self python back in the day.

have you heard of turtle. you will like turtle.

import turtle.
while on the topic,
import antigravity

>> No.3028510

>>3028482
Heh.

>wants to control /sci/
>/sci/ can't be controlled

>> No.3028518

TRU='*'
FAL='.'
import time
import os
def binNum(num,length,on=TRU,off=FAL):
x=(bin(num)+' ')[2:-1]
newstr=x[0]
for i in range(0,len(x)):
if x[i]=='1':
newstr=newstr+on
else:
newstr=newstr+off
x=(newstr+' ')[1:-1]
y=(length-len(x))*off
return y+x
def showTime(tim):
print(binNum(tim[3],6))
print(binNum(tim[4],6))
print(binNum(tim[5],6))
time.sleep(1)
os.system("cls")
def main():
while 1==1:
showTime(time.localtime())

main()


#binary clock

>> No.3028529

>>3028471

Where is the size of pointers specified in the C++ language definition?

>> No.3028534

>>3028518

well that failed, and I don't care to make screen shots.

just for you OP
http://typewith.me/1NgNLfur0v

>> No.3028541

>>3028529
I dunno, but it's definitely finite.

>> No.3028547

>>3028541

Then you don't know what you're talking about, do you?

>> No.3028555

>>3028541
im not who you were arguing with, but it sounds like you two are arguing about whether or not infinite memory can exist. that is obviously not true. and now youre arguing about whether or not the pointers to that memory can be infinite? ugh... not even worth the trouble...

>> No.3028571

>>3028555
No, I'm saying that C++ is not scalable to infinite memory and therefore cannot simulate a universal turing machine.

>>3028547
Then why don't you tell me, smart guy?

>> No.3028573

>>3028035

Fuck yeah Lisp/Scheme/Racket!

>> No.3028588

>>3028571
you win, i guess.

successful troll is successful . jpg

>> No.3028595

>>3028571

C++ does not define ANY limits on pointer size. This simple fact is why you're utterly wrong.

>> No.3028608

>>3028595
sizeof(void*) is finite, isn't it?

>> No.3028624

That is not at all why he's wrong. At all. Not even fucking close.

Goddam. Hard to tell who is dumber on sci; the trolls, or the morons who try to debate it.

It has fucking nothing to do with any limitations on the size of a goddam pointer. JFC.

>> No.3028657

>>3028624
u mad

>> No.3028661

>>3028624

If you can't tell who's trolling who, you've lost the game.

>> No.3028668

>>3028608
I don't think it need be, actually.

>> No.3028670

I'd give you a 0 for style.

>> No.3028677

>>3028668
But it is, which is why C++ isn't Turing complete.

>> No.3028685

>>3028677
Ah yes, the immovable practicality meets the impenetrable theoretics

>> No.3028689

>>3028677
Citation needed. Additionally, sizeof()s are measured in the number of `char`s, and chars need not have a finite domain.

>> No.3028696

For the non-trolls out there who might be confused:

No terminating Turing machine program requires an infinite tape.

>> No.3028707

>>3028696
I'm pretty sure that C++ is turingcomplete, anyone arguing otherwise is stuck on some minor detail that any EXPERT PROGRAMMER would solve in five elegant ways in his sleep.

>> No.3028708

>>3028696
We aren't talking about programs. We're talking about the machine itself. The machine requires an infinite tape, and the programs require tapes of unknown and arbitrary size.

>> No.3028710

>>3028677

Nope. You keep wanting ascribe the limitations of a specific implementations of C++ to the language itself.

sizeof(void *) isn't guaranteed to terminate in the language definition.

>> No.3028727

>>3028710
reference please

>> No.3028739

>>3028727
You want a reference to the place where a given limitation is NOT written?

>> No.3028747

>>3028739
I meant a citation, chuckles

>> No.3028756

>>3028747
You want a citation of the sentence where a given limitation is NOT written?

>> No.3028763

>>3028756
explicitly yes

>> No.3028795

If you don't like simple, you're a fucking idiot.

>> No.3028826

>>3028795
>if you idiot

>simplified

>> No.3029249

>>3028346
>Part of the language is turing complete
>but the language is not turing complete
That's like saying only part of your body can think, but your body can't think.

C++ templates are part of the C++ language, therefore C++ is turing complete.

>> No.3029291

>>3028826
if(!you.like(simple)){
you = new idiot();
}

FTFY

>> No.3032205
File: 390 KB, 1928x1424, newfriend tips.jpg [View same] [iqdb] [saucenao] [google]
3032205