Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lee Bow
May 11, 2008

by Fistgrrl
nevermind, I couldn't fix the issue. I cannot find the forum padding size adjustment in the php.

Adbot
ADBOT LOVES YOU

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug

tk posted:

code:
var homework =
	from x in Enumerable.Range(1, 200)
	from y in Enumerable.Range(1, 200)
	from h in Enumerable.Range(1, 200)
	where x * x + y * y == h * h
	select new {x, y, h};
Oh dear. What language is this?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Linq in C#.

Chuu
Sep 11, 2004

Grimey Drawer

Scaevolus posted:

Subtext

Ah, drat. Is there some software out there that'll help keep track of/optimize extremely messy truth tables, so I can translate them back into code?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Why not just use Karnaugh maps?

digital-entropy
Apr 21, 2002

On the application I work at at work we display to the user a tree of data in the following form:

code:
- root node
 - a child of the root
 - another child of the root
  - a grandchild of the root
  - another granchild of the root
 - another child of the root
  - another grandchild of the root
   - great-grandchild of the root
... and so on.

The only restriction is that each node in the tree has at most one parent. We allow the user to filter nodes based on a few things, but for the sake of this example I'll restrict it to the node label.

When the user enters a keyword, we show the full path to all nodes that contain the keyword. If I enter "root node", the following would be output:

- root node

If I enter "a child", you would expect this:

- root node
- a child of the root node

The question is then what is the quickest way to parse the tree and determine which nodes to show? We know that once a node is in we do not need to reevaluate it for inclusion, as it doesn't matter if the node itself matches the keyword or if it is one node in one path to a node that did match.

The first pass at this I simply did a recursive depth-first pass at the tree, but this meant that there were quite a few nodes that were repeatedly evaluated which is unnecessary. The second pass does the following:

  • Walk the tree and return all leaf nodes
  • For each leaf node:
    • If node was previously marked as included, return.
    • Otherwise, evaluate node for inclusion. If it is included, flag it and all of its ancestors as included.
    • Finally, f node is not included, recursively evaluate parent

At the end of this, each node in the tree should be flagged if it or one of its descendants was included as a result of the search.

This works, and reasonably well, but I was curious about two things. First, is there a name for this? "bottom-up traversal" didn't return many results. Secondly, is there a better way?

digital-entropy fucked around with this message at 06:17 on Mar 23, 2009

Fagballs
Feb 20, 2009
I just started messing with VB 2008. Would someone recommend a book or an online tutorial for the absolute newbie? TIA

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
Do you have a special reason for starting with that, or do you just like to learn useless things?

Fagballs
Feb 20, 2009

Mithaldu posted:

Do you have a special reason for starting with that, or do you just like to learn useless things?

No idea. I'd like to learn something useful, my company runs all their servers and clients on windows platforms. Any suggestions for what to start out with otherwise?

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

buttweed posted:

No idea. I'd like to learn something useful, my company runs all their servers and clients on windows platforms. Any suggestions for what to start out with otherwise?
VB is the devil. C# is nice; learn that instead.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
Oh, that's a bit different then. You sounded like the typical high school "imma go learn sum coding" dude.

I guess it depends mostly on what you're trying to do. If you really want to do GUI stuff, .NET C# is probably a good place to start. If you feel more like doing command line stuff, ActivePerl plus a copy of Perl Best Practices, or alternatively Python.

Unless of course your company's applications are written in Basic, in which case that might not be that bad a place to start.

Fagballs
Feb 20, 2009
I'm going to try C# then, Thanks.

huge sesh
Jun 9, 2008

digital-entropy posted:

This works, and reasonably well, but I was curious about two things. First, is there a name for this? "bottom-up traversal" didn't return many results. Secondly, is there a better way?

It's not really a tree traversal unless you consider the internal nodes. Preorder, inorder and postorder traversals only only vary in where they distribute internal nodes in the traversal order.

Also, are you really sure that each node has at most one parent? If so, your recursive DFS algorithm should never be evaluating any node more than once and in your current algorithm you wouldn't need to check leaf nodes to see if they've already been included.

In terms of optimization: One easy step would be to keep all your leaf nodes in a linked list, so you don't need to traverse the tree to get at all of them. However, doing this throws out the some of the advantages of using a tree structure--is it possible to evaluate internal nodes to check if ALL of their descendants can't possibly be included? If so, you can skip big chunks of your tree all at once.

