Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View paulosuzart's full-sized avatar

Paulo Suzart paulosuzart

View GitHub Profile
@paulosuzart
paulosuzart / Application.java
Created November 11, 2021 10:34
first repeated char
public class Application {
static String solve(String word) {
Objects.requireNonNull(word);
Map<String, Integer> chars = new LinkedHashMap<String, Integer>();
for (int i = 0; i < word.length(); i++) {
var w = word.charAt(i);
chars.compute(String.valueOf(w), (k, v) -> {
if (v != null) {
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@paulosuzart
paulosuzart / post.js
Last active July 17, 2020 13:02
post.js
import React, { useEffect } from "react";
import { connect, styled } from "frontity";
import Link from "./link";
import List from "./list";
import Item from "./list/list-item";
import FeaturedMedia from "./featured-media";
const Post = ({ state, actions, libraries }) => {
// Get information about the current URL.
const promiseWithTimeout = (timeoutMs, promise, failureMessage) => {
var timeoutHandle;
const timeoutPromise = new Promise((resolve, reject) => {
timeoutHandle = setTimeout(() => reject(new Error(failureMessage)), timeoutMs);
});
return Promise.race([
promise,
timeoutPromise,
]).then((result) => {
package com;
import static java.lang.String.valueOf;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
package example.controller
import arrow.fx.reactor.FluxK
import arrow.fx.reactor.extensions.fluxk.async.effect
import arrow.fx.reactor.value
import example.ParserService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Flux
@paulosuzart
paulosuzart / guess.rs
Last active June 13, 2019 14:13
book guess game modified a bit for fun
use std::cmp::Ordering;
use std::io;
use rand::Rng;
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
let mut attempts : Vec<u32> = Vec::new();
package io.github.pauljamescleary.petstore.domain.destination
import scala.language.higherKinds
trait DestinationRepositoryAlgebra[F[_]] {
def destinations(departureId: Long): F[List[Long]]
}
public class FindOutlier {
public static int find(int[] numbers) {
int lastOdd = 0;
int lastEven = 0;
int totalOdd = 0;
int totalEven = 0;
for (int i = 0; i < numbers.length; i++) {
@paulosuzart
paulosuzart / solve_students.py
Last active November 18, 2018 22:13
solve_students.py
def solve(students, music):
s = students[:] # simply copy the list to not mutate
zeroed_music = music - 1 # shit music index to 0
delete_at = zeroed_music % len(s) # decides where to delete mod the size of students
while len(s) > 1:
print('Considering students %s and index %s' % (s, delete_at))
del s[delete_at]
delete_at = (delete_at + zeroed_music) % len(s)
return s[0]