Skip to content

Instantly share code, notes, and snippets.

// Challenge 1
// Write Test cases for given challenges
// Challenge 2
// Sudoku Validation
// Write a sudoku validator. This function should return true if the 2-D array represents a valid sudoku and false otherwise. To be a valid sudoku:
//
// - Each row must have the digits from 1 to 9 exactly once.
// - Each column must have the digits from 1 to 9 exactly once.
// - Each 3x3 box must have the digits from 1 to 9 exactly once.
AppBar(
title: Text('McLaren Chat - ${widget.chatID}'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.exit_to_app),
onPressed: () async {
await FirebaseAuth.instance.signOut();
Navigator.pushReplacementNamed(context, '/');
},
),
@McLarenCollege
McLarenCollege / SimpleQueue.js
Created January 13, 2020 04:26
Simple Queue Template
class SimpleQueue {
constructor(size) {
this.queue = [];
this.maxLength = size;
}
enqueue(item) {
// Only change code below this line
// Only change code above this line
@McLarenCollege
McLarenCollege / movies_data.json
Created April 1, 2020 06:14
Movies Data JSON
[
{
"id": "1",
"title": "Game Night",
"year": "2018",
"genres": [
"Action",
"Comedy",
"Crime"
],

This code is not working as expected. Explain why.

List<String> getAll(List<String> urls) {
  List<String> results = [];
  urls.forEach((String url) async {
    var result = await get(url);
    results.add(result.body);
  });
 return results;
import React from "react";
class EnquiryForm extends React.Component {
state = {
customerName: '',
};
constructor(props) {
super(props);
this.handelNameChange = this.handelNameChange.bind(this);

Strong Password

Time allowed: 25 mins

Create a function that takes a candidate password and returns the minimum number of extra characters needed to make it a strong password.

A password is considered strong if it satisfies the following criteria:

  • Its length is at least 6.
  • It contains at least one digit.

The Dice Game

Allowed Time: 1 hour

Four friends are playing a simple dice game (players are denoted p1, p2, p3, and p4). In each round, all players roll a pair of six-sided dice. The player with the lowest total score is removed. If the lowest score is shared by two or more players, the player in that group with the lowest score from their first die is removed. If the lowest score is still shared (i.e. two or more players have the same rolls in the same order), then all players roll again. This process continues until one player remains. Given an array of scores only (given in player order for each round), return the winning player.

Examples

diceGame([[6, 2], [4, 3], [3, 4], [5, 4], [3, 5], [1, 5], [4, 3], [1, 5], [1, 5], [5, 6], [2, 2]]) ➞ "p1"

The Connell Sequence

Allowed Time: 55 minutes

The Connell sequence can be represented as a growing series of alternating numbered lines:

If the line number is odd, the line contains a quantity of odd numbers equal to the line number, sorted ascendingly. If the line number is even, the line contains a quantity of even numbers equal to the line number, sorted ascendingly. Every number in a line is equal to its next term less 2, and the last number (and highest) number of the sequence has to be the square of the line number. Numbers have to be unique: there are no duplicates in the sequence, and not every number is in the sequence.

void main() {
RegExp expression = RegExp(r'[cmf]an');
Iterable<RegExpMatch> matches = expression.allMatches(searchString);
matches.forEach((match) => print(match.group(0)));
}
String searchString = "Ana Bob Cpc aax bby ccz";
// How do we match 'Ana', 'Bob' and 'Cpc'?