BoneMonkey
Jul 25, 2008

I am happy for you.

I really hope this is the right place to ask something like this.

Ok this is gonna be a bit of an odd request, but hell it's worth a shot.

I need a new place to live, (finished uni back with the parents time to move on) and I'm looking for a programmer (in Europe (England preferred)) that really into doing the whole indie startup/bedroom game dev thing. That either has a spare room/sofa I can crash on. Or is into finding somewhere to flat share. I can pay rent,food etc.

As for me I'm 23, male, white and nerdy and I currently live in Hampshire, England and I'm an artist.
Skillset includes
Photoshop
mudbox
3d studio max

here is some of my more current work

http://www.artbytom.co.uk/junk/raider1.jpg
http://www.artbytom.co.uk/work/tuesdaythrash.jpg
http://www.artbytom.co.uk/junk/Fmvtest.jpg
http://www.artbytom.co.uk/junk/Fmvtest2.jpg
http://www.artbytom.co.uk/junk/street1.jpg
http://www.artbytom.co.uk/junk/nebula2.jpg
http://www.artbytom.co.uk/junk/ladysketch.jpg

and my website (slightly older stuff) can be found at
https://www.artbytom.co.uk

So if you are interested, please e-mail me at shockcomics@hotmail.com

So yeah, odd request, but I hope something comes from this as it would be one awesome adventure.

STOCKPILING TaB
Mar 4, 2009

by The Finn

BoneMonkey posted:

I really hope this is the right place to ask something like this.

Ok this is gonna be a bit of an odd request, but hell it's worth a shot.

I need a new place to live, (finished uni back with the parents time to move on) and I'm looking for a programmer (in Europe (England preferred)) that really into doing the whole indie startup/bedroom game dev thing. That either has a spare room/sofa I can crash on. Or is into finding somewhere to flat share. I can pay rent,food etc.

As for me I'm 23, male, white and nerdy and I currently live in Hampshire, England and I'm an artist.
Skillset includes
Photoshop
mudbox
3d studio max

here is some of my more current work

http://www.artbytom.co.uk/junk/raider1.jpg
http://www.artbytom.co.uk/work/tuesdaythrash.jpg
http://www.artbytom.co.uk/junk/Fmvtest.jpg
http://www.artbytom.co.uk/junk/Fmvtest2.jpg
http://www.artbytom.co.uk/junk/street1.jpg
http://www.artbytom.co.uk/junk/nebula2.jpg
http://www.artbytom.co.uk/junk/ladysketch.jpg

and my website (slightly older stuff) can be found at
https://www.artbytom.co.uk

So if you are interested, please e-mail me at shockcomics@hotmail.com

So yeah, odd request, but I hope something comes from this as it would be one awesome adventure.

Thanks for asking your question. Send me a PM and we can take this offline.

blorpy
Jan 5, 2005

Can I commission a drawing of Johnny Five Aces?

BoneMonkey
Jul 25, 2008

I am happy for you.

ENSIGN ECCHI posted:

Thanks for asking your question. Send me a PM and we can take this offline.

You are kinda un-pm-able so you might need to fix that first.
That or you're having me on.


Chain Chomp posted:

Can I commission a drawing of Johnny Five Aces?

Yes, Pm me about what you want done.

BoneMonkey fucked around with this message at 13:18 on Mar 24, 2009

cr0y
Mar 24, 2005



Does anyone know if there is an easy way to encrypt large files in php with a public key?

1337JiveTurkey
Feb 17, 2005

Encrypt it with a one-off symmetric key, then encrypt that key.

shodanjr_gr
Nov 20, 2007
Does VS2008 have an option to track down unused variables in ones code?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

cr0y posted:

Does anyone know if there is an easy way to encrypt large files in php with a public key?

Please don't write your own encryption software, you'll do it wrong. Find some library that complies with RFC 3852.

csammis
Aug 26, 2003

Mental Institution

shodanjr_gr posted:

Does VS2008 have an option to track down unused variables in ones code?

If you're using C#, the compiler emits a warning when a variable is unused. I don't know off the top of my head which warning level causes the C++ compiler to start emitting unused variable warnings, but you can fiddle around with it in the project properties under C/C++ -> General.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

csammis posted:

