Skip to content

Instantly share code, notes, and snippets.

@MVAodhan
MVAodhan / main.go
Created February 4, 2024 05:06
rwc-iq-29-02-24
package main
import (
"fmt"
"log"
"strconv"
"strings"
)
var daysInMonth = make(map[string]int)
/**
* Given two integers, generate a “fibonacci-like” sequence of n digits
* (where the next number in the pattern is the sum of the previous two numbers).
* Extra credit: Given a sequence, determine if the sequence is “fibonacci-like”.
*/
let n = 5
/**
* Write a function to output the ordinal suffix of a positive integer
* concatenated to an inputted number.
*
* > ordinal(3)
> '3rd'
> ordinal(57)
> '57th'
*/
function* fromTo(x, y) {
for (let i = x; i <= y; i++) {
yield i;
}
}
let fn = fromTo(5, 7);
let fnA = [...fn];
const gen=()=>{
// This week’s question:
// Given a list, swap every two adjacent nodes. Something to think about: How would your code change if this were a linked list, versus an array?
const args = [2, 1, 4, 3];
const swapPairs = (args) => {
let secondInPair = [];
let firstInPair = [];
let swapedPairs = [];
let error = 'Input Array not even, please provide an array with an even number of children'
const numberOfOnes = (num) => {
let total = 0;
let arraysToEval = [];
for (let i = 1; i <= num; i++) {
let iStr = i.toString();
let iStrArray = [...iStr];
if (iStrArray.indexOf('1') != -1) {
arraysToEval = [...arraysToEval, iStrArray];
}
};
type List = number[];
let listA: List = [1, 4, 5, 6];
let listB: List = [2, 3, 4, 5, 6];
const biggerArray = (listA: List, listB: List) => {
let greater: List;
let lesser: List;
if (listA.length > listB.length) {
greater = listA;
let listA = [1, 4, 5, 6];
let listB = [2, 3, 4, 5, 6];
const biggerArray = (listA, listB) => {
let greater;
let lesser;
if (listA.length > listB.length) {
greater = listA
lesser = listB;
}else {
const hideEmail = (email) => {
let emailParts = email.split('@');
let letters = [...emailParts[0]];
let lettersCopy = [...letters]
const first = lettersCopy.shift()
const last = lettersCopy.pop()
let blanks = []