GithubHelp home page GithubHelp logo

heartland-ruby-assessment's Introduction

Photo Renaming Challenge

Mike, an avid traveler, has a collection of photos that need to be reorganized. He wants to group his photos by city, sort them by the time they were taken, and assign each photo a consecutive natural number within each city group. Additionally, he wants to rename each photo with the city name and a zero-padded number.

Problem Statement

You are given a string representing a list of photos in the following format:

"<photoname>.<extension>, <city_name>, yyyy-mm-dd hh:mm:ss"
  • <photoname> is the name of the photo.
  • <extension> is the file extension ("jpg," "png," or "jpeg").
  • <city_name> is the name of the city where the photo was taken.
  • yyyy-mm-dd hh:mm:ss is the timestamp of when the photo was taken.

Your task is to write a function that takes this input string and returns a string representing the list of new names for all photos, following Mike's renaming criteria.

Function Signature

def solution(s: str) -> str:
    pass

Example

For example, given the input string:

"photo.jpg, Krakow, 2013-09-05 14:08:15
Mike.png, London, 2015-06-20 15:13:22
myFriends.png, Krakow, 2013-09-05 14:07:13
Eiffel.jpg, Florianopolis, 2015-07-23 08:03:02
pisatower.jpg, Florianopolis, 2015-07-22 23:59:59
BOB.jpg, London, 2015-08-05 00:02:03
notredame.png, Florianopolis, 2015-09-01 12:00:00
me.jpg, Krakow, 2013-09-06 15:40:22
a.png, Krakow, 2016-02-13 13:33:50
b.jpg, Krakow, 2016-01-02 15:12:22
c.jpg, Krakow, 2016-01-02 14:34:30
d.jpg, Krakow, 2016-01-02 15:15:01
e.png, Krakow, 2016-01-02 09:49:09
f.png, Krakow, 2016-01-02 10:55:32
g.jpg, Krakow, 2016-02-29 22:13:11"

Your function should return:

Krakow02.jpg
London1.png
Krakow01.png
Florianopolis2.jpg
Florianopolis1.jpg
London2.jpg
Florianopolis3.png
Krakow03.jpg
Krakow09.png
Krakow07.jpg
Krakow06.jpg
Krakow08.jpg
Krakow04.png
Krakow05.png
Krakow10.jpg

The photos are grouped by city, sorted by timestamp, and assigned numbers as per Mike's request.

Constraints

  • M is an integer within the range (1..100).
  • Each year is an integer within the range (2000..2020).
  • Each line of the input string follows the specified format and is separated by newline characters.
  • Photo names and city names consist only of English alphabet letters (1-20 characters).
  • City names start with a capital letter followed by lowercase letters.
  • No two photos from the same location share the same date and time.
  • Each extension is "jpg," "png," or "jpeg."

In your solution, focus on correctness and efficiency.

heartland-ruby-assessment's People

Contributors

spencer814 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.