{
  "source_file": "0930",
  "source_platform": "Dev.to",
  "author": "amananandrai",
  "title_listed": "Solving the mystery of 12.02.2021 !!",
  "keywords": "",
  "domain": "文本处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://dev.to/amananandrai/solving-the-mystery-of-12-02-2021-498e",
  "publish_date": "2021-02-12",
  "corpus_stage": "",
  "notes": "",
  "id": "2c808ada50a3",
  "collected_at": "2026-10-02T14:02:27",
  "title": "Solving the mystery of 12.02.2021 !! - DEV Community",
  "body_markdown": "We come across symmetry on a daily basis in our lives in many different ways, in both the natural and man-made world. Symmetry possesses the magic power of drawing our attention. Most of us value and enjoy experiencing symmetry both visually and mentally because it conveys a sense of aesthetic balance, beauty, equality, and evenness.\nToday's date is\n\"12-02-2021\"\nwhich is unique in its own right because it is one of the 12 palindromic dates of the 21st century. If we see the date in\nDD-MM-YYYY\nformat it is the same sequence of numbers if we see it in forward or backward way. Thus we can see that palindromes are also possessing symmetry.\nA palindrome is a symmetric word, phrase, number, or another sequence of units that reads the same forward and backward.\nSome interesting examples of sentences that are palindromic are -\n\"Never odd or even\"\n,\n\"No, it is opposition\"\n,\n\"No lemons, no melon\"\n,\n\"Rats live on no evil star\"\n, and\n\"Rise to vote, Sir\"\n.\nIn computer programming, the program to find whether a string or number is palindrome or not is very common. It is one of the first problems taught to new learners as it explains the concept of conditional statements like if-else and for and while loops to the beginners.\nIn this post, I will try to write programs in some famous programming languages to solve the problem of checking whether a number is a palindrome or not.\nC\nIn C language the code for finding whether a number is a palindrome or not is given below.\n#include\n<stdio.h>\nint\nmain\n(\nvoid\n)\n{\nint\nn\n,\nreverse\n=\n0\n,\nrem\n,\noriginal\n;\nprintf\n(\n\"Enter a number: \"\n);\nscanf\n(\n\"%d\"\n,\n&\nn\n);\noriginal\n=\nn\n;\n// reversing a number and saving it in variable reverse\n// find the remainder with 10 and add it to reverse and each step multiply by 10\n// divide the number by 10 until it is 0\nwhile\n(\nn\n!=\n0\n)\n{\nrem\n=\nn\n%\n10\n;\nreverse\n=\nreverse\n*\n10\n+\nrem\n;\nn\n/=\n10\n;\n}\n// checking condition for palindrome i.e. if orignal and reverse are equal\nif\n(\noriginal\n==\nreverse\n)\nprintf\n(\n\"%d is a palindrome.\"\n,\noriginal\n);\nelse\nprintf\n(\n\"%d is not a palindrome.\"\n,\noriginal\n);\nreturn\n0\n;\n}\nEnter fullscreen mode\nExit fullscreen mode\nC++\nIn C++ the code is similar to C with difference only in taking the input and printing output.\n#include\n<iostream>\nusing\nnamespace\nstd\n;\nint\nmain\n()\n{\nint\nn\n,\nreverse\n=\n0\n,\nrem\n,\noriginal\n;\ncout\n<<\n\"Enter a number: \"\n;\ncin\n>>\nn\n;\noriginal\n=\nn\n;\n// reversing a number and saving it in variable reverse\n// find the remainder with 10 and add it to reverse and each step multiply by 10\n// divide the number by 10 until it is 0\nwhile\n(\nn\n!=\n0\n)\n{\nrem\n=\nn\n%\n10\n;\nreverse\n=\nreverse\n*\n10\n+\nrem\n;\nn\n/=\n10\n;\n}\n// checking condition for palindrome i.e. if orignal and reverse are equal\nif\n(\noriginal\n==\nreverse\n)\ncout\n<<\noriginal\n<<\n\" is a palindrome.\"\n<<\nendl\n;\nelse\ncout\n<<\noriginal\n<<\n\" is not a palindrome.\"\n<<\nendl\n;\nreturn\n0\n;\n}\nEnter fullscreen mode\nExit fullscreen mode\nJava\nThe code in Java is given below the logic is the same as mentioned above in the case of C and C++.\nimport\njava.io.*\n;\nimport\njava.util.Scanner\n;\nclass\nPalindrome\n{\npublic\nstatic\nvoid\nmain\n(\nString\nargs\n[]){\nint\nrem\n,\nreverse\n=\n0\n,\noriginal\n;\nint\nn\n;\nSystem\n.\nout\n.\nprintln\n(\n\"Enter the number: \"\n);\nScanner\ns\n=\nnew\nScanner\n(\nSystem\n.\nin\n);\nn\n=\ns\n.\nnextInt\n();\noriginal\n=\nn\n;\nwhile\n(\nn\n>\n0\n){\nrem\n=\nn\n%\n10\n;\nreverse\n=(\nreverse\n*\n10\n)+\nrem\n;\nn\n=\nn\n/\n10\n;\n}\nif\n(\nreverse\n==\noriginal\n)\nSystem\n.\nout\n.\nprintln\n(\noriginal\n+\n\" is a palindrome number \"\n);\nelse\nSystem\n.\nout\n.\nprintln\n(\noriginal\n+\n\" is not a palindrome number\"\n);\n}\n}\nEnter fullscreen mode\nExit fullscreen mode\nPython\nThe code in Python is simpler as there are less overheads for import and input-output operations.\nprint\n(\n\"\nEnter a number\n\"\n)\nn\n=\nint\n(\ninput\n())\noriginal\n=\nn\nrem\n,\nreverse\n=\n0\n,\n0\nwhile\n(\nn\n!=\n0\n):\nrem\n=\nn\n%\n10\nreverse\n=\n(\nreverse\n*\n10\n)\n+\nrem\nn\n=\nn\n//\n10\nif\nreverse\n==\noriginal\n:\nprint\n(\noriginal\n,\n\"\nis a palindrome number\n\"\n)\nelse\n:\nprint\n(\noriginal\n,\n\"\nis not a palindrome number\n\"\n)\nEnter fullscreen mode\nExit fullscreen mode\nIf we treat the input as a string and use a string splicing method of python the code becomes much more smaller.\nprint\n(\n\"\nEnter a number\n\"\n)\nn\n=\ninput\n()\nreverse\n=\nn\n[::\n-\n1\n]\nif\nreverse\n==\nn\n:\nprint\n(\nn\n,\n\"\nis a palindrome number\n\"\n)\nelse\n:\nprint\n(\nn\n,\n\"\nis not a palindrome number\n\"\n)\nEnter fullscreen mode\nExit fullscreen mode\nPerl\nA similar program in Perl would look like this\nprint\n\"\nEnter a number:\n\";\n$n\n=<\nSTDIN\n>\n;\n$original\n=\n$n\n;\n$reverse\n=\n0\n;\nwhile\n(\n$n\n>\n0\n)\n{\n$rem\n=\n$n\n%\n10\n;\n$reverse\n=\n(\n$reverse\n*\n10\n)\n+\n$rem\n;\n$n\n=\nint\n(\n$n\n/\n10\n);\n}\nif\n(\n$original\n==\n$reverse\n)\n{\nprint\n\"\n$original\nis palindrome\n\\n\n\";\n}\nelse\n{\nprint\n\"\n$original\nis not palindrome\n\\n\n\";\n}\nEnter fullscreen mode\nExit fullscreen mode\nRuby\nThe program in Ruby to check whether a given number is palindrome or not is given below.\nputs\n\"Enter the number\"\nnum\n=\ngets\n.\nchomp\n.\nto_i\noriginal\n=\nnum\nreverse\n=\n0\nwhile\nnum!\n=\n0\nrem\n=\nnum\n%\n10\nnum\n=\nnum\n/\n10\nreverse\n=\nreverse\n*\n10\n+\nrem\nend\nif\n(\noriginal\n==\nreverse\n)\nputs\n\"\n#{\noriginal\n}\nis a palindrome\"\nelse\nputs\n\"\n#{\noriginal\n}\nis not a palindrome\"\nend\nEnter fullscreen mode\nExit fullscreen mode\nA code in which the number is converted to string and then reversed and then converted back to integer and this reversed number is compared with original is given below\nputs\n\"Enter the number\"\nnum\n=\ngets\n.\nchomp\n.\nto_i\nif\n(\nnum\n.\nto_s\n.\nreverse\n.\nto_i\n==\nnum\n)\nputs\n\"\n#{\nnum\n}\nis a palindrome\"\nelse\nputs\n\"\n#{\nnum\n}\nis not a palindrome\"\nend\nEnter fullscreen mode\nExit fullscreen mode\nHope the beginners got an idea about how to use conditional statements and loops in various languages and to check palindrome numbers using this article and it was beneficial for them.",
  "metadata": {
    "title": "Solving the mystery of 12.02.2021 !! - DEV Community",
    "description": "We come across symmetry on a daily basis in our lives in many different ways, in both the natural and... Tagged with beginners, programming, tutorial.",
    "keywords": "beginners, programming, tutorial, software, coding, development, engineering, inclusive, community",
    "author": null,
    "og:type": "article",
    "og:url": "https://dev.to/amananandrai/solving-the-mystery-of-12-02-2021-498e",
    "og:title": "Solving the mystery of 12.02.2021 !!",
    "og:description": "We come across symmetry on a daily basis in our lives in many different ways, in both the natural and...",
    "og:site_name": "DEV Community",
    "og:image": "https://media2.dev.to/dynamic/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu85f6l15n90vy9l4gtis.jpg",
    "twitter:site": "@thepracticaldev",
    "twitter:creator": "@",
    "twitter:title": "Solving the mystery of 12.02.2021 !!",
    "twitter:description": "We come across symmetry on a daily basis in our lives in many different ways, in both the natural and...",
    "twitter:card": "summary_large_image",
    "twitter:widgets:new-embed-design": "on",
    "twitter:image:src": "https://media2.dev.to/dynamic/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu85f6l15n90vy9l4gtis.jpg"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/2c808ada50a3/code/body-000.txt",
      "chars": 679,
      "language": "text"
    },
    {
      "file": "attachments/2c808ada50a3/code/body-001.txt",
      "chars": 689,
      "language": "text"
    },
    {
      "file": "attachments/2c808ada50a3/code/body-002.txt",
      "chars": 546,
      "language": "text"
    },
    {
      "file": "attachments/2c808ada50a3/code/body-003.txt",
      "chars": 275,
      "language": "text"
    },
    {
      "file": "attachments/2c808ada50a3/code/body-004.txt",
      "chars": 159,
      "language": "text"
    },
    {
      "file": "attachments/2c808ada50a3/code/body-005.txt",
      "chars": 250,
      "language": "text"
    },
    {
      "file": "attachments/2c808ada50a3/code/body-006.txt",
      "chars": 260,
      "language": "text"
    },
    {
      "file": "attachments/2c808ada50a3/code/body-007.txt",
      "chars": 157,
      "language": "text"
    }
  ],
  "images": [],
  "audio": [],
  "videos": [],
  "links": [],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:49:20Z",
  "source_url": "https://dev.to/amananandrai/solving-the-mystery-of-12-02-2021-498e",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 5715,
  "expected_body_images": 0,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/2c808ada50a3/pages/source.html",
  "local_html": "attachments/2c808ada50a3/pages/article.html",
  "body_base_path": "attachments/2c808ada50a3/pages/",
  "body_markdown_path": "attachments/2c808ada50a3/pages/article.md"
}