Jump to content

pseudo logic suggestions (Solved)


JohnOne
 Share

Recommended Posts

J1,

This is providing a distraction from the boring shit that I was working on...The solutions offered so far do not seem complete to me.

Please post your solution for comparison (learning) as I'm also coding something to solve this...

Incidentally, is it true that each part of the filename (before and after the "_") are the same length within one file but may vary from file to file?

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I have not done anything with it yet, been eating and watching a TV show. But I'm certain

that bit of logic will get me underway.

The two sides of _ are of varying length at their are no rules/pattern governing that.

With the code posted by bothose, it will give me the first true file it finds. I will then remove all instances of files

that are equal to the first part Or equal to the second, and loop it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

J1, we are all awash in a quagmire of uncertainties. When you're buried under an avalanche of snow the best to determine your orientation is to spit. If the spit dribbles into your eye then you're upside down.

Link to comment
Share on other sites

also bear in mind, my script returns all duplicates under the assumption that only the proper filename will be listed multiple times. So if there is a chance that these "wrong" numbers could end up having duplicates within the group you are evaluating....the quagmire expands.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

J1, we are all awash in a quagmire of uncertainties. When you're buried under an avalanche of snow the best to determine your orientation is to spit. If the spit dribbles into your eye then you're upside down.

haha

Some of us only have piss and dribble to look forward to, but I prefer mine down my chin.

EDIT:

Dribble that is.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

J1,

Given the following test data (from kaotibliss's post)

$a10[0]= "332333_14631"
$a10[1]= "88888_44444"
$a10[2]= "46588_44444"
$a10[3]= "33333_65788"
$a10[4]= "33333_11112"

Which would you say are good file names?

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

$a10[0]= "332333_14631"
$a10[1]= "88888_44444"
$a10[2]= "46588_44444"
$a10[3]= "33333_65788"
$a10[4]= "33333_11112"
$a10[5]= "46588_45723"

I have added [5]

which you can use to deduce a good file name.

You see it now?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

J1,

The good file name would be 46588_45723 and not 46588_44444 because 46588_44444 has dup last node?

Also,

Given

"123_321" (good)
"267_876" (good)
"12_98"  (good)
"2223_7881" (good)
"123_946"   (good)
"887_321" (bad)
"456_321" (bad)
"123_998" (good)

Is this correct?

kylomas

Edit: I see your dilema, there is nothing here to distinguish between 123_321 and 887_321....

Edit2: back to M23's assertion...to find bad files we have to uniquely id good files...

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

No, its good because both nodes are dupe.

Any other file containing either first or last node

are bad.

I'm working with this at the moment.

#include <File.au3>
#include <Array.au3>
$dir = @ScriptDir & ""
$good = $dir & "good"
$dump = $dir & "dump"
While Not @error
$FArray = _FileListToArray($dir, "*.lmi", 1)
$tmp = Work($FArray) ; the name of the first file found which should be good name
If FileExists($tmp) Then
  FileMove($dir & $tmp, $good & $tmp) ; if it is exist the move it
EndIf
$aTmp = StringSplit($tmp, "_", 3) ;these loops below get rid of other files that have either the first part or secong part in them
For $i = $FArray[0] To 1 Step -1
  If StringInStr($FArray[$i], $aTmp[0]) Then
   FileMove($dir & $FArray[$i], $dump & $FArray[$i], 8)
  EndIf
Next
For $i = $FArray[0] To 1 Step -1
  If StringInStr($FArray[$i], $aTmp[1]) Then
   FileMove($dir & $FArray[$i], $dump & $FArray[$i], 8)
  EndIf
Next
WEnd

Func Work($Array)
Local $column1[$Array[0] + 1]
Local $column2[$Array[0] + 1]
For $i = 0 To UBound($Array) - 1
  $Temp = StringSplit($Array[$i], "_")
  If @error Then ContinueLoop
  $column1[$i] = $Temp[1]
  $column2[$i] = $Temp[2]
Next
Local $FOUND = 0
For $k = UBound($column1) - 1 To 0 Step -1
  For $i = UBound($column1) - 1 To 0 Step -1
   If $column1[$k] = $column1[$i] And $i <> $k Then $FOUND = 1
  Next
  If $FOUND = 1 Then
   $FOUND = 0
  Else
   _ArrayDelete($column1, $k)
  EndIf
Next
For $k = UBound($column2) - 1 To 0 Step -1
  For $i = UBound($column2) - 1 To 0 Step -1
   If $column2[$k] = $column2[$i] And $i <> $k Then $FOUND = 1
  Next
  If $FOUND = 1 Then
   $FOUND = 0
  Else
   _ArrayDelete($column2, $k)
  EndIf
Next
If Not IsArray($column1) Or Not IsArray($column2) Then
  Return SetError(1)
EndIf
$Answer = $column1[0] & "_" & $column2[0]
Return $Answer
EndFunc   ;==>Work

EDIT: tags are a pain.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

No, its good because both nodes are dupe.

That's where I was (quickly) trying to go with my 2 minute code. Get a list of all 1st nodes that were duped, get a list of all 2nd nodes that were duped

Then start piecing them together looking for filenames. :)

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

