Skip to main content
Saved characters
Source Link
ProgramFOX
  • 8.3k
  • 7
  • 45
  • 70

C#, 343343 309 characters

namespace System.Linq{class C{static void Main(){int n=int.Parse(Console.ReadLine());for(int i=0;i<=n;i++){var b=i+"";var c=b.Replace("6","9");Console.Write(b+(b.All(x=>x=='0'|x=='8'|x=='6'|x=='9')&(b.Contains('6')|b.Contains('9'))&!b.EndsWith("0")&!(b.Count(x=>x=='6')==b.Count(x=>x=='9')&new String(c.Reverse().ToArray())==c)?". ":" "));}}}}
  • Consists only of 0, 8, 6 and 9.
  • Has at least one 6 or 9.
  • Does not end with a zero.
  • Is not the same number when you rotate it:
    • If a number has an equal amount of 6s and 9s, and
    • if c = the number with all 6s replaces with 9s,
    • and reversed c == c,
    • then: the rotated number is the same as the number itself.
namespace System.Linq
{
    class C
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i <= n; i++)
            {
                var b = i + "";
                var c = b.Replace("6", "9");
                Console.Write(b +
                    (b.All(x => x == '0' | x == '8' | x == '6' | x == '9') &
                    (b.Contains('6') | b.Contains('9')) & !b.EndsWith("0") &
                    !(b.Count(x => x == '6') == b.Count(x => x == '9') &
                    new String(c.Reverse().ToArray()) == c) ? ". " : " "));
            }
        }
    }
}

C#, 343 characters

namespace System.Linq{class C{static void Main(){int n=int.Parse(Console.ReadLine());for(int i=0;i<=n;i++){var b=i+"";var c=b.Replace("6","9");Console.Write(b+(b.All(x=>x=='0'|x=='8'|x=='6'|x=='9')&(b.Contains('6')|b.Contains('9'))&!b.EndsWith("0")&!(b.Count(x=>x=='6')==b.Count(x=>x=='9')&new String(c.Reverse().ToArray())==c)?". ":" "));}}}}
  • Consists only of 0, 8, 6 and 9.
  • Has at least one 6 or 9.
  • Does not end with a zero.
  • Is not the same number when you rotate it:
    • If a number has an equal amount of 6s and 9s, and
    • if c = the number with all 6s replaces with 9s,
    • and reversed c == c,
    • then: the rotated number is the same as the number itself.
namespace System.Linq
{
    class C
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i <= n; i++)
            {
                var b = i + "";
                var c = b.Replace("6", "9");
                Console.Write(b +
                    (b.All(x => x == '0' | x == '8' | x == '6' | x == '9') &
                    (b.Contains('6') | b.Contains('9')) & !b.EndsWith("0") &
                    !(b.Count(x => x == '6') == b.Count(x => x == '9') &
                    new String(c.Reverse().ToArray()) == c) ? ". " : " "));
            }
        }
    }
}

C#, 343 309 characters

namespace System.Linq{class C{static void Main(){int n=int.Parse(Console.ReadLine());for(int i=0;i<=n;i++){var b=i+"";var c=b.Replace("6","9");Console.Write(b+(b.All(x=>x=='0'|x=='8'|x=='6'|x=='9')&!b.EndsWith("0")&!(b.Count(x=>x=='6')==b.Count(x=>x=='9')&new String(c.Reverse().ToArray())==c)?". ":" "));}}}}
  • Consists only of 0, 8, 6 and 9.
  • Does not end with a zero.
  • Is not the same number when you rotate it:
    • If a number has an equal amount of 6s and 9s, and
    • if c = the number with all 6s replaces with 9s,
    • and reversed c == c,
    • then: the rotated number is the same as the number itself.
namespace System.Linq
{
    class C
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i <= n; i++)
            {
                var b = i + "";
                var c = b.Replace("6", "9");
                Console.Write(b +
                    (b.All(x => x == '0' | x == '8' | x == '6' | x == '9') &
                    !b.EndsWith("0") &
                    !(b.Count(x => x == '6') == b.Count(x => x == '9') &
                    new String(c.Reverse().ToArray()) == c) ? ". " : " "));
            }
        }
    }
}
Source Link
ProgramFOX
  • 8.3k
  • 7
  • 45
  • 70

C#, 343 characters

Way too long, but anyway:

namespace System.Linq{class C{static void Main(){int n=int.Parse(Console.ReadLine());for(int i=0;i<=n;i++){var b=i+"";var c=b.Replace("6","9");Console.Write(b+(b.All(x=>x=='0'|x=='8'|x=='6'|x=='9')&(b.Contains('6')|b.Contains('9'))&!b.EndsWith("0")&!(b.Count(x=>x=='6')==b.Count(x=>x=='9')&new String(c.Reverse().ToArray())==c)?". ":" "));}}}}

How does it work? To add a period to the number, it must match the following requirements:

  • Consists only of 0, 8, 6 and 9.
  • Has at least one 6 or 9.
  • Does not end with a zero.
  • Is not the same number when you rotate it:
    • If a number has an equal amount of 6s and 9s, and
    • if c = the number with all 6s replaces with 9s,
    • and reversed c == c,
    • then: the rotated number is the same as the number itself.

The numbers are separated by a space.

Code with indentation:

namespace System.Linq
{
    class C
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i <= n; i++)
            {
                var b = i + "";
                var c = b.Replace("6", "9");
                Console.Write(b +
                    (b.All(x => x == '0' | x == '8' | x == '6' | x == '9') &
                    (b.Contains('6') | b.Contains('9')) & !b.EndsWith("0") &
                    !(b.Count(x => x == '6') == b.Count(x => x == '9') &
                    new String(c.Reverse().ToArray()) == c) ? ". " : " "));
            }
        }
    }
}