{"id":644,"date":"2024-11-24T13:55:00","date_gmt":"2024-11-24T13:55:00","guid":{"rendered":"https:\/\/optimrepair.net\/?p=644"},"modified":"2025-07-02T17:59:45","modified_gmt":"2025-07-02T16:59:45","slug":"this-christmas-technology-at-the-service-of-tradition","status":"publish","type":"post","link":"https:\/\/optimrepair.net\/en\/this-christmas-technology-at-the-service-of-tradition\/","title":{"rendered":"The power of programming in the service of Christmas: Organise an automated Secret Santa"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"644\" class=\"elementor elementor-644\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-63a6a3fb e-flex e-con-boxed e-con e-parent\" data-id=\"63a6a3fb\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-2601b475 elementor-widget elementor-widget-text-editor\" data-id=\"2601b475\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\n<h3 class=\"wp-block-heading\" dir=\"auto\"><strong>This Christmas, technology in the service of tradition<\/strong><\/h3>\n<p class=\"body\" dir=\"auto\">Christmas is a time of joy, reunions and, of course, presents. One of the most popular traditions at this time of year is the\u2019<strong>Secret Santa<\/strong>, A fun and affordable way to spread smiles without emptying your wallet. But let's be honest: organising a Secret Santa isn't as magical as it seems. You've got repeated names, someone always misses out, the assignments are obvious\u2026 and in the end, there's always someone complaining.<\/p>\n<p class=\"body\" dir=\"auto\">What if I told you that technology can solve this mess with elegance? With a simple programme, you can run the Secret Santa draw without any complications, errors or cheating. What's more, you won't just be able to use it, but also customise it, understand it and, who knows, perhaps take your first steps into the world of programming.<\/p>\n<p class=\"body\" dir=\"auto\">A\u00a0<strong>Optimum Repair SL\u2122<\/strong>, We love combining tradition and innovation. This little Secret Santa programme is just one example of how technology can make our lives easier. If you have any questions, need help running it or want to learn more, please don't hesitate to get in touch with us.<\/p>\n<p class=\"body\" dir=\"auto\">We are not only experts in repairing computer equipment, but also in making technology accessible to everyone. In this article, we're giving you some software and will explain how to use and even modify a small programme written in\u00a0<strong>Java<\/strong>\u00a0that will make organising your Secret Santa as simple as clicking. Shall we?<\/p>\n<h3 dir=\"auto\"><strong>Why is programming important, even for an invisible friend?<\/strong><\/h3>\n<p class=\"body\" dir=\"auto\">We often think of programming as something remote, reserved only for experts working in tech companies. But nothing could be further from the truth. Every time you use an app, check your online banking or manage an invoice with an accounting programme, you're using tools created with lines of code.<\/p>\n<p class=\"body\" dir=\"auto\">Learning a bit of programming can open up a world of possibilities:<\/p>\n<ul dir=\"auto\">\n<li>\n<p class=\"body\" dir=\"auto\">Automate repetitive tasks.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">Better understand how the tools you use every day work.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">Create small, useful apps for your everyday life, like the one we're presenting to you today.<\/p>\n<\/li>\n<\/ul>\n<p class=\"body\" dir=\"auto\">This Secret Santa programme is a perfect example: a simple idea that can save you time and headaches while adding a bit of technology to Christmas traditions.<\/p>\n<h3 dir=\"auto\"><strong>How does the Secret Santa programme work?<\/strong><\/h3>\n<p class=\"body\" dir=\"auto\">This programme is written in\u00a0<strong>Java<\/strong>, a programming language that, despite being very powerful, can seem accessible even to beginners. Its function is simple but effective:<\/p>\n<ol dir=\"auto\">\n<li>\n<p class=\"body\" dir=\"auto\">Read a list of names that you can easily edit in a text file.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">It carries out a completely random draw among the participants.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">Generate an individual file for each person, with the name of the person they are to give the gift to.<\/p>\n<\/li>\n<\/ol>\n<p class=\"body\" dir=\"auto\">Why is it useful? Because it eliminates human error and ensures that each participant can only see the recipient of their gift. And if you're curious, we also provide the full code so you can modify it as you wish or learn a bit more about how it works.<\/p>\n<h3 dir=\"auto\"><strong>Step-by-step instructions<\/strong><\/h3>\n<h4 dir=\"auto\"><strong>1. Download the files<\/strong><\/h4>\n<p class=\"body\" dir=\"auto\">The programme consists of two files:<\/p>\n<ul dir=\"auto\">\n<li>\n<p class=\"body\" dir=\"auto\">\u201c<a href=\"https:\/\/drive.google.com\/file\/d\/1QuIeQhFjYV_9-02oXjDSA9pDhVqOUCNh\/view?usp=sharing\" rel=\"nofollow noopener\" data-page-id=\"\" target=\"_blank\">Participants.txt\u201d:<\/a>\u00a0Here you will write the names of the participants.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">\u201c<a href=\"https:\/\/drive.google.com\/file\/d\/1QUnA30Q6R0a5VWgoyFlUvBPY3Gbnv2pm\/view?usp=sharing\" rel=\"nofollow noopener\" data-page-id=\"\" target=\"_blank\">FriendInvisible.bat<\/a>\u201cThe executable file that will carry out the draw.<\/p>\n<\/li>\n<\/ul>\n<h4 dir=\"auto\"><strong>2. Write the names of the participants<\/strong><\/h4>\n<p class=\"body\" dir=\"auto\">Open the participants.txt file with Notepad or any simple text editor. Enter one name per line. For example:<\/p>\n<p class=\"body\" dir=\"auto\">Anna, Marc, J\u00falia, Pere, Marta<\/p>\n<p class=\"body\" dir=\"auto\">Save the file.<\/p>\n<h4 dir=\"auto\"><strong>3. Run the programme<\/strong><\/h4>\n<p class=\"body\" dir=\"auto\">Double-click on the AmicInvisible.bat file. The program:<\/p>\n<ul dir=\"auto\">\n<li>\n<p class=\"body\" dir=\"auto\">It will read the names from the file.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">They will assign a recipient to each participant.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">It will generate files like these:<\/p>\n<ul dir=\"auto\">\n<li>\n<p class=\"body\" dir=\"auto\">Anna.txt: \u201cYou have to give Pere a present.\u201d<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\">J\u00falia.txt: \u201cYou have to get Marta a present.\u201d<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p class=\"body\" dir=\"auto\">Each file will be saved automatically in the same directory.<\/p>\n<h4 dir=\"auto\"><strong>4. Send the results<\/strong><\/h4>\n<p class=\"body\" dir=\"auto\">Send each file to its recipient (via email, WhatsApp, etc.). That way, everyone will know who they're meant to give the gift to, and the mystery will be guaranteed!<\/p>\n<h3 dir=\"auto\"><strong>Learn more: The code explained step by step<\/strong><\/h3>\n<p class=\"body\" dir=\"auto\">Here is the complete code for the programme. Not only is it easy to understand, but it also includes annotations so you can learn exactly what each line does and, if you wish, modify or add complexity and features, even optimise the code!<\/p>\n<p class=\"body\" dir=\"auto\">import\u00a0<a href=\"http:\/\/java.io\/\" rel=\"nofollow noopener\" target=\"_blank\">Java I\/O<\/a>.*; \/\/ Allows managing files<\/p>\n<p class=\"body\" dir=\"auto\">import java.nio.file.*; \/\/ Facilitates the reading of the names file<\/p>\n<p class=\"body\" dir=\"auto\">import java.util.*; \/\/ To work with lists and shuffle randomly<\/p>\n<p class=\"body\" dir=\"auto\">public class AmicInvisible {<\/p>\n<p class=\"body\" dir=\"auto\">public static void main(String[] args) throws IOException { \/\/ Read the names from the file \u201cparticipants.txt\"<\/p>\n<p class=\"body\" dir=\"auto\">List participants = Files.readAllLines(Paths.get(\u201cparticipants.txt\u201d)); \/\/ Create a copy of the names and shuffle them<\/p>\n<p class=\"body\" dir=\"auto\">List recipients = new ArrayList(participants);<\/p>\n<p class=\"body\" dir=\"auto\">Collections.shuffle(recipients); \/\/ Checks that nobody gives themselves a gift<\/p>\n<p class=\"body\" dir=\"auto\">while (!assignmentsCorrect(participants, recipients)) {<\/p>\n<p class=\"body\" dir=\"auto\">Shuffle the recipients.;<\/p>\n<p class=\"body\" dir=\"auto\">Generate a .txt file for each participant with the recipient's name.<\/p>\n<p class=\"body\" dir=\"auto\">for (int i = 0; i &lt; participants.size(); i++) {<\/p>\n<p class=\"body\" dir=\"auto\">String participant = participants.get(i);<\/p>\n<p class=\"body\" dir=\"auto\">String recipient = recipients.get(i);<\/p>\n<p class=\"body\" dir=\"auto\">FileWriter writer = new FileWriter(participant + \u201c.txt\u201d);<\/p>\n<p class=\"body\" dir=\"auto\">You must give a gift to: + recipient;<\/p>\n<p class=\"body\" dir=\"auto\">Close the writer.;<\/p>\n<p class=\"body\" dir=\"auto\">}<\/p>\n<p class=\"body\" dir=\"auto\">The files have been generated correctly!;<\/p>\n<p class=\"body\" dir=\"auto\">}\/\/ Check that nobody gives themselves a gift<\/p>\n<p class=\"body\" dir=\"auto\">private static boolean correctAssignments(List participants, List recipients) {<\/p>\n<p class=\"body\" dir=\"auto\">for (int i = 0; i &lt; participants.size(); i++) {<\/p>\n<p class=\"body\" dir=\"auto\">if (participants.get(i).equals(destinatari.get(i))) {<\/p>\n<p class=\"body\" dir=\"auto\">return false;<\/p>\n<p class=\"body\" dir=\"auto\">}<\/p>\n<p class=\"body\" dir=\"auto\">}<\/p>\n<p class=\"body\" dir=\"auto\">return true;<\/p>\n<p class=\"body\" dir=\"auto\">}<\/p>\n<p class=\"body\" dir=\"auto\">}<\/p>\n<h3 dir=\"auto\"><strong>What does each part of the code do?<\/strong><\/h3>\n<ul dir=\"auto\">\n<li>\n<p class=\"body\" dir=\"auto\"><strong>Imports<\/strong>They allow you to work with files, lists and random numbers.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\"><strong>Reading names<\/strong>Open the participants.txt file and save the names.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\"><strong>Mixing and validation<\/strong>Ensure that no participant cheats themselves.<\/p>\n<\/li>\n<li>\n<p class=\"body\" dir=\"auto\"><strong>File creation<\/strong>Generate a custom .txt file for each participant.<\/p>\n<\/li>\n<\/ul>\n<p class=\"body\" dir=\"auto\">If you want to customise it, you can edit the file's message or add conditions (for example, that couples don't give gifts to each other).<\/p>\n<p class=\"body\" dir=\"auto\">Have a Christmas full of technology\u2026 and of very special presents!<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Aquest Nadal, tecnologia al servei de la tradici\u00f3 El Nadal \u00e9s una \u00e8poca d\u2019alegria, retrobaments i, per descomptat, regals. Una de les tradicions m\u00e9s populars per aquestes dates \u00e9s l\u2019amic invisible, una manera divertida i econ\u00f2mica de repartir somriures sense buidar la cartera. Per\u00f2 siguem sincers: organitzar un amic invisible no \u00e9s tan m\u00e0gic com [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":645,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[1],"tags":[],"class_list":["post-644","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sin-categoria"],"_links":{"self":[{"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/posts\/644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/comments?post=644"}],"version-history":[{"count":0,"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/posts\/644\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/media\/645"}],"wp:attachment":[{"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/media?parent=644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/categories?post=644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/optimrepair.net\/en\/wp-json\/wp\/v2\/tags?post=644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}