J1,

This code will create an array of all files that are good. Without further qualifying criteria I cannot figure out how to determine which are "good" files from the list of "might be good" files.

@koatkbliss - Seems like such a trivial thing, at first glance...right...

;
; hammer and tongs method
;
#include <array.au3>
local $a10[10]
local $a20[ubound($a10)][2]
$a10[0]= "332333_14631"
$a10[1]= "88888_44444"
$a10[2]= "46588_44444"
$a10[3]= "33333_65788"
$a10[4]= "33333_11112"
$a10[5]= "46588_45723"
;---------------------------------------
; winnow out files that have to be good
;---------------------------------------
; split file name to 2x array
for $i = 0 to ubound($a10) - 1
if stringlen($a10[$i]) = 0 then continueloop
$a30 = stringsplit($a10[$i],'_',2)
$a20[$i][0] = $a30[0]
$a20[$i][1] = $a30[1]
Next
; find unique first nodes - iterate each element of array through itself - save dups to string
local $save_ele, $save_dups
for $i = 0 to ubound($a20) - 1
$save_ele = $a20[$i][0]
for $j = 0 to ubound($a20) - 1
  if $j <> $i and $a20[$j][0] == $save_ele then $save_dups &= $a20[$j][0] & 0x0
Next
next
; find unique second nodes - iterate each element of array through itself - save dups to string
for $i = 0 to ubound($a20) - 1
$save_ele = $a20[$i][1]
for $j = 0 to ubound($a20) - 1
  if $i <> $j and $a20[$j][1] == $save_ele then $save_dups &= $a20[$j][1] & 0x0
Next
next
; run through array and blank all dups
$a30 = stringsplit($save_dups,0x0,2)
for $i = 0 to ubound($a30) - 1
for $j = 0 to ubound($a20) - 1
  if $a20[$j][0] = $a30[$i] then
   $a20[$j][0] = ''
   $a20[$j][1] = ''
  endif
  if $a20[$j][1] = $a30[$i] then
   $a20[$j][0] = ''
   $a20[$j][1] = ''
  endif
next
next
_arraydisplay($a20)

I keep thinking that some clever SQL might do this nicely, however, I don't have the skills for this.

Good Luck!!!

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

J1,

One last thing (I just washed my keyboard with a large coffee).

Does this make sense: if each node has dups than the entry that contains either node, where one of the nodes is unique, is the good file?

Gotta go some of my keys are on coffee auto-repeat...

Kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I'm not sure I follow, but I think you might be overcomplicating it (if that's possible).

Given that this is a good file...

123_456

Then if another file begins with 123, then its opposite end will be totally unique.

If a file ends in 456 then its opposite end will be totally unique.

The only exception to this rule, is the good file, it is the only file where

both ends have dupes.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Why don't you ask Marilyn Vos Savant?

So if a good file has 123_456 then any file that exists which has either the 123 or the 456 will considered a bad file?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...