If you're using C#, the compiler emits a warning when a variable is unused. I don't know off the top of my head which warning level causes the C++ compiler to start emitting unused variable warnings, but you can fiddle around with it in the project properties under C/C++ -> General.

In 2005 it's /W3

tef
May 30, 2004

-> some l-system crap ->

ShoulderDaemon posted:

Please don't write your own encryption software, you'll do it wrong. Find some library that complies with RFC 3852.

This may help: http://www.google.com/search?q=php+gpg

Crackbone
May 23, 2003

Vlaada is my co-pilot.

Retard vb in excel question:

I need a routine to:

Find the last row of data in column "F" in a workbook
Check each row in column "F" for character length
If the cell has more than 30 characters, trim it to 30

This is the script I copied off a website:
code:
Sub thirty()
     
     ' Get rownumber of lastrow of data Col F
    lastrow = Range("f65536").End(xlUp).Row
     
     ' Check row 1 to last row #, Col F
    For i = 1 To lastrow
         ' If longer than 30 chars
        If Len(Cells(i, 1)) > 30 Then
             ' Cut to 55 chars
            Cells(i, 1) = Left(Cells(i, 1), 30)
        End If
         ' Not longer than 30 - get next row
    Next i
     
End Sub
Doesn't show any signs of working when I run it though. Any ideas of what's wrong?

Fruit Smoothies
Mar 28, 2004

The bat with a ZING
I have 12 categories that need to be placed doubled up in 6 boxes. However, some of the categories can't pair up. Kinda like "cold" and "hot" can't go together. How would I go writing a program that can solve this type of combination problem, but apply rules to it? Is there a program that exists, or easy way of doing this without a computer program?

Cheers.

baquerd
Jul 2, 2007

by FactsAreUseless

Fruit Smoothies posted:

I have 12 categories that need to be placed doubled up in 6 boxes. However, some of the categories can't pair up. Kinda like "cold" and "hot" can't go together. How would I go writing a program that can solve this type of combination problem, but apply rules to it? Is there a program that exists, or easy way of doing this without a computer program?

Cheers.

Unless they need to be randomized, just place them manually?

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

quadreb posted:

Unless they need to be randomized, just place them manually?

There are 66 combinations of 12 categories in 6 boxes. To give you an idea, each category can be paired with only 2-3 others, and there can be no overlap.

Think of it like adjectives: hot, cold, wet, nice, sharp, blunt.

The issue with manual pairing, is you nearly always up with (at least) two at the end that don't fit, and you don't know where to make a change within the couples.

If I could do it manually, I would.

EDIT:

EG:

Nice, hot
Blunt, cold,
Which leaves sharp and wet.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

If you don't mind getting your hands dirty with a backtracking logic language like Prolog, this sounds like a good constraint programming problem.

baquerd
Jul 2, 2007

by FactsAreUseless

Fruit Smoothies posted:

There are 66 combinations of 12 categories in 6 boxes. To give you an idea, each category can be paired with only 2-3 others, and there can be no overlap.

Think of it like adjectives: hot, cold, wet, nice, sharp, blunt.

The issue with manual pairing, is you nearly always up with (at least) two at the end that don't fit, and you don't know where to make a change within the couples.

If I could do it manually, I would.

EDIT:

EG:

Nice, hot
Blunt, cold,
Which leaves sharp and wet.

Start with one, place all legal pairings.
Go to the next one, place all legal pairings not already used.
etc.

It's time consuming, but it'll get everything.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Fruit Smoothies posted:

I have 12 categories that need to be placed doubled up in 6 boxes. However, some of the categories can't pair up. Kinda like "cold" and "hot" can't go together. How would I go writing a program that can solve this type of combination problem, but apply rules to it? Is there a program that exists, or easy way of doing this without a computer program?

Cheers.

Here's a horrible ineffecient solution which should work.

If we need to assign 0 elements to n boxes, there is trivially only a single valid assignment: n empty boxes.

If we need to assign j > 0 elements to n boxes, then:
  • First, find all valid assignments of j-1 elements to n boxes (ignoring the last element, e).
  • For each such assignment a, consider each of the numbers i = 1 to n.
  • If e can be placed in the ith box of a without conflict, then yield that as an assignment of j elements to n boxes.
This method will generate all the valid assignments; it is essentially backtracking by using lists.

Here's an implementation:
code:
import Control.Monad
import Data.List

