Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Project Euler isn't just a computational challenge. I've solved a few problems algebraically. Whatever way works, as long as you don't brutefoce it (although if you can beat the CAPCHA and generate answers fast enough, you probably earned those points).
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Cheese> I love you

jaap
Posts: 2094
Joined: Fri Jul 06, 2007 7:06 am UTC
Contact:

Re: Coding: Fleeting Thoughts

headprogrammingczar wrote:Project Euler isn't just a computational challenge. I've solved a few problems algebraically. Whatever way works, as long as you don't brutefoce it (although if you can beat the CAPCHA and generate answers fast enough, you probably earned those points).

You have to leave at least 30 seconds between submitting answers.
Anyway, I would consider it cheating unless he then confirmed the answer really was correct by calculating the periods of the three decimal expansions he had to try.

Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

It was an educated guess. Any guess, when sufficently educated, is indistinguishable from a real solution.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

jaap wrote:
headprogrammingczar wrote:Project Euler isn't just a computational challenge. I've solved a few problems algebraically. Whatever way works, as long as you don't brutefoce it (although if you can beat the CAPCHA and generate answers fast enough, you probably earned those points).

You have to leave at least 30 seconds between submitting answers.
Anyway, I would consider it cheating unless he then confirmed the answer really was correct by calculating the periods of the three decimal expansions he had to try.

Brute force their SFTP (or FTP or Telnet or whatever) password and get onto their servers. Then, remove the script that prevents you from answering too quickly so you can brute force every problem. Only then do you deserve the points.

If you expected me to say you modify their database so you have every problem done, you are not worthy of getting the points for the questions.

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Berengal wrote:It was an educated guess. Any guess, when sufficently educated, is indistinguishable from a real solution.

"Guess" sounds so crude. Call it an "ansatz" instead.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

You, sir, name? wrote:
Berengal wrote:It was an educated guess. Any guess, when sufficently educated, is indistinguishable from a real solution.

"Guess" sounds so crude. Call it an "ansatz" instead.

You know, I'm sure the processes in your brain that are involved in guessing are far more advanced than the normal Eular answers.

Say you used the world's most advanced "genetic" algorithm.

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

TheChewanater wrote:
You, sir, name? wrote:
Berengal wrote:It was an educated guess. Any guess, when sufficently educated, is indistinguishable from a real solution.

"Guess" sounds so crude. Call it an "ansatz" instead.

You know, I'm sure the processes in your brain that are involved in guessing are far more advanced than the normal Eular answers.

Say you used the world's most advanced "genetic" algorithm.

