The solutions of tomorrow come from the strength of many in a diverse society, Prime Minister Justin Trudeau told students attending Canada's biggest hackathon being held at the University of Waterloo this weekend.

Trudeau made a brief but inspirational and energy-packed pitch for the value of diversity during the opening ceremonies for Hack the North, an event which brings together 1,000 students from top universities in 22 countries to collaborate on technology ideas and solutions.

Hack the North is organized by Techyon, a student-run non-profit organization, in partnership with Waterloo Engineering. The participants were chosen from a pool of 6,200 applicants from 72 countries around the world.

As he took the stage at the boisterous gathering, Trudeau told the students he is a bit jealous of their hackathon adventure. "I love to fiddle around with gadgets, to push myself, challenge myself to meet new people and figure things out, and you guys are up for a weekend of doing just that," he said.

But he encouraged the students to not just hack technology solutions, but to think of themselves as leaders in creating a better world.

"You are in a unique position to shape the future," Trudeau said. "You have the tools not only to seize the countless opportunities brought about by a new economy based on innovation, but to help others do the same."

Just as the spirit of collaboration and relying on mentors and colleagues at an event like Hack the North helps inspire and create technology solutions, that same spirit of embracing others, including those who are different, is what makes a country great, Trudeau said.

"Diversity is our strength," Trudeau said. "Leaning on each other, listening to each other is at the heart of why Canada is doing so well right now."

Around the world there are conflicts between people who are pointing to differences, but Canada has learned through experience that differences of opinions, perspectives and backgrounds can be an amazing source of strength, Trudeau said.

Trudeau's stop in Waterloo capped off a whirlwind tour that began in the morning in Montreal, where Facebook announced the launch of an artificial intelligence research lab. It is one of several big technology giants that have chosen Canada as a place for the development of artificial intelligence.

Trudeau said diversity is one of the reasons that those technology giants see Canada as a good place to be investing in.

"Companies like Google and Microsoft have chosen Canada because our people are educated, ambitious and innovative, which is good news for all of you, but also because we know that just because someone thinks differently from you, it's not a reason to push them away," he said.

"If, together, you can figure out a new way of doing something, a new way of solving problems, that will bring positive influences into the world. That's what diversity is," Trudeau said.

Trudeau said the "quick learners, creative thinkers and natural risk-takers" at the hackathon are also natural leaders. "You have the power to enact positive change, right here, right now," Trudeau said.

"The world needs you to lead. We need you to tackle some of the most pressing challenges facing your communities, your cities and your country."

He also encouraged the brilliant young minds from other countries to think of Canada as a home. "When you are starting a business or looking to change the world, remember that you can do both, right here in Canada," Trudeau said. "In fact, this is one of the best places in the world to do either of those things."

He said Canada is brimming with innovation and talent. "But if you decide to challenge yourself across the globe with more schooling or better job opportunities, do it secure in the knowledge that Canada will be waiting for you whenever you choose to come home, or to make this your home," he said.

"Dream big, work hard and have fun," Trudeau told the cheering students as he left the stage. "We are counting on all of you!"