Skip to main content
deleted 2 characters in body
Source Link

JavaScript - 168 129 119 113 111 109108

F=n=>{for(;~n;n--){r='';for(c of""+n)r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[^6890][1-57]/.test(r)&&n%10?n+".":n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){
    r='';for(c of ""+n)r=(c-6?c-9?c:6:9)+r; // rotate
    console.log( // output, new-line is added
        // original number, and
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        r-n && !/[^6890][1-57]/.test(r) && n%10
           ?n+".":n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

JavaScript - 168 129 119 113 111 109

F=n=>{for(;~n;n--){r='';for(c of""+n)r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[^6890]/.test(r)&&n%10?n+".":n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){
    r='';for(c of ""+n)r=(c-6?c-9?c:6:9)+r; // rotate
    console.log( // output, new-line is added
        // original number, and
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        r-n && !/[^6890]/.test(r) && n%10
           ?n+".":n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

JavaScript - 168 129 119 113 111 108

F=n=>{for(;~n;n--){r='';for(c of""+n)r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[1-57]/.test(r)&&n%10?n+".":n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){
    r='';for(c of ""+n)r=(c-6?c-9?c:6:9)+r; // rotate
    console.log( // output, new-line is added
        // original number, and
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        r-n && !/[1-57]/.test(r) && n%10
           ?n+".":n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

deleted 1 character in body
Source Link

JavaScript - 168 129 119 113 111 110109

F=n=>{for(;~n;n--){r='';for(c of n+""of""+n)r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[^6890]/.test(r)&&n%10?n+".":n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){
    r='';for(c of n+""""+n)r=(c-6?c-9?c:6:9)+r; // rotate
    console.log( // output, new-line is added
        // original number, and
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        r-n && !/[^6890]/.test(r) && n%10
           ?n+".":n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

JavaScript - 168 129 119 113 111 110

F=n=>{for(;~n;n--){r='';for(c of n+"")r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[^6890]/.test(r)&&n%10?n+".":n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){
    r='';for(c of n+"")r=(c-6?c-9?c:6:9)+r; // rotate
    console.log( // output, new-line is added
        // original number, and
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        r-n && !/[^6890]/.test(r) && n%10
           ?n+".":n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

JavaScript - 168 129 119 113 111 109

F=n=>{for(;~n;n--){r='';for(c of""+n)r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[^6890]/.test(r)&&n%10?n+".":n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){
    r='';for(c of ""+n)r=(c-6?c-9?c:6:9)+r; // rotate
    console.log( // output, new-line is added
        // original number, and
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        r-n && !/[^6890]/.test(r) && n%10
           ?n+".":n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

deleted 25 characters in body
Source Link

JavaScript - 168 129 119 113 111 108110

Expects n to be already defined

F=n=>{for(;~n;n--){r='';for(c of i=n+""n+"")r=(c-6?c-9?c:6:9)+r;console.log(n+(r-i&&n&&!/[^6890]/.test(ir)&&n%10?"n+".":"")n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){ // 'n' is expected as global variable
    r='';for(c of i=n+""n+"")r=(c-6?c-9?c:6:9)+r; // rotate, and prepare i as string
    console.log( // output, new-line is added
        // original number, and
        n
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        + (r-in && !/[^6890]/.test(ir) && n%10 
           ?"n+".":"")n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

JavaScript - 168 129 119 113 111 108

Expects n to be already defined

for(;~n;n--){r='';for(c of i=n+"")r=(c-6?c-9?c:6:9)+r;console.log(n+(r-i&&!/[^6890]/.test(i)&&n%10?".":""))}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

for(;~n;n--){ // 'n' is expected as global variable
    r='';for(c of i=n+"")r=(c-6?c-9?c:6:9)+r; // rotate, and prepare i as string
    console.log( // output, new-line is added
        // original number, and
        n
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        + (r-i && !/[^6890]/.test(i) && n%10 
           ?".":"")
    )}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions

JavaScript - 168 129 119 113 111 110

F=n=>{for(;~n;n--){r='';for(c of n+"")r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[^6890]/.test(r)&&n%10?n+".":n)}}

4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806. 9886 9889.

Or readable version:

F=n=>{for(;~n;n--){
    r='';for(c of n+"")r=(c-6?c-9?c:6:9)+r; // rotate
    console.log( // output, new-line is added
        // original number, and
        // append dot only if number is different than its rotated version and no un-rotatable digit is present and there is no zero at the end
        r-n && !/[^6890]/.test(r) && n%10
           ?n+".":n
    )}}

I am not very happy with the regex, any ideas?

Edit: Learned neat trick with ~ and for (... of ...) from @edc65
Edit2: Reorganized conditions
Edit3: applied suggestions by @edc65

edited body
Source Link
ProgramFOX
  • 8.3k
  • 7
  • 45
  • 70
Loading
added 54 characters in body
Source Link
Loading
edited body
Source Link
Loading
deleted 19 characters in body
Source Link
Loading
added 1 character in body
Source Link
Loading
Learned neat trick with `~` and `for (... of ...)` from @edc65
Source Link
Loading
Source Link
Loading