data Element
  = Cold
  | Hot
  | Black
  | White
  | Small
  | Large
  | Cat
  | Dog
  deriving (Eq, Show)

elementRules :: Element -> [Element] -> [()]
elementRules e box = do
  guard $ not $ e == Cold && Hot `elem` box
  guard $ not $ e == Hot && Cold `elem` box
  guard $ not $ e == Black && White `elem` box
  guard $ not $ e == White && Black `elem` box
  guard $ not $ e == Small && Large `elem` box
  guard $ not $ e == Large && Small `elem` box
  guard $ not $ e == Cat && Dog `elem` box
  guard $ not $ e == Dog && Cat `elem` box

assign :: [Element] -> [[Element]] -> [[[Element]]]
assign [] boxes = return boxes
assign (e:elems) boxes = do
  boxes <- assign elems boxes
  i <- msum $ map return $ [0 .. length boxes - 1]
  let box = boxes !! i
  elementRules e box
  return $ take i boxes ++ [e:box] ++ drop (i + 1) boxes

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

ShoulderDaemon posted:

Here's a horrible ineffecient solution which should work.

If we need to assign 0 elements to n boxes, there is trivially only a single valid assignment: n empty boxes.

If we need to assign j > 0 elements to n boxes, then:
  • First, find all valid assignments of j-1 elements to n boxes (ignoring the last element, e).
  • For each such assignment a, consider each of the numbers i = 1 to n.
  • If e can be placed in the ith box of a without conflict, then yield that as an assignment of j elements to n boxes.
This method will generate all the valid assignments; it is essentially backtracking by using lists.

Here's an implementation:

Thanks a lot. I'm downloading haskell to play with now.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
It's NP-complete with a pretty straightforward reduction from the partition problem. That said, you can reduce to the partition problem and get a much better constant factor.

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

ShoulderDaemon posted:

Here's an implementation:

Forgive my ignorance, but how do I access the result of this? I've done a few tutorials just now, but they involve printing to the screen, or saving to a file.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Fruit Smoothies posted:

Forgive my ignorance, but how do I access the result of this? I've done a few tutorials just now, but they involve printing to the screen, or saving to a file.

To be perfectly honest, I hadn't bothered to test that before posting it, but it looks right. You'll call it as assign elements boxes where elements is a list of elements to assign, such as [Hot, Cold, White], and boxes is a list of empty boxes to store in to, such as [ [], [] ]. The result is a list of lists of boxes, such as [ [ [Hot, White], [Cold] ], [ [Hot], [Cold, White] ] ]. You can play with this in ghci.

But this is really terrible code to try to learn Haskell from.

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

ShoulderDaemon posted:

To be perfectly honest, I hadn't bothered to test that before posting it, but it looks right. You'll call it as assign elements boxes where elements is a list of elements to assign, such as [Hot, Cold, White], and boxes is a list of empty boxes to store in to, such as [ [], [] ]. The result is a list of lists of boxes, such as [ [ [Hot, White], [Cold] ], [ [Hot], [Cold, White] ] ]. You can play with this in ghci.

But this is really terrible code to try to learn Haskell from.

EDIT: Nevermind, cheers.

Fruit Smoothies fucked around with this message at 01:06 on Mar 30, 2009

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Fruit Smoothies posted:

Isn't elements from your expression assign elements boxes simply the variable Element? Or is Element the type here?

Element is a type.

And that use of boxes is correct.

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

ShoulderDaemon posted:

Element is a type.

And that use of boxes is correct.

Thanks for the help. Now I need to decide whether to be a script kiddy and use this implementation, or to try and understand it, and translate into pascal.

huge sesh
Jun 9, 2008

Fruit Smoothies posted:

Thanks for the help. Now I need to decide whether to be a script kiddy and use this implementation, or to try and understand it, and translate into pascal.

I don't think you really want to try to implement the logic backend that Haskell has in Pascal.

Adbot
ADBOT LOVES YOU

Fruit Smoothies
Mar 28, 2004

The bat with a ZING

ShoulderDaemon posted:

Element is a type.

And that use of boxes is correct.

If you do it with 12 items, and 6 boxes, the program goes into a seemingly infinite loop. I know there can't be that many combinations.

Edit: It seems like the program wants to put more than two things in a box.

Fruit Smoothies fucked around with this message at 02:04 on Mar 30, 2009

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply