mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   FactorDB (https://www.mersenneforum.org/forumdisplay.php?f=94)
-   -   Broken aliquot sequences (https://www.mersenneforum.org/showthread.php?t=19737)

EdH 2020-05-16 11:47

[QUOTE=LaurV;545510]Nice job. Used to do all this procedure with the editor, in both pn2 and notepad++ you can mark/delete rectangular blocks (using shift+alt) and auto-number text lines. It is only a couple of cut/paste and takes a minute.[/QUOTE]
I'm not familiar with pn2, but Notepad++ needs Windows. (Wine has just notepad.) That would be a bigger effort for me. I wonder if gedit has this capability.

I'm thinking of expanding the script to do everything from just entering the broken sequence. Maybe I'll do that later, just for fun. Isn't really that big a call for it, is there? Are there more than three broken sequences?

EdH 2020-05-16 15:22

[QUOTE=EdH;545517]I'm thinking of expanding the script to do everything from just entering the broken sequence. Maybe I'll do that later, just for fun. Isn't really that big a call for it, is there? Are there more than three broken sequences?[/QUOTE]Here's a larger script that will take a sequence number and generate a local "fixed" .elf file for it. This works for me, but I can't guarantee success elsewhere:
[code]
#!/bin/bash
# Script to locally fix a broken Aliquot sequence
# Access to factordb.com is necessary
# aliqueit is necessary
# No error checking is performed
# Use at own risk

# Acquire sequence number, if not provided on command line
if [ ${#1} -lt 3 ]
then printf "Aliquot sequence: "
read sequence in
else
sequence=$1
fi

# Retrieve sequence.elf
echo "Retrieving $sequence.elf. . ."
wget -q -U Mozilla/5.0 "http://factordb.com/elf.php?seq=$sequence&type=1" -O alq_$sequence.elf

# Test sequence with aliqueit
./aliqueit $sequence -t >temp

# Acquire index of first invalid line
exec <"temp"
while read line
do
case $line in
"ERROR"*) index=${line:14};;
esac
done
colon=$(echo `expr index "$index" :`)
index=${index:0:colon-1}

# Truncate sequence.elf into temporary file
count=0
rm ${sequence}T 2>/dev/null
exec <"alq_${sequence}.elf"
while read line
do
if [ $count -lt $index ]
then echo "$line" >> ${sequence}T
fi
let count=${count}+1
done
rm alq_$sequence.elf
cp ${sequence}T alq_$sequence.elf

# Run aliqueit to create next index
./aliqueit $sequence -q >/dev/null

# Find new sequence from new index
newseq=$(tail -1 alq_$sequence.elf)
period=$(echo `expr index "$newseq" .`)
equals=$(echo `expr index "$newseq" =`)
newseq=${newseq:${period}+2:${equals}-${period}-4}
echo "$newseq"

# Retrieve new sequence.elf
echo "Retrieving $newseq.elf."
wget -q -U Mozilla/5.0 "http://factordb.com/elf.php?seq=$newseq&type=1" -O alq_$newseq.elf

# Splice the two sequences and renumber sequence.elf
rm temp.elf 2>/dev/null
count=0
exec <"${sequence}T"
while read line
do
period=$(echo `expr index "$line" .`)
echo "${count} ${line:$period-1}" >>temp.elf
let count=${count}+1
done
exec <"alq_$newseq.elf"
while read line
do
period=$(echo `expr index "$line" .`)
echo "${count} ${line:$period-1}" >>temp.elf
let count=${count}+1
done
rm alq_$sequence.elf
mv temp.elf alq_$sequence.elf

# Verify sequence .elf
./aliqueit $sequence -t
[/code]All valid factordb .elf files generate a warning in Aliqueit:
[code]
WARNING: @index ####: partial last line.[/code]This signals success.

Happy5214 2021-02-21 10:46

Aliquot sequence 1750944 has an error at index 1068.


All times are UTC. The time now is 12:00.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.