Though it took 3.7 or so billion years for the algorithm to learn to solve the problem (so slow it rivals java VMs from the '90s), so in that sense, it really doesn't qualify under the Euler rules.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

You, sir, name? wrote:Though it took 3.7 or so billion years for the algorithm to learn to solve the problem (so slow it rivals java VMs from the '90s), so in that sense, it really doesn't qualify under the Euler rules.

It has also taken decades to develop the hardware and software that can solve the problems, but the answers can be found in under a minute.

From the Project Eular website:
...although it may take several hours to design a successful algorithm with more difficult problems, an efficient implementation will allow a solution to be obtained on a modestly powered computer in less than one minute.

The meaning of "several" is up for debate. Also, notice the "may" and "more difficult".

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

e^iπ+1=0
Much, much better than Gooder
Posts: 2065
Joined: Sun Feb 15, 2009 9:41 am UTC
Location: Lancaster

Re: Coding: Fleeting Thoughts

jaap wrote:
headprogrammingczar wrote:Project Euler isn't just a computational challenge. I've solved a few problems algebraically. Whatever way works, as long as you don't brutefoce it (although if you can beat the CAPCHA and generate answers fast enough, you probably earned those points).

You have to leave at least 30 seconds between submitting answers.
Anyway, I would consider it cheating unless he then confirmed the answer really was correct by calculating the periods of the three decimal expansions he had to try.

Well, Wolfram|Alpha can do it for me, but really I don't know how to solve that problem properly.
poxic wrote:You, sir, have heroic hair.
poxic wrote:I note that the hair is not slowing down. It appears to have progressed from heroic to rocking.

(Avatar by Sungura)

'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: Coding: Fleeting Thoughts

I am always amazed by my ability to misread code in the same way over and over, and then look again a few hours/days later and immediately notice the problem. Like reading this:

Code: Select all

`glTexCoord2f(this->VtxCache[Command[i] >> 1].TextureCoordS / (float)(32 << this->Tile[0].SMask),   this->VtxCache[Command[i] >> 1].TextureCoordT / (float)(32 << this->Tile[0].TMask));`
as

Code: Select all

`glTexCoord2f(this->VtxCache[Command[i] >> 1].TextureCoordS),   this->VtxCache[Command[i] >> 1].TextureCoordT);`
every time. I must have looked over that function 47 times wondering why the texture coordinates were wrong.
(yes that is old messy code being replaced with nice shiny new code.)
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

b.i.o
Green is the loneliest number
Posts: 2519
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

Re: Coding: Fleeting Thoughts

'; DROP DATABASE;-- wrote:(yes that is old messy code being replaced with nice shiny new code.)

...I sure hope so. That's disgusting.

Moo
Oh man! I'm going to be so rebellious! I'm gonna...
Posts: 6440
Joined: Thu Aug 16, 2007 3:15 pm UTC
Location: Beyond the goblin city
Contact:

Re: Coding: Fleeting Thoughts

Man, people at Google must all be super nice and all visit deserted puppies in their free time. I had no idea integrating Google Maps into a website was this easy!
Proverbs 9:7-8 wrote:Anyone who rebukes a mocker will get an insult in return. Anyone who corrects the wicked will get hurt. So don't bother correcting mockers; they will only hate you.
Hawknc wrote:FFT: I didn't realise Proverbs 9:7-8 was the first recorded instance of "haters gonna hate"

The Black Hand
Posts: 1037
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Behind you

Re: Coding: Fleeting Thoughts

Is there a type[class] in haskell - or some other way - that will allow the following to compile:

Code: Select all

`collatz x | odd x = 3*x+1          | otherwise x/2`

If I use Integral, it complains about the /, if I use fractional, it complains about odd. It's the second time I've come across this problem.
73, de KE8BSL loc EN26.

hotaru
Posts: 1045
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: Coding: Fleeting Thoughts

RoadieRich wrote:Is there a type[class] in haskell - or some other way - that will allow the following to compile:

Code: Select all

`collatz x | odd x = 3*x+1          | otherwise x/2`

If I use Integral, it complains about the /, if I use fractional, it complains about odd. It's the second time I've come across this problem.

try using `div` instead of /.
like this:

Code: Select all

`collatz x | odd x     = 3 * x + 1          | otherwise = x `div` 2`

and then you can do this:

Code: Select all

`takeWhile (1 /=) \$ iterate collatz 670617279`

Code: Select all

`factorial = product . enumFromTo 1isPrime n = factorial (n - 1) `mod` n == n - 1`

Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Yeah, haskell separates different types of division, integer division, integer remainder and floating point division. I'm sort of ambivalent about this. It's nice to have all different divisions separate and to be made aware of them, but most of the time you just want to divide some effing numbers and it becomes a tiny bother to choose the right division function. The difference has been vital a couple of times though, and I'm sure I would've spent lots of time debugging in any other language without this difference, and finally I'd have to write whichever of the functions were missing anyway.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Contact:

Re: Coding: Fleeting Thoughts

Moo wrote:Man, people at Google must all be super nice and all visit deserted puppies in their free time. I had no idea integrating Google Maps into a website was this easy!

1. It is pretty fucking simple, isn't it? I love it.
2. I am a Google employee.
3. I visited a puppy today during lunch because he was lonely.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

e^iπ+1=0
Much, much better than Gooder
Posts: 2065
Joined: Sun Feb 15, 2009 9:41 am UTC
Location: Lancaster

Re: Coding: Fleeting Thoughts

Code: Select all

`>>> invalid syntax  File "<stdin>", line 1    invalid syntax                 ^SyntaxError: invalid syntax`
poxic wrote:You, sir, have heroic hair.
poxic wrote:I note that the hair is not slowing down. It appears to have progressed from heroic to rocking.

(Avatar by Sungura)

phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Blarg.

Dear coworker who seems to think he's the only one coding this project,
When you are making large-scale changes that require editing all the XML config files in the project, it's acceptable to use some form of automated tool to change all the XML files at once. However, it's considered good form to minimise the extent of the change... on the other hand, using a tool that involves parsing the XML, changing the DOM, and re-outputting the XML, resulting in re-indenting, re-wordwrapping, reordering attributes, replacing <foo /> with <foo/>, and the like, would be bad form. Especially when you have reason to believe that other people are working on those XML files too, and will get edit conflicts. And even more especially when your change is simply to add a single attribute to the root element.
If you just changed the one single line that you needed to change, then diff3 would've handled it automatically, but because you changed damn-near every line in the file, the merge tool is going to throw up its hands and go home.

I've just spent half an hour cleaning up SVN conflicts. And this isn't the first time.

Code: Select all

`enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}`
[he/him/his]

Aaeriele
Posts: 2127
Joined: Tue Feb 23, 2010 3:30 am UTC
Location: San Francisco, CA

Re: Coding: Fleeting Thoughts

phlip wrote:Blarg.

Dear coworker who seems to think he's the only one coding this project,
When you are making large-scale changes that require editing all the XML config files in the project, it's acceptable to use some form of automated tool to change all the XML files at once. However, it's considered good form to minimise the extent of the change... on the other hand, using a tool that involves parsing the XML, changing the DOM, and re-outputting the XML, resulting in re-indenting, re-wordwrapping, reordering attributes, replacing <foo /> with <foo/>, and the like, would be bad form. Especially when you have reason to believe that other people are working on those XML files too, and will get edit conflicts. And even more especially when your change is simply to add a single attribute to the root element.
If you just changed the one single line that you needed to change, then diff3 would've handled it automatically, but because you changed damn-near every line in the file, the merge tool is going to throw up its hands and go home.

I've just spent half an hour cleaning up SVN conflicts. And this isn't the first time.

You poor thing. Maybe he doesn't know its happening?
Vaniver wrote:Harvard is a hedge fund that runs the most prestigious dating agency in the world, and incidentally employs famous scientists to do research.

afuzzyduck wrote:ITS MEANT TO BE FLUTTERSHY BUT I JUST SEE AAERIELE! CURSE YOU FORA!

You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

1. Explain to him that what he's doing is causing problems
If it doesn't help
2. Complain with a supervisor or someone higher up in the pecking order
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

You, sir, name? wrote:2. Complain with a supervisor or someone higher up in the pecking order
Alternative: Commit before he does.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

This looks amazing, to say the least. I might try it sometime.

http://pyembedc.sourceforge.net/

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

levicc00123
Posts: 165
Joined: Thu Jan 03, 2008 5:33 pm UTC
Location: Sterling, CO
Contact:

Re: Coding: Fleeting Thoughts

TheChewanater wrote:This looks amazing, to say the least. I might try it sometime.

http://pyembedc.sourceforge.net/

[nerdgasm] This should be in the repository of every linux distribution if it's not already.[/nerdgasm]

You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

I can't help but feel something downright gnarly must be going on under the hood to allow for that.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

Xeio
Friends, Faidites, Countrymen
Posts: 5101
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

You, sir, name? wrote:I can't help but feel something downright gnarly must be going on under the hood to allow for that.
The atrocities committed in the name of speed... Also, it can call back into python functions? I'm scared...

Aaeriele
Posts: 2127
Joined: Tue Feb 23, 2010 3:30 am UTC
Location: San Francisco, CA

Re: Coding: Fleeting Thoughts

I don't even want to know what accessing Python vars with maps/dicts in them looks like.
Vaniver wrote:Harvard is a hedge fund that runs the most prestigious dating agency in the world, and incidentally employs famous scientists to do research.

afuzzyduck wrote:ITS MEANT TO BE FLUTTERSHY BUT I JUST SEE AAERIELE! CURSE YOU FORA!

Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Doesn't ruby have such a library as well?

It did recently get an inline Haskell library at least.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

b.i.o
Green is the loneliest number
Posts: 2519
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

Re: Coding: Fleeting Thoughts

Berengal wrote:Doesn't ruby have such a library as well?

Yes.

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: Coding: Fleeting Thoughts

Berengal wrote:Alternative: Commit before he does.

After making a whitespace change on every line.

Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: Coding: Fleeting Thoughts

Won't work. He'll just sync with the repository, and run his automated tool over it again, and won't notice the whitespace changes on every other line.

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

Why are you telling us instead of him?

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Well, I bitched at him about it (well, bitched politely) today, he said if/when it happens again, just go ahead and override it with my version, and tell him to run the script again.

Which is good enough, I think.

TheChewanater wrote:Why are you telling us instead of him?
Because there isn't a Coding rant thread.

Code: Select all

`enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}`
[he/him/his]

TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

While writing to a textbook publisher to complain about their book on web design, I included this at the end of my citations.

Code: Select all

`[[my name]]. My brain. May 1995.<ftp://192.168.1.-1/public/>`

I'm also tempted to put:

Code: Select all

`You.  Your brain.  `time`.</dev/null>`

But I won't.

http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

|Erasmus|
Branson
Posts: 2643
Joined: Tue Oct 30, 2007 7:53 am UTC
Location: Sydney, Australia
Contact:

Re: Coding: Fleeting Thoughts

phlip wrote:Well, I bitched at him about it (well, bitched politely) today, he said if/when it happens again, just go ahead and override it with my version, and tell him to run the script again.

Which is good enough, I think.

It will play havoc with revision logs though, won't it?

Like, make it impossible to see where any actual change was in both his change, and then your one which reverts it... :/

On another note, I want to kill a load of people at work this morning. Apparently it is a good idea to check a literal localised label string to check for a specific GUI element. This is after they decided to make it so these particular strings which are supposed to be localised, are not. At least the GM has already been told about that part, but relying on the fact they've already broken some things to make other things work is just silly.

elminster
Posts: 1560
Joined: Mon Feb 26, 2007 1:56 pm UTC
Location: London, UK, Dimensions 1 to 42.
Contact:

Re: Coding: Fleeting Thoughts

I had someone overwrite a good portion of my 4 hours of continuous coding before, because he saw svn conflicts and thought it was too confusing, so just overwrote it all. In the process managing to undo several critical fixes that I had done. Later on we had people complaining about it and I was just like... *sigh*.
Now I just ask them to commit first and/or make sure they've not got a big bulk of things that will conflict before hand. Sometimes conflicts can be a a bit ambiguous when 2 people are working on the same part of code.

lulzfish
Posts: 1214
Joined: Tue Dec 16, 2008 8:17 am UTC

Re: Coding: Fleeting Thoughts

elminster wrote:I had someone overwrite a good portion of my 4 hours of continuous coding before, because he saw svn conflicts and thought it was too confusing, so just overwrote it all. In the process managing to undo several critical fixes that I had done. Later on we had people complaining about it and I was just like... *sigh*.
Now I just ask them to commit first and/or make sure they've not got a big bulk of things that will conflict before hand. Sometimes conflicts can be a a bit ambiguous when 2 people are working on the same part of code.

I've had a lot of times in git where I just said to myself, "I have no fucking clue... I'm starting over".
Appending to my "list of ways that my 4-year CS curriculum has left me disappoint:"
"Did not learn the first thing about source control / versioning"

I tried to learn git on my own, but I can't commit to reading the manuals, so I just commit things periodically and hope I don't do anything fancy enough to accidentally break something.

urobythos
Posts: 34
Joined: Thu Mar 11, 2010 3:55 am UTC
Location: 3 AM

Re: Coding: Fleeting Thoughts

counting on coding

You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

urobythos wrote:counting on coding

find code/ | wc -l
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

hotaru
Posts: 1045
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: Coding: Fleeting Thoughts

hotaru wrote:

Code: Select all

`collatz x | odd x     = 3 * x + 1          | otherwise = x `div` 2`

Code: Select all

`collatz x = uncurry (!!) . first (:[3 * x + 1]) \$ divMod x 2`

for once i can use divMod and have code that's not a huge mess.

Code: Select all

`factorial = product . enumFromTo 1isPrime n = factorial (n - 1) `mod` n == n - 1`

Moo
Oh man! I'm going to be so rebellious! I'm gonna...
Posts: 6440
Joined: Thu Aug 16, 2007 3:15 pm UTC
Location: Beyond the goblin city
Contact:

Re: Coding: Fleeting Thoughts

I'm starting a project for a mutual acquaintance and have NO idea what to charge, as I've only ever worked in the UK and not here in South Africa and haven't been back long enough to know what going rates are. Googling "web development cost (only pages from South Africa)" gets me as much variation as googling "hooker rates" would, I imagine. Sigh. Time to pull a figure out of the air and watch his face for signals.
Proverbs 9:7-8 wrote:Anyone who rebukes a mocker will get an insult in return. Anyone who corrects the wicked will get hurt. So don't bother correcting mockers; they will only hate you.
Hawknc wrote:FFT: I didn't realise Proverbs 9:7-8 was the first recorded instance of "haters gonna hate"