Timeline for Calculate prime gaps
Current License: CC BY-SA 3.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 17, 2020 at 9:04 | history | edited | CommunityBot |
Commonmark migration
|
|
Mar 13, 2014 at 0:38 | history | edited | Newbrict | CC BY-SA 3.0 |
added orion's changes
|
Mar 12, 2014 at 22:57 | comment | added | orion |
112. This one just keeps giving more. n=2;c=2;while p=$c;do perl -e\(1x$[++n]')=~/^(11+?)\1+$/&&exit 1'&&c=$n;((c-p>g))&&g=$[c-p]&&echo $p $c $g;done
|
|
Mar 12, 2014 at 22:23 | comment | added | orion |
How about 121? :) n=3;c=2;while :;do p=$c;perl -e\(1x$n')=~/^(11+?)\1+$/&&exit 1'&&c=$n;let n++;f=$[c-p];((f>g))&&g=$f&&echo $p $c $g;done and you could still squeeze out a bit more. Also, if you post a perl-only version, you may win :)
|
|
Mar 12, 2014 at 21:44 | history | edited | Newbrict | CC BY-SA 3.0 |
off by 1 fix
|
Mar 12, 2014 at 21:38 | comment | added | orion |
I'll just say it here. Use backtics instead of $(), p=$[c] actually works, ((f>g)) is shorter (nice to have so many alternative brackets), quotes around echo are unnecessary (inside perl too: $_ is fine, or just only print without arguments).
|
|
Mar 12, 2014 at 21:35 | comment | added | Newbrict | @orion for some reason your edit was rejected, can you re-edit? | |
S Mar 12, 2014 at 21:29 | history | edited | Newbrict | CC BY-SA 3.0 |
less bytes
|
Mar 12, 2014 at 21:29 | review | Suggested edits | |||
S Mar 12, 2014 at 21:29 | |||||
Mar 12, 2014 at 21:27 | comment | added | orion | Your environment maybe had predefined variables. | |
Mar 12, 2014 at 21:21 | comment | added | Newbrict | @orion, sorry for some reason it seemed to work once now it broke on my machine too, i reverted it to 167. I'll try to add some of your other suggestions | |
Mar 12, 2014 at 21:21 | comment | added | orion |
test -n $d returned true for an empty string. test -n "$d" was fine but longer. However, man page says -n is optional, and it turns out test $d was ok. And therefore [ $d ] too. And g=0 had to be initialized.
|
|
Mar 12, 2014 at 21:21 | history | edited | Newbrict | CC BY-SA 3.0 |
fixed my bug
|
Mar 12, 2014 at 21:11 | comment | added | orion |
Using regex's NP backtracking to completely circumvent any loops and control structures is pure perfection. However, test is protesting quite a lot, and it doesn't work for me. You could also use some let n++ and let f=c-p and replace test with [ . Or possibly test in (()) where you don't need $ or spaces.
|
|
Mar 12, 2014 at 20:37 | history | edited | Newbrict | CC BY-SA 3.0 |
#
|
Mar 12, 2014 at 20:18 | history | edited | Newbrict | CC BY-SA 3.0 |
I learned how to use strike
|
Mar 12, 2014 at 20:10 | history | answered | Newbrict | CC BY-SA 3.0 |